Pasting multiple photos on iOS only pastes one photo
authorjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jun 2014 20:46:39 +0000 (20:46 +0000)
committerjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jun 2014 20:46:39 +0000 (20:46 +0000)
<https://bugs.webkit.org/show_bug.cgi?id=133495>
<rdar://problem/16138616>

Reviewed by Alexey Proskuryakov.

* editing/ios/EditorIOS.mm:
(WebCore::Editor::pasteWithPasteboard):
Create a WebContentReader. For each pasteboard item, get the document
fragment for that item, and add it to the reader. If we fail to get
the fragment from the delegate, fall back to using
webContentFromPasteboard() as before.

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

Source/WebCore/ChangeLog
Source/WebCore/editing/ios/EditorIOS.mm

index 84ebdc1..3e6a8d2 100644 (file)
@@ -1,3 +1,19 @@
+2014-06-03  Jon Honeycutt  <jhoneycutt@apple.com>
+
+        Pasting multiple photos on iOS only pastes one photo
+
+        <https://bugs.webkit.org/show_bug.cgi?id=133495>
+        <rdar://problem/16138616>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::pasteWithPasteboard):
+        Create a WebContentReader. For each pasteboard item, get the document
+        fragment for that item, and add it to the reader. If we fail to get
+        the fragment from the delegate, fall back to using
+        webContentFromPasteboard() as before.
+
 2014-06-04  Myles C. Maxfield  <litherum@gmail.com>
 
         Use references instead of pointers for non-optional arguments during text layout
index d9c70fc..35270c0 100644 (file)
@@ -399,6 +399,8 @@ public:
     {
     }
 
+    void addFragment(PassRefPtr<DocumentFragment>);
+
     Frame& frame;
     Range& context;
     const bool allowPlainText;
@@ -415,7 +417,6 @@ private:
     virtual bool readImage(PassRefPtr<SharedBuffer>, const String& type) override;
     virtual bool readURL(const URL&, const String& title) override;
     virtual bool readPlainText(const String&) override;
-    void addFragment(PassRefPtr<DocumentFragment>);
 };
 
 void Editor::WebContentReader::addFragment(PassRefPtr<DocumentFragment> newFragment)
@@ -554,11 +555,21 @@ PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteb
 void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
 {
     RefPtr<Range> range = selectedRange();
+    WebContentReader reader(m_frame, *range, allowPlainText);
+    int numberOfPasteboardItems = client()->getPasteboardItemsCount();
+    for (int i = 0; i < numberOfPasteboardItems; ++i) {
+        RefPtr<DocumentFragment> fragment = client()->documentFragmentFromDelegate(i);
+        if (!fragment)
+            continue;
+
+        reader.addFragment(fragment);
+    }
 
-    bool chosePlainText;
-    RefPtr<DocumentFragment> fragment = client()->documentFragmentFromDelegate(0);
-    if (!fragment)
-        fragment = webContentFromPasteboard(*pasteboard, *range, allowPlainText, chosePlainText);
+    RefPtr<DocumentFragment> fragment = reader.fragment;
+    if (!fragment) {
+        bool chosePlainTextIgnored;
+        fragment = webContentFromPasteboard(*pasteboard, *range, allowPlainText, chosePlainTextIgnored);
+    }
 
     if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
         pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);