Title: [222062] trunk/Source/WebCore
Revision
222062
Author
[email protected]
Date
2017-09-14 16:43:55 -0700 (Thu, 14 Sep 2017)

Log Message

WebContentReader::readWebArchive doesn't need to handle image MIME type
https://bugs.webkit.org/show_bug.cgi?id=176884

Reviewed by Sam Weinig.

Remove the code to handle image MIME types in the web archive on macOS since we have a separate code path
to handle images in the pasteboard directly. As far as I can tell, this code is never used in practice.

This allows merging iOS and macOS code to read web archive from the pasteboard. Also merged member functions
for handling RTFD and RTF in iOS and macOS in WebContentReaderCocoa.mm.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* editing/WebContentReader.cpp: Added.
(WebCore::WebContentReader::addFragment): Moved from WebContentReaderIOS.mm and simplified since appendChild
knows how to add a DocumentFragment.
* editing/WebContentReader.h:
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::createFragmentAndAddResources):
(WebCore::WebContentReader::readWebArchive): Merged iOS / macOS code here.
(WebCore::WebContentReader::readRTFD): Ditto.
(WebCore::WebContentReader::readRTF): Ditto.
(WebCore::WebContentReader::readPlainText): Ditto.
* editing/ios/EditorIOS.mm:
(WebCore::Editor::pasteWithPasteboard):
* editing/ios/WebContentReaderIOS.mm:
(WebCore::WebContentReader::readImage):
(WebCore::WebContentReader::readURL):
(WebCore::WebContentReader::readWebArchive): Moved to WebContentReaderCocoa.mm.
(WebCore::WebContentReader::readRTFD): Ditto.
(WebCore::WebContentReader::readRTF): Ditto.
(WebCore::WebContentReader::readPlainText): Ditto.
* editing/mac/WebContentReaderMac.mm:
(WebCore::WebContentReader::readWebArchive): Ditto.
(WebCore::WebContentReader::readRTFD): Ditto.
(WebCore::WebContentReader::readRTF): Ditto.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (222061 => 222062)


--- trunk/Source/WebCore/CMakeLists.txt	2017-09-14 23:43:15 UTC (rev 222061)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-09-14 23:43:55 UTC (rev 222062)
@@ -1781,6 +1781,7 @@
     editing/VisiblePosition.cpp
     editing/VisibleSelection.cpp
     editing/VisibleUnits.cpp
+    editing/WebContentReader.cpp
     editing/WrapContentsInDummySpanCommand.cpp
     editing/markup.cpp
 

Modified: trunk/Source/WebCore/ChangeLog (222061 => 222062)


--- trunk/Source/WebCore/ChangeLog	2017-09-14 23:43:15 UTC (rev 222061)
+++ trunk/Source/WebCore/ChangeLog	2017-09-14 23:43:55 UTC (rev 222062)
@@ -1,3 +1,42 @@
+2017-09-14  Ryosuke Niwa  <[email protected]>
+
+        WebContentReader::readWebArchive doesn't need to handle image MIME type
+        https://bugs.webkit.org/show_bug.cgi?id=176884
+
+        Reviewed by Sam Weinig.
+
+        Remove the code to handle image MIME types in the web archive on macOS since we have a separate code path
+        to handle images in the pasteboard directly. As far as I can tell, this code is never used in practice.
+
+        This allows merging iOS and macOS code to read web archive from the pasteboard. Also merged member functions
+        for handling RTFD and RTF in iOS and macOS in WebContentReaderCocoa.mm.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * editing/WebContentReader.cpp: Added.
+        (WebCore::WebContentReader::addFragment): Moved from WebContentReaderIOS.mm and simplified since appendChild
+        knows how to add a DocumentFragment.
+        * editing/WebContentReader.h:
+        * editing/cocoa/WebContentReaderCocoa.mm:
+        (WebCore::createFragmentAndAddResources):
+        (WebCore::WebContentReader::readWebArchive): Merged iOS / macOS code here.
+        (WebCore::WebContentReader::readRTFD): Ditto.
+        (WebCore::WebContentReader::readRTF): Ditto.
+        (WebCore::WebContentReader::readPlainText): Ditto.
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::pasteWithPasteboard):
+        * editing/ios/WebContentReaderIOS.mm:
+        (WebCore::WebContentReader::readImage):
+        (WebCore::WebContentReader::readURL):
+        (WebCore::WebContentReader::readWebArchive): Moved to WebContentReaderCocoa.mm.
+        (WebCore::WebContentReader::readRTFD): Ditto.
+        (WebCore::WebContentReader::readRTF): Ditto.
+        (WebCore::WebContentReader::readPlainText): Ditto.
+        * editing/mac/WebContentReaderMac.mm:
+        (WebCore::WebContentReader::readWebArchive): Ditto.
+        (WebCore::WebContentReader::readRTFD): Ditto.
+        (WebCore::WebContentReader::readRTF): Ditto.
+
 2017-09-14  Devin Rousso  <[email protected]>
 
         Web Inspector: make recording swizzle async

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (222061 => 222062)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-09-14 23:43:15 UTC (rev 222061)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-09-14 23:43:55 UTC (rev 222062)
@@ -4328,6 +4328,7 @@
 		9B532EA41BA928570038A827 /* SlotAssignment.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B532EA21BA928570038A827 /* SlotAssignment.h */; };
 		9B55EEE91B3E8898005342BC /* EditorCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B55EEE81B3E8898005342BC /* EditorCocoa.mm */; };
 		9B56C9AA1C89329A00C456DF /* CustomElementReactionQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B56C9A91C89329A00C456DF /* CustomElementReactionQueue.cpp */; };
+		9B61164A1F6A593300E923B8 /* WebContentReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B6116491F6A593300E923B8 /* WebContentReader.cpp */; };
 		9B69D3B41B98FFE900E3512B /* HTMLSlotElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B69D3B21B98FFE900E3512B /* HTMLSlotElement.cpp */; };
 		9B69D3B51B98FFE900E3512B /* HTMLSlotElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B69D3B31B98FFE900E3512B /* HTMLSlotElement.h */; };
 		9B69D3B81B99100700E3512B /* JSHTMLSlotElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B69D3B61B99100700E3512B /* JSHTMLSlotElement.cpp */; };
@@ -12779,6 +12780,7 @@
 		9B55EEE81B3E8898005342BC /* EditorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditorCocoa.mm; sourceTree = "<group>"; };
 		9B56C9A81C89312800C456DF /* CustomElementReactionQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomElementReactionQueue.h; sourceTree = "<group>"; };
 		9B56C9A91C89329A00C456DF /* CustomElementReactionQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomElementReactionQueue.cpp; sourceTree = "<group>"; };
+		9B6116491F6A593300E923B8 /* WebContentReader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebContentReader.cpp; sourceTree = "<group>"; };
 		9B69D3B11B98FF0A00E3512B /* HTMLSlotElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLSlotElement.idl; sourceTree = "<group>"; };
 		9B69D3B21B98FFE900E3512B /* HTMLSlotElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLSlotElement.cpp; sourceTree = "<group>"; };
 		9B69D3B31B98FFE900E3512B /* HTMLSlotElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLSlotElement.h; sourceTree = "<group>"; };
@@ -20632,6 +20634,7 @@
 				A883DF260F3D045D00F19BF6 /* VisibleSelection.h */,
 				93309DCE099E64910056E581 /* VisibleUnits.cpp */,
 				93309DCF099E64910056E581 /* VisibleUnits.h */,
+				9B6116491F6A593300E923B8 /* WebContentReader.cpp */,
 				9BF433761F67619B00E1FD71 /* WebContentReader.h */,
 				93309DD4099E64910056E581 /* WrapContentsInDummySpanCommand.cpp */,
 				93309DD5099E64910056E581 /* WrapContentsInDummySpanCommand.h */,
@@ -34473,6 +34476,7 @@
 				CDA29A311CBF74DA00901CCF /* WebAVPlayerController.mm in Sources */,
 				1F36EA9D1E21BA1700621E25 /* WebBackgroundTaskController.mm in Sources */,
 				A56C5B9A189F34570082D13C /* WebConsoleAgent.cpp in Sources */,
+				9B61164A1F6A593300E923B8 /* WebContentReader.cpp in Sources */,
 				9B9299B21F6796A4006723C2 /* WebContentReaderCocoa.mm in Sources */,
 				9B0811241F67CDC00074BDE2 /* WebContentReaderIOS.mm in Sources */,
 				9B9299AE1F67865B006723C2 /* WebContentReaderMac.mm in Sources */,

Copied: trunk/Source/WebCore/editing/WebContentReader.cpp (from rev 222061, trunk/Source/WebCore/editing/WebContentReader.h) (0 => 222062)


--- trunk/Source/WebCore/editing/WebContentReader.cpp	                        (rev 0)
+++ trunk/Source/WebCore/editing/WebContentReader.cpp	2017-09-14 23:43:55 UTC (rev 222062)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebContentReader.h"
+
+#include "DocumentFragment.h"
+
+namespace WebCore {
+
+void WebContentReader::addFragment(Ref<DocumentFragment>&& newFragment)
+{
+    if (!fragment)
+        fragment = WTFMove(newFragment);
+    else
+        fragment->appendChild(newFragment.get());
+}
+
+}
+

Modified: trunk/Source/WebCore/editing/WebContentReader.h (222061 => 222062)


--- trunk/Source/WebCore/editing/WebContentReader.h	2017-09-14 23:43:15 UTC (rev 222061)
+++ trunk/Source/WebCore/editing/WebContentReader.h	2017-09-14 23:43:55 UTC (rev 222062)
@@ -50,12 +50,10 @@
     {
     }
 
-#if PLATFORM(IOS)
-    void addFragment(RefPtr<DocumentFragment>&&);
-#endif
+    void addFragment(Ref<DocumentFragment>&&);
 
 private:
-#if !(PLATFORM(GTK) || PLATFORM(WIN))
+#if PLATFORM(COCOA)
     bool readWebArchive(SharedBuffer*) override;
     bool readFilenames(const Vector<String>&) override;
     bool readHTML(const String&) override;
@@ -67,7 +65,7 @@
     bool readPlainText(const String&) override;
 };
 
-#if PLATFORM(COCOA)
+#if PLATFORM(COCOA) && defined(__OBJC__)
 struct FragmentAndResources {
     RefPtr<DocumentFragment> fragment;
     Vector<Ref<ArchiveResource>> resources;
@@ -75,5 +73,5 @@
 
 RefPtr<DocumentFragment> createFragmentAndAddResources(Frame&, NSAttributedString*);
 #endif
-    
+
 }

Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (222061 => 222062)


--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm	2017-09-14 23:43:15 UTC (rev 222061)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm	2017-09-14 23:43:55 UTC (rev 222062)
@@ -33,8 +33,14 @@
 #include "DocumentLoader.h"
 #include "Frame.h"
 #include "FrameLoader.h"
+#include "FrameLoaderClient.h"
 #include "HTMLImageElement.h"
+#include "LegacyWebArchive.h"
 #include "Page.h"
+#include "Settings.h"
+#include "WebNSAttributedStringExtras.h"
+#include "markup.h"
+#include <pal/spi/cocoa/NSAttributedStringSPI.h>
 #include <wtf/SoftLinking.h>
 
 #if PLATFORM(IOS)
@@ -63,33 +69,101 @@
 {
     if (!frame.page() || !frame.document())
         return nullptr;
-    
+
     auto& document = *frame.document();
     if (!document.isHTMLDocument() || !string)
         return nullptr;
-    
+
     bool wasDeferringCallbacks = frame.page()->defersLoading();
     if (!wasDeferringCallbacks)
         frame.page()->setDefersLoading(true);
-    
+
     auto& cachedResourceLoader = document.cachedResourceLoader();
     bool wasImagesEnabled = cachedResourceLoader.imagesEnabled();
     if (wasImagesEnabled)
         cachedResourceLoader.setImagesEnabled(false);
-    
+
     auto fragmentAndResources = createFragment(frame, string);
-    
     if (auto* loader = frame.loader().documentLoader()) {
         for (auto& resource : fragmentAndResources.resources)
             loader->addArchiveResource(WTFMove(resource));
     }
-    
+
     if (wasImagesEnabled)
         cachedResourceLoader.setImagesEnabled(true);
     if (!wasDeferringCallbacks)
         frame.page()->setDefersLoading(false);
-    
+
     return WTFMove(fragmentAndResources.fragment);
 }
 
+bool WebContentReader::readWebArchive(SharedBuffer* buffer)
+{
+    if (frame.settings().preferMIMETypeForImages())
+        return false;
+
+    if (!frame.document())
+        return false;
+
+    if (!buffer)
+        return false;
+
+    auto archive = LegacyWebArchive::create(URL(), *buffer);
+    if (!archive)
+        return false;
+
+    RefPtr<ArchiveResource> mainResource = archive->mainResource();
+    if (!mainResource)
+        return false;
+
+    auto type = mainResource->mimeType();
+    if (!frame.loader().client().canShowMIMETypeAsHTML(type))
+        return false;
+
+    // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
+    if (DocumentLoader* loader = frame.loader().documentLoader())
+        loader->addAllArchiveResources(*archive);
+
+    auto markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size());
+    addFragment(createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent));
+    return true;
 }
+
+bool WebContentReader::readRTFD(SharedBuffer& buffer)
+{
+    if (frame.settings().preferMIMETypeForImages())
+        return false;
+
+    auto fragment = createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get());
+    if (!fragment)
+        return false;
+    addFragment(fragment.releaseNonNull());
+
+    return true;
+}
+
+bool WebContentReader::readRTF(SharedBuffer& buffer)
+{
+    if (frame.settings().preferMIMETypeForImages())
+        return false;
+
+    auto fragment = createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get());
+    if (!fragment)
+        return false;
+    addFragment(fragment.releaseNonNull());
+
+    return true;
+}
+
+bool WebContentReader::readPlainText(const String& text)
+{
+    if (!allowPlainText)
+        return false;
+
+    addFragment(createFragmentFromText(context, [text precomposedStringWithCanonicalMapping]));
+
+    madeFragmentFromPlainText = true;
+    return true;
+}
+
+}

Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (222061 => 222062)


--- trunk/Source/WebCore/editing/ios/EditorIOS.mm	2017-09-14 23:43:15 UTC (rev 222061)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm	2017-09-14 23:43:55 UTC (rev 222062)
@@ -233,8 +233,7 @@
         RefPtr<DocumentFragment> fragment = client()->documentFragmentFromDelegate(i);
         if (!fragment)
             continue;
-
-        reader.addFragment(WTFMove(fragment));
+        reader.addFragment(fragment.releaseNonNull());
     }
 
     RefPtr<DocumentFragment> fragment = reader.fragment;

Modified: trunk/Source/WebCore/editing/ios/WebContentReaderIOS.mm (222061 => 222062)


--- trunk/Source/WebCore/editing/ios/WebContentReaderIOS.mm	2017-09-14 23:43:15 UTC (rev 222061)
+++ trunk/Source/WebCore/editing/ios/WebContentReaderIOS.mm	2017-09-14 23:43:55 UTC (rev 222062)
@@ -42,59 +42,12 @@
 #import "MIMETypeRegistry.h"
 #import "Text.h"
 #import "UTIUtilities.h"
-#import "WebNSAttributedStringExtras.h"
 #import "markup.h"
 #import <MobileCoreServices/MobileCoreServices.h>
-#import <pal/spi/cocoa/NSAttributedStringSPI.h>
 #import <wtf/unicode/CharacterNames.h>
 
 namespace WebCore {
 
-void WebContentReader::addFragment(RefPtr<DocumentFragment>&& newFragment)
-{
-    if (!newFragment)
-        return;
-
-    if (!fragment) {
-        fragment = WTFMove(newFragment);
-        return;
-    }
-
-    while (auto* firstChild = newFragment->firstChild()) {
-        if (fragment->appendChild(*firstChild).hasException())
-            break;
-    }
-}
-
-bool WebContentReader::readWebArchive(SharedBuffer* buffer)
-{
-    if (!frame.document())
-        return false;
-
-    if (!buffer)
-        return false;
-
-    auto archive = LegacyWebArchive::create(URL(), *buffer);
-    if (!archive)
-        return false;
-
-    auto* mainResource = archive->mainResource();
-    if (!mainResource)
-        return false;
-
-    auto& type = mainResource->mimeType();
-    if (!frame.loader().client().canShowMIMETypeAsHTML(type))
-        return false;
-
-    // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
-    if (auto* loader = frame.loader().documentLoader())
-        loader->addAllArchiveResources(*archive);
-
-    auto markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size());
-    addFragment(createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent));
-    return true;
-}
-
 bool WebContentReader::readFilenames(const Vector<String>&)
 {
     return false;
@@ -109,18 +62,6 @@
     return true;
 }
 
-bool WebContentReader::readRTFD(SharedBuffer& buffer)
-{
-    addFragment(createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get()));
-    return fragment;
-}
-
-bool WebContentReader::readRTF(SharedBuffer& buffer)
-{
-    addFragment(createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get()));
-    return fragment;
-}
-
 bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type)
 {
     RetainPtr<CFStringRef> stringType = type.createCFString();
@@ -131,8 +72,11 @@
     // FIXME: Use a blob URL instead.
     auto archive = ArchiveResource::create(WTFMove(buffer), URL::fakeURLWithRelativePart(relativeURLPart), mimeType, emptyString(), emptyString());
     ASSERT(archive);
-    addFragment(createFragmentForImageResourceAndAddResource(frame, *archive));
-    return fragment;
+    auto fragment = createFragmentForImageResourceAndAddResource(frame, *archive);
+    if (!fragment)
+        return false;
+    addFragment(fragment.releaseNonNull());
+    return true;
 }
 
 bool WebContentReader::readURL(const URL& url, const String& title)
@@ -163,17 +107,4 @@
     return true;
 }
 
-bool WebContentReader::readPlainText(const String& text)
-{
-    if (!allowPlainText)
-        return false;
-
-    addFragment(createFragmentFromText(context, [text precomposedStringWithCanonicalMapping]));
-    if (!fragment)
-        return false;
-
-    madeFragmentFromPlainText = true;
-    return true;
 }
-
-}

Modified: trunk/Source/WebCore/editing/mac/WebContentReaderMac.mm (222061 => 222062)


--- trunk/Source/WebCore/editing/mac/WebContentReaderMac.mm	2017-09-14 23:43:15 UTC (rev 222061)
+++ trunk/Source/WebCore/editing/mac/WebContentReaderMac.mm	2017-09-14 23:43:55 UTC (rev 222062)
@@ -43,50 +43,10 @@
 #import "RuntimeEnabledFeatures.h"
 #import "Settings.h"
 #import "Text.h"
-#import "WebNSAttributedStringExtras.h"
 #import "markup.h"
 
 namespace WebCore {
 
-bool WebContentReader::readWebArchive(SharedBuffer* buffer)
-{
-    if (frame.settings().preferMIMETypeForImages())
-        return false;
-
-    if (!frame.document())
-        return false;
-
-    if (!buffer)
-        return false;
-
-    auto archive = LegacyWebArchive::create(URL(), *buffer);
-    if (!archive)
-        return false;
-
-    RefPtr<ArchiveResource> mainResource = archive->mainResource();
-    if (!mainResource)
-        return false;
-
-    const String& type = mainResource->mimeType();
-
-    if (frame.loader().client().canShowMIMETypeAsHTML(type)) {
-        // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
-        if (DocumentLoader* loader = frame.loader().documentLoader())
-            loader->addAllArchiveResources(*archive);
-
-        String markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size());
-        fragment = createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent);
-        return true;
-    }
-
-    if (MIMETypeRegistry::isSupportedImageMIMEType(type)) {
-        fragment = createFragmentForImageResourceAndAddResource(frame, mainResource.releaseNonNull());
-        return true;
-    }
-
-    return false;
-}
-
 bool WebContentReader::readFilenames(const Vector<String>& paths)
 {
     if (paths.isEmpty())
@@ -140,24 +100,6 @@
     return fragment;
 }
 
-bool WebContentReader::readRTFD(SharedBuffer& buffer)
-{
-    if (frame.settings().preferMIMETypeForImages())
-        return false;
-
-    fragment = createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get());
-    return fragment;
-}
-
-bool WebContentReader::readRTF(SharedBuffer& buffer)
-{
-    if (frame.settings().preferMIMETypeForImages())
-        return false;
-
-    fragment = createFragmentAndAddResources(frame, adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get());
-    return fragment;
-}
-
 bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type)
 {
     ASSERT(type.contains('/'));
@@ -189,17 +131,4 @@
     return true;
 }
 
-bool WebContentReader::readPlainText(const String& text)
-{
-    if (!allowPlainText)
-        return false;
-
-    fragment = createFragmentFromText(context, [text precomposedStringWithCanonicalMapping]);
-    if (!fragment)
-        return false;
-
-    madeFragmentFromPlainText = true;
-    return true;
 }
-    
-}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to