Changeset 165823 in webkit
- Timestamp:
- Mar 18, 2014 11:13:44 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r165818 r165823 1 2014-03-17 Alexey Proskuryakov <ap@apple.com> 2 3 [WK2] Pass ranges over IPC in a cross-platform manner 4 https://bugs.webkit.org/show_bug.cgi?id=130376 5 6 Reviewed by Anders Carlsson. 7 8 Added an EditingRange class for IPC, which automatically converts to and from 9 NSRanges, knowing the difference between notFound and NSNotFound. 10 11 Manually applied the same fix to characterIndexForPoint. 12 13 * Scripts/webkit2/messages.py: 14 (struct_or_class): 15 * Shared/EditingRange.h: Added. 16 (WebKit::EditingRange::EditingRange): 17 (WebKit::EditingRange::isValid): 18 (WebKit::EditingRange::operator NSRange): 19 * UIProcess/API/mac/WKView.mm: 20 (-[WKView insertText:replacementRange:]): 21 (-[WKView selectedRange]): 22 (-[WKView hasMarkedText]): 23 (-[WKView setMarkedText:selectedRange:replacementRange:]): 24 (-[WKView markedRange]): 25 (-[WKView attributedSubstringForProposedRange:actualRange:]): 26 (-[WKView characterIndexForPoint:]): 27 (-[WKView firstRectForCharacterRange:actualRange:]): 28 * UIProcess/WebPageProxy.h: 29 * UIProcess/ios/WKContentViewInteraction.mm: 30 (-[WKContentView setMarkedText:selectedRange:]): 31 (-[WKContentView insertText:]): 32 * UIProcess/ios/WebPageProxyIOS.mm: 33 (WebKit::WebPageProxy::setComposition): 34 (WebKit::WebPageProxy::insertText): 35 (WebKit::WebPageProxy::insertDictatedText): 36 (WebKit::WebPageProxy::getMarkedRange): 37 (WebKit::WebPageProxy::getSelectedRange): 38 (WebKit::WebPageProxy::getAttributedSubstringFromRange): 39 (WebKit::WebPageProxy::firstRectForCharacterRange): 40 * UIProcess/mac/WebPageProxyMac.mm: 41 (WebKit::WebPageProxy::setComposition): 42 (WebKit::WebPageProxy::insertText): 43 (WebKit::WebPageProxy::insertDictatedText): 44 (WebKit::WebPageProxy::getMarkedRange): 45 (WebKit::WebPageProxy::getSelectedRange): 46 (WebKit::WebPageProxy::getAttributedSubstringFromRange): 47 (WebKit::WebPageProxy::firstRectForCharacterRange): 48 * WebKit2.xcodeproj/project.pbxproj: 49 * WebProcess/WebPage/WebPage.cpp: 50 (WebKit::WebPage::rangeFromEditingRange): 51 * WebProcess/WebPage/WebPage.h: 52 * WebProcess/WebPage/WebPage.messages.in: 53 * WebProcess/WebPage/ios/WebPageIOS.mm: 54 (WebKit::WebPage::setComposition): 55 (WebKit::WebPage::insertText): 56 (WebKit::WebPage::insertDictatedText): 57 (WebKit::WebPage::getMarkedRange): 58 (WebKit::WebPage::getSelectedRange): 59 (WebKit::WebPage::getAttributedSubstringFromRange): 60 (WebKit::WebPage::firstRectForCharacterRange): 61 * WebProcess/WebPage/mac/WebPageMac.mm: 62 (WebKit::WebPage::setComposition): 63 (WebKit::WebPage::insertText): 64 (WebKit::WebPage::insertDictatedText): 65 (WebKit::WebPage::getMarkedRange): 66 (WebKit::WebPage::getSelectedRange): 67 (WebKit::WebPage::getAttributedSubstringFromRange): 68 (WebKit::WebPage::characterIndexForPoint): 69 (WebKit::WebPage::firstRectForCharacterRange): 70 1 71 2014-03-17 Filip Pizlo <fpizlo@apple.com> 2 72 -
trunk/Source/WebKit2/Scripts/webkit2/messages.py
r164955 r165823 212 212 'WebKit::DictionaryPopupInfo', 213 213 'WebKit::DrawingAreaInfo', 214 'WebKit::EditingRange', 214 215 'WebKit::EditorState', 215 216 'WebKit::InteractionInformationAtPosition', -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r165759 r165823 37 37 #import "ColorSpaceData.h" 38 38 #import "DataReference.h" 39 #import "EditingRange.h" 39 40 #import "EditorState.h" 40 41 #import "FindIndicator.h" … … 1290 1291 bool eventHandled; 1291 1292 if (!dictationAlternatives.isEmpty()) 1292 eventHandled = _data->_page->insertDictatedText(eventText, replacementRange .location, replacementRange.length, dictationAlternatives);1293 eventHandled = _data->_page->insertDictatedText(eventText, replacementRange, dictationAlternatives); 1293 1294 else 1294 eventHandled = _data->_page->insertText(eventText, replacementRange .location, replacementRange.length);1295 eventHandled = _data->_page->insertText(eventText, replacementRange); 1295 1296 1296 1297 if (parameters) … … 1481 1482 [self _executeSavedKeypressCommands]; 1482 1483 1483 uint64_t selectionStart; 1484 uint64_t selectionLength; 1485 _data->_page->getSelectedRange(selectionStart, selectionLength); 1486 1487 NSRange result = NSMakeRange(selectionStart, selectionLength); 1484 EditingRange selectedRange; 1485 _data->_page->getSelectedRange(selectedRange); 1486 1487 NSRange result = selectedRange; 1488 1488 if (result.location == NSNotFound) 1489 1489 LOG(TextInput, "selectedRange -> (NSNotFound, %u)", result.length); … … 1507 1507 } 1508 1508 } else { 1509 uint64_t location; 1510 uint64_t length; 1511 _data->_page->getMarkedRange(location, length); 1512 result = location != NSNotFound; 1509 EditingRange markedRange; 1510 _data->_page->getMarkedRange(markedRange); 1511 result = markedRange.location != notFound; 1513 1512 } 1514 1513 … … 1576 1575 } 1577 1576 1578 - (void)setMarkedText:(id)string selectedRange:(NSRange)newSel Range replacementRange:(NSRange)replacementRange1577 - (void)setMarkedText:(id)string selectedRange:(NSRange)newSelectedRange replacementRange:(NSRange)replacementRange 1579 1578 { 1580 1579 [self _executeSavedKeypressCommands]; … … 1583 1582 ASSERT(isAttributedString || [string isKindOfClass:[NSString class]]); 1584 1583 1585 LOG(TextInput, "setMarkedText:\"%@\" selectedRange:(%u, %u)", isAttributedString ? [string string] : string, newSel Range.location, newSelRange.length);1584 LOG(TextInput, "setMarkedText:\"%@\" selectedRange:(%u, %u)", isAttributedString ? [string string] : string, newSelectedRange.location, newSelectedRange.length); 1586 1585 1587 1586 // Use pointer to get parameters passed to us by the caller of interpretKeyEvents. … … 1609 1608 [self _notifyInputContextAboutDiscardedComposition]; 1610 1609 if ([text length] == 1 && [[text decomposedStringWithCanonicalMapping] characterAtIndex:0] < 0x80) { 1611 _data->_page->insertText(text, replacementRange .location, replacementRange.length);1610 _data->_page->insertText(text, replacementRange); 1612 1611 } else 1613 1612 NSBeep(); … … 1615 1614 } 1616 1615 1617 _data->_page->setComposition(text, underlines, newSel Range.location, newSelRange.length, replacementRange.location, replacementRange.length);1616 _data->_page->setComposition(text, underlines, newSelectedRange, replacementRange); 1618 1617 } 1619 1618 … … 1622 1621 [self _executeSavedKeypressCommands]; 1623 1622 1624 uint64_t location; 1625 uint64_t length; 1626 _data->_page->getMarkedRange(location, length); 1627 1628 LOG(TextInput, "markedRange -> (%u, %u)", location, length); 1629 return NSMakeRange(location, length); 1623 EditingRange markedRange; 1624 _data->_page->getMarkedRange(markedRange); 1625 1626 NSRange result = markedRange; 1627 if (result.location == NSNotFound) 1628 LOG(TextInput, "markedRange -> (NSNotFound, %u)", result.length); 1629 else 1630 LOG(TextInput, "markedRange -> (%u, %u)", result.location, result.length); 1631 1632 return result; 1630 1633 } 1631 1634 … … 1643 1646 1644 1647 AttributedString result; 1645 _data->_page->getAttributedSubstringFromRange(nsRange .location, nsRange.length, result);1648 _data->_page->getAttributedSubstringFromRange(nsRange, result); 1646 1649 1647 1650 if (actualRange) { … … 1668 1671 1669 1672 uint64_t result = _data->_page->characterIndexForPoint(IntPoint(thePoint)); 1673 if (result == notFound) 1674 result = NSNotFound; 1670 1675 LOG(TextInput, "characterIndexForPoint:(%f, %f) -> %u", thePoint.x, thePoint.y, result); 1671 1676 return result; … … 1682 1687 theRange.length = 0; 1683 1688 1684 NSRect resultRect = _data->_page->firstRectForCharacterRange(theRange .location, theRange.length);1689 NSRect resultRect = _data->_page->firstRectForCharacterRange(theRange); 1685 1690 resultRect = [self convertRect:resultRect toView:nil]; 1686 1691 resultRect = [self.window convertRectToScreen:resultRect]; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r165759 r165823 161 161 struct ColorSpaceData; 162 162 struct DictionaryPopupInfo; 163 struct EditingRange; 163 164 struct EditorState; 164 165 struct PlatformPopupMenuData; … … 526 527 void setMainFrameIsScrollable(bool); 527 528 528 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementRangeStart, uint64_t replacementRangeLength);529 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementRange); 529 530 void confirmComposition(); 530 531 void cancelComposition(); 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 void getMarkedRange( uint64_t& location, uint64_t& length);534 void getSelectedRange( uint64_t& location, uint64_t& length);535 void getAttributedSubstringFromRange( uint64_t rangeStart, uint64_t rangeLength, AttributedString&);532 bool insertText(const String& text, const EditingRange& replacementRange); 533 bool insertDictatedText(const String& text, const EditingRange& replacementRange, const Vector<WebCore::TextAlternativeWithRange>& dictationAlternatives); 534 void getMarkedRange(EditingRange&); 535 void getSelectedRange(EditingRange&); 536 void getAttributedSubstringFromRange(const EditingRange&, AttributedString&); 536 537 uint64_t characterIndexForPoint(const WebCore::IntPoint); 537 WebCore::IntRect firstRectForCharacterRange( uint64_t, uint64_t);538 WebCore::IntRect firstRectForCharacterRange(const EditingRange&); 538 539 bool executeKeypressCommands(const Vector<WebCore::KeypressCommand>&); 539 540 -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r165572 r165823 29 29 #if PLATFORM(IOS) 30 30 31 #import "EditingRange.h" 31 32 #import "NativeWebKeyboardEvent.h" 32 33 #import "NativeWebTouchEvent.h" … … 1410 1411 { 1411 1412 _markedText = markedText; 1412 _page->setComposition(markedText, Vector<WebCore::CompositionUnderline>(), selectedRange .location, selectedRange.length, 0, 0);1413 _page->setComposition(markedText, Vector<WebCore::CompositionUnderline>(), selectedRange, EditingRange()); 1413 1414 } 1414 1415 … … 1507 1508 - (void)insertText:(NSString *)aStringValue 1508 1509 { 1509 _page->insertText(aStringValue, NSNotFound, 0);1510 _page->insertText(aStringValue, EditingRange()); 1510 1511 } 1511 1512 -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r165759 r165823 30 30 31 31 #import "DataReference.h" 32 #import "EditingRange.h" 32 33 #import "NativeWebKeyboardEvent.h" 33 34 #import "PageClient.h" … … 99 100 } 100 101 101 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underline, uint64_t selectionStart, uint64_t selectionLength, uint64_t, uint64_t)102 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underline, const EditingRange& selectionRange, const EditingRange&) 102 103 { 103 104 if (!isValid()) 104 105 return; 105 106 106 process().send(Messages::WebPage::SetComposition(text, underline, selection Start, selectionLength), m_pageID);107 process().send(Messages::WebPage::SetComposition(text, underline, selectionRange), m_pageID); 107 108 } 108 109 … … 121 122 } 122 123 123 bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength)124 bool WebPageProxy::insertText(const String& text, const EditingRange& replacementRange) 124 125 { 125 126 if (!isValid()) 126 127 return true; 127 128 128 process().send(Messages::WebPage::InsertText(text, replacementRange Start, replacementRangeLength), m_pageID);129 process().send(Messages::WebPage::InsertText(text, replacementRange), m_pageID); 129 130 return true; 130 131 } 131 132 132 bool WebPageProxy::insertDictatedText(const String&, uint64_t, uint64_t, const Vector<WebCore::TextAlternativeWithRange>&)133 bool WebPageProxy::insertDictatedText(const String&, const EditingRange&, const Vector<WebCore::TextAlternativeWithRange>&) 133 134 { 134 135 notImplemented(); … … 136 137 } 137 138 138 void WebPageProxy::getMarkedRange( uint64_t&, uint64_t&)139 { 140 notImplemented(); 141 } 142 143 void WebPageProxy::getSelectedRange( uint64_t&, uint64_t&)144 { 145 notImplemented(); 146 } 147 148 void WebPageProxy::getAttributedSubstringFromRange( uint64_t, uint64_t, AttributedString&)139 void WebPageProxy::getMarkedRange(EditingRange&) 140 { 141 notImplemented(); 142 } 143 144 void WebPageProxy::getSelectedRange(EditingRange&) 145 { 146 notImplemented(); 147 } 148 149 void WebPageProxy::getAttributedSubstringFromRange(const EditingRange&, AttributedString&) 149 150 { 150 151 notImplemented(); … … 157 158 } 158 159 159 IntRect WebPageProxy::firstRectForCharacterRange( uint64_t, uint64_t)160 IntRect WebPageProxy::firstRectForCharacterRange(const EditingRange&) 160 161 { 161 162 notImplemented(); -
trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
r165759 r165823 34 34 #import "DataReference.h" 35 35 #import "DictionaryPopupInfo.h" 36 #import "EditingRange.h" 36 37 #import "EditorState.h" 37 38 #import "NativeWebKeyboardEvent.h" … … 152 153 } 153 154 154 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementRangeStart, uint64_t replacementRangeLength)155 void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementRange) 155 156 { 156 157 if (!isValid()) { … … 160 161 } 161 162 162 process().sendSync(Messages::WebPage::SetComposition(text, underlines, selection Start, selectionLength, replacementRangeStart, replacementRangeLength), Messages::WebPage::SetComposition::Reply(m_editorState), m_pageID);163 process().sendSync(Messages::WebPage::SetComposition(text, underlines, selectionRange, replacementRange), Messages::WebPage::SetComposition::Reply(m_editorState), m_pageID); 163 164 } 164 165 … … 179 180 } 180 181 181 bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength)182 bool WebPageProxy::insertText(const String& text, const EditingRange& replacementRange) 182 183 { 183 184 if (!isValid()) … … 185 186 186 187 bool handled = true; 187 process().sendSync(Messages::WebPage::InsertText(text, replacementRange Start, replacementRangeLength), Messages::WebPage::InsertText::Reply(handled, m_editorState), m_pageID);188 process().sendSync(Messages::WebPage::InsertText(text, replacementRange), Messages::WebPage::InsertText::Reply(handled, m_editorState), m_pageID); 188 189 m_temporarilyClosedComposition = false; 189 190 … … 191 192 } 192 193 193 bool WebPageProxy::insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, const Vector<TextAlternativeWithRange>& dictationAlternativesWithRange)194 bool WebPageProxy::insertDictatedText(const String& text, const EditingRange& replacementRange, const Vector<TextAlternativeWithRange>& dictationAlternativesWithRange) 194 195 { 195 196 #if USE(DICTATION_ALTERNATIVES) 196 197 if (dictationAlternativesWithRange.isEmpty()) 197 return insertText(text, replacementRange Start, replacementRangeLength);198 return insertText(text, replacementRange); 198 199 199 200 if (!isValid()) … … 210 211 211 212 if (dictationAlternatives.isEmpty()) 212 return insertText(text, replacementRange Start, replacementRangeLength);213 return insertText(text, replacementRange); 213 214 214 215 bool handled = true; 215 process().sendSync(Messages::WebPage::InsertDictatedText(text, replacementRange Start, replacementRangeLength, dictationAlternatives), Messages::WebPage::InsertDictatedText::Reply(handled, m_editorState), m_pageID);216 process().sendSync(Messages::WebPage::InsertDictatedText(text, replacementRange, dictationAlternatives), Messages::WebPage::InsertDictatedText::Reply(handled, m_editorState), m_pageID); 216 217 return handled; 217 218 #else 218 return insertText(text, replacementRange Start, replacementRangeLength);219 return insertText(text, replacementRange); 219 220 #endif 220 221 } 221 222 222 void WebPageProxy::getMarkedRange( uint64_t& location, uint64_t& length)223 { 224 location = NSNotFound;225 length = 0; 226 227 if (!isValid())228 return; 229 230 process().sendSync(Messages::WebPage::GetMarkedRange(), Messages::WebPage::GetMarkedRange::Reply(location, length), m_pageID);231 } 232 233 void WebPageProxy::getSelectedRange( uint64_t& location, uint64_t& length)234 { 235 location = NSNotFound;236 length = 0; 237 238 if (!isValid())239 return; 240 241 process().sendSync(Messages::WebPage::GetSelectedRange(), Messages::WebPage::GetSelectedRange::Reply(location, length), m_pageID);242 } 243 244 void WebPageProxy::getAttributedSubstringFromRange( uint64_t rangeStart, uint64_t rangeLength, AttributedString& result)245 { 246 if (!isValid()) 247 return; 248 process().sendSync(Messages::WebPage::GetAttributedSubstringFromRange(range Start, rangeLength), Messages::WebPage::GetAttributedSubstringFromRange::Reply(result), m_pageID);223 void WebPageProxy::getMarkedRange(EditingRange& result) 224 { 225 result = EditingRange(); 226 227 if (!isValid()) 228 return; 229 230 process().sendSync(Messages::WebPage::GetMarkedRange(), Messages::WebPage::GetMarkedRange::Reply(result), m_pageID); 231 MESSAGE_CHECK(result.isValid()); 232 } 233 234 void WebPageProxy::getSelectedRange(EditingRange& result) 235 { 236 result = EditingRange(); 237 238 if (!isValid()) 239 return; 240 241 process().sendSync(Messages::WebPage::GetSelectedRange(), Messages::WebPage::GetSelectedRange::Reply(result), m_pageID); 242 MESSAGE_CHECK(result.isValid()); 243 } 244 245 void WebPageProxy::getAttributedSubstringFromRange(const EditingRange& range, AttributedString& result) 246 { 247 if (!isValid()) 248 return; 249 process().sendSync(Messages::WebPage::GetAttributedSubstringFromRange(range), Messages::WebPage::GetAttributedSubstringFromRange::Reply(result), m_pageID); 249 250 } 250 251 … … 259 260 } 260 261 261 IntRect WebPageProxy::firstRectForCharacterRange( uint64_t location, uint64_t length)262 IntRect WebPageProxy::firstRectForCharacterRange(const EditingRange& range) 262 263 { 263 264 if (!isValid()) … … 265 266 266 267 IntRect resultRect; 267 process().sendSync(Messages::WebPage::FirstRectForCharacterRange( location, length), Messages::WebPage::FirstRectForCharacterRange::Reply(resultRect), m_pageID);268 process().sendSync(Messages::WebPage::FirstRectForCharacterRange(range), Messages::WebPage::FirstRectForCharacterRange::Reply(resultRect), m_pageID); 268 269 return resultRect; 269 270 } -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r165758 r165823 1461 1461 D3B9484911FF4B6500032B39 /* WebSearchPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484511FF4B6500032B39 /* WebSearchPopupMenu.h */; }; 1462 1462 DF58C6361371ACA000F9A37C /* NativeWebWheelEventMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = DF58C6351371ACA000F9A37C /* NativeWebWheelEventMac.mm */; }; 1463 E105FE5418D7B9DE008F57A8 /* EditingRange.h in Headers */ = {isa = PBXBuildFile; fileRef = E105FE5318D7B9DE008F57A8 /* EditingRange.h */; }; 1463 1464 E11D35AE16B63D1B006D23D7 /* com.apple.WebProcess.sb in Resources */ = {isa = PBXBuildFile; fileRef = E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */; }; 1464 1465 E133FD8A1423DD7F00FC7BFB /* WebKit.icns in Resources */ = {isa = PBXBuildFile; fileRef = E133FD891423DD7F00FC7BFB /* WebKit.icns */; }; … … 3323 3324 DF58C6311371AC5800F9A37C /* NativeWebWheelEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebWheelEvent.h; sourceTree = "<group>"; }; 3324 3325 DF58C6351371ACA000F9A37C /* NativeWebWheelEventMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebWheelEventMac.mm; sourceTree = "<group>"; }; 3326 E105FE5318D7B9DE008F57A8 /* EditingRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingRange.h; sourceTree = "<group>"; }; 3325 3327 E133FD891423DD7F00FC7BFB /* WebKit.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = WebKit.icns; path = Resources/WebKit.icns; sourceTree = "<group>"; }; 3326 3328 E13833EB189C33C8001E2350 /* LocalStorageDetails.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalStorageDetails.h; sourceTree = "<group>"; }; … … 3995 3997 C517388012DF8F4F00EE3F47 /* DragControllerAction.h */, 3996 3998 0FB659221208B4DB0044816C /* DrawingAreaInfo.h */, 3999 E105FE5318D7B9DE008F57A8 /* EditingRange.h */, 3997 4000 8CFECE931490F140002AAA32 /* EditorState.cpp */, 3998 4001 1AA41AB412C02EC4002BE67B /* EditorState.h */, … … 6568 6571 BCE81D8D1319F7EF00241910 /* FontInfo.h in Headers */, 6569 6572 1ABC3DFC1899F51C004F0626 /* WKNavigationDelegate.h in Headers */, 6573 E105FE5418D7B9DE008F57A8 /* EditingRange.h in Headers */, 6570 6574 BC17753F118BABF0007D9E9A /* GenericCallback.h in Headers */, 6571 6575 379A873618BBFA4300588AF2 /* _WKActivatedElementInfoInternal.h in Headers */, -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r165767 r165823 35 35 #include "DrawingArea.h" 36 36 #include "DrawingAreaMessages.h" 37 #include "EditingRange.h" 37 38 #include "EditorState.h" 38 39 #include "EventDispatcher.h" … … 4337 4338 } 4338 4339 4339 PassRefPtr<Range> WebPage::rangeFromEditingLocationAndLength(Frame& frame, uint64_t location, uint64_t length) 4340 { 4340 PassRefPtr<WebCore::Range> WebPage::rangeFromEditingRange(WebCore::Frame& frame, const EditingRange& range) 4341 { 4342 ASSERT(range.location != notFound); 4343 4341 4344 // Sanitize the input, because TextIterator::rangeFromLocationAndLength takes signed integers. 4342 if ( location > INT_MAX)4345 if (range.location > INT_MAX) 4343 4346 return 0; 4344 if (length > INT_MAX || location + length > INT_MAX) 4345 length = INT_MAX - location; 4347 int length; 4348 if (range.length <= INT_MAX && range.location + range.length <= INT_MAX) 4349 length = static_cast<int>(range.length); 4350 else 4351 length = INT_MAX - range.location; 4346 4352 4347 4353 // Our critical assumption is that we are only called by input methods that … … 4351 4357 // to use the root editable element of the selection start as the positional base. 4352 4358 // That fits with AppKit's idea of an input context. 4353 return TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), location, length); 4354 } 4359 return TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), static_cast<int>(range.location), length); 4360 } 4361 4355 4362 4356 4363 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r165767 r165823 164 164 struct AssistedNodeInformation; 165 165 struct AttributedString; 166 struct EditingRange; 166 167 struct EditorState; 167 168 struct InteractionInformationAtPosition; … … 456 457 void requestAutocorrectionContext(uint64_t callbackID); 457 458 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 replacementRangeLength);459 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength);459 void insertText(const String& text, const EditingRange& replacementRange); 460 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange); 460 461 void confirmComposition(); 461 462 void getPositionInformation(const WebCore::IntPoint&, InteractionInformationAtPosition&); … … 539 540 void cancelComposition(EditorState& newState); 540 541 #if !PLATFORM(IOS) 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);542 void insertText(const String& text, const EditingRange& replacementRange, bool& handled, EditorState& newState); 543 void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementRange, EditorState& newState); 543 544 void confirmComposition(EditorState& newState); 544 545 #endif 545 void getMarkedRange( uint64_t& location, uint64_t& length);546 void getSelectedRange( uint64_t& location, uint64_t& length);547 void getAttributedSubstringFromRange( uint64_t rangeStart, uint64_t rangeLength, AttributedString&);546 void getMarkedRange(EditingRange&); 547 void getSelectedRange(EditingRange&); 548 void getAttributedSubstringFromRange(const EditingRange&, AttributedString&); 548 549 void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result); 549 void firstRectForCharacterRange( uint64_t location, uint64_t length, WebCore::IntRect& resultRect);550 void firstRectForCharacterRange(const EditingRange&, WebCore::IntRect& resultRect); 550 551 void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState); 551 552 void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result); … … 555 556 void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result); 556 557 bool performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*); 557 void insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);558 void insertDictatedText(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState); 558 559 #elif PLATFORM(EFL) 559 560 void confirmComposition(const String& compositionString); … … 928 929 static PluginView* pluginViewForFrame(WebCore::Frame*); 929 930 930 PassRefPtr<WebCore::Range> rangeFromEditingLocationAndLength(WebCore::Frame&, uint64_t location, uint64_t length);931 static PassRefPtr<WebCore::Range> rangeFromEditingRange(WebCore::Frame&, const EditingRange&); 931 932 932 933 void reportUsedFeatures(); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r165769 r165823 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 replacementRangeLength)60 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength)59 InsertText(String text, WebKit::EditingRange replacementRange) 60 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, WebKit::EditingRange selectionRange) 61 61 ConfirmComposition() 62 62 GetPositionInformation(WebCore::IntPoint point) -> (WebKit::InteractionInformationAtPosition information) … … 293 293 # Text input. 294 294 CancelComposition() -> (WebKit::EditorState newState) 295 GetMarkedRange() -> ( uint64_t location, uint64_t length)296 GetSelectedRange() -> ( uint64_t location, uint64_t length)297 GetAttributedSubstringFromRange( uint64_t rangeStart, uint64_t rangeLength) -> (WebKit::AttributedString result)295 GetMarkedRange() -> (WebKit::EditingRange range) 296 GetSelectedRange() -> (WebKit::EditingRange range) 297 GetAttributedSubstringFromRange(WebKit::EditingRange range) -> (WebKit::AttributedString result) 298 298 CharacterIndexForPoint(WebCore::IntPoint point) -> (uint64_t result) 299 FirstRectForCharacterRange( uint64_t location, uint64_t length) -> (WebCore::IntRect resultRect)299 FirstRectForCharacterRange(WebKit::EditingRange range) -> (WebCore::IntRect resultRect) 300 300 ExecuteKeypressCommands(Vector<WebCore::KeypressCommand> savedCommands) -> (bool handled, WebKit::EditorState newState) 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 replacementRangeLength, Vector<WebCore::DictationAlternative> dictationAlternatives) -> (bool handled, WebKit::EditorState newState)303 InsertDictatedText(String text, WebKit::EditingRange replacementRange, 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 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)306 InsertText(String text, WebKit::EditingRange replacementRange) -> (bool handled, WebKit::EditorState newState) 307 SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, WebKit::EditingRange selectionRange, WebKit::EditingRange replacementRange) -> (WebKit::EditorState newState) 308 308 ConfirmComposition() -> (WebKit::EditorState newState) 309 309 #endif -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r165767 r165823 31 31 #import "AssistedNodeInformation.h" 32 32 #import "DataReference.h" 33 #import "EditingRange.h" 33 34 #import "EditorState.h" 34 35 #import "InteractionInformationAtPosition.h" … … 167 168 } 168 169 169 void WebPage::setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength)170 void WebPage::setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange) 170 171 { 171 172 Frame& frame = m_page->focusController().focusedOrMainFrame(); 172 173 173 174 if (frame.selection().selection().isContentEditable()) 174 frame.editor().setComposition(text, underlines, selection Start, selectionStart + selectionLength);175 frame.editor().setComposition(text, underlines, selectionRange.location, selectionRange.location + selectionRange.length); 175 176 } 176 177 … … 186 187 } 187 188 188 void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength)189 void WebPage::insertText(const String& text, const EditingRange& replacementEditingRange) 189 190 { 190 191 Frame& frame = m_page->focusController().focusedOrMainFrame(); 191 192 192 if (replacement RangeStart != NSNotFound) {193 RefPtr<Range> replacementRange = rangeFromEditing LocationAndLength(frame, replacementRangeStart, replacementRangeLength);193 if (replacementEditingRange.location != notFound) { 194 RefPtr<Range> replacementRange = rangeFromEditingRange(frame, replacementEditingRange); 194 195 if (replacementRange) 195 196 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); … … 204 205 } 205 206 206 void WebPage::insertDictatedText(const String&, uint64_t, uint64_t, const Vector<WebCore::DictationAlternative>&, bool&, EditorState&)207 { 208 notImplemented(); 209 } 210 211 void WebPage::getMarkedRange( uint64_t&, uint64_t&)212 { 213 notImplemented(); 214 } 215 216 void WebPage::getSelectedRange( uint64_t&, uint64_t&)217 { 218 notImplemented(); 219 } 220 221 void WebPage::getAttributedSubstringFromRange( uint64_t, uint64_t, AttributedString&)207 void WebPage::insertDictatedText(const String&, const EditingRange&, const Vector<WebCore::DictationAlternative>&, bool&, EditorState&) 208 { 209 notImplemented(); 210 } 211 212 void WebPage::getMarkedRange(EditingRange&) 213 { 214 notImplemented(); 215 } 216 217 void WebPage::getSelectedRange(EditingRange&) 218 { 219 notImplemented(); 220 } 221 222 void WebPage::getAttributedSubstringFromRange(const EditingRange&, AttributedString&) 222 223 { 223 224 notImplemented(); … … 229 230 } 230 231 231 void WebPage::firstRectForCharacterRange( uint64_t, uint64_t, WebCore::IntRect&)232 void WebPage::firstRectForCharacterRange(const EditingRange&, WebCore::IntRect&) 232 233 { 233 234 notImplemented(); -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r165767 r165823 31 31 #import "AttributedString.h" 32 32 #import "DataReference.h" 33 #import "EditingRange.h" 33 34 #import "EditorState.h" 34 35 #import "PDFKitImports.h" … … 246 247 } 247 248 248 void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionLength, uint64_t replacementRangeStart, uint64_t replacementRangeLength, EditorState& newState)249 void WebPage::setComposition(const String& text, Vector<CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementEditingRange, EditorState& newState) 249 250 { 250 251 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 252 253 if (frame.selection().selection().isContentEditable()) { 253 254 RefPtr<Range> replacementRange; 254 if (replacement RangeStart != NSNotFound) {255 replacementRange = rangeFromEditing LocationAndLength(frame, replacementRangeStart, replacementRangeLength);255 if (replacementEditingRange.location != notFound) { 256 replacementRange = rangeFromEditingRange(frame, replacementEditingRange); 256 257 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); 257 258 } 258 259 259 frame.editor().setComposition(text, underlines, selection Start, selectionStart + selectionLength);260 frame.editor().setComposition(text, underlines, selectionRange.location, selectionRange.location + selectionRange.length); 260 261 } 261 262 … … 277 278 } 278 279 279 void WebPage::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, bool& handled, EditorState& newState)280 { 281 Frame& frame = m_page->focusController().focusedOrMainFrame(); 282 283 if (replacement RangeStart != NSNotFound) {284 RefPtr<Range> replacementRange = rangeFromEditing LocationAndLength(frame, replacementRangeStart, replacementRangeLength);280 void WebPage::insertText(const String& text, const EditingRange& replacementEditingRange, bool& handled, EditorState& newState) 281 { 282 Frame& frame = m_page->focusController().focusedOrMainFrame(); 283 284 if (replacementEditingRange.location != notFound) { 285 RefPtr<Range> replacementRange = rangeFromEditingRange(frame, replacementEditingRange); 285 286 if (replacementRange) 286 287 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); … … 299 300 } 300 301 301 void WebPage::insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeLength, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState)302 { 303 Frame& frame = m_page->focusController().focusedOrMainFrame(); 304 305 if (replacement RangeStart != NSNotFound) {306 RefPtr<Range> replacementRange = rangeFromEditing LocationAndLength(frame, replacementRangeStart, replacementRangeLength);302 void WebPage::insertDictatedText(const String& text, const EditingRange& replacementEditingRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState) 303 { 304 Frame& frame = m_page->focusController().focusedOrMainFrame(); 305 306 if (replacementEditingRange.location != notFound) { 307 RefPtr<Range> replacementRange = rangeFromEditingRange(frame, replacementEditingRange); 307 308 if (replacementRange) 308 309 frame.selection().setSelection(VisibleSelection(replacementRange.get(), SEL_DEFAULT_AFFINITY)); … … 314 315 } 315 316 316 void WebPage::getMarkedRange( uint64_t& location, uint64_t& length)317 void WebPage::getMarkedRange(EditingRange& result) 317 318 { 318 319 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 321 322 size_t locationSize; 322 323 size_t lengthSize; 323 if (range && TextIterator::getLocationAndLengthFromRange(frame.selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) { 324 location = static_cast<uint64_t>(locationSize); 325 length = static_cast<uint64_t>(lengthSize); 326 } else { 327 location = NSNotFound; 328 length = 0; 329 } 330 } 331 332 void WebPage::getSelectedRange(uint64_t& location, uint64_t& length) 324 if (range && TextIterator::getLocationAndLengthFromRange(frame.selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) 325 result = EditingRange(static_cast<uint64_t>(locationSize), static_cast<uint64_t>(lengthSize)); 326 else 327 result = EditingRange(); 328 } 329 330 void WebPage::getSelectedRange(EditingRange& result) 333 331 { 334 332 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 337 335 size_t lengthSize; 338 336 RefPtr<Range> range = frame.selection().toNormalizedRange(); 339 if (range && TextIterator::getLocationAndLengthFromRange(frame.selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) { 340 location = static_cast<uint64_t>(locationSize); 341 length = static_cast<uint64_t>(lengthSize); 342 } else { 343 location = NSNotFound; 344 length = 0; 345 } 346 } 347 348 void WebPage::getAttributedSubstringFromRange(uint64_t rangeStart, uint64_t rangeLength, AttributedString& result) 337 if (range && TextIterator::getLocationAndLengthFromRange(frame.selection().rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) 338 result = EditingRange(static_cast<uint64_t>(locationSize), static_cast<uint64_t>(lengthSize)); 339 else 340 result = EditingRange(); 341 } 342 343 void WebPage::getAttributedSubstringFromRange(const EditingRange& editingRange, AttributedString& result) 349 344 { 350 345 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 354 349 return; 355 350 356 RefPtr<Range> range = rangeFromEditing LocationAndLength(frame, rangeStart, rangeLength);351 RefPtr<Range> range = rangeFromEditingRange(frame, editingRange); 357 352 if (!range) 358 353 return; … … 364 359 // whitespace at the end of the string which breaks the ATOK input method. <rdar://problem/5400551> 365 360 // To work around this we truncate the resultant string to the correct length. 366 if ([attributedString length] > rangeLength) {367 ASSERT([attributedString length] == rangeLength + 1);368 ASSERT([[attributedString string] characterAtIndex: rangeLength] == '\n' || [[attributedString string] characterAtIndex:rangeLength] == ' ');369 result.string = [attributedString attributedSubstringFromRange:NSMakeRange(0, rangeLength)];361 if ([attributedString length] > editingRange.length) { 362 ASSERT([attributedString length] == editingRange.length + 1); 363 ASSERT([[attributedString string] characterAtIndex:editingRange.length] == '\n' || [[attributedString string] characterAtIndex:editingRange.length] == ' '); 364 result.string = [attributedString attributedSubstringFromRange:NSMakeRange(0, editingRange.length)]; 370 365 } 371 366 } … … 373 368 void WebPage::characterIndexForPoint(IntPoint point, uint64_t& index) 374 369 { 375 index = NSNotFound;370 index = notFound; 376 371 377 372 HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(point); … … 388 383 } 389 384 390 void WebPage::firstRectForCharacterRange( uint64_t location, uint64_t length, WebCore::IntRect& resultRect)385 void WebPage::firstRectForCharacterRange(const EditingRange& editingRange, WebCore::IntRect& resultRect) 391 386 { 392 387 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 394 389 resultRect.setSize(IntSize(0, 0)); 395 390 396 RefPtr<Range> range = rangeFromEditing LocationAndLength(frame, location, length);391 RefPtr<Range> range = rangeFromEditingRange(frame, editingRange); 397 392 if (!range) 398 393 return;
Note: See TracChangeset
for help on using the changeset viewer.