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
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/
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
15 * The Original Code is the Mozilla SVG project.
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.
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.
35 * ***** END LICENSE BLOCK ***** */
37 #ifndef NS_SVGTEXTCONTAINERFRAME_H
38 #define NS_SVGTEXTCONTAINERFRAME_H
40 #include "nsSVGContainerFrame.h"
41 #include "nsIDOMSVGLengthList.h"
42 #include "nsISVGTextContentMetrics.h"
44 class nsISVGGlyphFragmentNode
;
45 class nsISVGGlyphFragmentLeaf
;
49 class nsSVGTextContainerFrame
: public nsSVGDisplayContainerFrame
,
50 public nsISVGTextContentMetrics
53 nsSVGTextContainerFrame(nsStyleContext
* aContext
) :
54 nsSVGDisplayContainerFrame(aContext
) {}
56 void NotifyGlyphMetricsChange();
57 NS_IMETHOD_(already_AddRefed
<nsIDOMSVGLengthList
>) GetX();
58 NS_IMETHOD_(already_AddRefed
<nsIDOMSVGLengthList
>) GetY();
59 NS_IMETHOD_(already_AddRefed
<nsIDOMSVGLengthList
>) GetDx();
60 NS_IMETHOD_(already_AddRefed
<nsIDOMSVGLengthList
>) GetDy();
62 // nsISupports interface:
63 NS_IMETHOD
QueryInterface(const nsIID
& aIID
, void** aInstancePtr
);
65 NS_IMETHOD_(nsrefcnt
) AddRef() { return 1; }
66 NS_IMETHOD_(nsrefcnt
) Release() { return 1; }
70 NS_IMETHOD
InsertFrames(nsIAtom
* aListName
,
72 nsIFrame
* aFrameList
);
73 NS_IMETHOD
RemoveFrame(nsIAtom
*aListName
, nsIFrame
*aOldFrame
);
75 // nsISVGTextContentMetrics
76 NS_IMETHOD
GetNumberOfChars(PRInt32
*_retval
);
77 NS_IMETHOD
GetComputedTextLength(float *_retval
);
78 NS_IMETHOD
GetSubStringLength(PRUint32 charnum
, PRUint32 nchars
, float *_retval
);
79 NS_IMETHOD
GetStartPositionOfChar(PRUint32 charnum
, nsIDOMSVGPoint
**_retval
);
80 NS_IMETHOD
GetEndPositionOfChar(PRUint32 charnum
, nsIDOMSVGPoint
**_retval
);
81 NS_IMETHOD
GetExtentOfChar(PRUint32 charnum
, nsIDOMSVGRect
**_retval
);
82 NS_IMETHOD
GetRotationOfChar(PRUint32 charnum
, float *_retval
);
83 NS_IMETHOD
GetCharNumAtPosition(nsIDOMSVGPoint
*point
, PRInt32
*_retval
);
87 * Returns the first child node for a frame
89 nsISVGGlyphFragmentNode
*
90 GetFirstGlyphFragmentChildNode();
93 * Returns the next child node for a frame
95 nsISVGGlyphFragmentNode
*
96 GetNextGlyphFragmentChildNode(nsISVGGlyphFragmentNode
*node
);
99 * Set Whitespace handling
101 void SetWhitespaceHandling();
104 * Returns the number of characters in a string
106 PRUint32
GetNumberOfChars();
109 * Determines the length of a string
111 float GetComputedTextLength();
114 * Determines the length of a substring
116 float GetSubStringLengthNoValidation(PRUint32 charnum
, PRUint32 nchars
);
119 * Get the character at the specified position
121 PRInt32
GetCharNumAtPosition(nsIDOMSVGPoint
*point
);
125 * Returns the glyph fragment containing a particular character
127 static nsISVGGlyphFragmentLeaf
*
128 GetGlyphFragmentAtCharNum(nsISVGGlyphFragmentNode
* node
,
133 * Returns the text frame ancestor of this frame (or the frame itself
134 * if this is a text frame)
136 nsSVGTextFrame
* GetTextFrame();