diff options
author | Anthony Ramine <nox@nox.paris> | 2020-03-27 17:04:48 +0100 |
---|---|---|
committer | Anthony Ramine <nox@nox.paris> | 2020-03-28 15:37:56 +0100 |
commit | 60ca98b753570ce4ce56bc92ddbdd3c0c0e5800d (patch) | |
tree | 67b85630a50c9b5e6ef95234a18b968ee738409e /components/script/dom | |
parent | 400c7012b1fe73a2cf23653e4813b0f80181d069 (diff) | |
download | servo-60ca98b753570ce4ce56bc92ddbdd3c0c0e5800d.tar.gz servo-60ca98b753570ce4ce56bc92ddbdd3c0c0e5800d.zip |
Pass pending restyles instead of draining them from layout
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/document.rs | 30 | ||||
-rw-r--r-- | components/script/dom/window.rs | 5 |
2 files changed, 15 insertions, 20 deletions
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<Element>, PendingRestyle)>; unsafe fn needs_paint_from_layout(&self); unsafe fn will_paint(&self); unsafe fn quirks_mode(&self) -> QuirksMode; @@ -2624,22 +2624,6 @@ impl LayoutDocumentHelpers for LayoutDom<Document> { } #[inline] - #[allow(unrooted_must_root)] - unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom<Element>, 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::<Node>().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::<Node>().get_flag(NodeFlags::IS_CONNECTED)) + .map(|(k, v)| (k.upcast::<Node>().to_trusted_node_address(), v)) + .collect() + } } impl Element { diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 1ea51a5c156..688ced4fda7 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -1617,13 +1617,14 @@ impl Window { reflow_info: Reflow { page_clip_rect: self.page_clip_rect.get(), }, - document: self.Document().upcast::<Node>().to_trusted_node_address(), + document: document.upcast::<Node>().to_trusted_node_address(), stylesheets_changed, window_size: self.window_size.get(), origin: self.origin().immutable().clone(), reflow_goal, script_join_chan: join_chan, - dom_count: self.Document().dom_count(), + dom_count: document.dom_count(), + pending_restyles: document.drain_pending_restyles(), }; self.layout_chan |