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

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

Issue 1675163002: Rename ComposedTree to FlatTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 4 years, 10 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 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/dom/NodeRareData.h" 47 #include "core/dom/NodeRareData.h"
48 #include "core/dom/NodeTraversal.h" 48 #include "core/dom/NodeTraversal.h"
49 #include "core/dom/ProcessingInstruction.h" 49 #include "core/dom/ProcessingInstruction.h"
50 #include "core/dom/Range.h" 50 #include "core/dom/Range.h"
51 #include "core/dom/StaticNodeList.h" 51 #include "core/dom/StaticNodeList.h"
52 #include "core/dom/StyleEngine.h" 52 #include "core/dom/StyleEngine.h"
53 #include "core/dom/TemplateContentDocumentFragment.h" 53 #include "core/dom/TemplateContentDocumentFragment.h"
54 #include "core/dom/Text.h" 54 #include "core/dom/Text.h"
55 #include "core/dom/TreeScopeAdopter.h" 55 #include "core/dom/TreeScopeAdopter.h"
56 #include "core/dom/UserActionElementSet.h" 56 #include "core/dom/UserActionElementSet.h"
57 #include "core/dom/shadow/ComposedTreeTraversal.h"
58 #include "core/dom/shadow/ElementShadow.h" 57 #include "core/dom/shadow/ElementShadow.h"
58 #include "core/dom/shadow/FlatTreeTraversal.h"
59 #include "core/dom/shadow/InsertionPoint.h" 59 #include "core/dom/shadow/InsertionPoint.h"
60 #include "core/dom/shadow/ShadowRoot.h" 60 #include "core/dom/shadow/ShadowRoot.h"
61 #include "core/editing/EditingUtilities.h" 61 #include "core/editing/EditingUtilities.h"
62 #include "core/editing/markers/DocumentMarkerController.h" 62 #include "core/editing/markers/DocumentMarkerController.h"
63 #include "core/events/Event.h" 63 #include "core/events/Event.h"
64 #include "core/events/EventDispatchMediator.h" 64 #include "core/events/EventDispatchMediator.h"
65 #include "core/events/EventDispatcher.h" 65 #include "core/events/EventDispatcher.h"
66 #include "core/events/EventListener.h" 66 #include "core/events/EventListener.h"
67 #include "core/events/GestureEvent.h" 67 #include "core/events/GestureEvent.h"
68 #include "core/events/KeyboardEvent.h" 68 #include "core/events/KeyboardEvent.h"
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 753
754 bool Node::shouldHaveFocusAppearance() const 754 bool Node::shouldHaveFocusAppearance() const
755 { 755 {
756 ASSERT(focused()); 756 ASSERT(focused());
757 return true; 757 return true;
758 } 758 }
759 759
760 bool Node::isInert() const 760 bool Node::isInert() const
761 { 761 {
762 const HTMLDialogElement* dialog = document().activeModalDialog(); 762 const HTMLDialogElement* dialog = document().activeModalDialog();
763 if (dialog && this != document() && (!canParticipateInComposedTree() || !Com posedTreeTraversal::containsIncludingPseudoElement(*dialog, *this))) 763 if (dialog && this != document() && (!canParticipateInFlatTree() || !FlatTre eTraversal::containsIncludingPseudoElement(*dialog, *this)))
764 return true; 764 return true;
765 return document().ownerElement() && document().ownerElement()->isInert(); 765 return document().ownerElement() && document().ownerElement()->isInert();
766 } 766 }
767 767
768 unsigned Node::nodeIndex() const 768 unsigned Node::nodeIndex() const
769 { 769 {
770 const Node* tempNode = previousSibling(); 770 const Node* tempNode = previousSibling();
771 unsigned count = 0; 771 unsigned count = 0;
772 for (count = 0; tempNode; count++) 772 for (count = 0; tempNode; count++)
773 tempNode = tempNode->previousSibling(); 773 tempNode = tempNode->previousSibling();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 if (hasEditableStyle()) 956 if (hasEditableStyle())
957 return true; 957 return true;
958 958
959 if (layoutObject()) { 959 if (layoutObject()) {
960 const ComputedStyle& style = layoutObject()->styleRef(); 960 const ComputedStyle& style = layoutObject()->styleRef();
961 // We allow selections to begin within an element that has -webkit-user- select: none set, 961 // We allow selections to begin within an element that has -webkit-user- select: none set,
962 // but if the element is draggable then dragging should take priority ov er selection. 962 // but if the element is draggable then dragging should take priority ov er selection.
963 if (style.userDrag() == DRAG_ELEMENT && style.userSelect() == SELECT_NON E) 963 if (style.userDrag() == DRAG_ELEMENT && style.userSelect() == SELECT_NON E)
964 return false; 964 return false;
965 } 965 }
966 ContainerNode* parent = ComposedTreeTraversal::parent(*this); 966 ContainerNode* parent = FlatTreeTraversal::parent(*this);
967 return parent ? parent->canStartSelection() : true; 967 return parent ? parent->canStartSelection() : true;
968 } 968 }
969 969
970 bool Node::canParticipateInComposedTree() const 970 bool Node::canParticipateInFlatTree() const
971 { 971 {
972 return !isShadowRoot() && !isSlotOrActiveInsertionPoint(); 972 return !isShadowRoot() && !isSlotOrActiveInsertionPoint();
973 } 973 }
974 974
975 bool Node::isSlotOrActiveInsertionPoint() const 975 bool Node::isSlotOrActiveInsertionPoint() const
976 { 976 {
977 return isHTMLSlotElement(*this) || isActiveInsertionPoint(*this); 977 return isHTMLSlotElement(*this) || isActiveInsertionPoint(*this);
978 } 978 }
979 979
980 bool Node::isInV1ShadowTree() const 980 bool Node::isInV1ShadowTree() const
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 attrs.appendLiteral(" (focused)"); 1558 attrs.appendLiteral(" (focused)");
1559 WTFLogAlways("%s%s\t%p%s\n", prefix, nodeName().utf8().data(), this, att rs.toString().utf8().data()); 1559 WTFLogAlways("%s%s\t%p%s\n", prefix, nodeName().utf8().data(), this, att rs.toString().utf8().data());
1560 } 1560 }
1561 } 1561 }
1562 1562
1563 void Node::showTreeForThis() const 1563 void Node::showTreeForThis() const
1564 { 1564 {
1565 showTreeAndMark(this, "*"); 1565 showTreeAndMark(this, "*");
1566 } 1566 }
1567 1567
1568 void Node::showTreeForThisInComposedTree() const 1568 void Node::showTreeForThisInFlatTree() const
1569 { 1569 {
1570 showTreeAndMarkInComposedTree(this, "*"); 1570 showTreeAndMarkInFlatTree(this, "*");
1571 } 1571 }
1572 1572
1573 void Node::showNodePathForThis() const 1573 void Node::showNodePathForThis() const
1574 { 1574 {
1575 WillBeHeapVector<RawPtrWillBeMember<const Node>, 16> chain; 1575 WillBeHeapVector<RawPtrWillBeMember<const Node>, 16> chain;
1576 const Node* node = this; 1576 const Node* node = this;
1577 while (node->parentOrShadowHostNode()) { 1577 while (node->parentOrShadowHostNode()) {
1578 chain.append(node); 1578 chain.append(node);
1579 node = node->parentOrShadowHostNode(); 1579 node = node->parentOrShadowHostNode();
1580 } 1580 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 1652
1653 if (node.isShadowRoot()) { 1653 if (node.isShadowRoot()) {
1654 if (ShadowRoot* youngerShadowRoot = toShadowRoot(node).youngerShadow Root()) 1654 if (ShadowRoot* youngerShadowRoot = toShadowRoot(node).youngerShadow Root())
1655 traverseTreeAndMark(indent.toString(), youngerShadowRoot, marked Node1, markedLabel1, markedNode2, markedLabel2); 1655 traverseTreeAndMark(indent.toString(), youngerShadowRoot, marked Node1, markedLabel1, markedNode2, markedLabel2);
1656 } else if (ShadowRoot* oldestShadowRoot = oldestShadowRootFor(&node)) { 1656 } else if (ShadowRoot* oldestShadowRoot = oldestShadowRootFor(&node)) {
1657 traverseTreeAndMark(indent.toString(), oldestShadowRoot, markedNode1 , markedLabel1, markedNode2, markedLabel2); 1657 traverseTreeAndMark(indent.toString(), oldestShadowRoot, markedNode1 , markedLabel1, markedNode2, markedLabel2);
1658 } 1658 }
1659 } 1659 }
1660 } 1660 }
1661 1661
1662 static void traverseTreeAndMarkInComposedTree(const String& baseIndent, const No de* rootNode, const Node* markedNode1, const char* markedLabel1, const Node* mar kedNode2, const char* markedLabel2) 1662 static void traverseTreeAndMarkInFlatTree(const String& baseIndent, const Node* rootNode, const Node* markedNode1, const char* markedLabel1, const Node* markedN ode2, const char* markedLabel2)
1663 { 1663 {
1664 for (const Node* node = rootNode; node; node = ComposedTreeTraversal::nextSi bling(*node)) { 1664 for (const Node* node = rootNode; node; node = FlatTreeTraversal::nextSiblin g(*node)) {
1665 StringBuilder indent; 1665 StringBuilder indent;
1666 if (node == markedNode1) 1666 if (node == markedNode1)
1667 indent.append(markedLabel1); 1667 indent.append(markedLabel1);
1668 if (node == markedNode2) 1668 if (node == markedNode2)
1669 indent.append(markedLabel2); 1669 indent.append(markedLabel2);
1670 indent.append(baseIndent); 1670 indent.append(baseIndent);
1671 node->showNode(indent.toString().utf8().data()); 1671 node->showNode(indent.toString().utf8().data());
1672 indent.append('\t'); 1672 indent.append('\t');
1673 1673
1674 Node* child = ComposedTreeTraversal::firstChild(*node); 1674 Node* child = FlatTreeTraversal::firstChild(*node);
1675 if (child) 1675 if (child)
1676 traverseTreeAndMarkInComposedTree(indent.toString(), child, markedNo de1, markedLabel1, markedNode2, markedLabel2); 1676 traverseTreeAndMarkInFlatTree(indent.toString(), child, markedNode1, markedLabel1, markedNode2, markedLabel2);
1677 } 1677 }
1678 } 1678 }
1679 1679
1680 void Node::showTreeAndMark(const Node* markedNode1, const char* markedLabel1, co nst Node* markedNode2, const char* markedLabel2) const 1680 void Node::showTreeAndMark(const Node* markedNode1, const char* markedLabel1, co nst Node* markedNode2, const char* markedLabel2) const
1681 { 1681 {
1682 const Node* rootNode; 1682 const Node* rootNode;
1683 const Node* node = this; 1683 const Node* node = this;
1684 while (node->parentOrShadowHostNode() && !isHTMLBodyElement(*node)) 1684 while (node->parentOrShadowHostNode() && !isHTMLBodyElement(*node))
1685 node = node->parentOrShadowHostNode(); 1685 node = node->parentOrShadowHostNode();
1686 rootNode = node; 1686 rootNode = node;
1687 1687
1688 String startingIndent; 1688 String startingIndent;
1689 traverseTreeAndMark(startingIndent, rootNode, markedNode1, markedLabel1, mar kedNode2, markedLabel2); 1689 traverseTreeAndMark(startingIndent, rootNode, markedNode1, markedLabel1, mar kedNode2, markedLabel2);
1690 } 1690 }
1691 1691
1692 void Node::showTreeAndMarkInComposedTree(const Node* markedNode1, const char* ma rkedLabel1, const Node* markedNode2, const char* markedLabel2) const 1692 void Node::showTreeAndMarkInFlatTree(const Node* markedNode1, const char* marked Label1, const Node* markedNode2, const char* markedLabel2) const
1693 { 1693 {
1694 const Node* rootNode; 1694 const Node* rootNode;
1695 const Node* node = this; 1695 const Node* node = this;
1696 while (node->parentOrShadowHostNode() && !isHTMLBodyElement(*node)) 1696 while (node->parentOrShadowHostNode() && !isHTMLBodyElement(*node))
1697 node = node->parentOrShadowHostNode(); 1697 node = node->parentOrShadowHostNode();
1698 rootNode = node; 1698 rootNode = node;
1699 1699
1700 String startingIndent; 1700 String startingIndent;
1701 traverseTreeAndMarkInComposedTree(startingIndent, rootNode, markedNode1, mar kedLabel1, markedNode2, markedLabel2); 1701 traverseTreeAndMarkInFlatTree(startingIndent, rootNode, markedNode1, markedL abel1, markedNode2, markedLabel2);
1702 } 1702 }
1703 1703
1704 void Node::formatForDebugger(char* buffer, unsigned length) const 1704 void Node::formatForDebugger(char* buffer, unsigned length) const
1705 { 1705 {
1706 String result; 1706 String result;
1707 String s; 1707 String s;
1708 1708
1709 s = nodeName(); 1709 s = nodeName();
1710 if (s.isEmpty()) 1710 if (s.isEmpty())
1711 result = "<none>"; 1711 result = "<none>";
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 showSubTreeAcrossFrame(rootNode, this, ""); 1750 showSubTreeAcrossFrame(rootNode, this, "");
1751 } 1751 }
1752 1752
1753 #endif 1753 #endif
1754 1754
1755 // -------- 1755 // --------
1756 1756
1757 Element* Node::enclosingLinkEventParentOrSelf() const 1757 Element* Node::enclosingLinkEventParentOrSelf() const
1758 { 1758 {
1759 const Node* result = nullptr; 1759 const Node* result = nullptr;
1760 for (const Node* node = this; node; node = ComposedTreeTraversal::parent(*no de)) { 1760 for (const Node* node = this; node; node = FlatTreeTraversal::parent(*node)) {
1761 // For imagemaps, the enclosing link node is the associated area element not the image itself. 1761 // For imagemaps, the enclosing link node is the associated area element not the image itself.
1762 // So we don't let images be the enclosingLinkNode, even though isLink s ometimes returns true 1762 // So we don't let images be the enclosingLinkNode, even though isLink s ometimes returns true
1763 // for them. 1763 // for them.
1764 if (node->isLink() && !isHTMLImageElement(*node)) { 1764 if (node->isLink() && !isHTMLImageElement(*node)) {
1765 // Casting to Element is safe because only HTMLAnchorElement, HTMLIm ageElement and 1765 // Casting to Element is safe because only HTMLAnchorElement, HTMLIm ageElement and
1766 // SVGAElement can return true for isLink(). 1766 // SVGAElement can return true for isLink().
1767 result = node; 1767 result = node;
1768 break; 1768 break;
1769 } 1769 }
1770 } 1770 }
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 2425
2426 void showNodePath(const blink::Node* node) 2426 void showNodePath(const blink::Node* node)
2427 { 2427 {
2428 if (node) 2428 if (node)
2429 node->showNodePathForThis(); 2429 node->showNodePathForThis();
2430 else 2430 else
2431 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2431 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2432 } 2432 }
2433 2433
2434 #endif 2434 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698