From 573c3b6d32908eb166b2bd08b91b26bd7832fc4b Mon Sep 17 00:00:00 2001 From: "doronr%us.ibm.com" Date: Tue, 18 Oct 2005 21:16:27 +0000 Subject: [PATCH] Bug 302188 - Support :read-only and :read-write pseudoclasses. patch by allan, r/sr=bz --- content/events/public/nsIEventStateManager.h | 41 +++++++++++--------- layout/style/nsCSSPseudoClassList.h | 2 + layout/style/nsCSSStyleSheet.cpp | 10 ++++- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/content/events/public/nsIEventStateManager.h b/content/events/public/nsIEventStateManager.h index 123c27a6ff8c..dbf027b9f9c4 100644 --- a/content/events/public/nsIEventStateManager.h +++ b/content/events/public/nsIEventStateManager.h @@ -152,33 +152,36 @@ public: NS_IMETHOD ShiftFocus(PRBool aDirection, nsIContent* aStart)=0; }; -#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) +#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 0x00000020 // CSS3-Selectors -#define NS_EVENT_STATE_ENABLED 0x00000040 // CSS3-Selectors -#define NS_EVENT_STATE_DISABLED 0x00000080 // CSS3-Selectors -#define NS_EVENT_STATE_REQUIRED 0x00000100 // CSS3-UI -#define NS_EVENT_STATE_OPTIONAL 0x00000200 // CSS3-UI -#define NS_EVENT_STATE_VISITED 0x00000400 // CSS2 -#define NS_EVENT_STATE_VALID 0x00000800 // CSS3-UI -#define NS_EVENT_STATE_INVALID 0x00001000 // CSS3-UI -#define NS_EVENT_STATE_INRANGE 0x00002000 // CSS3-UI -#define NS_EVENT_STATE_OUTOFRANGE 0x00004000 // CSS3-UI +#define NS_EVENT_STATE_CHECKED 0x00000020 // CSS3-Selectors +#define NS_EVENT_STATE_ENABLED 0x00000040 // CSS3-Selectors +#define NS_EVENT_STATE_DISABLED 0x00000080 // CSS3-Selectors +#define NS_EVENT_STATE_REQUIRED 0x00000100 // CSS3-UI +#define NS_EVENT_STATE_OPTIONAL 0x00000200 // CSS3-UI +#define NS_EVENT_STATE_VISITED 0x00000400 // CSS2 +#define NS_EVENT_STATE_VALID 0x00000800 // CSS3-UI +#define NS_EVENT_STATE_INVALID 0x00001000 // CSS3-UI +#define NS_EVENT_STATE_INRANGE 0x00002000 // CSS3-UI +#define NS_EVENT_STATE_OUTOFRANGE 0x00004000 // CSS3-UI +// these two are temporary (see bug 302188) +#define NS_EVENT_STATE_MOZ_READONLY 0x00008000 // CSS3-UI +#define NS_EVENT_STATE_MOZ_READWRITE 0x00010000 // CSS3-UI // Content could not be rendered (image/object/etc). -#define NS_EVENT_STATE_BROKEN 0x00008000 +#define NS_EVENT_STATE_BROKEN 0x00020000 // Content disabled by the user (images turned off, say) -#define NS_EVENT_STATE_USERDISABLED 0x00010000 +#define NS_EVENT_STATE_USERDISABLED 0x00040000 // Content suppressed by the user (ad blocking, etc) -#define NS_EVENT_STATE_SUPPRESSED 0x00020000 +#define NS_EVENT_STATE_SUPPRESSED 0x00080000 // Content is still loading such that there is nothing to show the // user (eg an image which hasn't started coming in yet) -#define NS_EVENT_STATE_LOADING 0x00040000 +#define NS_EVENT_STATE_LOADING 0x00100000 #endif // nsIEventStateManager_h__ diff --git a/layout/style/nsCSSPseudoClassList.h b/layout/style/nsCSSPseudoClassList.h index 0947d6c62f64..83ebce568a2a 100644 --- a/layout/style/nsCSSPseudoClassList.h +++ b/layout/style/nsCSSPseudoClassList.h @@ -91,3 +91,5 @@ CSS_PSEUDO_CLASS(valid, ":valid") CSS_PSEUDO_CLASS(invalid, ":invalid") CSS_PSEUDO_CLASS(inRange, ":in-range") CSS_PSEUDO_CLASS(outOfRange, ":out-of-range") +CSS_PSEUDO_CLASS(mozReadOnly, ":-moz-read-only") +CSS_PSEUDO_CLASS(mozReadWrite, ":-moz-read-write") diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index 0541f62d753e..70dcb0812da8 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -3130,6 +3130,12 @@ static PRBool SelectorMatches(RuleProcessorData &data, else if (nsCSSPseudoClasses::outOfRange == pseudoClass->mAtom) { result = STATE_CHECK(NS_EVENT_STATE_OUTOFRANGE); } + else if (nsCSSPseudoClasses::mozReadOnly == pseudoClass->mAtom) { + result = STATE_CHECK(NS_EVENT_STATE_MOZ_READONLY); + } + else if (nsCSSPseudoClasses::mozReadWrite == pseudoClass->mAtom) { + result = STATE_CHECK(NS_EVENT_STATE_MOZ_READWRITE); + } else { NS_ERROR("CSS parser parsed a pseudo-class that we do not handle"); result = PR_FALSE; // unknown pseudo class @@ -3657,7 +3663,9 @@ PRBool IsStateSelector(nsCSSSelector& aSelector) (pseudoClass->mAtom == nsCSSPseudoClasses::valid) || (pseudoClass->mAtom == nsCSSPseudoClasses::invalid) || (pseudoClass->mAtom == nsCSSPseudoClasses::inRange) || - (pseudoClass->mAtom == nsCSSPseudoClasses::outOfRange)) { + (pseudoClass->mAtom == nsCSSPseudoClasses::outOfRange) || + (pseudoClass->mAtom == nsCSSPseudoClasses::mozReadOnly) || + (pseudoClass->mAtom == nsCSSPseudoClasses::mozReadWrite)) { return PR_TRUE; } }