Bug 1325878: Support deep-cloning of ServoMediaLists. r=xidorn

MozReview-Commit-ID: K7NFe1tKrAZ
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2017-04-10 14:36:45 +08:00
parent 2999222436
commit 27ca9e0a46
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 10 additions and 2 deletions

View file

@ -20,7 +20,7 @@ pub use servo::media_queries::{Device, Expression};
pub use gecko::media_queries::{Device, Expression};
/// A type that encapsulates a media query list.
#[derive(Debug)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct MediaList {
/// The list of media queries.

View file

@ -1194,11 +1194,19 @@ pub extern "C" fn Servo_DeclarationBlock_RemovePropertyById(declarations: RawSer
#[no_mangle]
pub extern "C" fn Servo_MediaList_Create() -> RawServoMediaListStrong {
let global_style_data = &*GLOBAL_STYLE_DATA;
Arc::new(global_style_data.shared_lock.wrap(MediaList::default())).into_strong()
}
#[no_mangle]
pub extern "C" fn Servo_MediaList_DeepClone(list: RawServoMediaListBorrowed) -> RawServoMediaListStrong {
let global_style_data = &*GLOBAL_STYLE_DATA;
read_locked_arc(list, |list: &MediaList| {
Arc::new(global_style_data.shared_lock.wrap(list.clone()))
.into_strong()
})
}
#[no_mangle]
pub extern "C" fn Servo_MediaList_Matches(list: RawServoMediaListBorrowed,
raw_data: RawServoStyleSetBorrowed)