From df0118dd104318e2d0a1400aaf880c1826769e78 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 27 Mar 2020 15:16:57 +0100 Subject: Move PendingRestyle to the style_layout_interface crate --- components/script/dom/document.rs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'components/script/dom/document.rs') diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 7c82334c8ef..3f60524e114 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -133,7 +133,7 @@ use percent_encoding::percent_decode; use profile_traits::ipc as profile_ipc; use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType}; use ref_slice::ref_slice; -use script_layout_interface::message::{Msg, ReflowGoal}; +use script_layout_interface::message::{Msg, PendingRestyle, ReflowGoal}; use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType}; use script_traits::{ MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress, WheelDelta, @@ -157,7 +157,7 @@ use style::attr::AttrValue; use style::context::QuirksMode; use style::invalidation::element::restyle_hints::RestyleHint; use style::media_queries::{Device, MediaType}; -use style::selector_parser::{RestyleDamage, Snapshot}; +use style::selector_parser::Snapshot; use style::shared_lock::SharedRwLock as StyleSharedRwLock; use style::str::{split_html_space_chars, str_join}; use style::stylesheet_set::DocumentStylesheetSet; @@ -201,29 +201,6 @@ pub enum IsHTMLDocument { NonHTMLDocument, } -#[derive(Debug, MallocSizeOf)] -pub struct PendingRestyle { - /// If this element had a state or attribute change since the last restyle, track - /// the original condition of the element. - pub snapshot: Option, - - /// Any explicit restyles hints that have been accumulated for this element. - pub hint: RestyleHint, - - /// Any explicit restyles damage that have been accumulated for this element. - pub damage: RestyleDamage, -} - -impl PendingRestyle { - pub fn new() -> Self { - PendingRestyle { - snapshot: None, - hint: RestyleHint::empty(), - damage: RestyleDamage::empty(), - } - } -} - /// #[dom_struct] pub struct Document { -- cgit v1.2.3 From 60ca98b753570ce4ce56bc92ddbdd3c0c0e5800d Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 27 Mar 2020 17:04:48 +0100 Subject: Pass pending restyles instead of draining them from layout --- components/script/dom/document.rs | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'components/script/dom/document.rs') diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 3f60524e114..18d6e0cbd59 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -71,7 +71,7 @@ use crate::dom::location::Location; use crate::dom::messageevent::MessageEvent; use crate::dom::mouseevent::MouseEvent; use crate::dom::node::{self, document_from_node, window_from_node, CloneChildrenFlag}; -use crate::dom::node::{LayoutNodeHelpers, Node, NodeDamage, NodeFlags, ShadowIncluding}; +use crate::dom::node::{Node, NodeDamage, NodeFlags, ShadowIncluding}; use crate::dom::nodeiterator::NodeIterator; use crate::dom::nodelist::NodeList; use crate::dom::pagetransitionevent::PageTransitionEvent; @@ -134,6 +134,7 @@ use profile_traits::ipc as profile_ipc; use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType}; use ref_slice::ref_slice; use script_layout_interface::message::{Msg, PendingRestyle, ReflowGoal}; +use script_layout_interface::TrustedNodeAddress; use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType}; use script_traits::{ MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress, WheelDelta, @@ -2606,7 +2607,6 @@ pub enum DocumentSource { #[allow(unsafe_code)] pub trait LayoutDocumentHelpers { unsafe fn is_html_document_for_layout(&self) -> bool; - unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom, PendingRestyle)>; unsafe fn needs_paint_from_layout(&self); unsafe fn will_paint(&self); unsafe fn quirks_mode(&self) -> QuirksMode; @@ -2623,22 +2623,6 @@ impl LayoutDocumentHelpers for LayoutDom { (*self.unsafe_get()).is_html_document } - #[inline] - #[allow(unrooted_must_root)] - unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom, PendingRestyle)> { - let mut elements = (*self.unsafe_get()) - .pending_restyles - .borrow_mut_for_layout(); - // Elements were in a document when they were added to this list, but that - // may no longer be true when the next layout occurs. - let result = elements - .drain() - .map(|(k, v)| (k.to_layout(), v)) - .filter(|&(ref k, _)| k.upcast::().get_flag(NodeFlags::IS_CONNECTED)) - .collect(); - result - } - #[inline] unsafe fn needs_paint_from_layout(&self) { (*self.unsafe_get()).needs_paint.set(true) @@ -3579,6 +3563,16 @@ impl Document { (None, None) => ElementLookupResult::None, } } + + #[allow(unrooted_must_root)] + pub fn drain_pending_restyles(&self) -> Vec<(TrustedNodeAddress, PendingRestyle)> { + self.pending_restyles + .borrow_mut() + .drain() + .filter(|(k, _)| k.upcast::().get_flag(NodeFlags::IS_CONNECTED)) + .map(|(k, v)| (k.upcast::().to_trusted_node_address(), v)) + .collect() + } } impl Element { -- cgit v1.2.3 From dba6a635e5df980b2837495aae59711739c23716 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 27 Mar 2020 17:37:56 +0100 Subject: Give a lifetime parameter to LayoutDom --- components/script/dom/document.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'components/script/dom/document.rs') diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 18d6e0cbd59..f119429e01f 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2617,7 +2617,7 @@ pub trait LayoutDocumentHelpers { } #[allow(unsafe_code)] -impl LayoutDocumentHelpers for LayoutDom { +impl LayoutDocumentHelpers for LayoutDom<'_, Document> { #[inline] unsafe fn is_html_document_for_layout(&self) -> bool { (*self.unsafe_get()).is_html_document -- cgit v1.2.3