Limit the quirk that prevents dynamic pseudo-classes from applying to quirks mode, to :hover and :active only, and to a stricter definition of global selectors, since we no longer have to worry about performance problems. b=96984 sr=attinasi r=bzbarsky

This commit is contained in:
dbaron%fas.harvard.edu 2002-05-19 02:05:29 +00:00
Родитель 24df67f6ec
Коммит d434ae0342
2 изменённых файлов: 50 добавлений и 52 удалений

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

@ -3385,24 +3385,18 @@ inline PRBool IsLinkPseudo(nsIAtom* aAtom)
(nsCSSAtoms::anyLinkPseudo == aAtom)); (nsCSSAtoms::anyLinkPseudo == aAtom));
} }
inline PRBool IsEventSensitive(nsIAtom *aPseudo, nsIAtom *aContentTag, PRBool aSelectorIsGlobal) // Return whether we should apply a "global" (i.e., universal-tag)
// selector for event states in quirks mode. Note that
// |data.mIsHTMLLink| is checked separately by the caller, so we return
// false for |nsHTMLAtoms::a|, which here means a named anchor.
inline PRBool IsQuirkEventSensitive(nsIAtom *aContentTag)
{ {
// if the selector is global, meaning it is not tied to a tag, then return PRBool ((nsHTMLAtoms::button == aContentTag) ||
// we restrict the application of the event pseudo to the following tags (nsHTMLAtoms::img == aContentTag) ||
if (aSelectorIsGlobal) { (nsHTMLAtoms::input == aContentTag) ||
return PRBool ((nsHTMLAtoms::a == aContentTag) || (nsHTMLAtoms::label == aContentTag) ||
(nsHTMLAtoms::button == aContentTag) || (nsHTMLAtoms::select == aContentTag) ||
(nsHTMLAtoms::img == aContentTag) || (nsHTMLAtoms::textarea == aContentTag));
(nsHTMLAtoms::input == aContentTag) ||
(nsHTMLAtoms::li == aContentTag) ||
(nsHTMLAtoms::label == aContentTag) ||
(nsHTMLAtoms::select == aContentTag) ||
(nsHTMLAtoms::textarea == aContentTag));
} else {
// selector is not global, so apply the event pseudo to everything except HTML and BODY
return PRBool ((nsHTMLAtoms::html != aContentTag) &&
(nsHTMLAtoms::body != aContentTag));
}
} }
@ -3561,15 +3555,20 @@ static PRBool SelectorMatches(RuleProcessorData &data,
} }
else if (IsEventPseudo(pseudoClass->mAtom)) { else if (IsEventPseudo(pseudoClass->mAtom)) {
// check if the element is event-sensitive // check if the element is event-sensitive
// NOTE: we distinguish between global and subjected selectors so if (data.mIsQuirkMode &&
// pass that information on to the determining routine // global selector:
// ALSO NOTE: we used to do this only in Quirks mode, but because of !aSelector->mTag && !aSelector->mClassList &&
// performance problems we do it all the time now (bug 68821) !aSelector->mIDList && !aSelector->mAttrList &&
// When style resolution due to state changes is optimized this // :hover or :active
// should go back to QuirksMode only behavour (see also bug 75559) (nsCSSAtoms::activePseudo == pseudoClass->mAtom ||
PRBool isSelectorGlobal = aSelector->mTag==nsnull ? PR_TRUE : PR_FALSE; nsCSSAtoms::hoverPseudo == pseudoClass->mAtom) &&
if ((data.mIsHTMLContent) && // important for |IsQuirkEventSensitive|:
(!IsEventSensitive(pseudoClass->mAtom, data.mContentTag, isSelectorGlobal))){ data.mIsHTMLContent && !data.mIsHTMLLink &&
!IsQuirkEventSensitive(data.mContentTag)) {
// In quirks mode, only make certain elements sensitive to
// selectors ":hover" and ":active".
// XXX Once we make ":active" work correctly (bug 65917) this
// quirk should apply only to ":hover" (if to anything at all).
result = localFalse; result = localFalse;
} else { } else {
if (nsCSSAtoms::activePseudo == pseudoClass->mAtom) { if (nsCSSAtoms::activePseudo == pseudoClass->mAtom) {

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

@ -3385,24 +3385,18 @@ inline PRBool IsLinkPseudo(nsIAtom* aAtom)
(nsCSSAtoms::anyLinkPseudo == aAtom)); (nsCSSAtoms::anyLinkPseudo == aAtom));
} }
inline PRBool IsEventSensitive(nsIAtom *aPseudo, nsIAtom *aContentTag, PRBool aSelectorIsGlobal) // Return whether we should apply a "global" (i.e., universal-tag)
// selector for event states in quirks mode. Note that
// |data.mIsHTMLLink| is checked separately by the caller, so we return
// false for |nsHTMLAtoms::a|, which here means a named anchor.
inline PRBool IsQuirkEventSensitive(nsIAtom *aContentTag)
{ {
// if the selector is global, meaning it is not tied to a tag, then return PRBool ((nsHTMLAtoms::button == aContentTag) ||
// we restrict the application of the event pseudo to the following tags (nsHTMLAtoms::img == aContentTag) ||
if (aSelectorIsGlobal) { (nsHTMLAtoms::input == aContentTag) ||
return PRBool ((nsHTMLAtoms::a == aContentTag) || (nsHTMLAtoms::label == aContentTag) ||
(nsHTMLAtoms::button == aContentTag) || (nsHTMLAtoms::select == aContentTag) ||
(nsHTMLAtoms::img == aContentTag) || (nsHTMLAtoms::textarea == aContentTag));
(nsHTMLAtoms::input == aContentTag) ||
(nsHTMLAtoms::li == aContentTag) ||
(nsHTMLAtoms::label == aContentTag) ||
(nsHTMLAtoms::select == aContentTag) ||
(nsHTMLAtoms::textarea == aContentTag));
} else {
// selector is not global, so apply the event pseudo to everything except HTML and BODY
return PRBool ((nsHTMLAtoms::html != aContentTag) &&
(nsHTMLAtoms::body != aContentTag));
}
} }
@ -3561,15 +3555,20 @@ static PRBool SelectorMatches(RuleProcessorData &data,
} }
else if (IsEventPseudo(pseudoClass->mAtom)) { else if (IsEventPseudo(pseudoClass->mAtom)) {
// check if the element is event-sensitive // check if the element is event-sensitive
// NOTE: we distinguish between global and subjected selectors so if (data.mIsQuirkMode &&
// pass that information on to the determining routine // global selector:
// ALSO NOTE: we used to do this only in Quirks mode, but because of !aSelector->mTag && !aSelector->mClassList &&
// performance problems we do it all the time now (bug 68821) !aSelector->mIDList && !aSelector->mAttrList &&
// When style resolution due to state changes is optimized this // :hover or :active
// should go back to QuirksMode only behavour (see also bug 75559) (nsCSSAtoms::activePseudo == pseudoClass->mAtom ||
PRBool isSelectorGlobal = aSelector->mTag==nsnull ? PR_TRUE : PR_FALSE; nsCSSAtoms::hoverPseudo == pseudoClass->mAtom) &&
if ((data.mIsHTMLContent) && // important for |IsQuirkEventSensitive|:
(!IsEventSensitive(pseudoClass->mAtom, data.mContentTag, isSelectorGlobal))){ data.mIsHTMLContent && !data.mIsHTMLLink &&
!IsQuirkEventSensitive(data.mContentTag)) {
// In quirks mode, only make certain elements sensitive to
// selectors ":hover" and ":active".
// XXX Once we make ":active" work correctly (bug 65917) this
// quirk should apply only to ":hover" (if to anything at all).
result = localFalse; result = localFalse;
} else { } else {
if (nsCSSAtoms::activePseudo == pseudoClass->mAtom) { if (nsCSSAtoms::activePseudo == pseudoClass->mAtom) {