diff --git a/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Libraries/LibWeb/Layout/TreeBuilder.cpp index 9f01cae4a60..3b48c0695d3 100644 --- a/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -573,6 +573,8 @@ void TreeBuilder::update_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& return false; }(); + auto prior_quote_nesting_level = m_quote_nesting_level; + if (should_create_layout_node) update_layout_tree_before_children(dom_node, *layout_node, context, element_has_content_visibility_hidden); @@ -617,6 +619,14 @@ void TreeBuilder::update_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& restructure_block_node_in_inline_parent(static_cast(*layout_node)); } + // https://www.w3.org/TR/css-contain-2/#containment-style + // Giving an element style containment has the following effects: + // 2. The effects of the 'content' property’s 'open-quote', 'close-quote', 'no-open-quote' and 'no-close-quote' must + // be scoped to the element’s sub-tree. + if (dom_node.is_element() && (static_cast(dom_node)).has_style_containment()) { + m_quote_nesting_level = prior_quote_nesting_level; + } + dom_node.set_needs_layout_tree_update(false); dom_node.set_child_needs_layout_tree_update(false); } diff --git a/Tests/LibWeb/Crash/wpt-import/css/css-contain/quote-scoping-shadow-dom-crash.html b/Tests/LibWeb/Crash/wpt-import/css/css-contain/quote-scoping-shadow-dom-crash.html new file mode 100644 index 00000000000..dd67e619527 --- /dev/null +++ b/Tests/LibWeb/Crash/wpt-import/css/css-contain/quote-scoping-shadow-dom-crash.html @@ -0,0 +1,20 @@ + + + + + +
+ + +
+ + diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-001-ref.html new file mode 100644 index 00000000000..0b0e9c467ac --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-001-ref.html @@ -0,0 +1,8 @@ + + + + CSS-contain test reference + +

Test passes if the text below is "A1Z" (not including the quotation marks).

+

A1Z
+ diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-002-ref.html new file mode 100644 index 00000000000..c7239e3f485 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-002-ref.html @@ -0,0 +1,8 @@ + + + + CSS-contain test reference + + +

Test passes if the text below is "AZZ" (not including the quotation marks).

+

AZZ
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-003-ref.html new file mode 100644 index 00000000000..2bc8d6730e7 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-003-ref.html @@ -0,0 +1,8 @@ + + + + CSS-contain test reference + + +

Test passes if the text below is "AZ" (not including the quotation marks).

+

AZ
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-empty-style-boundaries-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-empty-style-boundaries-ref.html new file mode 100644 index 00000000000..6437e08eb1a --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-empty-style-boundaries-ref.html @@ -0,0 +1,12 @@ + + + + CSS-contain test: nested style containment and the quote element following a style boundary without any quotes + + + +
+
+ +
+
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-001-ref.html new file mode 100644 index 00000000000..5c1a6203e62 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-001-ref.html @@ -0,0 +1,7 @@ + + +CSS-contain test reference: style containment dynamic containment set invalidation + + +

Test passes if the text below is "A1(19" (not including the quotation marks).

+

A
1 (
1 9
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-002-ref.html new file mode 100644 index 00000000000..e48a080e921 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-002-ref.html @@ -0,0 +1,7 @@ + + +CSS-contain test reference: style containment dynamic containment set unset invalidation + + +

Test passes if the text below is "A1(+-" (not including the quotation marks).

+

A
1 (
+ -
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-003-ref.html new file mode 100644 index 00000000000..766ad6cbe96 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-003-ref.html @@ -0,0 +1,7 @@ + + +CSS-contain test reference: style containment dynamic containment set unset set invalidation + + +

Test passes if the text below is "A119" (not including the quotation marks).

+

A
1
1 9
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-004-ref.html new file mode 100644 index 00000000000..8280075f004 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-contain/reference/quote-scoping-invalidation-004-ref.html @@ -0,0 +1,7 @@ + + +CSS-contain test reference: style containment invalidation with elements in different subtrees + + +

Test passes if the text below is "A111119" (not including the quotation marks).

+

A
1 1
1 1
1 9
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-001.html new file mode 100644 index 00000000000..9c93a21dd05 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-001.html @@ -0,0 +1,28 @@ + + + + CSS-contain test: style containment and open-quote + + + + + + + + +

Test passes if the text below is "A1Z" (not including the quotation marks).

+

diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-002.html new file mode 100644 index 00000000000..ade90f69fc1 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-002.html @@ -0,0 +1,28 @@ + + + + CSS-contain test: style containment and close-quote + + + + + + + + +

Test passes if the text below is "AZZ" (not including the quotation marks).

+

diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-003.html new file mode 100644 index 00000000000..0d603570f85 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-003.html @@ -0,0 +1,32 @@ + + + + CSS-contain test: style containment and no-open-quote + + + + + + + + +

Test passes if the text below is "AZ" (not including the quotation marks).

+

diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-004.html new file mode 100644 index 00000000000..503c62afb42 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-004.html @@ -0,0 +1,32 @@ + + + + CSS-contain test: style containment and no-close-quote + + + + + + + + +

Test passes if the text below is "AZ" (not including the quotation marks).

+

diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-empty-style-boundaries.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-empty-style-boundaries.html new file mode 100644 index 00000000000..fe4fef0a8a5 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-empty-style-boundaries.html @@ -0,0 +1,13 @@ + + + + CSS-contain test: nested style containment and the quote element following a style boundary without any quotes + + + + +
+
+ +
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-001.html new file mode 100644 index 00000000000..38d6be3c533 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-001.html @@ -0,0 +1,35 @@ + + +CSS-contain test: style containment dynamic containment set invalidation + + + + + + +

Test passes if the text below is "A1(19" (not including the quotation marks).

+

+
+ + +
+ +
+ + diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-002.html new file mode 100644 index 00000000000..cd9026764b1 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-002.html @@ -0,0 +1,37 @@ + + +CSS-contain test: style containment dynamic containment set unset invalidation + + + + + + +

Test passes if the text below is "A1(+-" (not including the quotation marks).

+

+
+ + +
+ +
+ + diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-003.html new file mode 100644 index 00000000000..ad0cc23e26a --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-003.html @@ -0,0 +1,41 @@ + + +CSS-contain test: style containment dynamic containment set unset set invalidation + + + + + + +

Test passes if the text below is "A119" (not including the quotation marks).

+

+
+ + +
+ +
+ + diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-004.html new file mode 100644 index 00000000000..93d45fc97cb --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-contain/quote-scoping-invalidation-004.html @@ -0,0 +1,40 @@ + + +CSS-contain test: style containment invalidation with elements in different subtrees + + + + + + +

Test passes if the text below is "A111119" (not including the quotation marks).

+

+
+ + +
+
+ + +
+ +
+ +