LCOV - code coverage report
Current view: directory - layout/svg/base/src - nsSVGAFrame.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 43 0 0.0 %
Date: 2012-06-02 Functions: 15 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 the Mozilla SVG project.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Robert Longson.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2007
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Robert Longson <longsonr@gmail.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "nsSVGTSpanFrame.h"
      40                 : #include "nsISVGGlyphFragmentNode.h"
      41                 : #include "nsSVGGraphicElement.h"
      42                 : #include "nsSVGAElement.h"
      43                 : #include "nsSVGUtils.h"
      44                 : #include "gfxMatrix.h"
      45                 : #include "SVGLengthList.h"
      46                 : 
      47                 : // <a> elements can contain text. nsSVGGlyphFrames expect to have
      48                 : // a class derived from nsSVGTextContainerFrame as a parent. We
      49                 : // also need something that implements nsISVGGlyphFragmentNode to get
      50                 : // the text DOM to work.
      51                 : 
      52                 : using namespace mozilla;
      53                 : 
      54                 : typedef nsSVGTSpanFrame nsSVGAFrameBase;
      55                 : 
      56                 : class nsSVGAFrame : public nsSVGAFrameBase
      57               0 : {
      58                 :   friend nsIFrame*
      59                 :   NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
      60                 : protected:
      61               0 :   nsSVGAFrame(nsStyleContext* aContext) :
      62               0 :     nsSVGAFrameBase(aContext) {}
      63                 : 
      64                 : public:
      65                 :   NS_DECL_FRAMEARENA_HELPERS
      66                 : 
      67                 : #ifdef DEBUG
      68                 :   NS_IMETHOD Init(nsIContent*      aContent,
      69                 :                   nsIFrame*        aParent,
      70                 :                   nsIFrame*        aPrevInFlow);
      71                 : #endif
      72                 : 
      73                 :   // nsIFrame:
      74                 :   NS_IMETHOD  AttributeChanged(PRInt32         aNameSpaceID,
      75                 :                                nsIAtom*        aAttribute,
      76                 :                                PRInt32         aModType);
      77                 : 
      78                 :   /**
      79                 :    * Get the "type" of the frame
      80                 :    *
      81                 :    * @see nsGkAtoms::svgAFrame
      82                 :    */
      83                 :   virtual nsIAtom* GetType() const;
      84                 : 
      85                 : #ifdef DEBUG
      86               0 :   NS_IMETHOD GetFrameName(nsAString& aResult) const
      87                 :   {
      88               0 :     return MakeFrameName(NS_LITERAL_STRING("SVGA"), aResult);
      89                 :   }
      90                 : #endif
      91                 :   // nsISVGChildFrame interface:
      92                 :   virtual void NotifySVGChanged(PRUint32 aFlags);
      93                 :   
      94                 :   // nsSVGContainerFrame methods:
      95                 :   virtual gfxMatrix GetCanvasTM();
      96                 : 
      97                 :   // nsSVGTextContainerFrame methods:
      98                 :   virtual void GetXY(mozilla::SVGUserUnitList *aX, mozilla::SVGUserUnitList *aY);
      99                 :   virtual void GetDxDy(mozilla::SVGUserUnitList *aDx, mozilla::SVGUserUnitList *aDy);
     100               0 :   virtual const SVGNumberList* GetRotate() {
     101               0 :     return nsnull;
     102                 :   }
     103                 : 
     104                 : private:
     105                 :   nsAutoPtr<gfxMatrix> mCanvasTM;
     106                 : };
     107                 : 
     108                 : //----------------------------------------------------------------------
     109                 : // Implementation
     110                 : 
     111                 : nsIFrame*
     112               0 : NS_NewSVGAFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
     113                 : {
     114               0 :   return new (aPresShell) nsSVGAFrame(aContext);
     115                 : }
     116                 : 
     117               0 : NS_IMPL_FRAMEARENA_HELPERS(nsSVGAFrame)
     118                 : 
     119                 : //----------------------------------------------------------------------
     120                 : // nsIFrame methods
     121                 : #ifdef DEBUG
     122                 : NS_IMETHODIMP
     123               0 : nsSVGAFrame::Init(nsIContent* aContent,
     124                 :                   nsIFrame* aParent,
     125                 :                   nsIFrame* aPrevInFlow)
     126                 : {
     127               0 :   nsCOMPtr<nsIDOMSVGAElement> elem = do_QueryInterface(aContent);
     128               0 :   NS_ASSERTION(elem,
     129                 :                "Trying to construct an SVGAFrame for a "
     130                 :                "content element that doesn't support the right interfaces");
     131                 : 
     132               0 :   return nsSVGAFrameBase::Init(aContent, aParent, aPrevInFlow);
     133                 : }
     134                 : #endif /* DEBUG */
     135                 : 
     136                 : NS_IMETHODIMP
     137               0 : nsSVGAFrame::AttributeChanged(PRInt32         aNameSpaceID,
     138                 :                               nsIAtom*        aAttribute,
     139                 :                               PRInt32         aModType)
     140                 : {
     141               0 :   if (aNameSpaceID == kNameSpaceID_None &&
     142                 :       aAttribute == nsGkAtoms::transform) {
     143                 : 
     144               0 :     NotifySVGChanged(TRANSFORM_CHANGED);
     145                 :   }
     146                 : 
     147               0 :  return NS_OK;
     148                 : }
     149                 : 
     150                 : nsIAtom *
     151               0 : nsSVGAFrame::GetType() const
     152                 : {
     153               0 :   return nsGkAtoms::svgAFrame;
     154                 : }
     155                 : 
     156                 : //----------------------------------------------------------------------
     157                 : // nsISVGChildFrame methods
     158                 : 
     159                 : void
     160               0 : nsSVGAFrame::NotifySVGChanged(PRUint32 aFlags)
     161                 : {
     162               0 :   NS_ABORT_IF_FALSE(!(aFlags & DO_NOT_NOTIFY_RENDERING_OBSERVERS) ||
     163                 :                     (GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD),
     164                 :                     "Must be NS_STATE_SVG_NONDISPLAY_CHILD!");
     165                 : 
     166               0 :   NS_ABORT_IF_FALSE(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
     167                 :                     "Invalidation logic may need adjusting");
     168                 : 
     169               0 :   if (aFlags & TRANSFORM_CHANGED) {
     170                 :     // make sure our cached transform matrix gets (lazily) updated
     171               0 :     mCanvasTM = nsnull;
     172                 :   }
     173                 : 
     174               0 :   nsSVGAFrameBase::NotifySVGChanged(aFlags);
     175               0 : }
     176                 : 
     177                 : //----------------------------------------------------------------------
     178                 : // nsSVGContainerFrame methods:
     179                 : 
     180                 : gfxMatrix
     181               0 : nsSVGAFrame::GetCanvasTM()
     182                 : {
     183               0 :   if (!mCanvasTM) {
     184               0 :     NS_ASSERTION(mParent, "null parent");
     185                 : 
     186               0 :     nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
     187               0 :     nsSVGAElement *content = static_cast<nsSVGAElement*>(mContent);
     188                 : 
     189               0 :     gfxMatrix tm = content->PrependLocalTransformsTo(parent->GetCanvasTM());
     190                 : 
     191               0 :     mCanvasTM = new gfxMatrix(tm);
     192                 :   }
     193                 : 
     194               0 :   return *mCanvasTM;
     195                 : }
     196                 : 
     197                 : //----------------------------------------------------------------------
     198                 : // nsSVGTextContainerFrame methods:
     199                 : 
     200                 : void
     201               0 : nsSVGAFrame::GetXY(SVGUserUnitList *aX, SVGUserUnitList *aY)
     202                 : {
     203               0 :   aX->Clear();
     204               0 :   aY->Clear();
     205               0 : }
     206                 : 
     207                 : void
     208               0 : nsSVGAFrame::GetDxDy(SVGUserUnitList *aDx, SVGUserUnitList *aDy)
     209                 : {
     210               0 :   aDx->Clear();
     211               0 :   aDy->Clear();
     212               0 : }

Generated by: LCOV version 1.7