layout/forms/nsGfxRadioControlFrame.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsGfxRadioControlFrame.h"
michael@0 7 #include "nsRenderingContext.h"
michael@0 8 #include "nsDisplayList.h"
michael@0 9
michael@0 10 using namespace mozilla;
michael@0 11
michael@0 12 nsIFrame*
michael@0 13 NS_NewGfxRadioControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
michael@0 14 {
michael@0 15 return new (aPresShell) nsGfxRadioControlFrame(aContext);
michael@0 16 }
michael@0 17
michael@0 18 NS_IMPL_FRAMEARENA_HELPERS(nsGfxRadioControlFrame)
michael@0 19
michael@0 20 nsGfxRadioControlFrame::nsGfxRadioControlFrame(nsStyleContext* aContext):
michael@0 21 nsFormControlFrame(aContext)
michael@0 22 {
michael@0 23 }
michael@0 24
michael@0 25 nsGfxRadioControlFrame::~nsGfxRadioControlFrame()
michael@0 26 {
michael@0 27 }
michael@0 28
michael@0 29 #ifdef ACCESSIBILITY
michael@0 30 a11y::AccType
michael@0 31 nsGfxRadioControlFrame::AccessibleType()
michael@0 32 {
michael@0 33 return a11y::eHTMLRadioButtonType;
michael@0 34 }
michael@0 35 #endif
michael@0 36
michael@0 37 //--------------------------------------------------------------
michael@0 38 // Draw the dot for a non-native radio button in the checked state.
michael@0 39 static void
michael@0 40 PaintCheckedRadioButton(nsIFrame* aFrame,
michael@0 41 nsRenderingContext* aCtx,
michael@0 42 const nsRect& aDirtyRect,
michael@0 43 nsPoint aPt)
michael@0 44 {
michael@0 45 // The dot is an ellipse 2px on all sides smaller than the content-box,
michael@0 46 // drawn in the foreground color.
michael@0 47 nsRect rect(aPt, aFrame->GetSize());
michael@0 48 rect.Deflate(aFrame->GetUsedBorderAndPadding());
michael@0 49 rect.Deflate(nsPresContext::CSSPixelsToAppUnits(2),
michael@0 50 nsPresContext::CSSPixelsToAppUnits(2));
michael@0 51
michael@0 52 aCtx->SetColor(aFrame->StyleColor()->mColor);
michael@0 53 aCtx->FillEllipse(rect);
michael@0 54 }
michael@0 55
michael@0 56 void
michael@0 57 nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
michael@0 58 const nsRect& aDirtyRect,
michael@0 59 const nsDisplayListSet& aLists)
michael@0 60 {
michael@0 61 nsFormControlFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
michael@0 62
michael@0 63 if (!IsVisibleForPainting(aBuilder))
michael@0 64 return;
michael@0 65
michael@0 66 if (IsThemed())
michael@0 67 return; // The theme will paint the check, if any.
michael@0 68
michael@0 69 bool checked = true;
michael@0 70 GetCurrentCheckState(&checked); // Get check state from the content model
michael@0 71 if (!checked)
michael@0 72 return;
michael@0 73
michael@0 74 aLists.Content()->AppendNewToTop(new (aBuilder)
michael@0 75 nsDisplayGeneric(aBuilder, this, PaintCheckedRadioButton,
michael@0 76 "CheckedRadioButton",
michael@0 77 nsDisplayItem::TYPE_CHECKED_RADIOBUTTON));
michael@0 78 }

mercurial