Title: [203482] trunk/Source/WebCore
Revision
203482
Author
rn...@webkit.org
Date
2016-07-20 17:23:19 -0700 (Wed, 20 Jul 2016)

Log Message

iOS: Cannot paste images in RTF content
https://bugs.webkit.org/show_bug.cgi?id=159964
<rdar://problem/27442806>

Reviewed by Enrica Casucci.

The bug was caused by setDefersLoading(true) not deferring image loading for the parsed fragment.
Worked around this bug by disabling image loading while parsing the document fragment.

* editing/ios/EditorIOS.mm:
(WebCore::Editor::createFragmentAndAddResources):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (203481 => 203482)


--- trunk/Source/WebCore/ChangeLog	2016-07-21 00:15:58 UTC (rev 203481)
+++ trunk/Source/WebCore/ChangeLog	2016-07-21 00:23:19 UTC (rev 203482)
@@ -1,3 +1,17 @@
+2016-07-19  Ryosuke Niwa  <rn...@webkit.org>
+
+        iOS: Cannot paste images in RTF content
+        https://bugs.webkit.org/show_bug.cgi?id=159964
+        <rdar://problem/27442806>
+
+        Reviewed by Enrica Casucci.
+
+        The bug was caused by setDefersLoading(true) not deferring image loading for the parsed fragment.
+        Worked around this bug by disabling image loading while parsing the document fragment.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::createFragmentAndAddResources):
+
 2016-07-20  Brady Eidson  <beid...@apple.com>
 
         Address a small FIXME in IDB code.

Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (203481 => 203482)


--- trunk/Source/WebCore/editing/ios/EditorIOS.mm	2016-07-21 00:15:58 UTC (rev 203481)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm	2016-07-21 00:23:19 UTC (rev 203482)
@@ -26,9 +26,10 @@
 #include "config.h"
 #include "Editor.h"
 
-#include "CachedImage.h"
 #include "CSSComputedStyleDeclaration.h"
 #include "CSSPrimitiveValueMappings.h"
+#include "CachedImage.h"
+#include "CachedResourceLoader.h"
 #include "DOMRangeInternal.h"
 #include "DataTransfer.h"
 #include "DocumentFragment.h"
@@ -549,10 +550,11 @@
 
 RefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedString *string)
 {
-    if (!m_frame.page() || !m_frame.document() || !m_frame.document()->isHTMLDocument())
+    if (!m_frame.page() || !m_frame.document())
         return nullptr;
 
-    if (!string)
+    auto& document = *m_frame.document();
+    if (!document.isHTMLDocument() || !string)
         return nullptr;
 
     bool wasDeferringCallbacks = m_frame.page()->defersLoading();
@@ -559,6 +561,11 @@
     if (!wasDeferringCallbacks)
         m_frame.page()->setDefersLoading(true);
 
+    auto& cachedResourceLoader = document.cachedResourceLoader();
+    bool wasImagesEnabled = cachedResourceLoader.imagesEnabled();
+    if (wasImagesEnabled)
+        cachedResourceLoader.setImagesEnabled(false);
+
     Vector<RefPtr<ArchiveResource>> resources;
     RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources);
 
@@ -569,6 +576,8 @@
         }
     }
 
+    if (wasImagesEnabled)
+        cachedResourceLoader.setImagesEnabled(true);
     if (!wasDeferringCallbacks)
         m_frame.page()->setDefersLoading(false);
     

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (203481 => 203482)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2016-07-21 00:15:58 UTC (rev 203481)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2016-07-21 00:23:19 UTC (rev 203482)
@@ -103,6 +103,7 @@
     bool autoLoadImages() const { return m_autoLoadImages; }
     void setAutoLoadImages(bool);
 
+    bool imagesEnabled() const { return m_imagesEnabled; }
     void setImagesEnabled(bool);
 
     bool shouldDeferImageLoad(const URL&) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to