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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 float SVGTextContentElement::getSubStringLength( | 107 float SVGTextContentElement::getSubStringLength( |
108 unsigned charnum, | 108 unsigned charnum, |
109 unsigned nchars, | 109 unsigned nchars, |
110 ExceptionState& exceptionState) { | 110 ExceptionState& exceptionState) { |
111 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 111 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
112 | 112 |
113 unsigned numberOfChars = getNumberOfChars(); | 113 unsigned numberOfChars = getNumberOfChars(); |
114 if (charnum >= numberOfChars) { | 114 if (charnum >= numberOfChars) { |
115 exceptionState.throwDOMException( | 115 exceptionState.throwDOMException( |
116 IndexSizeError, ExceptionMessages::indexExceedsMaximumBound( | 116 IndexSizeError, |
117 "charnum", charnum, getNumberOfChars())); | 117 ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, |
| 118 getNumberOfChars())); |
118 return 0.0f; | 119 return 0.0f; |
119 } | 120 } |
120 | 121 |
121 if (nchars > numberOfChars - charnum) | 122 if (nchars > numberOfChars - charnum) |
122 nchars = numberOfChars - charnum; | 123 nchars = numberOfChars - charnum; |
123 | 124 |
124 return SVGTextQuery(layoutObject()).subStringLength(charnum, nchars); | 125 return SVGTextQuery(layoutObject()).subStringLength(charnum, nchars); |
125 } | 126 } |
126 | 127 |
127 SVGPointTearOff* SVGTextContentElement::getStartPositionOfChar( | 128 SVGPointTearOff* SVGTextContentElement::getStartPositionOfChar( |
128 unsigned charnum, | 129 unsigned charnum, |
129 ExceptionState& exceptionState) { | 130 ExceptionState& exceptionState) { |
130 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 131 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
131 | 132 |
132 if (charnum >= getNumberOfChars()) { | 133 if (charnum >= getNumberOfChars()) { |
133 exceptionState.throwDOMException( | 134 exceptionState.throwDOMException( |
134 IndexSizeError, ExceptionMessages::indexExceedsMaximumBound( | 135 IndexSizeError, |
135 "charnum", charnum, getNumberOfChars())); | 136 ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, |
| 137 getNumberOfChars())); |
136 return nullptr; | 138 return nullptr; |
137 } | 139 } |
138 | 140 |
139 FloatPoint point = | 141 FloatPoint point = |
140 SVGTextQuery(layoutObject()).startPositionOfCharacter(charnum); | 142 SVGTextQuery(layoutObject()).startPositionOfCharacter(charnum); |
141 return SVGPointTearOff::create(SVGPoint::create(point), 0, | 143 return SVGPointTearOff::create(SVGPoint::create(point), 0, |
142 PropertyIsNotAnimVal); | 144 PropertyIsNotAnimVal); |
143 } | 145 } |
144 | 146 |
145 SVGPointTearOff* SVGTextContentElement::getEndPositionOfChar( | 147 SVGPointTearOff* SVGTextContentElement::getEndPositionOfChar( |
146 unsigned charnum, | 148 unsigned charnum, |
147 ExceptionState& exceptionState) { | 149 ExceptionState& exceptionState) { |
148 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 150 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
149 | 151 |
150 if (charnum >= getNumberOfChars()) { | 152 if (charnum >= getNumberOfChars()) { |
151 exceptionState.throwDOMException( | 153 exceptionState.throwDOMException( |
152 IndexSizeError, ExceptionMessages::indexExceedsMaximumBound( | 154 IndexSizeError, |
153 "charnum", charnum, getNumberOfChars())); | 155 ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, |
| 156 getNumberOfChars())); |
154 return nullptr; | 157 return nullptr; |
155 } | 158 } |
156 | 159 |
157 FloatPoint point = | 160 FloatPoint point = |
158 SVGTextQuery(layoutObject()).endPositionOfCharacter(charnum); | 161 SVGTextQuery(layoutObject()).endPositionOfCharacter(charnum); |
159 return SVGPointTearOff::create(SVGPoint::create(point), 0, | 162 return SVGPointTearOff::create(SVGPoint::create(point), 0, |
160 PropertyIsNotAnimVal); | 163 PropertyIsNotAnimVal); |
161 } | 164 } |
162 | 165 |
163 SVGRectTearOff* SVGTextContentElement::getExtentOfChar( | 166 SVGRectTearOff* SVGTextContentElement::getExtentOfChar( |
164 unsigned charnum, | 167 unsigned charnum, |
165 ExceptionState& exceptionState) { | 168 ExceptionState& exceptionState) { |
166 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 169 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
167 | 170 |
168 if (charnum >= getNumberOfChars()) { | 171 if (charnum >= getNumberOfChars()) { |
169 exceptionState.throwDOMException( | 172 exceptionState.throwDOMException( |
170 IndexSizeError, ExceptionMessages::indexExceedsMaximumBound( | 173 IndexSizeError, |
171 "charnum", charnum, getNumberOfChars())); | 174 ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, |
| 175 getNumberOfChars())); |
172 return nullptr; | 176 return nullptr; |
173 } | 177 } |
174 | 178 |
175 FloatRect rect = SVGTextQuery(layoutObject()).extentOfCharacter(charnum); | 179 FloatRect rect = SVGTextQuery(layoutObject()).extentOfCharacter(charnum); |
176 return SVGRectTearOff::create(SVGRect::create(rect), 0, PropertyIsNotAnimVal); | 180 return SVGRectTearOff::create(SVGRect::create(rect), 0, PropertyIsNotAnimVal); |
177 } | 181 } |
178 | 182 |
179 float SVGTextContentElement::getRotationOfChar(unsigned charnum, | 183 float SVGTextContentElement::getRotationOfChar(unsigned charnum, |
180 ExceptionState& exceptionState) { | 184 ExceptionState& exceptionState) { |
181 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 185 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
182 | 186 |
183 if (charnum >= getNumberOfChars()) { | 187 if (charnum >= getNumberOfChars()) { |
184 exceptionState.throwDOMException( | 188 exceptionState.throwDOMException( |
185 IndexSizeError, ExceptionMessages::indexExceedsMaximumBound( | 189 IndexSizeError, |
186 "charnum", charnum, getNumberOfChars())); | 190 ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, |
| 191 getNumberOfChars())); |
187 return 0.0f; | 192 return 0.0f; |
188 } | 193 } |
189 | 194 |
190 return SVGTextQuery(layoutObject()).rotationOfCharacter(charnum); | 195 return SVGTextQuery(layoutObject()).rotationOfCharacter(charnum); |
191 } | 196 } |
192 | 197 |
193 int SVGTextContentElement::getCharNumAtPosition( | 198 int SVGTextContentElement::getCharNumAtPosition( |
194 SVGPointTearOff* point, | 199 SVGPointTearOff* point, |
195 ExceptionState& exceptionState) { | 200 ExceptionState& exceptionState) { |
196 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 201 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
197 return SVGTextQuery(layoutObject()) | 202 return SVGTextQuery(layoutObject()) |
198 .characterNumberAtPosition(point->target()->value()); | 203 .characterNumberAtPosition(point->target()->value()); |
199 } | 204 } |
200 | 205 |
201 void SVGTextContentElement::selectSubString(unsigned charnum, | 206 void SVGTextContentElement::selectSubString(unsigned charnum, |
202 unsigned nchars, | 207 unsigned nchars, |
203 ExceptionState& exceptionState) { | 208 ExceptionState& exceptionState) { |
204 unsigned numberOfChars = getNumberOfChars(); | 209 unsigned numberOfChars = getNumberOfChars(); |
205 if (charnum >= numberOfChars) { | 210 if (charnum >= numberOfChars) { |
206 exceptionState.throwDOMException( | 211 exceptionState.throwDOMException( |
207 IndexSizeError, ExceptionMessages::indexExceedsMaximumBound( | 212 IndexSizeError, |
208 "charnum", charnum, getNumberOfChars())); | 213 ExceptionMessages::indexExceedsMaximumBound("charnum", charnum, |
| 214 getNumberOfChars())); |
209 return; | 215 return; |
210 } | 216 } |
211 | 217 |
212 if (nchars > numberOfChars - charnum) | 218 if (nchars > numberOfChars - charnum) |
213 nchars = numberOfChars - charnum; | 219 nchars = numberOfChars - charnum; |
214 | 220 |
215 ASSERT(document().frame()); | 221 ASSERT(document().frame()); |
216 | 222 |
217 // Find selection start | 223 // Find selection start |
218 VisiblePosition start = VisiblePosition::firstPositionInNode( | 224 VisiblePosition start = VisiblePosition::firstPositionInNode( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 (!lineLayoutItem.isSVGText() && !lineLayoutItem.isSVGInline())) | 301 (!lineLayoutItem.isSVGText() && !lineLayoutItem.isSVGInline())) |
296 return nullptr; | 302 return nullptr; |
297 | 303 |
298 SVGElement* element = toSVGElement(lineLayoutItem.node()); | 304 SVGElement* element = toSVGElement(lineLayoutItem.node()); |
299 ASSERT(element); | 305 ASSERT(element); |
300 return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) | 306 return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) |
301 : 0; | 307 : 0; |
302 } | 308 } |
303 | 309 |
304 } // namespace blink | 310 } // namespace blink |
OLD | NEW |