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.
This commit is contained in:
Oriol Brufau 2024-01-30 13:38:20 +01:00 committed by GitHub
parent a07ad85eaa
commit a4cc0c563e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -94,7 +94,9 @@ use crate::dom::create::create_element;
use crate::dom::customelementregistry::{ use crate::dom::customelementregistry::{
CallbackReaction, CustomElementDefinition, CustomElementReaction, CustomElementState, 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::documentfragment::DocumentFragment;
use crate::dom::domrect::DOMRect; use crate::dom::domrect::DOMRect;
use crate::dom::domtokenlist::DOMTokenList; use crate::dom::domtokenlist::DOMTokenList;
@ -3380,7 +3382,10 @@ impl Element {
.and_then(|data| data.client_rect.as_ref()) .and_then(|data| data.client_rect.as_ref())
.and_then(|rect| rect.get().ok()) .and_then(|rect| rect.get().ok())
{ {
if doc.needs_reflow().is_none() { if matches!(
doc.needs_reflow(),
None | Some(ReflowTriggerCondition::PaintPostponed)
) {
return rect; return rect;
} }
} }