From 53368e989a9aca88244c8d2d78cdb9c9250a1fa5 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Thu, 3 Sep 2015 11:41:39 -0700 Subject: [PATCH] Backed out 2 changesets (bug 1035091) a=backout Backed out changeset 1fc07bdd9aa8 (bug 1035091) Backed out changeset f6e98029d1cb (bug 1035091) --HG-- rename : layout/style/test/chrome/test_moz_document_matching.html => layout/style/test/chrome/test_moz_document_rules.html rename : layout/style/test/chrome/test_moz_document_nesting.html => layout/style/test/test_bug511909.html rename : layout/style/test/chrome/test_moz_document_serialization.html => layout/style/test/test_rule_serialization.html --- dom/base/nsDocument.cpp | 32 +-- dom/base/nsTreeSanitizer.cpp | 3 +- .../en-US/chrome/layout/css.properties | 1 - dom/svg/SVGDocument.cpp | 4 +- editor/libeditor/nsHTMLEditor.cpp | 3 +- editor/libeditor/tests/test_bug520189.html | 18 +- layout/base/nsStyleSheetService.cpp | 55 ++--- layout/reftests/scoped-style/reftest.list | 1 + .../scoped-style-document-ref.html | 6 + .../scoped-style/scoped-style-document.html | 13 ++ .../conditional3/css-supports-027.xht | 21 ++ .../conditional3/css-supports-028.xht | 20 ++ .../submitted/conditional3/reftest.list | 2 + layout/style/CSSStyleSheet.cpp | 7 +- layout/style/Loader.cpp | 46 ++-- layout/style/Loader.h | 49 +---- layout/style/crashtests/473720-1.html | 1 + layout/style/crashtests/495269-2.html | 12 + layout/style/crashtests/crashtests.list | 2 + .../long-url-list-stack-overflow.html | 23 ++ layout/style/nsCSSParser.cpp | 62 ++---- layout/style/nsCSSParser.h | 7 +- layout/style/nsLayoutStylesheetCache.cpp | 51 ++--- layout/style/nsLayoutStylesheetCache.h | 11 +- layout/style/test/chrome/chrome.ini | 10 +- .../chrome/moz_document_condition_text.css | 10 - .../test/chrome/moz_document_nesting.css | 89 -------- .../chrome/moz_document_serialization.css | 9 - .../test_moz_document_condition_text.html | 61 ------ .../chrome/test_moz_document_crashes.html | 53 ----- .../chrome/test_moz_document_nesting.html | 120 ---------- ...hing.html => test_moz_document_rules.html} | 0 .../test_moz_document_serialization.html | 50 ----- .../chrome/test_moz_document_usability.html | 56 ----- layout/style/test/mochitest.ini | 2 + layout/style/test/test_bug511909.html | 205 ++++++++++++++++++ layout/style/test/test_condition_text.html | 70 ++++-- layout/style/test/test_css_eof_handling.html | 10 + layout/style/test/test_rule_insertion.html | 1 + .../style/test/test_rule_serialization.html | 53 +++++ 40 files changed, 531 insertions(+), 718 deletions(-) create mode 100644 layout/reftests/scoped-style/scoped-style-document-ref.html create mode 100644 layout/reftests/scoped-style/scoped-style-document.html create mode 100644 layout/reftests/w3c-css/submitted/conditional3/css-supports-027.xht create mode 100644 layout/reftests/w3c-css/submitted/conditional3/css-supports-028.xht create mode 100644 layout/style/crashtests/495269-2.html create mode 100644 layout/style/crashtests/long-url-list-stack-overflow.html delete mode 100644 layout/style/test/chrome/moz_document_condition_text.css delete mode 100644 layout/style/test/chrome/moz_document_nesting.css delete mode 100644 layout/style/test/chrome/moz_document_serialization.css delete mode 100644 layout/style/test/chrome/test_moz_document_condition_text.html delete mode 100644 layout/style/test/chrome/test_moz_document_crashes.html delete mode 100644 layout/style/test/chrome/test_moz_document_nesting.html rename layout/style/test/chrome/{test_moz_document_matching.html => test_moz_document_rules.html} (100%) delete mode 100644 layout/style/test/chrome/test_moz_document_serialization.html delete mode 100644 layout/style/test/chrome/test_moz_document_usability.html create mode 100644 layout/style/test/test_bug511909.html create mode 100644 layout/style/test/test_rule_serialization.html diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index f5b3931bf25e..eeb7f2e0d61f 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -4409,8 +4409,7 @@ FindSheet(const nsCOMArray& aSheets, nsIURI* aSheetURI) } nsresult -nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType, - nsIURI* aSheetURI) +nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType, nsIURI* aSheetURI) { NS_PRECONDITION(aSheetURI, "null arg"); @@ -4419,29 +4418,11 @@ nsDocument::LoadAdditionalStyleSheet(additionalSheetType aType, return NS_ERROR_INVALID_ARG; // Loading the sheet sync. - nsRefPtr loader = new css::Loader(); - - css::SheetParsingMode parsingMode; - switch (aType) { - case nsIDocument::eAgentSheet: - parsingMode = css::eAgentSheetFeatures; - break; - - case nsIDocument::eUserSheet: - parsingMode = css::eUserSheetFeatures; - break; - - case nsIDocument::eAuthorSheet: - parsingMode = css::eAuthorSheetFeatures; - break; - - default: - MOZ_CRASH("impossible value for aType"); - } + nsRefPtr loader = new mozilla::css::Loader(); nsRefPtr sheet; - nsresult rv = loader->LoadSheetSync(aSheetURI, parsingMode, true, - getter_AddRefs(sheet)); + nsresult rv = loader->LoadSheetSync(aSheetURI, aType == eAgentSheet, + true, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); sheet->SetOwningDocument(this); @@ -9954,10 +9935,7 @@ nsresult nsDocument::LoadChromeSheetSync(nsIURI* uri, bool isAgentSheet, CSSStyleSheet** sheet) { - css::SheetParsingMode mode = - isAgentSheet ? css::eAgentSheetFeatures - : css::eAuthorSheetFeatures; - return CSSLoader()->LoadSheetSync(uri, mode, isAgentSheet, sheet); + return CSSLoader()->LoadSheetSync(uri, isAgentSheet, isAgentSheet, sheet); } class nsDelayedEventDispatcher : public nsRunnable diff --git a/dom/base/nsTreeSanitizer.cpp b/dom/base/nsTreeSanitizer.cpp index f0496d9ecb27..7ac336b034ae 100644 --- a/dom/base/nsTreeSanitizer.cpp +++ b/dom/base/nsTreeSanitizer.cpp @@ -1103,8 +1103,7 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal, // Create the CSS parser, and parse the CSS text. nsCSSParser parser(nullptr, sheet); rv = parser.ParseSheet(aOriginal, aDocument->GetDocumentURI(), aBaseURI, - aDocument->NodePrincipal(), 0, - mozilla::css::eAuthorSheetFeatures); + aDocument->NodePrincipal(), 0, false); NS_ENSURE_SUCCESS(rv, true); // Mark the sheet as complete. MOZ_ASSERT(!sheet->IsModified(), diff --git a/dom/locales/en-US/chrome/layout/css.properties b/dom/locales/en-US/chrome/layout/css.properties index f558cd779577..102e456727a7 100644 --- a/dom/locales/en-US/chrome/layout/css.properties +++ b/dom/locales/en-US/chrome/layout/css.properties @@ -169,4 +169,3 @@ PEExpectedVariableNameEOF=identifier for variable name PEExpectedVariableName=Expected identifier for variable name but found '%1$S'. PEExpectedVariableFallback=Expected variable reference fallback after ','. PEExpectedVariableCommaOrCloseParen=Expected ',' or ')' after variable name in variable reference but found '%1$S'. -PEMozDocumentRuleNotAllowed=@-moz-document rules may only be used in user style sheets. diff --git a/dom/svg/SVGDocument.cpp b/dom/svg/SVGDocument.cpp index 7270ca183a6f..913f90338270 100644 --- a/dom/svg/SVGDocument.cpp +++ b/dom/svg/SVGDocument.cpp @@ -148,9 +148,7 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded() NS_NewURI(getter_AddRefs(uri), spec); if (uri) { nsRefPtr cssSheet; - cssLoader->LoadSheetSync(uri, - mozilla::css::eAgentSheetFeatures, - true, getter_AddRefs(cssSheet)); + cssLoader->LoadSheetSync(uri, true, true, getter_AddRefs(cssSheet)); if (cssSheet) { EnsureOnDemandBuiltInUASheet(cssSheet); } diff --git a/editor/libeditor/nsHTMLEditor.cpp b/editor/libeditor/nsHTMLEditor.cpp index 8a769b937971..e46ad9851354 100644 --- a/editor/libeditor/nsHTMLEditor.cpp +++ b/editor/libeditor/nsHTMLEditor.cpp @@ -2840,8 +2840,7 @@ nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL) nsRefPtr sheet; // Editor override style sheets may want to style Gecko anonymous boxes rv = ps->GetDocument()->CSSLoader()-> - LoadSheetSync(uaURI, mozilla::css::eAgentSheetFeatures, true, - getter_AddRefs(sheet)); + LoadSheetSync(uaURI, true, true, getter_AddRefs(sheet)); // Synchronous loads should ALWAYS return completed NS_ENSURE_TRUE(sheet, NS_ERROR_NULL_POINTER); diff --git a/editor/libeditor/tests/test_bug520189.html b/editor/libeditor/tests/test_bug520189.html index be4eeff540f8..d1b429000e82 100644 --- a/editor/libeditor/tests/test_bug520189.html +++ b/editor/libeditor/tests/test_bug520189.html @@ -1,10 +1,10 @@ - Test for Bug 520189 + Test for Bug 520182 @@ -79,7 +79,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=520189
 
+  
+
+
diff --git a/layout/style/crashtests/crashtests.list b/layout/style/crashtests/crashtests.list
index 5c587a6467a8..444071f15209 100644
--- a/layout/style/crashtests/crashtests.list
+++ b/layout/style/crashtests/crashtests.list
@@ -49,7 +49,9 @@ load 478321-1.xhtml
 load 512851-1.xhtml
 load 539613-1.xhtml
 load 588627-1.html
+skip load long-url-list-stack-overflow.html # skipped due to being slow (bug 477490)
 load 495269-1.html
+load 495269-2.html
 load 498036-1.html
 load 509155-1.html
 load 509156-1.html
diff --git a/layout/style/crashtests/long-url-list-stack-overflow.html b/layout/style/crashtests/long-url-list-stack-overflow.html
new file mode 100644
index 000000000000..899e858df566
--- /dev/null
+++ b/layout/style/crashtests/long-url-list-stack-overflow.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+ + diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 981edbce5993..4fd1523aad76 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -105,12 +105,6 @@ struct CSSParserInputState { bool mHavePushBack; }; -static_assert(eAuthorSheetFeatures == 0 && - eUserSheetFeatures == 1 && - eAgentSheetFeatures == 2, - "sheet parsing mode constants won't fit " - "in CSSParserImpl::mParsingMode"); - // Your basic top-down recursive descent style parser // The exposed methods and members of this class are precisely those // needed by nsCSSParser, far below. @@ -135,7 +129,7 @@ public: nsIURI* aBaseURI, nsIPrincipal* aSheetPrincipal, uint32_t aLineNumber, - SheetParsingMode aParsingMode); + bool aAllowUnsafeRules); nsresult ParseStyleAttribute(const nsAString& aAttributeValue, nsIURI* aDocURL, @@ -319,20 +313,12 @@ public: uint32_t aLineNumber, uint32_t aLineOffset); - bool AgentRulesEnabled() const { - return mParsingMode == eAgentSheetFeatures; - } - bool UserRulesEnabled() const { - return mParsingMode == eAgentSheetFeatures || - mParsingMode == eUserSheetFeatures; - } - nsCSSProps::EnabledState PropertyEnabledState() const { static_assert(nsCSSProps::eEnabledForAllContent == 0, "nsCSSProps::eEnabledForAllContent should be zero for " "this bitfield to work"); nsCSSProps::EnabledState enabledState = nsCSSProps::eEnabledForAllContent; - if (AgentRulesEnabled()) { + if (mUnsafeRulesEnabled) { enabledState |= nsCSSProps::eEnabledInUASheets; } if (mIsChromeOrCertifiedApp) { @@ -1218,12 +1204,8 @@ protected: // True when the unitless length quirk applies. bool mUnitlessLengthQuirk : 1; - // Controls access to nonstandard style constructs that are not safe - // for use on the public Web but necessary in UA sheets and/or - // useful in user sheets. The only values stored in this field are - // 0, 1, and 2; three bits are allocated to avoid issues should the - // enum type be signed. - SheetParsingMode mParsingMode : 3; + // True if unsafe rules should be allowed + bool mUnsafeRulesEnabled : 1; // True if we are in parsing rules for Chrome or Certified App content, // in which case CSS properties with the @@ -1352,7 +1334,7 @@ CSSParserImpl::CSSParserImpl() mNavQuirkMode(false), mHashlessColorQuirk(false), mUnitlessLengthQuirk(false), - mParsingMode(eAuthorSheetFeatures), + mUnsafeRulesEnabled(false), mIsChromeOrCertifiedApp(false), mViewportUnitsEnabled(true), mHTMLMediaMode(false), @@ -1459,7 +1441,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput, nsIURI* aBaseURI, nsIPrincipal* aSheetPrincipal, uint32_t aLineNumber, - SheetParsingMode aParsingMode) + bool aAllowUnsafeRules) { NS_PRECONDITION(aSheetPrincipal, "Must have principal here!"); NS_PRECONDITION(aBaseURI, "need base URI"); @@ -1504,7 +1486,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput, mSection = eCSSSection_Charset; // sheet is empty, any rules are fair } - mParsingMode = aParsingMode; + mUnsafeRulesEnabled = aAllowUnsafeRules; mIsChromeOrCertifiedApp = dom::IsChromeURI(aSheetURI) || aSheetPrincipal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED; @@ -1530,7 +1512,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput, } ReleaseScanner(); - mParsingMode = eAuthorSheetFeatures; + mUnsafeRulesEnabled = false; mIsChromeOrCertifiedApp = false; // XXX check for low level errors @@ -1708,7 +1690,7 @@ CSSParserImpl::ParseProperty(const nsCSSProperty aPropID, // Check for unknown or preffed off properties if (eCSSProperty_UNKNOWN == aPropID || !(nsCSSProps::IsEnabled(aPropID) || - (AgentRulesEnabled() && + (mUnsafeRulesEnabled && nsCSSProps::PropHasFlags(aPropID, CSS_PROPERTY_ALWAYS_ENABLED_IN_UA_SHEETS)))) { NS_ConvertASCIItoUTF16 propName(nsCSSProps::GetStringValue(aPropID)); @@ -2999,14 +2981,8 @@ CSSParserImpl::ParseAtRule(RuleAppendFunc aAppendFunc, newSection = eCSSSection_General; } else if (mToken.mIdent.LowerCaseEqualsLiteral("-moz-document")) { - if (UserRulesEnabled()) { - parseFunc = &CSSParserImpl::ParseMozDocumentRule; - newSection = eCSSSection_General; - } else { - REPORT_UNEXPECTED_TOKEN(PEMozDocumentRuleNotAllowed); - OUTPUT_ERROR(); - return SkipAtRule(aInAtRule); - } + parseFunc = &CSSParserImpl::ParseMozDocumentRule; + newSection = eCSSSection_General; } else if (mToken.mIdent.LowerCaseEqualsLiteral("font-face")) { parseFunc = &CSSParserImpl::ParseFontFaceRule; @@ -5614,7 +5590,7 @@ CSSParserImpl::ParsePseudoSelector(int32_t& aDataMask, bool pseudoClassIsUserAction = nsCSSPseudoClasses::IsUserActionPseudoClass(pseudoClassType); - if (!AgentRulesEnabled() && + if (!mUnsafeRulesEnabled && ((pseudoElementType < nsCSSPseudoElements::ePseudo_PseudoElementCount && nsCSSPseudoElements::PseudoElementIsUASheetOnly(pseudoElementType)) || (pseudoClassType != nsCSSPseudoClasses::ePseudoClass_NotPseudoClass && @@ -5650,10 +5626,10 @@ CSSParserImpl::ParsePseudoSelector(int32_t& aDataMask, bool isPseudoElement = (pseudoElementType < nsCSSPseudoElements::ePseudo_PseudoElementCount); // anonymous boxes are only allowed if they're the tree boxes or we have - // enabled agent rules + // enabled unsafe rules bool isAnonBox = isTreePseudo || (pseudoElementType == nsCSSPseudoElements::ePseudo_AnonBox && - AgentRulesEnabled()); + mUnsafeRulesEnabled); bool isPseudoClass = (pseudoClassType != nsCSSPseudoClasses::ePseudoClass_NotPseudoClass); @@ -10485,11 +10461,11 @@ CSSParserImpl::ParseSingleValueProperty(nsCSSValue& aValue, return false; } - // We only allow 'script-level' when agent rules are enabled, because + // We only allow 'script-level' when unsafe rules are enabled, because // otherwise it could interfere with rulenode optimizations if used in // a non-MathML-enabled document. We also only allow math-display when - // agent rules are enabled. - if (!AgentRulesEnabled() && + // unsafe rules are enabled. + if (!mUnsafeRulesEnabled && (aPropID == eCSSProperty_script_level || aPropID == eCSSProperty_math_display)) return false; @@ -15805,11 +15781,11 @@ nsCSSParser::ParseSheet(const nsAString& aInput, nsIURI* aBaseURI, nsIPrincipal* aSheetPrincipal, uint32_t aLineNumber, - SheetParsingMode aParsingMode) + bool aAllowUnsafeRules) { return static_cast(mImpl)-> ParseSheet(aInput, aSheetURI, aBaseURI, aSheetPrincipal, aLineNumber, - aParsingMode); + aAllowUnsafeRules); } nsresult diff --git a/layout/style/nsCSSParser.h b/layout/style/nsCSSParser.h index 2810bc8ec20f..8be66ed8f5c8 100644 --- a/layout/style/nsCSSParser.h +++ b/layout/style/nsCSSParser.h @@ -9,7 +9,6 @@ #define nsCSSParser_h___ #include "mozilla/Attributes.h" -#include "mozilla/css/Loader.h" #include "nsCSSProperty.h" #include "nsCSSScanner.h" @@ -33,6 +32,7 @@ class CSSVariableValues; namespace css { class Rule; class Declaration; +class Loader; class StyleRule; } // namespace css } // namespace mozilla @@ -77,14 +77,15 @@ public: * @param aSheetPrincipal the principal of the stylesheet. This must match * the principal of the sheet passed to SetStyleSheet. * @param aLineNumber the line number of the first line of the sheet. - * @param aParsingMode see SheetParsingMode in css/Loader.h + * @param aAllowUnsafeRules see aEnableUnsafeRules in + * mozilla::css::Loader::LoadSheetSync */ nsresult ParseSheet(const nsAString& aInput, nsIURI* aSheetURL, nsIURI* aBaseURI, nsIPrincipal* aSheetPrincipal, uint32_t aLineNumber, - mozilla::css::SheetParsingMode aParsingMode); + bool aAllowUnsafeRules); // Parse HTML style attribute or its equivalent in other markup // languages. aBaseURL is the base url to use for relative links in diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index c97360496150..d30dd0e1cca3 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -19,7 +19,6 @@ #include "nsPrintfCString.h" using namespace mozilla; -using namespace mozilla::css; static bool sNumberControlEnabled; @@ -60,7 +59,7 @@ nsLayoutStylesheetCache::ScrollbarsSheet() if (!gStyleCache->mScrollbarsSheet) { // Scrollbars don't need access to unsafe rules LoadSheetURL("chrome://global/skin/scrollbars.css", - gStyleCache->mScrollbarsSheet, eAuthorSheetFeatures); + gStyleCache->mScrollbarsSheet, false); } return gStyleCache->mScrollbarsSheet; @@ -74,7 +73,7 @@ nsLayoutStylesheetCache::FormsSheet() if (!gStyleCache->mFormsSheet) { // forms.css needs access to unsafe rules LoadSheetURL("resource://gre-resources/forms.css", - gStyleCache->mFormsSheet, eAgentSheetFeatures); + gStyleCache->mFormsSheet, true); } return gStyleCache->mFormsSheet; @@ -91,7 +90,7 @@ nsLayoutStylesheetCache::NumberControlSheet() if (!gStyleCache->mNumberControlSheet) { LoadSheetURL("resource://gre-resources/number-control.css", - gStyleCache->mNumberControlSheet, eAgentSheetFeatures); + gStyleCache->mNumberControlSheet, true); } return gStyleCache->mNumberControlSheet; @@ -118,7 +117,7 @@ nsLayoutStylesheetCache::UASheet() if (!gStyleCache->mUASheet) { LoadSheetURL("resource://gre-resources/ua.css", - gStyleCache->mUASheet, eAgentSheetFeatures); + gStyleCache->mUASheet, true); } return gStyleCache->mUASheet; @@ -131,7 +130,7 @@ nsLayoutStylesheetCache::HTMLSheet() if (!gStyleCache->mHTMLSheet) { LoadSheetURL("resource://gre-resources/html.css", - gStyleCache->mHTMLSheet, eAgentSheetFeatures); + gStyleCache->mHTMLSheet, true); } return gStyleCache->mHTMLSheet; @@ -179,7 +178,7 @@ nsLayoutStylesheetCache::MathMLSheet() if (!gStyleCache->mMathMLSheet) { LoadSheetURL("resource://gre-resources/mathml.css", - gStyleCache->mMathMLSheet, eAgentSheetFeatures); + gStyleCache->mMathMLSheet, true); } return gStyleCache->mMathMLSheet; @@ -200,7 +199,7 @@ nsLayoutStylesheetCache::NoScriptSheet() if (!gStyleCache->mNoScriptSheet) { LoadSheetURL("resource://gre-resources/noscript.css", - gStyleCache->mNoScriptSheet, eAgentSheetFeatures); + gStyleCache->mNoScriptSheet, true); } return gStyleCache->mNoScriptSheet; @@ -213,7 +212,7 @@ nsLayoutStylesheetCache::NoFramesSheet() if (!gStyleCache->mNoFramesSheet) { LoadSheetURL("resource://gre-resources/noframes.css", - gStyleCache->mNoFramesSheet, eAgentSheetFeatures); + gStyleCache->mNoFramesSheet, true); } return gStyleCache->mNoFramesSheet; @@ -252,7 +251,7 @@ nsLayoutStylesheetCache::ContentEditableSheet() if (!gStyleCache->mContentEditableSheet) { LoadSheetURL("resource://gre/res/contenteditable.css", - gStyleCache->mContentEditableSheet, eAgentSheetFeatures); + gStyleCache->mContentEditableSheet, true); } return gStyleCache->mContentEditableSheet; @@ -265,7 +264,7 @@ nsLayoutStylesheetCache::DesignModeSheet() if (!gStyleCache->mDesignModeSheet) { LoadSheetURL("resource://gre/res/designmode.css", - gStyleCache->mDesignModeSheet, eAgentSheetFeatures); + gStyleCache->mDesignModeSheet, true); } return gStyleCache->mDesignModeSheet; @@ -344,17 +343,17 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache() // And make sure that we load our UA sheets. No need to do this // per-profile, since they're profile-invariant. LoadSheetURL("resource://gre-resources/counterstyles.css", - mCounterStylesSheet, eAgentSheetFeatures); + mCounterStylesSheet, true); LoadSheetURL("resource://gre-resources/full-screen-override.css", - mFullScreenOverrideSheet, eAgentSheetFeatures); + mFullScreenOverrideSheet, true); LoadSheetURL("chrome://global/content/minimal-xul.css", - mMinimalXULSheet, eAgentSheetFeatures); + mMinimalXULSheet, true); LoadSheetURL("resource://gre-resources/quirk.css", - mQuirkSheet, eAgentSheetFeatures); + mQuirkSheet, true); LoadSheetURL("resource://gre/res/svg.css", - mSVGSheet, eAgentSheetFeatures); + mSVGSheet, true); LoadSheetURL("chrome://global/content/xul.css", - mXULSheet, eAgentSheetFeatures); + mXULSheet, true); // The remaining sheets are created on-demand do to their use being rarer // (which helps save memory for Firefox OS apps) or because they need to @@ -421,27 +420,25 @@ nsLayoutStylesheetCache::InitFromProfile() contentFile->Append(NS_LITERAL_STRING("userContent.css")); chromeFile->Append(NS_LITERAL_STRING("userChrome.css")); - LoadSheetFile(contentFile, mUserContentSheet, eUserSheetFeatures); - LoadSheetFile(chromeFile, mUserChromeSheet, eUserSheetFeatures); + LoadSheetFile(contentFile, mUserContentSheet); + LoadSheetFile(chromeFile, mUserChromeSheet); } /* static */ void nsLayoutStylesheetCache::LoadSheetURL(const char* aURL, nsRefPtr& aSheet, - SheetParsingMode aParsingMode) + bool aEnableUnsafeRules) { nsCOMPtr uri; NS_NewURI(getter_AddRefs(uri), aURL); - LoadSheet(uri, aSheet, aParsingMode); + LoadSheet(uri, aSheet, aEnableUnsafeRules); if (!aSheet) { NS_ERROR(nsPrintfCString("Could not load %s", aURL).get()); } } void -nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, - nsRefPtr& aSheet, - SheetParsingMode aParsingMode) +nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsRefPtr& aSheet) { bool exists = false; aFile->Exists(&exists); @@ -451,7 +448,7 @@ nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsCOMPtr uri; NS_NewFileURI(getter_AddRefs(uri), aFile); - LoadSheet(uri, aSheet, aParsingMode); + LoadSheet(uri, aSheet, false); } static void @@ -468,7 +465,7 @@ ErrorLoadingBuiltinSheet(nsIURI* aURI, const char* aMsg) void nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, nsRefPtr& aSheet, - SheetParsingMode aParsingMode) + bool aEnableUnsafeRules) { if (!aURI) { ErrorLoadingBuiltinSheet(aURI, "null URI"); @@ -485,7 +482,7 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, } - nsresult rv = gCSSLoader->LoadSheetSync(aURI, aParsingMode, true, + nsresult rv = gCSSLoader->LoadSheetSync(aURI, aEnableUnsafeRules, true, getter_AddRefs(aSheet)); if (NS_FAILED(rv)) { ErrorLoadingBuiltinSheet(aURI, diff --git a/layout/style/nsLayoutStylesheetCache.h b/layout/style/nsLayoutStylesheetCache.h index 79aa1c9c8ecd..0802c3c77978 100644 --- a/layout/style/nsLayoutStylesheetCache.h +++ b/layout/style/nsLayoutStylesheetCache.h @@ -13,13 +13,15 @@ #include "mozilla/Attributes.h" #include "mozilla/MemoryReporting.h" #include "mozilla/StaticPtr.h" -#include "mozilla/css/Loader.h" class nsIFile; class nsIURI; namespace mozilla { class CSSStyleSheet; +namespace css { +class Loader; +} // namespace css } // namespace mozilla class nsLayoutStylesheetCache final @@ -68,12 +70,11 @@ private: void InitMemoryReporter(); static void LoadSheetURL(const char* aURL, nsRefPtr& aSheet, - mozilla::css::SheetParsingMode aParsingMode); + bool aEnableUnsafeRules); static void LoadSheetFile(nsIFile* aFile, - nsRefPtr& aSheet, - mozilla::css::SheetParsingMode aParsingMode); + nsRefPtr& aSheet); static void LoadSheet(nsIURI* aURI, nsRefPtr& aSheet, - mozilla::css::SheetParsingMode aParsingMode); + bool aEnableUnsafeRules); static void InvalidateSheet(nsRefPtr& aSheet); static void DependentPrefChanged(const char* aPref, void* aData); void BuildPreferenceSheet(nsRefPtr& aSheet, diff --git a/layout/style/test/chrome/chrome.ini b/layout/style/test/chrome/chrome.ini index 5d911fa0377f..6064cce12b28 100644 --- a/layout/style/test/chrome/chrome.ini +++ b/layout/style/test/chrome/chrome.ini @@ -8,9 +8,6 @@ support-files = hover_helper.html match.png mismatch.png - moz_document_condition_text.css - moz_document_nesting.css - moz_document_serialization.css [test_addSheet.html] [test_additional_sheets.html] @@ -21,9 +18,4 @@ support-files = [test_bug535806.xul] [test_hover.html] skip-if = buildapp == 'mulet' -[test_moz_document_condition_text.html] -[test_moz_document_crashes.html] -[test_moz_document_matching.html] -[test_moz_document_nesting.html] -[test_moz_document_serialization.html] -[test_moz_document_usability.html] +[test_moz_document_rules.html] diff --git a/layout/style/test/chrome/moz_document_condition_text.css b/layout/style/test/chrome/moz_document_condition_text.css deleted file mode 100644 index 333f3245d8da..000000000000 --- a/layout/style/test/chrome/moz_document_condition_text.css +++ /dev/null @@ -1,10 +0,0 @@ -/* Bug 814907 (@-moz-document cases) */ -@-moz-document url(http://www.example.com/) {} -@-moz-document url('http://www.example.com/') {} -@-moz-document url("http://www.example.com/") {} -@-moz-document url-prefix('http://www.example.com/') {} -@-moz-document url-prefix("http://www.example.com/") {} -@-moz-document domain('example.com') {} -@-moz-document domain("example.com") {} -@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {} -@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {} diff --git a/layout/style/test/chrome/moz_document_nesting.css b/layout/style/test/chrome/moz_document_nesting.css deleted file mode 100644 index cafb166800bd..000000000000 --- a/layout/style/test/chrome/moz_document_nesting.css +++ /dev/null @@ -1,89 +0,0 @@ -/* formerly test_bug511909.html */ - -a { - font-weight: bold; -} -#pink { - color: pink; -} - -#green { - color: green; -} - -#blue { - color: blue; -} - - -pre { - border: 1px solid black; -} - -@-moz-document regexp(".*test_moz_document_nesting.*") { - #d { - color: pink; - } -} - -@media screen { - #m { - color: green; - } -} - -@-moz-document regexp(".*test_moz_document_nesting.*") { - @media screen { - #dm { - color: blue; - } - } -} - -@media screen { - @-moz-document regexp(".*test_moz_document_nesting.*") { - #md { - color: green; - } - } -} - -/* syntax error - recover at end of @media block */ -@media print { @-moz-document regexp("not_this_url") , } -#mx { - color: pink; -} - -/* syntax error - recover at end of @-moz-document block */ -@-moz-document regexp("not_this_url") { @media , } -#mxx { - color: blue; -} - -@media screen { - @-moz-document regexp(".*test_moz_document_nesting.*") { - @media screen { - @-moz-document regexp(".*test_moz_document_nesting.*") { - @media screen { - #me { - color: blue; - } - } - } - } - } -} - -/* formerly reftests/w3c-css/submitted/conditional3/css-supports-027.xht */ -@-moz-document regexp(".*test_moz_document_nesting.*") { - @supports (color: green) { - #mf { color: green } - } -} - -/* formerly reftests/w3c-css/submitted/conditional3/css-supports-028.xht */ -@supports (color: pink) { - @-moz-document regexp(".*test_moz_document_nesting.*") { - #mg { color: pink } - } -} diff --git a/layout/style/test/chrome/moz_document_serialization.css b/layout/style/test/chrome/moz_document_serialization.css deleted file mode 100644 index 82b4ecd76f9e..000000000000 --- a/layout/style/test/chrome/moz_document_serialization.css +++ /dev/null @@ -1,9 +0,0 @@ -@-moz-document url(http://www.example.com/) {} -@-moz-document url('http://www.example.com/') {} -@-moz-document url("http://www.example.com/") {} -@-moz-document url-prefix('http://www.example.com/') {} -@-moz-document url-prefix("http://www.example.com/") {} -@-moz-document domain('example.com') {} -@-moz-document domain("example.com") {} -@-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {} -@-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {} diff --git a/layout/style/test/chrome/test_moz_document_condition_text.html b/layout/style/test/chrome/test_moz_document_condition_text.html deleted file mode 100644 index 728c131395e4..000000000000 --- a/layout/style/test/chrome/test_moz_document_condition_text.html +++ /dev/null @@ -1,61 +0,0 @@ - -Test for Bug 814907 (@-moz-document cases) - - - - - - Mozilla Bug 814907 -

- -
-
-
- - diff --git a/layout/style/test/chrome/test_moz_document_crashes.html b/layout/style/test/chrome/test_moz_document_crashes.html deleted file mode 100644 index 34daf202417c..000000000000 --- a/layout/style/test/chrome/test_moz_document_crashes.html +++ /dev/null @@ -1,53 +0,0 @@ - -@-moz-document crash tests - - - - - - - - diff --git a/layout/style/test/chrome/test_moz_document_nesting.html b/layout/style/test/chrome/test_moz_document_nesting.html deleted file mode 100644 index 71bf26272d49..000000000000 --- a/layout/style/test/chrome/test_moz_document_nesting.html +++ /dev/null @@ -1,120 +0,0 @@ - -@media and @-moz-document testcases - - - - - - - - -
default style
-
-This line should be pink
-This line should be green
-This line should be blue
- -
@-moz-document {...}
-
-This line should be pink
- -
@media screen {...}
-
-This line should be green
- -
@-moz-document {
-   @media screen {...}
-}
-
-This line should be blue
- -
@media print {
-  @-moz-document regexp("not_this_url"),}
-    #mx {
-        color: pink;
-    }
-  }
-}
-
-This line should be pink
- -
@-moz-document regexp("not_this_url"){
-  @media print ,}
-    #mxx {
-      color: blue;
-    }
-  }
-}
-
-This line should be blue
- -
@media screen {
-  @-moz-document {...}
-}
-
-This line should be green
- -
@media screen {
-  @-moz-document {
-    @media screen {...}
-  }
-}
-
-This line should be blue
- -
@-moz-document {
-  @supports { ... }
-}
-
-This line should be green
- -
@supports {
-  @-moz-document { ... }
-}
-
-This line should be pink
- - diff --git a/layout/style/test/chrome/test_moz_document_matching.html b/layout/style/test/chrome/test_moz_document_rules.html similarity index 100% rename from layout/style/test/chrome/test_moz_document_matching.html rename to layout/style/test/chrome/test_moz_document_rules.html diff --git a/layout/style/test/chrome/test_moz_document_serialization.html b/layout/style/test/chrome/test_moz_document_serialization.html deleted file mode 100644 index e4624572f7d9..000000000000 --- a/layout/style/test/chrome/test_moz_document_serialization.html +++ /dev/null @@ -1,50 +0,0 @@ - -Test for reserialization of @-moz-document rules - - - - - - - - - diff --git a/layout/style/test/chrome/test_moz_document_usability.html b/layout/style/test/chrome/test_moz_document_usability.html deleted file mode 100644 index 4b538f31d420..000000000000 --- a/layout/style/test/chrome/test_moz_document_usability.html +++ /dev/null @@ -1,56 +0,0 @@ - -@-moz-document usability test (Bug 1035091) - - - - - - - - -

All text should be green.

-

All text should be green.

-

All text should be green.

-

All text should be green.

- - - diff --git a/layout/style/test/mochitest.ini b/layout/style/test/mochitest.ini index b23fbe4f76e7..15fec346d291 100644 --- a/layout/style/test/mochitest.ini +++ b/layout/style/test/mochitest.ini @@ -93,6 +93,7 @@ support-files = bug453896_iframe.html [test_bug470769.html] [test_bug499655.html] [test_bug499655.xhtml] +[test_bug511909.html] [test_bug517224.html] support-files = bug517224.sjs [test_bug524175.html] @@ -219,6 +220,7 @@ support-files = redundant_font_download.sjs [test_root_node_display.html] [test_rule_insertion.html] skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) # b2g-debug(monospace and serif text have sufficiently different widths) b2g-desktop(monospace and serif text have sufficiently different widths) +[test_rule_serialization.html] [test_rules_out_of_sheets.html] [test_selectors.html] skip-if = (toolkit == 'gonk' && debug) || toolkit == 'android' #bug 775227 #debug-only failure; timed out diff --git a/layout/style/test/test_bug511909.html b/layout/style/test/test_bug511909.html new file mode 100644 index 000000000000..060636a9faba --- /dev/null +++ b/layout/style/test/test_bug511909.html @@ -0,0 +1,205 @@ + + +@media and @-moz-document testcases + + + + + + + + + + + + + + + + + + + + + + + + Mozilla Bug 511909 +

+ + + +
+
default style
+
+This line should be pink
+ +This line should be green
+ +This line should be blue
+ +
@-moz-document {...}
+
+This line should be pink
+
@media screen {...}
+
+This line should be green
+
@-moz-document {
+   @media screen {...}
+}
+
+This line should be blue
+
@media print {
+  @-moz-document regexp("not_this_url"),}
+    #mx {
+        color: pink;
+    }
+  }
+}
+
+This line should be pink
+
@-moz-document regexp("not_this_url"){
+  @media print ,}
+    #mxx {
+      color: blue;
+    }
+  }
+}
+
+This line should be blue
+
@media screen {
+  @-moz-documen {...}
+}
+
+This line should be green
+
@media screen {
+  @-moz-document {
+    @media screen {...}
+  }
+}
+
+This line should be blue
+ + + diff --git a/layout/style/test/test_condition_text.html b/layout/style/test/test_condition_text.html index a7c0296c5bd6..9ab60758daf2 100644 --- a/layout/style/test/test_condition_text.html +++ b/layout/style/test/test_condition_text.html @@ -8,6 +8,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=814907 + + +
+
+
+ +