aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2017-10-11 10:29:32 +1100
committerXidorn Quan <me@upsuper.org>2017-10-11 10:29:32 +1100
commit0c40ae70edbc389d03dc2324a1054c6df48962fc (patch)
tree895ee71f18b4dc879d693564a5f3233cc918ebb1
parentbe5839fae6444c5134faa67e43c44d4d277a778a (diff)
downloadservo-0c40ae70edbc389d03dc2324a1054c6df48962fc.tar.gz
servo-0c40ae70edbc389d03dc2324a1054c6df48962fc.zip
Support pseudo-element properly in HasAuthorSpecifiedRules.
-rw-r--r--components/style/gecko/generated/bindings.rs4
-rw-r--r--components/style/rule_tree/mod.rs23
-rw-r--r--ports/geckolib/glue.rs20
3 files changed, 28 insertions, 19 deletions
diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs
index 2dd2506136b..ba6bdaedc47 100644
--- a/components/style/gecko/generated/bindings.rs
+++ b/components/style/gecko/generated/bindings.rs
@@ -2944,7 +2944,9 @@ extern "C" {
primary_style: ServoStyleContextBorrowed);
}
extern "C" {
- pub fn Servo_HasAuthorSpecifiedRules(element: RawGeckoElementBorrowed,
+ pub fn Servo_HasAuthorSpecifiedRules(style: ServoStyleContextBorrowed,
+ element: RawGeckoElementBorrowed,
+ pseudo_type: CSSPseudoElementType,
rule_type_mask: u32,
author_colors_allowed: bool) -> bool;
}
diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs
index 9de2e3daadd..04ef4b1a6c9 100644
--- a/components/style/rule_tree/mod.rs
+++ b/components/style/rule_tree/mod.rs
@@ -7,6 +7,8 @@
//! The rule tree.
use applicable_declarations::ApplicableDeclarationList;
+#[cfg(feature = "gecko")]
+use gecko::selector_parser::PseudoElement;
#[cfg(feature = "servo")]
use heapsize::HeapSizeOf;
#[cfg(feature = "gecko")]
@@ -1077,6 +1079,7 @@ impl StrongRuleNode {
#[cfg(feature = "gecko")]
pub fn has_author_specified_rules<E>(&self,
mut element: E,
+ mut pseudo: Option<PseudoElement>,
guards: &StylesheetGuards,
rule_type_mask: u32,
author_colors_allowed: bool)
@@ -1291,14 +1294,20 @@ impl StrongRuleNode {
if !have_explicit_ua_inherit { break }
// Continue to the parent element and search for the inherited properties.
- element = match element.inheritance_parent() {
- Some(parent) => parent,
- None => break
- };
+ if let Some(pseudo) = pseudo.take() {
+ if pseudo.inherits_from_default_values() {
+ break;
+ }
+ } else {
+ element = match element.inheritance_parent() {
+ Some(parent) => parent,
+ None => break
+ };
- let parent_data = element.mutate_data().unwrap();
- let parent_rule_node = parent_data.styles.primary().rules().clone();
- element_rule_node = Cow::Owned(parent_rule_node);
+ let parent_data = element.mutate_data().unwrap();
+ let parent_rule_node = parent_data.styles.primary().rules().clone();
+ element_rule_node = Cow::Owned(parent_rule_node);
+ }
properties = inherited_properties;
}
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index e41ff305d59..0cf07c469c5 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -1863,26 +1863,24 @@ pub extern "C" fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed,
}
#[no_mangle]
-pub extern "C" fn Servo_HasAuthorSpecifiedRules(element: RawGeckoElementBorrowed,
+pub extern "C" fn Servo_HasAuthorSpecifiedRules(style: ServoStyleContextBorrowed,
+ element: RawGeckoElementBorrowed,
+ pseudo_type: CSSPseudoElementType,
rule_type_mask: u32,
author_colors_allowed: bool)
-> bool
{
let element = GeckoElement(element);
-
- let data =
- element.borrow_data()
- .expect("calling Servo_HasAuthorSpecifiedRules on an unstyled element");
-
- let primary_style = data.styles.primary();
+ let pseudo = PseudoElement::from_pseudo_type(pseudo_type);
let guard = (*GLOBAL_STYLE_DATA).shared_lock.read();
let guards = StylesheetGuards::same(&guard);
- primary_style.rules().has_author_specified_rules(element,
- &guards,
- rule_type_mask,
- author_colors_allowed)
+ style.rules().has_author_specified_rules(element,
+ pseudo,
+ &guards,
+ rule_type_mask,
+ author_colors_allowed)
}
fn get_pseudo_style(