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

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

Issue 1932523003: Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-28T18:38:12 Created 4 years, 7 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 | « no previous file | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | 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 r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 5592 matching lines...) Expand 10 before | Expand all | Expand 10 after
5603 Node* ancestorNode(ancestor ? ancestor->node() : 0); 5603 Node* ancestorNode(ancestor ? ancestor->node() : 0);
5604 5604
5605 HeapVector<Member<Node>, 32> nodesToRemoveFromChain; 5605 HeapVector<Member<Node>, 32> nodesToRemoveFromChain;
5606 HeapVector<Member<Node>, 32> nodesToAddToChain; 5606 HeapVector<Member<Node>, 32> nodesToAddToChain;
5607 5607
5608 if (oldHoverObj != newHoverObj) { 5608 if (oldHoverObj != newHoverObj) {
5609 // If the old hovered node is not nil but it's layoutObject is, it was p robably detached as part of the :hover style 5609 // If the old hovered node is not nil but it's layoutObject is, it was p robably detached as part of the :hover style
5610 // (for instance by setting display:none in the :hover pseudo-class). In this case, the old hovered element (and its ancestors) 5610 // (for instance by setting display:none in the :hover pseudo-class). In this case, the old hovered element (and its ancestors)
5611 // must be updated, to ensure it's normal style is re-applied. 5611 // must be updated, to ensure it's normal style is re-applied.
5612 if (oldHoverNode && !oldHoverObj) { 5612 if (oldHoverNode && !oldHoverObj) {
5613 for (Node* node = oldHoverNode; node; node = node->parentNode()) { 5613 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*oldHoverNode) ) {
5614 if (!mustBeInActiveChain || (node->isElementNode() && toElement( node)->inActiveChain())) 5614 if (!mustBeInActiveChain || (node.isElementNode() && toElement(n ode).inActiveChain()))
5615 nodesToRemoveFromChain.append(node); 5615 nodesToRemoveFromChain.append(node);
5616 } 5616 }
5617 5617
5618 } 5618 }
5619 5619
5620 // The old hover path only needs to be cleared up to (and not including) the common ancestor; 5620 // The old hover path only needs to be cleared up to (and not including) the common ancestor;
5621 for (LayoutObject* curr = oldHoverObj; curr && curr != ancestor; curr = curr->hoverAncestor()) { 5621 for (LayoutObject* curr = oldHoverObj; curr && curr != ancestor; curr = curr->hoverAncestor()) {
5622 if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr ->node()->inActiveChain())) 5622 if (curr->node() && !curr->isText() && (!mustBeInActiveChain || curr ->node()->inActiveChain()))
5623 nodesToRemoveFromChain.append(curr->node()); 5623 nodesToRemoveFromChain.append(curr->node());
5624 } 5624 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
5974 #ifndef NDEBUG 5974 #ifndef NDEBUG
5975 using namespace blink; 5975 using namespace blink;
5976 void showLiveDocumentInstances() 5976 void showLiveDocumentInstances()
5977 { 5977 {
5978 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5978 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5979 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5979 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5980 for (Document* document : set) 5980 for (Document* document : set)
5981 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 5981 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
5982 } 5982 }
5983 #endif 5983 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698