From 344c50ee433ccfd8263931c09a58a62bf348530b Mon Sep 17 00:00:00 2001 From: Iris Hsiao Date: Tue, 14 Feb 2017 12:40:40 +0800 Subject: [PATCH] Backed out changeset 8379a33c1790 (bug 1339252) for valgrind test failure --- layout/reftests/svg/comments-in-pres-attrs.svg | 8 -------- .../svg/cssComment-in-attribute-01-ref.svg | 4 ++++ .../reftests/svg/cssComment-in-attribute-01.svg | 4 ++++ layout/reftests/svg/reftest.list | 2 +- layout/style/nsCSSParser.cpp | 15 ++++++++------- layout/style/nsCSSScanner.cpp | 3 ++- layout/style/nsCSSScanner.h | 9 +++++++++ 7 files changed, 28 insertions(+), 17 deletions(-) delete mode 100644 layout/reftests/svg/comments-in-pres-attrs.svg create mode 100644 layout/reftests/svg/cssComment-in-attribute-01-ref.svg create mode 100644 layout/reftests/svg/cssComment-in-attribute-01.svg diff --git a/layout/reftests/svg/comments-in-pres-attrs.svg b/layout/reftests/svg/comments-in-pres-attrs.svg deleted file mode 100644 index fbb88a2bddde..000000000000 --- a/layout/reftests/svg/comments-in-pres-attrs.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - Test for whether comments are allowed in SVG presentation attributes - - diff --git a/layout/reftests/svg/cssComment-in-attribute-01-ref.svg b/layout/reftests/svg/cssComment-in-attribute-01-ref.svg new file mode 100644 index 000000000000..91d0f0f3f0e0 --- /dev/null +++ b/layout/reftests/svg/cssComment-in-attribute-01-ref.svg @@ -0,0 +1,4 @@ + + Reference that css comment in attribute is not allowed + + diff --git a/layout/reftests/svg/cssComment-in-attribute-01.svg b/layout/reftests/svg/cssComment-in-attribute-01.svg new file mode 100644 index 000000000000..f14a26bc0b0d --- /dev/null +++ b/layout/reftests/svg/cssComment-in-attribute-01.svg @@ -0,0 +1,4 @@ + + Testcase that css comment in attribute is not allowed + + diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index 5dd60af29bda..beb29bffde8a 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -27,6 +27,7 @@ include svg-integration/reftest.list == baseline-middle-01.svg pass.svg == border-radius-01.html pass.svg +== cssComment-in-attribute-01.svg cssComment-in-attribute-01-ref.svg == clip-01.svg pass.svg == clip-02a.svg clip-02-ref.svg == clip-02b.svg clip-02-ref.svg @@ -42,7 +43,6 @@ fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu)||/^Windows\x20NT\x206\.[12]/ == clipPath-basic-07.svg pass.svg == clipPath-winding-01.svg pass.svg == clip-surface-clone-01.svg clip-surface-clone-01-ref.svg -== comments-in-pres-attrs.svg pass.svg == conditions-01.svg pass.svg == conditions-02.svg pass.svg == conditions-03.svg pass.svg diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 49407bdeeb27..1e0b130d3332 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -596,6 +596,11 @@ protected: nsAutoSuppressErrors mErrorSuppresser; }; + + bool IsSVGMode() const { + return mScanner->IsSVGMode(); + } + /** * Saves the current input state, which includes any currently pushed * back token, and the current position of the scanner. @@ -1459,10 +1464,6 @@ protected: // True if we are in parsing rules for the chrome. bool mIsChrome : 1; - // True if we're parsing SVG presentation attributes - // These attributes allow non-calc lengths to be unitless (mapping to px) - bool mIsSVGMode : 1; - // True if viewport units should be allowed. bool mViewportUnitsEnabled : 1; @@ -1676,7 +1677,6 @@ void CSSParserImpl::ReleaseScanner() { mScanner = nullptr; - mIsSVGMode = false; mReporter = nullptr; mBaseURI = nullptr; mSheetURI = nullptr; @@ -1991,7 +1991,7 @@ CSSParserImpl::ParseProperty(const nsCSSPropertyID aPropID, css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aSheetURI); InitScanner(scanner, reporter, aSheetURI, aBaseURI, aSheetPrincipal); mSection = eCSSSection_General; - mIsSVGMode = aIsSVGMode; + scanner.SetSVGMode(aIsSVGMode); *aChanged = false; @@ -7791,7 +7791,7 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue, } } - if (mIsSVGMode && !IsParsingCompoundProperty()) { + if (IsSVGMode() && !IsParsingCompoundProperty()) { // STANDARD: SVG Spec states that lengths and coordinates can be unitless // in which case they default to user-units (1 px = 1 user unit) if (((aVariantMask & VARIANT_LENGTH) != 0) && @@ -17773,6 +17773,7 @@ CSSParserImpl::IsValueValidForProperty(const nsCSSPropertyID aPropID, nsAutoSuppressErrors suppressErrors(this); mSection = eCSSSection_General; + scanner.SetSVGMode(false); // Check for unknown properties if (eCSSProperty_UNKNOWN == aPropID) { diff --git a/layout/style/nsCSSScanner.cpp b/layout/style/nsCSSScanner.cpp index 8bff725bf1e3..4909f15cfab2 100644 --- a/layout/style/nsCSSScanner.cpp +++ b/layout/style/nsCSSScanner.cpp @@ -352,6 +352,7 @@ nsCSSScanner::nsCSSScanner(const nsAString& aBuffer, uint32_t aLineNumber) , mRecordStartOffset(0) , mEOFCharacters(eEOFCharacters_None) , mReporter(nullptr) + , mSVGMode(false) , mRecording(false) , mSeenBadToken(false) , mSeenVariableReference(false) @@ -1232,7 +1233,7 @@ nsCSSScanner::Next(nsCSSToken& aToken, nsCSSScannerExclude aSkip) } continue; // start again at the beginning } - if (ch == '/' && Peek(1) == '*') { + if (ch == '/' && !IsSVGMode() && Peek(1) == '*') { SkipComment(); if (aSkip == eCSSScannerExclude_None) { aToken.mType = eCSSToken_Comment; diff --git a/layout/style/nsCSSScanner.h b/layout/style/nsCSSScanner.h index 707914b7a854..ef03958c8939 100644 --- a/layout/style/nsCSSScanner.h +++ b/layout/style/nsCSSScanner.h @@ -208,6 +208,13 @@ class nsCSSScanner { void SetErrorReporter(mozilla::css::ErrorReporter* aReporter) { mReporter = aReporter; } + // Set whether or not we are processing SVG + void SetSVGMode(bool aSVGMode) { + mSVGMode = aSVGMode; + } + bool IsSVGMode() const { + return mSVGMode; + } // Reset or check whether a BAD_URL or BAD_STRING token has been seen. void ClearSeenBadToken() { mSeenBadToken = false; } @@ -358,6 +365,8 @@ protected: mozilla::css::ErrorReporter *mReporter; + // True if we are in SVG mode; false in "normal" CSS + bool mSVGMode; bool mRecording; bool mSeenBadToken; bool mSeenVariableReference;