Commit 29bb5006 authored by mitz@apple.com's avatar mitz@apple.com

<rdar://problem/7696607> Links do not respect -webkit-user-drag: none

https://bugs.webkit.org/show_bug.cgi?id=35475

Reviewed by Maciej Stachowiak.

WebCore: 

Test: fast/css/user-drag-none.html

* page/DragController.cpp:
(WebCore::DragController::mayStartDragAtEventLocation): Added a node
parameter. The image drag check is done against the node, rather than
than against the hit test result. This prevents a non-draggable image
with an auto-draggable ancestor from being dragged alone. The link drag
check now ignores links that are -webkit-user-drag: none.
* page/DragController.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::shouldDragAutoNode): Pass the current node
to mayStartDragAtEventLocation().

LayoutTests: 

* fast/css/user-drag-none-expected.txt: Added.
* fast/css/user-drag-none.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bd3e8b8c
2010-02-27 Dan Bernstein <mitz@apple.com>
Reviewed by Maciej Stachowiak.
<rdar://problem/7696607> Links do not respect -webkit-user-drag: none
https://bugs.webkit.org/show_bug.cgi?id=35475
* fast/css/user-drag-none-expected.txt: Added.
* fast/css/user-drag-none.html: Added.
2010-02-27 Xan Lopez <xlopez@igalia.com>
Reviewed by Gustavo Noronha.
......
x
y
x
y
x
y
x
y
x
y
x
y
x
y
x
y
Test #0
PASS
PASS
Test #1
PASS
PASS
Test #2
PASS
PASS
Test #3
PASS
PASS
PASS
PASS
PASS
Test #4
PASS
PASS
PASS
PASS
PASS
Test #5
PASS
PASS
PASS
PASS
PASS
Test #6
PASS
PASS
PASS
PASS
PASS
Test #7
PASS
PASS
PASS
PASS
PASS
Test #8
PASS
PASS
PASS
PASS
PASS
Test #9
PASS
PASS
PASS
PASS
PASS
Test #10
PASS
PASS
PASS
PASS
PASS
<style>
.box { width: 100px; height: 90px; margin-bottom: 10px; background-color: lightblue; }
.drag-element { -webkit-user-drag: element; }
.drag-none { -webkit-user-drag: none; }
a { display: block; width: 80px; height: 80px; background-color: yellow; font-family: ahem; font-size: 25px; }
a span { color: orange; }
a img { vertical-align: bottom; }
</style>
<div id="container" style="position: relative;">
<div class="box" expect="IMG nil">
<img src="resources/greenbox.png">
</div>
<div class="box" expect="nil nil">
<img class="drag-none" src="resources/greenbox.png">
</div>
<div class="box drag-element" expect="DIV DIV">
<img class="drag-none" src="resources/greenbox.png">
</div>
<div class="box" expect="IMG text text A nil">
<a href="#"><img src="resources/greenbox.png">x<br><span>y</span></a>
</div>
<div class="box" expect="IMG text text A nil">
<a href="#" class="drag-element"><img src="resources/greenbox.png">x<br><span>y</span></a>
</div>
<div class="box" expect="IMG nil nil nil nil">
<a href="#" class="drag-none"><img src="resources/greenbox.png">x<br><span>y</span></a>
</div>
<div class="box" expect="A text text A nil">
<a href="#"><img class="drag-none" src="resources/greenbox.png">x<br><span>y</span></a>
</div>
<div class="box" expect="A text text A nil">
<a href="#" class="drag-element"><img class="drag-none" src="resources/greenbox.png">x<br><span>y</span></a>
</div>
<div class="box drag-element" expect="IMG DIV DIV DIV DIV">
<a href="#" class="drag-none"><img src="resources/greenbox.png">x<br><span>y</span></a>
</div>
<div class="box drag-element" expect="A text text A DIV">
<a href="#"><img class="drag-none" src="resources/greenbox.png">x<br><span>y</span></a>
</div>
<div class="box drag-element" expect="A text text A DIV">
<a href="#" class="drag-element"><img class="drag-none" src="resources/greenbox.png">x<br><span>y</span></a>
</div>
</div>
<pre id="console"></pre>
<script>
function log(message)
{
document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
}
onload = window.layoutTestController ? function()
{
layoutTestController.dumpAsText();
var container = document.getElementById("container");
var y = container.getBoundingClientRect().top;
for (var i = 0; i < container.childElementCount; ++i) {
var listener = function(event)
{
result = event.target.nodeType === Node.TEXT_NODE ? "text" : event.target.tagName;
};
container.addEventListener("dragstart", listener);
var child = container.children[i];
log("Test #" + i);
var expectedResults = child.getAttribute("expect").split(" ");
var result;
function test(h, v)
{
if (expectedResults.length) {
getSelection().empty();
result = "nil";
eventSender.mouseMoveTo(h, y - scrollY + v);
eventSender.mouseDown();
eventSender.mouseMoveTo(220, y - scrollY + v);
eventSender.mouseUp();
var expected = expectedResults.shift();
log(result === expected ? "PASS" : "FAIL: expected " + expected + " but got " + result);
}
}
test(20, 20);
test(45, 20);
test(20, 45);
test(45, 45);
test(95, 85);
container.removeEventListener("dragstart", listener);
y += 100;
scrollBy(0, 100);
}
} : undefined;
</script>
2010-02-27 Dan Bernstein <mitz@apple.com>
Reviewed by Maciej Stachowiak.
<rdar://problem/7696607> Links do not respect -webkit-user-drag: none
https://bugs.webkit.org/show_bug.cgi?id=35475
Test: fast/css/user-drag-none.html
* page/DragController.cpp:
(WebCore::DragController::mayStartDragAtEventLocation): Added a node
parameter. The image drag check is done against the node, rather than
than against the hit test result. This prevents a non-draggable image
with an auto-draggable ancestor from being dragged alone. The link drag
check now ignores links that are -webkit-user-drag: none.
* page/DragController.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::shouldDragAutoNode): Pass the current node
to mayStartDragAtEventLocation().
2010-02-27 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Timothy Hatcher.
......
......@@ -512,7 +512,7 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
return true;
}
bool DragController::mayStartDragAtEventLocation(const Frame* frame, const IntPoint& framePos)
bool DragController::mayStartDragAtEventLocation(const Frame* frame, const IntPoint& framePos, Node* node)
{
ASSERT(frame);
ASSERT(frame->settings());
......@@ -523,6 +523,8 @@ bool DragController::mayStartDragAtEventLocation(const Frame* frame, const IntPo
HitTestResult mouseDownTarget = HitTestResult(framePos);
mouseDownTarget = frame->eventHandler()->hitTestResultAtPoint(framePos, true);
if (node)
mouseDownTarget.setInnerNonSharedNode(node);
if (mouseDownTarget.image()
&& !mouseDownTarget.absoluteImageURL().isEmpty()
......@@ -532,7 +534,8 @@ bool DragController::mayStartDragAtEventLocation(const Frame* frame, const IntPo
if (!mouseDownTarget.absoluteLinkURL().isEmpty()
&& m_dragSourceAction & DragSourceActionLink
&& mouseDownTarget.isLiveLink())
&& mouseDownTarget.isLiveLink()
&& mouseDownTarget.URLElement()->renderer() && mouseDownTarget.URLElement()->renderer()->style()->userDrag() != DRAG_NONE)
return true;
if (mouseDownTarget.isSelected()
......@@ -540,7 +543,6 @@ bool DragController::mayStartDragAtEventLocation(const Frame* frame, const IntPo
return true;
return false;
}
static CachedImage* getCachedImage(Element* element)
......
......@@ -77,7 +77,7 @@ namespace WebCore {
DragDestinationAction dragDestinationAction() const { return m_dragDestinationAction; }
DragSourceAction delegateDragSourceAction(const IntPoint& pagePoint);
bool mayStartDragAtEventLocation(const Frame*, const IntPoint& framePos);
bool mayStartDragAtEventLocation(const Frame*, const IntPoint& framePos, Node*);
void dragEnded();
void placeDragCaret(const IntPoint&);
......
......@@ -2217,7 +2217,7 @@ bool EventHandler::shouldDragAutoNode(Node* node, const IntPoint& point) const
if (!node || !m_frame->view())
return false;
Page* page = m_frame->page();
return page && page->dragController()->mayStartDragAtEventLocation(m_frame, point);
return page && page->dragController()->mayStartDragAtEventLocation(m_frame, point, node);
}
void EventHandler::dragSourceEndedAt(const PlatformMouseEvent& event, DragOperation operation)
......
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