Bug 989965 - Resolve style for pseudo-elements correctly when style rules that have user action pseudo-classes on them are present. r=bzbarsky

This commit is contained in:
Cameron McCormack 2014-04-02 15:08:52 +11:00
Родитель 281ddc537e
Коммит b40f160398
4 изменённых файлов: 23 добавлений и 5 удалений

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

@ -0,0 +1,9 @@
<!DOCTYPE html>
<body>
<style>
::-moz-placeholder { color: red; }
::-moz-placeholder:focus { color: green; }
</style>
<script>
window.getComputedStyle(document.body, "::-moz-placeholder").color;
</script>

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

@ -102,4 +102,5 @@ load 930270-1.html
load 930270-2.html
load 945048-1.html
load 972199-1.html
load 989965-1.html
load large_border_image_width.html

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

@ -2435,6 +2435,19 @@ void ContentEnumFunc(const RuleValue& value, nsCSSSelector* aSelector,
if (selector->IsPseudoElement()) {
PseudoElementRuleProcessorData* pdata =
static_cast<PseudoElementRuleProcessorData*>(data);
if (!pdata->mPseudoElement && selector->mPseudoClassList) {
// We can get here when calling getComputedStyle(aElt, aPseudo) if:
//
// * aPseudo is a pseudo-element that supports a user action
// pseudo-class, like "::-moz-placeholder";
// * there is a style rule that uses a pseudo-class on this
// pseudo-element in the document, like ::-moz-placeholder:hover; and
// * aElt does not have such a pseudo-element.
//
// We know that the selector can't match, since there is no element for
// the user action pseudo-class to match against.
return;
}
if (!StateSelectorMatches(pdata->mPseudoElement, aSelector, nodeContext,
data->mTreeMatchContext)) {
return;

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

@ -491,11 +491,6 @@ struct MOZ_STACK_CLASS PseudoElementRuleProcessorData :
"invalid aPseudoType value");
NS_PRECONDITION(aTreeMatchContext.mForStyling, "Styling here!");
NS_PRECONDITION(aRuleWalker, "Must have rule walker");
NS_PRECONDITION(!(!aPseudoElement &&
nsCSSPseudoElements::PseudoElementSupportsUserActionState
(aPseudoType)),
"aPseudoElement must be specified if the pseudo supports "
":hover and :active");
}
nsCSSPseudoElements::Type mPseudoType;