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

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

Issue 2149893003: Rename Node::inShadowIncludingDocument() to Node::isConnected() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Created 4 years, 5 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/Node.h ('k') | third_party/WebKit/Source/core/dom/Node.idl » ('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 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 if (!node->isElementNode()) 614 if (!node->isElementNode())
615 return nullptr; 615 return nullptr;
616 if (ElementShadow* shadow = toElement(node)->shadow()) 616 if (ElementShadow* shadow = toElement(node)->shadow())
617 return shadow->oldestShadowRoot(); 617 return shadow->oldestShadowRoot();
618 return nullptr; 618 return nullptr;
619 } 619 }
620 #endif 620 #endif
621 621
622 Node& Node::shadowIncludingRoot() const 622 Node& Node::shadowIncludingRoot() const
623 { 623 {
624 if (inShadowIncludingDocument()) 624 if (isConnected())
625 return document(); 625 return document();
626 Node* root = const_cast<Node*>(this); 626 Node* root = const_cast<Node*>(this);
627 while (Node* host = root->shadowHost()) 627 while (Node* host = root->shadowHost())
628 root = host; 628 root = host;
629 while (Node* ancestor = root->parentNode()) 629 while (Node* ancestor = root->parentNode())
630 root = ancestor; 630 root = ancestor;
631 DCHECK(!root->shadowHost()); 631 DCHECK(!root->shadowHost());
632 return *root; 632 return *root;
633 } 633 }
634 634
(...skipping 17 matching lines...) Expand all
652 } 652 }
653 653
654 bool Node::needsDistributionRecalc() const 654 bool Node::needsDistributionRecalc() const
655 { 655 {
656 return shadowIncludingRoot().childNeedsDistributionRecalc(); 656 return shadowIncludingRoot().childNeedsDistributionRecalc();
657 } 657 }
658 658
659 void Node::updateDistribution() 659 void Node::updateDistribution()
660 { 660 {
661 // Extra early out to avoid spamming traces. 661 // Extra early out to avoid spamming traces.
662 if (inShadowIncludingDocument() && !document().childNeedsDistributionRecalc( )) 662 if (isConnected() && !document().childNeedsDistributionRecalc())
663 return; 663 return;
664 TRACE_EVENT0("blink", "Node::updateDistribution"); 664 TRACE_EVENT0("blink", "Node::updateDistribution");
665 ScriptForbiddenScope forbidScript; 665 ScriptForbiddenScope forbidScript;
666 Node& root = shadowIncludingRoot(); 666 Node& root = shadowIncludingRoot();
667 if (root.childNeedsDistributionRecalc()) 667 if (root.childNeedsDistributionRecalc())
668 root.recalcDistribution(); 668 root.recalcDistribution();
669 } 669 }
670 670
671 void Node::recalcDistribution() 671 void Node::recalcDistribution()
672 { 672 {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 m_nodeFlags &= ~StyleChangeMask; 760 m_nodeFlags &= ~StyleChangeMask;
761 761
762 clearSVGFilterNeedsLayerUpdate(); 762 clearSVGFilterNeedsLayerUpdate();
763 763
764 if (isElementNode() && hasRareData()) 764 if (isElementNode() && hasRareData())
765 toElement(*this).setAnimationStyleChange(false); 765 toElement(*this).setAnimationStyleChange(false);
766 } 766 }
767 767
768 bool Node::inActiveDocument() const 768 bool Node::inActiveDocument() const
769 { 769 {
770 return inShadowIncludingDocument() && document().isActive(); 770 return isConnected() && document().isActive();
771 } 771 }
772 772
773 Node* Node::focusDelegate() 773 Node* Node::focusDelegate()
774 { 774 {
775 return this; 775 return this;
776 } 776 }
777 777
778 bool Node::shouldHaveFocusAppearance() const 778 bool Node::shouldHaveFocusAppearance() const
779 { 779 {
780 DCHECK(focused()); 780 DCHECK(focused());
(...skipping 23 matching lines...) Expand all
804 } 804 }
805 805
806 void Node::clearNodeLists() 806 void Node::clearNodeLists()
807 { 807 {
808 rareData()->clearNodeLists(); 808 rareData()->clearNodeLists();
809 } 809 }
810 810
811 bool Node::isDescendantOf(const Node *other) const 811 bool Node::isDescendantOf(const Node *other) const
812 { 812 {
813 // Return true if other is an ancestor of this, otherwise false 813 // Return true if other is an ancestor of this, otherwise false
814 if (!other || !other->hasChildren() || inShadowIncludingDocument() != other- >inShadowIncludingDocument()) 814 if (!other || !other->hasChildren() || isConnected() != other->isConnected() )
815 return false; 815 return false;
816 if (other->treeScope() != treeScope()) 816 if (other->treeScope() != treeScope())
817 return false; 817 return false;
818 if (other->isTreeScope()) 818 if (other->isTreeScope())
819 return !isTreeScope(); 819 return !isTreeScope();
820 for (const ContainerNode* n = parentNode(); n; n = n->parentNode()) { 820 for (const ContainerNode* n = parentNode(); n; n = n->parentNode()) {
821 if (n == other) 821 if (n == other)
822 return true; 822 return true;
823 } 823 }
824 return false; 824 return false;
(...skipping 10 matching lines...) Expand all
835 { 835 {
836 if (!node) 836 if (!node)
837 return false; 837 return false;
838 838
839 if (this == node) 839 if (this == node)
840 return true; 840 return true;
841 841
842 if (document() != node->document()) 842 if (document() != node->document())
843 return false; 843 return false;
844 844
845 if (inShadowIncludingDocument() != node->inShadowIncludingDocument()) 845 if (isConnected() != node->isConnected())
846 return false; 846 return false;
847 847
848 bool hasChildren = isContainerNode() && toContainerNode(this)->hasChildren() ; 848 bool hasChildren = isContainerNode() && toContainerNode(this)->hasChildren() ;
849 bool hasShadow = isElementNode() && toElement(this)->shadow(); 849 bool hasShadow = isElementNode() && toElement(this)->shadow();
850 if (!hasChildren && !hasShadow) 850 if (!hasChildren && !hasShadow)
851 return false; 851 return false;
852 852
853 for (; node; node = node->shadowHost()) { 853 for (; node; node = node->shadowHost()) {
854 if (treeScope() == node->treeScope()) 854 if (treeScope() == node->treeScope())
855 return contains(node); 855 return contains(node);
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 if (attr2->getQualifiedName() == attr.name()) 1443 if (attr2->getQualifiedName() == attr.name())
1444 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_PRECEDING; 1444 return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSI TION_PRECEDING;
1445 } 1445 }
1446 1446
1447 ASSERT_NOT_REACHED(); 1447 ASSERT_NOT_REACHED();
1448 return DOCUMENT_POSITION_DISCONNECTED; 1448 return DOCUMENT_POSITION_DISCONNECTED;
1449 } 1449 }
1450 1450
1451 // If one node is in the document and the other is not, we must be disconnec ted. 1451 // If one node is in the document and the other is not, we must be disconnec ted.
1452 // If the nodes have different owning documents, they must be disconnected. Note that we avoid 1452 // If the nodes have different owning documents, they must be disconnected. Note that we avoid
1453 // comparing Attr nodes here, since they return false from inShadowIncluding Document() all the time (which seems like a bug). 1453 // comparing Attr nodes here, since they return false from isConnected() all the time (which seems like a bug).
1454 if (start1->inShadowIncludingDocument() != start2->inShadowIncludingDocument () || (treatment == TreatShadowTreesAsDisconnected && start1->treeScope() != sta rt2->treeScope())) { 1454 if (start1->isConnected() != start2->isConnected() || (treatment == TreatSha dowTreesAsDisconnected && start1->treeScope() != start2->treeScope())) {
1455 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED ING : DOCUMENT_POSITION_FOLLOWING; 1455 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED ING : DOCUMENT_POSITION_FOLLOWING;
1456 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION _SPECIFIC | direction; 1456 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION _SPECIFIC | direction;
1457 } 1457 }
1458 1458
1459 // We need to find a common ancestor container, and then compare the indices of the two immediate children. 1459 // We need to find a common ancestor container, and then compare the indices of the two immediate children.
1460 const Node* current; 1460 const Node* current;
1461 for (current = start1; current; current = current->parentOrShadowHostNode()) 1461 for (current = start1; current; current = current->parentOrShadowHostNode())
1462 chain1.append(current); 1462 chain1.append(current);
1463 for (current = start2; current; current = current->parentOrShadowHostNode()) 1463 for (current = start2; current; current = current->parentOrShadowHostNode())
1464 chain2.append(current); 1464 chain2.append(current);
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 2500
2501 void showNodePath(const blink::Node* node) 2501 void showNodePath(const blink::Node* node)
2502 { 2502 {
2503 if (node) 2503 if (node)
2504 node->showNodePathForThis(); 2504 node->showNodePathForThis();
2505 else 2505 else
2506 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2506 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2507 } 2507 }
2508 2508
2509 #endif 2509 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/Node.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698