mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Clear the stylist when Gecko stylesheets change, but don't rebuild it until explicitly flushed.
This is the servo part of part 3 of the fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1361843
This commit is contained in:
parent
fb5b587371
commit
4588664873
3 changed files with 27 additions and 39 deletions
|
@ -108,7 +108,8 @@ impl PerDocumentStyleDataImpl {
|
||||||
let author_style_disabled = self.stylesheets.author_style_disabled();
|
let author_style_disabled = self.stylesheets.author_style_disabled();
|
||||||
let mut stylesheets = Vec::<Arc<Stylesheet>>::new();
|
let mut stylesheets = Vec::<Arc<Stylesheet>>::new();
|
||||||
self.stylesheets.flush(&mut stylesheets);
|
self.stylesheets.flush(&mut stylesheets);
|
||||||
stylist.update(stylesheets.as_slice(),
|
stylist.clear();
|
||||||
|
stylist.rebuild(stylesheets.as_slice(),
|
||||||
&StylesheetGuards::same(guard),
|
&StylesheetGuards::same(guard),
|
||||||
/* ua_sheets = */ None,
|
/* ua_sheets = */ None,
|
||||||
/* stylesheets_changed = */ true,
|
/* stylesheets_changed = */ true,
|
||||||
|
@ -120,6 +121,13 @@ impl PerDocumentStyleDataImpl {
|
||||||
pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
|
pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
|
||||||
self.stylist.device.default_computed_values_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 {
|
unsafe impl HasFFI for PerDocumentStyleData {
|
||||||
|
|
|
@ -1626,16 +1626,16 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed,
|
pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed,
|
||||||
sheet: RawServoStyleSheetBorrowed,
|
sheet: RawServoStyleSheetBorrowed,
|
||||||
unique_id: u32, flush: bool);
|
unique_id: u32);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_PrependStyleSheet(set: RawServoStyleSetBorrowed,
|
pub fn Servo_StyleSet_PrependStyleSheet(set: RawServoStyleSetBorrowed,
|
||||||
sheet: RawServoStyleSheetBorrowed,
|
sheet: RawServoStyleSheetBorrowed,
|
||||||
unique_id: u32, flush: bool);
|
unique_id: u32);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_RemoveStyleSheet(set: RawServoStyleSetBorrowed,
|
pub fn Servo_StyleSet_RemoveStyleSheet(set: RawServoStyleSetBorrowed,
|
||||||
unique_id: u32, flush: bool);
|
unique_id: u32);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_InsertStyleSheetBefore(set:
|
pub fn Servo_StyleSet_InsertStyleSheetBefore(set:
|
||||||
|
@ -1643,8 +1643,7 @@ extern "C" {
|
||||||
sheet:
|
sheet:
|
||||||
RawServoStyleSheetBorrowed,
|
RawServoStyleSheetBorrowed,
|
||||||
unique_id: u32,
|
unique_id: u32,
|
||||||
before_unique_id: u32,
|
before_unique_id: u32);
|
||||||
flush: bool);
|
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_FlushStyleSheets(set: RawServoStyleSetBorrowed);
|
pub fn Servo_StyleSet_FlushStyleSheets(set: RawServoStyleSetBorrowed);
|
||||||
|
|
|
@ -595,60 +595,40 @@ pub extern "C" fn Servo_StyleSheet_ClearAndUpdate(stylesheet: RawServoStyleSheet
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StyleSet_AppendStyleSheet(raw_data: RawServoStyleSetBorrowed,
|
pub extern "C" fn Servo_StyleSet_AppendStyleSheet(raw_data: RawServoStyleSetBorrowed,
|
||||||
raw_sheet: RawServoStyleSheetBorrowed,
|
raw_sheet: RawServoStyleSheetBorrowed,
|
||||||
unique_id: u32,
|
unique_id: u32) {
|
||||||
flush: bool) {
|
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
|
||||||
let guard = global_style_data.shared_lock.read();
|
|
||||||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
||||||
data.stylesheets.append_stylesheet(sheet, unique_id);
|
data.stylesheets.append_stylesheet(sheet, unique_id);
|
||||||
if flush {
|
data.clear_stylist();
|
||||||
data.flush_stylesheets(&guard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StyleSet_PrependStyleSheet(raw_data: RawServoStyleSetBorrowed,
|
pub extern "C" fn Servo_StyleSet_PrependStyleSheet(raw_data: RawServoStyleSetBorrowed,
|
||||||
raw_sheet: RawServoStyleSheetBorrowed,
|
raw_sheet: RawServoStyleSheetBorrowed,
|
||||||
unique_id: u32,
|
unique_id: u32) {
|
||||||
flush: bool) {
|
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
|
||||||
let guard = global_style_data.shared_lock.read();
|
|
||||||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
||||||
data.stylesheets.prepend_stylesheet(sheet, unique_id);
|
data.stylesheets.prepend_stylesheet(sheet, unique_id);
|
||||||
if flush {
|
data.clear_stylist();
|
||||||
data.flush_stylesheets(&guard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(raw_data: RawServoStyleSetBorrowed,
|
pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(raw_data: RawServoStyleSetBorrowed,
|
||||||
raw_sheet: RawServoStyleSheetBorrowed,
|
raw_sheet: RawServoStyleSheetBorrowed,
|
||||||
unique_id: u32,
|
unique_id: u32,
|
||||||
before_unique_id: u32,
|
before_unique_id: u32) {
|
||||||
flush: bool) {
|
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
|
||||||
let guard = global_style_data.shared_lock.read();
|
|
||||||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
||||||
data.stylesheets.insert_stylesheet_before(sheet, unique_id, before_unique_id);
|
data.stylesheets.insert_stylesheet_before(sheet, unique_id, before_unique_id);
|
||||||
if flush {
|
data.clear_stylist();
|
||||||
data.flush_stylesheets(&guard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StyleSet_RemoveStyleSheet(raw_data: RawServoStyleSetBorrowed,
|
pub extern "C" fn Servo_StyleSet_RemoveStyleSheet(raw_data: RawServoStyleSetBorrowed,
|
||||||
unique_id: u32,
|
unique_id: u32) {
|
||||||
flush: bool) {
|
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
|
||||||
let guard = global_style_data.shared_lock.read();
|
|
||||||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
data.stylesheets.remove_stylesheet(unique_id);
|
data.stylesheets.remove_stylesheet(unique_id);
|
||||||
if flush {
|
data.clear_stylist();
|
||||||
data.flush_stylesheets(&guard);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[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();
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
data.stylesheets.force_dirty();
|
data.stylesheets.force_dirty();
|
||||||
data.stylesheets.set_author_style_disabled(author_style_disabled);
|
data.stylesheets.set_author_style_disabled(author_style_disabled);
|
||||||
|
data.clear_stylist();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue