mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Stop using Ref::map for selected_style and resolved_style.
Same concept as the previous patch. MozReview-Commit-ID: RFC8s7qQPM
This commit is contained in:
parent
18d552a1e9
commit
5bcc4192bf
4 changed files with 28 additions and 30 deletions
|
@ -219,7 +219,7 @@ impl InlineFragmentsAccumulator {
|
||||||
address: node.opaque(),
|
address: node.opaque(),
|
||||||
pseudo: node.get_pseudo_element_type().strip(),
|
pseudo: node.get_pseudo_element_type().strip(),
|
||||||
style: node.style(style_context),
|
style: node.style(style_context),
|
||||||
selected_style: node.selected_style(style_context).clone(),
|
selected_style: node.selected_style(style_context),
|
||||||
flags: InlineFragmentNodeFlags::empty(),
|
flags: InlineFragmentNodeFlags::empty(),
|
||||||
}),
|
}),
|
||||||
bidi_control_chars: None,
|
bidi_control_chars: None,
|
||||||
|
@ -360,7 +360,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(),
|
let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
style,
|
style,
|
||||||
child_node.selected_style(style_context).clone(),
|
child_node.selected_style(style_context),
|
||||||
child_node.restyle_damage(),
|
child_node.restyle_damage(),
|
||||||
SpecificFragmentInfo::TableRow);
|
SpecificFragmentInfo::TableRow);
|
||||||
let mut new_child: FlowRef = Arc::new(TableRowFlow::from_fragment(fragment));
|
let mut new_child: FlowRef = Arc::new(TableRowFlow::from_fragment(fragment));
|
||||||
|
@ -374,7 +374,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(),
|
let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
style,
|
style,
|
||||||
child_node.selected_style(style_context).clone(),
|
child_node.selected_style(style_context),
|
||||||
child_node.restyle_damage(),
|
child_node.restyle_damage(),
|
||||||
SpecificFragmentInfo::Table);
|
SpecificFragmentInfo::Table);
|
||||||
let mut new_child: FlowRef = Arc::new(TableFlow::from_fragment(fragment));
|
let mut new_child: FlowRef = Arc::new(TableFlow::from_fragment(fragment));
|
||||||
|
@ -389,7 +389,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
Fragment::from_opaque_node_and_style(child_node.opaque(),
|
Fragment::from_opaque_node_and_style(child_node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
style,
|
style,
|
||||||
child_node.selected_style(style_context).clone(),
|
child_node.selected_style(style_context),
|
||||||
child_node.restyle_damage(),
|
child_node.restyle_damage(),
|
||||||
SpecificFragmentInfo::TableWrapper);
|
SpecificFragmentInfo::TableWrapper);
|
||||||
let mut new_child: FlowRef = Arc::new(TableWrapperFlow::from_fragment(fragment, None));
|
let mut new_child: FlowRef = Arc::new(TableWrapperFlow::from_fragment(fragment, None));
|
||||||
|
@ -589,7 +589,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
let fragment = Fragment::from_opaque_node_and_style(whitespace_node,
|
let fragment = Fragment::from_opaque_node_and_style(whitespace_node,
|
||||||
whitespace_pseudo,
|
whitespace_pseudo,
|
||||||
whitespace_style,
|
whitespace_style,
|
||||||
node.selected_style(style_context).clone(),
|
node.selected_style(style_context),
|
||||||
whitespace_damage,
|
whitespace_damage,
|
||||||
fragment_info);
|
fragment_info);
|
||||||
inline_fragment_accumulator.fragments.fragments.push_back(fragment);
|
inline_fragment_accumulator.fragments.fragments.push_back(fragment);
|
||||||
|
@ -732,7 +732,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
node.opaque(),
|
node.opaque(),
|
||||||
node.get_pseudo_element_type().strip(),
|
node.get_pseudo_element_type().strip(),
|
||||||
style,
|
style,
|
||||||
selected_style.clone(),
|
selected_style,
|
||||||
node.restyle_damage(),
|
node.restyle_damage(),
|
||||||
specific_fragment_info))
|
specific_fragment_info))
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
Fragment::from_opaque_node_and_style(whitespace_node,
|
Fragment::from_opaque_node_and_style(whitespace_node,
|
||||||
whitespace_pseudo,
|
whitespace_pseudo,
|
||||||
whitespace_style,
|
whitespace_style,
|
||||||
node.selected_style(self.style_context()).clone(),
|
node.selected_style(self.style_context()),
|
||||||
whitespace_damage,
|
whitespace_damage,
|
||||||
fragment_info);
|
fragment_info);
|
||||||
fragment_accumulator.fragments.fragments.push_back(fragment)
|
fragment_accumulator.fragments.fragments.push_back(fragment)
|
||||||
|
@ -905,7 +905,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
||||||
node.get_pseudo_element_type().strip(),
|
node.get_pseudo_element_type().strip(),
|
||||||
modified_style,
|
modified_style,
|
||||||
node.selected_style(self.style_context()).clone(),
|
node.selected_style(self.style_context()),
|
||||||
node.restyle_damage(),
|
node.restyle_damage(),
|
||||||
info);
|
info);
|
||||||
fragment_accumulator.fragments.fragments.push_back(fragment)
|
fragment_accumulator.fragments.fragments.push_back(fragment)
|
||||||
|
@ -1000,7 +1000,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
||||||
node.get_pseudo_element_type().strip(),
|
node.get_pseudo_element_type().strip(),
|
||||||
modified_style,
|
modified_style,
|
||||||
node.selected_style(style_context).clone(),
|
node.selected_style(style_context),
|
||||||
node.restyle_damage(),
|
node.restyle_damage(),
|
||||||
fragment_info);
|
fragment_info);
|
||||||
|
|
||||||
|
@ -1035,7 +1035,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
||||||
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
style,
|
style,
|
||||||
node.selected_style(style_context).clone(),
|
node.selected_style(style_context),
|
||||||
node.restyle_damage(),
|
node.restyle_damage(),
|
||||||
fragment_info);
|
fragment_info);
|
||||||
|
|
||||||
|
|
|
@ -1282,7 +1282,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
|
||||||
node.opaque(),
|
node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
style,
|
style,
|
||||||
node.selected_style(style_context).clone(),
|
node.selected_style(style_context),
|
||||||
node.restyle_damage(),
|
node.restyle_damage(),
|
||||||
SpecificFragmentInfo::TableRow);
|
SpecificFragmentInfo::TableRow);
|
||||||
Arc::new(TableRowFlow::from_fragment(fragment))
|
Arc::new(TableRowFlow::from_fragment(fragment))
|
||||||
|
@ -1295,7 +1295,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
|
||||||
node.opaque(),
|
node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
style,
|
style,
|
||||||
node.selected_style(style_context).clone(),
|
node.selected_style(style_context),
|
||||||
node.restyle_damage(),
|
node.restyle_damage(),
|
||||||
SpecificFragmentInfo::TableCell);
|
SpecificFragmentInfo::TableCell);
|
||||||
let hide = node.style(style_context).get_inheritedtable().empty_cells == empty_cells::T::hide;
|
let hide = node.style(style_context).get_inheritedtable().empty_cells == empty_cells::T::hide;
|
||||||
|
@ -1309,7 +1309,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
|
||||||
Fragment::from_opaque_node_and_style(node.opaque(),
|
Fragment::from_opaque_node_and_style(node.opaque(),
|
||||||
PseudoElementType::Normal,
|
PseudoElementType::Normal,
|
||||||
style,
|
style,
|
||||||
node.selected_style(style_context).clone(),
|
node.selected_style(style_context),
|
||||||
node.restyle_damage(),
|
node.restyle_damage(),
|
||||||
SpecificFragmentInfo::Generic);
|
SpecificFragmentInfo::Generic);
|
||||||
Arc::new(BlockFlow::from_fragment(fragment, None))
|
Arc::new(BlockFlow::from_fragment(fragment, None))
|
||||||
|
|
|
@ -865,7 +865,7 @@ impl Fragment {
|
||||||
Fragment {
|
Fragment {
|
||||||
node: node.opaque(),
|
node: node.opaque(),
|
||||||
style: style,
|
style: style,
|
||||||
selected_style: node.selected_style(style_context).clone(),
|
selected_style: node.selected_style(style_context),
|
||||||
restyle_damage: restyle_damage,
|
restyle_damage: restyle_damage,
|
||||||
border_box: LogicalRect::zero(writing_mode),
|
border_box: LogicalRect::zero(writing_mode),
|
||||||
border_padding: LogicalMargin::zero(writing_mode),
|
border_padding: LogicalMargin::zero(writing_mode),
|
||||||
|
|
|
@ -18,7 +18,7 @@ use style::context::SharedStyleContext;
|
||||||
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TNode};
|
use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TNode};
|
||||||
use style::dom::OpaqueNode;
|
use style::dom::OpaqueNode;
|
||||||
use style::properties::ServoComputedValues;
|
use style::properties::ServoComputedValues;
|
||||||
use style::refcell::{Ref, RefCell};
|
use style::refcell::RefCell;
|
||||||
use style::selector_impl::{PseudoElement, PseudoElementCascadeType, ServoSelectorImpl};
|
use style::selector_impl::{PseudoElement, PseudoElementCascadeType, ServoSelectorImpl};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -303,24 +303,22 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + NodeInfo + PartialEq + Sized {
|
||||||
/// This should be used just for querying layout, or when we know the
|
/// This should be used just for querying layout, or when we know the
|
||||||
/// 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) -> Arc<ServoComputedValues> {
|
||||||
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
|
let data = self.get_style_data().unwrap().borrow();
|
||||||
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().clone(),
|
||||||
other
|
other
|
||||||
=> data.style_data.per_pseudo.get(&other.style_pseudo_element()).unwrap(),
|
=> data.style_data.per_pseudo.get(&other.style_pseudo_element()).unwrap().clone(),
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn selected_style(&self, _context: &SharedStyleContext) -> Ref<Arc<ServoComputedValues>> {
|
fn selected_style(&self, _context: &SharedStyleContext) -> Arc<ServoComputedValues> {
|
||||||
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
|
let data = self.get_style_data().unwrap().borrow();
|
||||||
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()).clone()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes the style from this node.
|
/// Removes the style from this node.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue