Auto merge of #17644 - emilio:invalidation-stylesheet-removals, r=heycam

stylo: Run the stylehseet invalidation pass also for stylesheet removals

People apparently do all sorts of silly stuff with stylesheets, see Google Inbox
in bug 1379203.

Bug: 1379433
Reviewed-By: heycam
MozReview-Commit-ID: 4x2d3glOFu8
This commit is contained in:
bors-servo 2017-07-09 05:18:36 -07:00 committed by GitHub
commit 00e366ac82
2 changed files with 23 additions and 7 deletions

View file

@ -125,8 +125,8 @@ where
stylist: &Stylist, stylist: &Stylist,
sheet: S, sheet: S,
before_sheet: S, before_sheet: S,
guard: &SharedRwLockReadGuard) guard: &SharedRwLockReadGuard
{ ) {
debug!("StylesheetSet::insert_stylesheet_before"); debug!("StylesheetSet::insert_stylesheet_before");
self.remove_stylesheet_if_present(&sheet); self.remove_stylesheet_if_present(&sheet);
let index = self.entries.iter().position(|entry| { let index = self.entries.iter().position(|entry| {
@ -142,12 +142,20 @@ where
} }
/// Remove a given stylesheet from the set. /// Remove a given stylesheet from the set.
pub fn remove_stylesheet(&mut self, sheet: S) { pub fn remove_stylesheet(
&mut self,
stylist: &Stylist,
sheet: S,
guard: &SharedRwLockReadGuard,
) {
debug!("StylesheetSet::remove_stylesheet"); debug!("StylesheetSet::remove_stylesheet");
self.remove_stylesheet_if_present(&sheet); self.remove_stylesheet_if_present(&sheet);
self.dirty = true; self.dirty = true;
// FIXME(emilio): We can do better! self.invalidations.collect_invalidations_for(
self.invalidations.invalidate_fully(); stylist,
&sheet,
guard
);
} }
/// Notes that the author style has been disabled for this document. /// Notes that the author style has been disabled for this document.

View file

@ -877,7 +877,8 @@ pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(
&data.stylist, &data.stylist,
unsafe { GeckoStyleSheet::new(sheet) }, unsafe { GeckoStyleSheet::new(sheet) },
unsafe { GeckoStyleSheet::new(before_sheet) }, unsafe { GeckoStyleSheet::new(before_sheet) },
&guard); &guard,
);
data.clear_stylist(); data.clear_stylist();
} }
@ -886,8 +887,15 @@ pub extern "C" fn Servo_StyleSet_RemoveStyleSheet(
raw_data: RawServoStyleSetBorrowed, raw_data: RawServoStyleSetBorrowed,
sheet: *const ServoStyleSheet sheet: *const ServoStyleSheet
) { ) {
let global_style_data = &*GLOBAL_STYLE_DATA;
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
data.stylesheets.remove_stylesheet(unsafe { GeckoStyleSheet::new(sheet) }); let mut data = &mut *data;
let guard = global_style_data.shared_lock.read();
data.stylesheets.remove_stylesheet(
&data.stylist,
unsafe { GeckoStyleSheet::new(sheet) },
&guard,
);
data.clear_stylist(); data.clear_stylist();
} }