Support :required and :optional pseudoclasses. Bug 302608, r+sr=bzbarsky, a=mkaply

This commit is contained in:
allan%beaufour.dk 2005-08-02 08:29:03 +00:00
Родитель e61c4e352f
Коммит 18c60543f2
3 изменённых файлов: 24 добавлений и 7 удалений

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

@ -139,12 +139,17 @@ public:
NS_IMETHOD ShiftFocus(PRBool aDirection, nsIContent* aStart)=0;
};
#define NS_EVENT_STATE_ACTIVE 0x0001 // mouse is down on content
#define NS_EVENT_STATE_FOCUS 0x0002 // content has focus
#define NS_EVENT_STATE_HOVER 0x0004 // mouse is hovering over content
#define NS_EVENT_STATE_DRAGOVER 0x0008 // drag is hovering over content
#define NS_EVENT_STATE_URLTARGET 0x0010 // content is URL's target (ref)
#define NS_EVENT_STATE_ACTIVE 0x00000001 // mouse is down on content
#define NS_EVENT_STATE_FOCUS 0x00000002 // content has focus
#define NS_EVENT_STATE_HOVER 0x00000004 // mouse is hovering over content
#define NS_EVENT_STATE_DRAGOVER 0x00000008 // drag is hovering over content
#define NS_EVENT_STATE_URLTARGET 0x00000010 // content is URL's target (ref)
// The following states are used only for ContentStatesChanged
#define NS_EVENT_STATE_CHECKED 0x0020
// CSS 3 Selectors
#define NS_EVENT_STATE_CHECKED 0x00000020
// CSS 3 UI
#define NS_EVENT_STATE_REQUIRED 0x00000040
#define NS_EVENT_STATE_OPTIONAL 0x00000080
#endif // nsIEventStateManager_h__

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

@ -76,3 +76,7 @@ CSS_PSEUDO_CLASS(lastChild, ":last-child")
CSS_PSEUDO_CLASS(lastNode, ":-moz-last-node")
CSS_PSEUDO_CLASS(onlyChild, ":only-child")
// CSS 3 UI
// http://www.w3.org/TR/2004/CR-css3-ui-20040511/#pseudo-classes
CSS_PSEUDO_CLASS(required, ":required")
CSS_PSEUDO_CLASS(optional, ":optional")

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

@ -3125,6 +3125,12 @@ static PRBool SelectorMatches(RuleProcessorData &data,
// <input type=radio>
result = STATE_CHECK(NS_EVENT_STATE_CHECKED);
}
else if (nsCSSPseudoClasses::required == pseudoClass->mAtom) {
result = STATE_CHECK(NS_EVENT_STATE_REQUIRED);
}
else if (nsCSSPseudoClasses::optional == pseudoClass->mAtom) {
result = STATE_CHECK(NS_EVENT_STATE_OPTIONAL);
}
else {
NS_ERROR("CSS parser parsed a pseudo-class that we do not handle");
result = PR_FALSE; // unknown pseudo class
@ -3637,7 +3643,9 @@ PRBool IsStateSelector(nsCSSSelector& aSelector)
(pseudoClass->mAtom == nsCSSPseudoClasses::mozDragOver) ||
(pseudoClass->mAtom == nsCSSPseudoClasses::focus) ||
(pseudoClass->mAtom == nsCSSPseudoClasses::hover) ||
(pseudoClass->mAtom == nsCSSPseudoClasses::target)) {
(pseudoClass->mAtom == nsCSSPseudoClasses::target) ||
(pseudoClass->mAtom == nsCSSPseudoClasses::required) ||
(pseudoClass->mAtom == nsCSSPseudoClasses::optional)) {
return PR_TRUE;
}
}