[chromium] No modifier flags (shift/ctrl/alt) in drag&drop events on chromium linux
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 May 2012 20:04:36 +0000 (20:04 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 May 2012 20:04:36 +0000 (20:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86236

Patch by Varun Jain <varunjain@google.com> on 2012-05-16
Reviewed by Tony Chang.

.:

* ManualTests/chromium/modifiers-during-drag-and-drop.html: Added.

Source/WebCore:

ManualTests: ManualTests/chromium/modifiers-during-drag-and-drop.html

* page/DragController.cpp:
(WebCore::createMouseEvent):
* platform/DragData.cpp:
(WebCore):
(WebCore::DragData::modifierKeyState):
* platform/DragData.h:
(DragData):
* platform/chromium/ChromiumDataObject.cpp:
(WebCore::ChromiumDataObject::ChromiumDataObject):
* platform/chromium/ChromiumDataObject.h:
(WebCore::ChromiumDataObject::modifierKeyState):
(WebCore::ChromiumDataObject::setModifierKeyState):
(ChromiumDataObject):
* platform/chromium/DragDataChromium.cpp:
(WebCore::DragData::modifierKeyState):
(WebCore):

Source/WebKit/chromium:

* public/WebView.h:
(WebView):
* src/WebViewImpl.cpp:
(WebKit::webInputEventKeyStateToPlatformEventKeyState):
(WebKit):
(WebKit::WebViewImpl::dragTargetDragEnter):
(WebKit::WebViewImpl::dragTargetDragOver):
(WebKit::WebViewImpl::dragTargetDrop):
(WebKit::WebViewImpl::dragTargetDragEnterOrOver):
* src/WebViewImpl.h:
(WebViewImpl):

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

13 files changed:
ChangeLog
ManualTests/chromium/modifiers-during-drag-and-drop.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/DragController.cpp
Source/WebCore/platform/DragData.cpp
Source/WebCore/platform/DragData.h
Source/WebCore/platform/chromium/ChromiumDataObject.cpp
Source/WebCore/platform/chromium/ChromiumDataObject.h
Source/WebCore/platform/chromium/DragDataChromium.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebView.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h

index 8e99e9e5b9a5fe914016f0cb2c101579c9b59ced..e1193d2f691010836f917757b7f66ee25d065ca2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-05-16  Varun Jain  <varunjain@google.com>
+
+        [chromium] No modifier flags (shift/ctrl/alt) in drag&drop events on chromium linux
+        https://bugs.webkit.org/show_bug.cgi?id=86236
+
+        Reviewed by Tony Chang.
+
+        * ManualTests/chromium/modifiers-during-drag-and-drop.html: Added.
+
 2012-05-16  Keishi Hattori  <keishi@webkit.org>
 
         [chromium] Add WebKit API to access inner text value of input element
diff --git a/ManualTests/chromium/modifiers-during-drag-and-drop.html b/ManualTests/chromium/modifiers-during-drag-and-drop.html
new file mode 100644 (file)
index 0000000..72136bb
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+<head>
+<script>
+    function logDrag(e) {
+        var l = document.getElementById('log');
+        l.innerHTML += 'shiftKey=' + e.shiftKey + ' ctrlKey=' + e.ctrlKey + ' altKey=' + e.altKey + ' metaKey=' + e.metaKey + '\n';
+        e.preventDefault();
+    }
+
+    document.addEventListener('DOMContentLoaded', function() {
+        document.addEventListener('dragenter', logDrag, false);
+        document.addEventListener('dragover', logDrag, false);
+        document.addEventListener('dragleave', logDrag, false);
+        document.addEventListener('drop', logDrag, false);
+    });
+</script>
+</head>
+
+<body>
+    <p>Drag the "Drag me" with any modifier keys pressed (Shift/Ctrl/Alt) and see if the log messages have the correct modifier state</p>
+    <div draggable='true' id='dragme'>
+        Drag me
+    </div>
+    <pre id='log'></pre>
+</body>
+</html>
index 16666fcdc005c50ea073960cb0604be791f03ccd..c3b558539654c0adaddfe9f7fd21df560ce10c68 100644 (file)
@@ -1,3 +1,29 @@
+2012-05-16  Varun Jain  <varunjain@google.com>
+
+        [chromium] No modifier flags (shift/ctrl/alt) in drag&drop events on chromium linux
+        https://bugs.webkit.org/show_bug.cgi?id=86236
+
+        Reviewed by Tony Chang.
+
+        ManualTests: ManualTests/chromium/modifiers-during-drag-and-drop.html
+
+        * page/DragController.cpp:
+        (WebCore::createMouseEvent):
+        * platform/DragData.cpp:
+        (WebCore):
+        (WebCore::DragData::modifierKeyState):
+        * platform/DragData.h:
+        (DragData):
+        * platform/chromium/ChromiumDataObject.cpp:
+        (WebCore::ChromiumDataObject::ChromiumDataObject):
+        * platform/chromium/ChromiumDataObject.h:
+        (WebCore::ChromiumDataObject::modifierKeyState):
+        (WebCore::ChromiumDataObject::setModifierKeyState):
+        (ChromiumDataObject):
+        * platform/chromium/DragDataChromium.cpp:
+        (WebCore::DragData::modifierKeyState):
+        (WebCore):
+
 2012-05-16  Jer Noble  <jer.noble@apple.com>
 
         <video> elements with no video tracks report false for webkitSupportsFullscreen.
index 89d72ae83638f764cd6db0fd18e43d0b9c94f25d..135446cf4088576f4159ee49aee84863b32213f3 100644 (file)
@@ -77,7 +77,12 @@ static PlatformMouseEvent createMouseEvent(DragData* dragData)
 {
     bool shiftKey, ctrlKey, altKey, metaKey;
     shiftKey = ctrlKey = altKey = metaKey = false;
-    PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, metaKey);
+    int keyState = dragData->modifierKeyState();
+    shiftKey = static_cast<bool>(keyState & PlatformEvent::ShiftKey);
+    ctrlKey = static_cast<bool>(keyState & PlatformEvent::CtrlKey);
+    altKey = static_cast<bool>(keyState & PlatformEvent::AltKey);
+    metaKey = static_cast<bool>(keyState & PlatformEvent::MetaKey);
+
     return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPosition(),
                               LeftButton, PlatformEvent::MouseMoved, 0, shiftKey, ctrlKey, altKey,
                               metaKey, currentTime());
index a61feab5ab3c0f902a858fa471bc70b190ea4f7f..efb705a46b524c04efe5e41ab4cf10eb7e4a1d4b 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "config.h"
 #include "DragData.h"
+#include "PlatformEvent.h"
+#include "PlatformKeyboardEvent.h"
 
 #if ENABLE(DRAG_SUPPORT)
 namespace WebCore {
@@ -51,6 +53,26 @@ DragData::DragData(const String&, const IntPoint& clientPosition, const IntPoint
 }
 #endif
 
+#if !PLATFORM(CHROMIUM)
+int DragData::modifierKeyState() const
+{
+    bool shiftKey, ctrlKey, altKey, metaKey;
+    shiftKey = ctrlKey = altKey = metaKey = false;
+    PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, metaKey);
+    int keyState = 0;
+    if (shiftKey)
+        keyState = keyState | PlatformEvent::ShiftKey;
+    if (ctrlKey)
+        keyState = keyState | PlatformEvent::CtrlKey;
+    if (altKey)
+        keyState = keyState | PlatformEvent::AltKey;
+    if (metaKey)
+        keyState = keyState | PlatformEvent::MetaKey;
+    return keyState;
+}
+#endif
+
+
 } // namespace WebCore
 
 #endif // ENABLE(DRAG_SUPPORT)
index 823ac553e5bfdc122b3a2a5c453c4dff782fb7a7..e13333e33fda0e590cb023b92584b3c42cfc009b 100644 (file)
@@ -118,6 +118,7 @@ public:
     bool containsColor() const;
     bool containsFiles() const;
     unsigned numberOfFiles() const;
+    int modifierKeyState() const;
 #if PLATFORM(MAC)
     const String& pasteboardName() { return m_pasteboardName; }
 #endif
index e656f44b27a8e1fcac16c8f00fe54f1d1d59842a..876ec437966df3973ffd77e8da4e3865bcf0c28c 100644 (file)
@@ -213,12 +213,14 @@ void ChromiumDataObject::addSharedBuffer(const String& name, PassRefPtr<SharedBu
 }
 
 ChromiumDataObject::ChromiumDataObject()
+    : m_modifierKeyState(0)
 {
 }
 
 ChromiumDataObject::ChromiumDataObject(const ChromiumDataObject& other)
     : RefCounted<ChromiumDataObject>()
     , m_itemList(other.m_itemList)
+    , m_modifierKeyState(0)
 {
 }
 
index 1a5d7898a4ec39226872c308f9857f5cb11ab98b..1efb4dfec7d1100c7dab5a21c9c05ae747af5685 100644 (file)
@@ -86,6 +86,9 @@ public:
     // Used to handle files (images) being dragged out.
     void addSharedBuffer(const String& name, PassRefPtr<SharedBuffer>);
 
+    int modifierKeyState() const { return m_modifierKeyState; }
+    void setModifierKeyState(int modifierKeyState) { m_modifierKeyState = modifierKeyState; }
+
 private:
     ChromiumDataObject();
     explicit ChromiumDataObject(const ChromiumDataObject&);
@@ -95,6 +98,9 @@ private:
     void internalAddFileItem(PassRefPtr<ChromiumDataObjectItem>);
 
     Vector<RefPtr<ChromiumDataObjectItem> > m_itemList;
+
+    // State of Shift/Ctrl/Alt/Meta keys.
+    int m_modifierKeyState;
 };
 
 } // namespace WebCore
index 009a3a08acc0e92cb9703aafe8fdd91b905d6dba..a04a30f2f461eb25c1b6258c63f8dfc2a55cc4bf 100644 (file)
@@ -75,6 +75,11 @@ unsigned DragData::numberOfFiles() const
     return m_platformDragData->filenames().size();
 }
 
+int DragData::modifierKeyState() const
+{
+    return m_platformDragData->modifierKeyState();
+}
+
 void DragData::asFilenames(Vector<String>& result) const
 {
     const Vector<String>& filenames = m_platformDragData->filenames();
index 1187b64cc50cfb5acc035182734b8cb638d6e693..c391eeef52337bcf02a281a199c6c786d1e0c596 100644 (file)
@@ -1,3 +1,22 @@
+2012-05-16  Varun Jain  <varunjain@google.com>
+
+        [chromium] No modifier flags (shift/ctrl/alt) in drag&drop events on chromium linux
+        https://bugs.webkit.org/show_bug.cgi?id=86236
+
+        Reviewed by Tony Chang.
+
+        * public/WebView.h:
+        (WebView):
+        * src/WebViewImpl.cpp:
+        (WebKit::webInputEventKeyStateToPlatformEventKeyState):
+        (WebKit):
+        (WebKit::WebViewImpl::dragTargetDragEnter):
+        (WebKit::WebViewImpl::dragTargetDragOver):
+        (WebKit::WebViewImpl::dragTargetDrop):
+        (WebKit::WebViewImpl::dragTargetDragEnterOrOver):
+        * src/WebViewImpl.h:
+        (WebViewImpl):
+
 2012-05-16  Yury Semikhatsky  <yurys@chromium.org>
 
         [Chromium] Web Inspector: DevToolsSanityTest.TestScriptsTabIsPopulatedOnInspectedPageRefresh is broken
index c1a29ced998ed032de1882b05b68153094159d4e..0f7093ac4fdc086154645a30c01ea334290fc5dc 100644 (file)
@@ -305,16 +305,31 @@ public:
 
     // Callback methods when a drag-and-drop operation is trying to drop
     // something on the WebView.
+    // FIXME: Remove this method after chromium changes catch up.
     virtual WebDragOperation dragTargetDragEnter(
         const WebDragData&,
         const WebPoint& clientPoint, const WebPoint& screenPoint,
         WebDragOperationsMask operationsAllowed) = 0;
+    virtual WebDragOperation dragTargetDragEnter(
+        const WebDragData&,
+        const WebPoint& clientPoint, const WebPoint& screenPoint,
+        WebDragOperationsMask operationsAllowed,
+        int keyModifiers) = 0;
+    // FIXME: Remove this method after chromium changes catch up.
     virtual WebDragOperation dragTargetDragOver(
         const WebPoint& clientPoint, const WebPoint& screenPoint,
         WebDragOperationsMask operationsAllowed) = 0;
+    virtual WebDragOperation dragTargetDragOver(
+        const WebPoint& clientPoint, const WebPoint& screenPoint,
+        WebDragOperationsMask operationsAllowed,
+        int keyModifiers) = 0;
     virtual void dragTargetDragLeave() = 0;
+    // FIXME: Remove this method after chromium changes catch up.
     virtual void dragTargetDrop(
         const WebPoint& clientPoint, const WebPoint& screenPoint) = 0;
+    virtual void dragTargetDrop(
+        const WebPoint& clientPoint, const WebPoint& screenPoint,
+        int keyModifiers) = 0;
 
 
     // Support for resource loading initiated by plugins -------------------
index a00e2b54484d55e33862161c8f93701d4ac2214e..e884fea7a283c35357421fbde91057b7bd816aba 100644 (file)
@@ -239,6 +239,20 @@ static const PopupContainerSettings autofillPopupSettings = {
 
 static bool shouldUseExternalPopupMenus = false;
 
+static int webInputEventKeyStateToPlatformEventKeyState(int webInputEventKeyState)
+{
+    int platformEventKeyState = 0;
+    if (webInputEventKeyState & WebInputEvent::ShiftKey)
+        platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent::ShiftKey;
+    if (webInputEventKeyState & WebInputEvent::ControlKey)
+        platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent::CtrlKey;
+    if (webInputEventKeyState & WebInputEvent::AltKey)
+        platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent::AltKey;
+    if (webInputEventKeyState & WebInputEvent::MetaKey)
+        platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent::MetaKey;
+    return platformEventKeyState;
+}
+
 // WebView ----------------------------------------------------------------
 
 WebView* WebView::create(WebViewClient* client)
@@ -2592,23 +2606,42 @@ WebDragOperation WebViewImpl::dragTargetDragEnter(
     const WebPoint& clientPoint,
     const WebPoint& screenPoint,
     WebDragOperationsMask operationsAllowed)
+{
+    return dragTargetDragEnter(webDragData, clientPoint, screenPoint, operationsAllowed, 0);
+}
+
+WebDragOperation WebViewImpl::dragTargetDragEnter(
+    const WebDragData& webDragData,
+    const WebPoint& clientPoint,
+    const WebPoint& screenPoint,
+    WebDragOperationsMask operationsAllowed,
+    int keyModifiers)
 {
     ASSERT(!m_currentDragData);
 
     m_currentDragData = webDragData;
     m_operationsAllowed = operationsAllowed;
 
-    return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter);
+    return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragEnter, keyModifiers);
 }
 
 WebDragOperation WebViewImpl::dragTargetDragOver(
     const WebPoint& clientPoint,
     const WebPoint& screenPoint,
     WebDragOperationsMask operationsAllowed)
+{
+    return dragTargetDragOver(clientPoint, screenPoint, operationsAllowed, 0);
+}
+
+WebDragOperation WebViewImpl::dragTargetDragOver(
+    const WebPoint& clientPoint,
+    const WebPoint& screenPoint,
+    WebDragOperationsMask operationsAllowed,
+    int keyModifiers)
 {
     m_operationsAllowed = operationsAllowed;
 
-    return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragOver);
+    return dragTargetDragEnterOrOver(clientPoint, screenPoint, DragOver, keyModifiers);
 }
 
 void WebViewImpl::dragTargetDragLeave()
@@ -2631,6 +2664,13 @@ void WebViewImpl::dragTargetDragLeave()
 
 void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
                                  const WebPoint& screenPoint)
+{
+    dragTargetDrop(clientPoint, screenPoint, 0);
+}
+
+void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
+                                 const WebPoint& screenPoint,
+                                 int keyModifiers)
 {
     ASSERT(m_currentDragData);
 
@@ -2646,6 +2686,7 @@ void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
         return;
     }
 
+    m_currentDragData->setModifierKeyState(webInputEventKeyStateToPlatformEventKeyState(keyModifiers));
     DragData dragData(
         m_currentDragData.get(),
         clientPoint,
@@ -2660,10 +2701,11 @@ void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
     m_dragScrollTimer->stop();
 }
 
-WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPoint, const WebPoint& screenPoint, DragAction dragAction)
+WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPoint, const WebPoint& screenPoint, DragAction dragAction, int keyModifiers)
 {
     ASSERT(m_currentDragData);
 
+    m_currentDragData->setModifierKeyState(webInputEventKeyStateToPlatformEventKeyState(keyModifiers));
     DragData dragData(
         m_currentDragData.get(),
         clientPoint,
index def7e8795bc969c1dafd6af208e6f454b356317c..b76a17206761d39d043e343fde144bc37a27698b 100644 (file)
@@ -231,14 +231,29 @@ public:
         const WebPoint& clientPoint,
         const WebPoint& screenPoint,
         WebDragOperationsMask operationsAllowed);
+    virtual WebDragOperation dragTargetDragEnter(
+        const WebDragData&,
+        const WebPoint& clientPoint,
+        const WebPoint& screenPoint,
+        WebDragOperationsMask operationsAllowed,
+        int keyModifiers);
     virtual WebDragOperation dragTargetDragOver(
         const WebPoint& clientPoint,
         const WebPoint& screenPoint,
         WebDragOperationsMask operationsAllowed);
+    virtual WebDragOperation dragTargetDragOver(
+        const WebPoint& clientPoint,
+        const WebPoint& screenPoint,
+        WebDragOperationsMask operationsAllowed,
+        int keyModifiers);
     virtual void dragTargetDragLeave();
     virtual void dragTargetDrop(
         const WebPoint& clientPoint,
         const WebPoint& screenPoint);
+    virtual void dragTargetDrop(
+        const WebPoint& clientPoint,
+        const WebPoint& screenPoint,
+        int keyModifiers);
     virtual unsigned long createUniqueIdentifierForRequest();
     virtual void inspectElementAt(const WebPoint& point);
     virtual WebString inspectorSettings() const;
@@ -578,7 +593,8 @@ private:
     // should be true.
     WebDragOperation dragTargetDragEnterOrOver(const WebPoint& clientPoint,
                                                const WebPoint& screenPoint,
-                                               DragAction);
+                                               DragAction,
+                                               int keyModifiers);
 
     void configureAutoResizeMode();