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 "nsIContent.h"
9 #include "nsCSSRendering.h"
10 #include "nsRenderingContext.h"
11 #include "nsIServiceManager.h"
13 #include "nsDisplayList.h"
14 #include "nsCSSAnonBoxes.h"
16 using namespace mozilla
;
19 NS_NewGfxRadioControlFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
)
21 return new (aPresShell
) nsGfxRadioControlFrame(aContext
);
24 NS_IMPL_FRAMEARENA_HELPERS(nsGfxRadioControlFrame
)
26 nsGfxRadioControlFrame::nsGfxRadioControlFrame(nsStyleContext
* aContext
):
27 nsFormControlFrame(aContext
)
31 nsGfxRadioControlFrame::~nsGfxRadioControlFrame()
37 nsGfxRadioControlFrame::AccessibleType()
39 return a11y::eHTMLRadioButtonType
;
43 //--------------------------------------------------------------
44 // Draw the dot for a non-native radio button in the checked state.
46 PaintCheckedRadioButton(nsIFrame
* aFrame
,
47 nsRenderingContext
* aCtx
,
48 const nsRect
& aDirtyRect
,
51 // The dot is an ellipse 2px on all sides smaller than the content-box,
52 // drawn in the foreground color.
53 nsRect
rect(aPt
, aFrame
->GetSize());
54 rect
.Deflate(aFrame
->GetUsedBorderAndPadding());
55 rect
.Deflate(nsPresContext::CSSPixelsToAppUnits(2),
56 nsPresContext::CSSPixelsToAppUnits(2));
58 aCtx
->SetColor(aFrame
->StyleColor()->mColor
);
59 aCtx
->FillEllipse(rect
);
63 nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
64 const nsRect
& aDirtyRect
,
65 const nsDisplayListSet
& aLists
)
67 nsFormControlFrame::BuildDisplayList(aBuilder
, aDirtyRect
, aLists
);
69 if (!IsVisibleForPainting(aBuilder
))
73 return; // The theme will paint the check, if any.
76 GetCurrentCheckState(&checked
); // Get check state from the content model
80 aLists
.Content()->AppendNewToTop(new (aBuilder
)
81 nsDisplayGeneric(aBuilder
, this, PaintCheckedRadioButton
,
83 nsDisplayItem::TYPE_CHECKED_RADIOBUTTON
));