Bug 524175. Compute weight correctly again for selectors involving pseudo-elements, and fail parsing selectors with more than one pseudo-element. r=zwol

This commit is contained in:
Boris Zbarsky 2009-10-23 21:41:59 -04:00
parent bc48a0588d
commit a15350e46e
6 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<body>
<span style="color: green">This text should be green</span>
</body>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<style>
#foo::before { color: green; content: "This text should be green"; }
span::before { color: red; }
</style>
<body>
<span id="foo"></span>
</body>

View File

@ -1330,4 +1330,5 @@ fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs
== 521539-1.html 521539-1-ref.html
== 520421-1.html 520421-1-ref.html
== 521685-1.html 521685-1-ref.html
== 524175-1.html 524175-1-ref.html
== 523096-1.html 523096-1-ref.html

View File

@ -2530,6 +2530,8 @@ CSSParserImpl::ParseSelectorGroup(nsCSSSelectorList*& aList)
return PR_FALSE;
}
list->AddSelector(empty);
// Save the weight of the non-pseudo-element part of this selector now
weight += listSel->CalcWeight();
listSel = list->mSelectors; // use the new one for the pseudo
}
NS_ASSERTION(!listSel->mLowercaseTag &&
@ -2538,6 +2540,7 @@ CSSParserImpl::ParseSelectorGroup(nsCSSSelectorList*& aList)
"already initialized");
listSel->mLowercaseTag.swap(pseudoElement);
listSel->mPseudoClassList = pseudoElementArgs.forget();
havePseudoElement = PR_TRUE;
}
combinator = PRUnichar(0);

View File

@ -168,6 +168,7 @@ _TEST_FILES = test_acid3_test46.html \
media_queries_dynamic_xbl_iframe.html \
media_queries_dynamic_xbl_style.css \
bug453896_iframe.html \
test_bug524175.html \
$(NULL)
_BROWSER_FILES = \

View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=524175
-->
<head>
<title>Test for Bug 524175</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
span::before ::before {}
</style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=524175">Mozilla Bug 524175</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 524175 **/
is(document.styleSheets[1].cssRules.length, 0, "Shouldn't have parsed that rule");
</script>
</pre>
</body>
</html>