LCOV - code coverage report
Current view: directory - layout/svg/base/src - nsSVGGlyphFrame.h (source / functions) Found Hit Coverage
Test: app.info Lines: 32 0 0.0 %
Date: 2012-06-02 Functions: 12 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                 : #ifndef __NS_SVGGLYPHFRAME_H__
      40                 : #define __NS_SVGGLYPHFRAME_H__
      41                 : 
      42                 : #include "nsSVGGeometryFrame.h"
      43                 : #include "nsISVGGlyphFragmentNode.h"
      44                 : #include "nsISVGChildFrame.h"
      45                 : #include "nsSVGUtils.h"
      46                 : #include "gfxContext.h"
      47                 : #include "gfxFont.h"
      48                 : #include "nsTextFragment.h"
      49                 : 
      50                 : class nsRenderingContext;
      51                 : class nsSVGTextFrame;
      52                 : class nsSVGTextPathFrame;
      53                 : class nsSVGGlyphFrame;
      54                 : class CharacterIterator;
      55                 : struct CharacterPosition;
      56                 : 
      57                 : typedef gfxFont::DrawMode DrawMode;
      58                 : 
      59                 : typedef nsSVGGeometryFrame nsSVGGlyphFrameBase;
      60                 : 
      61                 : class nsSVGGlyphFrame : public nsSVGGlyphFrameBase,
      62                 :                         public nsISVGGlyphFragmentNode,
      63                 :                         public nsISVGChildFrame
      64                 : {
      65                 :   friend nsIFrame*
      66                 :   NS_NewSVGGlyphFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
      67                 : protected:
      68               0 :   nsSVGGlyphFrame(nsStyleContext* aContext)
      69                 :     : nsSVGGlyphFrameBase(aContext),
      70                 :       mTextRun(nsnull),
      71                 :       mStartIndex(0),
      72                 :       mCompressWhitespace(true),
      73                 :       mTrimLeadingWhitespace(false),
      74               0 :       mTrimTrailingWhitespace(false)
      75               0 :       {}
      76               0 :   ~nsSVGGlyphFrame()
      77               0 :   {
      78               0 :     ClearTextRun();
      79               0 :   }
      80                 : 
      81                 : public:
      82                 :   NS_DECL_QUERYFRAME
      83                 :   NS_DECL_FRAMEARENA_HELPERS
      84                 : 
      85                 :   // These do not use the global transform if NS_STATE_NONDISPLAY_CHILD
      86                 :   nsresult GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval);
      87                 :   nsresult GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval);
      88                 :   nsresult GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retval);
      89                 :   nsresult GetRotationOfChar(PRUint32 charnum, float *_retval);
      90                 :   /**
      91                 :    * @param aForceGlobalTransform controls whether to use the
      92                 :    * global transform even when NS_STATE_NONDISPLAY_CHILD
      93                 :    */
      94                 :   float GetAdvance(bool aForceGlobalTransform);
      95                 : 
      96                 :   void SetGlyphPosition(gfxPoint *aPosition, bool aForceGlobalTransform);
      97                 :   nsSVGTextPathFrame* FindTextPathParent();
      98                 :   bool IsStartOfChunk(); // == is new absolutely positioned chunk.
      99                 : 
     100                 :   void GetXY(mozilla::SVGUserUnitList *aX, mozilla::SVGUserUnitList *aY);
     101                 :   void SetStartIndex(PRUint32 aStartIndex);
     102                 :   /*
     103                 :    * Returns inherited x and y values instead of parent element's attribute
     104                 :    * values.
     105                 :    */
     106                 :   void GetEffectiveXY(PRInt32 strLength,
     107                 :                       nsTArray<float> &aX, nsTArray<float> &aY);
     108                 :   /*
     109                 :    * Returns inherited dx and dy values instead of parent element's attribute
     110                 :    * values.
     111                 :    */
     112                 :   void GetEffectiveDxDy(PRInt32 strLength, 
     113                 :                         nsTArray<float> &aDx,
     114                 :                         nsTArray<float> &aDy);
     115                 :   /*
     116                 :    * Returns inherited rotate values instead of parent element's attribute
     117                 :    * values.
     118                 :    */
     119                 :   void GetEffectiveRotate(PRInt32 strLength,
     120                 :                           nsTArray<float> &aRotate);
     121                 :   PRUint16 GetTextAnchor();
     122                 :   bool IsAbsolutelyPositioned();
     123               0 :   bool IsTextEmpty() const {
     124               0 :     return mContent->GetText()->GetLength() == 0;
     125                 :   }
     126               0 :   void SetTrimLeadingWhitespace(bool aTrimLeadingWhitespace) {
     127               0 :     if (mTrimLeadingWhitespace != aTrimLeadingWhitespace) {
     128               0 :       mTrimLeadingWhitespace = aTrimLeadingWhitespace;
     129               0 :       ClearTextRun();
     130                 :     }
     131               0 :   }
     132               0 :   void SetTrimTrailingWhitespace(bool aTrimTrailingWhitespace) {
     133               0 :     if (mTrimTrailingWhitespace != aTrimTrailingWhitespace) {
     134               0 :       mTrimTrailingWhitespace = aTrimTrailingWhitespace;
     135               0 :       ClearTextRun();
     136                 :     }
     137               0 :   }
     138                 :   bool EndsWithWhitespace() const;
     139                 :   bool IsAllWhitespace() const;
     140                 : 
     141                 :   // nsIFrame interface:
     142                 :   NS_IMETHOD  CharacterDataChanged(CharacterDataChangeInfo* aInfo);
     143                 : 
     144                 :   virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
     145                 : 
     146                 :   NS_IMETHOD  IsSelectable(bool* aIsSelectable, PRUint8* aSelectStyle) const;
     147                 : 
     148                 :   NS_IMETHOD Init(nsIContent*      aContent,
     149                 :                   nsIFrame*        aParent,
     150                 :                   nsIFrame*        aPrevInFlow);
     151                 : 
     152                 :   /**
     153                 :    * Get the "type" of the frame
     154                 :    *
     155                 :    * @see nsGkAtoms::svgGlyphFrame
     156                 :    */
     157                 :   virtual nsIAtom* GetType() const;
     158                 : 
     159               0 :   virtual bool IsFrameOfType(PRUint32 aFlags) const
     160                 :   {
     161                 :     // Set the frame state bit for text frames to mark them as replaced.
     162                 :     // XXX kipp: temporary
     163                 : 
     164               0 :     return nsSVGGlyphFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
     165                 :   }
     166                 : 
     167                 : #ifdef DEBUG
     168               0 :   NS_IMETHOD GetFrameName(nsAString& aResult) const
     169                 :   {
     170               0 :     return MakeFrameName(NS_LITERAL_STRING("SVGGlyph"), aResult);
     171                 :   }
     172                 : #endif
     173                 : 
     174                 :   // nsISVGChildFrame interface:
     175                 :   // These four always use the global transform, even if NS_STATE_NONDISPLAY_CHILD
     176                 :   NS_IMETHOD PaintSVG(nsRenderingContext *aContext,
     177                 :                       const nsIntRect *aDirtyRect);
     178                 :   NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint);
     179                 :   NS_IMETHOD UpdateCoveredRegion();
     180                 :   virtual gfxRect GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
     181                 :                                       PRUint32 aFlags);
     182                 : 
     183                 :   NS_IMETHOD_(nsRect) GetCoveredRegion();
     184                 :   NS_IMETHOD InitialUpdate();
     185                 :   virtual void NotifySVGChanged(PRUint32 aFlags);
     186                 :   virtual void NotifyRedrawSuspended();
     187                 :   virtual void NotifyRedrawUnsuspended();
     188               0 :   NS_IMETHOD_(bool) IsDisplayContainer() { return false; }
     189               0 :   NS_IMETHOD_(bool) HasValidCoveredRect() {
     190               0 :     return !(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD);
     191                 :   }
     192                 : 
     193                 :   // nsSVGGeometryFrame methods
     194                 :   gfxMatrix GetCanvasTM();
     195                 : 
     196                 :   // nsISVGGlyphFragmentNode interface:
     197                 :   // These do not use the global transform if NS_STATE_NONDISPLAY_CHILD
     198                 :   virtual PRUint32 GetNumberOfChars();
     199                 :   virtual float GetComputedTextLength();
     200                 :   virtual float GetSubStringLength(PRUint32 charnum, PRUint32 fragmentChars);
     201                 :   virtual PRInt32 GetCharNumAtPosition(nsIDOMSVGPoint *point);
     202                 :   NS_IMETHOD_(nsSVGGlyphFrame *) GetFirstGlyphFrame();
     203                 :   NS_IMETHOD_(nsSVGGlyphFrame *) GetNextGlyphFrame();
     204               0 :   NS_IMETHOD_(void) SetWhitespaceCompression(bool aCompressWhitespace) {
     205               0 :     if (mCompressWhitespace != aCompressWhitespace) {
     206               0 :       mCompressWhitespace = aCompressWhitespace;
     207               0 :       ClearTextRun();
     208                 :     }
     209               0 :   }
     210                 : 
     211                 : protected:
     212                 :   friend class CharacterIterator;
     213                 : 
     214                 :   // Use a power of 2 here. It's not so important to match
     215                 :   // nsDeviceContext::AppUnitsPerDevPixel, but since we do a lot of
     216                 :   // multiplying by 1/GetTextRunUnitsFactor, it's good for it to be a
     217                 :   // power of 2 to avoid accuracy loss.
     218               0 :   static PRUint32 GetTextRunUnitsFactor() { return 64; }
     219                 :   
     220                 :   /**
     221                 :    * @aParam aDrawScale font drawing must be scaled into user units
     222                 :    * by this factor
     223                 :    * @param aMetricsScale font metrics must be scaled into user units
     224                 :    * by this factor
     225                 :    * @param aForceGlobalTransform set to true if we should force use of
     226                 :    * the global transform; otherwise we won't use the global transform
     227                 :    * if we're a NONDISPLAY_CHILD
     228                 :    */
     229                 :   bool EnsureTextRun(float *aDrawScale, float *aMetricsScale,
     230                 :                        bool aForceGlobalTransform);
     231                 :   void ClearTextRun();
     232                 : 
     233                 :   bool GetCharacterData(nsAString & aCharacterData);
     234                 :   bool GetCharacterPositions(nsTArray<CharacterPosition>* aCharacterPositions,
     235                 :                                float aMetricsScale);
     236                 :   PRUint32 GetTextRunFlags(PRUint32 strLength);
     237                 : 
     238                 :   void AddCharactersToPath(CharacterIterator *aIter,
     239                 :                            gfxContext *aContext);
     240                 :   void AddBoundingBoxesToPath(CharacterIterator *aIter,
     241                 :                               gfxContext *aContext);
     242                 :   void DrawCharacters(CharacterIterator *aIter,
     243                 :                       gfxContext *aContext,
     244                 :                       DrawMode aDrawMode,
     245                 :                       gfxPattern *aStrokePattern = nsnull);
     246                 : 
     247                 :   void NotifyGlyphMetricsChange();
     248                 :   void SetupGlobalTransform(gfxContext *aContext);
     249                 :   nsresult GetHighlight(PRUint32 *charnum, PRUint32 *nchars,
     250                 :                         nscolor *foreground, nscolor *background);
     251                 :   float GetSubStringAdvance(PRUint32 charnum, PRUint32 fragmentChars,
     252                 :                             float aMetricsScale);
     253                 :   gfxFloat GetBaselineOffset(float aMetricsScale);
     254                 : 
     255                 :   virtual void GetDxDy(SVGUserUnitList *aDx, SVGUserUnitList *aDy);
     256                 :   virtual const SVGNumberList *GetRotate();
     257                 : 
     258                 :   // Used to support GetBBoxContribution by making GetConvasTM use this as the
     259                 :   // parent transform instead of the real CanvasTM.
     260                 :   nsAutoPtr<gfxMatrix> mOverrideCanvasTM;
     261                 : 
     262                 :   // Owning pointer, must call gfxTextRunWordCache::RemoveTextRun before deleting
     263                 :   gfxTextRun *mTextRun;
     264                 :   gfxPoint mPosition;
     265                 :   // The start index into the position and rotation data
     266                 :   PRUint32 mStartIndex;
     267                 :   bool mCompressWhitespace;
     268                 :   bool mTrimLeadingWhitespace;
     269                 :   bool mTrimTrailingWhitespace;
     270                 : 
     271                 : private:
     272                 :   DrawMode SetupCairoState(gfxContext *aContext,
     273                 :                            gfxPattern **aStrokePattern);
     274                 : };
     275                 : 
     276                 : #endif

Generated by: LCOV version 1.7