layout/forms/nsGfxRadioControlFrame.cpp

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     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;
    12 nsIFrame*
    13 NS_NewGfxRadioControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
    14 {
    15   return new (aPresShell) nsGfxRadioControlFrame(aContext);
    16 }
    18 NS_IMPL_FRAMEARENA_HELPERS(nsGfxRadioControlFrame)
    20 nsGfxRadioControlFrame::nsGfxRadioControlFrame(nsStyleContext* aContext):
    21   nsFormControlFrame(aContext)
    22 {
    23 }
    25 nsGfxRadioControlFrame::~nsGfxRadioControlFrame()
    26 {
    27 }
    29 #ifdef ACCESSIBILITY
    30 a11y::AccType
    31 nsGfxRadioControlFrame::AccessibleType()
    32 {
    33   return a11y::eHTMLRadioButtonType;
    34 }
    35 #endif
    37 //--------------------------------------------------------------
    38 // Draw the dot for a non-native radio button in the checked state.
    39 static void
    40 PaintCheckedRadioButton(nsIFrame* aFrame,
    41                         nsRenderingContext* aCtx,
    42                         const nsRect& aDirtyRect,
    43                         nsPoint aPt)
    44 {
    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);
    54 }
    56 void
    57 nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    58                                          const nsRect&           aDirtyRect,
    59                                          const nsDisplayListSet& aLists)
    60 {
    61   nsFormControlFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
    63   if (!IsVisibleForPainting(aBuilder))
    64     return;
    66   if (IsThemed())
    67     return; // The theme will paint the check, if any.
    69   bool checked = true;
    70   GetCurrentCheckState(&checked); // Get check state from the content model
    71   if (!checked)
    72     return;
    74   aLists.Content()->AppendNewToTop(new (aBuilder)
    75     nsDisplayGeneric(aBuilder, this, PaintCheckedRadioButton,
    76                      "CheckedRadioButton",
    77                      nsDisplayItem::TYPE_CHECKED_RADIOBUTTON));
    78 }

mercurial