Remove unnecessary userVisibleString EditorClient function
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 21:08:10 +0000 (21:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2017 21:08:10 +0000 (21:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177456

Patch by Sam Weinig <sam@webkit.org> on 2017-09-25
Reviewed by Dan Bernstein.

Source/WebCore:

The implementation of userVisibleString has been in WebCore for sometime (in WebCoreNSURLExtras)
so there is no need to call through the EditorClient, just for it to call back to WebCore.

* editing/Editor.h:

    Keep userVisibleString helper function but make it static, as it no longer needs
    any state. It is useful to have this helper, so non-ObjC code in Editor can get a
    userVisibleString.

* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::userVisibleString):

    Call through to the WebCoreNSURLExtras implementation.

* editing/mac/EditorMac.mm:
(WebCore::Editor::plainTextFromPasteboard):
(WebCore::Editor::writeImageToPasteboard):
(WebCore::Editor::userVisibleString): Deleted.
* editing/mac/WebContentReaderMac.mm:
(WebCore::WebContentReader::readFilenames):

    Replace client calls with direct calls.

* loader/EmptyClients.cpp:
* page/EditorClient.h:

    Remove client function.

* testing/Internals.mm:
(WebCore::Internals::userVisibleString):

    Replace client call with direct call.

Source/WebKit:

* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::userVisibleString): Deleted.
* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
(WebKit::WebEditorClient::userVisibleString): Deleted.

    Remove userVisibleString client function.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::userVisibleString): Deleted.

    Remove userVisibleString client function.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222465 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.h
Source/WebCore/editing/cocoa/EditorCocoa.mm
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/editing/mac/WebContentReaderMac.mm
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/page/EditorClient.h
Source/WebCore/testing/Internals.mm
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h
Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm
Source/WebKit/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm

index cd2d715..8cc7b4f 100644 (file)
@@ -1,3 +1,43 @@
+2017-09-25  Sam Weinig  <sam@webkit.org>
+
+        Remove unnecessary userVisibleString EditorClient function
+        https://bugs.webkit.org/show_bug.cgi?id=177456
+
+        Reviewed by Dan Bernstein.
+
+        The implementation of userVisibleString has been in WebCore for sometime (in WebCoreNSURLExtras)
+        so there is no need to call through the EditorClient, just for it to call back to WebCore.
+
+        * editing/Editor.h:
+
+            Keep userVisibleString helper function but make it static, as it no longer needs
+            any state. It is useful to have this helper, so non-ObjC code in Editor can get a
+            userVisibleString.
+
+        * editing/cocoa/EditorCocoa.mm:
+        (WebCore::Editor::userVisibleString):
+
+            Call through to the WebCoreNSURLExtras implementation.
+
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::plainTextFromPasteboard):
+        (WebCore::Editor::writeImageToPasteboard):
+        (WebCore::Editor::userVisibleString): Deleted.
+        * editing/mac/WebContentReaderMac.mm:
+        (WebCore::WebContentReader::readFilenames):
+
+            Replace client calls with direct calls.
+
+        * loader/EmptyClients.cpp:
+        * page/EditorClient.h:
+
+            Remove client function.
+
+        * testing/Internals.mm:
+        (WebCore::Internals::userVisibleString):
+
+            Replace client call with direct call.
+
 2017-09-25  Timothy Horton  <timothy_horton@apple.com>
 
         Fix the build with <attachment> disabled
index 4642182..3c0feea 100644 (file)
@@ -535,8 +535,7 @@ private:
     RefPtr<SharedBuffer> selectionInWebArchiveFormat();
     String selectionInHTMLFormat();
     RefPtr<SharedBuffer> imageInWebArchiveFormat(Element&);
-    String userVisibleString(const URL&);
-
+    static String userVisibleString(const URL&);
     static RefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *);
     static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *);
 #endif
index e8a5734..1ea4911 100644 (file)
@@ -49,6 +49,7 @@
 #import "RenderStyle.h"
 #import "Text.h"
 #import "WebContentReader.h"
+#import "WebCoreNSURLExtras.h"
 #import <pal/spi/cocoa/NSAttributedStringSPI.h>
 #import <wtf/BlockObjCExceptions.h>
 
@@ -226,6 +227,11 @@ void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributed
     }
 }
 
+String Editor::userVisibleString(const URL& url)
+{
+    return WebCore::userVisibleString(url);
+}
+
 RefPtr<SharedBuffer> Editor::dataInRTFDFormat(NSAttributedString *string)
 {
     NSUInteger length = string.length;
index 449d34e..27c846e 100644 (file)
@@ -32,7 +32,6 @@
 #import "DataTransfer.h"
 #import "DocumentFragment.h"
 #import "Editing.h"
-#import "Editor.h"
 #import "EditorClient.h"
 #import "Frame.h"
 #import "FrameView.h"
@@ -50,6 +49,7 @@
 #import "RuntimeEnabledFeatures.h"
 #import "StyleProperties.h"
 #import "WebContentReader.h"
+#import "WebCoreNSURLExtras.h"
 #import "WebNSAttributedStringExtras.h"
 #import "markup.h"
 #import <AppKit/AppKit.h>
@@ -239,11 +239,6 @@ static void getImage(Element& imageElement, RefPtr<Image>& image, CachedImage*&
     cachedImage = tentativeCachedImage;
 }
 
-String Editor::userVisibleString(const URL& url)
-{
-    return client()->userVisibleString(url);
-}
-
 void Editor::selectionWillChange()
 {
     if (!hasComposition() || ignoreSelectionChanges() || m_frame.selection().isNone())
@@ -255,12 +250,12 @@ void Editor::selectionWillChange()
 
 String Editor::plainTextFromPasteboard(const PasteboardPlainText& text)
 {
-    String string = text.text;
+    auto string = text.text;
 
     // FIXME: It's not clear this is 100% correct since we know -[NSURL URLWithString:] does not handle
     // all the same cases we handle well in the URL code for creating an NSURL.
     if (text.isURL)
-        string = client()->userVisibleString([NSURL URLWithString:string]);
+        string = userVisibleString([NSURL URLWithString:string]);
 
     // FIXME: WTF should offer a non-Mac-specific way to convert string to precomposed form so we can do it for all platforms.
     return [(NSString *)string precomposedStringWithCanonicalMapping];
@@ -279,7 +274,7 @@ void Editor::writeImageToPasteboard(Pasteboard& pasteboard, Element& imageElemen
     pasteboardImage.dataInWebArchiveFormat = imageInWebArchiveFormat(imageElement);
     pasteboardImage.url.url = url;
     pasteboardImage.url.title = title;
-    pasteboardImage.url.userVisibleForm = client()->userVisibleString(pasteboardImage.url.url);
+    pasteboardImage.url.userVisibleForm = userVisibleString(pasteboardImage.url.url);
     pasteboardImage.resourceData = cachedImage->resourceBuffer();
     pasteboardImage.resourceMIMEType = cachedImage->response().mimeType();
 
index d7acbf4..5c15dad 100644 (file)
@@ -45,6 +45,7 @@
 #import "RuntimeEnabledFeatures.h"
 #import "Settings.h"
 #import "Text.h"
+#import "WebCoreNSURLExtras.h"
 #import "markup.h"
 
 namespace WebCore {
@@ -70,7 +71,7 @@ bool WebContentReader::readFilenames(const Vector<String>& paths)
         }
 #else
         auto paragraph = createDefaultParagraphElement(document);
-        paragraph->appendChild(document.createTextNode(frame.editor().client()->userVisibleString([NSURL fileURLWithPath:text])));
+        paragraph->appendChild(document.createTextNode(userVisibleString([NSURL fileURLWithPath:text])));
         fragment->appendChild(paragraph);
 #endif
     }
index cd0321a..c22adf2 100644 (file)
@@ -217,7 +217,6 @@ private:
     bool performTwoStepDrop(DocumentFragment&, Range&, bool) final { return false; }
 
 #if PLATFORM(COCOA)
-    NSString *userVisibleString(NSURL *) final { return nullptr; }
     void setInsertionPasteboard(const String&) final { };
     NSURL *canonicalizeURL(NSURL *) final { return nullptr; }
     NSURL *canonicalizeURLString(NSString *) final { return nullptr; }
index e135ed6..675ce90 100644 (file)
@@ -142,7 +142,6 @@ public:
 #endif
 
 #if PLATFORM(COCOA)
-    virtual NSString *userVisibleString(NSURL *) = 0;
     virtual void setInsertionPasteboard(const String& pasteboardName) = 0;
     virtual NSURL *canonicalizeURL(NSURL *) = 0;
     virtual NSURL *canonicalizeURLString(NSString *) = 0;
index 1a5d360..1292e39 100644 (file)
 #include "Internals.h"
 
 #include "DOMURL.h"
-#include "Document.h"
-#include "Editor.h"
-#include "EditorClient.h"
-#include "Frame.h"
+#include "WebCoreNSURLExtras.h"
 #include <wtf/SoftLinking.h>
 
 #if PLATFORM(IOS)
@@ -42,7 +39,7 @@ namespace WebCore {
 
 String Internals::userVisibleString(const DOMURL& url)
 {
-    return contextDocument()->frame()->editor().client()->userVisibleString(url.href());
+    return WebCore::userVisibleString(url.href());
 }
 
 #if PLATFORM(COCOA)
index 4880e31..8f11781 100644 (file)
@@ -1,3 +1,18 @@
+2017-09-25  Sam Weinig  <sam@webkit.org>
+
+        Remove unnecessary userVisibleString EditorClient function
+        https://bugs.webkit.org/show_bug.cgi?id=177456
+
+        Reviewed by Dan Bernstein.
+
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+        * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
+        (WebKit::WebEditorClient::userVisibleString): Deleted.
+        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
+        (WebKit::WebEditorClient::userVisibleString): Deleted.
+
+            Remove userVisibleString client function.
+
 2017-09-25  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r222455.
index a607d8e..0a641b8 100644 (file)
@@ -96,7 +96,6 @@ private:
     void overflowScrollPositionChanged() final;
 
 #if PLATFORM(COCOA)
-    NSString *userVisibleString(NSURL *) final;
     void setInsertionPasteboard(const String& pasteboardName) final;
     NSURL *canonicalizeURL(NSURL *) final;
     NSURL *canonicalizeURLString(NSString *) final;
index 37c9f7f..df3658c 100644 (file)
@@ -48,12 +48,6 @@ void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
     notImplemented();
 }
 
-NSString *WebEditorClient::userVisibleString(NSURL *)
-{
-    notImplemented();
-    return nil;
-}
-
 NSURL *WebEditorClient::canonicalizeURL(NSURL *)
 {
     notImplemented();
index 3a3f01f..0d0a8b8 100644 (file)
@@ -57,11 +57,6 @@ void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
     if (event->handledByInputMethod())
         event->setDefaultHandled();
 }
-    
-NSString *WebEditorClient::userVisibleString(NSURL *url)
-{
-    return WebCore::userVisibleString(url);
-}
 
 NSURL *WebEditorClient::canonicalizeURL(NSURL *url)
 {
index b17aa49..9c00404 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-25  Sam Weinig  <sam@webkit.org>
+
+        Remove unnecessary userVisibleString EditorClient function
+        https://bugs.webkit.org/show_bug.cgi?id=177456
+
+        Reviewed by Dan Bernstein.
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::userVisibleString): Deleted.
+
+            Remove userVisibleString client function.
+
 2017-09-25  Alex Christensen  <achristensen@webkit.org>
 
         Separate form submission from PolicyChecker infrastructure
index 328394d..8cffd59 100644 (file)
@@ -79,7 +79,6 @@ private:
     void didWriteSelectionToPasteboard() final;
     void getClientPasteboardDataForRange(WebCore::Range*, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final;
 
-    NSString *userVisibleString(NSURL *) final;
     void setInsertionPasteboard(const String&) final;
     NSURL *canonicalizeURL(NSURL *) final;
     NSURL *canonicalizeURLString(NSString *) final;
index 343c2c7..d57c2f5 100644 (file)
@@ -418,11 +418,6 @@ void WebEditorClient::getClientPasteboardDataForRange(WebCore::Range*, Vector<St
     // Not implemented WebKit, only WebKit2.
 }
 
-NSString *WebEditorClient::userVisibleString(NSURL *URL)
-{
-    return [URL _web_userVisibleString];
-}
-
 NSURL *WebEditorClient::canonicalizeURL(NSURL *URL)
 {
     return [URL _webkit_canonicalize];