Bug 1364824: Make RebuildAllStyleData's flush async too. r?heycam
If this turns out to be problematic, I won't land it, but I think it's worth
trying.
MozReview-Commit-ID: DyZHGArZnTl
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -69,18 +69,17 @@ ServoRestyleManager::PostRestyleEventFor
{
Servo_NoteExplicitHints(aElement, aRestyleHint, nsChangeHint(0));
}
void
ServoRestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint)
{
- // TODO(emilio): We might be able to do the StyleSet flushing async here too.
- StyleSet()->RebuildData();
+ StyleSet()->ClearData();
mHaveNonAnimationRestyles = true;
// NOTE(emilio): GeckoRestlyeManager does a sync style flush, which seems
// not to be needed in my testing.
//
// If it is, we can just do a content flush and call ProcessPendingRestyles.
if (Element* root = mPresContext->Document()->GetRootElement()) {
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -41,17 +41,17 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_Clea
mozilla::ServoStyleSheet* gecko_stylesheet,
const nsACString* data,
RawGeckoURLExtraData* extra_data)
SERVO_BINDING_FUNC(Servo_StyleSheet_HasRules, bool,
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_StyleSheet_GetRules, ServoCssRulesStrong,
RawServoStyleSheetBorrowed sheet)
SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned, RawGeckoPresContextOwned pres_context)
-SERVO_BINDING_FUNC(Servo_StyleSet_RebuildData, void,
+SERVO_BINDING_FUNC(Servo_StyleSet_ClearData, void,
RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet,
uint64_t unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
RawServoStyleSetBorrowed set,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -958,20 +958,21 @@ ServoStyleSet::ComputeAnimationValue(
{
return Servo_AnimationValue_Compute(aDeclarations,
aComputedValues.mCurrentStyle,
aComputedValues.mParentStyle,
mRawSet.get()).Consume();
}
void
-ServoStyleSet::RebuildData()
+ServoStyleSet::ClearData()
{
ClearNonInheritingStyleContexts();
- Servo_StyleSet_RebuildData(mRawSet.get());
+ Servo_StyleSet_ClearData(mRawSet.get());
+ mStylistMayNeedRebuild = true;
}
already_AddRefed<ServoComputedValues>
ServoStyleSet::ResolveServoStyle(Element* aElement)
{
MaybeRebuildStylist();
return Servo_ResolveStyle(aElement, mRawSet.get(),
mAllowResolveStaleStyles).Consume();
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -281,20 +281,22 @@ public:
#ifdef DEBUG
void AssertTreeIsClean();
#else
void AssertTreeIsClean() {}
#endif
/**
- * Rebuild the style data. This will force a stylesheet flush, and also
- * recompute the default computed styles.
+ * Clear the style data.
+ *
+ * This will recompute the default computed values, and schedule a stylesheet
+ * flush.
*/
- void RebuildData();
+ void ClearData();
/**
* Resolve style for the given element, and return it as a
* ServoComputedValues, not an nsStyleContext.
*/
already_AddRefed<ServoComputedValues> ResolveServoStyle(dom::Element* aElement);
bool GetKeyframesForName(const nsString& aName,
--- a/servo/components/style/gecko/data.rs
+++ b/servo/components/style/gecko/data.rs
@@ -86,18 +86,17 @@ impl PerDocumentStyleData {
}
impl PerDocumentStyleDataImpl {
/// Reset the device state because it may have changed.
///
/// Implies also a stylesheet flush.
pub fn reset_device(&mut self, guard: &SharedRwLockReadGuard) {
Arc::get_mut(&mut self.stylist.device).unwrap().reset();
- self.stylesheets.force_dirty();
- self.flush_stylesheets(guard);
+ self.clear_stylist();
}
/// Recreate the style data if the stylesheets have changed.
pub fn flush_stylesheets(&mut self, guard: &SharedRwLockReadGuard) {
if !self.stylesheets.has_changed() {
return;
}
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1135,17 +1135,17 @@ pub extern "C" fn Servo_ComputedValues_I
#[no_mangle]
pub extern "C" fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextOwned)
-> RawServoStyleSetOwned {
let data = Box::new(PerDocumentStyleData::new(pres_context));
data.into_ffi()
}
#[no_mangle]
-pub extern "C" fn Servo_StyleSet_RebuildData(raw_data: RawServoStyleSetBorrowed) {
+pub extern "C" fn Servo_StyleSet_ClearData(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);
}
#[no_mangle]
pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) {