Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2787943002: [WIP] Use the flat tree for hover handling.
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 // work that cleans the hover state. Because the hover state for the main 1466 // work that cleans the hover state. Because the hover state for the main
1467 // frame is updated by calling Document::updateHoverActiveState 1467 // frame is updated by calling Document::updateHoverActiveState
1468 while (newHoverFrameInDocument && newHoverFrameInDocument != m_frame) { 1468 while (newHoverFrameInDocument && newHoverFrameInDocument != m_frame) {
1469 newHoverFrameChain.push_back(newHoverFrameInDocument); 1469 newHoverFrameChain.push_back(newHoverFrameInDocument);
1470 Frame* parentFrame = newHoverFrameInDocument->tree().parent(); 1470 Frame* parentFrame = newHoverFrameInDocument->tree().parent();
1471 newHoverFrameInDocument = parentFrame && parentFrame->isLocalFrame() 1471 newHoverFrameInDocument = parentFrame && parentFrame->isLocalFrame()
1472 ? toLocalFrame(parentFrame) 1472 ? toLocalFrame(parentFrame)
1473 : nullptr; 1473 : nullptr;
1474 } 1474 }
1475 1475
1476 Node* oldHoverNodeInCurDoc = m_frame->document()->hoverNode(); 1476 Node* oldHoverNodeInCurDoc = m_frame->document()->hoverElement();
1477 Node* newInnermostHoverNode = innerElement; 1477 Node* newInnermostHoverNode = innerElement;
1478 1478
1479 if (newInnermostHoverNode != oldHoverNodeInCurDoc) { 1479 if (newInnermostHoverNode != oldHoverNodeInCurDoc) {
1480 size_t indexFrameChain = newHoverFrameChain.size(); 1480 size_t indexFrameChain = newHoverFrameChain.size();
1481 1481
1482 // Clear the hover state on any frames which are no longer in the frame 1482 // Clear the hover state on any frames which are no longer in the frame
1483 // chain of the hovered element. 1483 // chain of the hovered element.
1484 while (oldHoverNodeInCurDoc && 1484 while (oldHoverNodeInCurDoc &&
1485 oldHoverNodeInCurDoc->isFrameOwnerElement()) { 1485 oldHoverNodeInCurDoc->isFrameOwnerElement()) {
1486 LocalFrame* newHoverFrame = nullptr; 1486 LocalFrame* newHoverFrame = nullptr;
1487 // If we can't get the frame from the new hover frame chain, 1487 // If we can't get the frame from the new hover frame chain,
1488 // the newHoverFrame will be null and the old hover state will be cleared. 1488 // the newHoverFrame will be null and the old hover state will be cleared.
1489 if (indexFrameChain > 0) 1489 if (indexFrameChain > 0)
1490 newHoverFrame = newHoverFrameChain[--indexFrameChain]; 1490 newHoverFrame = newHoverFrameChain[--indexFrameChain];
1491 1491
1492 HTMLFrameOwnerElement* owner = 1492 HTMLFrameOwnerElement* owner =
1493 toHTMLFrameOwnerElement(oldHoverNodeInCurDoc); 1493 toHTMLFrameOwnerElement(oldHoverNodeInCurDoc);
1494 if (!owner->contentFrame() || !owner->contentFrame()->isLocalFrame()) 1494 if (!owner->contentFrame() || !owner->contentFrame()->isLocalFrame())
1495 break; 1495 break;
1496 1496
1497 LocalFrame* oldHoverFrame = toLocalFrame(owner->contentFrame()); 1497 LocalFrame* oldHoverFrame = toLocalFrame(owner->contentFrame());
1498 Document* doc = oldHoverFrame->document(); 1498 Document* doc = oldHoverFrame->document();
1499 if (!doc) 1499 if (!doc)
1500 break; 1500 break;
1501 1501
1502 oldHoverNodeInCurDoc = doc->hoverNode(); 1502 oldHoverNodeInCurDoc = doc->hoverElement();
1503 // If the old hovered frame is different from the new hovered frame. 1503 // If the old hovered frame is different from the new hovered frame.
1504 // we should clear the old hovered node from the old hovered frame. 1504 // we should clear the old hovered node from the old hovered frame.
1505 if (newHoverFrame != oldHoverFrame) 1505 if (newHoverFrame != oldHoverFrame)
1506 doc->updateHoverActiveState(request, nullptr, nullptr); 1506 doc->updateHoverActiveState(request, nullptr, nullptr);
1507 } 1507 }
1508 } 1508 }
1509 1509
1510 // Recursively set the new active/hover states on every frame in the chain of 1510 // Recursively set the new active/hover states on every frame in the chain of
1511 // innerElement. 1511 // innerElement.
1512 m_frame->document()->updateHoverActiveState(request, innerElement, nullptr); 1512 m_frame->document()->updateHoverActiveState(request, innerElement, nullptr);
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 MouseEventWithHitTestResults& mev, 2086 MouseEventWithHitTestResults& mev,
2087 LocalFrame* subframe) { 2087 LocalFrame* subframe) {
2088 WebInputEventResult result = 2088 WebInputEventResult result =
2089 subframe->eventHandler().handleMouseReleaseEvent(mev.event()); 2089 subframe->eventHandler().handleMouseReleaseEvent(mev.event());
2090 if (result != WebInputEventResult::NotHandled) 2090 if (result != WebInputEventResult::NotHandled)
2091 return result; 2091 return result;
2092 return WebInputEventResult::HandledSystem; 2092 return WebInputEventResult::HandledSystem;
2093 } 2093 }
2094 2094
2095 } // namespace blink 2095 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698