Changeset 154734 in webkit
- Timestamp:
- Aug 28, 2013 5:31:10 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r154732 r154734 1 2013-08-28 Antti Koivisto <antti@apple.com> 2 3 Make descendant iterators always require ContainerNode root 4 https://bugs.webkit.org/show_bug.cgi?id=120393 5 6 Reviewed by Andreas Kling. 7 8 Remove Node* root versions of the iterators. 9 Fix the few call sites that required them to have tighter typing. 10 11 * accessibility/AccessibilityNodeObject.cpp: 12 (WebCore::AccessibilityNodeObject::canvasHasFallbackContent): 13 (WebCore::siblingWithAriaRole): 14 * dom/ChildIterator.h: 15 (WebCore::::ChildIteratorAdapter): 16 (WebCore::::begin): 17 (WebCore::::end): 18 (WebCore::elementChildren): 19 (WebCore::childrenOfType): 20 * dom/DescendantIterator.h: 21 (WebCore::::DescendantIterator): 22 (WebCore::::DescendantIteratorAdapter): 23 (WebCore::::begin): 24 (WebCore::::end): 25 (WebCore::elementDescendants): 26 (WebCore::descendantsOfType): 27 * editing/ApplyStyleCommand.cpp: 28 (WebCore::dummySpanAncestorForNode): 29 (WebCore::ApplyStyleCommand::cleanupUnstyledAppleStyleSpans): 30 (WebCore::ApplyStyleCommand::applyInlineStyle): 31 * editing/ApplyStyleCommand.h: 32 1 33 2013-08-28 Sergio Villar Senin <svillar@igalia.com> 2 34 -
trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
r154710 r154734 418 418 if (!node || !node->hasTagName(canvasTag)) 419 419 return false; 420 420 Element* canvasElement = toElement(node); 421 421 // If it has any children that are elements, we'll assume it might be fallback 422 422 // content. If it has no children or its only children are not elements 423 423 // (e.g. just text nodes), it doesn't have fallback content. 424 return elementChildren( node).begin() != elementChildren(node).end();424 return elementChildren(canvasElement).begin() != elementChildren(canvasElement).end(); 425 425 } 426 426 … … 1123 1123 static Element* siblingWithAriaRole(String role, Node* node) 1124 1124 { 1125 Node* parent = node->parentNode();1125 ContainerNode* parent = node->parentNode(); 1126 1126 if (!parent) 1127 1127 return 0; 1128 1129 1128 for (auto sibling = elementChildren(parent).begin(), end = elementChildren(parent).end(); sibling != end; ++sibling) { 1130 1129 const AtomicString& siblingAriaRole = sibling->fastGetAttribute(roleAttr); -
trunk/Source/WebCore/dom/ChildIterator.h
r154700 r154734 55 55 }; 56 56 57 template <typename ElementType , typename ContainerType>57 template <typename ElementType> 58 58 class ChildIteratorAdapter { 59 59 public: 60 ChildIteratorAdapter(Container Type* root);60 ChildIteratorAdapter(ContainerNode* root); 61 61 ChildIterator<ElementType> begin(); 62 62 ChildIterator<ElementType> end(); 63 63 64 64 private: 65 const Container Type* m_root;65 const ContainerNode* m_root; 66 66 }; 67 67 68 ChildIteratorAdapter<Element, ContainerNode> elementChildren(ContainerNode* root); 69 ChildIteratorAdapter<Element, Node> elementChildren(Node* root); 70 template <typename ElementType> ChildIteratorAdapter<ElementType, ContainerNode> childrenOfType(ContainerNode* root); 71 template <typename ElementType> ChildIteratorAdapter<ElementType, Node> childrenOfType(Node* root); 68 ChildIteratorAdapter<Element> elementChildren(ContainerNode* root); 69 template <typename ElementType> ChildIteratorAdapter<ElementType> childrenOfType(ContainerNode* root); 72 70 73 71 template <typename ElementType> … … 135 133 } 136 134 137 template <typename ElementType , typename ContainerType>138 inline ChildIteratorAdapter<ElementType , ContainerType>::ChildIteratorAdapter(ContainerType* root)135 template <typename ElementType> 136 inline ChildIteratorAdapter<ElementType>::ChildIteratorAdapter(ContainerNode* root) 139 137 : m_root(root) 140 138 { 141 139 } 142 140 143 template <typename ElementType , typename ContainerType>144 inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType , ContainerType>::begin()141 template <typename ElementType> 142 inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType>::begin() 145 143 { 146 144 return ChildIterator<ElementType>(Traversal<ElementType>::firstChild(m_root)); 147 145 } 148 146 149 template <typename ElementType , typename ContainerType>150 inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType , ContainerType>::end()147 template <typename ElementType> 148 inline ChildIterator<ElementType> ChildIteratorAdapter<ElementType>::end() 151 149 { 152 150 return ChildIterator<ElementType>(); 153 151 } 154 152 155 inline ChildIteratorAdapter<Element , ContainerNode> elementChildren(ContainerNode* root)153 inline ChildIteratorAdapter<Element> elementChildren(ContainerNode* root) 156 154 { 157 return ChildIteratorAdapter<Element, ContainerNode>(root); 158 } 159 160 inline ChildIteratorAdapter<Element, Node> elementChildren(Node* root) 161 { 162 return ChildIteratorAdapter<Element, Node>(root); 155 return ChildIteratorAdapter<Element>(root); 163 156 } 164 157 165 158 template <typename ElementType> 166 inline ChildIteratorAdapter<ElementType , ContainerNode> childrenOfType(ContainerNode* root)159 inline ChildIteratorAdapter<ElementType> childrenOfType(ContainerNode* root) 167 160 { 168 return ChildIteratorAdapter<ElementType, ContainerNode>(root); 169 } 170 171 template <typename ElementType> 172 inline ChildIteratorAdapter<ElementType, Node> childrenOfType(Node* root) 173 { 174 return ChildIteratorAdapter<ElementType, Node>(root); 161 return ChildIteratorAdapter<ElementType>(root); 175 162 } 176 163 -
trunk/Source/WebCore/dom/DescendantIterator.h
r154700 r154734 38 38 class DescendantIterator { 39 39 public: 40 DescendantIterator(const Node* root);41 DescendantIterator(const Node* root, ElementType* current);40 DescendantIterator(const ContainerNode* root); 41 DescendantIterator(const ContainerNode* root, ElementType* current); 42 42 DescendantIterator& operator++(); 43 43 ElementType& operator*(); … … 46 46 47 47 private: 48 const Node* m_root;48 const ContainerNode* m_root; 49 49 ElementType* m_current; 50 50 … … 56 56 }; 57 57 58 template <typename ElementType , typename ContainerType>58 template <typename ElementType> 59 59 class DescendantIteratorAdapter { 60 60 public: 61 DescendantIteratorAdapter(Container Type* root);61 DescendantIteratorAdapter(ContainerNode* root); 62 62 DescendantIterator<ElementType> begin(); 63 63 DescendantIterator<ElementType> end(); 64 64 65 65 private: 66 Container Type* m_root;66 ContainerNode* m_root; 67 67 }; 68 68 69 DescendantIteratorAdapter<Element, ContainerNode> elementDescendants(ContainerNode* root); 70 DescendantIteratorAdapter<Element, Node> elementDescendants(Node* root); 71 template <typename ElementType> DescendantIteratorAdapter<ElementType, ContainerNode> descendantsOfType(ContainerNode* root); 72 template <typename ElementType> DescendantIteratorAdapter<ElementType, Node> descendantsOfType(Node* root); 69 DescendantIteratorAdapter<Element> elementDescendants(ContainerNode* root); 70 template <typename ElementType> DescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode* root); 73 71 74 72 template <typename ElementType> 75 inline DescendantIterator<ElementType>::DescendantIterator(const Node* root)73 inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root) 76 74 : m_root(root) 77 75 , m_current(nullptr) … … 83 81 84 82 template <typename ElementType> 85 inline DescendantIterator<ElementType>::DescendantIterator(const Node* root, ElementType* current)83 inline DescendantIterator<ElementType>::DescendantIterator(const ContainerNode* root, ElementType* current) 86 84 : m_root(root) 87 85 , m_current(current) … … 139 137 } 140 138 141 template <typename ElementType , typename ContainerType>142 inline DescendantIteratorAdapter<ElementType , ContainerType>::DescendantIteratorAdapter(ContainerType* root)139 template <typename ElementType> 140 inline DescendantIteratorAdapter<ElementType>::DescendantIteratorAdapter(ContainerNode* root) 143 141 : m_root(root) 144 142 { 145 143 } 146 144 147 template <typename ElementType , typename ContainerType>148 inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType , ContainerType>::begin()145 template <typename ElementType> 146 inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType>::begin() 149 147 { 150 148 return DescendantIterator<ElementType>(m_root, Traversal<ElementType>::firstWithin(m_root)); 151 149 } 152 150 153 template <typename ElementType , typename ContainerType>154 inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType , ContainerType>::end()151 template <typename ElementType> 152 inline DescendantIterator<ElementType> DescendantIteratorAdapter<ElementType>::end() 155 153 { 156 154 return DescendantIterator<ElementType>(m_root); 157 155 } 158 156 159 inline DescendantIteratorAdapter<Element , ContainerNode> elementDescendants(ContainerNode* root)157 inline DescendantIteratorAdapter<Element> elementDescendants(ContainerNode* root) 160 158 { 161 return DescendantIteratorAdapter<Element, ContainerNode>(root); 162 } 163 164 inline DescendantIteratorAdapter<Element, Node> elementDescendants(Node* root) 165 { 166 return DescendantIteratorAdapter<Element, Node>(root); 159 return DescendantIteratorAdapter<Element>(root); 167 160 } 168 161 169 162 template <typename ElementType> 170 inline DescendantIteratorAdapter<ElementType , ContainerNode> descendantsOfType(ContainerNode* root)163 inline DescendantIteratorAdapter<ElementType> descendantsOfType(ContainerNode* root) 171 164 { 172 return DescendantIteratorAdapter<ElementType, ContainerNode>(root); 173 } 174 175 template <typename ElementType> 176 inline DescendantIteratorAdapter<ElementType, Node> descendantsOfType(Node* root) 177 { 178 return DescendantIteratorAdapter<ElementType, Node>(root); 165 return DescendantIteratorAdapter<ElementType>(root); 179 166 } 180 167 -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r154581 r154734 426 426 } 427 427 428 static Node* dummySpanAncestorForNode(const Node* node)428 static ContainerNode* dummySpanAncestorForNode(const Node* node) 429 429 { 430 430 while (node && (!node->isElementNode() || !isStyleSpanOrSpanWithOnlyStyleAttribute(toElement(node)))) … … 434 434 } 435 435 436 void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans( Node* dummySpanAncestor)436 void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans(ContainerNode* dummySpanAncestor) 437 437 { 438 438 if (!dummySpanAncestor) … … 552 552 void ApplyStyleCommand::applyInlineStyle(EditingStyle* style) 553 553 { 554 RefPtr< Node> startDummySpanAncestor = 0;555 RefPtr< Node> endDummySpanAncestor = 0;554 RefPtr<ContainerNode> startDummySpanAncestor = 0; 555 RefPtr<ContainerNode> endDummySpanAncestor = 0; 556 556 557 557 // update document layout once before removing styles -
trunk/Source/WebCore/editing/ApplyStyleCommand.h
r143821 r154734 109 109 bool mergeStartWithPreviousIfIdentical(const Position& start, const Position& end); 110 110 bool mergeEndWithNextIfIdentical(const Position& start, const Position& end); 111 void cleanupUnstyledAppleStyleSpans( Node* dummySpanAncestor);111 void cleanupUnstyledAppleStyleSpans(ContainerNode* dummySpanAncestor); 112 112 113 113 void surroundNodeRangeWithElement(PassRefPtr<Node> start, PassRefPtr<Node> end, PassRefPtr<Element>);
Note: See TracChangeset
for help on using the changeset viewer.