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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2790133002: Allow display:contents elements in hover chain. (Closed)
Patch Set: Fixed nits. 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/ContainerNode.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 3929 matching lines...) Expand 10 before | Expand all | Expand 10 after
3940 3940
3941 // We can't be focused if we're not in the document. 3941 // We can't be focused if we're not in the document.
3942 if (!node->isConnected()) 3942 if (!node->isConnected())
3943 return; 3943 return;
3944 bool contains = 3944 bool contains =
3945 node->isShadowIncludingInclusiveAncestorOf(m_focusedElement.get()); 3945 node->isShadowIncludingInclusiveAncestorOf(m_focusedElement.get());
3946 if (contains && (m_focusedElement != node || !amongChildrenOnly)) 3946 if (contains && (m_focusedElement != node || !amongChildrenOnly))
3947 clearFocusedElement(); 3947 clearFocusedElement();
3948 } 3948 }
3949 3949
3950 static Node* skipDisplayNoneAncestors(Node* node) {
3951 while (node) {
3952 if (node->layoutObject())
3953 return node;
3954 if (node->isElementNode() && toElement(node)->hasDisplayContentsStyle())
3955 return node;
3956 node = FlatTreeTraversal::parent(*node);
3957 }
3958 return nullptr;
3959 }
3960
3950 void Document::hoveredNodeDetached(Element& element) { 3961 void Document::hoveredNodeDetached(Element& element) {
3951 if (!m_hoverNode) 3962 if (!m_hoverNode)
3952 return; 3963 return;
3953 3964
3954 m_hoverNode->updateDistribution(); 3965 m_hoverNode->updateDistribution();
3955 if (element != m_hoverNode && 3966 if (element != m_hoverNode &&
3956 (!m_hoverNode->isTextNode() || 3967 (!m_hoverNode->isTextNode() ||
3957 element != FlatTreeTraversal::parent(*m_hoverNode))) 3968 element != FlatTreeTraversal::parent(*m_hoverNode)))
3958 return; 3969 return;
3959 3970
3960 m_hoverNode = FlatTreeTraversal::parent(element); 3971 m_hoverNode = skipDisplayNoneAncestors(&element);
3961 while (m_hoverNode && !m_hoverNode->layoutObject())
3962 m_hoverNode = FlatTreeTraversal::parent(*m_hoverNode);
3963 3972
3964 // If the mouse cursor is not visible, do not clear existing 3973 // If the mouse cursor is not visible, do not clear existing
3965 // hover effects on the ancestors of |element| and do not invoke 3974 // hover effects on the ancestors of |element| and do not invoke
3966 // new hover effects on any other element. 3975 // new hover effects on any other element.
3967 if (!page()->isCursorVisible()) 3976 if (!page()->isCursorVisible())
3968 return; 3977 return;
3969 3978
3970 if (frame()) 3979 if (frame())
3971 frame()->eventHandler().scheduleHoverStateUpdate(); 3980 frame()->eventHandler().scheduleHoverStateUpdate();
3972 } 3981 }
3973 3982
3974 void Document::activeChainNodeDetached(Element& element) { 3983 void Document::activeChainNodeDetached(Element& element) {
3975 if (!m_activeHoverElement) 3984 if (!m_activeHoverElement)
3976 return; 3985 return;
3977 3986
3978 if (element != m_activeHoverElement) 3987 if (element != m_activeHoverElement)
3979 return; 3988 return;
3980 3989
3981 Node* activeNode = FlatTreeTraversal::parent(element); 3990 Node* activeNode = skipDisplayNoneAncestors(&element);
3982 while (activeNode && activeNode->isElementNode() &&
3983 !activeNode->layoutObject())
3984 activeNode = FlatTreeTraversal::parent(*activeNode);
3985
3986 m_activeHoverElement = activeNode && activeNode->isElementNode() 3991 m_activeHoverElement = activeNode && activeNode->isElementNode()
3987 ? toElement(activeNode) 3992 ? toElement(activeNode)
3988 : nullptr; 3993 : nullptr;
3989 } 3994 }
3990 3995
3991 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const { 3996 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const {
3992 return m_annotatedRegions; 3997 return m_annotatedRegions;
3993 } 3998 }
3994 3999
3995 void Document::setAnnotatedRegions( 4000 void Document::setAnnotatedRegions(
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after
6203 // only those) nodes should remain :active until the mouse is released. 6208 // only those) nodes should remain :active until the mouse is released.
6204 bool allowActiveChanges = !oldActiveElement && activeHoverElement(); 6209 bool allowActiveChanges = !oldActiveElement && activeHoverElement();
6205 6210
6206 // If the mouse is down and if this is a mouse move event, we want to restrict 6211 // If the mouse is down and if this is a mouse move event, we want to restrict
6207 // changes in :hover/:active to only apply to elements that are in the :active 6212 // changes in :hover/:active to only apply to elements that are in the :active
6208 // chain that we froze at the time the mouse went down. 6213 // chain that we froze at the time the mouse went down.
6209 bool mustBeInActiveChain = request.active() && request.move(); 6214 bool mustBeInActiveChain = request.active() && request.move();
6210 6215
6211 Node* oldHoverNode = hoverNode(); 6216 Node* oldHoverNode = hoverNode();
6212 6217
6213 // Check to see if the hovered node has changed. 6218 // The passed in innerElement may not be a result of a hit test for the
6214 // If it hasn't, we do not need to do anything. 6219 // current up-to-date flat/layout tree. That means the element may be
6215 Node* newHoverNode = innerElementInDocument; 6220 // display:none at this point. Skip up the ancestor chain until we reach an
6216 while (newHoverNode && !newHoverNode->layoutObject()) 6221 // element with a layoutObject or a display:contents element.
6217 newHoverNode = newHoverNode->parentOrShadowHostNode(); 6222 Node* newHoverNode = skipDisplayNoneAncestors(innerElementInDocument);
6218 6223
6219 // Update our current hover node. 6224 // Update our current hover node.
6220 setHoverNode(newHoverNode); 6225 setHoverNode(newHoverNode);
6221 6226
6222 Node* ancestor = 6227 Node* ancestor =
6223 (oldHoverNode && oldHoverNode->isConnected() && newHoverNode) 6228 (oldHoverNode && oldHoverNode->isConnected() && newHoverNode)
6224 ? FlatTreeTraversal::commonAncestor(*oldHoverNode, *newHoverNode) 6229 ? FlatTreeTraversal::commonAncestor(*oldHoverNode, *newHoverNode)
6225 : nullptr; 6230 : nullptr;
6226 6231
6227 HeapVector<Member<Node>, 32> nodesToRemoveFromChain; 6232 HeapVector<Member<Node>, 32> nodesToRemoveFromChain;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
6628 } 6633 }
6629 6634
6630 void showLiveDocumentInstances() { 6635 void showLiveDocumentInstances() {
6631 WeakDocumentSet& set = liveDocumentSet(); 6636 WeakDocumentSet& set = liveDocumentSet();
6632 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6637 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6633 for (blink::Document* document : set) 6638 for (blink::Document* document : set)
6634 fprintf(stderr, "- Document %p URL: %s\n", document, 6639 fprintf(stderr, "- Document %p URL: %s\n", document,
6635 document->url().getString().utf8().data()); 6640 document->url().getString().utf8().data());
6636 } 6641 }
6637 #endif 6642 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ContainerNode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698