Commit 91cc070e authored by rniwa@webkit.org's avatar rniwa@webkit.org

2011-05-13 Ryosuke Niwa <rniwa@webkit.org>

        Reviewed by Darin Adler.

        click event shouldn't fire when the target is ever removed in mouseup
        https://bugs.webkit.org/show_bug.cgi?id=60600

        Added tests to ensure WebKit does not fire click event when the target node
        is removed in mouseup event.

        * fast/events/remove-target-in-mouseup-deep-expected.txt: Added.
        * fast/events/remove-target-in-mouseup-deep.html: Added.
        * fast/events/remove-target-in-mouseup-expected.txt: Added.
        * fast/events/remove-target-in-mouseup-insertback-expected.txt: Added.
        * fast/events/remove-target-in-mouseup-insertback.html: Added.
        * fast/events/remove-target-in-mouseup-twice-expected.txt: Added.
        * fast/events/remove-target-in-mouseup-twice.html: Added.
        * fast/events/remove-target-in-mouseup.html: Added.
2011-05-13  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Darin Adler.

        click event shouldn't fire when the target is ever removed in mouseup
        https://bugs.webkit.org/show_bug.cgi?id=60600

        Fixed the bug by invalidating m_clickNode when it or one of its ancestors has been removed
        from the document. New behavior matches Internet Explorer and Firefox.

        Tests: fast/events/remove-target-in-mouseup-deep.html
               fast/events/remove-target-in-mouseup-insertback.html
               fast/events/remove-target-in-mouseup-twice.html
               fast/events/remove-target-in-mouseup.html

        * dom/Document.cpp:
        (WebCore::Document::nodeChildrenWillBeRemoved): Calls EventHandler::nodeWillBeRemoved.
        (WebCore::Document::nodeWillBeRemoved): Calls EventHandler::nodeWillBeRemoved.
        * page/EventHandler.cpp:
        (WebCore::EventHandler::nodeWillBeRemoved): Added; invalidates m_clickNode when m_clickNode
        or one of its ancestor is removed from the document.
        * page/EventHandler.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86461 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 05fdb04b
2011-05-13 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Darin Adler.
click event shouldn't fire when the target is ever removed in mouseup
https://bugs.webkit.org/show_bug.cgi?id=60600
Added tests to ensure WebKit does not fire click event when the target node
is removed in mouseup event.
* fast/events/remove-target-in-mouseup-deep-expected.txt: Added.
* fast/events/remove-target-in-mouseup-deep.html: Added.
* fast/events/remove-target-in-mouseup-expected.txt: Added.
* fast/events/remove-target-in-mouseup-insertback-expected.txt: Added.
* fast/events/remove-target-in-mouseup-insertback.html: Added.
* fast/events/remove-target-in-mouseup-twice-expected.txt: Added.
* fast/events/remove-target-in-mouseup-twice.html: Added.
* fast/events/remove-target-in-mouseup.html: Added.
2011-05-13 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
This test ensures WebKit does not fire click event on a node that has been removed in mouseup event.
PASS
<!DOCTYPE html>
<html>
<body>
<p>This test ensures WebKit does not fire click event on a node that has been removed in mouseup event.</p>
<div id="test"><b id="target"><em><span onmouseup="mouseup()" onclick="test.innerHTML = 'FAIL';">click here</span></em></b></div>
<script>
var test = document.getElementById('test');
var target = document.getElementById('target');
function mouseup() {
test.appendChild(document.createTextNode('PASS'));
test.removeChild(target);
test.appendChild(target);
test.removeChild(target);
}
if (window.layoutTestController) {
layoutTestController.dumpAsText();
if (!window.eventSender)
test.innerHTML = 'FAIL - this test requires eventSender';
else {
eventSender.mouseMoveTo(target.offsetLeft + target.offsetWidth / 2, target.offsetTop + target.offsetHeight / 2);
eventSender.mouseDown();
eventSender.leapForward(200);
eventSender.mouseUp();
}
}
</script>
</body>
</html>
This test ensures WebKit does not fire click event on a node that has been removed in mouseup event. To manually test, click a box below.
PASS
This test ensures WebKit does not fire click event on a node that has been removed and inserted back in mouseup event.
PASS
<!DOCTYPE html>
<html>
<body>
<p>This test ensures WebKit does not fire click event on a node that has been removed and inserted back in mouseup event.</p>
<div id="test"><span id="target" onmouseup="mouseup()" onclick="test.innerHTML = 'FAIL';">click here</span></div>
<script>
var test = document.getElementById('test');
var target = document.getElementById('target');
function mouseup() {
test.appendChild(document.createTextNode('PASS'));
test.removeChild(target);
test.appendChild(target);
}
if (window.layoutTestController) {
layoutTestController.dumpAsText();
if (!window.eventSender)
test.innerHTML = 'FAIL - this test requires eventSender';
else {
eventSender.mouseMoveTo(target.offsetLeft + target.offsetWidth / 2, target.offsetTop + target.offsetHeight / 2);
eventSender.mouseDown();
eventSender.leapForward(200);
eventSender.mouseUp();
test.removeChild(target);
}
}
</script>
</body>
</html>
This test ensures WebKit does not fire click event on a node that has been removed twice in mouseup event.
PASS
<!DOCTYPE html>
<html>
<body>
<p>This test ensures WebKit does not fire click event on a node that has been removed twice in mouseup event.</p>
<div id="test"><span id="target" onmouseup="mouseup()" onclick="test.innerHTML = 'FAIL';">click here</span></div>
<script>
var test = document.getElementById('test');
var target = document.getElementById('target');
function mouseup() {
test.appendChild(document.createTextNode('PASS'));
test.removeChild(target);
test.appendChild(target);
test.removeChild(target);
}
if (window.layoutTestController) {
layoutTestController.dumpAsText();
if (!window.eventSender)
test.innerHTML = 'FAIL - this test requires eventSender';
else {
eventSender.mouseMoveTo(target.offsetLeft + target.offsetWidth / 2, target.offsetTop + target.offsetHeight / 2);
eventSender.mouseDown();
eventSender.leapForward(200);
eventSender.mouseUp();
}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p>This test ensures WebKit does not fire click event on a node that has been removed in mouseup event.
To manually test, click a box below.</p>
<div id="test"><img src="" width="100" height="100" border="1" id="target" onmouseup="mouseup()" onclick="test.innerHTML = 'FAIL';"></div>
<script>
var test = document.getElementById('test');
var target = document.getElementById('target');
function mouseup() {
test.appendChild(document.createTextNode('PASS'));
target.parentNode.removeChild(target);
}
if (window.layoutTestController) {
layoutTestController.dumpAsText();
if (!window.eventSender)
test.innerHTML = 'FAIL - this test requires eventSender';
else {
eventSender.mouseMoveTo(target.offsetLeft + target.offsetWidth / 2, target.offsetTop + target.offsetHeight / 2);
eventSender.mouseDown();
eventSender.leapForward(200);
eventSender.mouseUp();
}
}
</script>
</body>
</html>
2011-05-13 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Darin Adler.
click event shouldn't fire when the target is ever removed in mouseup
https://bugs.webkit.org/show_bug.cgi?id=60600
Fixed the bug by invalidating m_clickNode when it or one of its ancestors has been removed
from the document. New behavior matches Internet Explorer and Firefox.
Tests: fast/events/remove-target-in-mouseup-deep.html
fast/events/remove-target-in-mouseup-insertback.html
fast/events/remove-target-in-mouseup-twice.html
fast/events/remove-target-in-mouseup.html
* dom/Document.cpp:
(WebCore::Document::nodeChildrenWillBeRemoved): Calls EventHandler::nodeWillBeRemoved.
(WebCore::Document::nodeWillBeRemoved): Calls EventHandler::nodeWillBeRemoved.
* page/EventHandler.cpp:
(WebCore::EventHandler::nodeWillBeRemoved): Added; invalidates m_clickNode when m_clickNode
or one of its ancestor is removed from the document.
* page/EventHandler.h:
2011-05-13 Alexey Proskuryakov <ap@apple.com>
Reviewed by Joseph Pecoraro.
......@@ -3399,6 +3399,7 @@ void Document::nodeChildrenWillBeRemoved(ContainerNode* container)
if (Frame* frame = this->frame()) {
for (Node* n = container->firstChild(); n; n = n->nextSibling()) {
frame->eventHandler()->nodeWillBeRemoved(n);
frame->selection()->nodeWillBeRemoved(n);
frame->page()->dragCaretController()->nodeWillBeRemoved(n);
}
......@@ -3418,6 +3419,7 @@ void Document::nodeWillBeRemoved(Node* n)
}
if (Frame* frame = this->frame()) {
frame->eventHandler()->nodeWillBeRemoved(n);
frame->selection()->nodeWillBeRemoved(n);
frame->page()->dragCaretController()->nodeWillBeRemoved(n);
}
......
......@@ -259,6 +259,12 @@ void EventHandler::clear()
#endif
}
void EventHandler::nodeWillBeRemoved(Node* nodeToBeRemoved)
{
if (nodeToBeRemoved->contains(m_clickNode.get()))
m_clickNode = 0;
}
static void setSelectionIfNeeded(FrameSelection* selection, const VisibleSelection& newSelection)
{
ASSERT(selection);
......
......@@ -98,6 +98,7 @@ public:
~EventHandler();
void clear();
void nodeWillBeRemoved(Node*);
#if ENABLE(DRAG_SUPPORT)
void updateSelectionForMouseDrag();
......
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