Changeset 245595 in webkit
- Timestamp:
- May 21, 2019 2:54:05 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r245589 r245595 1 2019-05-21 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 The cost of WebViewImpl::hasMarkedTextWithCompletionHandler should not increase with document size 4 https://bugs.webkit.org/show_bug.cgi?id=198075 5 <rdar://problem/37560103> 6 7 Reviewed by Tim Horton. 8 9 * UIProcess/Cocoa/WebViewImpl.mm: 10 (WebKit::WebViewImpl::hasMarkedTextWithCompletionHandler): 11 12 Refactor hasMarkedTextWithCompletionHandler to use Editor::hasComposition, instead of computing the actual 13 marked text range. The latter is more expensive and unnecessary, since it uses TextIterator from the document 14 root to find editing offsets. This makes the cost of determining whether there is marked text proportional to 15 the document size. 16 17 This matches behavior in legacy WebKit, as well as iOS. 18 19 * UIProcess/WebPageProxy.cpp: 20 (WebKit::WebPageProxy::hasMarkedText): 21 * UIProcess/WebPageProxy.h: 22 * WebProcess/WebPage/WebPage.cpp: 23 (WebKit::WebPage::hasMarkedText): 24 * WebProcess/WebPage/WebPage.h: 25 * WebProcess/WebPage/WebPage.messages.in: 26 1 27 2019-05-21 Jiewen Tan <jiewen_tan@apple.com> 2 28 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r245073 r245595 4813 4813 } 4814 4814 4815 void WebViewImpl::hasMarkedTextWithCompletionHandler(void(^completionHandlerPtr)(BOOL hasMarkedText)) 4816 { 4817 auto completionHandler = adoptNS([completionHandlerPtr copy]); 4818 4815 void WebViewImpl::hasMarkedTextWithCompletionHandler(void(^completionHandler)(BOOL hasMarkedText)) 4816 { 4819 4817 LOG(TextInput, "hasMarkedText"); 4820 m_page->getMarkedRangeAsync([completionHandler](const EditingRange& editingRangeResult, WebKit::CallbackBase::Error error) { 4821 void (^completionHandlerBlock)(BOOL) = (void (^)(BOOL))completionHandler.get(); 4822 if (error != WebKit::CallbackBase::Error::None) { 4823 LOG(TextInput, " ...hasMarkedText failed."); 4824 completionHandlerBlock(NO); 4825 return; 4826 } 4827 BOOL hasMarkedText = editingRangeResult.location != notFound; 4828 LOG(TextInput, " -> hasMarkedText returned %u", hasMarkedText); 4829 completionHandlerBlock(hasMarkedText); 4818 m_page->hasMarkedText([completionHandler = makeBlockPtr(completionHandler)] (bool result) { 4819 completionHandler(result); 4820 LOG(TextInput, " -> hasMarkedText returned %u", result); 4830 4821 }); 4831 4822 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r245540 r245595 7952 7952 } 7953 7953 7954 void WebPageProxy::hasMarkedText(CompletionHandler<void(bool)>&& callback) 7955 { 7956 if (!hasRunningProcess()) { 7957 callback(false); 7958 return; 7959 } 7960 m_process->connection()->sendWithAsyncReply(Messages::WebPage::HasMarkedText(), WTFMove(callback), m_pageID); 7961 } 7962 7954 7963 void WebPageProxy::getMarkedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&& callbackFunction) 7955 7964 { -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r245565 r245595 770 770 void setTextAsync(const String&); 771 771 void insertTextAsync(const String& text, const EditingRange& replacementRange, InsertTextOptions&&); 772 void hasMarkedText(CompletionHandler<void(bool)>&&); 772 773 void getMarkedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&&); 773 774 void getSelectedRangeAsync(WTF::Function<void (EditingRange, CallbackBase::Error)>&&); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r245543 r245595 5174 5174 } 5175 5175 5176 void WebPage::hasMarkedText(CompletionHandler<void(bool)>&& completionHandler) 5177 { 5178 completionHandler(m_page->focusController().focusedOrMainFrame().editor().hasComposition()); 5179 } 5180 5176 5181 void WebPage::getMarkedRangeAsync(CallbackID callbackID) 5177 5182 { -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r245565 r245595 790 790 void setTextAsync(const String&); 791 791 void insertTextAsync(const String& text, const EditingRange& replacementRange, InsertTextOptions&&); 792 void hasMarkedText(CompletionHandler<void(bool)>&&); 792 793 void getMarkedRangeAsync(CallbackID); 793 794 void getSelectedRangeAsync(CallbackID); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r245335 r245595 435 435 SetTextAsync(String text) 436 436 InsertTextAsync(String text, struct WebKit::EditingRange replacementRange, struct WebKit::InsertTextOptions options) 437 HasMarkedText() -> (bool hasMarkedText) Async 437 438 GetMarkedRangeAsync(WebKit::CallbackID callbackID) 438 439 GetSelectedRangeAsync(WebKit::CallbackID callbackID)
Note: See TracChangeset
for help on using the changeset viewer.