[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 8e99e9e..e1193d2 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 16666fc..c3b5585 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 89d72ae..135446c 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 a61feab..efb705a 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 823ac55..e13333e 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 e656f44..876ec43 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 1a5d789..1efb4df 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 009a3a0..a04a30f 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 1187b64..c391eee 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 c1a29ce..0f7093a 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 a00e2b5..e884fea 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)
@@ -2593,12 +2607,22 @@ WebDragOperation WebViewImpl::dragTargetDragEnter(
     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(
@@ -2606,9 +2630,18 @@ WebDragOperation WebViewImpl::dragTargetDragOver(
     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()
@@ -2632,6 +2665,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);
 
     // If this webview transitions from the "drop accepting" state to the "not
@@ -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 def7e87..b76a172 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();