Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: Source/core/svg/SVGTextContentElement.cpp

Issue 1321783002: Throw exceptions for charnum == getNumberOfChars in get{...}OfChar APIs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/svg/text/svgtextcontentelement-methods-parameters-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (nchars > numberOfChars - charnum) 114 if (nchars > numberOfChars - charnum)
115 nchars = numberOfChars - charnum; 115 nchars = numberOfChars - charnum;
116 116
117 return SVGTextQuery(layoutObject()).subStringLength(charnum, nchars); 117 return SVGTextQuery(layoutObject()).subStringLength(charnum, nchars);
118 } 118 }
119 119
120 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGTextContentElement::getStartPositionO fChar(unsigned charnum, ExceptionState& exceptionState) 120 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGTextContentElement::getStartPositionO fChar(unsigned charnum, ExceptionState& exceptionState)
121 { 121 {
122 document().updateLayoutIgnorePendingStylesheets(); 122 document().updateLayoutIgnorePendingStylesheets();
123 123
124 if (charnum > getNumberOfChars()) { 124 if (charnum >= getNumberOfChars()) {
125 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 125 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
126 return nullptr; 126 return nullptr;
127 } 127 }
128 128
129 FloatPoint point = SVGTextQuery(layoutObject()).startPositionOfCharacter(cha rnum); 129 FloatPoint point = SVGTextQuery(layoutObject()).startPositionOfCharacter(cha rnum);
130 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val); 130 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val);
131 } 131 }
132 132
133 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGTextContentElement::getEndPositionOfC har(unsigned charnum, ExceptionState& exceptionState) 133 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGTextContentElement::getEndPositionOfC har(unsigned charnum, ExceptionState& exceptionState)
134 { 134 {
135 document().updateLayoutIgnorePendingStylesheets(); 135 document().updateLayoutIgnorePendingStylesheets();
136 136
137 if (charnum > getNumberOfChars()) { 137 if (charnum >= getNumberOfChars()) {
138 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 138 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
139 return nullptr; 139 return nullptr;
140 } 140 }
141 141
142 FloatPoint point = SVGTextQuery(layoutObject()).endPositionOfCharacter(charn um); 142 FloatPoint point = SVGTextQuery(layoutObject()).endPositionOfCharacter(charn um);
143 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val); 143 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val);
144 } 144 }
145 145
146 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGTextContentElement::getExtentOfChar(un signed charnum, ExceptionState& exceptionState) 146 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGTextContentElement::getExtentOfChar(un signed charnum, ExceptionState& exceptionState)
147 { 147 {
148 document().updateLayoutIgnorePendingStylesheets(); 148 document().updateLayoutIgnorePendingStylesheets();
149 149
150 if (charnum > getNumberOfChars()) { 150 if (charnum >= getNumberOfChars()) {
151 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 151 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
152 return nullptr; 152 return nullptr;
153 } 153 }
154 154
155 FloatRect rect = SVGTextQuery(layoutObject()).extentOfCharacter(charnum); 155 FloatRect rect = SVGTextQuery(layoutObject()).extentOfCharacter(charnum);
156 return SVGRectTearOff::create(SVGRect::create(rect), 0, PropertyIsNotAnimVal ); 156 return SVGRectTearOff::create(SVGRect::create(rect), 0, PropertyIsNotAnimVal );
157 } 157 }
158 158
159 float SVGTextContentElement::getRotationOfChar(unsigned charnum, ExceptionState& exceptionState) 159 float SVGTextContentElement::getRotationOfChar(unsigned charnum, ExceptionState& exceptionState)
160 { 160 {
161 document().updateLayoutIgnorePendingStylesheets(); 161 document().updateLayoutIgnorePendingStylesheets();
162 162
163 if (charnum > getNumberOfChars()) { 163 if (charnum >= getNumberOfChars()) {
164 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars())); 164 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound("charnum", charnum, getNumberOfChars()));
165 return 0.0f; 165 return 0.0f;
166 } 166 }
167 167
168 return SVGTextQuery(layoutObject()).rotationOfCharacter(charnum); 168 return SVGTextQuery(layoutObject()).rotationOfCharacter(charnum);
169 } 169 }
170 170
171 int SVGTextContentElement::getCharNumAtPosition(PassRefPtrWillBeRawPtr<SVGPointT earOff> point, ExceptionState& exceptionState) 171 int SVGTextContentElement::getCharNumAtPosition(PassRefPtrWillBeRawPtr<SVGPointT earOff> point, ExceptionState& exceptionState)
172 { 172 {
173 document().updateLayoutIgnorePendingStylesheets(); 173 document().updateLayoutIgnorePendingStylesheets();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 if (!layoutObject->isSVGText() && !layoutObject->isSVGInline()) 259 if (!layoutObject->isSVGText() && !layoutObject->isSVGInline())
260 return nullptr; 260 return nullptr;
261 261
262 SVGElement* element = toSVGElement(layoutObject->node()); 262 SVGElement* element = toSVGElement(layoutObject->node());
263 ASSERT(element); 263 ASSERT(element);
264 return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) : 0; 264 return isSVGTextContentElement(*element) ? toSVGTextContentElement(element) : 0;
265 } 265 }
266 266
267 } 267 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/text/svgtextcontentelement-methods-parameters-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698