Cache effective media query results.

This patch also makes RulesIterator not iterate over rules for which we don't
process nested rules.

There's nothing depending on this behavior right now afaik, and this will make
us duplicate less code in following patches.

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1357461
MozReview-Commit-ID: CaMFQtAVnJF
This commit is contained in:
Emilio Cobos Álvarez 2017-06-02 17:38:41 +02:00
parent b5232c940d
commit 5c66d3c77a
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
6 changed files with 242 additions and 87 deletions

View file

@ -747,6 +747,24 @@ pub extern "C" fn Servo_StyleSet_AppendStyleSheet(raw_data: RawServoStyleSetBorr
data.clear_stylist();
}
#[no_mangle]
pub extern "C" fn Servo_StyleSet_MediumFeaturesChanged(
raw_data: RawServoStyleSetBorrowed,
) -> bool {
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
// NOTE(emilio): We don't actually need to flush the stylist here and ensure
// it's up to date.
//
// In case it isn't we would trigger a rebuild + restyle as needed too.
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
data.stylist.media_features_change_changed_style(
data.stylesheets.iter(),
&guard,
)
}
#[no_mangle]
pub extern "C" fn Servo_StyleSet_PrependStyleSheet(raw_data: RawServoStyleSetBorrowed,
raw_sheet: RawServoStyleSheetBorrowed,
@ -1408,6 +1426,7 @@ pub extern "C" fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextOwned)
pub extern "C" fn Servo_StyleSet_RebuildData(raw_data: RawServoStyleSetBorrowed) {
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
data.reset_device(&guard);
}