LCOV - code coverage report
Current view: directory - layout/forms - nsGfxRadioControlFrame.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 32 0 0.0 %
Date: 2012-06-02 Functions: 9 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #include "nsGfxRadioControlFrame.h"
      39                 : #include "nsIContent.h"
      40                 : #include "nsCOMPtr.h"
      41                 : #include "nsCSSRendering.h"
      42                 : #include "nsRenderingContext.h"
      43                 : #ifdef ACCESSIBILITY
      44                 : #include "nsAccessibilityService.h"
      45                 : #endif
      46                 : #include "nsIServiceManager.h"
      47                 : #include "nsITheme.h"
      48                 : #include "nsDisplayList.h"
      49                 : #include "nsCSSAnonBoxes.h"
      50                 : 
      51                 : nsIFrame*
      52               0 : NS_NewGfxRadioControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
      53                 : {
      54               0 :   return new (aPresShell) nsGfxRadioControlFrame(aContext);
      55                 : }
      56                 : 
      57               0 : NS_IMPL_FRAMEARENA_HELPERS(nsGfxRadioControlFrame)
      58                 : 
      59               0 : nsGfxRadioControlFrame::nsGfxRadioControlFrame(nsStyleContext* aContext):
      60               0 :   nsFormControlFrame(aContext)
      61                 : {
      62               0 : }
      63                 : 
      64               0 : nsGfxRadioControlFrame::~nsGfxRadioControlFrame()
      65                 : {
      66               0 : }
      67                 : 
      68                 : #ifdef ACCESSIBILITY
      69                 : already_AddRefed<nsAccessible>
      70               0 : nsGfxRadioControlFrame::CreateAccessible()
      71                 : {
      72               0 :   nsAccessibilityService* accService = nsIPresShell::AccService();
      73               0 :   if (accService) {
      74                 :     return accService->CreateHTMLRadioButtonAccessible(mContent,
      75               0 :                                                        PresContext()->PresShell());
      76                 :   }
      77                 : 
      78               0 :   return nsnull;
      79                 : }
      80                 : #endif
      81                 : 
      82                 : //--------------------------------------------------------------
      83                 : // Draw the dot for a non-native radio button in the checked state.
      84                 : static void
      85               0 : PaintCheckedRadioButton(nsIFrame* aFrame,
      86                 :                         nsRenderingContext* aCtx,
      87                 :                         const nsRect& aDirtyRect,
      88                 :                         nsPoint aPt)
      89                 : {
      90                 :   // The dot is an ellipse 2px on all sides smaller than the content-box,
      91                 :   // drawn in the foreground color.
      92               0 :   nsRect rect(aPt, aFrame->GetSize());
      93               0 :   rect.Deflate(aFrame->GetUsedBorderAndPadding());
      94                 :   rect.Deflate(nsPresContext::CSSPixelsToAppUnits(2),
      95               0 :                nsPresContext::CSSPixelsToAppUnits(2));
      96                 : 
      97               0 :   aCtx->SetColor(aFrame->GetStyleColor()->mColor);
      98               0 :   aCtx->FillEllipse(rect);
      99               0 : }
     100                 : 
     101                 : NS_IMETHODIMP
     102               0 : nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
     103                 :                                          const nsRect&           aDirtyRect,
     104                 :                                          const nsDisplayListSet& aLists)
     105                 : {
     106                 :   nsresult rv = nsFormControlFrame::BuildDisplayList(aBuilder, aDirtyRect,
     107               0 :                                                      aLists);
     108               0 :   NS_ENSURE_SUCCESS(rv, rv);
     109                 :   
     110               0 :   if (!IsVisibleForPainting(aBuilder))
     111               0 :     return NS_OK;
     112                 :   
     113               0 :   if (IsThemed())
     114               0 :     return NS_OK; // The theme will paint the check, if any.
     115                 : 
     116               0 :   bool checked = true;
     117               0 :   GetCurrentCheckState(&checked); // Get check state from the content model
     118               0 :   if (!checked)
     119               0 :     return NS_OK;
     120                 :     
     121                 :   return aLists.Content()->AppendNewToTop(new (aBuilder)
     122                 :     nsDisplayGeneric(aBuilder, this, PaintCheckedRadioButton,
     123                 :                      "CheckedRadioButton",
     124               0 :                      nsDisplayItem::TYPE_CHECKED_RADIOBUTTON));
     125                 : }

Generated by: LCOV version 1.7