Bug 783213 - Part 1: Only apply the :active and :hover quirk to links, and not when the selector uses other pseudo-classes. r=dbaron

This commit is contained in:
Brian Marshall 2014-11-08 17:16:39 -08:00
Родитель 58969bc68a
Коммит c0a3b6e87d
1 изменённых файлов: 24 добавлений и 20 удалений

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

@ -1458,18 +1458,25 @@ static bool ValueIncludes(const nsSubstring& aValueList,
return false; return false;
} }
// Return whether we should apply a "global" (i.e., universal-tag) // Return whether the selector matches conditions for the :active and
// selector for event states in quirks mode. Note that // :hover quirk.
// |IsLink()| is checked separately by the caller, so we return static inline bool ActiveHoverQuirkMatches(nsCSSSelector* aSelector)
// false for |nsGkAtoms::a|, which here means a named anchor.
inline bool IsQuirkEventSensitive(nsIAtom *aContentTag)
{ {
return bool ((nsGkAtoms::button == aContentTag) || if (aSelector->HasTagSelector() || aSelector->mAttrList ||
(nsGkAtoms::img == aContentTag) || aSelector->mIDList || aSelector->mClassList) {
(nsGkAtoms::input == aContentTag) || return false;
(nsGkAtoms::label == aContentTag) || }
(nsGkAtoms::select == aContentTag) ||
(nsGkAtoms::textarea == aContentTag)); // No pseudo-class other than :active and :hover.
for (nsPseudoClassList* pseudoClass = aSelector->mPseudoClassList;
pseudoClass; pseudoClass = pseudoClass->mNext) {
if (pseudoClass->mType != nsCSSPseudoClasses::ePseudoClass_hover &&
pseudoClass->mType != nsCSSPseudoClasses::ePseudoClass_active) {
return false;
}
}
return true;
} }
@ -1676,21 +1683,18 @@ StateSelectorMatches(Element* aElement,
const bool isNegated = aDependence != nullptr; const bool isNegated = aDependence != nullptr;
// Bit-based pseudo-classes // Bit-based pseudo-classes
if (aStatesToCheck.HasAtLeastOneOfStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE) && if (aStatesToCheck.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE |
NS_EVENT_STATE_HOVER) &&
aTreeMatchContext.mCompatMode == eCompatibility_NavQuirks && aTreeMatchContext.mCompatMode == eCompatibility_NavQuirks &&
// global selector: ActiveHoverQuirkMatches(aSelector) &&
!aSelector->HasTagSelector() && !aSelector->mIDList &&
!aSelector->mClassList && !aSelector->mAttrList &&
// This (or the other way around) both make :not() asymmetric // This (or the other way around) both make :not() asymmetric
// in quirks mode (and it's hard to work around since we're // in quirks mode (and it's hard to work around since we're
// testing the current mNegations, not the first // testing the current mNegations, not the first
// (unnegated)). This at least makes it closer to the spec. // (unnegated)). This at least makes it closer to the spec.
!isNegated && !isNegated &&
// important for |IsQuirkEventSensitive|: aElement->IsHTML() && !nsCSSRuleProcessor::IsLink(aElement)) {
aElement->IsHTML() && !nsCSSRuleProcessor::IsLink(aElement) && // In quirks mode, only make links sensitive to selectors ":active"
!IsQuirkEventSensitive(aElement->Tag())) { // and ":hover".
// In quirks mode, only make certain elements sensitive to
// selectors ":hover" and ":active".
return false; return false;
} }