diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index 2e1e17a2ebc..64252c79afc 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -108,18 +108,26 @@ impl PerDocumentStyleDataImpl { let author_style_disabled = self.stylesheets.author_style_disabled(); let mut stylesheets = Vec::>::new(); self.stylesheets.flush(&mut stylesheets); - stylist.update(stylesheets.as_slice(), - &StylesheetGuards::same(guard), - /* ua_sheets = */ None, - /* stylesheets_changed = */ true, - author_style_disabled, - &mut extra_data); + stylist.clear(); + stylist.rebuild(stylesheets.as_slice(), + &StylesheetGuards::same(guard), + /* ua_sheets = */ None, + /* stylesheets_changed = */ true, + author_style_disabled, + &mut extra_data); } /// Get the default computed values for this document. pub fn default_computed_values(&self) -> &Arc { self.stylist.device.default_computed_values_arc() } + + /// Clear the stylist. This will be a no-op if the stylist is + /// already cleared; the stylist handles that. + pub fn clear_stylist(&mut self) { + let mut stylist = Arc::get_mut(&mut self.stylist).unwrap(); + stylist.clear(); + } } unsafe impl HasFFI for PerDocumentStyleData { diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index eddc0d90c76..ddb888a678c 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -1626,16 +1626,16 @@ extern "C" { extern "C" { pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed, sheet: RawServoStyleSheetBorrowed, - unique_id: u32, flush: bool); + unique_id: u32); } extern "C" { pub fn Servo_StyleSet_PrependStyleSheet(set: RawServoStyleSetBorrowed, sheet: RawServoStyleSheetBorrowed, - unique_id: u32, flush: bool); + unique_id: u32); } extern "C" { pub fn Servo_StyleSet_RemoveStyleSheet(set: RawServoStyleSetBorrowed, - unique_id: u32, flush: bool); + unique_id: u32); } extern "C" { pub fn Servo_StyleSet_InsertStyleSheetBefore(set: @@ -1643,8 +1643,7 @@ extern "C" { sheet: RawServoStyleSheetBorrowed, unique_id: u32, - before_unique_id: u32, - flush: bool); + before_unique_id: u32); } extern "C" { pub fn Servo_StyleSet_FlushStyleSheets(set: RawServoStyleSetBorrowed); diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 3de322d9d98..6cb6dae48a5 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -595,60 +595,40 @@ pub extern "C" fn Servo_StyleSheet_ClearAndUpdate(stylesheet: RawServoStyleSheet #[no_mangle] pub extern "C" fn Servo_StyleSet_AppendStyleSheet(raw_data: RawServoStyleSetBorrowed, raw_sheet: RawServoStyleSheetBorrowed, - unique_id: u32, - flush: bool) { - let global_style_data = &*GLOBAL_STYLE_DATA; - let guard = global_style_data.shared_lock.read(); + unique_id: u32) { let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let sheet = HasArcFFI::as_arc(&raw_sheet); data.stylesheets.append_stylesheet(sheet, unique_id); - if flush { - data.flush_stylesheets(&guard); - } + data.clear_stylist(); } #[no_mangle] pub extern "C" fn Servo_StyleSet_PrependStyleSheet(raw_data: RawServoStyleSetBorrowed, raw_sheet: RawServoStyleSheetBorrowed, - unique_id: u32, - flush: bool) { - let global_style_data = &*GLOBAL_STYLE_DATA; - let guard = global_style_data.shared_lock.read(); + unique_id: u32) { let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let sheet = HasArcFFI::as_arc(&raw_sheet); data.stylesheets.prepend_stylesheet(sheet, unique_id); - if flush { - data.flush_stylesheets(&guard); - } + data.clear_stylist(); } #[no_mangle] pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(raw_data: RawServoStyleSetBorrowed, raw_sheet: RawServoStyleSheetBorrowed, unique_id: u32, - before_unique_id: u32, - flush: bool) { - let global_style_data = &*GLOBAL_STYLE_DATA; - let guard = global_style_data.shared_lock.read(); + before_unique_id: u32) { let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let sheet = HasArcFFI::as_arc(&raw_sheet); data.stylesheets.insert_stylesheet_before(sheet, unique_id, before_unique_id); - if flush { - data.flush_stylesheets(&guard); - } + data.clear_stylist(); } #[no_mangle] pub extern "C" fn Servo_StyleSet_RemoveStyleSheet(raw_data: RawServoStyleSetBorrowed, - unique_id: u32, - flush: bool) { - let global_style_data = &*GLOBAL_STYLE_DATA; - let guard = global_style_data.shared_lock.read(); + unique_id: u32) { let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); data.stylesheets.remove_stylesheet(unique_id); - if flush { - data.flush_stylesheets(&guard); - } + data.clear_stylist(); } #[no_mangle] @@ -665,6 +645,7 @@ pub extern "C" fn Servo_StyleSet_NoteStyleSheetsChanged(raw_data: RawServoStyleS let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); data.stylesheets.force_dirty(); data.stylesheets.set_author_style_disabled(author_style_disabled); + data.clear_stylist(); } #[no_mangle]