[chromium] No modifier flags (shift/ctrl/alt) in drag&drop events on chromium linux

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: http://svn.webkit.org/repository/webkit/trunk@117327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2ef5ac99
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
......
<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>
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.
......@@ -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());
......
......@@ -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)
......@@ -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
......
......@@ -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)
{
}
......
......@@ -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
......
......@@ -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();
......
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
......@@ -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 -------------------
......
......@@ -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,
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment