LCOV - code coverage report
Current view: directory - layout/svg/base/src - nsSVGTSpanFrame.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 55 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                 :  * Crocodile Clips Ltd..
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2002
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      27                 :  * or 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 "nsIDOMSVGTSpanElement.h"
      40                 : #include "nsIDOMSVGAltGlyphElement.h"
      41                 : #include "nsSVGTSpanFrame.h"
      42                 : #include "nsSVGUtils.h"
      43                 : #include "nsSVGTextFrame.h"
      44                 : #include "nsSVGOuterSVGFrame.h"
      45                 : 
      46                 : //----------------------------------------------------------------------
      47                 : // Implementation
      48                 : 
      49                 : nsIFrame*
      50               0 : NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
      51                 : {
      52               0 :   return new (aPresShell) nsSVGTSpanFrame(aContext);
      53                 : }
      54                 : 
      55               0 : NS_IMPL_FRAMEARENA_HELPERS(nsSVGTSpanFrame)
      56                 : 
      57                 : nsIAtom *
      58               0 : nsSVGTSpanFrame::GetType() const
      59                 : {
      60               0 :   return nsGkAtoms::svgTSpanFrame;
      61                 : }
      62                 : 
      63                 : //----------------------------------------------------------------------
      64                 : // nsQueryFrame methods
      65                 : 
      66               0 : NS_QUERYFRAME_HEAD(nsSVGTSpanFrame)
      67               0 :   NS_QUERYFRAME_ENTRY(nsISVGGlyphFragmentNode)
      68               0 : NS_QUERYFRAME_TAIL_INHERITING(nsSVGTSpanFrameBase)
      69                 : 
      70                 : //----------------------------------------------------------------------
      71                 : // nsIFrame methods
      72                 : 
      73                 : #ifdef DEBUG
      74                 : NS_IMETHODIMP
      75               0 : nsSVGTSpanFrame::Init(nsIContent* aContent,
      76                 :                       nsIFrame* aParent,
      77                 :                       nsIFrame* aPrevInFlow)
      78                 : {
      79               0 :   NS_ASSERTION(aParent, "null parent");
      80                 : 
      81                 :   // Some of our subclasses have an aContent that's not a <svg:tspan> or are
      82                 :   // allowed to be constructed even when there is no nsISVGTextContentMetrics
      83                 :   // ancestor.  For example, nsSVGAFrame inherits from us but may have nothing
      84                 :   // to do with text.
      85               0 :   if (GetType() == nsGkAtoms::svgTSpanFrame) {
      86               0 :     nsIFrame* ancestorFrame = nsSVGUtils::GetFirstNonAAncestorFrame(aParent);
      87               0 :     NS_ASSERTION(ancestorFrame, "Must have ancestor");
      88                 : 
      89               0 :     nsSVGTextContainerFrame *metrics = do_QueryFrame(ancestorFrame);
      90               0 :     NS_ASSERTION(metrics,
      91                 :                  "trying to construct an SVGTSpanFrame for an invalid "
      92                 :                  "container");
      93                 : 
      94               0 :     nsCOMPtr<nsIDOMSVGTSpanElement> tspan = do_QueryInterface(aContent);
      95               0 :     nsCOMPtr<nsIDOMSVGAltGlyphElement> altGlyph = do_QueryInterface(aContent);
      96               0 :     NS_ASSERTION(tspan || altGlyph, "Content is not an SVG tspan or altGlyph");
      97                 :   }
      98                 : 
      99               0 :   return nsSVGTSpanFrameBase::Init(aContent, aParent, aPrevInFlow);
     100                 : }
     101                 : #endif /* DEBUG */
     102                 : 
     103                 : NS_IMETHODIMP
     104               0 : nsSVGTSpanFrame::AttributeChanged(PRInt32         aNameSpaceID,
     105                 :                                   nsIAtom*        aAttribute,
     106                 :                                   PRInt32         aModType)
     107                 : {
     108               0 :   if (aNameSpaceID == kNameSpaceID_None &&
     109                 :       (aAttribute == nsGkAtoms::x ||
     110                 :        aAttribute == nsGkAtoms::y ||
     111                 :        aAttribute == nsGkAtoms::dx ||
     112                 :        aAttribute == nsGkAtoms::dy ||
     113                 :        aAttribute == nsGkAtoms::rotate)) {
     114               0 :     NotifyGlyphMetricsChange();
     115                 :   }
     116                 : 
     117               0 :   return NS_OK;
     118                 : }
     119                 : 
     120                 : //----------------------------------------------------------------------
     121                 : // nsSVGContainerFrame methods:
     122                 : 
     123                 : gfxMatrix
     124               0 : nsSVGTSpanFrame::GetCanvasTM()
     125                 : {
     126               0 :   NS_ASSERTION(mParent, "null parent");
     127               0 :   return static_cast<nsSVGContainerFrame*>(mParent)->GetCanvasTM();  
     128                 : }
     129                 : 
     130                 : //----------------------------------------------------------------------
     131                 : // nsISVGGlyphFragmentNode methods:
     132                 : 
     133                 : PRUint32
     134               0 : nsSVGTSpanFrame::GetNumberOfChars()
     135                 : {
     136               0 :   return nsSVGTSpanFrameBase::GetNumberOfChars();
     137                 : }
     138                 : 
     139                 : float
     140               0 : nsSVGTSpanFrame::GetComputedTextLength()
     141                 : {
     142               0 :   return nsSVGTSpanFrameBase::GetComputedTextLength();
     143                 : }
     144                 : 
     145                 : float
     146               0 : nsSVGTSpanFrame::GetSubStringLength(PRUint32 charnum, PRUint32 nchars)
     147                 : {
     148               0 :   return nsSVGTSpanFrameBase::GetSubStringLength(charnum, nchars);
     149                 : }
     150                 : 
     151                 : PRInt32
     152               0 : nsSVGTSpanFrame::GetCharNumAtPosition(nsIDOMSVGPoint *point)
     153                 : {
     154               0 :   return nsSVGTSpanFrameBase::GetCharNumAtPosition(point);
     155                 : }
     156                 : 
     157                 : NS_IMETHODIMP_(nsSVGGlyphFrame *)
     158               0 : nsSVGTSpanFrame::GetFirstGlyphFrame()
     159                 : {
     160                 :   // try children first:
     161               0 :   nsIFrame* kid = mFrames.FirstChild();
     162               0 :   while (kid) {
     163               0 :     nsISVGGlyphFragmentNode *node = do_QueryFrame(kid);
     164               0 :     if (node)
     165               0 :       return node->GetFirstGlyphFrame();
     166               0 :     kid = kid->GetNextSibling();
     167                 :   }
     168                 : 
     169                 :   // nope. try siblings:
     170               0 :   return GetNextGlyphFrame();
     171                 : 
     172                 : }
     173                 : 
     174                 : NS_IMETHODIMP_(nsSVGGlyphFrame *)
     175               0 : nsSVGTSpanFrame::GetNextGlyphFrame()
     176                 : {
     177               0 :   nsIFrame* sibling = GetNextSibling();
     178               0 :   while (sibling) {
     179               0 :     nsISVGGlyphFragmentNode *node = do_QueryFrame(sibling);
     180               0 :     if (node)
     181               0 :       return node->GetFirstGlyphFrame();
     182               0 :     sibling = sibling->GetNextSibling();
     183                 :   }
     184                 : 
     185                 :   // no more siblings. go back up the tree.
     186                 :   
     187               0 :   NS_ASSERTION(GetParent(), "null parent");
     188               0 :   nsISVGGlyphFragmentNode *node = do_QueryFrame(GetParent());
     189               0 :   return node ? node->GetNextGlyphFrame() : nsnull;
     190                 : }
     191                 : 
     192                 : NS_IMETHODIMP_(void)
     193               0 : nsSVGTSpanFrame::SetWhitespaceCompression(bool)
     194                 : {
     195               0 :   nsSVGTSpanFrameBase::SetWhitespaceCompression();
     196               0 : }

Generated by: LCOV version 1.7