1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsGfxRadioControlFrame.h"
7 #include "nsRenderingContext.h"
8 #include "nsDisplayList.h"
10 using namespace mozilla
;
13 NS_NewGfxRadioControlFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
)
15 return new (aPresShell
) nsGfxRadioControlFrame(aContext
);
18 NS_IMPL_FRAMEARENA_HELPERS(nsGfxRadioControlFrame
)
20 nsGfxRadioControlFrame::nsGfxRadioControlFrame(nsStyleContext
* aContext
):
21 nsFormControlFrame(aContext
)
25 nsGfxRadioControlFrame::~nsGfxRadioControlFrame()
31 nsGfxRadioControlFrame::AccessibleType()
33 return a11y::eHTMLRadioButtonType
;
37 //--------------------------------------------------------------
38 // Draw the dot for a non-native radio button in the checked state.
40 PaintCheckedRadioButton(nsIFrame
* aFrame
,
41 nsRenderingContext
* aCtx
,
42 const nsRect
& aDirtyRect
,
45 // The dot is an ellipse 2px on all sides smaller than the content-box,
46 // drawn in the foreground color.
47 nsRect
rect(aPt
, aFrame
->GetSize());
48 rect
.Deflate(aFrame
->GetUsedBorderAndPadding());
49 rect
.Deflate(nsPresContext::CSSPixelsToAppUnits(2),
50 nsPresContext::CSSPixelsToAppUnits(2));
52 aCtx
->SetColor(aFrame
->StyleColor()->mColor
);
53 aCtx
->FillEllipse(rect
);
57 nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
58 const nsRect
& aDirtyRect
,
59 const nsDisplayListSet
& aLists
)
61 nsFormControlFrame::BuildDisplayList(aBuilder
, aDirtyRect
, aLists
);
63 if (!IsVisibleForPainting(aBuilder
))
67 return; // The theme will paint the check, if any.
70 GetCurrentCheckState(&checked
); // Get check state from the content model
74 aLists
.Content()->AppendNewToTop(new (aBuilder
)
75 nsDisplayGeneric(aBuilder
, this, PaintCheckedRadioButton
,
77 nsDisplayItem::TYPE_CHECKED_RADIOBUTTON
));