mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Update to rules in current css3-mediaqueries spec for handling malformed media queries: all of the handling is now at the query level rather than the query list level. (Bug 689319) r=bzbarsky
This commit is contained in:
parent
05093e122d
commit
14920bf983
@ -341,7 +341,7 @@ protected:
|
||||
bool GatherMedia(nsMediaList* aMedia,
|
||||
bool aInAtRule);
|
||||
bool ParseMediaQuery(bool aInAtRule, nsMediaQuery **aQuery,
|
||||
bool *aParsedSomething, bool *aHitStop);
|
||||
bool *aHitStop);
|
||||
bool ParseMediaQueryExpression(nsMediaQuery* aQuery);
|
||||
void ProcessImport(const nsString& aURLSpec,
|
||||
nsMediaList* aMedia,
|
||||
@ -1177,13 +1177,8 @@ CSSParserImpl::ParseMediaList(const nsSubstring& aBuffer,
|
||||
// to a media query. (The main substative difference is the relative
|
||||
// precedence of commas and paretheses.)
|
||||
|
||||
if (!GatherMedia(aMediaList, PR_FALSE)) {
|
||||
aMediaList->Clear();
|
||||
aMediaList->SetNonEmpty(); // don't match anything
|
||||
if (!mHTMLMediaMode) {
|
||||
OUTPUT_ERROR();
|
||||
}
|
||||
}
|
||||
GatherMedia(aMediaList, false); // can only fail on low-level error (OOM)
|
||||
|
||||
nsresult rv = mScanner.GetLowLevelError();
|
||||
CLEAR_ERROR();
|
||||
ReleaseScanner();
|
||||
@ -1627,11 +1622,9 @@ CSSParserImpl::ParseURLOrString(nsString& aURL)
|
||||
bool
|
||||
CSSParserImpl::ParseMediaQuery(bool aInAtRule,
|
||||
nsMediaQuery **aQuery,
|
||||
bool *aParsedSomething,
|
||||
bool *aHitStop)
|
||||
{
|
||||
*aQuery = nsnull;
|
||||
*aParsedSomething = PR_FALSE;
|
||||
*aHitStop = PR_FALSE;
|
||||
|
||||
// "If the comma-separated list is the empty list it is assumed to
|
||||
@ -1656,9 +1649,8 @@ CSSParserImpl::ParseMediaQuery(bool aInAtRule,
|
||||
}
|
||||
UngetToken();
|
||||
|
||||
*aParsedSomething = PR_TRUE;
|
||||
|
||||
nsAutoPtr<nsMediaQuery> query(new nsMediaQuery);
|
||||
nsMediaQuery* query = new nsMediaQuery;
|
||||
*aQuery = query;
|
||||
if (!query) {
|
||||
mScanner.SetLowLevelError(NS_ERROR_OUT_OF_MEMORY);
|
||||
return PR_FALSE;
|
||||
@ -1735,7 +1727,6 @@ CSSParserImpl::ParseMediaQuery(bool aInAtRule,
|
||||
query->SetHadUnknownExpression();
|
||||
}
|
||||
}
|
||||
*aQuery = query.forget();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
@ -1747,13 +1738,17 @@ CSSParserImpl::GatherMedia(nsMediaList* aMedia,
|
||||
{
|
||||
for (;;) {
|
||||
nsAutoPtr<nsMediaQuery> query;
|
||||
bool parsedSomething, hitStop;
|
||||
bool hitStop;
|
||||
if (!ParseMediaQuery(aInAtRule, getter_Transfers(query),
|
||||
&parsedSomething, &hitStop)) {
|
||||
&hitStop)) {
|
||||
NS_ASSERTION(!hitStop, "should return true when hit stop");
|
||||
OUTPUT_ERROR();
|
||||
if (NS_FAILED(mScanner.GetLowLevelError())) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (query) {
|
||||
query->SetHadUnknownExpression();
|
||||
}
|
||||
if (aInAtRule) {
|
||||
const PRUnichar stopChars[] =
|
||||
{ PRUnichar(','), PRUnichar('{'), PRUnichar(';'), PRUnichar(0) };
|
||||
@ -1768,9 +1763,6 @@ CSSParserImpl::GatherMedia(nsMediaList* aMedia,
|
||||
hitStop = PR_TRUE;
|
||||
}
|
||||
}
|
||||
if (parsedSomething) {
|
||||
aMedia->SetNonEmpty();
|
||||
}
|
||||
if (query) {
|
||||
nsresult rv = aMedia->AppendQuery(query);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -542,8 +542,7 @@ NS_IMPL_RELEASE(nsMediaList)
|
||||
|
||||
|
||||
nsMediaList::nsMediaList()
|
||||
: mIsEmpty(PR_TRUE)
|
||||
, mStyleSheet(nsnull)
|
||||
: mStyleSheet(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
@ -556,10 +555,6 @@ nsMediaList::GetText(nsAString& aMediaText)
|
||||
{
|
||||
aMediaText.Truncate();
|
||||
|
||||
if (mArray.Length() == 0 && !mIsEmpty) {
|
||||
aMediaText.AppendLiteral("not all");
|
||||
}
|
||||
|
||||
for (PRInt32 i = 0, i_end = mArray.Length(); i < i_end; ++i) {
|
||||
nsMediaQuery* query = mArray[i];
|
||||
NS_ENSURE_TRUE(query, NS_ERROR_FAILURE);
|
||||
@ -601,7 +596,7 @@ nsMediaList::Matches(nsPresContext* aPresContext,
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
return mIsEmpty;
|
||||
return mArray.IsEmpty();
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -624,7 +619,6 @@ nsMediaList::Clone(nsMediaList** aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
result->mIsEmpty = mIsEmpty;
|
||||
NS_ADDREF(*aResult = result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -205,11 +205,7 @@ public:
|
||||
|
||||
PRInt32 Count() { return mArray.Length(); }
|
||||
nsMediaQuery* MediumAt(PRInt32 aIndex) { return mArray[aIndex]; }
|
||||
void Clear() { mArray.Clear(); mIsEmpty = PR_TRUE; }
|
||||
// a media list with no items may not represent the lack of a media
|
||||
// list; it could represent the empty string or something with parser
|
||||
// errors, which means that the media list should never match
|
||||
void SetNonEmpty() { mIsEmpty = PR_FALSE; }
|
||||
void Clear() { mArray.Clear(); }
|
||||
|
||||
protected:
|
||||
~nsMediaList();
|
||||
@ -218,7 +214,6 @@ protected:
|
||||
nsresult Append(const nsAString & aOldMedium);
|
||||
|
||||
nsTArray<nsAutoPtr<nsMediaQuery> > mArray;
|
||||
bool mIsEmpty;
|
||||
// not refcounted; sheet will let us know when it goes away
|
||||
// mStyleSheet is the sheet that needs to be dirtied when this medialist
|
||||
// changes
|
||||
|
@ -79,7 +79,7 @@ function run() {
|
||||
var sheet = parse_test_style_element.sheet; // XXX yikes, not live!
|
||||
if (sheet.cssRules.length == 1 &&
|
||||
sheet.cssRules[0].type == CSSRule.MEDIA_RULE)
|
||||
return sheet.cssRules[0].media.mediaText != "screen";
|
||||
return sheet.cssRules[0].media.mediaText != "screen, not all";
|
||||
ok(false, "unexpected result testing whether query " + q +
|
||||
" is parseable");
|
||||
return true; // doesn't matter, we already failed
|
||||
|
Loading…
Reference in New Issue
Block a user