Bug 853360 - Implement the coneGain part of the AudioPannerNode. r=roc
[gecko.git] / layout / forms / nsGfxRadioControlFrame.cpp
blob64461248bbac0d73332498918c335b894ffd0381
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"
8 #include "nsCOMPtr.h"
9 #include "nsCSSRendering.h"
10 #include "nsRenderingContext.h"
11 #include "nsIServiceManager.h"
12 #include "nsITheme.h"
13 #include "nsDisplayList.h"
14 #include "nsCSSAnonBoxes.h"
16 using namespace mozilla;
18 nsIFrame*
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()
35 #ifdef ACCESSIBILITY
36 a11y::AccType
37 nsGfxRadioControlFrame::AccessibleType()
39 return a11y::eHTMLRadioButtonType;
41 #endif
43 //--------------------------------------------------------------
44 // Draw the dot for a non-native radio button in the checked state.
45 static void
46 PaintCheckedRadioButton(nsIFrame* aFrame,
47 nsRenderingContext* aCtx,
48 const nsRect& aDirtyRect,
49 nsPoint aPt)
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);
62 void
63 nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
64 const nsRect& aDirtyRect,
65 const nsDisplayListSet& aLists)
67 nsFormControlFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
69 if (!IsVisibleForPainting(aBuilder))
70 return;
72 if (IsThemed())
73 return; // The theme will paint the check, if any.
75 bool checked = true;
76 GetCurrentCheckState(&checked); // Get check state from the content model
77 if (!checked)
78 return;
80 aLists.Content()->AppendNewToTop(new (aBuilder)
81 nsDisplayGeneric(aBuilder, this, PaintCheckedRadioButton,
82 "CheckedRadioButton",
83 nsDisplayItem::TYPE_CHECKED_RADIOBUTTON));