mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Define share_style_with_candidate_if_possible on LayoutElement.
This commit is contained in:
parent
e5df6fa753
commit
a9f75b7c4f
1 changed files with 6 additions and 4 deletions
|
@ -420,7 +420,9 @@ trait PrivateMatchMethods {
|
||||||
shareable: bool,
|
shareable: bool,
|
||||||
animate_properties: bool)
|
animate_properties: bool)
|
||||||
-> RestyleDamage;
|
-> RestyleDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
trait PrivateElementMatchMethods {
|
||||||
fn share_style_with_candidate_if_possible(&self,
|
fn share_style_with_candidate_if_possible(&self,
|
||||||
parent_node: Option<LayoutNode>,
|
parent_node: Option<LayoutNode>,
|
||||||
candidate: &StyleSharingCandidate)
|
candidate: &StyleSharingCandidate)
|
||||||
|
@ -504,13 +506,13 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
|
||||||
*style = Some(this_style);
|
*style = Some(this_style);
|
||||||
damage
|
damage
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'ln> PrivateElementMatchMethods for LayoutElement<'ln> {
|
||||||
fn share_style_with_candidate_if_possible(&self,
|
fn share_style_with_candidate_if_possible(&self,
|
||||||
parent_node: Option<LayoutNode>,
|
parent_node: Option<LayoutNode>,
|
||||||
candidate: &StyleSharingCandidate)
|
candidate: &StyleSharingCandidate)
|
||||||
-> Option<Arc<ComputedValues>> {
|
-> Option<Arc<ComputedValues>> {
|
||||||
let element = self.as_element().unwrap();
|
|
||||||
|
|
||||||
let parent_node = match parent_node {
|
let parent_node = match parent_node {
|
||||||
Some(ref parent_node) if parent_node.as_element().is_some() => parent_node,
|
Some(ref parent_node) if parent_node.as_element().is_some() => parent_node,
|
||||||
Some(_) | None => return None,
|
Some(_) | None => return None,
|
||||||
|
@ -528,7 +530,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check tag names, classes, etc.
|
// Check tag names, classes, etc.
|
||||||
if !candidate.can_share_style_with(&element) {
|
if !candidate.can_share_style_with(self) {
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,7 +596,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, &(ref candidate, ())) in style_sharing_candidate_cache.iter().enumerate() {
|
for (i, &(ref candidate, ())) in style_sharing_candidate_cache.iter().enumerate() {
|
||||||
match self.share_style_with_candidate_if_possible(parent.clone(), candidate) {
|
match element.share_style_with_candidate_if_possible(parent.clone(), candidate) {
|
||||||
Some(shared_style) => {
|
Some(shared_style) => {
|
||||||
// Yay, cache hit. Share the style.
|
// Yay, cache hit. Share the style.
|
||||||
let mut layout_data_ref = self.mutate_layout_data();
|
let mut layout_data_ref = self.mutate_layout_data();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue