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

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

Issue 2398293003: Move Layout Tree Construction code into Element::rebuildLayoutTree() (Closed)
Patch Set: Addressing bugsnash@ comments Created 4 years, 2 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) 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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 while (node->parentNode()) 383 while (node->parentNode())
384 node = node->parentNode(); 384 node = node->parentNode();
385 return const_cast<Node&>(*node); 385 return const_cast<Node&>(*node);
386 } 386 }
387 387
388 Node* Node::getRootNode(const GetRootNodeOptions& options) const { 388 Node* Node::getRootNode(const GetRootNodeOptions& options) const {
389 return (options.hasComposed() && options.composed()) ? &shadowIncludingRoot() 389 return (options.hasComposed() && options.composed()) ? &shadowIncludingRoot()
390 : &treeRoot(); 390 : &treeRoot();
391 } 391 }
392 392
393 Text* Node::nextTextSibling() const {
394 for (Node* sibling = nextSibling();
395 sibling &&
396 !(sibling->isElementNode() && toElement(sibling)->layoutObject());
esprehn 2016/10/17 21:36:26 Run demorgans :) (!sibling->isElementNode() || !t
nainar 2016/10/18 00:04:41 Done.
397 sibling = sibling->nextSibling()) {
398 if (sibling->isTextNode()) {
399 return toText(sibling);
400 }
401 }
402 return nullptr;
403 }
404
393 Node* Node::insertBefore(Node* newChild, 405 Node* Node::insertBefore(Node* newChild,
394 Node* refChild, 406 Node* refChild,
395 ExceptionState& exceptionState) { 407 ExceptionState& exceptionState) {
396 if (isContainerNode()) 408 if (isContainerNode())
397 return toContainerNode(this)->insertBefore(newChild, refChild, 409 return toContainerNode(this)->insertBefore(newChild, refChild,
398 exceptionState); 410 exceptionState);
399 411
400 exceptionState.throwDOMException( 412 exceptionState.throwDOMException(
401 HierarchyRequestError, "This node type does not support this method."); 413 HierarchyRequestError, "This node type does not support this method.");
402 return nullptr; 414 return nullptr;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType; 702 m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType;
691 } 703 }
692 704
693 void Node::markAncestorsWithChildNeedsStyleRecalc() { 705 void Node::markAncestorsWithChildNeedsStyleRecalc() {
694 for (ContainerNode* p = parentOrShadowHostNode(); 706 for (ContainerNode* p = parentOrShadowHostNode();
695 p && !p->childNeedsStyleRecalc(); p = p->parentOrShadowHostNode()) 707 p && !p->childNeedsStyleRecalc(); p = p->parentOrShadowHostNode())
696 p->setChildNeedsStyleRecalc(); 708 p->setChildNeedsStyleRecalc();
697 document().scheduleLayoutTreeUpdateIfNeeded(); 709 document().scheduleLayoutTreeUpdateIfNeeded();
698 } 710 }
699 711
712 void Node::markAncestorsWithChildNeedsReattachLayoutTree() {
713 for (ContainerNode* p = parentOrShadowHostNode();
714 p && !p->childNeedsReattachLayoutTree(); p = p->parentOrShadowHostNode())
715 p->setChildNeedsReattachLayoutTree();
716 }
717
718 void Node::setNeedsReattachLayoutTree() {
719 setFlag(NeedsReattachLayoutTree);
720 markAncestorsWithChildNeedsReattachLayoutTree();
721 }
722
700 void Node::setNeedsStyleRecalc(StyleChangeType changeType, 723 void Node::setNeedsStyleRecalc(StyleChangeType changeType,
701 const StyleChangeReasonForTracing& reason) { 724 const StyleChangeReasonForTracing& reason) {
702 DCHECK(changeType != NoStyleChange); 725 DCHECK(changeType != NoStyleChange);
703 if (!inActiveDocument()) 726 if (!inActiveDocument())
704 return; 727 return;
705 728
706 TRACE_EVENT_INSTANT1( 729 TRACE_EVENT_INSTANT1(
707 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), 730 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"),
708 "StyleRecalcInvalidationTracking", TRACE_EVENT_SCOPE_THREAD, "data", 731 "StyleRecalcInvalidationTracking", TRACE_EVENT_SCOPE_THREAD, "data",
709 InspectorStyleRecalcInvalidationTrackingEvent::data(this, reason)); 732 InspectorStyleRecalcInvalidationTrackingEvent::data(this, reason));
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 904
882 void Node::attachLayoutTree(const AttachContext&) { 905 void Node::attachLayoutTree(const AttachContext&) {
883 DCHECK(document().inStyleRecalc() || isDocumentNode()); 906 DCHECK(document().inStyleRecalc() || isDocumentNode());
884 DCHECK(!document().lifecycle().inDetach()); 907 DCHECK(!document().lifecycle().inDetach());
885 DCHECK(needsAttach()); 908 DCHECK(needsAttach());
886 DCHECK(!layoutObject() || 909 DCHECK(!layoutObject() ||
887 (layoutObject()->style() && 910 (layoutObject()->style() &&
888 (layoutObject()->parent() || layoutObject()->isLayoutView()))); 911 (layoutObject()->parent() || layoutObject()->isLayoutView())));
889 912
890 clearNeedsStyleRecalc(); 913 clearNeedsStyleRecalc();
914 clearNeedsReattachLayoutTree();
891 915
892 if (AXObjectCache* cache = document().axObjectCache()) 916 if (AXObjectCache* cache = document().axObjectCache())
893 cache->updateCacheAfterNodeIsAttached(this); 917 cache->updateCacheAfterNodeIsAttached(this);
894 } 918 }
895 919
896 void Node::detachLayoutTree(const AttachContext& context) { 920 void Node::detachLayoutTree(const AttachContext& context) {
897 DCHECK(document().lifecycle().stateAllowsDetach()); 921 DCHECK(document().lifecycle().stateAllowsDetach());
898 DocumentLifecycle::DetachScope willDetach(document().lifecycle()); 922 DocumentLifecycle::DetachScope willDetach(document().lifecycle());
899 923
900 if (layoutObject()) 924 if (layoutObject())
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 if (node) { 2491 if (node) {
2468 std::stringstream stream; 2492 std::stringstream stream;
2469 node->printNodePathTo(stream); 2493 node->printNodePathTo(stream);
2470 LOG(INFO) << stream.str(); 2494 LOG(INFO) << stream.str();
2471 } else { 2495 } else {
2472 LOG(INFO) << "Cannot showNodePath for <null>"; 2496 LOG(INFO) << "Cannot showNodePath for <null>";
2473 } 2497 }
2474 } 2498 }
2475 2499
2476 #endif 2500 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698