Changeset 174314 in webkit


Ignore:
Timestamp:
Oct 4, 2014 1:37:57 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

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.

Location:
trunk/Source/WebCore
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r174313 r174314  
     12014-10-04  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Move DragController::createFragmentFromDragData implementation to the editor
     4        https://bugs.webkit.org/show_bug.cgi?id=136819
     5
     6        Reviewed by Darin Adler.
     7
     8        Make Editor::webContentFromPasteboard() common to all ports and
     9        add a implementation for every port.
     10
     11        * PlatformWin.cmake: Add new files to compilation.
     12        * WebCore.vcxproj/WebCore.vcxproj: Ditto.
     13        * editing/Editor.cpp:
     14        (WebCore::Editor::pasteWithPasteboard): Move to EditorWin.cpp
     15        since this is only used by windows port.
     16        * editing/Editor.h:
     17        * editing/efl/EditorEfl.cpp:
     18        (WebCore::Editor::webContentFromPasteboard):
     19        * editing/gtk/EditorGtk.cpp:
     20        (WebCore::Editor::webContentFromPasteboard):
     21        * editing/win/EditorWin.cpp: Added.
     22        (WebCore::Editor::pasteWithPasteboard):
     23        (WebCore::Editor::webContentFromPasteboard):
     24        * page/DragController.cpp:
     25        (WebCore::documentFragmentFromDragData): Use the editor instead of
     26        createFragmentFromDragData() that has been removed. Also made this
     27        method a static funtion again.
     28        * page/DragController.h:
     29        * page/efl/DragControllerEfl.cpp: Remove createFragmentFromDragData().
     30        * page/gtk/DragControllerGtk.cpp: Ditto.
     31        * page/mac/DragControllerMac.mm: Ditto.
     32        * page/win/DragControllerWin.cpp: Ditto.
     33        * platform/Pasteboard.h:
     34        (WebCore::Pasteboard::dragDataMap): Add a getter for m_dragDataMap
     35        as required by Editor::webContentFromPasteboard for windows.
     36
    1372014-10-04  Christophe Dumez  <cdumez@apple.com>
    238
  • trunk/Source/WebCore/PlatformWin.cmake

    r172499 r174314  
    1010list(APPEND WebCore_SOURCES
    1111    accessibility/win/AccessibilityObjectWin.cpp
     12
     13    editing/win/EditorWin.cpp
    1214
    1315    html/HTMLSelectElementWin.cpp
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r174278 r174314  
    1492914929      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
    1493014930    </ClCompile>
     14931    <ClCompile Include="..\editing\win\EditorWin.cpp"/>
    1493114932    <ClCompile Include="..\fileapi\AsyncFileStream.cpp" />
    1493214933    <ClCompile Include="..\html\BaseButtonInputType.cpp" />
  • trunk/Source/WebCore/editing/Editor.cpp

    r174225 r174314  
    561561#endif
    562562
    563 #if !PLATFORM(COCOA) && !PLATFORM(EFL) && !PLATFORM(GTK)
    564 void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
    565 {
    566     RefPtr<Range> range = selectedRange();
    567     if (!range)
    568         return;
    569 
    570     bool chosePlainText;
    571     RefPtr<DocumentFragment> fragment = pasteboard->documentFragment(m_frame, *range, allowPlainText, chosePlainText);
    572     if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
    573         pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
    574 }
    575 #endif
    576 
    577563bool Editor::canSmartReplaceWithPasteboard(Pasteboard& pasteboard)
    578564{
  • trunk/Source/WebCore/editing/Editor.h

    r173687 r174314  
    427427#endif
    428428
     429    PassRefPtr<DocumentFragment> webContentFromPasteboard(Pasteboard&, Range& context, bool allowPlainText, bool& chosePlainText);
     430
    429431#if PLATFORM(COCOA)
    430432    WEBCORE_EXPORT static RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove);
     
    434436    WEBCORE_EXPORT String stringSelectionForPasteboard();
    435437    String stringSelectionForPasteboardWithImageAltText();
    436     PassRefPtr<DocumentFragment> webContentFromPasteboard(Pasteboard&, Range& context, bool allowPlainText, bool& chosePlainText);
    437438#if !PLATFORM(IOS)
    438439    bool canCopyExcludingStandaloneImages();
  • trunk/Source/WebCore/editing/efl/EditorEfl.cpp

    r168650 r174314  
    2828#include "Editor.h"
    2929
     30#include "DocumentFragment.h"
    3031#include "NotImplemented.h"
    3132#include "Pasteboard.h"
     33#include <wtf/PassRefPtr.h>
    3234
    3335namespace WebCore {
     
    4850}
    4951
     52PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard&, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
     53{
     54    return nullptr;
     55}
     56
    5057} // namespace WebCore
  • trunk/Source/WebCore/editing/gtk/EditorGtk.cpp

    r173932 r174314  
    130130}
    131131
     132PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
     133{
     134    return createFragmentFromPasteboardData(pasteboard, m_frame, context, allowPlainText, chosePlainText);
     135}
     136
    132137} // namespace WebCore
  • trunk/Source/WebCore/page/DragController.cpp

    r174225 r174314  
    115115}
    116116
    117 PassRefPtr<DocumentFragment> DragController::documentFragmentFromDragData(DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
     117static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
    118118{
    119119    chosePlainText = false;
     
    121121    Document& document = context.ownerDocument();
    122122    if (dragData.containsCompatibleContent()) {
    123         if (PassRefPtr<DocumentFragment> fragment = createFragmentFromDragData(dragData, frame, context, allowPlainText, chosePlainText))
     123        if (PassRefPtr<DocumentFragment> fragment = frame.editor().webContentFromPasteboard(*Pasteboard::createForDragAndDrop(dragData), context, allowPlainText, chosePlainText))
    124124            return fragment;
    125125
  • trunk/Source/WebCore/page/DragController.h

    r173686 r174314  
    116116        void declareAndWriteDragImage(DataTransfer&, Element&, const URL&, const String& label);
    117117
    118         // FIXME: Move createFragmentFromDragData implementation to the Editor and make documentFragmentFromDragData a static function again.
    119         static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData&, Frame&, Range&, bool allowPlainText, bool& chosePlainText);
    120         static PassRefPtr<DocumentFragment> createFragmentFromDragData(DragData&, Frame&, Range&, bool allowPlainText, bool& chosePlainText);
    121 
    122118        Page& m_page;
    123119        DragClient& m_client;
  • trunk/Source/WebCore/page/efl/DragControllerEfl.cpp

    r173686 r174314  
    7474}
    7575
    76 PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData&, Frame&, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
    77 {
    78     return nullptr;
    7976}
    80 
    81 }
  • trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp

    r173687 r174314  
    8282}
    8383
    84 PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData& dragData, Frame& frame, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
    85 {
    86     if (!dragData.platformData()->hasMarkup() || !frame.document())
    87         return nullptr;
    88 
    89     return createFragmentFromMarkup(*frame.document(), dragData.platformData()->markup(), "");
    9084}
    91 
    92 }
  • trunk/Source/WebCore/page/mac/DragControllerMac.mm

    r173686 r174314  
    9393}
    9494
    95 PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
    96 {
    97     Pasteboard pasteboard(dragData.pasteboardName());
    98     return frame.editor().webContentFromPasteboard(pasteboard, context, allowPlainText, chosePlainText);
    99 }
    100 
    10195} // namespace WebCore
    10296
  • trunk/Source/WebCore/page/win/DragControllerWin.cpp

    r173686 r174314  
    2727#include "DragController.h"
    2828
    29 #include "ClipboardUtilitiesWin.h"
    3029#include "DataTransfer.h"
    3130#include "Document.h"
    32 #include "DocumentFragment.h"
    3331#include "DragData.h"
    3432#include "Element.h"
    35 #include "Frame.h"
    36 #include "FrameSelection.h"
    3733#include "Pasteboard.h"
    3834#include "markup.h"
     
    8884}
    8985
    90 template <typename PlatformDragData>
    91 static PassRefPtr<DocumentFragment> createFragmentFromPlatformData(PlatformDragData* platformDragData, Frame& frame)
    92 {
    93     if (containsFilenames(platformDragData)) {
    94         if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame.document(), platformDragData))
    95             return fragment;
    96     }
    97 
    98     if (containsHTML(platformDragData)) {
    99         if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame.document(), platformDragData))
    100             return fragment;
    101     }
    102     return nullptr;
    10386}
    104 
    105 PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData& dragData, Frame& frame, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
    106 {
    107     if (DragDataRef platformDragData = dragData.platformData())
    108         return createFragmentFromPlatformData(platformDragData, frame);
    109 
    110     return createFragmentFromPlatformData(&dragData.dragDataMap(), frame);
    111 }
    112 
    113 }
  • trunk/Source/WebCore/platform/Pasteboard.h

    r173687 r174314  
    203203    COMPtr<IDataObject> dataObject() const { return m_dataObject; }
    204204    void setExternalDataObject(IDataObject*);
     205    const DragDataMap& dragDataMap() const { return m_dragDataMap; }
    205206    void writeURLToWritableDataObject(const URL&, const String&);
    206207    COMPtr<WCDataObject> writableDataObject() const { return m_writableDataObject; }
Note: See TracChangeset for help on using the changeset viewer.