Changeset 198992 in webkit
- Timestamp:
- Apr 3, 2016, 3:00:20 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r198990 r198992 1 2016-04-03 Antti Koivisto <antti@apple.com> 2 3 Tighten ComposedTreeAncestorIterator to return Elements 4 https://bugs.webkit.org/show_bug.cgi?id=150324 5 6 Reviewed by Andreas Kling. 7 8 Only other thing it could credibly return was Document. We can exclude it from the composed tree and avoid some casting. 9 10 * dom/ComposedTreeAncestorIterator.h: 11 (WebCore::ComposedTreeAncestorIterator::operator*): 12 (WebCore::ComposedTreeAncestorIterator::operator->): 13 (WebCore::ComposedTreeAncestorIterator::operator==): 14 (WebCore::ComposedTreeAncestorIterator::operator!=): 15 (WebCore::ComposedTreeAncestorIterator::operator++): 16 (WebCore::ComposedTreeAncestorIterator::get): 17 (WebCore::ComposedTreeAncestorIterator::ComposedTreeAncestorIterator): 18 (WebCore::ComposedTreeAncestorIterator::traverseParent): 19 (WebCore::ComposedTreeAncestorAdapter::begin): 20 (WebCore::ComposedTreeAncestorAdapter::end): 21 (WebCore::ComposedTreeAncestorAdapter::first): 22 * dom/Element.cpp: 23 (WebCore::Element::resolveComputedStyle): 24 * dom/Node.cpp: 25 (WebCore::Node::updateAncestorsForStyleRecalc): 26 (WebCore::Node::setNeedsStyleRecalc): 27 * rendering/RenderNamedFlowThread.cpp: 28 (WebCore::RenderNamedFlowThread::isChildAllowed): 29 (WebCore::RenderNamedFlowThread::dispatchRegionOversetChangeEventIfNeeded): 30 * style/RenderTreeUpdater.cpp: 31 (WebCore::findRenderingRoot): 32 (WebCore::RenderTreeUpdater::commit): 33 1 34 2016-04-03 Antti Koivisto <antti@apple.com> 2 35 -
trunk/Source/WebCore/dom/ComposedTreeAncestorIterator.h
r191127 r198992 37 37 class ComposedTreeAncestorIterator { 38 38 public: 39 ComposedTreeAncestorIterator( ContainerNode& root);40 ComposedTreeAncestorIterator( ContainerNode& root,Node& current);39 ComposedTreeAncestorIterator(); 40 ComposedTreeAncestorIterator(Node& current); 41 41 42 ContainerNode& operator*() { return get(); }43 ContainerNode* operator->() { return &get(); }42 Element& operator*() { return get(); } 43 Element* operator->() { return &get(); } 44 44 45 45 bool operator==(const ComposedTreeAncestorIterator& other) const { return m_current == other.m_current; } … … 48 48 ComposedTreeAncestorIterator& operator++() { return traverseParent(); } 49 49 50 ContainerNode& get() { return downcast<ContainerNode>(*m_current); }50 Element& get() { return downcast<Element>(*m_current); } 51 51 ComposedTreeAncestorIterator& traverseParent(); 52 52 … … 54 54 void traverseParentInShadowTree(); 55 55 56 ContainerNode& m_root;57 56 Node* m_current { 0 }; 58 57 }; 59 58 60 inline ComposedTreeAncestorIterator::ComposedTreeAncestorIterator(ContainerNode& root) 61 : m_root(root) 59 inline ComposedTreeAncestorIterator::ComposedTreeAncestorIterator() 62 60 { 63 ASSERT(!is<ShadowRoot>(m_root));64 61 } 65 62 66 inline ComposedTreeAncestorIterator::ComposedTreeAncestorIterator(ContainerNode& root, Node& current) 67 : m_root(root) 68 , m_current(¤t) 63 inline ComposedTreeAncestorIterator::ComposedTreeAncestorIterator(Node& current) 64 : m_current(¤t) 69 65 { 70 ASSERT(!is<ShadowRoot>(m_root));71 66 ASSERT(!is<ShadowRoot>(m_current)); 72 67 } … … 74 69 inline ComposedTreeAncestorIterator& ComposedTreeAncestorIterator::traverseParent() 75 70 { 76 if (m_current == &m_root) {77 m_current = nullptr;78 return *this;79 }80 81 71 auto* parent = m_current->parentNode(); 82 72 if (!parent) { … … 88 78 return *this; 89 79 } 80 if (!is<Element>(*parent)) { 81 m_current = nullptr; 82 return *this; 83 }; 90 84 91 85 if (auto* shadowRoot = parent->shadowRoot()) { … … 114 108 { 115 109 if (is<ShadowRoot>(m_node)) 116 return iterator( m_node.document(),*downcast<ShadowRoot>(m_node).host());110 return iterator(*downcast<ShadowRoot>(m_node).host()); 117 111 if (is<PseudoElement>(m_node)) 118 return iterator( m_node.document(),*downcast<PseudoElement>(m_node).hostElement());119 return iterator(m_node .document(), m_node).traverseParent();112 return iterator(*downcast<PseudoElement>(m_node).hostElement()); 113 return iterator(m_node).traverseParent(); 120 114 } 121 115 iterator end() 122 116 { 123 return iterator( m_node.document());117 return iterator(); 124 118 } 125 ContainerNode* first()119 Element* first() 126 120 { 127 121 auto it = begin(); -
trunk/Source/WebCore/dom/Element.cpp
r198943 r198992 2484 2484 auto composedAncestors = composedTreeAncestors(*this); 2485 2485 for (auto& ancestor : composedAncestors) { 2486 if (!is<Element>(ancestor)) 2487 break; 2488 auto& ancestorElement = downcast<Element>(ancestor); 2489 elementsRequiringComputedStyle.prepend(&ancestorElement); 2490 if (auto* existingStyle = ancestorElement.existingComputedStyle()) { 2486 elementsRequiringComputedStyle.prepend(&ancestor); 2487 if (auto* existingStyle = ancestor.existingComputedStyle()) { 2491 2488 computedStyle = existingStyle; 2492 2489 break; -
trunk/Source/WebCore/dom/Node.cpp
r198943 r198992 747 747 it->setDirectChildNeedsStyleRecalc(); 748 748 749 if (i s<Element>(*it) && downcast<Element>(*it).childrenAffectedByPropertyBasedBackwardPositionalRules()) {749 if (it->childrenAffectedByPropertyBasedBackwardPositionalRules()) { 750 750 if (it->styleChangeType() < FullStyleChange) 751 751 it->setStyleChange(FullStyleChange); … … 762 762 } 763 763 764 Document& document = this->document(); 765 if (document.childNeedsStyleRecalc()) 766 document.scheduleStyleRecalc(); 764 auto* documentElement = document().documentElement(); 765 if (!documentElement) 766 return; 767 if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc()) 768 return; 769 document().setChildNeedsStyleRecalc(); 770 document().scheduleStyleRecalc(); 767 771 } 768 772 -
trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp
r197716 r198992 549 549 550 550 auto* originalParent = composedTreeAncestors(*child.node()).first(); 551 if (! is<Element>(originalParent)|| !originalParent->renderer())551 if (!originalParent || !originalParent->renderer()) 552 552 return true; 553 553 554 return downcast<Element>(*originalParent).renderer()->isChildAllowed(child, style);554 return originalParent->renderer()->isChildAllowed(child, style); 555 555 } 556 556 -
trunk/Source/WebCore/style/RenderTreeUpdater.cpp
r198990 r198992 64 64 static ContainerNode& findRenderingRoot(ContainerNode& node) 65 65 { 66 auto& document = node.document(); 67 for (ComposedTreeAncestorIterator it(document, node), end(document); it != end; ++it) { 68 if (it->renderer()) 69 return *it; 70 ASSERT(hasImplicitDisplayContents(downcast<Element>(*it))); 66 if (node.renderer()) 67 return node; 68 for (auto& ancestor : composedTreeAncestors(node)) { 69 if (ancestor.renderer()) 70 return ancestor; 71 ASSERT(hasImplicitDisplayContents(ancestor)); 71 72 } 72 73 ASSERT_NOT_REACHED(); 73 return document;74 return node.document(); 74 75 } 75 76
Note:
See TracChangeset
for help on using the changeset viewer.