Back out 6d1c0e678b61 (Bug 689319) because of test failures

This commit is contained in:
Matt Brubeck 2011-09-30 14:11:24 -07:00
Родитель 634763fa4d
Коммит 19659a44a6
4 изменённых файлов: 34 добавлений и 15 удалений

Просмотреть файл

@ -341,7 +341,7 @@ protected:
bool GatherMedia(nsMediaList* aMedia,
bool aInAtRule);
bool ParseMediaQuery(bool aInAtRule, nsMediaQuery **aQuery,
bool *aHitStop);
bool *aParsedSomething, bool *aHitStop);
bool ParseMediaQueryExpression(nsMediaQuery* aQuery);
void ProcessImport(const nsString& aURLSpec,
nsMediaList* aMedia,
@ -1177,8 +1177,13 @@ CSSParserImpl::ParseMediaList(const nsSubstring& aBuffer,
// to a media query. (The main substative difference is the relative
// precedence of commas and paretheses.)
GatherMedia(aMediaList, false); // can only fail on low-level error (OOM)
if (!GatherMedia(aMediaList, PR_FALSE)) {
aMediaList->Clear();
aMediaList->SetNonEmpty(); // don't match anything
if (!mHTMLMediaMode) {
OUTPUT_ERROR();
}
}
nsresult rv = mScanner.GetLowLevelError();
CLEAR_ERROR();
ReleaseScanner();
@ -1622,9 +1627,11 @@ 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
@ -1649,8 +1656,9 @@ CSSParserImpl::ParseMediaQuery(bool aInAtRule,
}
UngetToken();
nsMediaQuery* query = new nsMediaQuery;
*aQuery = query;
*aParsedSomething = PR_TRUE;
nsAutoPtr<nsMediaQuery> query(new nsMediaQuery);
if (!query) {
mScanner.SetLowLevelError(NS_ERROR_OUT_OF_MEMORY);
return PR_FALSE;
@ -1727,6 +1735,7 @@ CSSParserImpl::ParseMediaQuery(bool aInAtRule,
query->SetHadUnknownExpression();
}
}
*aQuery = query.forget();
return PR_TRUE;
}
@ -1738,17 +1747,13 @@ CSSParserImpl::GatherMedia(nsMediaList* aMedia,
{
for (;;) {
nsAutoPtr<nsMediaQuery> query;
bool hitStop;
bool parsedSomething, hitStop;
if (!ParseMediaQuery(aInAtRule, getter_Transfers(query),
&hitStop)) {
&parsedSomething, &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) };
@ -1763,6 +1768,9 @@ CSSParserImpl::GatherMedia(nsMediaList* aMedia,
hitStop = PR_TRUE;
}
}
if (parsedSomething) {
aMedia->SetNonEmpty();
}
if (query) {
nsresult rv = aMedia->AppendQuery(query);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -542,7 +542,8 @@ NS_IMPL_RELEASE(nsMediaList)
nsMediaList::nsMediaList()
: mStyleSheet(nsnull)
: mIsEmpty(PR_TRUE)
, mStyleSheet(nsnull)
{
}
@ -555,6 +556,10 @@ 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);
@ -596,7 +601,7 @@ nsMediaList::Matches(nsPresContext* aPresContext,
return PR_TRUE;
}
}
return mArray.IsEmpty();
return mIsEmpty;
}
nsresult
@ -619,6 +624,7 @@ nsMediaList::Clone(nsMediaList** aResult)
return NS_ERROR_OUT_OF_MEMORY;
}
}
result->mIsEmpty = mIsEmpty;
NS_ADDREF(*aResult = result);
return NS_OK;
}

Просмотреть файл

@ -205,7 +205,11 @@ public:
PRInt32 Count() { return mArray.Length(); }
nsMediaQuery* MediumAt(PRInt32 aIndex) { return mArray[aIndex]; }
void Clear() { mArray.Clear(); }
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; }
protected:
~nsMediaList();
@ -214,6 +218,7 @@ 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, not all";
return sheet.cssRules[0].media.mediaText != "screen";
ok(false, "unexpected result testing whether query " + q +
" is parseable");
return true; // doesn't matter, we already failed