mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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;
|
||||
mod ns_t_array;
|
||||
mod ns_timing_function;
|
||||
mod origin_flags;
|
||||
pub mod ownership;
|
||||
pub mod refptr;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue