Bug 1364746 - stylo: Continue to propagate quirks mode information to Servo r=bholley
authorNazım Can Altınova <canaltinova@gmail.com>
Sun, 14 May 2017 18:11:18 +0300
changeset 358769 dad46e25b2d79eaa5194d4539fdb5923235f3d21
parent 358768 d58fda39820b7019e8364f033dab5183d939f678
child 358770 3dda5445e08d66a652fbbb7246fb549601e545fa
push id31838
push userkwierso@gmail.com
push dateWed, 17 May 2017 20:32:10 +0000
treeherdermozilla-central@b133ec74e3d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1364746
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1364746 - stylo: Continue to propagate quirks mode information to Servo r=bholley I've propagated quirks mode information on some places. But we needed to pass quirks mode to some other FFI functions to be able to handle that information properly. MozReview-Commit-ID: JovQWjN3YJx
dom/animation/KeyframeUtils.cpp
dom/canvas/CanvasRenderingContext2D.cpp
dom/smil/nsSMILCSSValueType.cpp
dom/svg/nsSVGElement.cpp
layout/style/Loader.cpp
layout/style/ServoBindingList.h
layout/style/ServoStyleSheet.cpp
layout/style/ServoStyleSheet.h
layout/style/nsDOMCSSDeclaration.cpp
layout/style/nsLayoutStylesheetCache.cpp
layout/style/test/gtest/StyloParsingBench.cpp
--- a/dom/animation/KeyframeUtils.cpp
+++ b/dom/animation/KeyframeUtils.cpp
@@ -740,17 +740,18 @@ KeyframeUtils::ParseProperty(nsCSSProper
   NS_ConvertUTF16toUTF8 value(aValue);
   // FIXME this is using the wrong base uri (bug 1343919)
   RefPtr<URLExtraData> data = new URLExtraData(aDocument->GetDocumentURI(),
                                                aDocument->GetDocumentURI(),
                                                aDocument->NodePrincipal());
   return Servo_ParseProperty(aProperty,
                              &value,
                              data,
-                             ParsingMode::Default).Consume();
+                             ParsingMode::Default,
+                             aDocument->GetCompatibilityMode()).Consume();
 }
 
 // ------------------------------------------------------------------
 //
 // Internal helpers
 //
 // ------------------------------------------------------------------
 
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2806,33 +2806,35 @@ CreateDeclarationForServo(nsCSSPropertyI
                      aDocument->NodePrincipal());
 
   NS_ConvertUTF16toUTF8 value(aPropertyValue);
 
   RefPtr<RawServoDeclarationBlock> servoDeclarations =
     Servo_ParseProperty(aProperty,
                         &value,
                         data,
-                        ParsingMode::Default).Consume();
+                        ParsingMode::Default,
+                        aDocument->GetCompatibilityMode()).Consume();
 
   if (!servoDeclarations) {
     // We got a syntax error.  The spec says this value must be ignored.
     return nullptr;
   }
 
   // From canvas spec, force to set line-height property to 'normal' font
   // property.
   if (aProperty == eCSSProperty_font) {
     const nsCString normalString = NS_LITERAL_CSTRING("normal");
     Servo_DeclarationBlock_SetPropertyById(servoDeclarations,
                                            eCSSProperty_line_height,
                                            &normalString,
                                            false,
                                            data,
-                                           ParsingMode::Default);
+                                           ParsingMode::Default,
+                                           aDocument->GetCompatibilityMode());
   }
 
   return servoDeclarations.forget();
 }
 
 static already_AddRefed<RawServoDeclarationBlock>
 CreateFontDeclarationForServo(const nsAString& aFont,
                               nsIDocument* aDocument)
--- a/dom/smil/nsSMILCSSValueType.cpp
+++ b/dom/smil/nsSMILCSSValueType.cpp
@@ -488,17 +488,18 @@ ValueFromStringHelper(nsCSSPropertyID aP
                                                doc->GetDocumentURI(),
                                                doc->NodePrincipal());
   NS_ConvertUTF16toUTF8 value(aString);
   RefPtr<RawServoDeclarationBlock> servoDeclarationBlock =
     Servo_ParseProperty(aPropID,
                         &value,
                         data,
                         ParsingMode::AllowUnitlessLength |
-                        ParsingMode::AllowAllNumericValues).Consume();
+                        ParsingMode::AllowAllNumericValues,
+                        doc->GetCompatibilityMode()).Consume();
   if (!servoDeclarationBlock) {
     return nullptr;
   }
 
   // Compute value
   PropertyValuePair propValuePair;
   propValuePair.mProperty = aPropID;
   propValuePair.mServoDeclarationBlock = servoDeclarationBlock;
--- a/dom/svg/nsSVGElement.cpp
+++ b/dom/svg/nsSVGElement.cpp
@@ -1233,17 +1233,17 @@ MappedAttrParser::ParseMappedAttrValue(n
                             mElement->NodePrincipal(), mDecl->AsGecko(), &changed, false, true);
     } else {
       NS_ConvertUTF16toUTF8 value(aMappedAttrValue);
       // FIXME (bug 1343964): Figure out a better solution for sending the base uri to servo
       RefPtr<URLExtraData> data = new URLExtraData(mBaseURI, mDocURI,
                                                    mElement->NodePrincipal());
       changed = Servo_DeclarationBlock_SetPropertyById(
         mDecl->AsServo()->Raw(), propertyID, &value, false, data,
-        ParsingMode::AllowUnitlessLength);
+        ParsingMode::AllowUnitlessLength, mElement->OwnerDoc()->GetCompatibilityMode());
     }
 
     if (changed) {
       // The normal reporting of use counters by the nsCSSParser won't happen
       // since it doesn't have a sheet.
       if (nsCSSProps::IsShorthand(propertyID)) {
         CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, propertyID,
                                              CSSEnabledState::eForAllContent) {
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1775,17 +1775,18 @@ Loader::ParseSheet(const nsAString& aInp
     rv = parser.ParseSheet(aInput, sheetURI, baseURI,
                            aLoadData->mSheet->Principal(),
                            aLoadData->mLineNumber);
   } else {
     rv =
       aLoadData->mSheet->AsServo()->ParseSheet(this,
                                                aInput, sheetURI, baseURI,
                                                aLoadData->mSheet->Principal(),
-                                               aLoadData->mLineNumber);
+                                               aLoadData->mLineNumber,
+                                               GetCompatibilityMode());
   }
 
   mParsingDatas.RemoveElementAt(mParsingDatas.Length() - 1);
 
   if (NS_FAILED(rv)) {
     LOG_ERROR(("  Low-level error in parser!"));
     SheetComplete(aLoadData, rv);
     return rv;
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -26,17 +26,18 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_Empt
                    mozilla::css::SheetParsingMode parsing_mode)
 SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8Bytes, RawServoStyleSheetStrong,
                    mozilla::css::Loader* loader,
                    mozilla::ServoStyleSheet* gecko_stylesheet,
                    const nsACString* data,
                    mozilla::css::SheetParsingMode parsing_mode,
                    const RawServoMediaList* media_list,
                    RawGeckoURLExtraData* extra_data,
-                   uint32_t line_number_offset)
+                   uint32_t line_number_offset,
+                   nsCompatibility quirks_mode)
 SERVO_BINDING_FUNC(Servo_ImportRule_GetSheet,
                    RawServoStyleSheetStrong,
                    const RawServoImportRuleBorrowed import_rule)
 SERVO_BINDING_FUNC(Servo_StyleSheet_ClearAndUpdate,
                    void,
                    RawServoStyleSheetBorrowed stylesheet,
                    mozilla::css::Loader* loader,
                    mozilla::ServoStyleSheet* gecko_stylesheet,
@@ -149,17 +150,18 @@ SERVO_BINDING_FUNC(Servo_SupportsRule_Ge
 SERVO_BINDING_FUNC(Servo_DocumentRule_GetConditionText, void,
                    RawServoDocumentRuleBorrowed rule, nsAString* result)
 
 // Animations API
 SERVO_BINDING_FUNC(Servo_ParseProperty,
                    RawServoDeclarationBlockStrong,
                    nsCSSPropertyID property, const nsACString* value,
                    RawGeckoURLExtraData* data,
-                   mozilla::ParsingMode parsing_mode)
+                   mozilla::ParsingMode parsing_mode,
+                   nsCompatibility quirks_mode)
 SERVO_BINDING_FUNC(Servo_ParseEasing, bool,
                    const nsAString* easing,
                    RawGeckoURLExtraData* data,
                    nsTimingFunctionBorrowedMut output)
 SERVO_BINDING_FUNC(Servo_GetComputedKeyframeValues, void,
                    RawGeckoKeyframeListBorrowed keyframes,
                    ServoComputedValuesBorrowed style,
                    ServoComputedValuesBorrowedOrNull parent_style,
@@ -244,23 +246,25 @@ SERVO_BINDING_FUNC(Servo_DeclarationBloc
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_GetPropertyIsImportant, bool,
                    RawServoDeclarationBlockBorrowed declarations,
                    const nsACString* property)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetProperty, bool,
                    RawServoDeclarationBlockBorrowed declarations,
                    const nsACString* property,
                    const nsACString* value, bool is_important,
                    RawGeckoURLExtraData* data,
-                   mozilla::ParsingMode parsing_mode)
+                   mozilla::ParsingMode parsing_mode,
+                   nsCompatibility quirks_mode)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_SetPropertyById, bool,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property,
                    const nsACString* value, bool is_important,
                    RawGeckoURLExtraData* data,
-                   mozilla::ParsingMode parsing_mode)
+                   mozilla::ParsingMode parsing_mode,
+                   nsCompatibility quirks_mode)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemoveProperty, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    const nsACString* property)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_RemovePropertyById, void,
                    RawServoDeclarationBlockBorrowed declarations,
                    nsCSSPropertyID property)
 SERVO_BINDING_FUNC(Servo_DeclarationBlock_HasCSSWideKeyword, bool,
                    RawServoDeclarationBlockBorrowed declarations,
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -92,30 +92,32 @@ ServoStyleSheet::HasRules() const
 }
 
 nsresult
 ServoStyleSheet::ParseSheet(css::Loader* aLoader,
                             const nsAString& aInput,
                             nsIURI* aSheetURI,
                             nsIURI* aBaseURI,
                             nsIPrincipal* aSheetPrincipal,
-                            uint32_t aLineNumber)
+                            uint32_t aLineNumber,
+                            nsCompatibility aCompatMode)
 {
   MOZ_ASSERT_IF(mMedia, mMedia->IsServo());
   RefPtr<URLExtraData> extraData =
     new URLExtraData(aBaseURI, aSheetURI, aSheetPrincipal);
 
   NS_ConvertUTF16toUTF8 input(aInput);
   if (!Inner()->mSheet) {
     auto* mediaList = static_cast<ServoMediaList*>(mMedia.get());
     RawServoMediaList* media = mediaList ?  &mediaList->RawList() : nullptr;
 
     Inner()->mSheet =
       Servo_StyleSheet_FromUTF8Bytes(
-          aLoader, this, &input, mParsingMode, media, extraData, aLineNumber
+          aLoader, this, &input, mParsingMode, media, extraData,
+          aLineNumber, aCompatMode
       ).Consume();
   } else {
     // TODO(emilio): Once we have proper inner cloning (which we don't right
     // now) we should update the mediaList here too, though it's slightly
     // tricky.
     Servo_StyleSheet_ClearAndUpdate(Inner()->mSheet, aLoader,
                                     this, &input, extraData, aLineNumber);
   }
--- a/layout/style/ServoStyleSheet.h
+++ b/layout/style/ServoStyleSheet.h
@@ -8,16 +8,17 @@
 #define mozilla_ServoStyleSheet_h
 
 #include "mozilla/dom/SRIMetadata.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/ServoBindingTypes.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInfo.h"
 #include "mozilla/URLExtraData.h"
+#include "nsCompatibility.h"
 #include "nsStringFwd.h"
 
 namespace mozilla {
 
 class ServoCSSRuleList;
 
 namespace css {
 class Loader;
@@ -62,17 +63,18 @@ public:
 
   bool HasRules() const;
 
   MOZ_MUST_USE nsresult ParseSheet(css::Loader* aLoader,
                                    const nsAString& aInput,
                                    nsIURI* aSheetURI,
                                    nsIURI* aBaseURI,
                                    nsIPrincipal* aSheetPrincipal,
-                                   uint32_t aLineNumber);
+                                   uint32_t aLineNumber,
+                                   nsCompatibility aCompatMode);
 
   /**
    * Called instead of ParseSheet to initialize the Servo stylesheet object
    * for a failed load. Either ParseSheet or LoadFailed must be called before
    * adding a ServoStyleSheet to a ServoStyleSet.
    */
   void LoadFailed();
 
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -325,17 +325,17 @@ nsDOMCSSDeclaration::ModifyDeclaration(G
 
     aGeckoFunc(decl->AsGecko(), geckoEnv, &changed);
   } else {
     ServoCSSParsingEnvironment servoEnv = GetServoCSSParsingEnvironment();
     if (!servoEnv.mUrlExtraData) {
       return NS_ERROR_NOT_AVAILABLE;
     }
 
-    changed = aServoFunc(decl->AsServo(), servoEnv.mUrlExtraData);
+    changed = aServoFunc(decl->AsServo(), servoEnv);
   }
   if (!changed) {
     // Parsing failed -- but we don't throw an exception for that.
     return NS_OK;
   }
 
   return SetCSSDeclaration(decl);
 }
@@ -347,20 +347,21 @@ nsDOMCSSDeclaration::ParsePropertyValue(
 {
   return ModifyDeclaration(
     [&](Declaration* decl, CSSParsingEnvironment& env, bool* changed) {
       nsCSSParser cssParser(env.mCSSLoader);
       cssParser.ParseProperty(aPropID, aPropValue,
                               env.mSheetURI, env.mBaseURI, env.mPrincipal,
                               decl, changed, aIsImportant);
     },
-    [&](ServoDeclarationBlock* decl, URLExtraData* data) {
+    [&](ServoDeclarationBlock* decl, ServoCSSParsingEnvironment& env) {
       NS_ConvertUTF16toUTF8 value(aPropValue);
       return Servo_DeclarationBlock_SetPropertyById(
-        decl->Raw(), aPropID, &value, aIsImportant, data, ParsingMode::Default);
+        decl->Raw(), aPropID, &value, aIsImportant, env.mUrlExtraData,
+        ParsingMode::Default, env.mCompatMode);
     });
 }
 
 nsresult
 nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
                                               const nsAString& aPropValue,
                                               bool aIsImportant)
 {
@@ -368,22 +369,22 @@ nsDOMCSSDeclaration::ParseCustomProperty
   return ModifyDeclaration(
     [&](Declaration* decl, CSSParsingEnvironment& env, bool* changed) {
       nsCSSParser cssParser(env.mCSSLoader);
       auto propName = Substring(aPropertyName, CSS_CUSTOM_NAME_PREFIX_LENGTH);
       cssParser.ParseVariable(propName, aPropValue, env.mSheetURI,
                               env.mBaseURI, env.mPrincipal, decl,
                               changed, aIsImportant);
     },
-    [&](ServoDeclarationBlock* decl, URLExtraData* data) {
+    [&](ServoDeclarationBlock* decl, ServoCSSParsingEnvironment& env) {
       NS_ConvertUTF16toUTF8 property(aPropertyName);
       NS_ConvertUTF16toUTF8 value(aPropValue);
       return Servo_DeclarationBlock_SetProperty(
-        decl->Raw(), &property, &value, aIsImportant, data,
-        ParsingMode::Default);
+        decl->Raw(), &property, &value, aIsImportant, env.mUrlExtraData,
+        ParsingMode::Default, env.mCompatMode);
     });
 }
 
 nsresult
 nsDOMCSSDeclaration::RemovePropertyInternal(nsCSSPropertyID aPropID)
 {
   DeclarationBlock* olddecl = GetCSSDeclaration(eOperation_RemoveProperty);
   if (!olddecl) {
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -990,17 +990,18 @@ nsLayoutStylesheetCache::BuildPreference
                "sheet without reallocation");
 
   if (sheet->IsGecko()) {
     sheet->AsGecko()->ReparseSheet(sheetText);
   } else {
     ServoStyleSheet* servoSheet = sheet->AsServo();
     // NB: The pref sheet never has @import rules.
     nsresult rv =
-      servoSheet->ParseSheet(nullptr, sheetText, uri, uri, nullptr, 0);
+      servoSheet->ParseSheet(nullptr, sheetText, uri, uri, nullptr, 0,
+                             eCompatibility_FullStandards);
     // Parsing the about:PreferenceStyleSheet URI can only fail on OOM. If we
     // are OOM before we parsed any documents we might as well abort.
     MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
   }
 
 #undef NS_GET_R_G_B
 }
 
--- a/layout/style/test/gtest/StyloParsingBench.cpp
+++ b/layout/style/test/gtest/StyloParsingBench.cpp
@@ -23,17 +23,18 @@ static void ServoParsingBench() {
   NS_NAMED_LITERAL_CSTRING(css_, EXAMPLE_STYLESHEET);
   const nsACString& css = css_;
   ASSERT_TRUE(IsUTF8(css));
 
   RefPtr<URLExtraData> data = new URLExtraData(
     NullPrincipalURI::Create(), nullptr, NullPrincipal::Create());
   for (int i = 0; i < PARSING_REPETITIONS; i++) {
     RefPtr<RawServoStyleSheet> stylesheet = Servo_StyleSheet_FromUTF8Bytes(
-      nullptr, nullptr, &css, eAuthorSheetFeatures, nullptr, data, 0
+      nullptr, nullptr, &css, eAuthorSheetFeatures, nullptr,
+      data, 0, eCompatibility_FullStandards
     ).Consume();
   }
 }
 
 MOZ_GTEST_BENCH(Stylo, Servo_StyleSheet_FromUTF8Bytes_Bench, ServoParsingBench);
 
 #endif