style: Make Servo_StyleSet_NoteStyleSheetsChanged take a set of origins to dirty.

This commit is contained in:
Cameron McCormack 2017-08-12 18:18:52 +08:00
parent d90ff1801a
commit 0cf487b0ac
3 changed files with 57 additions and 2 deletions

View file

@ -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;

View 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);
}
}
}
}

View file

@ -74,6 +74,7 @@ use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
use style::gecko_bindings::structs::IterationCompositeOperation;
use style::gecko_bindings::structs::MallocSizeOf;
use style::gecko_bindings::structs::OriginFlags;
use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
use style::gecko_bindings::structs::SeenPtrs;
@ -954,11 +955,14 @@ pub extern "C" fn Servo_StyleSet_FlushStyleSheets(
pub extern "C" fn Servo_StyleSet_NoteStyleSheetsChanged(
raw_data: RawServoStyleSetBorrowed,
author_style_disabled: bool,
changed_origins: OriginFlags,
) {
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.clear_stylist();
}
#[no_mangle]