Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (290379 => 290380)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-02-23 18:14:59 UTC (rev 290380)
@@ -1,3 +1,15 @@
+2022-02-23 Antti Koivisto <[email protected]>
+
+ [CSS Container Queries] offsetWidth/Height and similar should update layout for container queries
+ https://bugs.webkit.org/show_bug.cgi?id=237079
+
+ Reviewed by Simon Fraser.
+
+ * web-platform-tests/css/css-contain/container-queries/auto-scrollbars-expected.txt:
+ * web-platform-tests/css/css-contain/container-queries/inline-size-containment-expected.txt:
+ * web-platform-tests/css/css-contain/container-queries/inline-size-containment-vertical-rl-expected.txt:
+ * web-platform-tests/css/css-contain/container-queries/transition-scrollbars-expected.txt:
+
2022-02-22 Antti Koivisto <[email protected]>
[CSS container Queries] getComputedStyle should update style for invalid query containers
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/auto-scrollbars-expected.txt (290379 => 290380)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/auto-scrollbars-expected.txt 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/auto-scrollbars-expected.txt 2022-02-23 18:14:59 UTC (rev 290380)
@@ -1,4 +1,4 @@
-FAIL Initial layout - expecting a scrollbar without overflowing content instead of overflowing content without a scrollbar assert_equals: Layout with a scrollbar means the container query applies expected "50px" but got "100px"
+FAIL Initial layout - expecting a scrollbar without overflowing content instead of overflowing content without a scrollbar assert_less_than: Expects a vertical scrollbar expected a number less than 100 but got 100
FAIL Same result after a reflow assert_less_than: Expects a vertical scrollbar expected a number less than 100 but got 100
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-containment-expected.txt (290379 => 290380)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-containment-expected.txt 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-containment-expected.txt 2022-02-23 18:14:59 UTC (rev 290380)
@@ -1,3 +1,3 @@
-FAIL inline-size containment only assert_equals: expected 400 but got 20
+PASS inline-size containment only
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-containment-vertical-rl-expected.txt (290379 => 290380)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-containment-vertical-rl-expected.txt 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-containment-vertical-rl-expected.txt 2022-02-23 18:14:59 UTC (rev 290380)
@@ -1,3 +1,3 @@
-FAIL inline-size containment only assert_equals: expected 50 but got 400
+PASS inline-size containment only
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/transition-scrollbars-expected.txt (290379 => 290380)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/transition-scrollbars-expected.txt 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/transition-scrollbars-expected.txt 2022-02-23 18:14:59 UTC (rev 290380)
@@ -1,4 +1,4 @@
Foo bar foo bar foo Foo bar foo bar foo Foo bar foo bar foo Foo bar foo bar foo Foo bar foo bar foo
-FAIL Scrollbars do not cause a transition of background-color assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 255)"
+FAIL Scrollbars do not cause a transition of background-color assert_equals: expected "rgb(0, 0, 255)" but got "rgb(0, 64, 128)"
Modified: trunk/Source/WebCore/ChangeLog (290379 => 290380)
--- trunk/Source/WebCore/ChangeLog 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/Source/WebCore/ChangeLog 2022-02-23 18:14:59 UTC (rev 290380)
@@ -1,3 +1,34 @@
+2022-02-23 Antti Koivisto <[email protected]>
+
+ [CSS Container Queries] offsetWidth/Height and similar should update layout for container queries
+ https://bugs.webkit.org/show_bug.cgi?id=237079
+
+ Reviewed by Simon Fraser.
+
+ Fix
+
+ css/css-contain/container-queries/inline-size-containment.html
+ css/css-contain/container-queries/inline-size-containment-vertical-rl.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::updateLayout):
+
+ Make iterative instead of recursive.
+
+ (WebCore::Document::updateLayoutIfDimensionsOutOfDate):
+
+ Check for query containers.
+ Call local updateLayout instead of the FrameViewLayoutContext one.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
+ * style/StyleScope.cpp:
+ (WebCore::Style::Scope::updateQueryContainerState):
+
+ Add protection against infinite layout/invalidation cycle with unstable layouts.
+
+ * style/StyleScope.h:
+
2022-02-23 Andres Gonzalez <[email protected]>
Fix for assert crash in AccessibilityRenderObject::visiblePositionForIndex.
Modified: trunk/Source/WebCore/dom/Document.cpp (290379 => 290380)
--- trunk/Source/WebCore/dom/Document.cpp 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/Source/WebCore/dom/Document.cpp 2022-02-23 18:14:59 UTC (rev 290380)
@@ -2208,8 +2208,15 @@
frameView->layoutContext().layout();
- if (styleScope().updateQueryContainerState())
- updateLayout();
+ Style::Scope::QueryContainerUpdateContext queryContainerUpdateContext;
+ while (styleScope().updateQueryContainerState(queryContainerUpdateContext)) {
+ updateStyleIfNeeded();
+
+ if (!frameView->layoutContext().needsLayout())
+ break;
+
+ frameView->layoutContext().layout();
+ }
}
void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks runPostLayoutTasks)
@@ -2313,7 +2320,12 @@
previousBox = currentBox;
currentBox = downcast<RenderBox>(currRenderer);
-
+
+ if (currentBox->style().containerType() != ContainerType::None) {
+ requireFullLayout = true;
+ break;
+ }
+
// If a box needs layout for itself or if a box has changed children and sizes its width to
// its content, then require a full layout.
if (currentBox->selfNeedsLayout() ||
@@ -2348,9 +2360,9 @@
StackStats::LayoutCheckPoint layoutCheckPoint;
- // Only do a layout if changes have occurred that make it necessary.
- if (requireFullLayout && frameView && renderView() && (frameView->layoutContext().isLayoutPending() || renderView()->needsLayout()))
- frameView->layoutContext().layout();
+ // Only do a layout if changes have occurred that make it necessary.
+ if (requireFullLayout)
+ updateLayout();
return requireFullLayout;
}
Modified: trunk/Source/WebCore/page/FrameView.cpp (290379 => 290380)
--- trunk/Source/WebCore/page/FrameView.cpp 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/Source/WebCore/page/FrameView.cpp 2022-02-23 18:14:59 UTC (rev 290380)
@@ -4541,6 +4541,8 @@
return descendantsDeque.first().ptr();
};
+ Style::Scope::QueryContainerUpdateContext queryContainerUpdateContext;
+
for (unsigned i = 0; i < maxUpdatePasses; ++i) {
bool didWork = false;
DescendantsDeque deque;
@@ -4549,7 +4551,7 @@
didWork = true;
if (view->needsLayout()) {
view->layoutContext().layout();
- view->frame().document()->styleScope().updateQueryContainerState();
+ view->frame().document()->styleScope().updateQueryContainerState(queryContainerUpdateContext);
didWork = true;
}
}
Modified: trunk/Source/WebCore/style/StyleScope.cpp (290379 => 290380)
--- trunk/Source/WebCore/style/StyleScope.cpp 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/Source/WebCore/style/StyleScope.cpp 2022-02-23 18:14:59 UTC (rev 290380)
@@ -783,7 +783,7 @@
return m_shadowRoot && m_shadowRoot->mode() == ShadowRootMode::UserAgent;
}
-bool Scope::updateQueryContainerState()
+bool Scope::updateQueryContainerState(QueryContainerUpdateContext& context)
{
ASSERT(!m_shadowRoot);
ASSERT(m_document.renderView());
@@ -791,7 +791,7 @@
auto previousStates = WTFMove(m_queryContainerStates);
m_queryContainerStates.clear();
- Vector<Element*> changedContainers;
+ Vector<Element*> containersToInvalidate;
for (auto& containerRenderer : m_document.renderView()->containerQueryBoxes()) {
auto* containerElement = containerRenderer.element();
@@ -814,15 +814,16 @@
auto it = previousStates.find(*containerElement);
bool changed = it == previousStates.end() || sizeChanged(it->value);
- if (changed)
- changedContainers.append(containerElement);
+ // Protect against unstable layout by invalidating only once per container.
+ if (changed && context.invalidatedContainers.add(containerElement).isNewEntry)
+ containersToInvalidate.append(containerElement);
m_queryContainerStates.add(*containerElement, size);
}
- for (auto* toInvalidate : changedContainers)
+ for (auto* toInvalidate : containersToInvalidate)
toInvalidate->invalidateForQueryContainerChange();
- return !changedContainers.isEmpty();
+ return !containersToInvalidate.isEmpty();
}
HTMLSlotElement* assignedSlotForScopeOrdinal(const Element& element, ScopeOrdinal scopeOrdinal)
Modified: trunk/Source/WebCore/style/StyleScope.h (290379 => 290380)
--- trunk/Source/WebCore/style/StyleScope.h 2022-02-23 18:09:17 UTC (rev 290379)
+++ trunk/Source/WebCore/style/StyleScope.h 2022-02-23 18:14:59 UTC (rev 290380)
@@ -129,7 +129,10 @@
static Scope& forNode(Node&);
static Scope* forOrdinal(Element&, ScopeOrdinal);
- bool updateQueryContainerState();
+ struct QueryContainerUpdateContext {
+ HashSet<Element*> invalidatedContainers;
+ };
+ bool updateQueryContainerState(QueryContainerUpdateContext&);
private:
Scope& documentScope();