OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (m_specifiedTextLength == defaultTextLength) | 96 if (m_specifiedTextLength == defaultTextLength) |
97 m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedT
extLength(), ASSERT_NO_EXCEPTION); | 97 m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedT
extLength(), ASSERT_NO_EXCEPTION); |
98 | 98 |
99 m_textLength.shouldSynchronize = true; | 99 m_textLength.shouldSynchronize = true; |
100 return static_pointer_cast<SVGAnimatedLength>(lookupOrCreateTextLengthWrappe
r(this)); | 100 return static_pointer_cast<SVGAnimatedLength>(lookupOrCreateTextLengthWrappe
r(this)); |
101 | 101 |
102 } | 102 } |
103 | 103 |
104 unsigned SVGTextContentElement::getNumberOfChars() | 104 unsigned SVGTextContentElement::getNumberOfChars() |
105 { | 105 { |
106 document()->updateLayoutIgnorePendingStylesheets(); | 106 document().updateLayoutIgnorePendingStylesheets(); |
107 return SVGTextQuery(renderer()).numberOfCharacters(); | 107 return SVGTextQuery(renderer()).numberOfCharacters(); |
108 } | 108 } |
109 | 109 |
110 float SVGTextContentElement::getComputedTextLength() | 110 float SVGTextContentElement::getComputedTextLength() |
111 { | 111 { |
112 document()->updateLayoutIgnorePendingStylesheets(); | 112 document().updateLayoutIgnorePendingStylesheets(); |
113 return SVGTextQuery(renderer()).textLength(); | 113 return SVGTextQuery(renderer()).textLength(); |
114 } | 114 } |
115 | 115 |
116 float SVGTextContentElement::getSubStringLength(unsigned charnum, unsigned nchar
s, ExceptionState& es) | 116 float SVGTextContentElement::getSubStringLength(unsigned charnum, unsigned nchar
s, ExceptionState& es) |
117 { | 117 { |
118 document()->updateLayoutIgnorePendingStylesheets(); | 118 document().updateLayoutIgnorePendingStylesheets(); |
119 | 119 |
120 unsigned numberOfChars = getNumberOfChars(); | 120 unsigned numberOfChars = getNumberOfChars(); |
121 if (charnum >= numberOfChars) { | 121 if (charnum >= numberOfChars) { |
122 es.throwDOMException(IndexSizeError); | 122 es.throwDOMException(IndexSizeError); |
123 return 0.0f; | 123 return 0.0f; |
124 } | 124 } |
125 | 125 |
126 if (nchars > numberOfChars - charnum) | 126 if (nchars > numberOfChars - charnum) |
127 nchars = numberOfChars - charnum; | 127 nchars = numberOfChars - charnum; |
128 | 128 |
129 return SVGTextQuery(renderer()).subStringLength(charnum, nchars); | 129 return SVGTextQuery(renderer()).subStringLength(charnum, nchars); |
130 } | 130 } |
131 | 131 |
132 SVGPoint SVGTextContentElement::getStartPositionOfChar(unsigned charnum, Excepti
onState& es) | 132 SVGPoint SVGTextContentElement::getStartPositionOfChar(unsigned charnum, Excepti
onState& es) |
133 { | 133 { |
134 document()->updateLayoutIgnorePendingStylesheets(); | 134 document().updateLayoutIgnorePendingStylesheets(); |
135 | 135 |
136 if (charnum > getNumberOfChars()) { | 136 if (charnum > getNumberOfChars()) { |
137 es.throwDOMException(IndexSizeError); | 137 es.throwDOMException(IndexSizeError); |
138 return FloatPoint(); | 138 return FloatPoint(); |
139 } | 139 } |
140 | 140 |
141 return SVGTextQuery(renderer()).startPositionOfCharacter(charnum); | 141 return SVGTextQuery(renderer()).startPositionOfCharacter(charnum); |
142 } | 142 } |
143 | 143 |
144 SVGPoint SVGTextContentElement::getEndPositionOfChar(unsigned charnum, Exception
State& es) | 144 SVGPoint SVGTextContentElement::getEndPositionOfChar(unsigned charnum, Exception
State& es) |
145 { | 145 { |
146 document()->updateLayoutIgnorePendingStylesheets(); | 146 document().updateLayoutIgnorePendingStylesheets(); |
147 | 147 |
148 if (charnum > getNumberOfChars()) { | 148 if (charnum > getNumberOfChars()) { |
149 es.throwDOMException(IndexSizeError); | 149 es.throwDOMException(IndexSizeError); |
150 return FloatPoint(); | 150 return FloatPoint(); |
151 } | 151 } |
152 | 152 |
153 return SVGTextQuery(renderer()).endPositionOfCharacter(charnum); | 153 return SVGTextQuery(renderer()).endPositionOfCharacter(charnum); |
154 } | 154 } |
155 | 155 |
156 SVGRect SVGTextContentElement::getExtentOfChar(unsigned charnum, ExceptionState&
es) | 156 SVGRect SVGTextContentElement::getExtentOfChar(unsigned charnum, ExceptionState&
es) |
157 { | 157 { |
158 document()->updateLayoutIgnorePendingStylesheets(); | 158 document().updateLayoutIgnorePendingStylesheets(); |
159 | 159 |
160 if (charnum > getNumberOfChars()) { | 160 if (charnum > getNumberOfChars()) { |
161 es.throwDOMException(IndexSizeError); | 161 es.throwDOMException(IndexSizeError); |
162 return SVGRect(); | 162 return SVGRect(); |
163 } | 163 } |
164 | 164 |
165 return SVGTextQuery(renderer()).extentOfCharacter(charnum); | 165 return SVGTextQuery(renderer()).extentOfCharacter(charnum); |
166 } | 166 } |
167 | 167 |
168 float SVGTextContentElement::getRotationOfChar(unsigned charnum, ExceptionState&
es) | 168 float SVGTextContentElement::getRotationOfChar(unsigned charnum, ExceptionState&
es) |
169 { | 169 { |
170 document()->updateLayoutIgnorePendingStylesheets(); | 170 document().updateLayoutIgnorePendingStylesheets(); |
171 | 171 |
172 if (charnum > getNumberOfChars()) { | 172 if (charnum > getNumberOfChars()) { |
173 es.throwDOMException(IndexSizeError); | 173 es.throwDOMException(IndexSizeError); |
174 return 0.0f; | 174 return 0.0f; |
175 } | 175 } |
176 | 176 |
177 return SVGTextQuery(renderer()).rotationOfCharacter(charnum); | 177 return SVGTextQuery(renderer()).rotationOfCharacter(charnum); |
178 } | 178 } |
179 | 179 |
180 int SVGTextContentElement::getCharNumAtPosition(const SVGPoint& point) | 180 int SVGTextContentElement::getCharNumAtPosition(const SVGPoint& point) |
181 { | 181 { |
182 document()->updateLayoutIgnorePendingStylesheets(); | 182 document().updateLayoutIgnorePendingStylesheets(); |
183 return SVGTextQuery(renderer()).characterNumberAtPosition(point); | 183 return SVGTextQuery(renderer()).characterNumberAtPosition(point); |
184 } | 184 } |
185 | 185 |
186 void SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars, E
xceptionState& es) | 186 void SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars, E
xceptionState& es) |
187 { | 187 { |
188 unsigned numberOfChars = getNumberOfChars(); | 188 unsigned numberOfChars = getNumberOfChars(); |
189 if (charnum >= numberOfChars) { | 189 if (charnum >= numberOfChars) { |
190 es.throwDOMException(IndexSizeError); | 190 es.throwDOMException(IndexSizeError); |
191 return; | 191 return; |
192 } | 192 } |
193 | 193 |
194 if (nchars > numberOfChars - charnum) | 194 if (nchars > numberOfChars - charnum) |
195 nchars = numberOfChars - charnum; | 195 nchars = numberOfChars - charnum; |
196 | 196 |
197 ASSERT(document()); | 197 ASSERT(document().frame()); |
198 ASSERT(document()->frame()); | |
199 | 198 |
200 FrameSelection* selection = document()->frame()->selection(); | 199 FrameSelection* selection = document().frame()->selection(); |
201 if (!selection) | 200 if (!selection) |
202 return; | 201 return; |
203 | 202 |
204 // Find selection start | 203 // Find selection start |
205 VisiblePosition start(firstPositionInNode(const_cast<SVGTextContentElement*>
(this))); | 204 VisiblePosition start(firstPositionInNode(const_cast<SVGTextContentElement*>
(this))); |
206 for (unsigned i = 0; i < charnum; ++i) | 205 for (unsigned i = 0; i < charnum; ++i) |
207 start = start.next(); | 206 start = start.next(); |
208 | 207 |
209 // Find selection end | 208 // Find selection end |
210 VisiblePosition end(start); | 209 VisiblePosition end(start); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 SVGElement* element = toSVGElement(renderer->node()); | 301 SVGElement* element = toSVGElement(renderer->node()); |
303 ASSERT(element); | 302 ASSERT(element); |
304 | 303 |
305 if (!element->isTextContent()) | 304 if (!element->isTextContent()) |
306 return 0; | 305 return 0; |
307 | 306 |
308 return toSVGTextContentElement(element); | 307 return toSVGTextContentElement(element); |
309 } | 308 } |
310 | 309 |
311 } | 310 } |
OLD | NEW |