зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
58969bc68a
Коммит
c0a3b6e87d
|
@ -1458,18 +1458,25 @@ static bool ValueIncludes(const nsSubstring& aValueList,
|
|||
return false;
|
||||
}
|
||||
|
||||
// Return whether we should apply a "global" (i.e., universal-tag)
|
||||
// selector for event states in quirks mode. Note that
|
||||
// |IsLink()| is checked separately by the caller, so we return
|
||||
// false for |nsGkAtoms::a|, which here means a named anchor.
|
||||
inline bool IsQuirkEventSensitive(nsIAtom *aContentTag)
|
||||
// Return whether the selector matches conditions for the :active and
|
||||
// :hover quirk.
|
||||
static inline bool ActiveHoverQuirkMatches(nsCSSSelector* aSelector)
|
||||
{
|
||||
return bool ((nsGkAtoms::button == aContentTag) ||
|
||||
(nsGkAtoms::img == aContentTag) ||
|
||||
(nsGkAtoms::input == aContentTag) ||
|
||||
(nsGkAtoms::label == aContentTag) ||
|
||||
(nsGkAtoms::select == aContentTag) ||
|
||||
(nsGkAtoms::textarea == aContentTag));
|
||||
if (aSelector->HasTagSelector() || aSelector->mAttrList ||
|
||||
aSelector->mIDList || aSelector->mClassList) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// 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 &&
|
||||
// global selector:
|
||||
!aSelector->HasTagSelector() && !aSelector->mIDList &&
|
||||
!aSelector->mClassList && !aSelector->mAttrList &&
|
||||
ActiveHoverQuirkMatches(aSelector) &&
|
||||
// This (or the other way around) both make :not() asymmetric
|
||||
// in quirks mode (and it's hard to work around since we're
|
||||
// testing the current mNegations, not the first
|
||||
// (unnegated)). This at least makes it closer to the spec.
|
||||
!isNegated &&
|
||||
// important for |IsQuirkEventSensitive|:
|
||||
aElement->IsHTML() && !nsCSSRuleProcessor::IsLink(aElement) &&
|
||||
!IsQuirkEventSensitive(aElement->Tag())) {
|
||||
// In quirks mode, only make certain elements sensitive to
|
||||
// selectors ":hover" and ":active".
|
||||
aElement->IsHTML() && !nsCSSRuleProcessor::IsLink(aElement)) {
|
||||
// In quirks mode, only make links sensitive to selectors ":active"
|
||||
// and ":hover".
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче