Commit 6183bf93 authored by oliver@apple.com's avatar oliver@apple.com

2010-03-14 Oliver Hunt <oliver@apple.com>

        Reviewed by Darin Adler.

        REGRESSION(r53287): drop event is not fired if dataTransfer.dropEffect is not explicitly set
        https://bugs.webkit.org/show_bug.cgi?id=36095

        Correct this test to cover the somewhat bizarre "correct" handling
        of undefined dropEffect

        * fast/events/drag-and-drop-expected.txt:
        * fast/events/drag-and-drop.html:
2010-03-14  Oliver Hunt  <oliver@apple.com>

        Reviewed by Darin Adler.

        REGRESSION(r53287): drop event is not fired if dataTransfer.dropEffect is not explicitly set
        https://bugs.webkit.org/show_bug.cgi?id=36095

        The issue here is that while dropEffect is meant to be initialized
        to "none", the behaviour of the drag is differs between dragEffect
        not being set and dragEffect being explicitly set to "none"

        This patch corrects this behaviour by making Clipboard distinguish
        between the initial "none" value of dropEffect and an explicit "none".
        This alone is insufficient for correct behaviour, we also need to
        resurrect the removed defaultOperationForDrag function, but we now
        use the function only when dragEffect is uninitialized.  There are a
        few tweaks to the behaviour of the defaultOperationForDrag as well
        to ensure exactly the same set of outcomes for all cases that we
        may hit it.

        * dom/Clipboard.cpp:
        (WebCore::Clipboard::Clipboard):
        (WebCore::dragOpFromIEOp):
        (WebCore::Clipboard::destinationOperation):
        * dom/Clipboard.h:
        (WebCore::Clipboard::dropEffect):
        (WebCore::Clipboard::dropEffectIsUninitialized):
        * page/DragController.cpp:
        (WebCore::defaultOperationForDrag):
        (WebCore::DragController::tryDHTMLDrag):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55977 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bba8e8db
2010-03-14 Oliver Hunt <oliver@apple.com>
Reviewed by Darin Adler.
REGRESSION(r53287): drop event is not fired if dataTransfer.dropEffect is not explicitly set
https://bugs.webkit.org/show_bug.cgi?id=36095
Correct this test to cover the somewhat bizarre "correct" handling
of undefined dropEffect
* fast/events/drag-and-drop-expected.txt:
* fast/events/drag-and-drop.html:
2010-03-12 Shu Chang <chang.shu@nokia.com>
Reviewed by David Levin.
......
......@@ -11,7 +11,7 @@ PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
PASS event.dataTransfer.dropEffect is "move"
PASS event.dataTransfer.dropEffect is "link"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
When effectAllowed == "undefined"
......@@ -24,7 +24,7 @@ PASS event.dataTransfer.dropEffect is "move"
PASS event.dataTransfer.effectAllowed is "uninitialized"
PASS event.dataTransfer.dropEffect is "link"
PASS event.dataTransfer.effectAllowed is "uninitialized"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
When effectAllowed == "none"
......@@ -40,7 +40,7 @@ PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
PASS event.dataTransfer.dropEffect is "move"
PASS event.dataTransfer.dropEffect is "link"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
When effectAllowed == "copy"
......@@ -48,7 +48,7 @@ PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
When effectAllowed == "move"
......@@ -56,7 +56,7 @@ PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "move"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "move"
When effectAllowed == "link"
......@@ -64,7 +64,7 @@ PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "link"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "link"
When effectAllowed == "copyMove"
......@@ -72,7 +72,7 @@ PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
PASS event.dataTransfer.dropEffect is "move"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "move"
When effectAllowed == "copyLink"
......@@ -80,7 +80,7 @@ PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "link"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
When effectAllowed == "linkMove"
......@@ -88,7 +88,7 @@ PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "move"
PASS event.dataTransfer.dropEffect is "link"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "move"
When effectAllowed == "dummy"
......@@ -101,7 +101,7 @@ PASS event.dataTransfer.dropEffect is "move"
PASS event.dataTransfer.effectAllowed is "uninitialized"
PASS event.dataTransfer.dropEffect is "link"
PASS event.dataTransfer.effectAllowed is "uninitialized"
PASS event.dataTransfer.dropEffect is "none"
PASS event.dataTransfer.dropEffect is "copy"
TEST COMPLETE
......@@ -108,9 +108,26 @@
// doesn't need special cases for undefined.
chosenEffectAllowed = "uninitialized";
}
expected = dropEffectElem.options[dropEffectElem.selectedIndex].value;
if (chosenDropEffect == "dummy") {
switch (chosenEffectAllowed) {
case "undefined":
case "copyLink":
case "uninitialized":
case "all":
expected = "copy";
break;
case "copyMove":
case "move":
case "linkMove":
expected = "move";
break;
default:
expected = chosenEffectAllowed;
}
}
if (isDropEffectAllowed(chosenDropEffect, chosenEffectAllowed))
shouldBeEqualToString('event.dataTransfer.dropEffect', dropEffectElem.options[dropEffectElem.selectedIndex].value);
shouldBeEqualToString('event.dataTransfer.dropEffect', expected);
else
shouldBeEqualToString('event.dataTransfer.dropEffect', 'none');
......@@ -126,6 +143,8 @@
return true;
if (chosenDropEffect == "link" && ["link", "copyLink", "linkMove", "uninitialized", "all"].indexOf(allowedDropEffect) != -1)
return true;
if (chosenDropEffect == "dummy" && ["copy", "link", "move", "copyLink", "copyMove", "linkMove", "uninitialized", "all"].indexOf(allowedDropEffect) != -1)
return true;
return false;
}
......
2010-03-14 Oliver Hunt <oliver@apple.com>
Reviewed by Darin Adler.
REGRESSION(r53287): drop event is not fired if dataTransfer.dropEffect is not explicitly set
https://bugs.webkit.org/show_bug.cgi?id=36095
The issue here is that while dropEffect is meant to be initialized
to "none", the behaviour of the drag is differs between dragEffect
not being set and dragEffect being explicitly set to "none"
This patch corrects this behaviour by making Clipboard distinguish
between the initial "none" value of dropEffect and an explicit "none".
This alone is insufficient for correct behaviour, we also need to
resurrect the removed defaultOperationForDrag function, but we now
use the function only when dragEffect is uninitialized. There are a
few tweaks to the behaviour of the defaultOperationForDrag as well
to ensure exactly the same set of outcomes for all cases that we
may hit it.
* dom/Clipboard.cpp:
(WebCore::Clipboard::Clipboard):
(WebCore::dragOpFromIEOp):
(WebCore::Clipboard::destinationOperation):
* dom/Clipboard.h:
(WebCore::Clipboard::dropEffect):
(WebCore::Clipboard::dropEffectIsUninitialized):
* page/DragController.cpp:
(WebCore::defaultOperationForDrag):
(WebCore::DragController::tryDHTMLDrag):
2010-03-14 Antti Koivisto <koivisto@iki.fi>
Reviewed by Simon Hausmann.
......
......@@ -36,7 +36,7 @@ namespace WebCore {
Clipboard::Clipboard(ClipboardAccessPolicy policy, bool isForDragging)
: m_policy(policy)
, m_dropEffect("none")
, m_dropEffect("uninitialized")
, m_effectAllowed("uninitialized")
, m_dragStarted(false)
, m_forDragging(isForDragging)
......@@ -110,7 +110,7 @@ DragOperation Clipboard::sourceOperation() const
DragOperation Clipboard::destinationOperation() const
{
DragOperation op = dragOpFromIEOp(m_dropEffect);
ASSERT(op == DragOperationCopy || op == DragOperationNone || op == DragOperationLink || op == DragOperationGeneric || op == DragOperationMove);
ASSERT(op == DragOperationCopy || op == DragOperationNone || op == DragOperationLink || op == DragOperationGeneric || op == DragOperationMove || op == DragOperationEvery);
return op;
}
......
......@@ -43,8 +43,9 @@ namespace WebCore {
// Is this operation a drag-drop or a copy-paste?
bool isForDragging() const { return m_forDragging; }
String dropEffect() const { return m_dropEffect; }
String dropEffect() const { return dropEffectIsUninitialized() ? "none" : m_dropEffect; }
void setDropEffect(const String&);
bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitialized"; }
String effectAllowed() const { return m_effectAllowed; }
void setEffectAllowed(const String&);
......
......@@ -485,6 +485,25 @@ bool DragController::canProcessDrag(DragData* dragData)
return true;
}
static DragOperation defaultOperationForDrag(DragOperation srcOpMask)
{
// This is designed to match IE's operation fallback for the case where
// the page calls preventDefault() in a drag event but doesn't set dropEffect.
if (srcOpMask == DragOperationEvery)
return DragOperationCopy;
if (srcOpMask == DragOperationNone)
return DragOperationNone;
if (srcOpMask & DragOperationMove || srcOpMask & DragOperationGeneric)
return DragOperationMove;
if (srcOpMask & DragOperationCopy)
return DragOperationCopy;
if (srcOpMask & DragOperationLink)
return DragOperationLink;
// FIXME: Does IE really return "generic" even if no operations were allowed by the source?
return DragOperationGeneric;
}
bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
{
ASSERT(dragData);
......@@ -506,7 +525,9 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
}
operation = clipboard->destinationOperation();
if (!(srcOpMask & operation)) {
if (clipboard->dropEffectIsUninitialized())
operation = defaultOperationForDrag(srcOpMask);
else if (!(srcOpMask & operation)) {
// The element picked an operation which is not supported by the source
operation = DragOperationNone;
}
......
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