Bug 1390691 - Fix up Servo_StyleSet_MediumFeaturesChanged for Linux 32-bit ABI. r=Manishearth draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 15 Aug 2017 17:10:13 -0500
changeset 647209 370fda11d7f9e3b5c81ed2f17174e1bc394eb6da
parent 647208 da153f89548af00b3151909cfd4f2d55ae6fec8b
child 726426 0479b238525127b1240c3389c47cdc36b4de0900
push id74321
push userbmo:jryans@gmail.com
push dateWed, 16 Aug 2017 03:16:57 +0000
reviewersManishearth
bugs1390691
milestone57.0a1
Bug 1390691 - Fix up Servo_StyleSet_MediumFeaturesChanged for Linux 32-bit ABI. r=Manishearth Bindgen bitfield enums don't work as return values with the Linux 32-bit ABI at the moment because they wrap the value in a struct. This causes the Rust side to believe the caller will pass along space for the struct return value, while C++ believes it's just an integer value. MozReview-Commit-ID: LY6z7lEKgOp
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -58,17 +58,20 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_Size
 SERVO_BINDING_FUNC(Servo_StyleSheet_GetOrigin,
                    mozilla::OriginFlags,
                    RawServoStyleSheetContentsBorrowed sheet)
 SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSet*, RawGeckoPresContextOwned pres_context)
 SERVO_BINDING_FUNC(Servo_StyleSet_Clear, void,
                    RawServoStyleSetBorrowed set)
 SERVO_BINDING_FUNC(Servo_StyleSet_RebuildCachedData, void,
                    RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_StyleSet_MediumFeaturesChanged, mozilla::OriginFlags,
+// We'd like to return `OriginFlags` here, but bindgen bitfield enums don't
+// work as return values with the Linux 32-bit ABI at the moment because
+// they wrap the value in a struct.
+SERVO_BINDING_FUNC(Servo_StyleSet_MediumFeaturesChanged, uint8_t,
                    RawServoStyleSetBorrowed set, bool* viewport_units_used)
 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,
                    const mozilla::ServoStyleSheet* gecko_sheet)
 SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -162,18 +162,18 @@ ServoStyleSet::InvalidateStyleForCSSRule
   MOZ_ASSERT(StylistNeedsUpdate());
   mPresContext->RestyleManager()->AsServo()->PostRestyleEventForCSSRuleChanges();
 }
 
 nsRestyleHint
 ServoStyleSet::MediumFeaturesChanged(bool aViewportChanged)
 {
   bool viewportUnitsUsed = false;
-  const OriginFlags rulesChanged =
-    Servo_StyleSet_MediumFeaturesChanged(mRawSet.get(), &viewportUnitsUsed);
+  const OriginFlags rulesChanged = static_cast<OriginFlags>(
+    Servo_StyleSet_MediumFeaturesChanged(mRawSet.get(), &viewportUnitsUsed));
 
   if (rulesChanged != OriginFlags(0)) {
     MarkOriginsDirty(rulesChanged);
     return eRestyle_Subtree;
   }
 
   if (viewportUnitsUsed && aViewportChanged) {
     return eRestyle_ForceDescendants;