Diff
Modified: trunk/Source/WebCore/ChangeLog (174313 => 174314)
--- trunk/Source/WebCore/ChangeLog 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/ChangeLog 2014-10-04 08:37:57 UTC (rev 174314)
@@ -1,3 +1,39 @@
+2014-10-04 Carlos Garcia Campos <cgar...@igalia.com>
+
+ Move DragController::createFragmentFromDragData implementation to the editor
+ https://bugs.webkit.org/show_bug.cgi?id=136819
+
+ Reviewed by Darin Adler.
+
+ Make Editor::webContentFromPasteboard() common to all ports and
+ add a implementation for every port.
+
+ * PlatformWin.cmake: Add new files to compilation.
+ * WebCore.vcxproj/WebCore.vcxproj: Ditto.
+ * editing/Editor.cpp:
+ (WebCore::Editor::pasteWithPasteboard): Move to EditorWin.cpp
+ since this is only used by windows port.
+ * editing/Editor.h:
+ * editing/efl/EditorEfl.cpp:
+ (WebCore::Editor::webContentFromPasteboard):
+ * editing/gtk/EditorGtk.cpp:
+ (WebCore::Editor::webContentFromPasteboard):
+ * editing/win/EditorWin.cpp: Added.
+ (WebCore::Editor::pasteWithPasteboard):
+ (WebCore::Editor::webContentFromPasteboard):
+ * page/DragController.cpp:
+ (WebCore::documentFragmentFromDragData): Use the editor instead of
+ createFragmentFromDragData() that has been removed. Also made this
+ method a static funtion again.
+ * page/DragController.h:
+ * page/efl/DragControllerEfl.cpp: Remove createFragmentFromDragData().
+ * page/gtk/DragControllerGtk.cpp: Ditto.
+ * page/mac/DragControllerMac.mm: Ditto.
+ * page/win/DragControllerWin.cpp: Ditto.
+ * platform/Pasteboard.h:
+ (WebCore::Pasteboard::dragDataMap): Add a getter for m_dragDataMap
+ as required by Editor::webContentFromPasteboard for windows.
+
2014-10-04 Christophe Dumez <cdu...@apple.com>
Use is<>() / downcast<>() for CSS StyleProperties
Modified: trunk/Source/WebCore/PlatformWin.cmake (174313 => 174314)
--- trunk/Source/WebCore/PlatformWin.cmake 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/PlatformWin.cmake 2014-10-04 08:37:57 UTC (rev 174314)
@@ -10,6 +10,8 @@
list(APPEND WebCore_SOURCES
accessibility/win/AccessibilityObjectWin.cpp
+ editing/win/EditorWin.cpp
+
html/HTMLSelectElementWin.cpp
page/win/DragControllerWin.cpp
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (174313 => 174314)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2014-10-04 08:37:57 UTC (rev 174314)
@@ -14928,6 +14928,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="..\editing\win\EditorWin.cpp"/>
<ClCompile Include="..\fileapi\AsyncFileStream.cpp" />
<ClCompile Include="..\html\BaseButtonInputType.cpp" />
<ClCompile Include="..\html\BaseCheckableInputType.cpp" />
Modified: trunk/Source/WebCore/editing/Editor.cpp (174313 => 174314)
--- trunk/Source/WebCore/editing/Editor.cpp 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/editing/Editor.cpp 2014-10-04 08:37:57 UTC (rev 174314)
@@ -560,20 +560,6 @@
#endif
-#if !PLATFORM(COCOA) && !PLATFORM(EFL) && !PLATFORM(GTK)
-void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
-{
- RefPtr<Range> range = selectedRange();
- if (!range)
- return;
-
- bool chosePlainText;
- RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, *range, allowPlainText, chosePlainText);
- if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
- pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
-}
-#endif
-
bool Editor::canSmartReplaceWithPasteboard(Pasteboard& pasteboard)
{
return client() && client()->smartInsertDeleteEnabled() && pasteboard.canSmartReplace();
Modified: trunk/Source/WebCore/editing/Editor.h (174313 => 174314)
--- trunk/Source/WebCore/editing/Editor.h 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/editing/Editor.h 2014-10-04 08:37:57 UTC (rev 174314)
@@ -426,6 +426,8 @@
DeleteButtonController& deleteButtonController() const { return *m_deleteButtonController; }
#endif
+ PassRefPtr<DocumentFragment> webContentFromPasteboard(Pasteboard&, Range& context, bool allowPlainText, bool& chosePlainText);
+
#if PLATFORM(COCOA)
WEBCORE_EXPORT static RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove);
WEBCORE_EXPORT bool insertParagraphSeparatorInQuotedContent();
@@ -433,7 +435,6 @@
WEBCORE_EXPORT NSDictionary* fontAttributesForSelectionStart() const;
WEBCORE_EXPORT String stringSelectionForPasteboard();
String stringSelectionForPasteboardWithImageAltText();
- PassRefPtr<DocumentFragment> webContentFromPasteboard(Pasteboard&, Range& context, bool allowPlainText, bool& chosePlainText);
#if !PLATFORM(IOS)
bool canCopyExcludingStandaloneImages();
void takeFindStringFromSelection();
Modified: trunk/Source/WebCore/editing/efl/EditorEfl.cpp (174313 => 174314)
--- trunk/Source/WebCore/editing/efl/EditorEfl.cpp 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/editing/efl/EditorEfl.cpp 2014-10-04 08:37:57 UTC (rev 174314)
@@ -27,8 +27,10 @@
#include "config.h"
#include "Editor.h"
+#include "DocumentFragment.h"
#include "NotImplemented.h"
#include "Pasteboard.h"
+#include <wtf/PassRefPtr.h>
namespace WebCore {
@@ -47,4 +49,9 @@
notImplemented();
}
+PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard&, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
+{
+ return nullptr;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/gtk/EditorGtk.cpp (174313 => 174314)
--- trunk/Source/WebCore/editing/gtk/EditorGtk.cpp 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/editing/gtk/EditorGtk.cpp 2014-10-04 08:37:57 UTC (rev 174314)
@@ -129,4 +129,9 @@
pasteboard.write(pasteboardContent);
}
+PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
+{
+ return createFragmentFromPasteboardData(pasteboard, m_frame, context, allowPlainText, chosePlainText);
+}
+
} // namespace WebCore
Added: trunk/Source/WebCore/editing/win/EditorWin.cpp (0 => 174314)
--- trunk/Source/WebCore/editing/win/EditorWin.cpp (rev 0)
+++ trunk/Source/WebCore/editing/win/EditorWin.cpp 2014-10-04 08:37:57 UTC (rev 174314)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 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. ``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
+ * 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 "Editor.h"
+
+#include "ClipboardUtilitiesWin.h"
+#include "DocumentFragment.h"
+#include "Frame.h"
+#include "FrameSelection.h"
+#include "Pasteboard.h"
+#include "windows.h"
+
+namespace WebCore {
+
+void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
+{
+ RefPtr<Range> range = selectedRange();
+ if (!range)
+ return;
+
+ bool chosePlainText;
+ RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, *range, allowPlainText, chosePlainText);
+ if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
+}
+
+template <typename PlatformDragData>
+static PassRefPtr<DocumentFragment> createFragmentFromPlatformData(PlatformDragData& platformDragData, Frame& frame)
+{
+ if (containsFilenames(&platformDragData)) {
+ if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame.document(), &platformDragData))
+ return fragment;
+ }
+
+ if (containsHTML(&platformDragData)) {
+ if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame.document(), &platformDragData))
+ return fragment;
+ }
+ return nullptr;
+}
+
+PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
+{
+ if (COMPtr<IDataObject> platformDragData = pasteboard.dataObject())
+ return createFragmentFromPlatformData(*platformDragData, m_frame);
+
+ return createFragmentFromPlatformData(pasteboard.dragDataMap(), m_frame);
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/page/DragController.cpp (174313 => 174314)
--- trunk/Source/WebCore/page/DragController.cpp 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/page/DragController.cpp 2014-10-04 08:37:57 UTC (rev 174314)
@@ -114,13 +114,13 @@
m_client.dragControllerDestroyed();
}
-PassRefPtr<DocumentFragment> DragController::documentFragmentFromDragData(DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
+static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
{
chosePlainText = false;
Document& document = context.ownerDocument();
if (dragData.containsCompatibleContent()) {
- if (PassRefPtr<DocumentFragment> fragment = createFragmentFromDragData(dragData, frame, context, allowPlainText, chosePlainText))
+ if (PassRefPtr<DocumentFragment> fragment = frame.editor().webContentFromPasteboard(*Pasteboard::createForDragAndDrop(dragData), context, allowPlainText, chosePlainText))
return fragment;
if (dragData.containsURL(DragData::DoNotConvertFilenames)) {
Modified: trunk/Source/WebCore/page/DragController.h (174313 => 174314)
--- trunk/Source/WebCore/page/DragController.h 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/page/DragController.h 2014-10-04 08:37:57 UTC (rev 174314)
@@ -115,10 +115,6 @@
void cleanupAfterSystemDrag();
void declareAndWriteDragImage(DataTransfer&, Element&, const URL&, const String& label);
- // FIXME: Move createFragmentFromDragData implementation to the Editor and make documentFragmentFromDragData a static function again.
- static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData&, Frame&, Range&, bool allowPlainText, bool& chosePlainText);
- static PassRefPtr<DocumentFragment> createFragmentFromDragData(DragData&, Frame&, Range&, bool allowPlainText, bool& chosePlainText);
-
Page& m_page;
DragClient& m_client;
Modified: trunk/Source/WebCore/page/efl/DragControllerEfl.cpp (174313 => 174314)
--- trunk/Source/WebCore/page/efl/DragControllerEfl.cpp 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/page/efl/DragControllerEfl.cpp 2014-10-04 08:37:57 UTC (rev 174314)
@@ -73,9 +73,4 @@
{
}
-PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData&, Frame&, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
-{
- return nullptr;
}
-
-}
Modified: trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp (174313 => 174314)
--- trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp 2014-10-04 08:37:57 UTC (rev 174314)
@@ -81,12 +81,4 @@
frame->editor().writeImageToPasteboard(dataTransfer.pasteboard(), element, url, label);
}
-PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData& dragData, Frame& frame, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
-{
- if (!dragData.platformData()->hasMarkup() || !frame.document())
- return nullptr;
-
- return createFragmentFromMarkup(*frame.document(), dragData.platformData()->markup(), "");
}
-
-}
Modified: trunk/Source/WebCore/page/mac/DragControllerMac.mm (174313 => 174314)
--- trunk/Source/WebCore/page/mac/DragControllerMac.mm 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/page/mac/DragControllerMac.mm 2014-10-04 08:37:57 UTC (rev 174314)
@@ -92,12 +92,6 @@
m_client.declareAndWriteDragImage(dataTransfer.pasteboard().name(), element, url, label, element.document().frame());
}
-PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
-{
- Pasteboard pasteboard(dragData.pasteboardName());
- return frame.editor().webContentFromPasteboard(pasteboard, context, allowPlainText, chosePlainText);
-}
-
} // namespace WebCore
#endif // ENABLE(DRAG_SUPPORT)
Modified: trunk/Source/WebCore/page/win/DragControllerWin.cpp (174313 => 174314)
--- trunk/Source/WebCore/page/win/DragControllerWin.cpp 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/page/win/DragControllerWin.cpp 2014-10-04 08:37:57 UTC (rev 174314)
@@ -26,14 +26,10 @@
#include "config.h"
#include "DragController.h"
-#include "ClipboardUtilitiesWin.h"
#include "DataTransfer.h"
#include "Document.h"
-#include "DocumentFragment.h"
#include "DragData.h"
#include "Element.h"
-#include "Frame.h"
-#include "FrameSelection.h"
#include "Pasteboard.h"
#include "markup.h"
#include "windows.h"
@@ -87,27 +83,4 @@
pasteboard.writeMarkup(createMarkup(element, IncludeNode, 0, ResolveAllURLs));
}
-template <typename PlatformDragData>
-static PassRefPtr<DocumentFragment> createFragmentFromPlatformData(PlatformDragData* platformDragData, Frame& frame)
-{
- if (containsFilenames(platformDragData)) {
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame.document(), platformDragData))
- return fragment;
- }
-
- if (containsHTML(platformDragData)) {
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame.document(), platformDragData))
- return fragment;
- }
- return nullptr;
}
-
-PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData& dragData, Frame& frame, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
-{
- if (DragDataRef platformDragData = dragData.platformData())
- return createFragmentFromPlatformData(platformDragData, frame);
-
- return createFragmentFromPlatformData(&dragData.dragDataMap(), frame);
-}
-
-}
Modified: trunk/Source/WebCore/platform/Pasteboard.h (174313 => 174314)
--- trunk/Source/WebCore/platform/Pasteboard.h 2014-10-04 08:30:15 UTC (rev 174313)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2014-10-04 08:37:57 UTC (rev 174314)
@@ -202,6 +202,7 @@
#if PLATFORM(WIN)
COMPtr<IDataObject> dataObject() const { return m_dataObject; }
void setExternalDataObject(IDataObject*);
+ const DragDataMap& dragDataMap() const { return m_dragDataMap; }
void writeURLToWritableDataObject(const URL&, const String&);
COMPtr<WCDataObject> writableDataObject() const { return m_writableDataObject; }
void writeImageToDataObject(Element&, const URL&); // FIXME: Layering violation.