Changeset 215724 in webkit
- Timestamp:
- Apr 25, 2017 12:00:59 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r215722 r215724 1 2017-04-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support reading NSURL titles from the pasteboard when performing data interaction 4 https://bugs.webkit.org/show_bug.cgi?id=171156 5 <rdar://problem/31356937> 6 7 Reviewed by Tim Horton. 8 9 Support reading link titles from the pasteboard when performing data interaction. To do this, we refactor 10 Pasteboard::readURL to take in an additional String& title which is ultimately plumbed to the PlatformPasteboard 11 where it is set to the value of -[NSURL _title]. 12 13 Test: DataInteractionTests.ExternalSourceTitledNSURL. 14 15 * editing/FrameSelection.h: 16 * editing/ios/EditorIOS.mm: 17 (WebCore::Editor::WebContentReader::readURL): 18 * page/DragController.cpp: 19 (WebCore::DragController::performDragOperation): 20 (WebCore::DragController::concludeEditDrag): 21 22 Move calls to clearDragCaret() out of concludeEditDrag and into the call site, in performDragOperation after 23 attempting to concludeEditDrag. This is done so that if the WebEditorClient queries whether the drag caret is 24 in richly editable content for the purposes of generating a document fragment to insert, the answer will not 25 always be false as a drop is occurring. 26 27 * platform/PasteboardStrategy.h: 28 * platform/PlatformPasteboard.h: 29 * platform/ios/PasteboardIOS.mm: 30 (WebCore::Pasteboard::respectsUTIFidelities): 31 (WebCore::Pasteboard::readString): 32 * platform/ios/PlatformPasteboardIOS.mm: 33 (WebCore::PlatformPasteboard::readURL): 34 1 35 2017-04-24 Andy VanWagoner <thetalecrafter@gmail.com> 2 36 -
trunk/Source/WebCore/editing/FrameSelection.h
r212484 r215724 98 98 99 99 bool isContentEditable() const { return m_position.rootEditableElement(); } 100 bool isContentRichlyEditable() const;100 WEBCORE_EXPORT bool isContentRichlyEditable() const; 101 101 102 102 bool hasCaret() const { return m_position.isNotNull(); } -
trunk/Source/WebCore/editing/ios/EditorIOS.mm
r215686 r215724 321 321 } 322 322 323 bool Editor::WebContentReader::readURL(const URL& url, const String& )323 bool Editor::WebContentReader::readURL(const URL& url, const String& title) 324 324 { 325 325 if (url.isEmpty()) … … 349 349 auto anchor = HTMLAnchorElement::create(*frame.document()); 350 350 anchor->setAttributeWithoutSynchronization(HTMLNames::hrefAttr, url.string()); 351 anchor->appendChild(frame.document()->createTextNode([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping])); 351 352 String linkText = title.length() ? title : String([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]); 353 anchor->appendChild(frame.document()->createTextNode(linkText)); 352 354 353 355 auto newFragment = frame.document()->createDocumentFragment(); -
trunk/Source/WebCore/page/DragController.cpp
r215669 r215724 250 250 m_client.didConcludeEditDrag(); 251 251 m_documentUnderMouse = nullptr; 252 clearDragCaret(); 252 253 return true; 253 254 } 254 255 255 256 m_documentUnderMouse = nullptr; 257 clearDragCaret(); 256 258 257 259 if (operationForLoad(dragData) == DragOperationNone) … … 509 511 } 510 512 511 if (!m_page.dragController().canProcessDrag(dragData)) { 512 clearDragCaret(); 513 return false; 514 } 513 if (!m_page.dragController().canProcessDrag(dragData)) 514 return false; 515 515 516 516 VisibleSelection dragCaret = m_page.dragCaretController().caretPosition(); 517 clearDragCaret();518 517 RefPtr<Range> range = dragCaret.toNormalizedRange(); 519 518 RefPtr<Element> rootEditableElement = innerFrame->selection().selection().rootEditableElement(); -
trunk/Source/WebCore/platform/PasteboardStrategy.h
r215714 r215724 51 51 virtual String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) = 0; 52 52 virtual RefPtr<SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) = 0; 53 virtual URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName ) = 0;53 virtual URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName, String& title) = 0; 54 54 virtual void getFilenamesForDataInteraction(Vector<String>& filenames, const String& pasteboardName) = 0; 55 55 virtual void getTypesByFidelityForItemAtIndex(Vector<String>& types, uint64_t index, const String& pasteboardName) = 0; -
trunk/Source/WebCore/platform/PlatformPasteboard.h
r215714 r215724 84 84 WEBCORE_EXPORT RefPtr<SharedBuffer> readBuffer(int index, const String& pasteboardType); 85 85 WEBCORE_EXPORT String readString(int index, const String& pasteboardType); 86 WEBCORE_EXPORT URL readURL(int index, const String& pasteboardType );86 WEBCORE_EXPORT URL readURL(int index, const String& pasteboardType, String& title); 87 87 WEBCORE_EXPORT int count(); 88 88 WEBCORE_EXPORT int numberOfFiles(); -
trunk/Source/WebCore/platform/ios/PasteboardIOS.mm
r215714 r215724 194 194 195 195 if ([type isEqualToString:(NSString *)kUTTypeURL]) { 196 URL url = strategy.readURLFromPasteboard(itemIndex, kUTTypeURL, pasteboardName); 197 return !url.isNull() && reader.readURL(url, String()); 196 String title; 197 URL url = strategy.readURLFromPasteboard(itemIndex, kUTTypeURL, pasteboardName, title); 198 return !url.isNull() && reader.readURL(url, title); 198 199 } 199 200 … … 329 330 330 331 if ([cocoaType isEqualToString:(NSString *)kUTTypeURL]) { 331 URL url = strategy.readURLFromPasteboard(0, kUTTypeURL, m_pasteboardName); 332 String title; 333 URL url = strategy.readURLFromPasteboard(0, kUTTypeURL, m_pasteboardName, title); 332 334 if (!url.isNull()) 333 335 cocoaValue = [(NSURL *)url absoluteString]; -
trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
r215714 r215724 390 390 } 391 391 392 URL PlatformPasteboard::readURL(int index, const String& type )392 URL PlatformPasteboard::readURL(int index, const String& type, String& title) 393 393 { 394 394 NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:index]; … … 404 404 return URL(); 405 405 406 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 407 if ([value respondsToSelector:@selector(_title)]) 408 title = [value _title]; 409 #else 410 UNUSED_PARAM(title); 411 #endif 412 406 413 return (NSURL *)value; 407 414 } -
trunk/Source/WebKit/mac/ChangeLog
r215722 r215724 1 2017-04-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support reading NSURL titles from the pasteboard when performing data interaction 4 https://bugs.webkit.org/show_bug.cgi?id=171156 5 <rdar://problem/31356937> 6 7 Reviewed by Tim Horton. 8 9 Add a new WK1 SPI property, -[WebFrame hasRichlyEditableDragCaret]. 10 11 * WebCoreSupport/WebPlatformStrategies.h: 12 * WebCoreSupport/WebPlatformStrategies.mm: 13 (WebPlatformStrategies::readURLFromPasteboard): 14 * WebView/WebFrame.mm: 15 (-[WebFrame hasRichlyEditableDragCaret]): 16 * WebView/WebFramePrivate.h: 17 1 18 2017-04-24 Andy VanWagoner <thetalecrafter@gmail.com> 2 19 -
trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h
r215714 r215724 66 66 String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override; 67 67 RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override; 68 WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName ) override;68 WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName, String& title) override; 69 69 void getFilenamesForDataInteraction(Vector<String>& filenames, const String& pasteboardName) override; 70 70 void getTypesByFidelityForItemAtIndex(Vector<String>& types, uint64_t index, const String& pasteboardName) override; -
trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
r215714 r215724 222 222 } 223 223 224 WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& type, const String& pasteboardName )225 { 226 return PlatformPasteboard(pasteboardName).readURL(index, type );224 WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& type, const String& pasteboardName, String& title) 225 { 226 return PlatformPasteboard(pasteboardName).readURL(index, type, title); 227 227 } 228 228 -
trunk/Source/WebKit/mac/WebView/WebFrame.mm
r215686 r215724 2217 2217 } 2218 2218 2219 - (BOOL)hasRichlyEditableDragCaret 2220 { 2221 if (auto* page = core(self)->page()) 2222 return page->dragCaretController().isContentRichlyEditable(); 2223 return NO; 2224 } 2225 2219 2226 // Used by pagination code called from AppKit when a standalone web page is printed. 2220 2227 - (NSArray *)_computePageRectsWithPrintScaleFactor:(float)printScaleFactor pageSize:(NSSize)pageSize -
trunk/Source/WebKit/mac/WebView/WebFramePrivate.h
r211021 r215724 278 278 - (NSArray *)_computePageRectsWithPrintScaleFactor:(float)printWidthScaleFactor pageSize:(NSSize)pageSize; 279 279 280 // Drag and drop support. 281 @property (nonatomic, readonly) BOOL hasRichlyEditableDragCaret; 282 280 283 #if TARGET_OS_IPHONE 281 284 - (DOMDocumentFragment *)_documentFragmentForText:(NSString *)text; -
trunk/Source/WebKit2/ChangeLog
r215714 r215724 1 2017-04-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support reading NSURL titles from the pasteboard when performing data interaction 4 https://bugs.webkit.org/show_bug.cgi?id=171156 5 <rdar://problem/31356937> 6 7 Reviewed by Tim Horton. 8 9 Adjust for interface changes in WebCore to support plumbing the title of an NSURL from the platform pasteboard 10 back to WebCore. Additionally, implement WebEditorClient::hasRichlyEditableSelection (which previously returned 11 false) to check whether the current selection is richly editable, or the drop caret is in richly editable content. 12 See WebCore ChangeLog for more details. 13 14 * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: 15 (WebKit::WebPasteboardProxy::readURLFromPasteboard): 16 * UIProcess/WebPasteboardProxy.h: 17 * UIProcess/WebPasteboardProxy.messages.in: 18 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 19 (WebKit::WebPlatformStrategies::readURLFromPasteboard): 20 * WebProcess/WebCoreSupport/WebPlatformStrategies.h: 21 * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm: 22 (WebKit::WebEditorClient::hasRichlyEditableSelection): 23 * WebProcess/WebPage/WebPage.cpp: 24 (WebKit::WebPage::hasRichlyEditableSelection): 25 * WebProcess/WebPage/WebPage.h: 26 1 27 2017-04-24 Wenson Hsieh <wenson_hsieh@apple.com> 2 28 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
r215714 r215724 171 171 } 172 172 173 void WebPasteboardProxy::readURLFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, String& url )174 { 175 url = PlatformPasteboard(pasteboardName).readURL(index, pasteboardType );173 void WebPasteboardProxy::readURLFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, String& url, String& title) 174 { 175 url = PlatformPasteboard(pasteboardName).readURL(index, pasteboardType, title); 176 176 } 177 177 -
trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.h
r215714 r215724 76 76 void writeStringToPasteboard(const String& pasteboardType, const String&, const String& pasteboardName); 77 77 void readStringFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, WTF::String&); 78 void readURLFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, String& );78 void readURLFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, String& url, String& title); 79 79 void readBufferFromPasteboard(uint64_t index, const String& pasteboardType, const String& pasteboardName, SharedMemory::Handle&, uint64_t& size); 80 80 void getPasteboardItemsCount(const String& pasteboardName, uint64_t& itemsCount); -
trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in
r215714 r215724 28 28 WriteStringToPasteboard(String pasteboardType, String text, String pasteboardName) 29 29 ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string) 30 ReadURLFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String string)30 ReadURLFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (String url, String title) 31 31 ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName) -> (WebKit::SharedMemory::Handle handle, uint64_t size) 32 32 GetPasteboardItemsCount(String pasteboardName) -> (uint64_t itemsCount) -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r215714 r215724 336 336 } 337 337 338 WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName )338 WebCore::URL WebPlatformStrategies::readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName, String& title) 339 339 { 340 340 String urlString; 341 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadURLFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadURLFromPasteboard::Reply(urlString ), 0);341 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadURLFromPasteboard(index, pasteboardType, pasteboardName), Messages::WebPasteboardProxy::ReadURLFromPasteboard::Reply(urlString, title), 0); 342 342 return URL(ParsedURLString, urlString); 343 343 } -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
r215714 r215724 67 67 String readStringFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override; 68 68 RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName) override; 69 WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName ) override;69 WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType, const String& pasteboardName, String& title) override; 70 70 void getFilenamesForDataInteraction(Vector<String>& filenames, const String& pasteboardName) override; 71 71 void getTypesByFidelityForItemAtIndex(Vector<String>& types, uint64_t index, const String& pasteboardName) override; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm
r204717 r215724 102 102 bool WebEditorClient::hasRichlyEditableSelection() 103 103 { 104 notImplemented(); 105 return false; 104 return m_page->hasRichlyEditableSelection(); 106 105 } 107 106 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r215653 r215724 3870 3870 #endif 3871 3871 3872 bool WebPage::hasRichlyEditableSelection() const 3873 { 3874 auto& frame = m_page->focusController().focusedOrMainFrame(); 3875 if (m_page->dragCaretController().isContentRichlyEditable()) 3876 return true; 3877 3878 return frame.selection().selection().isContentRichlyEditable(); 3879 } 3880 3872 3881 void WebPage::changeSpellingToWord(const String& word) 3873 3882 { -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r215255 r215724 600 600 void setForceAlwaysUserScalable(bool); 601 601 #endif 602 bool hasRichlyEditableSelection() const; 602 603 603 604 void setLayerTreeStateIsFrozen(bool); -
trunk/Tools/ChangeLog
r215714 r215724 1 2017-04-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Support reading NSURL titles from the pasteboard when performing data interaction 4 https://bugs.webkit.org/show_bug.cgi?id=171156 5 <rdar://problem/31356937> 6 7 Reviewed by Tim Horton. 8 9 Adds a new unit test, DataInteractionTests.ExternalSourceTitledNSURL. 10 11 * TestWebKitAPI/Tests/ios/DataInteractionTests.mm: 12 (TestWebKitAPI::TEST): 13 1 14 2017-04-24 Wenson Hsieh <wenson_hsieh@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
r215714 r215724 535 535 } 536 536 537 TEST(DataInteractionTests, ExternalSourceTitledNSURL) 538 { 539 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 540 [webView synchronouslyLoadTestPageNamed:@"autofocus-contenteditable"]; 541 [webView stringByEvaluatingJavaScript:@"getSelection().removeAllRanges()"]; 542 543 NSURL *titledURL = [NSURL URLWithString:@"https://www.apple.com"]; 544 titledURL._title = @"Apple"; 545 auto simulatedItemProvider = adoptNS([[UIItemProvider alloc] init]); 546 [simulatedItemProvider registerObject:titledURL visibility:NSItemProviderRepresentationVisibilityAll]; 547 548 auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]); 549 [dataInteractionSimulator setExternalItemProviders:@[ simulatedItemProvider.get() ]]; 550 [dataInteractionSimulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)]; 551 552 EXPECT_WK_STREQ("Apple", [webView stringByEvaluatingJavaScript:@"editor.querySelector('a').textContent"]); 553 EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"editor.querySelector('a').href"]); 554 } 555 537 556 TEST(DataInteractionTests, OverrideDataInteractionOperation) 538 557 {
Note: See TracChangeset
for help on using the changeset viewer.