Truly independent web browser
LibWeb: Replace selected inline font size wrappers
Andreas Klingf3e34da221b9
diff --git a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp b/Libraries/LibWeb/Editing/Internal/Algorithms.cppindex 27b168ceedf..623362c928a 100644--- a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp+++ b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp@@ -3999,7 +3999,16 @@ void push_down_values(Utf16FlyString const& command, GC::Ref<DOM::Node> node, Op// 10. If the effective command value of command is not loosely equivalent to new value on the parent of the last// member of ancestor list, and new value is not null, abort this algorithm.- if (new_value.has_value() && ancestor_list.last()->parent()+ // INTEROP: Replace simple inline font size wrappers even when no ancestor already has the requested size.+ // Keep container styles intact.+ auto can_replace_inline_font_size = command == CommandNames::fontSize+ && all_of(ancestor_list, [](auto const& ancestor) {+ if (!is_simple_modifiable_element(ancestor))+ return false;+ auto display = resolved_display(ancestor);+ return display.has_value() && display->is_inline_outside() && display->is_flow_inside();+ });+ if (!can_replace_inline_font_size && new_value.has_value() && ancestor_list.last()->parent()&& !values_are_loosely_equivalent(command, optional_utf16_view(effective_command_value(ancestor_list.last()->parent(), command)), new_value))return;diff --git a/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]index 21c783ce9c1..b8471bea45e 100644--- a/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]+++ b/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]@@ -2,8 +2,8 @@ Harness status: OKFound 1000 tests-975 Pass-25 Fail+982 Pass+18 FailPass [["stylewithcss","false"],["fontsize","4"]] "<table><tbody data-start=0 data-end=1><tr><td>foo<td>bar<td>baz</table>" queryCommandValue("fontsize") beforePass [["stylewithcss","false"],["fontsize","4"]] "<table><tbody data-start=0 data-end=1><tr><td>foo<td>bar<td>baz</table>" queryCommandIndeterm("fontsize") afterPass [["stylewithcss","false"],["fontsize","4"]] "<table><tbody data-start=0 data-end=1><tr><td>foo<td>bar<td>baz</table>" queryCommandState("fontsize") after@@ -123,7 +123,7 @@ Pass [["stylewithcss","true"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>Pass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>": execCommand("stylewithcss", false, "false") return valuePass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>" checks for modifications to non-editable content-Fail [["stylewithcss","false"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>" compare innerHTML+Pass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>" compare innerHTMLPass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>" queryCommandState("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>foo[bar]baz</font>" queryCommandValue("stylewithcss") before@@ -349,7 +349,7 @@ Pass [["stylewithcss","false"],["fontsize","4"]] "foo<span style=\"font-size: xxPass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>": execCommand("stylewithcss", false, "true") return valuePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" checks for modifications to non-editable content-Fail [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" compare innerHTML+Pass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" compare innerHTMLPass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" queryCommandState("stylewithcss") beforePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" queryCommandValue("stylewithcss") before@@ -365,7 +365,7 @@ Pass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: xx-smaPass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>": execCommand("stylewithcss", false, "false") return valuePass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" checks for modifications to non-editable content-Fail [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" compare innerHTML+Pass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" compare innerHTMLPass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" queryCommandState("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: xx-small\">foo[bar]baz</span>" queryCommandValue("stylewithcss") before@@ -550,7 +550,7 @@ Pass [["stylewithcss","false"],["fontsize","4"]] "foo<span style=\"font-size: 2ePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>": execCommand("stylewithcss", false, "true") return valuePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" checks for modifications to non-editable content-Fail [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" compare innerHTML+Pass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" compare innerHTMLPass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" queryCommandState("stylewithcss") beforePass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" queryCommandValue("stylewithcss") before@@ -566,7 +566,7 @@ Pass [["stylewithcss","true"],["fontsize","4"]] "<span style=\"font-size: 2em\">Pass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>": execCommand("stylewithcss", false, "false") return valuePass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" checks for modifications to non-editable content-Fail [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" compare innerHTML+Pass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" compare innerHTMLPass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" queryCommandState("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "<span style=\"font-size: 2em\">foo[bar]baz</span>" queryCommandValue("stylewithcss") before@@ -968,7 +968,7 @@ Pass [["stylewithcss","true"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>bazPass [["stylewithcss","false"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>baz": execCommand("stylewithcss", false, "false") return valuePass [["stylewithcss","false"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>baz": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","false"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>baz" checks for modifications to non-editable content-Fail [["stylewithcss","false"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>baz" compare innerHTML+Pass [["stylewithcss","false"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>baz" compare innerHTMLPass [["stylewithcss","false"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>baz" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>baz" queryCommandState("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "fo[o<font size=2>b]ar</font>baz" queryCommandValue("stylewithcss") before@@ -1000,7 +1000,7 @@ Pass [["stylewithcss","true"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]azPass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az": execCommand("stylewithcss", false, "false") return valuePass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" checks for modifications to non-editable content-Fail [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" compare innerHTML+Pass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" compare innerHTMLPass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" queryCommandState("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" queryCommandValue("stylewithcss") before\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected] b/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]index f539f08fbf6..334f3cf5494 100644--- a/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]+++ b/Tests/LibWeb/Text/expected/wpt-import/editing/run/[email protected]@@ -2,8 +2,8 @@ Harness status: OKFound 422 tests-394 Pass-28 Fail+397 Pass+25 FailPass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" queryCommandIndeterm("stylewithcss") afterFail [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" queryCommandState("stylewithcss") afterPass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>b]az" queryCommandValue("stylewithcss") after@@ -64,7 +64,7 @@ Pass [["stylewithcss","true"],["fontsize","4"]] "foo[<font size=2>b]ar</font>bazPass [["stylewithcss","false"],["fontsize","4"]] "foo[<font size=2>b]ar</font>baz": execCommand("stylewithcss", false, "false") return valuePass [["stylewithcss","false"],["fontsize","4"]] "foo[<font size=2>b]ar</font>baz": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","false"],["fontsize","4"]] "foo[<font size=2>b]ar</font>baz" checks for modifications to non-editable content-Fail [["stylewithcss","false"],["fontsize","4"]] "foo[<font size=2>b]ar</font>baz" compare innerHTML+Pass [["stylewithcss","false"],["fontsize","4"]] "foo[<font size=2>b]ar</font>baz" compare innerHTMLPass [["stylewithcss","false"],["fontsize","4"]] "foo[<font size=2>b]ar</font>baz" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "foo[<font size=2>b]ar</font>baz" queryCommandState("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "foo[<font size=2>b]ar</font>baz" queryCommandValue("stylewithcss") before@@ -96,7 +96,7 @@ Pass [["stylewithcss","true"],["fontsize","4"]] "foo<font size=2>ba[r</font>]bazPass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>]baz": execCommand("stylewithcss", false, "false") return valuePass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>]baz": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>]baz" checks for modifications to non-editable content-Fail [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>]baz" compare innerHTML+Pass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>]baz" compare innerHTMLPass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>]baz" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>]baz" queryCommandState("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "foo<font size=2>ba[r</font>]baz" queryCommandValue("stylewithcss") before@@ -224,7 +224,7 @@ Pass [["stylewithcss","true"],["fontsize","4"]] "<font size=1>fo[o</font><span sPass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>fo[o</font><span style=font-size:xx-small>b]ar</span>": execCommand("stylewithcss", false, "false") return valuePass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>fo[o</font><span style=font-size:xx-small>b]ar</span>": execCommand("fontsize", false, "4") return valuePass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>fo[o</font><span style=font-size:xx-small>b]ar</span>" checks for modifications to non-editable content-Fail [["stylewithcss","false"],["fontsize","4"]] "<font size=1>fo[o</font><span style=font-size:xx-small>b]ar</span>" compare innerHTML+Pass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>fo[o</font><span style=font-size:xx-small>b]ar</span>" compare innerHTMLPass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>fo[o</font><span style=font-size:xx-small>b]ar</span>" queryCommandIndeterm("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>fo[o</font><span style=font-size:xx-small>b]ar</span>" queryCommandState("stylewithcss") beforePass [["stylewithcss","false"],["fontsize","4"]] "<font size=1>fo[o</font><span style=font-size:xx-small>b]ar</span>" queryCommandValue("stylewithcss") before