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

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

Issue 1071863002: Prefer ComposedTreeTraversal to NodeRenderingTraversal. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/dom/Node.cpp » ('j') | Source/core/dom/Node.cpp » ('J')
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 #include "core/dom/SelectorQuery.h" 94 #include "core/dom/SelectorQuery.h"
95 #include "core/dom/StaticNodeList.h" 95 #include "core/dom/StaticNodeList.h"
96 #include "core/dom/StyleEngine.h" 96 #include "core/dom/StyleEngine.h"
97 #include "core/dom/TouchList.h" 97 #include "core/dom/TouchList.h"
98 #include "core/dom/TransformSource.h" 98 #include "core/dom/TransformSource.h"
99 #include "core/dom/TreeWalker.h" 99 #include "core/dom/TreeWalker.h"
100 #include "core/dom/VisitedLinkState.h" 100 #include "core/dom/VisitedLinkState.h"
101 #include "core/dom/XMLDocument.h" 101 #include "core/dom/XMLDocument.h"
102 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" 102 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h"
103 #include "core/dom/custom/CustomElementRegistrationContext.h" 103 #include "core/dom/custom/CustomElementRegistrationContext.h"
104 #include "core/dom/shadow/ComposedTreeTraversal.h"
104 #include "core/dom/shadow/ElementShadow.h" 105 #include "core/dom/shadow/ElementShadow.h"
105 #include "core/dom/shadow/ShadowRoot.h" 106 #include "core/dom/shadow/ShadowRoot.h"
106 #include "core/editing/Editor.h" 107 #include "core/editing/Editor.h"
107 #include "core/editing/FrameSelection.h" 108 #include "core/editing/FrameSelection.h"
108 #include "core/editing/SpellChecker.h" 109 #include "core/editing/SpellChecker.h"
109 #include "core/editing/markup.h" 110 #include "core/editing/markup.h"
110 #include "core/events/BeforeUnloadEvent.h" 111 #include "core/events/BeforeUnloadEvent.h"
111 #include "core/events/Event.h" 112 #include "core/events/Event.h"
112 #include "core/events/EventFactory.h" 113 #include "core/events/EventFactory.h"
113 #include "core/events/EventListener.h" 114 #include "core/events/EventListener.h"
(...skipping 3229 matching lines...) Expand 10 before | Expand all | Expand 10 after
3343 setFocusedElement(nullptr); 3344 setFocusedElement(nullptr);
3344 } 3345 }
3345 3346
3346 void Document::hoveredNodeDetached(Node* node) 3347 void Document::hoveredNodeDetached(Node* node)
3347 { 3348 {
3348 ASSERT(node); 3349 ASSERT(node);
3349 if (!m_hoverNode) 3350 if (!m_hoverNode)
3350 return; 3351 return;
3351 3352
3352 m_hoverNode->updateDistribution(); 3353 m_hoverNode->updateDistribution();
3353 if (node != m_hoverNode && (!m_hoverNode->isTextNode() || node != NodeRender ingTraversal::parent(*m_hoverNode))) 3354 if (node != m_hoverNode && (!m_hoverNode->isTextNode() || node != ComposedTr eeTraversal::parent(*m_hoverNode)))
3354 return; 3355 return;
3355 3356
3356 m_hoverNode = NodeRenderingTraversal::parent(*node); 3357 m_hoverNode = ComposedTreeTraversal::parent(*node);
3357 while (m_hoverNode && !m_hoverNode->layoutObject()) 3358 while (m_hoverNode && !m_hoverNode->layoutObject())
3358 m_hoverNode = NodeRenderingTraversal::parent(*m_hoverNode); 3359 m_hoverNode = ComposedTreeTraversal::parent(*m_hoverNode);
3359 3360
3360 // If the mouse cursor is not visible, do not clear existing 3361 // If the mouse cursor is not visible, do not clear existing
3361 // hover effects on the ancestors of |node| and do not invoke 3362 // hover effects on the ancestors of |node| and do not invoke
3362 // new hover effects on any other element. 3363 // new hover effects on any other element.
3363 if (!page()->isCursorVisible()) 3364 if (!page()->isCursorVisible())
3364 return; 3365 return;
3365 3366
3366 if (frame()) 3367 if (frame())
3367 frame()->eventHandler().scheduleHoverStateUpdate(); 3368 frame()->eventHandler().scheduleHoverStateUpdate();
3368 } 3369 }
3369 3370
3370 void Document::activeChainNodeDetached(Node* node) 3371 void Document::activeChainNodeDetached(Node* node)
3371 { 3372 {
3372 if (!m_activeHoverElement) 3373 if (!m_activeHoverElement)
3373 return; 3374 return;
3374 3375
3375 if (node != m_activeHoverElement) 3376 if (node != m_activeHoverElement)
3376 return; 3377 return;
3377 3378
3378 Node* activeNode = NodeRenderingTraversal::parent(*node); 3379 Node* activeNode = ComposedTreeTraversal::parent(*node);
3379 while (activeNode && activeNode->isElementNode() && !activeNode->layoutObjec t()) 3380 while (activeNode && activeNode->isElementNode() && !activeNode->layoutObjec t())
3380 activeNode = NodeRenderingTraversal::parent(*activeNode); 3381 activeNode = ComposedTreeTraversal::parent(*activeNode);
3381 3382
3382 m_activeHoverElement = activeNode && activeNode->isElementNode() ? toElement (activeNode) : 0; 3383 m_activeHoverElement = activeNode && activeNode->isElementNode() ? toElement (activeNode) : 0;
3383 } 3384 }
3384 3385
3385 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const 3386 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const
3386 { 3387 {
3387 return m_annotatedRegions; 3388 return m_annotatedRegions;
3388 } 3389 }
3389 3390
3390 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions) 3391 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions)
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
5221 Element* innerElementInDocument = innerElement; 5222 Element* innerElementInDocument = innerElement;
5222 while (innerElementInDocument && innerElementInDocument->document() != this) { 5223 while (innerElementInDocument && innerElementInDocument->document() != this) {
5223 innerElementInDocument->document().updateHoverActiveState(request, inner ElementInDocument); 5224 innerElementInDocument->document().updateHoverActiveState(request, inner ElementInDocument);
5224 innerElementInDocument = innerElementInDocument->document().ownerElement (); 5225 innerElementInDocument = innerElementInDocument->document().ownerElement ();
5225 } 5226 }
5226 5227
5227 Element* oldActiveElement = activeHoverElement(); 5228 Element* oldActiveElement = activeHoverElement();
5228 if (oldActiveElement && !request.active()) { 5229 if (oldActiveElement && !request.active()) {
5229 // The oldActiveElement renderer is null, dropped on :active by setting display: none, 5230 // The oldActiveElement renderer is null, dropped on :active by setting display: none,
5230 // for instance. We still need to clear the ActiveChain as the mouse is released. 5231 // for instance. We still need to clear the ActiveChain as the mouse is released.
5231 for (Node* node = oldActiveElement; node; node = NodeRenderingTraversal: :parent(*node)) { 5232 for (Node* node = oldActiveElement; node; node = ComposedTreeTraversal:: parent(*node)) {
5232 ASSERT(!node->isTextNode()); 5233 ASSERT(!node->isTextNode());
5233 node->setActive(false); 5234 node->setActive(false);
5234 m_userActionElements.setInActiveChain(node, false); 5235 m_userActionElements.setInActiveChain(node, false);
5235 } 5236 }
5236 setActiveHoverElement(nullptr); 5237 setActiveHoverElement(nullptr);
5237 } else { 5238 } else {
5238 Element* newActiveElement = innerElementInDocument; 5239 Element* newActiveElement = innerElementInDocument;
5239 if (!oldActiveElement && newActiveElement && !newActiveElement->isDisabl edFormControl() && request.active() && !request.touchMove()) { 5240 if (!oldActiveElement && newActiveElement && !newActiveElement->isDisabl edFormControl() && request.active() && !request.touchMove()) {
5240 // We are setting the :active chain and freezing it. If future moves happen, they 5241 // We are setting the :active chain and freezing it. If future moves happen, they
5241 // will need to reference this chain. 5242 // will need to reference this chain.
5242 for (Node* node = newActiveElement; node; node = NodeRenderingTraver sal::parent(*node)) { 5243 for (Node* node = newActiveElement; node; node = ComposedTreeTravers al::parent(*node)) {
5243 ASSERT(!node->isTextNode()); 5244 ASSERT(!node->isTextNode());
5244 m_userActionElements.setInActiveChain(node, true); 5245 m_userActionElements.setInActiveChain(node, true);
5245 } 5246 }
5246 setActiveHoverElement(newActiveElement); 5247 setActiveHoverElement(newActiveElement);
5247 } 5248 }
5248 } 5249 }
5249 // If the mouse has just been pressed, set :active on the chain. Those (and only those) 5250 // If the mouse has just been pressed, set :active on the chain. Those (and only those)
5250 // nodes should remain :active until the mouse is released. 5251 // nodes should remain :active until the mouse is released.
5251 bool allowActiveChanges = !oldActiveElement && activeHoverElement(); 5252 bool allowActiveChanges = !oldActiveElement && activeHoverElement();
5252 5253
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
5700 #ifndef NDEBUG 5701 #ifndef NDEBUG
5701 using namespace blink; 5702 using namespace blink;
5702 void showLiveDocumentInstances() 5703 void showLiveDocumentInstances()
5703 { 5704 {
5704 WeakDocumentSet& set = liveDocumentSet(); 5705 WeakDocumentSet& set = liveDocumentSet();
5705 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5706 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5706 for (Document* document : set) 5707 for (Document* document : set)
5707 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5708 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5708 } 5709 }
5709 #endif 5710 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Node.cpp » ('j') | Source/core/dom/Node.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698