mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +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),
|
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 {
|
pub trait MatchMethods {
|
||||||
/// Inserts and removes the matching `Descendant` selectors from a bloom
|
/// Inserts and removes the matching `Descendant` selectors from a bloom
|
||||||
/// filter. This is used to speed up CSS selector matching to remove
|
/// 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`.
|
/// called to reset the bloom filter after an `insert`.
|
||||||
fn remove_from_bloom_filter(&self, bf: &mut BloomFilter);
|
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
|
/// 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
|
/// 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.
|
/// guarantee that at the type system level yet.
|
||||||
|
@ -543,27 +545,26 @@ impl<'ln> PrivateElementMatchMethods for LayoutElement<'ln> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ln> MatchMethods for LayoutNode<'ln> {
|
impl<'ln> ElementMatchMethods for LayoutElement<'ln> {
|
||||||
fn match_node(&self,
|
fn match_element(&self,
|
||||||
stylist: &Stylist,
|
stylist: &Stylist,
|
||||||
parent_bf: Option<&BloomFilter>,
|
parent_bf: Option<&BloomFilter>,
|
||||||
applicable_declarations: &mut ApplicableDeclarations,
|
applicable_declarations: &mut ApplicableDeclarations,
|
||||||
shareable: &mut bool) {
|
shareable: &mut bool) {
|
||||||
let element = self.as_element().unwrap();
|
let style_attribute = self.style_attribute().as_ref();
|
||||||
let style_attribute = element.style_attribute().as_ref();
|
|
||||||
|
|
||||||
applicable_declarations.normal_shareable =
|
applicable_declarations.normal_shareable =
|
||||||
stylist.push_applicable_declarations(&element,
|
stylist.push_applicable_declarations(self,
|
||||||
parent_bf,
|
parent_bf,
|
||||||
style_attribute,
|
style_attribute,
|
||||||
None,
|
None,
|
||||||
&mut applicable_declarations.normal);
|
&mut applicable_declarations.normal);
|
||||||
stylist.push_applicable_declarations(&element,
|
stylist.push_applicable_declarations(self,
|
||||||
parent_bf,
|
parent_bf,
|
||||||
None,
|
None,
|
||||||
Some(PseudoElement::Before),
|
Some(PseudoElement::Before),
|
||||||
&mut applicable_declarations.before);
|
&mut applicable_declarations.before);
|
||||||
stylist.push_applicable_declarations(&element,
|
stylist.push_applicable_declarations(self,
|
||||||
parent_bf,
|
parent_bf,
|
||||||
None,
|
None,
|
||||||
Some(PseudoElement::After),
|
Some(PseudoElement::After),
|
||||||
|
@ -573,7 +574,9 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
||||||
applicable_declarations.before.is_empty() &&
|
applicable_declarations.before.is_empty() &&
|
||||||
applicable_declarations.after.is_empty()
|
applicable_declarations.after.is_empty()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'ln> MatchMethods for LayoutNode<'ln> {
|
||||||
unsafe fn share_style_if_possible(&self,
|
unsafe fn share_style_if_possible(&self,
|
||||||
style_sharing_candidate_cache:
|
style_sharing_candidate_cache:
|
||||||
&mut StyleSharingCandidateCache,
|
&mut StyleSharingCandidateCache,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
use construct::FlowConstructor;
|
use construct::FlowConstructor;
|
||||||
use context::LayoutContext;
|
use context::LayoutContext;
|
||||||
use css::matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult};
|
use css::matching::{ApplicableDeclarations, ElementMatchMethods, MatchMethods, StyleSharingResult};
|
||||||
use flow::{MutableFlowUtils, PostorderFlowTraversal, PreorderFlowTraversal};
|
use flow::{MutableFlowUtils, PostorderFlowTraversal, PreorderFlowTraversal};
|
||||||
use flow::{self, Flow};
|
use flow::{self, Flow};
|
||||||
use incremental::{self, BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, RestyleDamage};
|
use incremental::{self, BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, RestyleDamage};
|
||||||
|
@ -174,10 +174,10 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
|
||||||
StyleSharingResult::CannotShare(mut shareable) => {
|
StyleSharingResult::CannotShare(mut shareable) => {
|
||||||
let mut applicable_declarations = ApplicableDeclarations::new();
|
let mut applicable_declarations = ApplicableDeclarations::new();
|
||||||
|
|
||||||
if node.as_element().is_some() {
|
if let Some(element) = node.as_element() {
|
||||||
// Perform the CSS selector matching.
|
// Perform the CSS selector matching.
|
||||||
let stylist = unsafe { &*self.layout_context.shared.stylist };
|
let stylist = unsafe { &*self.layout_context.shared.stylist };
|
||||||
node.match_node(stylist,
|
element.match_element(stylist,
|
||||||
Some(&*bf),
|
Some(&*bf),
|
||||||
&mut applicable_declarations,
|
&mut applicable_declarations,
|
||||||
&mut shareable);
|
&mut shareable);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue