Changeset 289457 in webkit
- Timestamp:
- Feb 8, 2022 11:35:37 PM (5 months ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
-
ChangeLog (modified) (1 diff)
-
dom/Document.cpp (modified) (1 diff)
-
dom/Element.cpp (modified) (1 diff)
-
dom/Element.h (modified) (1 diff)
-
page/FrameView.cpp (modified) (1 diff)
-
rendering/RenderBox.cpp (modified) (2 diffs)
-
rendering/RenderView.cpp (modified) (1 diff)
-
rendering/RenderView.h (modified) (3 diffs)
-
style/StyleScope.cpp (modified) (2 diffs)
-
style/StyleScope.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r289455 r289457 1 2022-02-08 Antti Koivisto <antti@apple.com> 2 3 [CSS Container Queries] Track query containers so they can be invalidated on size change 4 https://bugs.webkit.org/show_bug.cgi?id=236297 5 6 Reviewed by Alan Bujtas. 7 8 Add container size tracking. 9 10 * dom/Document.cpp: 11 (WebCore::Document::updateLayout): 12 * dom/Element.cpp: 13 (WebCore::Element::invalidateForQueryContainerChange): 14 * dom/Element.h: 15 * page/FrameView.cpp: 16 (WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive): 17 * rendering/RenderBox.cpp: 18 (WebCore::RenderBox::willBeDestroyed): 19 (WebCore::RenderBox::styleWillChange): 20 * rendering/RenderView.cpp: 21 (WebCore::RenderView::registerContainerQueryBox): 22 (WebCore::RenderView::unregisterContainerQueryBox): 23 * rendering/RenderView.h: 24 * style/StyleScope.cpp: 25 (WebCore::Style::Scope::updateQueryContainerState): 26 27 Save the sizes after layout and invalidate if needed. 28 29 * style/StyleScope.h: 30 1 31 2022-02-08 Antoine Quint <graouts@webkit.org> 2 32 -
trunk/Source/WebCore/dom/Document.cpp
r289246 r289457 2199 2199 StackStats::LayoutCheckPoint layoutCheckPoint; 2200 2200 2201 // Only do a layout if changes have occurred that make it necessary. 2202 if (frameView && renderView() && (frameView->layoutContext().isLayoutPending() || renderView()->needsLayout())) 2203 frameView->layoutContext().layout(); 2201 if (!frameView || !renderView()) 2202 return; 2203 if (!frameView->layoutContext().isLayoutPending() && !renderView()->needsLayout()) 2204 return; 2205 2206 frameView->layoutContext().layout(); 2207 2208 if (styleScope().updateQueryContainerState()) 2209 updateLayout(); 2204 2210 } 2205 2211 -
trunk/Source/WebCore/dom/Element.cpp
r289246 r289457 2131 2131 } 2132 2132 2133 void Element::invalidateForQueryContainerChange() 2134 { 2135 // FIXME: This doesn't really need to recompute the element style. 2136 Node::invalidateStyle(Style::Validity::ElementInvalid); 2137 } 2138 2133 2139 void Element::invalidateEventListenerRegions() 2134 2140 { -
trunk/Source/WebCore/dom/Element.h
r289246 r289457 636 636 void invalidateStyleInternal(); 637 637 void invalidateStyleForSubtreeInternal(); 638 void invalidateForQueryContainerChange(); 638 639 639 640 void invalidateEventListenerRegions(); -
trunk/Source/WebCore/page/FrameView.cpp
r288008 r289457 4540 4540 if (view->needsLayout()) { 4541 4541 view->layoutContext().layout(); 4542 view->frame().document()->styleScope().updateQueryContainerState(); 4542 4543 didWork = true; 4543 4544 } -
trunk/Source/WebCore/rendering/RenderBox.cpp
r289443 r289457 174 174 removeControlStatesForRenderer(*this); 175 175 176 if (hasInitializedStyle() && style().hasSnapPosition()) 177 view().unregisterBoxWithScrollSnapPositions(*this); 176 if (hasInitializedStyle()) { 177 if (style().hasSnapPosition()) 178 view().unregisterBoxWithScrollSnapPositions(*this); 179 if (style().containerType() != ContainerType::None) 180 view().unregisterContainerQueryBox(*this); 181 } 178 182 179 183 RenderBoxModelObject::willBeDestroyed(); … … 293 297 view().unregisterBoxWithScrollSnapPositions(*this); 294 298 } 299 300 if (newStyle.containerType() != ContainerType::None) 301 view().registerContainerQueryBox(*this); 302 else if (oldStyle && oldStyle->containerType() != ContainerType::None) 303 view().unregisterContainerQueryBox(*this); 295 304 296 305 RenderBoxModelObject::styleWillChange(diff, newStyle); -
trunk/Source/WebCore/rendering/RenderView.cpp
r288069 r289457 963 963 } 964 964 965 void RenderView::registerContainerQueryBox(const RenderBox& box) 966 { 967 m_containerQueryBoxes.add(box); 968 } 969 970 void RenderView::unregisterContainerQueryBox(const RenderBox& box) 971 { 972 m_containerQueryBoxes.remove(box); 973 } 974 965 975 } // namespace WebCore -
trunk/Source/WebCore/rendering/RenderView.h
r285345 r289457 30 30 #include <wtf/HashSet.h> 31 31 #include <wtf/ListHashSet.h> 32 #include <wtf/WeakHashSet.h> 32 33 33 34 namespace WebCore { … … 205 206 const HashSet<const RenderBox*>& boxesWithScrollSnapPositions() { return m_boxesWithScrollSnapPositions; } 206 207 208 void registerContainerQueryBox(const RenderBox&); 209 void unregisterContainerQueryBox(const RenderBox&); 210 const WeakHashSet<const RenderBox>& containerQueryBoxes() const { return m_containerQueryBoxes; } 211 207 212 private: 208 213 void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, OptionSet<MapCoordinatesMode>, bool* wasFixed) const override; … … 271 276 272 277 HashSet<const RenderBox*> m_boxesWithScrollSnapPositions; 278 WeakHashSet<const RenderBox> m_containerQueryBoxes; 273 279 }; 274 280 -
trunk/Source/WebCore/style/StyleScope.cpp
r287325 r289457 42 42 #include "Logging.h" 43 43 #include "ProcessingInstruction.h" 44 #include "RenderView.h" 44 45 #include "SVGElementTypeHelpers.h" 45 46 #include "SVGStyleElement.h" … … 783 784 } 784 785 786 bool Scope::updateQueryContainerState() 787 { 788 ASSERT(!m_shadowRoot); 789 ASSERT(m_document.renderView()); 790 791 auto previousStates = WTFMove(m_queryContainerStates); 792 m_queryContainerStates.clear(); 793 794 Vector<Element*> changedContainers; 795 796 for (auto& containerRenderer : m_document.renderView()->containerQueryBoxes()) { 797 auto* containerElement = containerRenderer.element(); 798 if (!containerElement) 799 continue; 800 auto size = containerRenderer.size(); 801 auto it = previousStates.find(*containerElement); 802 bool changed = it == previousStates.end() || it->value != size; 803 if (changed) 804 changedContainers.append(containerElement); 805 m_queryContainerStates.add(*containerElement, size); 806 } 807 808 for (auto* toInvalidate : changedContainers) 809 toInvalidate->invalidateForQueryContainerChange(); 810 811 return !changedContainers.isEmpty(); 812 } 813 785 814 HTMLSlotElement* assignedSlotForScopeOrdinal(const Element& element, ScopeOrdinal scopeOrdinal) 786 815 { -
trunk/Source/WebCore/style/StyleScope.h
r287325 r289457 28 28 #pragma once 29 29 30 #include "LayoutSize.h" 30 31 #include "MediaQueryEvaluator.h" 31 32 #include "StyleScopeOrdinal.h" … … 39 40 #include <wtf/RefPtr.h> 40 41 #include <wtf/Vector.h> 42 #include <wtf/WeakHashMap.h> 41 43 #include <wtf/text/WTFString.h> 42 44 … … 128 130 static Scope* forOrdinal(Element&, ScopeOrdinal); 129 131 132 bool updateQueryContainerState(); 133 130 134 private: 131 135 Scope& documentScope(); … … 202 206 203 207 std::optional<MediaQueryViewportState> m_viewportStateOnPreviousMediaQueryEvaluation; 208 WeakHashMap<Element, LayoutSize> m_queryContainerStates; 204 209 205 210 // FIXME: These (and some things above) are only relevant for the root scope.
Note: See TracChangeset
for help on using the changeset viewer.