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

Side by Side Diff: Source/core/dom/ContainerNode.h

Issue 208933003: Remove SiblingRuleHelper (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tighten types to ContainerNode Created 6 years, 9 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 | « Source/core/css/resolver/SharedStyleFinder.cpp ('k') | Source/core/dom/ContainerNode.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 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return s_count; 69 return s_count;
70 } 70 }
71 #endif 71 #endif
72 72
73 private: 73 private:
74 #ifndef NDEBUG 74 #ifndef NDEBUG
75 static unsigned s_count; 75 static unsigned s_count;
76 #endif 76 #endif
77 }; 77 };
78 78
79 enum DynamicRestyleFlags {
80 ChildrenAffectedByFocus = 1 << 0,
81 ChildrenAffectedByHover = 1 << 1,
82 ChildrenAffectedByActive = 1 << 2,
83 ChildrenAffectedByDrag = 1 << 3,
84 ChildrenAffectedByFirstChildRules = 1 << 4,
85 ChildrenAffectedByLastChildRules = 1 << 5,
86 ChildrenAffectedByDirectAdjacentRules = 1 << 6,
87 ChildrenAffectedByIndirectAdjacentRules = 1 << 7,
88 ChildrenAffectedByForwardPositionalRules = 1 << 8,
89 ChildrenAffectedByBackwardPositionalRules = 1 << 9,
90
91 NumberOfDynamicRestyleFlags = 10,
92 };
93
79 class ContainerNode : public Node { 94 class ContainerNode : public Node {
80 public: 95 public:
81 virtual ~ContainerNode(); 96 virtual ~ContainerNode();
82 97
83 Node* firstChild() const { return m_firstChild; } 98 Node* firstChild() const { return m_firstChild; }
84 Node* lastChild() const { return m_lastChild; } 99 Node* lastChild() const { return m_lastChild; }
85 bool hasChildren() const { return m_firstChild; } 100 bool hasChildren() const { return m_firstChild; }
86 101
87 bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling (); } 102 bool hasOneChild() const { return m_firstChild && !m_firstChild->nextSibling (); }
88 bool hasOneTextChild() const { return hasOneChild() && m_firstChild->isTextN ode(); } 103 bool hasOneTextChild() const { return hasOneChild() && m_firstChild->isTextN ode(); }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void cloneChildNodes(ContainerNode* clone); 135 void cloneChildNodes(ContainerNode* clone);
121 136
122 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; 137 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
123 virtual void detach(const AttachContext& = AttachContext()) OVERRIDE; 138 virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
124 virtual LayoutRect boundingBox() const OVERRIDE FINAL; 139 virtual LayoutRect boundingBox() const OVERRIDE FINAL;
125 virtual void setFocus(bool) OVERRIDE; 140 virtual void setFocus(bool) OVERRIDE;
126 void focusStateChanged(); 141 void focusStateChanged();
127 virtual void setActive(bool = true) OVERRIDE; 142 virtual void setActive(bool = true) OVERRIDE;
128 virtual void setHovered(bool = true) OVERRIDE; 143 virtual void setHovered(bool = true) OVERRIDE;
129 144
145 bool childrenAffectedByFocus() const { return hasRestyleFlag(ChildrenAffecte dByFocus); }
146 void setChildrenAffectedByFocus() { setRestyleFlag(ChildrenAffectedByFocus); }
147
148 bool childrenAffectedByHover() const { return hasRestyleFlag(ChildrenAffecte dByHover); }
149 void setChildrenAffectedByHover() { setRestyleFlag(ChildrenAffectedByHover); }
150
151 bool childrenAffectedByActive() const { return hasRestyleFlag(ChildrenAffect edByActive); }
152 void setChildrenAffectedByActive() { setRestyleFlag(ChildrenAffectedByActive ); }
153
154 bool childrenAffectedByDrag() const { return hasRestyleFlag(ChildrenAffected ByDrag); }
155 void setChildrenAffectedByDrag() { setRestyleFlag(ChildrenAffectedByDrag); }
156
157 bool childrenAffectedByPositionalRules() const { return hasRestyleFlag(Child renAffectedByForwardPositionalRules) || hasRestyleFlag(ChildrenAffectedByBackwar dPositionalRules); }
158
159 bool childrenAffectedByFirstChildRules() const { return hasRestyleFlag(Child renAffectedByFirstChildRules); }
160 void setChildrenAffectedByFirstChildRules() { setRestyleFlag(ChildrenAffecte dByFirstChildRules); }
161
162 bool childrenAffectedByLastChildRules() const { return hasRestyleFlag(Childr enAffectedByLastChildRules); }
163 void setChildrenAffectedByLastChildRules() { setRestyleFlag(ChildrenAffected ByLastChildRules); }
164
165 bool childrenAffectedByDirectAdjacentRules() const { return hasRestyleFlag(C hildrenAffectedByDirectAdjacentRules); }
166 void setChildrenAffectedByDirectAdjacentRules() { setRestyleFlag(ChildrenAff ectedByDirectAdjacentRules); }
167
168 bool childrenAffectedByIndirectAdjacentRules() const { return hasRestyleFlag (ChildrenAffectedByIndirectAdjacentRules); }
169 void setChildrenAffectedByIndirectAdjacentRules() { setRestyleFlag(ChildrenA ffectedByIndirectAdjacentRules); }
170
171 bool childrenAffectedByForwardPositionalRules() const { return hasRestyleFla g(ChildrenAffectedByForwardPositionalRules); }
172 void setChildrenAffectedByForwardPositionalRules() { setRestyleFlag(Children AffectedByForwardPositionalRules); }
173
174 bool childrenAffectedByBackwardPositionalRules() const { return hasRestyleFl ag(ChildrenAffectedByBackwardPositionalRules); }
175 void setChildrenAffectedByBackwardPositionalRules() { setRestyleFlag(Childre nAffectedByBackwardPositionalRules); }
176
177 void checkForChildrenAdjacentRuleChanges();
178
179 bool childrenSupportStyleSharing() const { return !hasRestyleFlags(); }
180
130 // ------------------------------------------------------------------------- ---- 181 // ------------------------------------------------------------------------- ----
131 // Notification of document structure changes (see core/dom/Node.h for more notification methods) 182 // Notification of document structure changes (see core/dom/Node.h for more notification methods)
132 183
133 // Notifies the node that it's list of children have changed (either by addi ng or removing child nodes), or a child 184 // Notifies the node that it's list of children have changed (either by addi ng or removing child nodes), or a child
134 // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE ha s changed its value. 185 // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE ha s changed its value.
135 virtual void childrenChanged(bool createdByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0); 186 virtual void childrenChanged(bool createdByParser = false, Node* beforeChang e = 0, Node* afterChange = 0, int childCountDelta = 0);
136 187
137 void disconnectDescendantFrames(); 188 void disconnectDescendantFrames();
138 189
139 protected: 190 protected:
140 ContainerNode(TreeScope*, ConstructionType = CreateContainer); 191 ContainerNode(TreeScope*, ConstructionType = CreateContainer);
141 192
142 template<class GenericNode, class GenericNodeContainer> 193 template<class GenericNode, class GenericNodeContainer>
143 friend void appendChildToContainer(GenericNode& child, GenericNodeContainer& ); 194 friend void appendChildToContainer(GenericNode& child, GenericNodeContainer& );
144 195
145 template<class GenericNode, class GenericNodeContainer> 196 template<class GenericNode, class GenericNodeContainer>
146 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, Generi cNode*& tail, GenericNodeContainer&); 197 friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, Generi cNode*& tail, GenericNodeContainer&);
147 198
148 void removeDetachedChildren(); 199 void removeDetachedChildren();
149 void setFirstChild(Node* child) { m_firstChild = child; } 200 void setFirstChild(Node* child) { m_firstChild = child; }
150 void setLastChild(Node* child) { m_lastChild = child; } 201 void setLastChild(Node* child) { m_lastChild = child; }
151 202
152 private: 203 private:
153 void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild); 204 void removeBetween(Node* previousChild, Node* nextChild, Node& oldChild);
154 void insertBeforeCommon(Node& nextChild, Node& oldChild); 205 void insertBeforeCommon(Node& nextChild, Node& oldChild);
155 void updateTreeAfterInsertion(Node& child); 206 void updateTreeAfterInsertion(Node& child);
156 void willRemoveChildren(); 207 void willRemoveChildren();
157 void willRemoveChild(Node& child); 208 void willRemoveChild(Node& child);
158 209
210 bool hasRestyleFlag(DynamicRestyleFlags mask) const { return hasRareData() & & hasRestyleFlagInternal(mask); }
211 bool hasRestyleFlags() const { return hasRareData() && hasRestyleFlagsIntern al(); }
212 void setRestyleFlag(DynamicRestyleFlags);
213 bool hasRestyleFlagInternal(DynamicRestyleFlags) const;
214 bool hasRestyleFlagsInternal() const;
215
159 inline bool checkAcceptChildGuaranteedNodeTypes(const Node& newChild, Except ionState&) const; 216 inline bool checkAcceptChildGuaranteedNodeTypes(const Node& newChild, Except ionState&) const;
160 inline bool checkAcceptChild(const Node* newChild, const Node* oldChild, Exc eptionState&) const; 217 inline bool checkAcceptChild(const Node* newChild, const Node* oldChild, Exc eptionState&) const;
161 inline bool containsConsideringHostElements(const Node&) const; 218 inline bool containsConsideringHostElements(const Node&) const;
162 inline bool isChildTypeAllowed(const Node& child) const; 219 inline bool isChildTypeAllowed(const Node& child) const;
163 220
164 void attachChildren(const AttachContext& = AttachContext()); 221 void attachChildren(const AttachContext& = AttachContext());
165 void detachChildren(const AttachContext& = AttachContext()); 222 void detachChildren(const AttachContext& = AttachContext());
166 223
167 bool getUpperLeftCorner(FloatPoint&) const; 224 bool getUpperLeftCorner(FloatPoint&) const;
168 bool getLowerRightCorner(FloatPoint&) const; 225 bool getLowerRightCorner(FloatPoint&) const;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 302
246 inline Node& Node::highestAncestor() const 303 inline Node& Node::highestAncestor() const
247 { 304 {
248 Node* node = const_cast<Node*>(this); 305 Node* node = const_cast<Node*>(this);
249 Node* highest = node; 306 Node* highest = node;
250 for (; node; node = node->parentNode()) 307 for (; node; node = node->parentNode())
251 highest = node; 308 highest = node;
252 return *highest; 309 return *highest;
253 } 310 }
254 311
255 inline Node* Node::parentElementOrShadowRoot() const 312 inline ContainerNode* Node::parentElementOrShadowRoot() const
256 { 313 {
257 ContainerNode* parent = parentNode(); 314 ContainerNode* parent = parentNode();
258 return parent && (parent->isElementNode() || parent->isShadowRoot()) ? paren t : 0; 315 return parent && (parent->isElementNode() || parent->isShadowRoot()) ? paren t : 0;
259 } 316 }
260 317
261 // This constant controls how much buffer is initially allocated 318 // This constant controls how much buffer is initially allocated
262 // for a Node Vector that is used to store child Nodes of a given Node. 319 // for a Node Vector that is used to store child Nodes of a given Node.
263 // FIXME: Optimize the value. 320 // FIXME: Optimize the value.
264 const int initialNodeVectorSize = 11; 321 const int initialNodeVectorSize = 11;
265 typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector; 322 typedef Vector<RefPtr<Node>, initialNodeVectorSize> NodeVector;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 389
333 RefPtr<Node> m_currentNode; 390 RefPtr<Node> m_currentNode;
334 unsigned m_currentIndex; 391 unsigned m_currentIndex;
335 OwnPtr<Vector<RefPtr<Node> > > m_childNodes; // Lazily instantiated. 392 OwnPtr<Vector<RefPtr<Node> > > m_childNodes; // Lazily instantiated.
336 ChildNodesLazySnapshot* m_nextSnapshot; 393 ChildNodesLazySnapshot* m_nextSnapshot;
337 }; 394 };
338 395
339 } // namespace WebCore 396 } // namespace WebCore
340 397
341 #endif // ContainerNode_h 398 #endif // ContainerNode_h
OLDNEW
« no previous file with comments | « Source/core/css/resolver/SharedStyleFinder.cpp ('k') | Source/core/dom/ContainerNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698