mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Don't expose any AtomicRefCell directly from style traits
This lets us experiment with how we store this data on the DOM side.
This commit is contained in:
parent
4c61baee30
commit
516e8e0aa6
9 changed files with 67 additions and 42 deletions
|
@ -30,7 +30,7 @@
|
|||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
||||
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
||||
use gfx_traits::ByteIndex;
|
||||
use html5ever::{LocalName, Namespace};
|
||||
use layout::data::StyleAndLayoutData;
|
||||
|
@ -551,8 +551,20 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
self.mutate_data().unwrap()
|
||||
}
|
||||
|
||||
fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> {
|
||||
self.get_style_data().map(|data| &data.element_data)
|
||||
/// Whether there is an ElementData container.
|
||||
fn has_data(&self) -> bool {
|
||||
self.get_style_data().is_some()
|
||||
}
|
||||
|
||||
/// Immutably borrows the ElementData.
|
||||
fn borrow_data(&self) -> Option<AtomicRef<ElementData>> {
|
||||
self.get_style_data().map(|data| data.element_data.borrow())
|
||||
}
|
||||
|
||||
/// Mutably borrows the ElementData.
|
||||
fn mutate_data(&self) -> Option<AtomicRefMut<ElementData>> {
|
||||
self.get_style_data()
|
||||
.map(|data| data.element_data.borrow_mut())
|
||||
}
|
||||
|
||||
fn skip_item_display_fixup(&self) -> bool {
|
||||
|
@ -688,7 +700,7 @@ impl<'le> ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn get_style_data(&self) -> Option<&StyleData> {
|
||||
self.get_style_and_layout_data().map(|opaque| {
|
||||
self.get_style_and_layout_data().map(|opaque| unsafe {
|
||||
&opaque
|
||||
.downcast_ref::<StyleAndLayoutData>()
|
||||
.unwrap()
|
||||
|
@ -1027,7 +1039,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> {
|
|||
|
||||
fn parent_style(&self) -> Arc<ComputedValues> {
|
||||
let parent = self.node.parent_node().unwrap().as_element().unwrap();
|
||||
let parent_data = parent.get_data().unwrap().borrow();
|
||||
let parent_data = parent.borrow_data().unwrap();
|
||||
parent_data.styles.primary().clone()
|
||||
}
|
||||
|
||||
|
@ -1312,10 +1324,7 @@ impl<'le> ThreadSafeLayoutElement<'le> for ServoThreadSafeLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn style_data(&self) -> AtomicRef<ElementData> {
|
||||
self.element
|
||||
.get_data()
|
||||
.expect("Unstyled layout node?")
|
||||
.borrow()
|
||||
self.element.borrow_data().expect("Unstyled layout node?")
|
||||
}
|
||||
|
||||
fn is_shadow_host(&self) -> bool {
|
||||
|
|
|
@ -1472,7 +1472,7 @@ impl LayoutThread {
|
|||
|
||||
// If we haven't styled this node yet, we don't need to track a
|
||||
// restyle.
|
||||
let style_data = match el.get_data() {
|
||||
let mut style_data = match el.mutate_data() {
|
||||
Some(d) => d,
|
||||
None => {
|
||||
unsafe { el.unset_snapshot_flags() };
|
||||
|
@ -1485,8 +1485,6 @@ impl LayoutThread {
|
|||
map.insert(el.as_node().opaque(), s);
|
||||
}
|
||||
|
||||
let mut style_data = style_data.borrow_mut();
|
||||
|
||||
// Stash the data on the element for processing by the style system.
|
||||
style_data.hint.insert(restyle.hint.into());
|
||||
style_data.damage = restyle.damage;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue