mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Make Servo_StyleSet_NoteStyleSheetsChanged take a set of origins to dirty.
This commit is contained in:
parent
d90ff1801a
commit
0cf487b0ac
3 changed files with 57 additions and 2 deletions
|
@ -13,6 +13,7 @@ mod ns_style_auto_array;
|
||||||
pub mod ns_style_coord;
|
pub mod ns_style_coord;
|
||||||
mod ns_t_array;
|
mod ns_t_array;
|
||||||
mod ns_timing_function;
|
mod ns_timing_function;
|
||||||
|
mod origin_flags;
|
||||||
pub mod ownership;
|
pub mod ownership;
|
||||||
pub mod refptr;
|
pub mod refptr;
|
||||||
mod style_complex_color;
|
mod style_complex_color;
|
||||||
|
|
50
components/style/gecko_bindings/sugar/origin_flags.rs
Normal file
50
components/style/gecko_bindings/sugar/origin_flags.rs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
//! Helper to iterate over `OriginFlags` bits.
|
||||||
|
|
||||||
|
use gecko_bindings::structs::OriginFlags;
|
||||||
|
use gecko_bindings::structs::OriginFlags_Author;
|
||||||
|
use gecko_bindings::structs::OriginFlags_User;
|
||||||
|
use gecko_bindings::structs::OriginFlags_UserAgent;
|
||||||
|
use stylesheets::Origin;
|
||||||
|
|
||||||
|
impl OriginFlags {
|
||||||
|
/// Returns an iterator over the origins present in the `OriginFlags`,
|
||||||
|
/// in order from highest priority (author) to lower (user agent).
|
||||||
|
pub fn iter(self) -> OriginFlagsIter {
|
||||||
|
OriginFlagsIter {
|
||||||
|
origin_flags: self,
|
||||||
|
cur: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Iterates over the origins present in an `OriginFlags`, in order from
|
||||||
|
/// highest priority (author) to lower (user agent).
|
||||||
|
pub struct OriginFlagsIter {
|
||||||
|
origin_flags: OriginFlags,
|
||||||
|
cur: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Iterator for OriginFlagsIter {
|
||||||
|
type Item = Origin;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Origin> {
|
||||||
|
loop {
|
||||||
|
let (bit, origin) = match self.cur {
|
||||||
|
0 => (OriginFlags_Author, Origin::Author),
|
||||||
|
1 => (OriginFlags_User, Origin::User),
|
||||||
|
2 => (OriginFlags_UserAgent, Origin::UserAgent),
|
||||||
|
_ => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
self.cur += 1;
|
||||||
|
|
||||||
|
if (self.origin_flags & bit).0 != 0 {
|
||||||
|
return Some(origin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,6 +74,7 @@ use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
|
||||||
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
|
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
|
||||||
use style::gecko_bindings::structs::IterationCompositeOperation;
|
use style::gecko_bindings::structs::IterationCompositeOperation;
|
||||||
use style::gecko_bindings::structs::MallocSizeOf;
|
use style::gecko_bindings::structs::MallocSizeOf;
|
||||||
|
use style::gecko_bindings::structs::OriginFlags;
|
||||||
use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||||
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
|
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
|
||||||
use style::gecko_bindings::structs::SeenPtrs;
|
use style::gecko_bindings::structs::SeenPtrs;
|
||||||
|
@ -954,11 +955,14 @@ pub extern "C" fn Servo_StyleSet_FlushStyleSheets(
|
||||||
pub extern "C" fn Servo_StyleSet_NoteStyleSheetsChanged(
|
pub extern "C" fn Servo_StyleSet_NoteStyleSheetsChanged(
|
||||||
raw_data: RawServoStyleSetBorrowed,
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
author_style_disabled: bool,
|
author_style_disabled: bool,
|
||||||
|
changed_origins: OriginFlags,
|
||||||
) {
|
) {
|
||||||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||||
data.stylesheets.force_dirty();
|
for origin in changed_origins.iter() {
|
||||||
|
data.stylesheets.force_dirty_origin(&origin);
|
||||||
|
data.clear_stylist_origin(&origin);
|
||||||
|
}
|
||||||
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