style: Add FFI function to compare ComputedValues for custom property differences.
draft
style: Add FFI function to compare ComputedValues for custom property differences.
MozReview-Commit-ID: 9ayoBjzZTdG
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -187,16 +187,21 @@ impl ComputedValues {
}
/// Clone the visited style. Used for inheriting parent styles in
/// StyleBuilder::for_inheritance.
pub fn clone_visited_style(&self) -> Option<Arc<ComputedValues>> {
self.visited_style.clone()
}
+ /// Gets a reference to the custom properties map (if one exists).
+ pub fn get_custom_properties(&self) -> Option<<&::custom_properties::CustomPropertiesMap> {
+ self.custom_properties.as_ref().map(|x| &**x)
+ }
+
pub fn custom_properties(&self) -> Option<Arc<CustomPropertiesMap>> {
self.custom_properties.clone()
}
#[allow(non_snake_case)]
pub fn has_moz_binding(&self) -> bool {
!self.get_box().gecko.mBinding.mPtr.mRawPtr.is_null()
}
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1728,16 +1728,26 @@ pub extern "C" fn Servo_ComputedValues_G
pub extern "C" fn Servo_ComputedValues_SpecifiesAnimationsOrTransitions(values: ServoComputedValuesBorrowed)
-> bool {
let values = ComputedValues::as_arc(&values);
let b = values.get_box();
b.specifies_animations() || b.specifies_transitions()
}
#[no_mangle]
+pub extern "C" fn Servo_ComputedValues_EqualCustomProperties(
+ first: ServoComputedValuesBorrowed,
+ second: ServoComputedValuesBorrowed
+) -> bool {
+ let first = ComputedValues::as_arc(&first);
+ let second = ComputedValues::as_arc(&second);
+ first.get_custom_properties() == second.get_custom_properties()
+}
+
+#[no_mangle]
pub extern "C" fn Servo_ComputedValues_GetStyleRuleList(values: ServoComputedValuesBorrowed,
rules: RawGeckoServoStyleRuleListBorrowedMut) {
let values = ComputedValues::as_arc(&values);
if let Some(ref rule_node) = values.rules {
let mut result = vec![];
for node in rule_node.self_and_ancestors() {
if let &StyleSource::Style(ref rule) = node.style_source() {
result.push(Locked::<StyleRule>::arc_as_borrowed(&rule));