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 IBM Corporation.
18 : * Portions created by the Initial Developer are Copyright (C) 2006
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPL"), or
25 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 : * in which case the provisions of the GPL or the LGPL are applicable instead
27 : * of those above. If you wish to allow use of your version of this file only
28 : * under the terms of either the GPL or the LGPL, and not to allow others to
29 : * use your version of this file under the terms of the MPL, indicate your
30 : * decision by deleting the provisions above and replace them with the notice
31 : * and other provisions required by the GPL or the LGPL. If you do not delete
32 : * the provisions above, a recipient may use your version of this file under
33 : * the terms of any one of the MPL, the GPL or the LGPL.
34 : *
35 : * ***** END LICENSE BLOCK ***** */
36 :
37 : #ifndef NS_SVGTEXTCONTAINERFRAME_H
38 : #define NS_SVGTEXTCONTAINERFRAME_H
39 :
40 : #include "nsSVGContainerFrame.h"
41 :
42 : class nsISVGGlyphFragmentNode;
43 : class nsSVGTextFrame;
44 : class nsSVGGlyphFrame;
45 :
46 : class nsSVGTextContainerFrame : public nsSVGDisplayContainerFrame
47 0 : {
48 : protected:
49 0 : nsSVGTextContainerFrame(nsStyleContext* aContext) :
50 0 : nsSVGDisplayContainerFrame(aContext) {}
51 :
52 : public:
53 : void NotifyGlyphMetricsChange();
54 : virtual void GetXY(SVGUserUnitList *aX, SVGUserUnitList *aY);
55 : virtual void GetDxDy(SVGUserUnitList *aDx, SVGUserUnitList *aDy);
56 : virtual const SVGNumberList *GetRotate();
57 :
58 : NS_DECL_QUERYFRAME_TARGET(nsSVGTextContainerFrame)
59 : NS_DECL_QUERYFRAME
60 : NS_DECL_FRAMEARENA_HELPERS
61 :
62 : // nsIFrame
63 : NS_IMETHOD InsertFrames(ChildListID aListID,
64 : nsIFrame* aPrevFrame,
65 : nsFrameList& aFrameList);
66 : NS_IMETHOD RemoveFrame(ChildListID aListID, nsIFrame *aOldFrame);
67 :
68 : NS_IMETHOD GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval);
69 : NS_IMETHOD GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval);
70 : NS_IMETHOD GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retval);
71 : NS_IMETHOD GetRotationOfChar(PRUint32 charnum, float *_retval);
72 :
73 : /*
74 : * Returns the number of characters in a string
75 : */
76 : virtual PRUint32 GetNumberOfChars();
77 :
78 : /*
79 : * Determines the length of a string
80 : */
81 : virtual float GetComputedTextLength();
82 :
83 : /*
84 : * Determines the length of a substring
85 : */
86 : virtual float GetSubStringLength(PRUint32 charnum, PRUint32 nchars);
87 :
88 : /*
89 : * Get the character at the specified position
90 : */
91 : virtual PRInt32 GetCharNumAtPosition(nsIDOMSVGPoint *point);
92 : void GetEffectiveXY(nsTArray<float> &aX, nsTArray<float> &aY);
93 : void GetEffectiveDxDy(nsTArray<float> &aDx, nsTArray<float> &aDy);
94 : void GetEffectiveRotate(nsTArray<float> &aRotate);
95 :
96 : protected:
97 : /*
98 : * Returns the first child node for a frame
99 : */
100 : nsISVGGlyphFragmentNode *
101 : GetFirstGlyphFragmentChildNode();
102 :
103 : /*
104 : * Returns the next child node for a frame
105 : */
106 : nsISVGGlyphFragmentNode *
107 : GetNextGlyphFragmentChildNode(nsISVGGlyphFragmentNode *node);
108 :
109 : void CopyPositionList(nsTArray<float> *parentList,
110 : SVGUserUnitList *selfList,
111 : nsTArray<float> &dstList,
112 : PRUint32 aOffset);
113 : void CopyRotateList(nsTArray<float> *parentList,
114 : const SVGNumberList *selfList,
115 : nsTArray<float> &dstList,
116 : PRUint32 aOffset);
117 : PRUint32 BuildPositionList(PRUint32 aOffset, PRUint32 aDepth);
118 :
119 : void SetWhitespaceCompression();
120 : private:
121 : /*
122 : * Returns the glyph frame containing a particular character
123 : */
124 : static nsSVGGlyphFrame *
125 : GetGlyphFrameAtCharNum(nsISVGGlyphFragmentNode* node,
126 : PRUint32 charnum,
127 : PRUint32 *offset);
128 :
129 : /*
130 : * Returns the text frame ancestor of this frame (or the frame itself
131 : * if this is a text frame)
132 : */
133 : nsSVGTextFrame * GetTextFrame();
134 : nsTArray<float> mX;
135 : nsTArray<float> mY;
136 : nsTArray<float> mDx;
137 : nsTArray<float> mDy;
138 : nsTArray<float> mRotate;
139 : };
140 :
141 : #endif
|