Bug 1355724 - stylo: Fix propagation of quirks mode information to servo side r?emilio
It was getting inial value from gecko side before and that was always
eCompatibility_NavQuirks. Created an FFI to fetch quirks mode.
MozReview-Commit-ID: 1lXsM9hwldZ
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1182,27 +1182,31 @@ nsPresContext::CompatibilityModeChanged(
return;
}
nsIDocument* doc = mShell->GetDocument();
if (!doc) {
return;
}
+ StyleSetHandle styleSet = mShell->StyleSet();
+ if (styleSet->IsServo()) {
+ styleSet->AsServo()->CompatibilityModeChanged();
+ }
+
if (doc->IsSVGDocument()) {
// SVG documents never load quirk.css.
return;
}
bool needsQuirkSheet = CompatibilityMode() == eCompatibility_NavQuirks;
if (mQuirkSheetAdded == needsQuirkSheet) {
return;
}
- StyleSetHandle styleSet = mShell->StyleSet();
auto cache = nsLayoutStylesheetCache::For(styleSet->BackendType());
StyleSheet* sheet = cache->QuirkSheet();
if (needsQuirkSheet) {
// quirk.css needs to come after html.css; we just keep it at the end.
DebugOnly<nsresult> rv =
styleSet->AppendStyleSheet(SheetType::Agent, sheet);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "failed to insert quirk.css");
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -53,16 +53,18 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_Size
SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned, RawGeckoPresContextOwned pres_context)
SERVO_BINDING_FUNC(Servo_StyleSet_Clear, void,
RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_RebuildData, void,
RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_MediumFeaturesChanged, bool,
RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
+SERVO_BINDING_FUNC(Servo_StyleSet_CompatModeChanged, void,
+ RawServoStyleSetBorrowed raw_data)
SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet,
uint64_t unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet,
uint64_t unique_id)
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1118,16 +1118,22 @@ ServoStyleSet::RebuildData()
void
ServoStyleSet::ClearDataAndMarkDeviceDirty()
{
ClearNonInheritingStyleContexts();
Servo_StyleSet_Clear(mRawSet.get());
mStylistState |= StylistState::FullyDirty;
}
+void
+ServoStyleSet::CompatibilityModeChanged()
+{
+ Servo_StyleSet_CompatModeChanged(mRawSet.get());
+}
+
already_AddRefed<ServoComputedValues>
ServoStyleSet::ResolveServoStyle(Element* aElement)
{
UpdateStylistIfNeeded();
return Servo_ResolveStyle(aElement, mRawSet.get(),
mAllowResolveStaleStyles).Consume();
}
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -342,16 +342,21 @@ public:
/**
* Clears the style data, both style sheet data and cached non-inheriting
* style contexts, and marks the stylist as needing an unconditional full
* rebuild, including a device reset.
*/
void ClearDataAndMarkDeviceDirty();
/**
+ * Notifies the Servo stylesheet that the document's compatibility mode has changed.
+ */
+ void CompatibilityModeChanged();
+
+ /**
* 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,
const nsTimingFunction& aTimingFunction,
const ServoComputedValues* aComputedValues,