aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_dom/document.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-04-04 13:34:35 +0200
committerGitHub <noreply@github.com>2024-04-04 11:34:35 +0000
commit24c3a2df1eb63a75274eb219128f305aabc236c2 (patch)
tree83d675d70fe18d617426e8f9e1be28513427a008 /components/script/layout_dom/document.rs
parentdf457c43c8f78d18e4e6fbc19910e35f82249b63 (diff)
downloadservo-24c3a2df1eb63a75274eb219128f305aabc236c2.tar.gz
servo-24c3a2df1eb63a75274eb219128f305aabc236c2.zip
script: Make layout DOM wrappers not generic on layout data (#31994)
Remove the type parameter from the layout DOM wrappers. This is possible now that style and layout data are separate and the `Any` nature of the layout data is exposed in the wrappers. Removing the phantom data member of the wrappers also allows using the default `derive` implementations for things like `Clone`, `Copy`, and `PartialEq`.
Diffstat (limited to 'components/script/layout_dom/document.rs')
-rw-r--r--components/script/layout_dom/document.rs35
1 files changed, 9 insertions, 26 deletions
diff --git a/components/script/layout_dom/document.rs b/components/script/layout_dom/document.rs
index f55c198ef48..c3cbd7a6c22 100644
--- a/components/script/layout_dom/document.rs
+++ b/components/script/layout_dom/document.rs
@@ -2,9 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-use std::marker::PhantomData;
-
-use script_layout_interface::wrapper_traits::LayoutDataTrait;
use selectors::matching::QuirksMode;
use style::dom::{TDocument, TNode};
use style::shared_lock::{
@@ -18,25 +15,14 @@ use crate::dom::node::{LayoutNodeHelpers, Node, NodeFlags};
use crate::layout_dom::{ServoLayoutElement, ServoLayoutNode, ServoShadowRoot};
// A wrapper around documents that ensures ayout can only ever access safe properties.
-pub struct ServoLayoutDocument<'dom, LayoutDataType: LayoutDataTrait> {
+#[derive(Clone, Copy)]
+pub struct ServoLayoutDocument<'dom> {
/// The wrapped private DOM Document
document: LayoutDom<'dom, Document>,
-
- /// A PhantomData that is used to track the type of the stored layout data.
- phantom: PhantomData<LayoutDataType>,
-}
-
-impl<'dom, LayoutDataType: LayoutDataTrait> Clone for ServoLayoutDocument<'dom, LayoutDataType> {
- fn clone(&self) -> Self {
- *self
- }
}
-impl<'dom, LayoutDataType: LayoutDataTrait> Copy for ServoLayoutDocument<'dom, LayoutDataType> {}
-impl<'ld, LayoutDataType: LayoutDataTrait> ::style::dom::TDocument
- for ServoLayoutDocument<'ld, LayoutDataType>
-{
- type ConcreteNode = ServoLayoutNode<'ld, LayoutDataType>;
+impl<'ld> ::style::dom::TDocument for ServoLayoutDocument<'ld> {
+ type ConcreteNode = ServoLayoutNode<'ld>;
fn as_node(&self) -> Self::ConcreteNode {
ServoLayoutNode::from_layout_js(self.document.upcast())
@@ -55,8 +41,8 @@ impl<'ld, LayoutDataType: LayoutDataTrait> ::style::dom::TDocument
}
}
-impl<'ld, LayoutDataType: LayoutDataTrait> ServoLayoutDocument<'ld, LayoutDataType> {
- pub fn root_element(&self) -> Option<ServoLayoutElement<'ld, LayoutDataType>> {
+impl<'ld> ServoLayoutDocument<'ld> {
+ pub fn root_element(&self) -> Option<ServoLayoutElement<'ld>> {
self.as_node()
.dom_children()
.flat_map(|n| n.as_element())
@@ -75,7 +61,7 @@ impl<'ld, LayoutDataType: LayoutDataTrait> ServoLayoutDocument<'ld, LayoutDataTy
self.document.style_shared_lock()
}
- pub fn shadow_roots(&self) -> Vec<ServoShadowRoot<LayoutDataType>> {
+ pub fn shadow_roots(&self) -> Vec<ServoShadowRoot> {
unsafe {
self.document
.shadow_roots()
@@ -104,10 +90,7 @@ impl<'ld, LayoutDataType: LayoutDataTrait> ServoLayoutDocument<'ld, LayoutDataTy
}
}
- pub fn from_layout_js(doc: LayoutDom<'ld, Document>) -> Self {
- ServoLayoutDocument {
- document: doc,
- phantom: PhantomData,
- }
+ pub fn from_layout_js(document: LayoutDom<'ld, Document>) -> Self {
+ ServoLayoutDocument { document }
}
}