Bug 1302949 - Add a method to Gecko bindings for comparing declaration blocks; r=manishearth
MozReview-Commit-ID: EtX2oLXdGNm
--- 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)