mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Define match_node on LayoutElement as match_element.
This commit is contained in:
parent
a9f75b7c4f
commit
5c7dc4c633
2 changed files with 26 additions and 23 deletions
|
@ -371,6 +371,14 @@ pub enum StyleSharingResult {
|
|||
StyleWasShared(usize, RestyleDamage),
|
||||
}
|
||||
|
||||
pub trait ElementMatchMethods {
|
||||
fn match_element(&self,
|
||||
stylist: &Stylist,
|
||||
parent_bf: Option<&BloomFilter>,
|
||||
applicable_declarations: &mut ApplicableDeclarations,
|
||||
shareable: &mut bool);
|
||||
}
|
||||
|
||||
pub trait MatchMethods {
|
||||
/// Inserts and removes the matching `Descendant` selectors from a bloom
|
||||
/// filter. This is used to speed up CSS selector matching to remove
|
||||
|
@ -385,12 +393,6 @@ pub trait MatchMethods {
|
|||
/// called to reset the bloom filter after an `insert`.
|
||||
fn remove_from_bloom_filter(&self, bf: &mut BloomFilter);
|
||||
|
||||
fn match_node(&self,
|
||||
stylist: &Stylist,
|
||||
parent_bf: Option<&BloomFilter>,
|
||||
applicable_declarations: &mut ApplicableDeclarations,
|
||||
shareable: &mut bool);
|
||||
|
||||
/// Attempts to share a style with another node. This method is unsafe because it depends on
|
||||
/// the `style_sharing_candidate_cache` having only live nodes in it, and we have no way to
|
||||
/// guarantee that at the type system level yet.
|
||||
|
@ -543,27 +545,26 @@ impl<'ln> PrivateElementMatchMethods for LayoutElement<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'ln> MatchMethods for LayoutNode<'ln> {
|
||||
fn match_node(&self,
|
||||
stylist: &Stylist,
|
||||
parent_bf: Option<&BloomFilter>,
|
||||
applicable_declarations: &mut ApplicableDeclarations,
|
||||
shareable: &mut bool) {
|
||||
let element = self.as_element().unwrap();
|
||||
let style_attribute = element.style_attribute().as_ref();
|
||||
impl<'ln> ElementMatchMethods for LayoutElement<'ln> {
|
||||
fn match_element(&self,
|
||||
stylist: &Stylist,
|
||||
parent_bf: Option<&BloomFilter>,
|
||||
applicable_declarations: &mut ApplicableDeclarations,
|
||||
shareable: &mut bool) {
|
||||
let style_attribute = self.style_attribute().as_ref();
|
||||
|
||||
applicable_declarations.normal_shareable =
|
||||
stylist.push_applicable_declarations(&element,
|
||||
stylist.push_applicable_declarations(self,
|
||||
parent_bf,
|
||||
style_attribute,
|
||||
None,
|
||||
&mut applicable_declarations.normal);
|
||||
stylist.push_applicable_declarations(&element,
|
||||
stylist.push_applicable_declarations(self,
|
||||
parent_bf,
|
||||
None,
|
||||
Some(PseudoElement::Before),
|
||||
&mut applicable_declarations.before);
|
||||
stylist.push_applicable_declarations(&element,
|
||||
stylist.push_applicable_declarations(self,
|
||||
parent_bf,
|
||||
None,
|
||||
Some(PseudoElement::After),
|
||||
|
@ -573,7 +574,9 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
|||
applicable_declarations.before.is_empty() &&
|
||||
applicable_declarations.after.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> MatchMethods for LayoutNode<'ln> {
|
||||
unsafe fn share_style_if_possible(&self,
|
||||
style_sharing_candidate_cache:
|
||||
&mut StyleSharingCandidateCache,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use construct::FlowConstructor;
|
||||
use context::LayoutContext;
|
||||
use css::matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult};
|
||||
use css::matching::{ApplicableDeclarations, ElementMatchMethods, MatchMethods, StyleSharingResult};
|
||||
use flow::{MutableFlowUtils, PostorderFlowTraversal, PreorderFlowTraversal};
|
||||
use flow::{self, Flow};
|
||||
use incremental::{self, BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, RestyleDamage};
|
||||
|
@ -174,13 +174,13 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
|
|||
StyleSharingResult::CannotShare(mut shareable) => {
|
||||
let mut applicable_declarations = ApplicableDeclarations::new();
|
||||
|
||||
if node.as_element().is_some() {
|
||||
if let Some(element) = node.as_element() {
|
||||
// Perform the CSS selector matching.
|
||||
let stylist = unsafe { &*self.layout_context.shared.stylist };
|
||||
node.match_node(stylist,
|
||||
Some(&*bf),
|
||||
&mut applicable_declarations,
|
||||
&mut shareable);
|
||||
element.match_element(stylist,
|
||||
Some(&*bf),
|
||||
&mut applicable_declarations,
|
||||
&mut shareable);
|
||||
} else if node.has_changed() {
|
||||
ThreadSafeLayoutNode::new(&node).set_restyle_damage(
|
||||
incremental::rebuild_and_reflow())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue