Bug 1302949 - Add a method to Gecko bindings for comparing declaration blocks; r=manishearth draft
authorBrian Birtles <birtles@gmail.com>
Thu, 15 Sep 2016 16:09:54 +0900
changeset 419994 e145343d87834250f9946ea1cfbd6d0eaf494165
parent 419993 93170aeb0fc7e8044f7e87bf9956906b14e63277
child 419995 a646e4c3425ebed9557d677890a2bab69bc39ca6
push id31064
push userbbirtles@mozilla.com
push dateMon, 03 Oct 2016 04:36:09 +0000
reviewersmanishearth
bugs1302949
milestone52.0a1
Bug 1302949 - Add a method to Gecko bindings for comparing declaration blocks; r=manishearth MozReview-Commit-ID: EtX2oLXdGNm
servo/components/style/gecko/wrapper.rs
servo/components/style/gecko_bindings/bindings.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -68,16 +68,22 @@ pub struct GeckoDeclarationBlock {
     // instance. It wouldn't provide safety as Rust usually promises,
     // but it is fine as far as we only access them in a single thread.
     // If we need to access them in different threads, we would need
     // to redesign how it works with MiscContainer in Gecko side.
     pub cache: AtomicPtr<bindings::nsHTMLCSSStyleSheet>,
     pub immutable: AtomicBool,
 }
 
+impl PartialEq for GeckoDeclarationBlock {
+    fn eq(&self, other: &GeckoDeclarationBlock) -> bool {
+        self.declarations == other.declarations
+    }
+}
+
 unsafe impl HasFFI for GeckoDeclarationBlock {
     type FFIType = bindings::ServoDeclarationBlock;
 }
 unsafe impl HasArcFFI for GeckoDeclarationBlock {}
 
 
 // We can eliminate OpaqueStyleData when the bindings move into the style crate.
 fn to_opaque_style_data(d: *mut NonOpaqueStyleData) -> *mut OpaqueStyleData {
--- a/servo/components/style/gecko_bindings/bindings.rs
+++ b/servo/components/style/gecko_bindings/bindings.rs
@@ -867,16 +867,21 @@ extern "C" {
     pub fn Servo_DeclarationBlock_AddRef(declarations:
                                              ServoDeclarationBlockBorrowed);
 }
 extern "C" {
     pub fn Servo_DeclarationBlock_Release(declarations:
                                               ServoDeclarationBlockBorrowed);
 }
 extern "C" {
+    pub fn Servo_DeclarationBlock_Equals(a: ServoDeclarationBlockBorrowed,
+                                         b: ServoDeclarationBlockBorrowed)
+     -> bool;
+}
+extern "C" {
     pub fn Servo_DeclarationBlock_GetCache(declarations:
                                                ServoDeclarationBlockBorrowed)
      -> *mut nsHTMLCSSStyleSheet;
 }
 extern "C" {
     pub fn Servo_DeclarationBlock_SetImmutable(declarations:
                                                    ServoDeclarationBlockBorrowed);
 }
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -408,16 +408,23 @@ pub extern "C" fn Servo_DeclarationBlock
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_DeclarationBlock_Release(declarations: ServoDeclarationBlockBorrowed) {
     unsafe { GeckoDeclarationBlock::release(declarations) };
 }
 
 #[no_mangle]
+pub extern "C" fn Servo_DeclarationBlock_Equals(a: ServoDeclarationBlockBorrowed,
+                                                b: ServoDeclarationBlockBorrowed)
+                                                -> bool {
+    GeckoDeclarationBlock::as_arc(&a) == GeckoDeclarationBlock::as_arc(&b)
+}
+
+#[no_mangle]
 pub extern "C" fn Servo_DeclarationBlock_GetCache(declarations: ServoDeclarationBlockBorrowed)
                                                  -> *mut nsHTMLCSSStyleSheet {
     GeckoDeclarationBlock::as_arc(&declarations).cache.load(Ordering::Relaxed)
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_DeclarationBlock_SetImmutable(declarations: ServoDeclarationBlockBorrowed) {
     GeckoDeclarationBlock::as_arc(&declarations).immutable.store(true, Ordering::Relaxed)