mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add an author_style_disabled flag to stylist.update, and associated structs.
MozReview-Commit-ID: FiXyEN4xVnU
This commit is contained in:
parent
54e691b2aa
commit
91a9fb06c7
5 changed files with 29 additions and 3 deletions
|
@ -1085,6 +1085,7 @@ impl LayoutThread {
|
|||
ua_or_user: &ua_or_user_guard,
|
||||
};
|
||||
let mut extra_data = ExtraStyleData {
|
||||
author_style_disabled: None,
|
||||
marker: PhantomData,
|
||||
};
|
||||
let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(
|
||||
|
|
|
@ -32,6 +32,9 @@ pub struct PerDocumentStyleDataImpl {
|
|||
/// Whether the stylesheets list above has changed since the last restyle.
|
||||
pub stylesheets_changed: bool,
|
||||
|
||||
/// Has author style been disabled?
|
||||
pub author_style_disabled: bool,
|
||||
|
||||
// FIXME(bholley): Hook these up to something.
|
||||
/// Unused. Will go away when we actually implement transitions and
|
||||
/// animations properly.
|
||||
|
@ -65,6 +68,7 @@ impl PerDocumentStyleData {
|
|||
stylist: Arc::new(Stylist::new(device)),
|
||||
stylesheets: vec![],
|
||||
stylesheets_changed: true,
|
||||
author_style_disabled: false,
|
||||
new_animations_sender: new_anims_sender,
|
||||
new_animations_receiver: new_anims_receiver,
|
||||
running_animations: Arc::new(RwLock::new(HashMap::new())),
|
||||
|
@ -103,6 +107,7 @@ impl PerDocumentStyleDataImpl {
|
|||
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
|
||||
let mut extra_data = ExtraStyleData {
|
||||
font_faces: &mut self.font_faces,
|
||||
author_style_disabled: Some(self.author_style_disabled),
|
||||
};
|
||||
stylist.update(&self.stylesheets, &StylesheetGuards::same(guard),
|
||||
None, true, &mut extra_data);
|
||||
|
|
|
@ -1525,7 +1525,8 @@ extern "C" {
|
|||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_NoteStyleSheetsChanged(set:
|
||||
RawServoStyleSetBorrowed);
|
||||
RawServoStyleSetBorrowed,
|
||||
author_style_disabled: bool);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_FillKeyframesForName(set: RawServoStyleSetBorrowed,
|
||||
|
|
|
@ -78,6 +78,9 @@ pub struct Stylist {
|
|||
/// If true, the quirks-mode stylesheet is applied.
|
||||
quirks_mode: bool,
|
||||
|
||||
/// If true, authored styles are ignored.
|
||||
author_style_disabled: bool,
|
||||
|
||||
/// If true, the device has changed, and the stylist needs to be updated.
|
||||
is_device_dirty: bool,
|
||||
|
||||
|
@ -134,6 +137,10 @@ pub struct ExtraStyleData<'a> {
|
|||
#[cfg(feature = "gecko")]
|
||||
pub font_faces: &'a mut Vec<(Arc<Locked<FontFaceRule>>, Origin)>,
|
||||
|
||||
/// A parameter to change a setting to ignore author styles during update.
|
||||
/// A None value indicates that update should use existing settings.
|
||||
pub author_style_disabled: Option<bool>,
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[cfg(feature = "servo")]
|
||||
pub marker: PhantomData<&'a usize>,
|
||||
|
@ -167,6 +174,7 @@ impl Stylist {
|
|||
device: Arc::new(device),
|
||||
is_device_dirty: true,
|
||||
quirks_mode: false,
|
||||
author_style_disabled: false,
|
||||
|
||||
element_map: PerPseudoElementSelectorMap::new(),
|
||||
pseudos_map: Default::default(),
|
||||
|
@ -274,7 +282,16 @@ impl Stylist {
|
|||
}
|
||||
}
|
||||
|
||||
for ref stylesheet in doc_stylesheets.iter() {
|
||||
// Absorb changes to author_style_disabled, if supplied.
|
||||
if let Some(author_style_disabled) = extra_data.author_style_disabled {
|
||||
self.author_style_disabled = author_style_disabled;
|
||||
}
|
||||
|
||||
// Only use author stylesheets if author styles are enabled.
|
||||
let author_style_enabled = !self.author_style_disabled;
|
||||
let sheets_to_add = doc_stylesheets.iter().filter(
|
||||
|&s| author_style_enabled || s.origin != Origin::Author);
|
||||
for ref stylesheet in sheets_to_add {
|
||||
self.add_stylesheet(stylesheet, guards.author, extra_data);
|
||||
}
|
||||
|
||||
|
|
|
@ -645,9 +645,11 @@ pub extern "C" fn Servo_StyleSet_FlushStyleSheets(raw_data: RawServoStyleSetBorr
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_NoteStyleSheetsChanged(raw_data: RawServoStyleSetBorrowed) {
|
||||
pub extern "C" fn Servo_StyleSet_NoteStyleSheetsChanged(raw_data: RawServoStyleSetBorrowed,
|
||||
author_style_disabled: bool) {
|
||||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||
data.stylesheets_changed = true;
|
||||
data.author_style_disabled = author_style_disabled;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue