RESOLVED FIXED 120862
MouseEnter and MouseLeave may be emitted on Document nodes
https://bugs.webkit.org/show_bug.cgi?id=120862
Summary MouseEnter and MouseLeave may be emitted on Document nodes
Allan Sandfeld Jensen
Reported 2013-09-06 08:59:53 PDT
Only Elements can be targets of mouse-events, which means emitting mouseenter or mouseleave on a document node is a mistake. This bug was noticed when cleaning up the overgeneric use of Nodes and replacing them with Elements in Document::updateHoverActiveState.
Attachments
Patch (9.39 KB, patch)
2013-09-06 09:04 PDT, Allan Sandfeld Jensen
no flags
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2 (452.49 KB, application/zip)
2013-09-07 02:26 PDT, Build Bot
no flags
Archive of layout-test-results from webkit-ews-03 for mac-mountainlion (531.64 KB, application/zip)
2013-09-07 05:52 PDT, Build Bot
no flags
Patch (9.53 KB, patch)
2013-09-09 02:43 PDT, Allan Sandfeld Jensen
no flags
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion (504.68 KB, application/zip)
2013-09-09 03:48 PDT, Build Bot
no flags
Patch (6.64 KB, patch)
2013-09-09 05:54 PDT, Allan Sandfeld Jensen
no flags
Patch (8.27 KB, patch)
2013-09-09 07:03 PDT, Allan Sandfeld Jensen
tonikitoo: review+
Allan Sandfeld Jensen
Comment 1 2013-09-06 09:04:42 PDT
Andreas Kling
Comment 2 2013-09-06 09:50:48 PDT
This patch looks cool, though the new test seems to be failing on EWS. Any idea what's up with that?
Allan Sandfeld Jensen
Comment 3 2013-09-06 10:14:37 PDT
(In reply to comment #2) > This patch looks cool, though the new test seems to be failing on EWS. Any idea what's up with that? I will take a look, but it does assume the mouse pointer starts outside the document before the test and can be moved off it again by moving it to -10,-10.
Darin Adler
Comment 4 2013-09-06 13:57:22 PDT
Comment on attachment 210761 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=210761&action=review > Source/WebCore/dom/Document.cpp:5868 > for (Node* node = oldHoveredElement.get(); node; node = node->parentNode()) { > - if (!mustBeInActiveChain || (node->isElementNode() && toElement(node)->inActiveChain())) > - nodesToRemoveFromChain.append(node); > + if (!node->isElementNode()) > + continue; > + Element* element = toElement(node); > + if (!mustBeInActiveChain || element->inActiveChain()) > + elementsToRemoveFromChain.append(element); > } Should just write: for (Element* element = oldHoveredElement.get(); element; element = element->parentElement()) { That would eliminate three lines of code below. Also, mustBeInActiveChain should be checked outside the loop, not inside it. > Source/WebCore/dom/Document.cpp:5878 > for (RenderObject* curr = oldHoverObj; curr && curr != ancestor; curr = curr->hoverAncestor()) { > - if (!curr->node() || curr->isText()) > + if (!curr->node() || !curr->node()->isElementNode()) > continue; > - if (!mustBeInActiveChain || (curr->node()->isElementNode() && toElement(curr->node())->inActiveChain())) > - nodesToRemoveFromChain.append(curr->node()); > + Element* element = toElement(curr->node()); > + if (!mustBeInActiveChain || element->inActiveChain()) > + elementsToRemoveFromChain.append(element); > } !mustBeInActiveChain should be checked outside the loop > Source/WebCore/dom/Document.cpp:5893 > for (RenderObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) { > - if (!curr->node() || curr->isText()) > + if (!curr->node() || !curr->node()->isElementNode()) > continue; > - if (!mustBeInActiveChain || (curr->node()->isElementNode() && toElement(curr->node())->inActiveChain())) > - nodesToAddToChain.append(curr->node()); > + Element* element = toElement(curr->node()); > + if (!mustBeInActiveChain || element->inActiveChain()) > + elementsToAddToChain.append(element); > } !mustBeInActiveChain should be checked outside the loop > Source/WebCore/dom/Document.cpp:5896 > - size_t removeCount = nodesToRemoveFromChain.size(); > + size_t removeCount = elementsToRemoveFromChain.size(); > for (size_t i = 0; i < removeCount; ++i) { Our modern style for this is: for (size_t i = 0, size = elementsToRemoveFromChain.size(); i < size; ++i) { Please consider using that style.
Build Bot
Comment 5 2013-09-07 02:26:56 PDT
Comment on attachment 210761 [details] Patch Attachment 210761 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/1709623 New failing tests: fast/events/mouseenterleave-on-document.html
Build Bot
Comment 6 2013-09-07 02:26:58 PDT
Created attachment 210900 [details] Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: webkit-ews-09 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.4
Build Bot
Comment 7 2013-09-07 05:52:14 PDT
Comment on attachment 210761 [details] Patch Attachment 210761 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/1704707 New failing tests: fast/events/mouseenterleave-on-document.html
Build Bot
Comment 8 2013-09-07 05:52:17 PDT
Created attachment 210901 [details] Archive of layout-test-results from webkit-ews-03 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: webkit-ews-03 Port: mac-mountainlion Platform: Mac OS X 10.8.4
Allan Sandfeld Jensen
Comment 9 2013-09-09 02:33:17 PDT
(In reply to comment #3) > (In reply to comment #2) > > This patch looks cool, though the new test seems to be failing on EWS. Any idea what's up with that? > > I will take a look, but it does assume the mouse pointer starts outside the document before the test and can be moved off it again by moving it to -10,-10. Yes, it is leaving the document that appears to be problematic
Allan Sandfeld Jensen
Comment 10 2013-09-09 02:37:42 PDT
(In reply to comment #4) > Also, mustBeInActiveChain should be checked outside the loop, not inside it. > I am not sure I understand that part. mustBeInActiveChain is checked as part of an else statement, if I moved it outside the loop I would need two different loops to choose from.
Allan Sandfeld Jensen
Comment 11 2013-09-09 02:43:06 PDT
Created attachment 211021 [details] Patch Cleanup suggested by darin, and the test now moves the mouse out of the document in positive coordinates
Build Bot
Comment 12 2013-09-09 03:48:22 PDT
Comment on attachment 211021 [details] Patch Attachment 211021 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/1726533 New failing tests: fast/events/mouseenterleave-on-document.html
Build Bot
Comment 13 2013-09-09 03:48:24 PDT
Created attachment 211026 [details] Archive of layout-test-results from webkit-ews-04 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: webkit-ews-04 Port: mac-mountainlion Platform: Mac OS X 10.8.4
Allan Sandfeld Jensen
Comment 14 2013-09-09 04:45:02 PDT
(In reply to comment #12) > (From update of attachment 211021 [details]) > Attachment 211021 [details] did not pass mac-ews (mac): > Output: http://webkit-queues.appspot.com/results/1726533 > > New failing tests: > fast/events/mouseenterleave-on-document.html It seems moving the mouse out of the webview doesn't work on the mac test bots. If the test I uploaded to bug 121026 works on Mac though, that should be able to test this bug as well.
Antonio Gomes
Comment 15 2013-09-09 05:23:27 PDT
Comment on attachment 211021 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=211021&action=review > Source/WebCore/ChangeLog:9 > + This cleans up the code and fixes a hidden bug. You should mention why the change, and what the hidden bug is.
Allan Sandfeld Jensen
Comment 16 2013-09-09 05:39:19 PDT
(In reply to comment #15) > (From update of attachment 211021 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=211021&action=review > > > Source/WebCore/ChangeLog:9 > > + This cleans up the code and fixes a hidden bug. > > You should mention why the change, and what the hidden bug is. Right. The hidden bug is then one mentioned in the title, but yes it is not really clear.
Allan Sandfeld Jensen
Comment 17 2013-09-09 05:54:47 PDT
Antonio Gomes
Comment 18 2013-09-09 05:57:49 PDT
Comment on attachment 211032 [details] Patch Looks good. Can we test that with iframe documents?
Allan Sandfeld Jensen
Comment 19 2013-09-09 06:13:25 PDT
(In reply to comment #18) > (From update of attachment 211032 [details]) > Looks good. Can we test that with iframe documents? I assume so. I am waiting for the output from EWS on the patch in bug 121026, but it should be exactly this bug it demonstrates since the test also depends on this fix.
Allan Sandfeld Jensen
Comment 20 2013-09-09 07:03:55 PDT
Allan Sandfeld Jensen
Comment 21 2013-09-09 07:38:46 PDT
Note You need to log in before you can comment on or make changes to this bug.