Changeset 165759 in webkit
- Timestamp:
- Mar 17, 2014, 2:31:33 PM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r165758 r165759 1 2014-03-17 Alexey Proskuryakov <ap@apple.com> 2 3 [Mac] Standardize on start/length in text input IPC methods 4 https://bugs.webkit.org/show_bug.cgi?id=130359 5 6 Reviewed by Anders Carlsson. 7 8 Some IPC methods used start/length, and others use start/end. This was confusing. 9 10 While here, changed WebPageMac.mm to not use NSMakeRange where we don't need it 11 (I want to move this code to WebPage.cpp, where it could be shared with iOS and 12 other platforms, as it doesn't depend on Foundation much). 13 14 * UIProcess/API/mac/WKView.mm: 15 (-[WKView insertText:replacementRange:]): 16 (-[WKView setMarkedText:selectedRange:replacementRange:]): 17 (-[WKView attributedSubstringForProposedRange:actualRange:]): 18 * UIProcess/WebPageProxy.cpp: 19 (WebKit::WebPageProxy::internalShowContextMenu): 20 * UIProcess/WebPageProxy.h: 21 * UIProcess/ios/WebPageProxyIOS.mm: 22 (WebKit::WebPageProxy::setComposition): 23 (WebKit::WebPageProxy::insertText): 24 * UIProcess/mac/WebPageProxyMac.mm: 25 (WebKit::WebPageProxy::setComposition): 26 (WebKit::WebPageProxy::insertText): 27 (WebKit::WebPageProxy::insertDictatedText): 28 (WebKit::WebPageProxy::getAttributedSubstringFromRange): 29 * WebProcess/WebPage/WebPage.cpp: 30 (WebKit::WebPage::setComposition): 31 * WebProcess/WebPage/WebPage.h: 32 * WebProcess/WebPage/WebPage.messages.in: 33 * WebProcess/WebPage/ios/WebPageIOS.mm: 34 (WebKit::WebPage::setComposition): 35 (WebKit::WebPage::insertText): 36 * WebProcess/WebPage/mac/WebPageMac.mm: 37 (WebKit::WebPage::setComposition): 38 (WebKit::WebPage::insertText): 39 (WebKit::WebPage::insertDictatedText): 40 (WebKit::WebPage::getAttributedSubstringFromRange): 41 (WebKit::convertToRange): 42 (WebKit::WebPage::firstRectForCharacterRange): 43 1 44 2014-03-17 Tim Horton <timothy_horton@apple.com> 2 45 -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r165758 r165759 1290 1290 bool eventHandled; 1291 1291 if (!dictationAlternatives.isEmpty()) 1292 eventHandled = _data->_page->insertDictatedText(eventText, replacementRange.location, NSMaxRange(replacementRange), dictationAlternatives);1292 eventHandled = _data->_page->insertDictatedText(eventText, replacementRange.location, replacementRange.length, dictationAlternatives); 1293 1293 else 1294 eventHandled = _data->_page->insertText(eventText, replacementRange.location, NSMaxRange(replacementRange));1294 eventHandled = _data->_page->insertText(eventText, replacementRange.location, replacementRange.length); 1295 1295 1296 1296 if (parameters) … … 1609 1609 [self _notifyInputContextAboutDiscardedComposition]; 1610 1610 if ([text length] == 1 && [[text decomposedStringWithCanonicalMapping] characterAtIndex:0] < 0x80) { 1611 _data->_page->insertText(text, replacementRange.location, NSMaxRange(replacementRange));1611 _data->_page->insertText(text, replacementRange.location, replacementRange.length); 1612 1612 } else 1613 1613 NSBeep(); … … 1615 1615 } 1616 1616 1617 _data->_page->setComposition(text, underlines, newSelRange.location, NSMaxRange(newSelRange), replacementRange.location, NSMaxRange(replacementRange));1617 _data->_page->setComposition(text, underlines, newSelRange.location, newSelRange.length, replacementRange.location, replacementRange.length); 1618 1618 } 1619 1619 … … 1643 1643 1644 1644 AttributedString result; 1645 _data->_page->getAttributedSubstringFromRange(nsRange.location, NSMaxRange(nsRange), result);1645 _data->_page->getAttributedSubstringFromRange(nsRange.location, nsRange.length, result); 1646 1646 1647 1647 if (actualRange) { -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r165748 r165759 4483 4483 4484 4484 #if PLATFORM(GTK) 4485 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRange End)4485 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRange) 4486 4486 { 4487 4487 // FIXME: We need to find out how to proper handle the crashes case. -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r165750 r165759 526 526 void setMainFrameIsScrollable(bool); 527 527 528 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);528 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementRangeStart, uint64_t replacementRangeLength); 529 529 void confirmComposition(); 530 530 void cancelComposition(); 531 bool insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End);532 bool insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End, const Vector<WebCore::TextAlternativeWithRange>& dictationAlternatives);531 bool insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength); 532 bool insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, const Vector<WebCore::TextAlternativeWithRange>& dictationAlternatives); 533 533 void getMarkedRange(uint64_t& location, uint64_t& length); 534 534 void getSelectedRange(uint64_t& location, uint64_t& length); 535 void getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t range End, AttributedString&);535 void getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t rangeLength, AttributedString&); 536 536 uint64_t characterIndexForPoint(const WebCore::IntPoint); 537 537 WebCore::IntRect firstRectForCharacterRange(uint64_t, uint64_t); -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r165577 r165759 99 99 } 100 100 101 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underline, uint64_t selectionStart, uint64_t selection End, uint64_t, uint64_t)101 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underline, uint64_t selectionStart, uint64_t selectionLength, uint64_t, uint64_t) 102 102 { 103 103 if (!isValid()) 104 104 return; 105 105 106 process().send(Messages::WebPage::SetComposition(text, underline, selectionStart, selection End), m_pageID);106 process().send(Messages::WebPage::SetComposition(text, underline, selectionStart, selectionLength), m_pageID); 107 107 } 108 108 … … 121 121 } 122 122 123 bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End)123 bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength) 124 124 { 125 125 if (!isValid()) 126 126 return true; 127 127 128 process().send(Messages::WebPage::InsertText(text, replacementRangeStart, replacementRange End), m_pageID);128 process().send(Messages::WebPage::InsertText(text, replacementRangeStart, replacementRangeLength), m_pageID); 129 129 return true; 130 130 } -
trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
r165750 r165759 152 152 } 153 153 154 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)154 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementRangeStart, uint64_t replacementRangeLength) 155 155 { 156 156 if (!isValid()) { … … 160 160 } 161 161 162 process().sendSync(Messages::WebPage::SetComposition(text, underlines, selectionStart, selection End, replacementRangeStart, replacementRangeEnd), Messages::WebPage::SetComposition::Reply(m_editorState), m_pageID);162 process().sendSync(Messages::WebPage::SetComposition(text, underlines, selectionStart, selectionLength, replacementRangeStart, replacementRangeLength), Messages::WebPage::SetComposition::Reply(m_editorState), m_pageID); 163 163 } 164 164 … … 179 179 } 180 180 181 bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End)181 bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength) 182 182 { 183 183 if (!isValid()) … … 185 185 186 186 bool handled = true; 187 process().sendSync(Messages::WebPage::InsertText(text, replacementRangeStart, replacementRange End), Messages::WebPage::InsertText::Reply(handled, m_editorState), m_pageID);187 process().sendSync(Messages::WebPage::InsertText(text, replacementRangeStart, replacementRangeLength), Messages::WebPage::InsertText::Reply(handled, m_editorState), m_pageID); 188 188 m_temporarilyClosedComposition = false; 189 189 … … 191 191 } 192 192 193 bool WebPageProxy::insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End, const Vector<TextAlternativeWithRange>& dictationAlternativesWithRange)193 bool WebPageProxy::insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, const Vector<TextAlternativeWithRange>& dictationAlternativesWithRange) 194 194 { 195 195 #if USE(DICTATION_ALTERNATIVES) 196 196 if (dictationAlternativesWithRange.isEmpty()) 197 return insertText(text, replacementRangeStart, replacementRange End);197 return insertText(text, replacementRangeStart, replacementRangeLength); 198 198 199 199 if (!isValid()) … … 210 210 211 211 if (dictationAlternatives.isEmpty()) 212 return insertText(text, replacementRangeStart, replacementRange End);212 return insertText(text, replacementRangeStart, replacementRangeLength); 213 213 214 214 bool handled = true; 215 process().sendSync(Messages::WebPage::InsertDictatedText(text, replacementRangeStart, replacementRange End, dictationAlternatives), Messages::WebPage::InsertDictatedText::Reply(handled, m_editorState), m_pageID);215 process().sendSync(Messages::WebPage::InsertDictatedText(text, replacementRangeStart, replacementRangeLength, dictationAlternatives), Messages::WebPage::InsertDictatedText::Reply(handled, m_editorState), m_pageID); 216 216 return handled; 217 217 #else 218 return insertText(text, replacementRangeStart, replacementRange End);218 return insertText(text, replacementRangeStart, replacementRangeLength); 219 219 #endif 220 220 } … … 242 242 } 243 243 244 void WebPageProxy::getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t range End, AttributedString& result)245 { 246 if (!isValid()) 247 return; 248 process().sendSync(Messages::WebPage::GetAttributedSubstringFromRange(rangeStart, range End), Messages::WebPage::GetAttributedSubstringFromRange::Reply(result), m_pageID);244 void WebPageProxy::getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t rangeLength, AttributedString& result) 245 { 246 if (!isValid()) 247 return; 248 process().sendSync(Messages::WebPage::GetAttributedSubstringFromRange(rangeStart, rangeLength), Messages::WebPage::GetAttributedSubstringFromRange::Reply(result), m_pageID); 249 249 } 250 250 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r165753 r165759 3910 3910 } 3911 3911 3912 void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End, uint64_t replacementStart, uint64_t replacementLength)3912 void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementStart, uint64_t replacementLength) 3913 3913 { 3914 3914 Frame* targetFrame = targetFrameForEditing(this); … … 3929 3929 } 3930 3930 3931 targetFrame->editor().setComposition(text, underlines, selectionStart, selection End);3931 targetFrame->editor().setComposition(text, underlines, selectionStart, selectionStart + selectionLength); 3932 3932 send(Messages::WebPageProxy::EditorStateChanged(editorState())); 3933 3933 } -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r165750 r165759 456 456 void requestAutocorrectionContext(uint64_t callbackID); 457 457 void getAutocorrectionContext(String& beforeText, String& markedText, String& selectedText, String& afterText, uint64_t& location, uint64_t& length); 458 void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End);459 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End);458 void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength); 459 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength); 460 460 void confirmComposition(); 461 461 void getPositionInformation(const WebCore::IntPoint&, InteractionInformationAtPosition&); … … 522 522 523 523 #if PLATFORM(GTK) 524 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRange End);524 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeLength); 525 525 void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength); 526 526 void cancelComposition(); … … 539 539 void cancelComposition(EditorState& newState); 540 540 #if !PLATFORM(IOS) 541 void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End, bool& handled, EditorState& newState);542 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState);541 void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, bool& handled, EditorState& newState); 542 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementRangeStart, uint64_t replacementRangeLength, EditorState& newState); 543 543 void confirmComposition(EditorState& newState); 544 544 #endif 545 545 void getMarkedRange(uint64_t& location, uint64_t& length); 546 546 void getSelectedRange(uint64_t& location, uint64_t& length); 547 void getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t range End, AttributedString&);547 void getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t rangeLength, AttributedString&); 548 548 void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result); 549 549 void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect); … … 555 555 void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result); 556 556 bool performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*); 557 void insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);557 void insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState); 558 558 #elif PLATFORM(EFL) 559 559 void confirmComposition(const String& compositionString); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r165750 r165759 57 57 RequestAutocorrectionContext(uint64_t callbackID) 58 58 GetAutocorrectionContext() -> (String beforeContext, String markedText, String selectedText, String afterContext, uint64_t location, uint64_t length) 59 InsertText(String text, uint64_t replacementRangeStart, uint64_t replacementRange End)60 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End)59 InsertText(String text, uint64_t replacementRangeStart, uint64_t replacementRangeLength) 60 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength) 61 61 ConfirmComposition() 62 62 GetPositionInformation(WebCore::IntPoint point) -> (WebKit::InteractionInformationAtPosition information) … … 275 275 276 276 #if PLATFORM(GTK) 277 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRange End)277 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeLength) 278 278 ConfirmComposition(String text, int64_t selectionStart, int64_t selectionLength) 279 279 CancelComposition() … … 295 295 GetMarkedRange() -> (uint64_t location, uint64_t length) 296 296 GetSelectedRange() -> (uint64_t location, uint64_t length) 297 GetAttributedSubstringFromRange(uint64_t rangeStart, uint64_t range End) -> (WebKit::AttributedString result)297 GetAttributedSubstringFromRange(uint64_t rangeStart, uint64_t rangeLength) -> (WebKit::AttributedString result) 298 298 CharacterIndexForPoint(WebCore::IntPoint point) -> (uint64_t result) 299 299 FirstRectForCharacterRange(uint64_t location, uint64_t length) -> (WebCore::IntRect resultRect) … … 301 301 ShouldDelayWindowOrderingEvent(WebKit::WebMouseEvent event) -> (bool result) 302 302 AcceptsFirstMouse(int eventNumber, WebKit::WebMouseEvent event) -> (bool result) 303 InsertDictatedText(String text, uint64_t replacementRangeStart, uint64_t replacementRange End, Vector<WebCore::DictationAlternative> dictationAlternatives) -> (bool handled, WebKit::EditorState newState)303 InsertDictatedText(String text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, Vector<WebCore::DictationAlternative> dictationAlternatives) -> (bool handled, WebKit::EditorState newState) 304 304 #endif 305 305 #if PLATFORM(MAC) 306 InsertText(String text, uint64_t replacementRangeStart, uint64_t replacementRange End) -> (bool handled, WebKit::EditorState newState)307 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End, uint64_t replacementRangeStart, uint64_t replacementRangeEnd) -> (WebKit::EditorState newState)306 InsertText(String text, uint64_t replacementRangeStart, uint64_t replacementRangeLength) -> (bool handled, WebKit::EditorState newState) 307 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementRangeStart, uint64_t replacementRangeLength) -> (WebKit::EditorState newState) 308 308 ConfirmComposition() -> (WebKit::EditorState newState) 309 309 #endif -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r165577 r165759 167 167 } 168 168 169 void WebPage::setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End)169 void WebPage::setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength) 170 170 { 171 171 Frame& frame = m_page->focusController().focusedOrMainFrame(); 172 172 173 173 if (frame.selection().selection().isContentEditable()) 174 frame.editor().setComposition(text, underlines, selectionStart, selection End);174 frame.editor().setComposition(text, underlines, selectionStart, selectionStart + selectionLength); 175 175 } 176 176 … … 202 202 } 203 203 204 void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End)204 void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength) 205 205 { 206 206 Frame& frame = m_page->focusController().focusedOrMainFrame(); 207 207 208 208 if (replacementRangeStart != NSNotFound) { 209 RefPtr<Range> replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRange End - replacementRangeStart));209 RefPtr<Range> replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeLength)); 210 210 if (replacementRange) 211 211 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r165750 r165759 77 77 namespace WebKit { 78 78 79 static PassRefPtr<Range> convertToRange(Frame*, NSRange);79 static PassRefPtr<Range> convertToRange(Frame*, uint64_t location, uint64_t length); 80 80 81 81 void WebPage::platformInitialize() … … 248 248 } 249 249 250 void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selection End, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState)250 void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementRangeStart, uint64_t replacementRangeLength, EditorState& newState) 251 251 { 252 252 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 255 255 RefPtr<Range> replacementRange; 256 256 if (replacementRangeStart != NSNotFound) { 257 replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));257 replacementRange = convertToRange(&frame, replacementRangeStart, replacementRangeLength); 258 258 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); 259 259 } 260 260 261 frame.editor().setComposition(text, underlines, selectionStart, selection End);261 frame.editor().setComposition(text, underlines, selectionStart, selectionStart + selectionLength); 262 262 } 263 263 … … 279 279 } 280 280 281 void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End, bool& handled, EditorState& newState)281 void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, bool& handled, EditorState& newState) 282 282 { 283 283 Frame& frame = m_page->focusController().focusedOrMainFrame(); 284 284 285 285 if (replacementRangeStart != NSNotFound) { 286 RefPtr<Range> replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));286 RefPtr<Range> replacementRange = convertToRange(&frame, replacementRangeStart, replacementRangeLength); 287 287 if (replacementRange) 288 288 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); … … 301 301 } 302 302 303 void WebPage::insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRange End, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState)303 void WebPage::insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState) 304 304 { 305 305 Frame& frame = m_page->focusController().focusedOrMainFrame(); 306 306 307 307 if (replacementRangeStart != NSNotFound) { 308 RefPtr<Range> replacementRange = convertToRange(&frame, NSMakeRange(replacementRangeStart, replacementRangeEnd - replacementRangeStart));308 RefPtr<Range> replacementRange = convertToRange(&frame, replacementRangeStart, replacementRangeLength); 309 309 if (replacementRange) 310 310 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); … … 348 348 } 349 349 350 void WebPage::getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t range End, AttributedString& result)350 void WebPage::getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t rangeLength, AttributedString& result) 351 351 { 352 352 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 356 356 return; 357 357 358 NSRange nsRange = NSMakeRange(rangeStart, rangeEnd - rangeStart); 359 RefPtr<Range> range = convertToRange(&frame, nsRange); 358 RefPtr<Range> range = convertToRange(&frame, rangeStart, rangeLength); 360 359 if (!range) 361 360 return; … … 367 366 // whitespace at the end of the string which breaks the ATOK input method. <rdar://problem/5400551> 368 367 // To work around this we truncate the resultant string to the correct length. 369 if ([attributedString length] > nsRange.length) {370 ASSERT([attributedString length] == nsRange.length + 1);371 ASSERT([[attributedString string] characterAtIndex: nsRange.length] == '\n' || [[attributedString string] characterAtIndex:nsRange.length] == ' ');372 result.string = [attributedString attributedSubstringFromRange:NSMakeRange(0, nsRange.length)];368 if ([attributedString length] > rangeLength) { 369 ASSERT([attributedString length] == rangeLength + 1); 370 ASSERT([[attributedString string] characterAtIndex:rangeLength] == '\n' || [[attributedString string] characterAtIndex:rangeLength] == ' '); 371 result.string = [attributedString attributedSubstringFromRange:NSMakeRange(0, rangeLength)]; 373 372 } 374 373 } … … 391 390 } 392 391 393 PassRefPtr<Range> convertToRange(Frame* frame, NSRange nsrange)394 { 395 if ( nsrange.location > INT_MAX)392 PassRefPtr<Range> convertToRange(Frame* frame, uint64_t location, uint64_t length) 393 { 394 if (location > INT_MAX) 396 395 return 0; 397 if ( nsrange.length > INT_MAX || nsrange.location + nsrange.length > INT_MAX)398 nsrange.length = INT_MAX - nsrange.location;396 if (length > INT_MAX || location + length > INT_MAX) 397 length = INT_MAX - location; 399 398 400 399 // our critical assumption is that we are only called by input methods that … … 404 403 // to use the root editable element of the selection start as the positional base. 405 404 // That fits with AppKit's idea of an input context. 406 return TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), nsrange.location, nsrange.length);405 return TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length); 407 406 } 408 407 … … 413 412 resultRect.setSize(IntSize(0, 0)); 414 413 415 RefPtr<Range> range = convertToRange(&frame, NSMakeRange(location, length));414 RefPtr<Range> range = convertToRange(&frame, location, length); 416 415 if (!range) 417 416 return;
Note:
See TracChangeset
for help on using the changeset viewer.