Changeset 165767 in webkit
- Timestamp:
- Mar 17, 2014 3:28:25 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r165766 r165767 1 2014-03-17 Alexey Proskuryakov <ap@apple.com> 2 3 Move convertToRange() helper to cross-platform WebPage.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=130365 5 6 Reviewed by Tim Horton. 7 8 Also renamed it to rangeFromEditingLocationAndLength(). 9 10 * WebProcess/WebPage/WebPage.cpp: 11 (WebKit::WebPage::rangeFromEditingLocationAndLength): 12 * WebProcess/WebPage/WebPage.h: 13 * WebProcess/WebPage/ios/WebPageIOS.mm: 14 (WebKit::WebPage::insertText): 15 * WebProcess/WebPage/mac/WebPageMac.mm: 16 (WebKit::WebPage::setComposition): 17 (WebKit::WebPage::insertText): 18 (WebKit::WebPage::insertDictatedText): 19 (WebKit::WebPage::getAttributedSubstringFromRange): 20 (WebKit::WebPage::characterIndexForPoint): 21 (WebKit::WebPage::firstRectForCharacterRange): 22 1 23 2014-03-17 Anders Carlsson <andersca@apple.com> 2 24 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r165759 r165767 4337 4337 } 4338 4338 4339 PassRefPtr<Range> WebPage::rangeFromEditingLocationAndLength(Frame& frame, uint64_t location, uint64_t length) 4340 { 4341 // Sanitize the input, because TextIterator::rangeFromLocationAndLength takes signed integers. 4342 if (location > INT_MAX) 4343 return 0; 4344 if (length > INT_MAX || location + length > INT_MAX) 4345 length = INT_MAX - location; 4346 4347 // Our critical assumption is that we are only called by input methods that 4348 // concentrate on a given area containing the selection. 4349 // We have to do this because of text fields and textareas. The DOM for those is not 4350 // directly in the document DOM, so serialization is problematic. Our solution is 4351 // to use the root editable element of the selection start as the positional base. 4352 // That fits with AppKit's idea of an input context. 4353 return TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), location, length); 4354 } 4355 4339 4356 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r165759 r165767 928 928 static PluginView* pluginViewForFrame(WebCore::Frame*); 929 929 930 PassRefPtr<WebCore::Range> rangeFromEditingLocationAndLength(WebCore::Frame&, uint64_t location, uint64_t length); 931 930 932 void reportUsedFeatures(); 931 933 -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r165759 r165767 186 186 } 187 187 188 static PassRefPtr<Range> convertToRange(Frame* frame, NSRange nsrange)189 {190 if (nsrange.location > INT_MAX)191 return 0;192 if (nsrange.length > INT_MAX || nsrange.location + nsrange.length > INT_MAX)193 nsrange.length = INT_MAX - nsrange.location;194 195 // our critical assumption is that we are only called by input methods that196 // concentrate on a given area containing the selection197 // We have to do this because of text fields and textareas. The DOM for those is not198 // directly in the document DOM, so serialization is problematic. Our solution is199 // to use the root editable element of the selection start as the positional base.200 // That fits with AppKit's idea of an input context.201 return TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), nsrange.location, nsrange.length);202 }203 204 188 void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength) 205 189 { … … 207 191 208 192 if (replacementRangeStart != NSNotFound) { 209 RefPtr<Range> replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeLength));193 RefPtr<Range> replacementRange = rangeFromEditingLocationAndLength(frame, replacementRangeStart, replacementRangeLength); 210 194 if (replacementRange) 211 195 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r165759 r165767 77 77 namespace WebKit { 78 78 79 static PassRefPtr<Range> convertToRange(Frame*, uint64_t location, uint64_t length);80 81 79 void WebPage::platformInitialize() 82 80 { … … 255 253 RefPtr<Range> replacementRange; 256 254 if (replacementRangeStart != NSNotFound) { 257 replacementRange = convertToRange(&frame, replacementRangeStart, replacementRangeLength);255 replacementRange = rangeFromEditingLocationAndLength(frame, replacementRangeStart, replacementRangeLength); 258 256 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); 259 257 } … … 284 282 285 283 if (replacementRangeStart != NSNotFound) { 286 RefPtr<Range> replacementRange = convertToRange(&frame, replacementRangeStart, replacementRangeLength);284 RefPtr<Range> replacementRange = rangeFromEditingLocationAndLength(frame, replacementRangeStart, replacementRangeLength); 287 285 if (replacementRange) 288 286 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); … … 306 304 307 305 if (replacementRangeStart != NSNotFound) { 308 RefPtr<Range> replacementRange = convertToRange(&frame, replacementRangeStart, replacementRangeLength);306 RefPtr<Range> replacementRange = rangeFromEditingLocationAndLength(frame, replacementRangeStart, replacementRangeLength); 309 307 if (replacementRange) 310 308 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); … … 356 354 return; 357 355 358 RefPtr<Range> range = convertToRange(&frame, rangeStart, rangeLength);356 RefPtr<Range> range = rangeFromEditingLocationAndLength(frame, rangeStart, rangeLength); 359 357 if (!range) 360 358 return; … … 389 387 index = static_cast<uint64_t>(location); 390 388 } 391 392 PassRefPtr<Range> convertToRange(Frame* frame, uint64_t location, uint64_t length)393 {394 if (location > INT_MAX)395 return 0;396 if (length > INT_MAX || location + length > INT_MAX)397 length = INT_MAX - location;398 399 // our critical assumption is that we are only called by input methods that400 // concentrate on a given area containing the selection401 // We have to do this because of text fields and textareas. The DOM for those is not402 // directly in the document DOM, so serialization is problematic. Our solution is403 // to use the root editable element of the selection start as the positional base.404 // That fits with AppKit's idea of an input context.405 return TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length);406 }407 389 408 390 void WebPage::firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect) … … 412 394 resultRect.setSize(IntSize(0, 0)); 413 395 414 RefPtr<Range> range = convertToRange(&frame, location, length);396 RefPtr<Range> range = rangeFromEditingLocationAndLength(frame, location, length); 415 397 if (!range) 416 398 return;
Note: See TracChangeset
for help on using the changeset viewer.