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,
|
ua_or_user: &ua_or_user_guard,
|
||||||
};
|
};
|
||||||
let mut extra_data = ExtraStyleData {
|
let mut extra_data = ExtraStyleData {
|
||||||
|
author_style_disabled: None,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
};
|
};
|
||||||
let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(
|
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.
|
/// Whether the stylesheets list above has changed since the last restyle.
|
||||||
pub stylesheets_changed: bool,
|
pub stylesheets_changed: bool,
|
||||||
|
|
||||||
|
/// Has author style been disabled?
|
||||||
|
pub author_style_disabled: bool,
|
||||||
|
|
||||||
// FIXME(bholley): Hook these up to something.
|
// FIXME(bholley): Hook these up to something.
|
||||||
/// Unused. Will go away when we actually implement transitions and
|
/// Unused. Will go away when we actually implement transitions and
|
||||||
/// animations properly.
|
/// animations properly.
|
||||||
|
@ -65,6 +68,7 @@ impl PerDocumentStyleData {
|
||||||
stylist: Arc::new(Stylist::new(device)),
|
stylist: Arc::new(Stylist::new(device)),
|
||||||
stylesheets: vec![],
|
stylesheets: vec![],
|
||||||
stylesheets_changed: true,
|
stylesheets_changed: true,
|
||||||
|
author_style_disabled: false,
|
||||||
new_animations_sender: new_anims_sender,
|
new_animations_sender: new_anims_sender,
|
||||||
new_animations_receiver: new_anims_receiver,
|
new_animations_receiver: new_anims_receiver,
|
||||||
running_animations: Arc::new(RwLock::new(HashMap::new())),
|
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 stylist = Arc::get_mut(&mut self.stylist).unwrap();
|
||||||
let mut extra_data = ExtraStyleData {
|
let mut extra_data = ExtraStyleData {
|
||||||
font_faces: &mut self.font_faces,
|
font_faces: &mut self.font_faces,
|
||||||
|
author_style_disabled: Some(self.author_style_disabled),
|
||||||
};
|
};
|
||||||
stylist.update(&self.stylesheets, &StylesheetGuards::same(guard),
|
stylist.update(&self.stylesheets, &StylesheetGuards::same(guard),
|
||||||
None, true, &mut extra_data);
|
None, true, &mut extra_data);
|
||||||
|
|
|
@ -1525,7 +1525,8 @@ extern "C" {
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_NoteStyleSheetsChanged(set:
|
pub fn Servo_StyleSet_NoteStyleSheetsChanged(set:
|
||||||
RawServoStyleSetBorrowed);
|
RawServoStyleSetBorrowed,
|
||||||
|
author_style_disabled: bool);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_FillKeyframesForName(set: RawServoStyleSetBorrowed,
|
pub fn Servo_StyleSet_FillKeyframesForName(set: RawServoStyleSetBorrowed,
|
||||||
|
|
|
@ -78,6 +78,9 @@ pub struct Stylist {
|
||||||
/// If true, the quirks-mode stylesheet is applied.
|
/// If true, the quirks-mode stylesheet is applied.
|
||||||
quirks_mode: bool,
|
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.
|
/// If true, the device has changed, and the stylist needs to be updated.
|
||||||
is_device_dirty: bool,
|
is_device_dirty: bool,
|
||||||
|
|
||||||
|
@ -134,6 +137,10 @@ pub struct ExtraStyleData<'a> {
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub font_faces: &'a mut Vec<(Arc<Locked<FontFaceRule>>, Origin)>,
|
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)]
|
#[allow(missing_docs)]
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub marker: PhantomData<&'a usize>,
|
pub marker: PhantomData<&'a usize>,
|
||||||
|
@ -167,6 +174,7 @@ impl Stylist {
|
||||||
device: Arc::new(device),
|
device: Arc::new(device),
|
||||||
is_device_dirty: true,
|
is_device_dirty: true,
|
||||||
quirks_mode: false,
|
quirks_mode: false,
|
||||||
|
author_style_disabled: false,
|
||||||
|
|
||||||
element_map: PerPseudoElementSelectorMap::new(),
|
element_map: PerPseudoElementSelectorMap::new(),
|
||||||
pseudos_map: Default::default(),
|
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);
|
self.add_stylesheet(stylesheet, guards.author, extra_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -645,9 +645,11 @@ pub extern "C" fn Servo_StyleSet_FlushStyleSheets(raw_data: RawServoStyleSetBorr
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[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();
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
data.stylesheets_changed = true;
|
data.stylesheets_changed = true;
|
||||||
|
data.author_style_disabled = author_style_disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue