mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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(),
|
||||
pseudo: node.get_pseudo_element_type().strip(),
|
||||
style: node.style(style_context),
|
||||
selected_style: node.selected_style(style_context).clone(),
|
||||
selected_style: node.selected_style(style_context),
|
||||
flags: InlineFragmentNodeFlags::empty(),
|
||||
}),
|
||||
bidi_control_chars: None,
|
||||
|
@ -360,7 +360,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
child_node.selected_style(style_context).clone(),
|
||||
child_node.selected_style(style_context),
|
||||
child_node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableRow);
|
||||
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(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
child_node.selected_style(style_context).clone(),
|
||||
child_node.selected_style(style_context),
|
||||
child_node.restyle_damage(),
|
||||
SpecificFragmentInfo::Table);
|
||||
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(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
child_node.selected_style(style_context).clone(),
|
||||
child_node.selected_style(style_context),
|
||||
child_node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableWrapper);
|
||||
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,
|
||||
whitespace_pseudo,
|
||||
whitespace_style,
|
||||
node.selected_style(style_context).clone(),
|
||||
node.selected_style(style_context),
|
||||
whitespace_damage,
|
||||
fragment_info);
|
||||
inline_fragment_accumulator.fragments.fragments.push_back(fragment);
|
||||
|
@ -732,7 +732,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
node.opaque(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
style,
|
||||
selected_style.clone(),
|
||||
selected_style,
|
||||
node.restyle_damage(),
|
||||
specific_fragment_info))
|
||||
}
|
||||
|
@ -882,7 +882,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
Fragment::from_opaque_node_and_style(whitespace_node,
|
||||
whitespace_pseudo,
|
||||
whitespace_style,
|
||||
node.selected_style(self.style_context()).clone(),
|
||||
node.selected_style(self.style_context()),
|
||||
whitespace_damage,
|
||||
fragment_info);
|
||||
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(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
modified_style,
|
||||
node.selected_style(self.style_context()).clone(),
|
||||
node.selected_style(self.style_context()),
|
||||
node.restyle_damage(),
|
||||
info);
|
||||
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(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
modified_style,
|
||||
node.selected_style(style_context).clone(),
|
||||
node.selected_style(style_context),
|
||||
node.restyle_damage(),
|
||||
fragment_info);
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
node.selected_style(style_context).clone(),
|
||||
node.selected_style(style_context),
|
||||
node.restyle_damage(),
|
||||
fragment_info);
|
||||
|
||||
|
|
|
@ -1282,7 +1282,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
|
|||
node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
node.selected_style(style_context).clone(),
|
||||
node.selected_style(style_context),
|
||||
node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableRow);
|
||||
Arc::new(TableRowFlow::from_fragment(fragment))
|
||||
|
@ -1295,7 +1295,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
|
|||
node.opaque(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
node.selected_style(style_context).clone(),
|
||||
node.selected_style(style_context),
|
||||
node.restyle_damage(),
|
||||
SpecificFragmentInfo::TableCell);
|
||||
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(),
|
||||
PseudoElementType::Normal,
|
||||
style,
|
||||
node.selected_style(style_context).clone(),
|
||||
node.selected_style(style_context),
|
||||
node.restyle_damage(),
|
||||
SpecificFragmentInfo::Generic);
|
||||
Arc::new(BlockFlow::from_fragment(fragment, None))
|
||||
|
|
|
@ -865,7 +865,7 @@ impl Fragment {
|
|||
Fragment {
|
||||
node: node.opaque(),
|
||||
style: style,
|
||||
selected_style: node.selected_style(style_context).clone(),
|
||||
selected_style: node.selected_style(style_context),
|
||||
restyle_damage: restyle_damage,
|
||||
border_box: LogicalRect::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::OpaqueNode;
|
||||
use style::properties::ServoComputedValues;
|
||||
use style::refcell::{Ref, RefCell};
|
||||
use style::refcell::RefCell;
|
||||
use style::selector_impl::{PseudoElement, PseudoElementCascadeType, ServoSelectorImpl};
|
||||
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
|
||||
/// element style is precomputed, not from general layout itself.
|
||||
#[inline]
|
||||
fn resolved_style(&self) -> Ref<Arc<ServoComputedValues>> {
|
||||
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
|
||||
match self.get_pseudo_element_type() {
|
||||
PseudoElementType::Normal
|
||||
=> data.style_data.style.as_ref().unwrap(),
|
||||
other
|
||||
=> data.style_data.per_pseudo.get(&other.style_pseudo_element()).unwrap(),
|
||||
}
|
||||
})
|
||||
fn resolved_style(&self) -> Arc<ServoComputedValues> {
|
||||
let data = self.get_style_data().unwrap().borrow();
|
||||
match self.get_pseudo_element_type() {
|
||||
PseudoElementType::Normal
|
||||
=> data.style_data.style.as_ref().unwrap().clone(),
|
||||
other
|
||||
=> data.style_data.per_pseudo.get(&other.style_pseudo_element()).unwrap().clone(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn selected_style(&self, _context: &SharedStyleContext) -> Ref<Arc<ServoComputedValues>> {
|
||||
Ref::map(self.get_style_data().unwrap().borrow(), |data| {
|
||||
data.style_data.per_pseudo
|
||||
.get(&PseudoElement::Selection)
|
||||
.unwrap_or(data.style_data.style.as_ref().unwrap())
|
||||
})
|
||||
fn selected_style(&self, _context: &SharedStyleContext) -> Arc<ServoComputedValues> {
|
||||
let data = self.get_style_data().unwrap().borrow();
|
||||
data.style_data.per_pseudo
|
||||
.get(&PseudoElement::Selection)
|
||||
.unwrap_or(data.style_data.style.as_ref().unwrap()).clone()
|
||||
}
|
||||
|
||||
/// Removes the style from this node.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue