mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add an update_stylesheet method to StylesheetSet.
MozReview-Commit-ID: KlRkApYL8wk
This commit is contained in:
parent
b50cf33efd
commit
c617649e67
3 changed files with 33 additions and 0 deletions
|
@ -1885,6 +1885,11 @@ extern "C" {
|
||||||
unique_id: u64,
|
unique_id: u64,
|
||||||
before_unique_id: u64);
|
before_unique_id: u64);
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_StyleSet_UpdateStyleSheet(set: RawServoStyleSetBorrowed,
|
||||||
|
sheet: RawServoStyleSheetBorrowed,
|
||||||
|
unique_id: u64);
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_FlushStyleSheets(set: RawServoStyleSetBorrowed,
|
pub fn Servo_StyleSet_FlushStyleSheets(set: RawServoStyleSetBorrowed,
|
||||||
doc_elem:
|
doc_elem:
|
||||||
|
|
|
@ -137,6 +137,23 @@ impl StylesheetSet {
|
||||||
guard)
|
guard)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update the sheet that matches the unique_id.
|
||||||
|
pub fn update_stylesheet(
|
||||||
|
&mut self,
|
||||||
|
sheet: &Arc<Stylesheet>,
|
||||||
|
unique_id: u64)
|
||||||
|
{
|
||||||
|
// Since this function doesn't set self.dirty, or call
|
||||||
|
// self.invalidations.collect_invalidations_for, it should
|
||||||
|
// only be called in the case where sheet is a clone of
|
||||||
|
// the sheet it is updating.
|
||||||
|
debug!("StylesheetSet::update_stylesheet");
|
||||||
|
if let Some(entry) = self.entries.iter_mut().find(
|
||||||
|
|e| e.unique_id == unique_id) {
|
||||||
|
entry.sheet = sheet.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove a given stylesheet from the set.
|
/// Remove a given stylesheet from the set.
|
||||||
pub fn remove_stylesheet(&mut self, unique_id: u64) {
|
pub fn remove_stylesheet(&mut self, unique_id: u64) {
|
||||||
debug!("StylesheetSet::remove_stylesheet");
|
debug!("StylesheetSet::remove_stylesheet");
|
||||||
|
|
|
@ -909,6 +909,17 @@ pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(raw_data: RawServoStyleS
|
||||||
data.clear_stylist();
|
data.clear_stylist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn Servo_StyleSet_UpdateStyleSheet(raw_data: RawServoStyleSetBorrowed,
|
||||||
|
raw_sheet: RawServoStyleSheetBorrowed,
|
||||||
|
unique_id: u64) {
|
||||||
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
|
let sheet = HasArcFFI::as_arc(&raw_sheet);
|
||||||
|
data.stylesheets.update_stylesheet(
|
||||||
|
sheet,
|
||||||
|
unique_id);
|
||||||
|
}
|
||||||
|
|
||||||
#[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: u64) {
|
unique_id: u64) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue