mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use get_style_data() where possible.
This commit is contained in:
parent
72632ac16d
commit
d50c166786
1 changed files with 36 additions and 20 deletions
|
@ -231,23 +231,29 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn borrow_data_unchecked(&self) -> Option<*const PrivateStyleData> {
|
unsafe fn borrow_data_unchecked(&self) -> Option<*const PrivateStyleData> {
|
||||||
self.borrow_layout_data_unchecked().map(|d| &(*d).style_data as *const PrivateStyleData)
|
self.get_style_data().map(|d| {
|
||||||
|
&(*d.as_unsafe_cell().get()).style_data as *const _
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn borrow_data(&self) -> Option<Ref<PrivateStyleData>> {
|
fn borrow_data(&self) -> Option<Ref<PrivateStyleData>> {
|
||||||
self.borrow_layout_data().map(|d| Ref::map(d, |d| &d.style_data))
|
self.get_style_data().map(|d| {
|
||||||
|
Ref::map(d.borrow(), |d| &d.style_data)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mutate_data(&self) -> Option<RefMut<PrivateStyleData>> {
|
fn mutate_data(&self) -> Option<RefMut<PrivateStyleData>> {
|
||||||
self.mutate_layout_data().map(|d| RefMut::map(d, |d| &mut d.style_data))
|
self.get_style_data().map(|d| {
|
||||||
|
RefMut::map(d.borrow_mut(), |d| &mut d.style_data)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn restyle_damage(self) -> RestyleDamage {
|
fn restyle_damage(self) -> RestyleDamage {
|
||||||
self.borrow_layout_data().unwrap().restyle_damage
|
self.get_style_data().unwrap().borrow().restyle_damage
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_restyle_damage(self, damage: RestyleDamage) {
|
fn set_restyle_damage(self, damage: RestyleDamage) {
|
||||||
self.mutate_layout_data().unwrap().restyle_damage = damage;
|
self.get_style_data().unwrap().borrow_mut().restyle_damage = damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_node(&self) -> Option<ServoLayoutNode<'ln>> {
|
fn parent_node(&self) -> Option<ServoLayoutNode<'ln>> {
|
||||||
|
@ -716,8 +722,11 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_before_pseudo(&self) -> Option<Self> {
|
fn get_before_pseudo(&self) -> Option<Self> {
|
||||||
if self.borrow_layout_data().unwrap()
|
if self.get_style_data()
|
||||||
.style_data.per_pseudo
|
.unwrap()
|
||||||
|
.borrow()
|
||||||
|
.style_data
|
||||||
|
.per_pseudo
|
||||||
.contains_key(&PseudoElement::Before) {
|
.contains_key(&PseudoElement::Before) {
|
||||||
Some(self.with_pseudo(PseudoElementType::Before(None)))
|
Some(self.with_pseudo(PseudoElementType::Before(None)))
|
||||||
} else {
|
} else {
|
||||||
|
@ -727,8 +736,11 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_after_pseudo(&self) -> Option<Self> {
|
fn get_after_pseudo(&self) -> Option<Self> {
|
||||||
if self.borrow_layout_data().unwrap()
|
if self.get_style_data()
|
||||||
.style_data.per_pseudo
|
.unwrap()
|
||||||
|
.borrow()
|
||||||
|
.style_data
|
||||||
|
.per_pseudo
|
||||||
.contains_key(&PseudoElement::After) {
|
.contains_key(&PseudoElement::After) {
|
||||||
Some(self.with_pseudo(PseudoElementType::After(None)))
|
Some(self.with_pseudo(PseudoElementType::After(None)))
|
||||||
} else {
|
} else {
|
||||||
|
@ -783,7 +795,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
fn style(&self, context: &SharedStyleContext) -> Ref<Arc<ServoComputedValues>> {
|
fn style(&self, context: &SharedStyleContext) -> Ref<Arc<ServoComputedValues>> {
|
||||||
match self.get_pseudo_element_type() {
|
match self.get_pseudo_element_type() {
|
||||||
PseudoElementType::Normal => {
|
PseudoElementType::Normal => {
|
||||||
Ref::map(self.borrow_layout_data().unwrap(), |data| {
|
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
|
||||||
data.style_data.style.as_ref().unwrap()
|
data.style_data.style.as_ref().unwrap()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -795,10 +807,12 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
// Already computed during the cascade.
|
// Already computed during the cascade.
|
||||||
PseudoElementCascadeType::Eager => {},
|
PseudoElementCascadeType::Eager => {},
|
||||||
PseudoElementCascadeType::Precomputed => {
|
PseudoElementCascadeType::Precomputed => {
|
||||||
if !self.borrow_layout_data()
|
if !self.get_style_data()
|
||||||
.unwrap().style_data
|
.unwrap()
|
||||||
|
.borrow()
|
||||||
|
.style_data
|
||||||
.per_pseudo.contains_key(&style_pseudo) {
|
.per_pseudo.contains_key(&style_pseudo) {
|
||||||
let mut data = self.mutate_layout_data().unwrap();
|
let mut data = self.get_style_data().unwrap().borrow_mut();
|
||||||
let new_style =
|
let new_style =
|
||||||
context.stylist
|
context.stylist
|
||||||
.precomputed_values_for_pseudo(&style_pseudo,
|
.precomputed_values_for_pseudo(&style_pseudo,
|
||||||
|
@ -809,10 +823,12 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
}
|
}
|
||||||
PseudoElementCascadeType::Lazy => {
|
PseudoElementCascadeType::Lazy => {
|
||||||
debug_assert!(self.is_element_or_elements_pseudo());
|
debug_assert!(self.is_element_or_elements_pseudo());
|
||||||
if !self.borrow_layout_data()
|
if !self.get_style_data()
|
||||||
.unwrap().style_data
|
.unwrap()
|
||||||
|
.borrow()
|
||||||
|
.style_data
|
||||||
.per_pseudo.contains_key(&style_pseudo) {
|
.per_pseudo.contains_key(&style_pseudo) {
|
||||||
let mut data = self.mutate_layout_data().unwrap();
|
let mut data = self.get_style_data().unwrap().borrow_mut();
|
||||||
let new_style =
|
let new_style =
|
||||||
context.stylist
|
context.stylist
|
||||||
.lazily_compute_pseudo_element_style(
|
.lazily_compute_pseudo_element_style(
|
||||||
|
@ -825,7 +841,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref::map(self.borrow_layout_data().unwrap(), |data| {
|
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
|
||||||
data.style_data.per_pseudo.get(&style_pseudo).unwrap()
|
data.style_data.per_pseudo.get(&style_pseudo).unwrap()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -841,7 +857,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
/// element style is precomputed, not from general layout itself.
|
/// element style is precomputed, not from general layout itself.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn resolved_style(&self) -> Ref<Arc<ServoComputedValues>> {
|
fn resolved_style(&self) -> Ref<Arc<ServoComputedValues>> {
|
||||||
Ref::map(self.borrow_layout_data().unwrap(), |data| {
|
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
|
||||||
match self.get_pseudo_element_type() {
|
match self.get_pseudo_element_type() {
|
||||||
PseudoElementType::Normal
|
PseudoElementType::Normal
|
||||||
=> data.style_data.style.as_ref().unwrap(),
|
=> data.style_data.style.as_ref().unwrap(),
|
||||||
|
@ -853,7 +869,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn selected_style(&self, _context: &SharedStyleContext) -> Ref<Arc<ServoComputedValues>> {
|
fn selected_style(&self, _context: &SharedStyleContext) -> Ref<Arc<ServoComputedValues>> {
|
||||||
Ref::map(self.borrow_layout_data().unwrap(), |data| {
|
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
|
||||||
data.style_data.per_pseudo
|
data.style_data.per_pseudo
|
||||||
.get(&PseudoElement::Selection)
|
.get(&PseudoElement::Selection)
|
||||||
.unwrap_or(data.style_data.style.as_ref().unwrap())
|
.unwrap_or(data.style_data.style.as_ref().unwrap())
|
||||||
|
@ -864,7 +880,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq {
|
||||||
///
|
///
|
||||||
/// Unlike the version on TNode, this handles pseudo-elements.
|
/// Unlike the version on TNode, this handles pseudo-elements.
|
||||||
fn unstyle(self) {
|
fn unstyle(self) {
|
||||||
let mut data = self.mutate_layout_data().unwrap();
|
let mut data = self.get_style_data().unwrap().borrow_mut();
|
||||||
|
|
||||||
match self.get_pseudo_element_type() {
|
match self.get_pseudo_element_type() {
|
||||||
PseudoElementType::Normal => {
|
PseudoElementType::Normal => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue