aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md38
-rw-r--r--components/layout/data.rs17
-rw-r--r--components/layout/query.rs36
-rw-r--r--components/layout/traversal.rs4
-rw-r--r--components/layout/wrapper.rs29
-rw-r--r--components/layout_2020/data.rs16
-rw-r--r--components/layout_2020/dom_traversal.rs4
-rw-r--r--components/layout_2020/lib.rs2
-rw-r--r--components/layout_2020/query.rs15
-rw-r--r--components/layout_2020/traversal.rs31
-rw-r--r--components/layout_2020/wrapper.rs19
-rw-r--r--components/layout_thread/dom_wrapper.rs67
-rw-r--r--components/layout_thread/lib.rs16
-rw-r--r--components/layout_thread_2020/dom_wrapper.rs67
-rw-r--r--components/layout_thread_2020/lib.rs15
-rw-r--r--components/script/devtools.rs7
-rw-r--r--components/script/dom/bindings/trace.rs4
-rw-r--r--components/script/dom/element.rs2
-rw-r--r--components/script/dom/node.rs39
-rw-r--r--components/script/dom/webgl_extensions/extensions.rs2
-rw-r--r--components/script/dom/webglrenderingcontext.rs2
-rw-r--r--components/script/dom/window.rs11
-rw-r--r--components/script_layout_interface/lib.rs39
-rw-r--r--components/script_layout_interface/message.rs6
-rw-r--r--components/script_layout_interface/rpc.rs8
-rw-r--r--components/script_layout_interface/wrapper_traits.rs23
-rw-r--r--components/style/attr.rs14
-rw-r--r--tests/unit/style/attr.rs3
-rw-r--r--tests/wpt/metadata/html/rendering/dimension-attributes.html.ini156
-rw-r--r--tests/wpt/metadata/html/rendering/non-replaced-elements/the-hr-element-0/width.html.ini2
30 files changed, 217 insertions, 477 deletions
diff --git a/README.md b/README.md
index 1dc0f4830a8..16b7ca5a913 100644
--- a/README.md
+++ b/README.md
@@ -86,46 +86,14 @@ If you are using **Ubuntu 16.04** or **Linux Mint 18.*** run `export HARFBUZ
If you get an undefined symbol error on `gst_player_get_config` try removing `gir1.2-gst-plugins-bad-1.0` and all old versions of clang, see [#22016](https://github.com/servo/servo/issues/22016)
-If you are on **Ubuntu 14.04** and encountered errors on installing these dependencies involving `libcheese`, see [#6158](https://github.com/servo/servo/issues/6158) for a workaround. You may also need to install gcc 4.9, clang 4.0, and cmake 3.2:
-
-<details>
-gcc 4.9:
-
-```sh
-sudo add-apt-repository ppa:ubuntu-toolchain-r/test
-sudo apt-get update
-sudo apt-get install gcc-4.9 g++-4.9
-sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
-```
-
-clang 4.0:
-
-```sh
-wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
-sudo apt-add-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main"
-sudo apt-get update
-sudo apt-get install -y clang-4.0
-```
-
-cmake 3.2:
-
-```sh
-sudo apt-get install software-properties-common
-sudo add-apt-repository ppa:george-edison55/cmake-3.x
-sudo apt-get update
-sudo apt-get install cmake
-```
-
-</details>
-
#### On Fedora
``` sh
-sudo dnf install python2 python2-virtualenv python2-pip
-./mach bootstrap
+sudo dnf install python3 python3-virtualenv python3-pip
+python3 ./mach bootstrap
```
-If `./mach bootstrap` doesn't work, file a bug, and, run the commands below:
+If `python3 ./mach bootstrap` doesn't work, file a bug, and, run the commands below:
``` sh
sudo dnf install curl libtool gcc-c++ libXi-devel libunwind-devel \
diff --git a/components/layout/data.rs b/components/layout/data.rs
index b965bc44ebd..65d96bae244 100644
--- a/components/layout/data.rs
+++ b/components/layout/data.rs
@@ -6,25 +6,14 @@ use crate::construct::ConstructionResult;
use atomic_refcell::AtomicRefCell;
use script_layout_interface::StyleData;
-#[repr(C)]
-pub struct StyleAndLayoutData {
+pub struct StyleAndLayoutData<'dom> {
/// The style data associated with a node.
- pub style_data: StyleData,
+ pub style_data: &'dom StyleData,
/// The layout data associated with a node.
- pub layout_data: AtomicRefCell<LayoutData>,
-}
-
-impl StyleAndLayoutData {
- pub fn new() -> Self {
- Self {
- style_data: StyleData::new(),
- layout_data: AtomicRefCell::new(LayoutData::new()),
- }
- }
+ pub layout_data: &'dom AtomicRefCell<LayoutData>,
}
/// Data that layout associates with a node.
-#[repr(C)]
pub struct LayoutData {
/// The current results of flow construction for this node. This is either a
/// flow or a `ConstructionItem`. See comments in `construct.rs` for more
diff --git a/components/layout/query.rs b/components/layout/query.rs
index b1e33a1dedf..a5f66cb9dcd 100644
--- a/components/layout/query.rs
+++ b/components/layout/query.rs
@@ -6,7 +6,6 @@
use crate::construct::ConstructionResult;
use crate::context::LayoutContext;
-use crate::data::StyleAndLayoutData;
use crate::display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap};
use crate::display_list::IndexableText;
use crate::flow::{Flow, GetBaseFlow};
@@ -23,7 +22,7 @@ use msg::constellation_msg::PipelineId;
use script_layout_interface::rpc::TextIndexResponse;
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC};
use script_layout_interface::rpc::{NodeGeometryResponse, NodeScrollIdResponse};
-use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse, StyleResponse};
+use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse};
use script_layout_interface::wrapper_traits::{
LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
};
@@ -77,9 +76,6 @@ pub struct LayoutThreadData {
/// A queued response for the offset parent/rect of a node.
pub offset_parent_response: OffsetParentResponse,
- /// A queued response for the style of a node.
- pub style_response: StyleResponse,
-
/// Scroll offsets of scrolling regions.
pub scroll_offsets: ScrollOffsetMap,
@@ -180,12 +176,6 @@ impl LayoutRPC for LayoutRPCImpl {
rw_data.offset_parent_response.clone()
}
- fn style(&self) -> StyleResponse {
- let &LayoutRPCImpl(ref rw_data) = self;
- let rw_data = rw_data.lock().unwrap();
- rw_data.style_response.clone()
- }
-
fn text_index(&self) -> TextIndexResponse {
let &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock().unwrap();
@@ -966,13 +956,6 @@ pub fn process_offset_parent_query(
}
}
-pub fn process_style_query<'dom>(requested_node: impl LayoutNode<'dom>) -> StyleResponse {
- let element = requested_node.as_element().unwrap();
- let data = element.borrow_data();
-
- StyleResponse(data.map(|d| d.styles.primary().clone()))
-}
-
enum InnerTextItem {
Text(String),
RequiredLineBreakCount(u32),
@@ -1036,21 +1019,12 @@ fn inner_text_collection_steps<'dom>(
_ => child,
};
- let element_data = {
- &node.get_style_and_layout_data().as_ref().map(|opaque| {
- &opaque
- .downcast_ref::<StyleAndLayoutData>()
- .unwrap()
- .style_data
- .element_data
- })
+ let element_data = match node.get_style_and_opaque_layout_data() {
+ Some(data) => &data.style_data.element_data,
+ None => continue,
};
- if element_data.is_none() {
- continue;
- }
-
- let style = match element_data.unwrap().borrow().styles.get_primary() {
+ let style = match element_data.borrow().styles.get_primary() {
None => continue,
Some(style) => style.clone(),
};
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs
index 244531cee46..4fb3838d18e 100644
--- a/components/layout/traversal.rs
+++ b/components/layout/traversal.rs
@@ -9,7 +9,7 @@ use crate::context::LayoutContext;
use crate::display_list::DisplayListBuildState;
use crate::flow::{Flow, FlowFlags, GetBaseFlow, ImmutableFlowUtils};
use crate::wrapper::ThreadSafeLayoutNodeHelpers;
-use crate::wrapper::{GetRawData, LayoutNodeLayoutData};
+use crate::wrapper::{GetStyleAndLayoutData, LayoutNodeLayoutData};
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
use servo_config::opts;
use style::context::{SharedStyleContext, StyleContext};
@@ -73,7 +73,7 @@ where
// flow construction:
// (1) They child doesn't yet have layout data (preorder traversal initializes it).
// (2) The parent element has restyle damage (so the text flow also needs fixup).
- node.get_raw_data().is_none() || !parent_data.damage.is_empty()
+ node.get_style_and_layout_data().is_none() || !parent_data.damage.is_empty()
}
fn shared_context(&self) -> &SharedStyleContext {
diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs
index 04648ad3abf..126c74a886f 100644
--- a/components/layout/wrapper.rs
+++ b/components/layout/wrapper.rs
@@ -32,7 +32,7 @@
use crate::data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
use atomic_refcell::{AtomicRef, AtomicRefMut};
-use script_layout_interface::wrapper_traits::GetLayoutData;
+use script_layout_interface::wrapper_traits::GetStyleAndOpaqueLayoutData;
use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use style::dom::{NodeInfo, TNode};
use style::selector_parser::RestyleDamage;
@@ -47,14 +47,16 @@ pub trait LayoutNodeLayoutData<'dom> {
impl<'dom, T> LayoutNodeLayoutData<'dom> for T
where
- T: GetLayoutData<'dom>,
+ T: GetStyleAndOpaqueLayoutData<'dom>,
{
fn borrow_layout_data(self) -> Option<AtomicRef<'dom, LayoutData>> {
- self.get_raw_data().map(|d| d.layout_data.borrow())
+ self.get_style_and_layout_data()
+ .map(|d| d.layout_data.borrow())
}
fn mutate_layout_data(self) -> Option<AtomicRefMut<'dom, LayoutData>> {
- self.get_raw_data().map(|d| d.layout_data.borrow_mut())
+ self.get_style_and_layout_data()
+ .map(|d| d.layout_data.borrow_mut())
}
fn flow_debug_id(self) -> usize {
@@ -63,17 +65,20 @@ where
}
}
-pub trait GetRawData<'dom> {
- fn get_raw_data(self) -> Option<&'dom StyleAndLayoutData>;
+pub trait GetStyleAndLayoutData<'dom> {
+ fn get_style_and_layout_data(self) -> Option<StyleAndLayoutData<'dom>>;
}
-impl<'dom, T> GetRawData<'dom> for T
+impl<'dom, T> GetStyleAndLayoutData<'dom> for T
where
- T: GetLayoutData<'dom>,
+ T: GetStyleAndOpaqueLayoutData<'dom>,
{
- fn get_raw_data(self) -> Option<&'dom StyleAndLayoutData> {
- self.get_style_and_layout_data()
- .map(|opaque| opaque.downcast_ref().unwrap())
+ fn get_style_and_layout_data(self) -> Option<StyleAndLayoutData<'dom>> {
+ self.get_style_and_opaque_layout_data()
+ .map(|data| StyleAndLayoutData {
+ style_data: &data.style_data,
+ layout_data: data.generic_data.downcast_ref().unwrap(),
+ })
}
}
@@ -143,7 +148,7 @@ where
}
let damage = {
- let data = node.get_raw_data().unwrap();
+ let data = node.get_style_and_layout_data().unwrap();
if !data
.layout_data
diff --git a/components/layout_2020/data.rs b/components/layout_2020/data.rs
index d8aa8cf77ac..6df89c80533 100644
--- a/components/layout_2020/data.rs
+++ b/components/layout_2020/data.rs
@@ -6,17 +6,7 @@ use crate::element_data::LayoutDataForElement;
use atomic_refcell::AtomicRefCell;
use script_layout_interface::StyleData;
-#[repr(C)]
-pub struct StyleAndLayoutData {
- pub style_data: StyleData,
- pub(super) layout_data: AtomicRefCell<LayoutDataForElement>,
-}
-
-impl StyleAndLayoutData {
- pub fn new() -> Self {
- Self {
- style_data: StyleData::new(),
- layout_data: Default::default(),
- }
- }
+pub struct StyleAndLayoutData<'dom> {
+ pub style_data: &'dom StyleData,
+ pub(super) layout_data: &'dom AtomicRefCell<LayoutDataForElement>,
}
diff --git a/components/layout_2020/dom_traversal.rs b/components/layout_2020/dom_traversal.rs
index 8ea6bb01de7..ce5f9799743 100644
--- a/components/layout_2020/dom_traversal.rs
+++ b/components/layout_2020/dom_traversal.rs
@@ -8,7 +8,7 @@ use crate::element_data::{LayoutBox, LayoutDataForElement};
use crate::geom::PhysicalSize;
use crate::replaced::{CanvasInfo, CanvasSource, ReplacedContent};
use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside, DisplayOutside};
-use crate::wrapper::GetRawData;
+use crate::wrapper::GetStyleAndLayoutData;
use atomic_refcell::AtomicRefMut;
use html5ever::LocalName;
use net_traits::image::base::Image as NetImage;
@@ -448,7 +448,7 @@ where
#[allow(unsafe_code)]
fn layout_data_mut(self) -> AtomicRefMut<'dom, LayoutDataForElement> {
- self.get_raw_data()
+ self.get_style_and_layout_data()
.map(|d| d.layout_data.borrow_mut())
.unwrap()
}
diff --git a/components/layout_2020/lib.rs b/components/layout_2020/lib.rs
index e34c6ba76ee..6b7a08ec29b 100644
--- a/components/layout_2020/lib.rs
+++ b/components/layout_2020/lib.rs
@@ -14,7 +14,7 @@ pub mod context;
pub mod data;
pub mod display_list;
mod dom_traversal;
-mod element_data;
+pub mod element_data;
mod flow;
mod formatting_contexts;
mod fragments;
diff --git a/components/layout_2020/query.rs b/components/layout_2020/query.rs
index fc4ac985253..b863d58cdc3 100644
--- a/components/layout_2020/query.rs
+++ b/components/layout_2020/query.rs
@@ -15,7 +15,7 @@ use msg::constellation_msg::PipelineId;
use script_layout_interface::rpc::TextIndexResponse;
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC};
use script_layout_interface::rpc::{NodeGeometryResponse, NodeScrollIdResponse};
-use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse, StyleResponse};
+use script_layout_interface::rpc::{OffsetParentResponse, ResolvedStyleResponse};
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
use script_traits::LayoutMsg as ConstellationMsg;
use script_traits::UntrustedNodeAddress;
@@ -59,9 +59,6 @@ pub struct LayoutThreadData {
/// A queued response for the offset parent/rect of a node.
pub offset_parent_response: OffsetParentResponse,
- /// A queued response for the style of a node.
- pub style_response: StyleResponse,
-
/// Scroll offsets of scrolling regions.
pub scroll_offsets: HashMap<ExternalScrollId, Vector2D<f32, LayoutPixel>>,
@@ -139,12 +136,6 @@ impl LayoutRPC for LayoutRPCImpl {
rw_data.offset_parent_response.clone()
}
- fn style(&self) -> StyleResponse {
- let &LayoutRPCImpl(ref rw_data) = self;
- let rw_data = rw_data.lock().unwrap();
- rw_data.style_response.clone()
- }
-
fn text_index(&self) -> TextIndexResponse {
let &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock().unwrap();
@@ -220,10 +211,6 @@ pub fn process_offset_parent_query(_requested_node: OpaqueNode) -> OffsetParentR
OffsetParentResponse::empty()
}
-pub fn process_style_query<'dom>(_requested_node: impl LayoutNode<'dom>) -> StyleResponse {
- StyleResponse(None)
-}
-
// https://html.spec.whatwg.org/multipage/#the-innertext-idl-attribute
pub fn process_element_inner_text_query<'dom>(_node: impl LayoutNode<'dom>) -> String {
"".to_owned()
diff --git a/components/layout_2020/traversal.rs b/components/layout_2020/traversal.rs
index b57fe2b63f1..1f73a7816f1 100644
--- a/components/layout_2020/traversal.rs
+++ b/components/layout_2020/traversal.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::context::LayoutContext;
-use crate::wrapper::GetRawData;
+use crate::wrapper::GetStyleAndLayoutData;
use script_layout_interface::wrapper_traits::LayoutNode;
use style::context::{SharedStyleContext, StyleContext};
use style::data::ElementData;
@@ -45,25 +45,28 @@ where
) where
F: FnMut(E::ConcreteNode),
{
- unsafe { node.initialize_data() };
-
- if !node.is_text_node() {
- let el = node.as_element().unwrap();
- let mut data = el.mutate_data().unwrap();
- recalc_style_at(self, traversal_data, context, el, &mut data, note_child);
- }
- }
-
- fn process_postorder(&self, _style_context: &mut StyleContext<E>, node: E::ConcreteNode) {
- if let Some(el) = node.as_element() {
- unsafe {
+ unsafe {
+ node.initialize_data();
+ if !node.is_text_node() {
+ let el = node.as_element().unwrap();
+ let mut data = el.mutate_data().unwrap();
+ recalc_style_at(self, traversal_data, context, el, &mut data, note_child);
el.unset_dirty_descendants();
}
}
}
+ #[inline]
+ fn needs_postorder_traversal() -> bool {
+ false
+ }
+
+ fn process_postorder(&self, _style_context: &mut StyleContext<E>, _node: E::ConcreteNode) {
+ panic!("this should never be called")
+ }
+
fn text_node_needs_traversal(node: E::ConcreteNode, parent_data: &ElementData) -> bool {
- node.get_raw_data().is_none() || !parent_data.damage.is_empty()
+ node.get_style_and_layout_data().is_none() || !parent_data.damage.is_empty()
}
fn shared_context(&self) -> &SharedStyleContext {
diff --git a/components/layout_2020/wrapper.rs b/components/layout_2020/wrapper.rs
index e7c5ab5a7b1..635889dc92e 100644
--- a/components/layout_2020/wrapper.rs
+++ b/components/layout_2020/wrapper.rs
@@ -5,18 +5,21 @@
#![allow(unsafe_code)]
use crate::data::StyleAndLayoutData;
-use script_layout_interface::wrapper_traits::GetLayoutData;
+use script_layout_interface::wrapper_traits::GetStyleAndOpaqueLayoutData;
-pub trait GetRawData<'dom> {
- fn get_raw_data(self) -> Option<&'dom StyleAndLayoutData>;
+pub trait GetStyleAndLayoutData<'dom> {
+ fn get_style_and_layout_data(self) -> Option<StyleAndLayoutData<'dom>>;
}
-impl<'dom, T> GetRawData<'dom> for T
+impl<'dom, T> GetStyleAndLayoutData<'dom> for T
where
- T: GetLayoutData<'dom>,
+ T: GetStyleAndOpaqueLayoutData<'dom>,
{
- fn get_raw_data(self) -> Option<&'dom StyleAndLayoutData> {
- self.get_style_and_layout_data()
- .map(|opaque| opaque.downcast_ref().unwrap())
+ fn get_style_and_layout_data(self) -> Option<StyleAndLayoutData<'dom>> {
+ self.get_style_and_opaque_layout_data()
+ .map(|data| StyleAndLayoutData {
+ style_data: &data.style_data,
+ layout_data: data.generic_data.downcast_ref().unwrap(),
+ })
}
}
diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs
index 404200e9ae0..064ceb5148e 100644
--- a/components/layout_thread/dom_wrapper.rs
+++ b/components/layout_thread/dom_wrapper.rs
@@ -30,11 +30,11 @@
#![allow(unsafe_code)]
-use atomic_refcell::{AtomicRef, AtomicRefMut};
+use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use gfx_traits::ByteIndex;
use html5ever::{LocalName, Namespace};
-use layout::data::StyleAndLayoutData;
-use layout::wrapper::GetRawData;
+use layout::data::LayoutData;
+use layout::wrapper::GetStyleAndLayoutData;
use msg::constellation_msg::{BrowsingContextId, PipelineId};
use net_traits::image::base::{Image, ImageMetadata};
use range::Range;
@@ -50,13 +50,13 @@ use script::layout_exports::{
LayoutDom, LayoutElementHelpers, LayoutNodeHelpers, LayoutShadowRootHelpers,
};
use script_layout_interface::wrapper_traits::{
- DangerousThreadSafeLayoutNode, GetLayoutData, LayoutNode,
+ DangerousThreadSafeLayoutNode, GetStyleAndOpaqueLayoutData, LayoutNode,
};
use script_layout_interface::wrapper_traits::{
PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
};
use script_layout_interface::{
- HTMLCanvasData, HTMLMediaData, LayoutNodeType, OpaqueStyleAndLayoutData,
+ HTMLCanvasData, HTMLMediaData, LayoutNodeType, StyleAndOpaqueLayoutData,
};
use script_layout_interface::{SVGSVGData, StyleData, TrustedNodeAddress};
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
@@ -268,18 +268,21 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
}
unsafe fn initialize_data(&self) {
- if self.get_raw_data().is_none() {
- let opaque = OpaqueStyleAndLayoutData::new(StyleAndLayoutData::new());
- self.init_style_and_layout_data(opaque);
+ if self.get_style_and_layout_data().is_none() {
+ let opaque = StyleAndOpaqueLayoutData::new(
+ StyleData::new(),
+ AtomicRefCell::new(LayoutData::new()),
+ );
+ self.init_style_and_opaque_layout_data(opaque);
};
}
- unsafe fn init_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData) {
- self.get_jsmanaged().init_style_and_layout_data(data);
+ unsafe fn init_style_and_opaque_layout_data(&self, data: Box<StyleAndOpaqueLayoutData>) {
+ self.get_jsmanaged().init_style_and_opaque_layout_data(data);
}
- unsafe fn take_style_and_layout_data(&self) -> OpaqueStyleAndLayoutData {
- self.get_jsmanaged().take_style_and_layout_data()
+ unsafe fn take_style_and_opaque_layout_data(&self) -> Box<StyleAndOpaqueLayoutData> {
+ self.get_jsmanaged().take_style_and_opaque_layout_data()
}
fn is_connected(&self) -> bool {
@@ -287,27 +290,27 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
}
}
-impl<'dom> GetLayoutData<'dom> for ServoLayoutNode<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- self.get_jsmanaged().get_style_and_layout_data()
+impl<'dom> GetStyleAndOpaqueLayoutData<'dom> for ServoLayoutNode<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ self.get_jsmanaged().get_style_and_opaque_layout_data()
}
}
-impl<'dom> GetLayoutData<'dom> for ServoLayoutElement<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- self.as_node().get_style_and_layout_data()
+impl<'dom> GetStyleAndOpaqueLayoutData<'dom> for ServoLayoutElement<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ self.as_node().get_style_and_opaque_layout_data()
}
}
-impl<'dom> GetLayoutData<'dom> for ServoThreadSafeLayoutNode<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- self.node.get_style_and_layout_data()
+impl<'dom> GetStyleAndOpaqueLayoutData<'dom> for ServoThreadSafeLayoutNode<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ self.node.get_style_and_opaque_layout_data()
}
}
-impl<'dom> GetLayoutData<'dom> for ServoThreadSafeLayoutElement<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- self.element.as_node().get_style_and_layout_data()
+impl<'dom> GetStyleAndOpaqueLayoutData<'dom> for ServoThreadSafeLayoutElement<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ self.element.as_node().get_style_and_opaque_layout_data()
}
}
@@ -536,8 +539,8 @@ impl<'le> TElement for ServoLayoutElement<'le> {
}
unsafe fn clear_data(&self) {
- if self.get_raw_data().is_some() {
- drop(self.as_node().take_style_and_layout_data());
+ if self.get_style_and_layout_data().is_some() {
+ drop(self.as_node().take_style_and_opaque_layout_data());
}
}
@@ -695,12 +698,8 @@ impl<'le> ServoLayoutElement<'le> {
}
fn get_style_data(&self) -> Option<&StyleData> {
- self.get_style_and_layout_data().map(|opaque| {
- &opaque
- .downcast_ref::<StyleAndLayoutData>()
- .unwrap()
- .style_data
- })
+ self.get_style_and_opaque_layout_data()
+ .map(|data| &data.style_data)
}
pub unsafe fn unset_snapshot_flags(&self) {
@@ -1045,8 +1044,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> {
})
}
- fn get_style_and_layout_data(self) -> Option<&'ln OpaqueStyleAndLayoutData> {
- self.node.get_style_and_layout_data()
+ fn get_style_and_opaque_layout_data(self) -> Option<&'ln StyleAndOpaqueLayoutData> {
+ self.node.get_style_and_opaque_layout_data()
}
fn is_ignorable_whitespace(&self, context: &SharedStyleContext) -> bool {
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 453067de4cd..98cdef1492b 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -55,9 +55,7 @@ use layout::query::{
process_content_box_request, process_content_boxes_request, LayoutRPCImpl, LayoutThreadData,
};
use layout::query::{process_node_scroll_area_request, process_node_scroll_id_request};
-use layout::query::{
- process_offset_parent_query, process_resolved_style_request, process_style_query,
-};
+use layout::query::{process_offset_parent_query, process_resolved_style_request};
use layout::sequential;
use layout::traversal::{
ComputeStackingRelativePositions, PreorderFlowTraversal, RecalcStyleAndConstructFlows,
@@ -80,7 +78,7 @@ use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
use script_layout_interface::message::{LayoutThreadInit, Msg, NodesFromPointQueryType, Reflow};
use script_layout_interface::message::{QueryMsg, ReflowComplete, ReflowGoal, ScriptReflow};
use script_layout_interface::rpc::TextIndexResponse;
-use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse, StyleResponse};
+use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse};
use script_layout_interface::wrapper_traits::LayoutNode;
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
use script_traits::{DrawAPaintImageResult, IFrameSizeMsg, PaintWorkletError, WindowSizeType};
@@ -595,7 +593,6 @@ impl LayoutThread {
scroll_area_response: Rect::zero(),
resolved_style_response: String::new(),
offset_parent_response: OffsetParentResponse::empty(),
- style_response: StyleResponse(None),
scroll_offsets: HashMap::new(),
text_index_response: TextIndexResponse(None),
nodes_from_point_response: vec![],
@@ -1308,9 +1305,7 @@ impl LayoutThread {
&QueryMsg::OffsetParentQuery(_) => {
rw_data.offset_parent_response = OffsetParentResponse::empty();
},
- &QueryMsg::StyleQuery(_) => {
- rw_data.style_response = StyleResponse(None);
- },
+ &QueryMsg::StyleQuery => {},
&QueryMsg::TextIndexQuery(..) => {
rw_data.text_index_response = TextIndexResponse(None);
},
@@ -1634,10 +1629,7 @@ impl LayoutThread {
&QueryMsg::OffsetParentQuery(node) => {
rw_data.offset_parent_response = process_offset_parent_query(node, root_flow);
},
- &QueryMsg::StyleQuery(node) => {
- let node = unsafe { ServoLayoutNode::new(&node) };
- rw_data.style_response = process_style_query(node);
- },
+ &QueryMsg::StyleQuery => {},
&QueryMsg::NodesFromPointQuery(client_point, ref reflow_goal) => {
let mut flags = match reflow_goal {
&NodesFromPointQueryType::Topmost => webrender_api::HitTestFlags::empty(),
diff --git a/components/layout_thread_2020/dom_wrapper.rs b/components/layout_thread_2020/dom_wrapper.rs
index d3fedcaf905..92a9f3f005b 100644
--- a/components/layout_thread_2020/dom_wrapper.rs
+++ b/components/layout_thread_2020/dom_wrapper.rs
@@ -30,11 +30,11 @@
#![allow(unsafe_code)]
-use atomic_refcell::{AtomicRef, AtomicRefMut};
+use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use gfx_traits::ByteIndex;
use html5ever::{LocalName, Namespace};
-use layout::data::StyleAndLayoutData;
-use layout::wrapper::GetRawData;
+use layout::element_data::LayoutDataForElement;
+use layout::wrapper::GetStyleAndLayoutData;
use msg::constellation_msg::{BrowsingContextId, PipelineId};
use net_traits::image::base::{Image, ImageMetadata};
use range::Range;
@@ -50,13 +50,13 @@ use script::layout_exports::{
LayoutDom, LayoutElementHelpers, LayoutNodeHelpers, LayoutShadowRootHelpers,
};
use script_layout_interface::wrapper_traits::{
- DangerousThreadSafeLayoutNode, GetLayoutData, LayoutNode,
+ DangerousThreadSafeLayoutNode, GetStyleAndOpaqueLayoutData, LayoutNode,
};
use script_layout_interface::wrapper_traits::{
PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
};
use script_layout_interface::{
- HTMLCanvasData, HTMLMediaData, LayoutNodeType, OpaqueStyleAndLayoutData,
+ HTMLCanvasData, HTMLMediaData, LayoutNodeType, StyleAndOpaqueLayoutData,
};
use script_layout_interface::{SVGSVGData, StyleData, TrustedNodeAddress};
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
@@ -275,18 +275,21 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
}
unsafe fn initialize_data(&self) {
- if self.get_raw_data().is_none() {
- let opaque = OpaqueStyleAndLayoutData::new(StyleAndLayoutData::new());
- self.init_style_and_layout_data(opaque);
+ if self.get_style_and_layout_data().is_none() {
+ let opaque = StyleAndOpaqueLayoutData::new(
+ StyleData::new(),
+ AtomicRefCell::new(LayoutDataForElement::default()),
+ );
+ self.init_style_and_opaque_layout_data(opaque);
};
}
- unsafe fn init_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData) {
- self.get_jsmanaged().init_style_and_layout_data(data);
+ unsafe fn init_style_and_opaque_layout_data(&self, data: Box<StyleAndOpaqueLayoutData>) {
+ self.get_jsmanaged().init_style_and_opaque_layout_data(data);
}
- unsafe fn take_style_and_layout_data(&self) -> OpaqueStyleAndLayoutData {
- self.get_jsmanaged().take_style_and_layout_data()
+ unsafe fn take_style_and_opaque_layout_data(&self) -> Box<StyleAndOpaqueLayoutData> {
+ self.get_jsmanaged().take_style_and_opaque_layout_data()
}
fn is_connected(&self) -> bool {
@@ -294,27 +297,27 @@ impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> {
}
}
-impl<'dom> GetLayoutData<'dom> for ServoLayoutNode<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- unsafe { self.get_jsmanaged().get_style_and_layout_data() }
+impl<'dom> GetStyleAndOpaqueLayoutData<'dom> for ServoLayoutNode<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ unsafe { self.get_jsmanaged().get_style_and_opaque_layout_data() }
}
}
-impl<'dom> GetLayoutData<'dom> for ServoLayoutElement<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- self.as_node().get_style_and_layout_data()
+impl<'dom> GetStyleAndOpaqueLayoutData<'dom> for ServoLayoutElement<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ self.as_node().get_style_and_opaque_layout_data()
}
}
-impl<'dom> GetLayoutData<'dom> for ServoThreadSafeLayoutNode<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- self.node.get_style_and_layout_data()
+impl<'dom> GetStyleAndOpaqueLayoutData<'dom> for ServoThreadSafeLayoutNode<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ self.node.get_style_and_opaque_layout_data()
}
}
-impl<'dom> GetLayoutData<'dom> for ServoThreadSafeLayoutElement<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- self.element.as_node().get_style_and_layout_data()
+impl<'dom> GetStyleAndOpaqueLayoutData<'dom> for ServoThreadSafeLayoutElement<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ self.element.as_node().get_style_and_opaque_layout_data()
}
}
@@ -544,8 +547,8 @@ impl<'le> TElement for ServoLayoutElement<'le> {
}
unsafe fn clear_data(&self) {
- if self.get_raw_data().is_some() {
- drop(self.as_node().take_style_and_layout_data());
+ if self.get_style_and_layout_data().is_some() {
+ drop(self.as_node().take_style_and_opaque_layout_data());
}
}
@@ -703,12 +706,8 @@ impl<'le> ServoLayoutElement<'le> {
}
fn get_style_data(&self) -> Option<&StyleData> {
- self.get_style_and_layout_data().map(|opaque| {
- &opaque
- .downcast_ref::<StyleAndLayoutData>()
- .unwrap()
- .style_data
- })
+ self.get_style_and_opaque_layout_data()
+ .map(|data| &data.style_data)
}
pub unsafe fn unset_snapshot_flags(&self) {
@@ -1053,8 +1052,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> {
})
}
- fn get_style_and_layout_data(self) -> Option<&'ln OpaqueStyleAndLayoutData> {
- self.node.get_style_and_layout_data()
+ fn get_style_and_opaque_layout_data(self) -> Option<&'ln StyleAndOpaqueLayoutData> {
+ self.node.get_style_and_opaque_layout_data()
}
fn is_ignorable_whitespace(&self, context: &SharedStyleContext) -> bool {
diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs
index 0dbc6b44cdf..3a808d287ae 100644
--- a/components/layout_thread_2020/lib.rs
+++ b/components/layout_thread_2020/lib.rs
@@ -42,8 +42,7 @@ use layout::query::{
use layout::query::{process_element_inner_text_query, process_node_geometry_request};
use layout::query::{process_node_scroll_area_request, process_node_scroll_id_request};
use layout::query::{
- process_offset_parent_query, process_resolved_style_request, process_style_query,
- process_text_index_request,
+ process_offset_parent_query, process_resolved_style_request, process_text_index_request,
};
use layout::traversal::RecalcStyle;
use layout::{BoxTreeRoot, FragmentTreeRoot};
@@ -64,7 +63,7 @@ use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
use script_layout_interface::message::{LayoutThreadInit, Msg, NodesFromPointQueryType};
use script_layout_interface::message::{QueryMsg, ReflowComplete, ReflowGoal, ScriptReflow};
use script_layout_interface::rpc::TextIndexResponse;
-use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse, StyleResponse};
+use script_layout_interface::rpc::{LayoutRPC, OffsetParentResponse};
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
use script_traits::{DrawAPaintImageResult, PaintWorkletError};
use script_traits::{Painter, WebrenderIpcSender};
@@ -551,7 +550,6 @@ impl LayoutThread {
scroll_area_response: Rect::zero(),
resolved_style_response: String::new(),
offset_parent_response: OffsetParentResponse::empty(),
- style_response: StyleResponse(None),
scroll_offsets: HashMap::new(),
text_index_response: TextIndexResponse(None),
nodes_from_point_response: vec![],
@@ -978,9 +976,7 @@ impl LayoutThread {
&QueryMsg::OffsetParentQuery(_) => {
rw_data.offset_parent_response = OffsetParentResponse::empty();
},
- &QueryMsg::StyleQuery(_) => {
- rw_data.style_response = StyleResponse(None);
- },
+ &QueryMsg::StyleQuery => {},
&QueryMsg::TextIndexQuery(..) => {
rw_data.text_index_response = TextIndexResponse(None);
},
@@ -1261,10 +1257,7 @@ impl LayoutThread {
&QueryMsg::OffsetParentQuery(node) => {
rw_data.offset_parent_response = process_offset_parent_query(node);
},
- &QueryMsg::StyleQuery(node) => {
- let node = unsafe { ServoLayoutNode::new(&node) };
- rw_data.style_response = process_style_query(node);
- },
+ &QueryMsg::StyleQuery => {},
&QueryMsg::NodesFromPointQuery(client_point, ref reflow_goal) => {
let mut flags = match reflow_goal {
&NodesFromPointQueryType::Topmost => webrender_api::HitTestFlags::empty(),
diff --git a/components/script/devtools.rs b/components/script/devtools.rs
index 2298883c555..49d855ff20f 100644
--- a/components/script/devtools.rs
+++ b/components/script/devtools.rs
@@ -15,7 +15,6 @@ use crate::dom::document::AnimationFrameCallback;
use crate::dom::element::Element;
use crate::dom::globalscope::GlobalScope;
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
-use crate::dom::window::Window;
use crate::realms::enter_realm;
use crate::script_thread::Documents;
use devtools_traits::{AutoMargins, ComputedNodeLayout, TimelineMarkerType};
@@ -150,7 +149,7 @@ pub fn handle_get_layout(
position: String::from(computed_style.Position()),
zIndex: String::from(computed_style.ZIndex()),
boxSizing: String::from(computed_style.BoxSizing()),
- autoMargins: determine_auto_margins(&window, &*node),
+ autoMargins: determine_auto_margins(&node),
marginTop: String::from(computed_style.MarginTop()),
marginRight: String::from(computed_style.MarginRight()),
marginBottom: String::from(computed_style.MarginBottom()),
@@ -169,8 +168,8 @@ pub fn handle_get_layout(
.unwrap();
}
-fn determine_auto_margins(window: &Window, node: &Node) -> AutoMargins {
- let style = window.style_query(node.to_trusted_node_address()).unwrap();
+fn determine_auto_margins(node: &Node) -> AutoMargins {
+ let style = node.style().unwrap();
let margin = style.get_margin();
AutoMargins {
top: margin.margin_top.is_auto(),
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index c30fced7c4d..305c6327b82 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -97,7 +97,7 @@ use profile_traits::mem::ProfilerChan as MemProfilerChan;
use profile_traits::time::ProfilerChan as TimeProfilerChan;
use script_layout_interface::message::PendingRestyle;
use script_layout_interface::rpc::LayoutRPC;
-use script_layout_interface::OpaqueStyleAndLayoutData;
+use script_layout_interface::StyleAndOpaqueLayoutData;
use script_traits::serializable::BlobImpl;
use script_traits::transferable::MessagePortImpl;
use script_traits::{DocumentActivity, DrawAPaintImageResult};
@@ -508,7 +508,7 @@ unsafe_no_jsmanaged_fields!(StatusCode);
unsafe_no_jsmanaged_fields!(SystemTime);
unsafe_no_jsmanaged_fields!(Instant);
unsafe_no_jsmanaged_fields!(RelativePos);
-unsafe_no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
+unsafe_no_jsmanaged_fields!(StyleAndOpaqueLayoutData);
unsafe_no_jsmanaged_fields!(PathBuf);
unsafe_no_jsmanaged_fields!(DrawAPaintImageResult);
unsafe_no_jsmanaged_fields!(DocumentId);
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 0c991998f0e..2fd6780cab0 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -396,7 +396,7 @@ impl Element {
/// style will be `None` for elements in a `display: none` subtree. otherwise, the element has a
/// layout box iff it doesn't have `display: none`.
pub fn style(&self) -> Option<Arc<ComputedValues>> {
- window_from_node(self).style_query(self.upcast::<Node>().to_trusted_node_address())
+ self.upcast::<Node>().style()
}
// https://drafts.csswg.org/cssom-view/#css-layout-box
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 8530078c919..4579890a03e 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -75,8 +75,9 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use msg::constellation_msg::{BrowsingContextId, PipelineId};
use net_traits::image::base::{Image, ImageMetadata};
use ref_slice::ref_slice;
+use script_layout_interface::message::QueryMsg;
use script_layout_interface::{HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType};
-use script_layout_interface::{OpaqueStyleAndLayoutData, SVGSVGData, TrustedNodeAddress};
+use script_layout_interface::{SVGSVGData, StyleAndOpaqueLayoutData, TrustedNodeAddress};
use script_traits::DocumentActivity;
use script_traits::UntrustedNodeAddress;
use selectors::matching::{matches_selector_list, MatchingContext, MatchingMode};
@@ -95,6 +96,7 @@ use std::ops::Range;
use std::sync::Arc as StdArc;
use style::context::QuirksMode;
use style::dom::OpaqueNode;
+use style::properties::ComputedValues;
use style::selector_parser::{SelectorImpl, SelectorParser};
use style::stylesheets::Stylesheet;
use uuid::Uuid;
@@ -152,8 +154,8 @@ pub struct Node {
///
/// Must be sent back to the layout thread to be destroyed when this
/// node is finalized.
- #[ignore_malloc_size_of = "shrug"]
- style_and_layout_data: UnsafeCell<Option<OpaqueStyleAndLayoutData>>,
+ #[ignore_malloc_size_of = "Unsafe cell"]
+ style_and_layout_data: UnsafeCell<Option<Box<StyleAndOpaqueLayoutData>>>,
}
bitflags! {
@@ -1229,6 +1231,23 @@ impl Node {
_ => false,
}
}
+
+ #[allow(unsafe_code)]
+ pub fn style(&self) -> Option<Arc<ComputedValues>> {
+ if !window_from_node(self).layout_reflow(QueryMsg::StyleQuery) {
+ return None;
+ }
+ unsafe {
+ (*self.style_and_layout_data.get()).as_ref().map(|data| {
+ data.style_data
+ .element_data
+ .borrow()
+ .styles
+ .primary()
+ .clone()
+ })
+ }
+ }
}
/// Iterate through `nodes` until we find a `Node` that is not in `not_in`
@@ -1282,9 +1301,9 @@ pub trait LayoutNodeHelpers<'dom> {
fn children_count(self) -> u32;
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData>;
- unsafe fn init_style_and_layout_data(self, data: OpaqueStyleAndLayoutData);
- unsafe fn take_style_and_layout_data(self) -> OpaqueStyleAndLayoutData;
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData>;
+ unsafe fn init_style_and_opaque_layout_data(self, data: Box<StyleAndOpaqueLayoutData>);
+ unsafe fn take_style_and_opaque_layout_data(self) -> Box<StyleAndOpaqueLayoutData>;
fn text_content(self) -> Cow<'dom, str>;
fn selection(self) -> Option<Range<usize>>;
@@ -1410,13 +1429,13 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
#[inline]
#[allow(unsafe_code)]
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData> {
- unsafe { (*self.unsafe_get().style_and_layout_data.get()).as_ref() }
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData> {
+ unsafe { (*self.unsafe_get().style_and_layout_data.get()).as_deref() }
}
#[inline]
#[allow(unsafe_code)]
- unsafe fn init_style_and_layout_data(self, val: OpaqueStyleAndLayoutData) {
+ unsafe fn init_style_and_opaque_layout_data(self, val: Box<StyleAndOpaqueLayoutData>) {
let data = &mut *self.unsafe_get().style_and_layout_data.get();
debug_assert!(data.is_none());
*data = Some(val);
@@ -1424,7 +1443,7 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
#[inline]
#[allow(unsafe_code)]
- unsafe fn take_style_and_layout_data(self) -> OpaqueStyleAndLayoutData {
+ unsafe fn take_style_and_opaque_layout_data(self) -> Box<StyleAndOpaqueLayoutData> {
(*self.unsafe_get().style_and_layout_data.get())
.take()
.unwrap()
diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs
index b7a2f2beb80..2dc3ef8f11f 100644
--- a/components/script/dom/webgl_extensions/extensions.rs
+++ b/components/script/dom/webgl_extensions/extensions.rs
@@ -178,7 +178,7 @@ impl WebGLExtensions {
.insert(name, Box::new(TypedWebGLExtensionWrapper::<T>::new()));
}
- pub fn get_suported_extensions(&self) -> Vec<&'static str> {
+ pub fn get_supported_extensions(&self) -> Vec<&'static str> {
self.extensions
.borrow()
.iter()
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index ff4dea4fdb3..d4327f6216a 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -1915,7 +1915,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
fn GetSupportedExtensions(&self) -> Option<Vec<DOMString>> {
self.extension_manager
.init_once(|| self.get_gl_extensions());
- let extensions = self.extension_manager.get_suported_extensions();
+ let extensions = self.extension_manager.get_supported_extensions();
Some(
extensions
.iter()
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 6782047c5a2..ee7d38b57e1 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -131,7 +131,7 @@ use style::dom::OpaqueNode;
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
use style::media_queries;
use style::parser::ParserContext as CssParserContext;
-use style::properties::{ComputedValues, PropertyId};
+use style::properties::PropertyId;
use style::selector_parser::PseudoElement;
use style::str::HTML_SPACE_CHARACTERS;
use style::stylesheets::CssRuleType;
@@ -1904,13 +1904,6 @@ impl Window {
(element, response.rect)
}
- pub fn style_query(&self, node: TrustedNodeAddress) -> Option<servo_arc::Arc<ComputedValues>> {
- if !self.layout_reflow(QueryMsg::StyleQuery(node)) {
- return None;
- }
- self.layout_rpc.style().0
- }
-
pub fn text_index_query(
&self,
node: &Node,
@@ -2461,7 +2454,7 @@ fn debug_reflow_events(id: PipelineId, reflow_goal: &ReflowGoal, reason: &Reflow
&QueryMsg::NodeScrollIdQuery(_n) => "\tNodeScrollIdQuery",
&QueryMsg::ResolvedStyleQuery(_, _, _) => "\tResolvedStyleQuery",
&QueryMsg::OffsetParentQuery(_n) => "\tOffsetParentQuery",
- &QueryMsg::StyleQuery(_n) => "\tStyleQuery",
+ &QueryMsg::StyleQuery => "\tStyleQuery",
&QueryMsg::TextIndexQuery(..) => "\tTextIndexQuery",
&QueryMsg::ElementInnerTextQuery(_) => "\tElementInnerTextQuery",
&QueryMsg::InnerWindowDimensionsQuery(_) => "\tInnerWindowDimensionsQuery",
diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs
index 6fb859aa112..651c0815f9f 100644
--- a/components/script_layout_interface/lib.rs
+++ b/components/script_layout_interface/lib.rs
@@ -29,12 +29,13 @@ use std::any::Any;
use std::sync::atomic::AtomicIsize;
use style::data::ElementData;
-#[repr(C)]
+#[derive(MallocSizeOf)]
pub struct StyleData {
/// Data that the style system associates with a node. When the
/// style system is being used standalone, this is all that hangs
/// off the node. This must be first to permit the various
/// transmutations between ElementData and PersistentLayoutData.
+ #[ignore_malloc_size_of = "This probably should not be ignored"]
pub element_data: AtomicRefCell<ElementData>,
/// Information needed during parallel traversals.
@@ -50,37 +51,33 @@ impl StyleData {
}
}
+pub type StyleAndOpaqueLayoutData = StyleAndGenericData<dyn Any + Send + Sync>;
+
#[derive(MallocSizeOf)]
-pub struct OpaqueStyleAndLayoutData {
- // NB: We really store a `StyleAndLayoutData` here, so be careful!
+pub struct StyleAndGenericData<T>
+where
+ T: ?Sized,
+{
+ /// The style data.
+ pub style_data: StyleData,
+ /// The opaque layout data.
#[ignore_malloc_size_of = "Trait objects are hard"]
- ptr: Box<dyn Any + Send + Sync>,
+ pub generic_data: T,
}
-impl OpaqueStyleAndLayoutData {
- #[inline]
- pub fn new<T>(value: T) -> Self
- where
- T: Any + Send + Sync,
- {
- Self {
- ptr: Box::new(value) as Box<dyn Any + Send + Sync>,
- }
- }
-
- /// Extremely cursed.
+impl StyleAndOpaqueLayoutData {
#[inline]
- pub fn downcast_ref<T>(&self) -> Option<&T>
+ pub fn new<T>(style_data: StyleData, layout_data: T) -> Box<Self>
where
T: Any + Send + Sync,
{
- self.ptr.downcast_ref()
+ Box::new(StyleAndGenericData {
+ style_data,
+ generic_data: layout_data,
+ })
}
}
-#[allow(unsafe_code)]
-unsafe impl Send for OpaqueStyleAndLayoutData {}
-
/// Information that we need stored in each DOM node.
#[derive(MallocSizeOf)]
pub struct DomParallelInfo {
diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs
index 48ec7223250..63854134cac 100644
--- a/components/script_layout_interface/message.rs
+++ b/components/script_layout_interface/message.rs
@@ -122,7 +122,7 @@ pub enum QueryMsg {
// garbage values such as `0xdeadbeef as *const _`, this is unsound.
NodeScrollIdQuery(TrustedNodeAddress),
ResolvedStyleQuery(TrustedNodeAddress, Option<PseudoElement>, PropertyId),
- StyleQuery(TrustedNodeAddress),
+ StyleQuery,
ElementInnerTextQuery(TrustedNodeAddress),
InnerWindowDimensionsQuery(BrowsingContextId),
}
@@ -153,7 +153,7 @@ impl ReflowGoal {
QueryMsg::NodeScrollIdQuery(_) |
QueryMsg::ResolvedStyleQuery(..) |
QueryMsg::OffsetParentQuery(_) |
- QueryMsg::StyleQuery(_) => false,
+ QueryMsg::StyleQuery => false,
},
}
}
@@ -175,7 +175,7 @@ impl ReflowGoal {
QueryMsg::ResolvedStyleQuery(..) |
QueryMsg::OffsetParentQuery(_) |
QueryMsg::InnerWindowDimensionsQuery(_) |
- QueryMsg::StyleQuery(_) => false,
+ QueryMsg::StyleQuery => false,
},
}
}
diff --git a/components/script_layout_interface/rpc.rs b/components/script_layout_interface/rpc.rs
index 19da8fa6afc..991437553cd 100644
--- a/components/script_layout_interface/rpc.rs
+++ b/components/script_layout_interface/rpc.rs
@@ -6,8 +6,6 @@ use app_units::Au;
use euclid::default::Rect;
use euclid::Size2D;
use script_traits::UntrustedNodeAddress;
-use servo_arc::Arc;
-use style::properties::ComputedValues;
use style_traits::CSSPixel;
use webrender_api::ExternalScrollId;
@@ -33,9 +31,6 @@ pub trait LayoutRPC {
/// Query layout for the resolved value of a given CSS property
fn resolved_style(&self) -> ResolvedStyleResponse;
fn offset_parent(&self) -> OffsetParentResponse;
- /// Requests the styles for an element. Contains a `None` value if the element is in a `display:
- /// none` subtree.
- fn style(&self) -> StyleResponse;
fn text_index(&self) -> TextIndexResponse;
/// Requests the list of nodes from the given point.
fn nodes_from_point_response(&self) -> Vec<UntrustedNodeAddress>;
@@ -73,7 +68,4 @@ impl OffsetParentResponse {
}
#[derive(Clone)]
-pub struct StyleResponse(pub Option<Arc<ComputedValues>>);
-
-#[derive(Clone)]
pub struct TextIndexResponse(pub Option<usize>);
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs
index 671dd1c8230..2056129244b 100644
--- a/components/script_layout_interface/wrapper_traits.rs
+++ b/components/script_layout_interface/wrapper_traits.rs
@@ -7,8 +7,8 @@
use crate::HTMLCanvasData;
use crate::HTMLMediaData;
use crate::LayoutNodeType;
-use crate::OpaqueStyleAndLayoutData;
use crate::SVGSVGData;
+use crate::StyleAndOpaqueLayoutData;
use atomic_refcell::AtomicRef;
use gfx_traits::{combine_id_with_fragment_type, ByteIndex, FragmentType};
use html5ever::{LocalName, Namespace};
@@ -79,13 +79,13 @@ impl PseudoElementType {
}
/// Trait to abstract access to layout data across various data structures.
-pub trait GetLayoutData<'dom> {
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData>;
+pub trait GetStyleAndOpaqueLayoutData<'dom> {
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData>;
}
/// 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<'dom>: Debug + GetLayoutData<'dom> + TNode {
+pub trait LayoutNode<'dom>: Debug + GetStyleAndOpaqueLayoutData<'dom> + TNode {
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>;
fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode;
@@ -93,8 +93,8 @@ pub trait LayoutNode<'dom>: Debug + GetLayoutData<'dom> + TNode {
fn type_id(&self) -> LayoutNodeType;
unsafe fn initialize_data(&self);
- unsafe fn init_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData);
- unsafe fn take_style_and_layout_data(&self) -> OpaqueStyleAndLayoutData;
+ unsafe fn init_style_and_opaque_layout_data(&self, data: Box<StyleAndOpaqueLayoutData>);
+ unsafe fn take_style_and_opaque_layout_data(&self) -> Box<StyleAndOpaqueLayoutData>;
fn rev_children(self) -> LayoutIterator<ReverseChildrenIterator<Self>> {
LayoutIterator(ReverseChildrenIterator {
@@ -160,7 +160,7 @@ 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<'dom>:
- Clone + Copy + Debug + GetLayoutData<'dom> + NodeInfo + PartialEq + Sized
+ Clone + Copy + Debug + GetStyleAndOpaqueLayoutData<'dom> + NodeInfo + PartialEq + Sized
{
type ConcreteNode: LayoutNode<'dom, ConcreteThreadSafeLayoutNode = Self>;
type ConcreteElement: TElement;
@@ -224,7 +224,7 @@ pub trait ThreadSafeLayoutNode<'dom>:
.map_or(PseudoElementType::Normal, |el| el.get_pseudo_element_type())
}
- fn get_style_and_layout_data(self) -> Option<&'dom OpaqueStyleAndLayoutData>;
+ fn get_style_and_opaque_layout_data(self) -> Option<&'dom StyleAndOpaqueLayoutData>;
fn style(&self, context: &SharedStyleContext) -> Arc<ComputedValues> {
if let Some(el) = self.as_element() {
@@ -314,7 +314,12 @@ pub trait DangerousThreadSafeLayoutNode<'dom>: ThreadSafeLayoutNode<'dom> {
}
pub trait ThreadSafeLayoutElement<'dom>:
- Clone + Copy + Sized + Debug + ::selectors::Element<Impl = SelectorImpl> + GetLayoutData<'dom>
+ Clone
+ + Copy
+ + Sized
+ + Debug
+ + ::selectors::Element<Impl = SelectorImpl>
+ + GetStyleAndOpaqueLayoutData<'dom>
{
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<
'dom,
diff --git a/components/style/attr.rs b/components/style/attr.rs
index 1d0d555d509..92ab7700fb8 100644
--- a/components/style/attr.rs
+++ b/components/style/attr.rs
@@ -539,28 +539,18 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto {
value = value.trim_start_matches(HTML_SPACE_CHARACTERS);
// Step 4
- if value.is_empty() {
- return LengthOrPercentageOrAuto::Auto;
- }
-
- // Step 5
- if value.starts_with('+') {
- value = &value[1..]
- }
-
- // Steps 6 & 7
match value.chars().nth(0) {
Some('0'..='9') => {},
_ => return LengthOrPercentageOrAuto::Auto,
}
- // Steps 8 to 13
+ // Steps 5 to 8
// We trim the string length to the minimum of:
// 1. the end of the string
// 2. the first occurence of a '%' (U+0025 PERCENT SIGN)
// 3. the second occurrence of a '.' (U+002E FULL STOP)
// 4. the occurrence of a character that is neither a digit nor '%' nor '.'
- // Note: Step 10 is directly subsumed by FromStr::from_str
+ // Note: Step 7.4 is directly subsumed by FromStr::from_str
let mut end_index = value.len();
let (mut found_full_stop, mut found_percent) = (false, false);
for (i, ch) in value.chars().enumerate() {
diff --git a/tests/unit/style/attr.rs b/tests/unit/style/attr.rs
index 261d6d8f98b..9bcfa2be522 100644
--- a/tests/unit/style/attr.rs
+++ b/tests/unit/style/attr.rs
@@ -66,7 +66,8 @@ pub fn test_parse_length() {
check("0", LengthOrPercentageOrAuto::Length(Au::from_px(0)));
check("0.000%", LengthOrPercentageOrAuto::Percentage(0.0));
- check("+5.82%", LengthOrPercentageOrAuto::Percentage(0.0582));
+ check("+5.82%", LengthOrPercentageOrAuto::Auto);
+ check("5.82%", LengthOrPercentageOrAuto::Percentage(0.0582));
check(
"5.82",
LengthOrPercentageOrAuto::Length(Au::from_f64_px(5.82)),
diff --git a/tests/wpt/metadata/html/rendering/dimension-attributes.html.ini b/tests/wpt/metadata/html/rendering/dimension-attributes.html.ini
index b0a5e5d8414..6583da6a4c8 100644
--- a/tests/wpt/metadata/html/rendering/dimension-attributes.html.ini
+++ b/tests/wpt/metadata/html/rendering/dimension-attributes.html.ini
@@ -2552,21 +2552,12 @@
[<td height="20.25E2"> mapping to height]
expected: FAIL
- [<hr width=" +200.25in "> mapping to width]
- expected: FAIL
-
[<object vspace="20.25e2"> mapping to marginTop]
expected: FAIL
[<marquee hspace="20.25e2"> mapping to marginRight]
expected: FAIL
- [<td width=" +200.25% "> mapping to width]
- expected: FAIL
-
- [<iframe width="+200"> mapping to width]
- expected: FAIL
-
[<object hspace="20.25e2"> mapping to marginRight]
expected: FAIL
@@ -2579,30 +2570,12 @@
[<input width="20.25e2"> mapping to width]
expected: FAIL
- [<td width=" +200.25in "> mapping to width]
- expected: FAIL
-
- [<iframe height=" +200.25in "> mapping to height]
- expected: FAIL
-
[<img hspace="20.25E2"> mapping to marginLeft]
expected: FAIL
[<marquee vspace="20.25E2"> mapping to marginTop]
expected: FAIL
- [<img width="+200%"> mapping to width]
- expected: FAIL
-
- [<img height=" +200in "> mapping to height]
- expected: FAIL
-
- [<table width=" +200.25% "> mapping to width]
- expected: FAIL
-
- [<iframe width=" +200.25%abc"> mapping to width]
- expected: FAIL
-
[<embed vspace="20.25E2"> mapping to marginTop]
expected: FAIL
@@ -2618,24 +2591,12 @@
[<embed hspace="20.25e2"> mapping to marginRight]
expected: FAIL
- [<td width=" +200.25%abc"> mapping to width]
- expected: FAIL
-
[<embed height="20.25e2"> mapping to height]
expected: FAIL
- [<td width="+200"> mapping to width]
- expected: FAIL
-
- [<hr width="+200"> mapping to width]
- expected: FAIL
-
[<marquee hspace="20.25e2"> mapping to marginLeft]
expected: FAIL
- [<img height="+0%"> mapping to height]
- expected: FAIL
-
[<input vspace="20.25E2"> mapping to marginTop]
expected: FAIL
@@ -2648,12 +2609,6 @@
[<input hspace="20.25e2"> mapping to marginLeft]
expected: FAIL
- [<iframe height="+200"> mapping to height]
- expected: FAIL
-
- [<iframe height=" +200in "> mapping to height]
- expected: FAIL
-
[<table height="20.25E2"> mapping to height]
expected: FAIL
@@ -2675,21 +2630,9 @@
[<img vspace="20.25E2"> mapping to marginBottom]
expected: FAIL
- [<iframe width=" +200in "> mapping to width]
- expected: FAIL
-
- [<iframe width="+200%"> mapping to width]
- expected: FAIL
-
- [<td width=" +200in "> mapping to width]
- expected: FAIL
-
[<tr height="20.25E2"> mapping to height]
expected: FAIL
- [<img height=" +200.25%abc"> mapping to height]
- expected: FAIL
-
[<marquee width="20.25E2"> mapping to width]
expected: FAIL
@@ -2699,120 +2642,51 @@
[<input vspace="20.25E2"> mapping to marginBottom]
expected: FAIL
- [<table width=" +200in "> mapping to width]
- expected: FAIL
-
[<marquee vspace="20.25e2"> mapping to marginBottom]
expected: FAIL
[<img vspace="20.25E2"> mapping to marginTop]
expected: FAIL
- [<table width=" +200.25in "> mapping to width]
- expected: FAIL
-
- [<img width=" +200.25% "> mapping to width]
- expected: FAIL
-
[<embed hspace="20.25e2"> mapping to marginLeft]
expected: FAIL
- [<hr width=" +200.25%abc"> mapping to width]
- expected: FAIL
-
[<embed hspace="20.25E2"> mapping to marginRight]
expected: FAIL
- [<hr width="+0%"> mapping to width]
- expected: FAIL
-
- [<img width="+0%"> mapping to width]
- expected: FAIL
-
- [<iframe height=" +200.25%abc"> mapping to height]
- expected: FAIL
-
- [<img width="+200"> mapping to width]
- expected: FAIL
-
[<input width="20.25E2"> mapping to width]
expected: FAIL
[<marquee height="20.25e2"> mapping to height]
expected: FAIL
- [<hr width="+0"> mapping to width]
- expected: FAIL
-
[<object hspace="20.25E2"> mapping to marginLeft]
expected: FAIL
- [<img width="+0"> mapping to width]
- expected: FAIL
-
- [<iframe width="+0"> mapping to width]
- expected: FAIL
-
[<img hspace="20.25e2"> mapping to marginRight]
expected: FAIL
[<input hspace="20.25e2"> mapping to marginRight]
expected: FAIL
- [<iframe height="+200%"> mapping to height]
- expected: FAIL
-
- [<hr width=" +200in "> mapping to width]
- expected: FAIL
-
- [<img height="+200"> mapping to height]
- expected: FAIL
-
- [<img height="+0"> mapping to height]
- expected: FAIL
-
[<embed hspace="20.25E2"> mapping to marginLeft]
expected: FAIL
- [<img width=" +200.25in "> mapping to width]
- expected: FAIL
-
- [<table width="+200%"> mapping to width]
- expected: FAIL
-
[<object vspace="20.25E2"> mapping to marginBottom]
expected: FAIL
- [<img height=" +200.25% "> mapping to height]
- expected: FAIL
-
- [<table width=" +200.25%abc"> mapping to width]
- expected: FAIL
-
[<object height="20.25e2"> mapping to height]
expected: FAIL
- [<iframe width=" +200.25% "> mapping to width]
- expected: FAIL
-
- [<table width="+200"> mapping to width]
- expected: FAIL
-
[<embed width="20.25e2"> mapping to width]
expected: FAIL
[<embed vspace="20.25E2"> mapping to marginBottom]
expected: FAIL
- [<iframe width=" +200.25in "> mapping to width]
- expected: FAIL
-
[<embed vspace="20.25e2"> mapping to marginBottom]
expected: FAIL
- [<iframe height="+0%"> mapping to height]
- expected: FAIL
-
[<video width="20.25E2"> mapping to width]
expected: FAIL
@@ -2822,57 +2696,33 @@
[<video height="20.25e2"> mapping to height]
expected: FAIL
- [<hr width="+200%"> mapping to width]
- expected: FAIL
-
[<tr height="20.25e2"> mapping to height]
expected: FAIL
- [<img width=" +200.25%abc"> mapping to width]
- expected: FAIL
-
[<input hspace="20.25E2"> mapping to marginRight]
expected: FAIL
- [<iframe height="+0"> mapping to height]
- expected: FAIL
-
[<video width="20.25e2"> mapping to width]
expected: FAIL
[<marquee width="20.25e2"> mapping to width]
expected: FAIL
- [<hr width=" +200.25% "> mapping to width]
- expected: FAIL
-
[<marquee hspace="20.25E2"> mapping to marginRight]
expected: FAIL
[<col width="20.25e2"> mapping to width]
expected: FAIL
- [<iframe height=" +200.25% "> mapping to height]
- expected: FAIL
-
[<embed width="20.25E2"> mapping to width]
expected: FAIL
- [<iframe width="+0%"> mapping to width]
- expected: FAIL
-
[<input vspace="20.25e2"> mapping to marginBottom]
expected: FAIL
[<input hspace="20.25E2"> mapping to marginLeft]
expected: FAIL
- [<img height="+200%"> mapping to height]
- expected: FAIL
-
- [<td width="+200%"> mapping to width]
- expected: FAIL
-
[<marquee vspace="20.25e2"> mapping to marginTop]
expected: FAIL
@@ -2882,9 +2732,6 @@
[<object hspace="20.25e2"> mapping to marginLeft]
expected: FAIL
- [<img height=" +200.25in "> mapping to height]
- expected: FAIL
-
[<input vspace="20.25e2"> mapping to marginTop]
expected: FAIL
@@ -2900,9 +2747,6 @@
[<marquee hspace="20.25E2"> mapping to marginLeft]
expected: FAIL
- [<img width=" +200in "> mapping to width]
- expected: FAIL
-
[<object height="20.25E2"> mapping to height]
expected: FAIL
diff --git a/tests/wpt/metadata/html/rendering/non-replaced-elements/the-hr-element-0/width.html.ini b/tests/wpt/metadata/html/rendering/non-replaced-elements/the-hr-element-0/width.html.ini
deleted file mode 100644
index 3c08b64d3ea..00000000000
--- a/tests/wpt/metadata/html/rendering/non-replaced-elements/the-hr-element-0/width.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[width.html]
- expected: FAIL