WebContentReader::readHTML should be shared between macOS and iOS
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Oct 2017 07:04:07 +0000 (07:04 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Oct 2017 07:04:07 +0000 (07:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178044

Reviewed by Wenson Hsieh.

Merged the implementations for WebContentReader::readHTML between macOS and iOS.

* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::WebContentReader::readHTML):
* editing/ios/WebContentReaderIOS.mm:
(WebCore::WebContentReader::readHTML): Deleted.
* editing/mac/WebContentReaderMac.mm:
(WebCore::WebContentReader::readHTML): Deleted.

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

Source/WebCore/ChangeLog
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
Source/WebCore/editing/ios/WebContentReaderIOS.mm
Source/WebCore/editing/mac/WebContentReaderMac.mm

index d539886..3765cc1 100644 (file)
@@ -1,3 +1,19 @@
+2017-10-07  Ryosuke Niwa  <rniwa@webkit.org>
+
+        WebContentReader::readHTML should be shared between macOS and iOS
+        https://bugs.webkit.org/show_bug.cgi?id=178044
+
+        Reviewed by Wenson Hsieh.
+
+        Merged the implementations for WebContentReader::readHTML between macOS and iOS.
+
+        * editing/cocoa/WebContentReaderCocoa.mm:
+        (WebCore::WebContentReader::readHTML):
+        * editing/ios/WebContentReaderIOS.mm:
+        (WebCore::WebContentReader::readHTML): Deleted.
+        * editing/mac/WebContentReaderMac.mm:
+        (WebCore::WebContentReader::readHTML): Deleted.
+
 2017-10-06  Zalan Bujtas  <zalan@apple.com>
 
         RenderTable should not hold a collection of raw pointers to RenderTableCaption
index e73220c..5e191fa 100644 (file)
@@ -211,6 +211,32 @@ bool WebContentReader::readWebArchive(SharedBuffer* buffer)
     return true;
 }
 
+bool WebContentReader::readHTML(const String& string)
+{
+    String stringOmittingMicrosoftPrefix = string;
+    
+#if PLATFORM(MAC)
+    // This code was added to make HTML paste from Microsoft Word on Mac work, back in 2004.
+    // It's a simple-minded way to ignore the CF_HTML clipboard format, just skipping over the
+    // description part and parsing the entire context plus fragment.
+    if (string.startsWith("Version:")) {
+        size_t location = string.findIgnoringCase("<html");
+        if (location != notFound)
+            stringOmittingMicrosoftPrefix = string.substring(location);
+    }
+#endif
+
+    if (stringOmittingMicrosoftPrefix.isEmpty())
+        return false;
+
+    if (!frame.document())
+        return false;
+    Document& document = *frame.document();
+
+    addFragment(createFragmentFromMarkup(document, stringOmittingMicrosoftPrefix, emptyString(), DisallowScriptingAndPluginContent));
+    return true;
+}
+
 bool WebContentReader::readRTFD(SharedBuffer& buffer)
 {
     if (frame.settings().preferMIMETypeForImages())
index 796e6e8..034ba9a 100644 (file)
@@ -52,15 +52,6 @@ bool WebContentReader::readFilenames(const Vector<String>&)
     return false;
 }
 
-bool WebContentReader::readHTML(const String& string)
-{
-    if (!frame.document())
-        return false;
-
-    addFragment(createFragmentFromMarkup(*frame.document(), string, emptyString(), DisallowScriptingAndPluginContent));
-    return true;
-}
-
 bool WebContentReader::readURL(const URL& url, const String& title)
 {
     if (url.isEmpty())
index 5c15dad..d3d7b7d 100644 (file)
@@ -79,30 +79,6 @@ bool WebContentReader::readFilenames(const Vector<String>& paths)
     return true;
 }
 
-bool WebContentReader::readHTML(const String& string)
-{
-    String stringOmittingMicrosoftPrefix = string;
-
-    // This code was added to make HTML paste from Microsoft Word on Mac work, back in 2004.
-    // It's a simple-minded way to ignore the CF_HTML clipboard format, just skipping over the
-    // description part and parsing the entire context plus fragment.
-    if (string.startsWith("Version:")) {
-        size_t location = string.findIgnoringCase("<html");
-        if (location != notFound)
-            stringOmittingMicrosoftPrefix = string.substring(location);
-    }
-
-    if (stringOmittingMicrosoftPrefix.isEmpty())
-        return false;
-
-    if (!frame.document())
-        return false;
-    Document& document = *frame.document();
-
-    fragment = createFragmentFromMarkup(document, stringOmittingMicrosoftPrefix, emptyString(), DisallowScriptingAndPluginContent);
-    return fragment;
-}
-
 bool WebContentReader::readURL(const URL& url, const String& title)
 {
     if (url.string().isEmpty())