--- a/dom/base/ResponsiveImageSelector.cpp
+++ b/dom/base/ResponsiveImageSelector.cpp
@@ -237,17 +237,17 @@ ResponsiveImageSelector::SetSizesFromDes
{
ClearSelectedCandidate();
mSizeQueries.Clear();
mSizeValues.Clear();
nsCSSParser cssParser;
return cssParser.ParseSourceSizeList(aSizes, nullptr, 0,
- mSizeQueries, mSizeValues, true);
+ mSizeQueries, mSizeValues);
}
void
ResponsiveImageSelector::AppendCandidateIfUnique(const ResponsiveImageCandidate & aCandidate)
{
int numCandidates = mCandidates.Length();
// With the exception of Default, which should not be added until we are done
--- a/dom/html/HTMLSourceElement.cpp
+++ b/dom/html/HTMLSourceElement.cpp
@@ -72,33 +72,33 @@ HTMLSourceElement::WouldMatchMediaForDoc
return true;
}
nsIPresShell* presShell = aDocument->GetShell();
nsPresContext* pctx = presShell ? presShell->GetPresContext() : nullptr;
nsCSSParser cssParser;
RefPtr<nsMediaList> mediaList = new nsMediaList();
- cssParser.ParseMediaList(aMedia, nullptr, 0, mediaList, false);
+ cssParser.ParseMediaList(aMedia, nullptr, 0, mediaList);
return pctx && mediaList->Matches(pctx, nullptr);
}
void
HTMLSourceElement::UpdateMediaList(const nsAttrValue* aValue)
{
mMediaList = nullptr;
nsString mediaStr;
if (!aValue || (mediaStr = aValue->GetStringValue()).IsEmpty()) {
return;
}
nsCSSParser cssParser;
mMediaList = new nsMediaList();
- cssParser.ParseMediaList(mediaStr, nullptr, 0, mMediaList, false);
+ cssParser.ParseMediaList(mediaStr, nullptr, 0, mMediaList);
}
nsresult
HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
{
// If we are associated with a <picture> with a valid <img>, notify it of
// responsive parameter changes
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -641,20 +641,17 @@ nsMediaList::GetText(nsAString& aMediaTe
}
// XXXbz this is so ill-defined in the spec, it's not clear quite what
// it should be doing....
void
nsMediaList::SetText(const nsAString& aMediaText)
{
nsCSSParser parser;
-
- bool htmlMode = mStyleSheet && mStyleSheet->GetOwnerNode();
-
- parser.ParseMediaList(aMediaText, nullptr, 0, this, htmlMode);
+ parser.ParseMediaList(aMediaText, nullptr, 0, this);
}
bool
nsMediaList::Matches(nsPresContext* aPresContext,
nsMediaQueryResultCacheKey* aKey)
{
for (int32_t i = 0, i_end = mArray.Length(); i < i_end; ++i) {
if (mArray[i]->Matches(aPresContext, aKey)) {
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1295,17 +1295,17 @@ Loader::PrepareSheet(StyleSheet* aSheet,
NS_ASSERTION(!aMediaList,
"must not provide both aMediaString and aMediaList");
mediaList = new nsMediaList();
nsCSSParser mediumParser(this);
// We have aMediaString only when linked from link elements, style
// elements, or PIs, so pass true.
- mediumParser.ParseMediaList(aMediaString, nullptr, 0, mediaList, true);
+ mediumParser.ParseMediaList(aMediaString, nullptr, 0, mediaList);
}
sheet->SetMedia(mediaList);
sheet->SetTitle(aTitle);
sheet->SetEnabled(!isAlternate);
sheet->SetScopeElement(aScopeElement);
}
--- a/layout/style/MediaQueryList.cpp
+++ b/layout/style/MediaQueryList.cpp
@@ -19,17 +19,17 @@ MediaQueryList::MediaQueryList(nsIDocume
const nsAString &aMediaQueryList)
: mDocument(aDocument),
mMediaList(new nsMediaList),
mMatchesValid(false)
{
PR_INIT_CLIST(this);
nsCSSParser parser;
- parser.ParseMediaList(aMediaQueryList, nullptr, 0, mMediaList, false);
+ parser.ParseMediaList(aMediaQueryList, nullptr, 0, mMediaList);
}
MediaQueryList::~MediaQueryList()
{
if (mDocument) {
PR_REMOVE_LINK(this);
}
}
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -197,25 +197,23 @@ public:
bool ParseTransformProperty(const nsAString& aPropValue,
bool aDisallowRelativeValues,
nsCSSValue& aResult);
void ParseMediaList(const nsSubstring& aBuffer,
nsIURI* aURL, // for error reporting
uint32_t aLineNumber, // for error reporting
- nsMediaList* aMediaList,
- bool aHTMLMode);
+ nsMediaList* aMediaList);
bool ParseSourceSizeList(const nsAString& aBuffer,
nsIURI* aURI, // for error reporting
uint32_t aLineNumber, // for error reporting
InfallibleTArray< nsAutoPtr<nsMediaQuery> >& aQueries,
- InfallibleTArray<nsCSSValue>& aValues,
- bool aHTMLMode);
+ InfallibleTArray<nsCSSValue>& aValues);
void ParseVariable(const nsAString& aVariableName,
const nsAString& aPropValue,
nsIURI* aSheetURL,
nsIURI* aBaseURL,
nsIPrincipal* aSheetPrincipal,
css::Declaration* aDeclaration,
bool* aChanged,
@@ -1483,20 +1481,16 @@ protected:
css::SheetParsingMode mParsingMode : 3;
// True if we are in parsing rules for the chrome.
bool mIsChrome : 1;
// True if viewport units should be allowed.
bool mViewportUnitsEnabled : 1;
- // True for parsing media lists for HTML attributes, where we have to
- // ignore CSS comments.
- bool mHTMLMediaMode : 1;
-
// This flag is set when parsing a non-box shorthand; it's used to not apply
// some quirks during shorthand parsing
bool mParsingCompoundProperty : 1;
// True if we are in the middle of parsing an @supports condition.
// This is used to avoid recording the input stream when variable references
// are encountered in a property declaration in the @supports condition.
bool mInSupportsCondition : 1;
@@ -1608,17 +1602,16 @@ CSSParserImpl::CSSParserImpl()
mNameSpaceMap(nullptr),
mHavePushBack(false),
mNavQuirkMode(false),
mHashlessColorQuirk(false),
mUnitlessLengthQuirk(false),
mParsingMode(css::eAuthorSheetFeatures),
mIsChrome(false),
mViewportUnitsEnabled(true),
- mHTMLMediaMode(false),
mParsingCompoundProperty(false),
mInSupportsCondition(false),
mInFailingSupportsRule(false),
mSuppressErrors(false),
mSheetPrincipalRequired(true),
mWebkitBoxUnprefixState(eNotParsingDecls),
mNextFree(nullptr)
{
@@ -1682,17 +1675,16 @@ CSSParserImpl::Reset()
}
void
CSSParserImpl::InitScanner(nsCSSScanner& aScanner,
css::ErrorReporter& aReporter,
nsIURI* aSheetURI, nsIURI* aBaseURI,
nsIPrincipal* aSheetPrincipal)
{
- NS_PRECONDITION(!mHTMLMediaMode, "Bad initial state");
NS_PRECONDITION(!mParsingCompoundProperty, "Bad initial state");
NS_PRECONDITION(!mScanner, "already have scanner");
mScanner = &aScanner;
mReporter = &aReporter;
mScanner->SetErrorReporter(mReporter);
mBaseURI = aBaseURI;
@@ -2127,73 +2119,56 @@ CSSParserImpl::ParseVariable(const nsASt
ReleaseScanner();
}
void
CSSParserImpl::ParseMediaList(const nsSubstring& aBuffer,
nsIURI* aURI, // for error reporting
uint32_t aLineNumber, // for error reporting
- nsMediaList* aMediaList,
- bool aHTMLMode)
+ nsMediaList* aMediaList)
{
// XXX Are there cases where the caller wants to keep what it already
// has in case of parser error? If GatherMedia ever changes to return
// a value other than true, we probably should avoid modifying aMediaList.
aMediaList->Clear();
// fake base URI since media lists don't have URIs in them
nsCSSScanner scanner(aBuffer, aLineNumber);
css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
InitScanner(scanner, reporter, aURI, aURI, nullptr);
- mHTMLMediaMode = aHTMLMode;
-
// XXXldb We need to make the scanner not skip CSS comments! (Or
// should we?)
- // For aHTMLMode, we used to follow the parsing rules in
- // http://www.w3.org/TR/1999/REC-html401-19991224/types.html#type-media-descriptors
- // which wouldn't work for media queries since they remove all but the
- // first word. However, they're changed in
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/section-document.html#media2
- // (as of 2008-05-29) which says that the media attribute just points
- // to a media query. (The main substative difference is the relative
- // precedence of commas and paretheses.)
-
DebugOnly<bool> parsedOK = GatherMedia(aMediaList, false);
NS_ASSERTION(parsedOK, "GatherMedia returned false; we probably want to avoid "
"trashing aMediaList");
CLEAR_ERROR();
ReleaseScanner();
- mHTMLMediaMode = false;
}
// <source-size-list> = <source-size>#?
// <source-size> = <media-condition>? <length>
bool
CSSParserImpl::ParseSourceSizeList(const nsAString& aBuffer,
nsIURI* aURI, // for error reporting
uint32_t aLineNumber, // for error reporting
InfallibleTArray< nsAutoPtr<nsMediaQuery> >& aQueries,
- InfallibleTArray<nsCSSValue>& aValues,
- bool aHTMLMode)
+ InfallibleTArray<nsCSSValue>& aValues)
{
aQueries.Clear();
aValues.Clear();
// fake base URI since media value lists don't have URIs in them
nsCSSScanner scanner(aBuffer, aLineNumber);
css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
InitScanner(scanner, reporter, aURI, aURI, nullptr);
- // See ParseMediaList comment about HTML mode
- mHTMLMediaMode = aHTMLMode;
-
// https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-sizes-attribute
bool hitEnd = false;
do {
bool hitError = false;
// Parse single <media-condition> <source-size-value>
do {
nsAutoPtr<nsMediaQuery> query;
nsCSSValue value;
@@ -2252,17 +2227,16 @@ CSSParserImpl::ParseSourceSizeList(const
if (!SkipUntil(',')) {
hitEnd = true;
}
}
} while (!hitEnd);
CLEAR_ERROR();
ReleaseScanner();
- mHTMLMediaMode = false;
return !aQueries.IsEmpty();
}
bool
CSSParserImpl::ParseColorString(const nsSubstring& aBuffer,
nsIURI* aURI, // for error reporting
uint32_t aLineNumber, // for error reporting
@@ -18220,34 +18194,32 @@ nsCSSParser::ParseVariable(const nsAStri
ParseVariable(aVariableName, aPropValue, aSheetURI, aBaseURI,
aSheetPrincipal, aDeclaration, aChanged, aIsImportant);
}
void
nsCSSParser::ParseMediaList(const nsSubstring& aBuffer,
nsIURI* aURI,
uint32_t aLineNumber,
- nsMediaList* aMediaList,
- bool aHTMLMode)
+ nsMediaList* aMediaList)
{
static_cast<CSSParserImpl*>(mImpl)->
- ParseMediaList(aBuffer, aURI, aLineNumber, aMediaList, aHTMLMode);
+ ParseMediaList(aBuffer, aURI, aLineNumber, aMediaList);
}
bool
nsCSSParser::ParseSourceSizeList(const nsAString& aBuffer,
nsIURI* aURI,
uint32_t aLineNumber,
InfallibleTArray< nsAutoPtr<nsMediaQuery> >& aQueries,
InfallibleTArray<nsCSSValue>& aValues,
- bool aHTMLMode)
+ )
{
return static_cast<CSSParserImpl*>(mImpl)->
- ParseSourceSizeList(aBuffer, aURI, aLineNumber, aQueries, aValues,
- aHTMLMode);
+ ParseSourceSizeList(aBuffer, aURI, aLineNumber, aQueries, aValues);
}
bool
nsCSSParser::ParseFontFamilyListString(const nsSubstring& aBuffer,
nsIURI* aURI,
uint32_t aLineNumber,
nsCSSValue& aValue)
{
--- a/layout/style/nsCSSParser.h
+++ b/layout/style/nsCSSParser.h
@@ -147,28 +147,24 @@ public:
const nsAString& aPropValue,
nsIURI* aSheetURL,
nsIURI* aBaseURL,
nsIPrincipal* aSheetPrincipal,
mozilla::css::Declaration* aDeclaration,
bool* aChanged,
bool aIsImportant);
/**
- * Parse aBuffer into a media list |aMediaList|, which must be
- * non-null, replacing its current contents. If aHTMLMode is true,
- * parse according to HTML rules, with commas as the most important
- * delimiter. Otherwise, parse according to CSS rules, with
- * parentheses and strings more important than commas. |aURL| and
- * |aLineNumber| are used for error reporting.
+ * Parse aBuffer into a media list |aMediaList|, which must be non-null,
+ * replacing its current contents. |aURL| and |aLineNumber| are used for error
+ * reporting.
*/
void ParseMediaList(const nsSubstring& aBuffer,
nsIURI* aURL,
uint32_t aLineNumber,
- nsMediaList* aMediaList,
- bool aHTMLMode);
+ nsMediaList* aMediaList);
/*
* Parse aBuffer into a list of media queries and their associated values,
* according to grammar:
* <source-size-list> = <source-size>#?
* <source-size> = <media-condition>? <length>
*
* Note that this grammar is top-level: The function expects to consume the
@@ -176,18 +172,17 @@ public:
*
* Output arrays overwritten (not appended) and are cleared in case of parse
* failure.
*/
bool ParseSourceSizeList(const nsAString& aBuffer,
nsIURI* aURI, // for error reporting
uint32_t aLineNumber, // for error reporting
InfallibleTArray< nsAutoPtr<nsMediaQuery> >& aQueries,
- InfallibleTArray<nsCSSValue>& aValues,
- bool aHTMLMode);
+ InfallibleTArray<nsCSSValue>& aValues);
/**
* Parse aBuffer into a nsCSSValue |aValue|. Will return false
* if aBuffer is not a valid font family list.
*/
bool ParseFontFamilyListString(const nsSubstring& aBuffer,
nsIURI* aURL,
uint32_t aLineNumber,