Skip to content

Commit

Permalink
Bug 1302949 - Add a method to Gecko bindings for comparing declaratio…
Browse files Browse the repository at this point in the history
…n blocks; r=Manishearth

MozReview-Commit-ID: EtX2oLXdGNm
  • Loading branch information
birtles authored and Manishearth committed Oct 9, 2016
1 parent 56e70ae commit 61bcc3a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/style/gecko/wrapper.rs
Expand Up @@ -70,6 +70,16 @@ pub struct GeckoDeclarationBlock {
pub immutable: AtomicBool,
}

impl PartialEq for GeckoDeclarationBlock {
fn eq(&self, other: &GeckoDeclarationBlock) -> bool {
match (&self.declarations, &other.declarations) {
(&None, &None) => true,
(&Some(ref s), &Some(ref other)) => *s.read() == *other.read(),
_ => false,
}
}
}

unsafe impl HasFFI for GeckoDeclarationBlock {
type FFIType = bindings::ServoDeclarationBlock;
}
Expand Down
5 changes: 5 additions & 0 deletions components/style/gecko_bindings/bindings.rs
Expand Up @@ -872,6 +872,11 @@ 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)
Expand Down
7 changes: 7 additions & 0 deletions ports/geckolib/glue.rs
Expand Up @@ -413,6 +413,13 @@ pub extern "C" fn Servo_DeclarationBlock_Release(declarations: ServoDeclarationB
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 {
Expand Down

0 comments on commit 61bcc3a

Please sign in to comment.