aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_layout_interface
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-03-28 13:37:31 -0400
committerGitHub <noreply@github.com>2020-03-28 13:37:31 -0400
commit15d8c6058bb5fd21036cb35500a0c2f23a9ef7f7 (patch)
treefde1850c9fe7f9050d0342a7c01f76f39985040f /components/script_layout_interface
parente69de9bc9cf5cdd29d1c392c613bc1c1ad4815bf (diff)
parentdba6a635e5df980b2837495aae59711739c23716 (diff)
downloadservo-15d8c6058bb5fd21036cb35500a0c2f23a9ef7f7.tar.gz
servo-15d8c6058bb5fd21036cb35500a0c2f23a9ef7f7.zip
Auto merge of #26048 - nox:layout-2020-transparent-data, r=jdm
Give a lifetime parameter to LayoutDom
Diffstat (limited to 'components/script_layout_interface')
-rw-r--r--components/script_layout_interface/message.rs31
-rw-r--r--components/script_layout_interface/wrapper_traits.rs47
2 files changed, 52 insertions, 26 deletions
diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs
index e48ac42f509..96c4a132368 100644
--- a/components/script_layout_interface/message.rs
+++ b/components/script_layout_interface/message.rs
@@ -23,8 +23,9 @@ use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use style::context::QuirksMode;
use style::dom::OpaqueNode;
+use style::invalidation::element::restyle_hints::RestyleHint;
use style::properties::PropertyId;
-use style::selector_parser::PseudoElement;
+use style::selector_parser::{PseudoElement, RestyleDamage, Snapshot};
use style::stylesheets::Stylesheet;
/// Asynchronous messages that script can send to layout.
@@ -218,6 +219,8 @@ pub struct ScriptReflow {
pub dom_count: u32,
/// The current window origin
pub origin: ImmutableOrigin,
+ /// Restyle snapshot map.
+ pub pending_restyles: Vec<(TrustedNodeAddress, PendingRestyle)>,
}
pub struct LayoutThreadInit {
@@ -234,3 +237,29 @@ pub struct LayoutThreadInit {
pub layout_is_busy: Arc<AtomicBool>,
pub window_size: WindowSizeData,
}
+
+/// A pending restyle.
+#[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<Snapshot>,
+
+ /// 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 {
+ /// Creates a new empty pending restyle.
+ #[inline]
+ pub fn new() -> Self {
+ PendingRestyle {
+ snapshot: None,
+ hint: RestyleHint::empty(),
+ damage: RestyleDamage::empty(),
+ }
+ }
+}
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs
index f5801649810..67b107a86d7 100644
--- a/components/script_layout_interface/wrapper_traits.rs
+++ b/components/script_layout_interface/wrapper_traits.rs
@@ -78,14 +78,14 @@ impl PseudoElementType {
}
/// Trait to abstract access to layout data across various data structures.
-pub trait GetLayoutData {
+pub trait GetLayoutData<'dom> {
fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData>;
}
/// A wrapper so that layout can access only the methods that it should have access to. Layout must
/// only ever see these and must never see instances of `LayoutDom`.
-pub trait LayoutNode: Debug + GetLayoutData + TNode {
- type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode;
+pub trait LayoutNode<'dom>: Debug + GetLayoutData<'dom> + TNode {
+ type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>;
fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode;
/// Returns the type ID of this node.
@@ -109,16 +109,13 @@ pub trait LayoutNode: Debug + GetLayoutData + TNode {
fn is_connected(&self) -> bool;
}
-pub struct ReverseChildrenIterator<ConcreteNode>
-where
- ConcreteNode: LayoutNode,
-{
+pub struct ReverseChildrenIterator<ConcreteNode> {
current: Option<ConcreteNode>,
}
-impl<ConcreteNode> Iterator for ReverseChildrenIterator<ConcreteNode>
+impl<'dom, ConcreteNode> Iterator for ReverseChildrenIterator<ConcreteNode>
where
- ConcreteNode: LayoutNode,
+ ConcreteNode: LayoutNode<'dom>,
{
type Item = ConcreteNode;
fn next(&mut self) -> Option<ConcreteNode> {
@@ -128,16 +125,13 @@ where
}
}
-pub struct TreeIterator<ConcreteNode>
-where
- ConcreteNode: LayoutNode,
-{
+pub struct TreeIterator<ConcreteNode> {
stack: Vec<ConcreteNode>,
}
-impl<ConcreteNode> TreeIterator<ConcreteNode>
+impl<'dom, ConcreteNode> TreeIterator<ConcreteNode>
where
- ConcreteNode: LayoutNode,
+ ConcreteNode: LayoutNode<'dom>,
{
fn new(root: ConcreteNode) -> TreeIterator<ConcreteNode> {
let mut stack = vec![];
@@ -150,9 +144,9 @@ where
}
}
-impl<ConcreteNode> Iterator for TreeIterator<ConcreteNode>
+impl<'dom, ConcreteNode> Iterator for TreeIterator<ConcreteNode>
where
- ConcreteNode: LayoutNode,
+ ConcreteNode: LayoutNode<'dom>,
{
type Item = ConcreteNode;
fn next(&mut self) -> Option<ConcreteNode> {
@@ -164,13 +158,13 @@ where
/// A thread-safe version of `LayoutNode`, used during flow construction. This type of layout
/// node does not allow any parents or siblings of nodes to be accessed, to avoid races.
-pub trait ThreadSafeLayoutNode:
- Clone + Copy + Debug + GetLayoutData + NodeInfo + PartialEq + Sized
+pub trait ThreadSafeLayoutNode<'dom>:
+ Clone + Copy + Debug + GetLayoutData<'dom> + NodeInfo + PartialEq + Sized
{
- type ConcreteNode: LayoutNode<ConcreteThreadSafeLayoutNode = Self>;
+ type ConcreteNode: LayoutNode<'dom, ConcreteThreadSafeLayoutNode = Self>;
type ConcreteElement: TElement;
- type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<ConcreteThreadSafeLayoutNode = Self>
+ type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'dom, ConcreteThreadSafeLayoutNode = Self>
+ ::selectors::Element<Impl = SelectorImpl>;
type ChildrenIterator: Iterator<Item = Self> + Sized;
@@ -313,15 +307,18 @@ pub trait ThreadSafeLayoutNode:
// This trait is only public so that it can be implemented by the gecko wrapper.
// It can be used to violate thread-safety, so don't use it elsewhere in layout!
#[allow(unsafe_code)]
-pub trait DangerousThreadSafeLayoutNode: ThreadSafeLayoutNode {
+pub trait DangerousThreadSafeLayoutNode<'dom>: ThreadSafeLayoutNode<'dom> {
unsafe fn dangerous_first_child(&self) -> Option<Self>;
unsafe fn dangerous_next_sibling(&self) -> Option<Self>;
}
-pub trait ThreadSafeLayoutElement:
- Clone + Copy + Sized + Debug + ::selectors::Element<Impl = SelectorImpl> + GetLayoutData
+pub trait ThreadSafeLayoutElement<'dom>:
+ Clone + Copy + Sized + Debug + ::selectors::Element<Impl = SelectorImpl> + GetLayoutData<'dom>
{
- type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>;
+ type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<
+ 'dom,
+ ConcreteThreadSafeLayoutElement = Self,
+ >;
/// This type alias is just a work-around to avoid writing
///