Skip to content

Truly independent web browser

LibWeb: Rebuild an element's box when its appearance changes

Andreas Kling85ad44d41352
diff --git a/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs b/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs
index ac6f5bea3cd..fae3ddc42e5 100644
--- a/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs
@@ -556,7 +556,7 @@ fn property_invalidation(property: u16, old: ComputedValuesView<'_>, new: Comput
}
if matches!(
property,
- property_id::CONTENT | property_id::CONTENT_VISIBILITY | property_id::TEXT_TRANSFORM
+ property_id::APPEARANCE | property_id::CONTENT | property_id::CONTENT_VISIBILITY | property_id::TEXT_TRANSFORM
) {
return StyleInvalidation::rebuild_layout_tree_from(REBUILD_ROOT_SELF);
}
diff --git a/Tests/LibWeb/Text/expected/css/appearance-change-rebuilds-box.txt b/Tests/LibWeb/Text/expected/css/appearance-change-rebuilds-box.txt
new file mode 100644
index 00000000000..ad502d1b20b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/appearance-change-rebuilds-box.txt
@@ -0,0 +1,12 @@
+<input> with its native appearance: 169.6875x20, the tree matches a full rebuild: true
+<input> given none: 169.6875x20, the tree matches a full rebuild: true
+<input> back: 169.6875x20, the tree matches a full rebuild: true
+<input type=checkbox> with its native appearance: 13x13, the tree matches a full rebuild: true
+<input type=checkbox> given none: 0x0, the tree matches a full rebuild: true
+<input type=checkbox> back: 13x13, the tree matches a full rebuild: true
+<input type=radio> with its native appearance: 12x12, the tree matches a full rebuild: true
+<input type=radio> given none: 0x0, the tree matches a full rebuild: true
+<input type=radio> back: 12x12, the tree matches a full rebuild: true
+<input type=range> with its native appearance: 129x16, the tree matches a full rebuild: true
+<input type=range> given none: 129x16, the tree matches a full rebuild: true
+<input type=range> back: 129x16, the tree matches a full rebuild: true
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/restyle-form-controls.txt b/Tests/LibWeb/Text/expected/css/style-engine/restyle-form-controls.txt
index 4597a651fd7..d8e94c72c48 100644
--- a/Tests/LibWeb/Text/expected/css/style-engine/restyle-form-controls.txt
+++ b/Tests/LibWeb/Text/expected/css/style-engine/restyle-form-controls.txt
@@ -1,5 +1,5 @@
auto: checkbox auto 13x13, select auto true
-none: checkbox none 13x13, select none true
+none: checkbox none 0x0, select none true
select width back to auto: false
auto again: checkbox auto 13x13, select auto true
select width back to auto: true
diff --git a/Tests/LibWeb/Text/input/css/appearance-change-rebuilds-box.html b/Tests/LibWeb/Text/input/css/appearance-change-rebuilds-box.html
new file mode 100644
index 00000000000..2bec336136d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/appearance-change-rebuilds-box.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ .none { appearance: none; }
+</style>
+<body>
+<script>
+ test(() => {
+ for (const html of ["<input>", "<input type=checkbox>", "<input type=radio>", "<input type=range>"]) {
+ const parent = document.createElement("div");
+ parent.innerHTML = html;
+ document.body.append(parent);
+ const input = parent.firstChild;
+ const report = label => {
+ const { width, height } = input.getBoundingClientRect();
+ println(`${html} ${label}: ${width}x${height}, the tree matches a full rebuild: ${internals.compareLayoutTreeWithFullRebuild().matches}`);
+ };
+ report("with its native appearance");
+ input.className = "none";
+ report("given none");
+ input.className = "";
+ report("back");
+ parent.remove();
+ }
+ });
+</script>