Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

A stylesheet added during a press, a hover or a focus no longer crashes the page

shinyobjectzf321704e7723
diff --git a/engine/page/host/tests/restyle.rs b/engine/page/host/tests/restyle.rs
new file mode 100644
index 00000000..41dae222
--- /dev/null
+++ b/engine/page/host/tests/restyle.rs
@@ -0,0 +1,21 @@
+//! A stylesheet added while something is focused, hovered or pressed (a page that adds its styles as it draws: a sheet, a
+//! dialog). raea.app's window crashed on it (11-24: Approve pressed): the pressed element's snapshot holds its state and no
+//! attributes, and stylo's stylesheet invalidation asked it for the class and id it had.
+use bevy::prelude::*;
+
+#[test]
+fn a_stylesheet_added_while_an_element_is_focused() {
+ let app = App::new();
+ let at = raea_sys_page::Page { size: UVec2::new(400, 300), scale: 1.0 };
+ let config = raea_sys_page::providers::config_in(app.world(), at, None);
+ let html = r#"<head><style>button:focus { color: rgb(1, 2, 3) }</style></head><body><button id="go" class="b">Go</button><div id="more"></div></body>"#;
+ let mut doc = blitz_html::HtmlDocument::from_html(html, config).into_inner();
+ doc.resolve(0.0);
+ let go = doc.get_element_by_id("go").unwrap();
+ doc.set_focus_to(go);
+ let more = doc.get_element_by_id("more").unwrap();
+ doc.mutate().set_inner_html(more, "<style>.b { width: 40px; display: block } #go { height: 20px }</style>");
+ doc.resolve(0.0);
+ assert_eq!(doc.resolved_style_value(go, "width"), "40px");
+ assert_eq!(doc.resolved_style_value(go, "height"), "20px");
+}
diff --git a/vendor/stylo/invalidation/stylesheets.rs b/vendor/stylo/invalidation/stylesheets.rs
index 751ac135..70be732a 100644
--- a/vendor/stylo/invalidation/stylesheets.rs
+++ b/vendor/stylo/invalidation/stylesheets.rs
@@ -202,6 +202,10 @@ impl StylesheetInvalidationSet {
{
debug_assert!(!self.style_fully_invalid);
+ // raea: a snapshot of state alone (a hover, a press, the focus) has no old class or id to ask for, and Servo's
+ // panics when asked (raea.app's window crashed as Approve was pressed: engine/page/host/tests/restyle.rs)
+ let snapshot = snapshot.filter(|s| s.has_attrs());
+
let mut kind = InvalidationKind::None;
if !self.buckets.classes.is_empty() {
diff --git a/vendor/vendor.toml b/vendor/vendor.toml
index dbec373c..c5ced7ee 100644
--- a/vendor/vendor.toml
+++ b/vendor/vendor.toml
@@ -98,7 +98,7 @@ exit = "parley carrying the fix"
path = "vendor/stylo"
upstream = "crates.io:0.22.0"
kind = "patch"
-reason = "line-clamp, text-wrap-style (with Chrome's pretty) and pointer-events' SVG keywords (all, visible, painted...) for Servo too, Gecko-only upstream; url() filters; ::-webkit-slider-thumb and ::-moz-range-thumb as the slider thumb; unknown vendor-prefixed properties reported like any other, so a page can be told what it lost (raea #34); background-clip's text value for Servo too (#37); text-autospace for Servo too, initial no-autospace as Chrome's (#44); vector-effect for Servo too (#45)"
+reason = "line-clamp, text-wrap-style (with Chrome's pretty) and pointer-events' SVG keywords (all, visible, painted...) for Servo too, Gecko-only upstream; url() filters; ::-webkit-slider-thumb and ::-moz-range-thumb as the slider thumb; unknown vendor-prefixed properties reported like any other, so a page can be told what it lost (raea #34); background-clip's text value for Servo too (#37); text-autospace for Servo too, initial no-autospace as Chrome's (#44); vector-effect for Servo too (#45); a stylesheet's invalidation doesn't ask a state-only snapshot for its class or id (it panicked)"
exit = "Servo's stylo enabling them"
[anyrender]