From a4cc0c563eb4ff391ae4d5a64f147b8062531b07 Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Tue, 30 Jan 2024 13:38:20 +0100 Subject: [PATCH] Allow using cached client_rect() for paint-only reflow (#31219) PR #31210 avoided the cache for all kinds of reflow, but it's actually fine to use it for ReflowTriggerCondition::PaintPostponed. --- components/script/dom/element.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 6348bb412a9..7d2c9afb2aa 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -94,7 +94,9 @@ use crate::dom::create::create_element; use crate::dom::customelementregistry::{ CallbackReaction, CustomElementDefinition, CustomElementReaction, CustomElementState, }; -use crate::dom::document::{determine_policy_for_token, Document, LayoutDocumentHelpers}; +use crate::dom::document::{ + determine_policy_for_token, Document, LayoutDocumentHelpers, ReflowTriggerCondition, +}; use crate::dom::documentfragment::DocumentFragment; use crate::dom::domrect::DOMRect; use crate::dom::domtokenlist::DOMTokenList; @@ -3380,7 +3382,10 @@ impl Element { .and_then(|data| data.client_rect.as_ref()) .and_then(|rect| rect.get().ok()) { - if doc.needs_reflow().is_none() { + if matches!( + doc.needs_reflow(), + None | Some(ReflowTriggerCondition::PaintPostponed) + ) { return rect; } }