From 8bb0be7d4fc4bbb8af91dccd690ba1bf38064e53 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 2 Apr 2023 08:48:29 +0200 Subject: [PATCH] LibWeb: Don't apply presentational hints to associated pseudo elements CSS properties generated by presentational hints in content attributes should not leak into pseudo elements. --- ...ould-not-be-affected-by-presentational-hints.txt | 13 +++++++++++++ ...uld-not-be-affected-by-presentational-hints.html | 11 +++++++++++ Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 3 ++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/css-pseudo-element-should-not-be-affected-by-presentational-hints.txt create mode 100644 Tests/LibWeb/Layout/input/css-pseudo-element-should-not-be-affected-by-presentational-hints.html diff --git a/Tests/LibWeb/Layout/expected/css-pseudo-element-should-not-be-affected-by-presentational-hints.txt b/Tests/LibWeb/Layout/expected/css-pseudo-element-should-not-be-affected-by-presentational-hints.txt new file mode 100644 index 0000000000..2e7686b39c --- /dev/null +++ b/Tests/LibWeb/Layout/expected/css-pseudo-element-should-not-be-affected-by-presentational-hints.txt @@ -0,0 +1,13 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (1,1) content-size 798x47.835937 children: not-inline + BlockContainer at (10,10) content-size 780x29.835937 children: not-inline + TableWrapper <(anonymous)> at (10,10) content-size 104x29.835937 children: not-inline + TableBox at (11,11) content-size 104x27.835937 children: not-inline + TableRowGroupBox at (11,11) content-size 104x27.835937 children: not-inline + TableRowBox at (11,11) content-size 104x27.835937 children: not-inline + TableCellBox
at (13,13) content-size 100x23.835937 children: not-inline + BlockContainer <(anonymous)> at (14,14) content-size 98x21.835937 children: inline + line 0 width: 0, height: 21.835937, bottom: 21.835937, baseline: 16.914062 + frag 0 from TextNode start: 0, length: 0, rect: [14,14 0x21.835937] + "" + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/css-pseudo-element-should-not-be-affected-by-presentational-hints.html b/Tests/LibWeb/Layout/input/css-pseudo-element-should-not-be-affected-by-presentational-hints.html new file mode 100644 index 0000000000..ba7142ee07 --- /dev/null +++ b/Tests/LibWeb/Layout/input/css-pseudo-element-should-not-be-affected-by-presentational-hints.html @@ -0,0 +1,11 @@ +
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 61aea66ad2..da5e080303 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -912,7 +912,8 @@ ErrorOr StyleComputer::compute_cascaded_values(StyleProperties& style, DOM // FIXME: Normal user declarations // Author presentational hints (NOTE: The spec doesn't say exactly how to prioritize these.) - element.apply_presentational_hints(style); + if (!pseudo_element.has_value()) + element.apply_presentational_hints(style); // Normal author declarations cascade_declarations(style, element, pseudo_element, matching_rule_set.author_rules, CascadeOrigin::Author, Important::No);