Changeset 49651 in webkit


Ignore:
Timestamp:
Oct 15, 2009 1:39:43 PM (14 years ago)
Author:
dbates@webkit.org
Message:

2009-10-15 Daniel Bates <dbates@webkit.org>

Reviewed by Adam Roben.

https://bugs.webkit.org/show_bug.cgi?id=24731
And
rdar://problem/5015961


Implements support for DHTML drag-and-drop operations (i.e. ondragstart, ondragend)
in the Windows build so that it conforms to the Mac OS X build. Hence, dropEffect is
correctly set.


The WebView and WebDropSource drag-and-drop functions, as called by function
DoDragDrop in its event loop, neither used the drop effect as specified by
event.dataTransfer.dropEffect nor respected event.dataTransfer.effectsAllowed.
Instead, these functions defaulted to some hardcoded drop effect and set of
allowed drop effects, respectively.

Tests: fast/events/drag-and-drop.html

  • WebCoreSupport/WebDragClient.cpp: (WebDragClient::startDrag):
  • WebDropSource.cpp: (WebDropSource::QueryContinueDrag): Moved call to EventHandler::dragSourceEndedAt into method WebDragClient::startDrag.
  • WebDropSource.h:
  • WebView.cpp: (WebView::keyStateToDragOperation): Fixes <rdar://problem/5015961>. Determines appropriate drop effect from state of keyboard and allowed effects m_page->dragController()->sourceDragOperation(). (WebView::DragEnter): (WebView::DragOver): (WebView::Drop):
  • WebView.h:

2009-10-15 Daniel Bates <dbates@webkit.org>

Reviewed by Adam Roben.

https://bugs.webkit.org/show_bug.cgi?id=24731
And
rdar://problem/5015961


Tests that DHTML drag-and-drop works correctly.


Note, this test fails when effectAllowed == "uninitialized" because
this effect has not been implemented yet (see bug #30291).

  • fast/events/drag-and-drop-expected.txt: Added.
  • fast/events/drag-and-drop.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r49646 r49651  
     12009-10-15  Daniel Bates  <dbates@webkit.org>
     2
     3        Reviewed by Adam Roben.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=24731
     6        And
     7        rdar://problem/5015961
     8       
     9        Tests that DHTML drag-and-drop works correctly.
     10       
     11        Note, this test fails when effectAllowed == "uninitialized" because
     12        this effect has not been implemented yet (see bug #30291).
     13
     14        * fast/events/drag-and-drop-expected.txt: Added.
     15        * fast/events/drag-and-drop.html: Added.
     16
    1172009-10-15  Zan Dobersek  <zandobersek@gmail.com>
    218
  • trunk/WebKit/win/ChangeLog

    r49566 r49651  
     12009-10-15  Daniel Bates  <dbates@webkit.org>
     2
     3        Reviewed by Adam Roben.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=24731
     6        And
     7        rdar://problem/5015961
     8       
     9        Implements support for DHTML drag-and-drop operations (i.e. ondragstart, ondragend)
     10        in the Windows build so that it conforms to the Mac OS X build. Hence, dropEffect is
     11        correctly set.
     12       
     13        The WebView and WebDropSource drag-and-drop functions, as called by function
     14        DoDragDrop in its event loop, neither used the drop effect as specified by
     15        event.dataTransfer.dropEffect nor respected event.dataTransfer.effectsAllowed.
     16        Instead, these functions defaulted to some hardcoded drop effect and set of
     17        allowed drop effects, respectively.
     18
     19        Tests: fast/events/drag-and-drop.html
     20
     21        * WebCoreSupport/WebDragClient.cpp:
     22        (WebDragClient::startDrag):
     23        * WebDropSource.cpp:
     24        (WebDropSource::QueryContinueDrag): Moved call to EventHandler::dragSourceEndedAt
     25        into method WebDragClient::startDrag.
     26        * WebDropSource.h:
     27        * WebView.cpp:
     28        (WebView::keyStateToDragOperation): Fixes <rdar://problem/5015961>. Determines
     29        appropriate drop effect from state of keyboard and allowed effects
     30        m_page->dragController()->sourceDragOperation().
     31        (WebView::DragEnter):
     32        (WebView::DragOver):
     33        (WebView::Drop):
     34        * WebView.h:
     35
    1362009-10-14  Adam Roben  <aroben@apple.com>
    237
  • trunk/WebKit/win/WebCoreSupport/WebDragClient.cpp

    r49268 r49651  
    173173
    174174        DWORD okEffect = draggingSourceOperationMaskToDragCursors(m_webView->page()->dragController()->sourceDragOperation());
    175         DWORD effect;
     175        DWORD effect = DROPEFFECT_NONE;
    176176        COMPtr<IWebUIDelegate> ui;
     177        HRESULT hr = E_NOTIMPL;
    177178        if (SUCCEEDED(m_webView->uiDelegate(&ui))) {
    178179            COMPtr<IWebUIDelegatePrivate> uiPrivate;
    179180            if (SUCCEEDED(ui->QueryInterface(IID_IWebUIDelegatePrivate, (void**)&uiPrivate)))
    180                 if (SUCCEEDED(uiPrivate->doDragDrop(m_webView, dataObject.get(), source.get(), okEffect, &effect)))
    181                     return;
     181                hr = uiPrivate->doDragDrop(m_webView, dataObject.get(), source.get(), okEffect, &effect);
    182182        }
    183 
    184         DoDragDrop(dataObject.get(), source.get(), okEffect, &effect);
     183        if (hr == E_NOTIMPL)
     184            hr = DoDragDrop(dataObject.get(), source.get(), okEffect, &effect);
     185
     186        DragOperation operation = DragOperationNone;
     187        if (hr == DRAGDROP_S_DROP) {
     188            if (effect & DROPEFFECT_COPY)
     189                operation = DragOperationCopy;
     190            else if (effect & DROPEFFECT_LINK)
     191                operation = DragOperationLink;
     192            else if (effect & DROPEFFECT_MOVE)
     193                operation = DragOperationMove;
     194        }
     195        frame->eventHandler()->dragSourceEndedAt(generateMouseEvent(m_webView, false), operation);
    185196    }
    186197}
  • trunk/WebKit/win/WebDropSource.cpp

    r45515 r49651  
    107107    if (fEscapePressed || !(grfKeyState & (MK_LBUTTON|MK_RBUTTON))) {
    108108        m_dropped = !fEscapePressed;
    109         if (Page* page = m_webView->page())
    110             if (Frame* frame = page->mainFrame())
    111                 //FIXME: We need to figure out how to find out what actually happened in the drag <rdar://problem/5015961>
    112                 frame->eventHandler()->dragSourceEndedAt(generateMouseEvent(m_webView.get(), false), fEscapePressed ? DragOperationNone : DragOperationCopy);
    113109        return fEscapePressed? DRAGDROP_S_CANCEL : DRAGDROP_S_DROP;
    114110    } else if (Page* page = m_webView->page())
  • trunk/WebKit/win/WebDropSource.h

    r31726 r49651  
    3333class WebView;
    3434
     35namespace WebCore {
     36    class PlatformMouseEvent;
     37}
     38
     39WebCore::PlatformMouseEvent generateMouseEvent(WebView*, bool isDrag);
     40
    3541class WebDropSource : public IDropSource
    3642{
  • trunk/WebKit/win/WebView.cpp

    r49564 r49651  
    46454645}
    46464646
    4647 static DragOperation keyStateToDragOperation(DWORD) {
    4648     //FIXME: This is currently very simple, it may need to actually
    4649     //work out an appropriate DragOperation in future -- however this
    4650     //behaviour appears to match FireFox
    4651     return (DragOperation)(DragOperationCopy | DragOperationLink);
     4647DragOperation WebView::keyStateToDragOperation(DWORD grfKeyState) const
     4648{
     4649    if (!m_page)
     4650        return DragOperationNone;
     4651
     4652    // Conforms to Microsoft's key combinations as documented for
     4653    // IDropTarget::DragOver. Note, grfKeyState is the current
     4654    // state of the keyboard modifier keys on the keyboard. See:
     4655    // <http://msdn.microsoft.com/en-us/library/ms680129(VS.85).aspx>.
     4656    DragOperation operation = m_page->dragController()->sourceDragOperation();
     4657
     4658    if ((grfKeyState & (MK_CONTROL | MK_SHIFT)) == (MK_CONTROL | MK_SHIFT))
     4659        operation = DragOperationLink;
     4660    else if ((grfKeyState & MK_CONTROL) == MK_CONTROL)
     4661        operation = DragOperationCopy;
     4662    else if ((grfKeyState & MK_SHIFT) == MK_SHIFT)
     4663        operation = DragOperationGeneric;
     4664
     4665    return operation;
    46524666}
    46534667
     
    46664680    *pdwEffect = dragOperationToDragCursor(m_page->dragController()->dragEntered(&data));
    46674681
     4682    m_lastDropEffect = *pdwEffect;
    46684683    m_dragData = pDataObject;
    46694684
     
    46864701        *pdwEffect = DROPEFFECT_NONE;
    46874702
     4703    m_lastDropEffect = *pdwEffect;
    46884704    return S_OK;
    46894705}
     
    47104726
    47114727    m_dragData = 0;
    4712     *pdwEffect = DROPEFFECT_NONE;
     4728    *pdwEffect = m_lastDropEffect;
    47134729    POINTL localpt = pt;
    47144730    ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt);
  • trunk/WebKit/win/WebView.h

    r49564 r49651  
    873873    void updateBackingStore(WebCore::FrameView*, HDC = 0, bool backingStoreCompletelyDirty = false, WindowsToPaint = PaintWebViewOnly);
    874874
     875    WebCore::DragOperation keyStateToDragOperation(DWORD grfKeyState) const;
     876
     877    // FIXME: This variable is part of a workaround. The drop effect (pdwEffect) passed to Drop is incorrect.
     878    // We set this variable in DragEnter and DragOver so that it can be used in Drop to set the correct drop effect.
     879    // Thus, on return from DoDragDrop we have the correct pdwEffect for the drag-and-drop operation.
     880    // (see https://bugs.webkit.org/show_bug.cgi?id=29264)
     881    DWORD m_lastDropEffect;
     882
    875883protected:
    876884    HIMC getIMMContext();
Note: See TracChangeset for help on using the changeset viewer.