diff --git a/content/xbl/public/nsIXBLPrototypeHandler.h b/content/xbl/public/nsIXBLPrototypeHandler.h index 018b325dbab..0fe2e0b16a4 100644 --- a/content/xbl/public/nsIXBLPrototypeHandler.h +++ b/content/xbl/public/nsIXBLPrototypeHandler.h @@ -32,7 +32,8 @@ #define nsIXBLPrototypeHandler_h__ class nsIContent; -class nsIDOMEvent; +class nsIDOMMouseEvent; +class nsIDOMKeyEvent; // {921812E7-A044-4bd8-B49E-69BB0A607202} #define NS_IXBLPROTOTYPEHANDLER_IID \ @@ -43,7 +44,9 @@ class nsIXBLPrototypeHandler : public nsISupports public: static const nsIID& GetIID() { static nsIID iid = NS_IXBLPROTOTYPEHANDLER_IID; return iid; } - NS_IMETHOD EventMatched(nsIDOMEvent* aEvent, PRBool* aResult) = 0; + NS_IMETHOD MouseEventMatched(nsIDOMMouseEvent* aEvent, PRBool* aResult) = 0; + NS_IMETHOD KeyEventMatched(nsIDOMKeyEvent* aEvent, PRBool* aResult) = 0; + NS_IMETHOD GetHandlerElement(nsIContent** aResult) = 0; NS_IMETHOD GetNextHandler(nsIXBLPrototypeHandler** aResult) = 0; diff --git a/content/xbl/src/nsXBLEventHandler.cpp b/content/xbl/src/nsXBLEventHandler.cpp index 07921d5ba0e..b216b77948b 100644 --- a/content/xbl/src/nsXBLEventHandler.cpp +++ b/content/xbl/src/nsXBLEventHandler.cpp @@ -171,8 +171,10 @@ nsresult nsXBLEventHandler::KeyUp(nsIDOMEvent* aKeyEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aKeyEvent, &matched); + if (mProtoHandler) { + nsCOMPtr key(do_QueryInterface(aKeyEvent)); + mProtoHandler->KeyEventMatched(key, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("keyup"), aKeyEvent); @@ -185,8 +187,10 @@ nsresult nsXBLEventHandler::KeyDown(nsIDOMEvent* aKeyEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aKeyEvent, &matched); + if (mProtoHandler) { + nsCOMPtr key(do_QueryInterface(aKeyEvent)); + mProtoHandler->KeyEventMatched(key, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("keydown"), aKeyEvent); @@ -199,8 +203,10 @@ nsresult nsXBLEventHandler::KeyPress(nsIDOMEvent* aKeyEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aKeyEvent, &matched); + if (mProtoHandler) { + nsCOMPtr key(do_QueryInterface(aKeyEvent)); + mProtoHandler->KeyEventMatched(key, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("keypress"), aKeyEvent); @@ -213,8 +219,10 @@ nsresult nsXBLEventHandler::MouseDown(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("mousedown"), aMouseEvent); @@ -227,8 +235,10 @@ nsresult nsXBLEventHandler::MouseUp(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("mouseup"), aMouseEvent); @@ -241,8 +251,10 @@ nsresult nsXBLEventHandler::MouseClick(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("click"), aMouseEvent); @@ -255,8 +267,10 @@ nsresult nsXBLEventHandler::MouseDblClick(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("dblclick"), aMouseEvent); @@ -269,8 +283,10 @@ nsresult nsXBLEventHandler::MouseOver(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("mouseover"), aMouseEvent); @@ -283,8 +299,10 @@ nsresult nsXBLEventHandler::MouseOut(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("mouseout"), aMouseEvent); diff --git a/content/xbl/src/nsXBLPrototypeHandler.cpp b/content/xbl/src/nsXBLPrototypeHandler.cpp index f32f08387c2..1c04a2b0fb0 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -106,22 +106,6 @@ nsXBLPrototypeHandler::~nsXBLPrototypeHandler() NS_IMPL_ISUPPORTS1(nsXBLPrototypeHandler, nsIXBLPrototypeHandler) -NS_IMETHODIMP -nsXBLPrototypeHandler::EventMatched(nsIDOMEvent* aEvent, PRBool* aResult) -{ - nsCOMPtr mouse(do_QueryInterface(aEvent)); - if (mouse) - *aResult = MouseEventMatched(mouse); - else { - nsCOMPtr key(do_QueryInterface(aEvent)); - if (key) - *aResult = KeyEventMatched(key); - else *aResult = PR_TRUE; - } - - return NS_OK; -} - NS_IMETHODIMP nsXBLPrototypeHandler::GetHandlerElement(nsIContent** aResult) { @@ -172,14 +156,18 @@ nsXBLPrototypeHandler::InitAccessKey() } -PRBool -nsXBLPrototypeHandler::KeyEventMatched(nsIDOMKeyEvent* aKeyEvent) +NS_IMETHODIMP +nsXBLPrototypeHandler::KeyEventMatched(nsIDOMKeyEvent* aKeyEvent, PRBool* aResult) { - if (!mHandlerElement) - return PR_FALSE; + *aResult = PR_TRUE; + + if (!mHandlerElement) { + *aResult = PR_FALSE; + return NS_OK; + } if (mDetail == 0 && mDetail2 == 0 && mKeyMask == 0) - return PR_TRUE; // No filters set up. It's generic. + return NS_OK; // No filters set up. It's generic. // Get the keycode and charcode of the key event. PRUint32 keyCode, charCode; @@ -188,33 +176,47 @@ nsXBLPrototypeHandler::KeyEventMatched(nsIDOMKeyEvent* aKeyEvent) PRBool keyMatched = (mDetail == (mDetail2 ? charCode : keyCode)); - if (!keyMatched) - return PR_FALSE; + if (!keyMatched) { + *aResult = PR_FALSE; + return NS_OK; + } // Now check modifier keys - return ModifiersMatchMask(aKeyEvent); + PRBool result = ModifiersMatchMask(aKeyEvent); + *aResult = result; + return NS_OK; } -PRBool -nsXBLPrototypeHandler::MouseEventMatched(nsIDOMMouseEvent* aMouseEvent) +NS_IMETHODIMP +nsXBLPrototypeHandler::MouseEventMatched(nsIDOMMouseEvent* aMouseEvent, PRBool* aResult) { - if (!mHandlerElement) - return PR_FALSE; + *aResult = PR_TRUE; + + if (!mHandlerElement) { + *aResult = PR_FALSE; + return NS_OK; + } if (mDetail == 0 && mDetail2 == 0 && mKeyMask == 0) - return PR_TRUE; // No filters set up. It's generic. + return NS_OK; // No filters set up. It's generic. unsigned short button; aMouseEvent->GetButton(&button); - if (mDetail != 0 && (button != mDetail)) - return PR_FALSE; + if (mDetail != 0 && (button != mDetail)) { + *aResult = PR_FALSE; + return NS_OK; + } PRInt32 clickcount; aMouseEvent->GetDetail(&clickcount); - if (mDetail2 != 0 && (clickcount != mDetail2)) - return PR_FALSE; + if (mDetail2 != 0 && (clickcount != mDetail2)) { + *aResult = PR_FALSE; + return NS_OK; + } - return ModifiersMatchMask(aMouseEvent); + PRBool result = ModifiersMatchMask(aMouseEvent); + *aResult = result; + return NS_OK; } enum { diff --git a/content/xbl/src/nsXBLPrototypeHandler.h b/content/xbl/src/nsXBLPrototypeHandler.h index 1dfa12073a4..cb37556acac 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.h +++ b/content/xbl/src/nsXBLPrototypeHandler.h @@ -44,7 +44,9 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD EventMatched(nsIDOMEvent* aEvent, PRBool* aResult); + NS_IMETHOD MouseEventMatched(nsIDOMMouseEvent* aEvent, PRBool* aResult); + NS_IMETHOD KeyEventMatched(nsIDOMKeyEvent* aEvent, PRBool* aResult); + NS_IMETHOD GetHandlerElement(nsIContent** aResult); NS_IMETHOD GetNextHandler(nsIXBLPrototypeHandler** aResult); diff --git a/layout/xbl/public/nsIXBLPrototypeHandler.h b/layout/xbl/public/nsIXBLPrototypeHandler.h index 018b325dbab..0fe2e0b16a4 100644 --- a/layout/xbl/public/nsIXBLPrototypeHandler.h +++ b/layout/xbl/public/nsIXBLPrototypeHandler.h @@ -32,7 +32,8 @@ #define nsIXBLPrototypeHandler_h__ class nsIContent; -class nsIDOMEvent; +class nsIDOMMouseEvent; +class nsIDOMKeyEvent; // {921812E7-A044-4bd8-B49E-69BB0A607202} #define NS_IXBLPROTOTYPEHANDLER_IID \ @@ -43,7 +44,9 @@ class nsIXBLPrototypeHandler : public nsISupports public: static const nsIID& GetIID() { static nsIID iid = NS_IXBLPROTOTYPEHANDLER_IID; return iid; } - NS_IMETHOD EventMatched(nsIDOMEvent* aEvent, PRBool* aResult) = 0; + NS_IMETHOD MouseEventMatched(nsIDOMMouseEvent* aEvent, PRBool* aResult) = 0; + NS_IMETHOD KeyEventMatched(nsIDOMKeyEvent* aEvent, PRBool* aResult) = 0; + NS_IMETHOD GetHandlerElement(nsIContent** aResult) = 0; NS_IMETHOD GetNextHandler(nsIXBLPrototypeHandler** aResult) = 0; diff --git a/layout/xbl/src/nsXBLEventHandler.cpp b/layout/xbl/src/nsXBLEventHandler.cpp index 07921d5ba0e..b216b77948b 100644 --- a/layout/xbl/src/nsXBLEventHandler.cpp +++ b/layout/xbl/src/nsXBLEventHandler.cpp @@ -171,8 +171,10 @@ nsresult nsXBLEventHandler::KeyUp(nsIDOMEvent* aKeyEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aKeyEvent, &matched); + if (mProtoHandler) { + nsCOMPtr key(do_QueryInterface(aKeyEvent)); + mProtoHandler->KeyEventMatched(key, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("keyup"), aKeyEvent); @@ -185,8 +187,10 @@ nsresult nsXBLEventHandler::KeyDown(nsIDOMEvent* aKeyEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aKeyEvent, &matched); + if (mProtoHandler) { + nsCOMPtr key(do_QueryInterface(aKeyEvent)); + mProtoHandler->KeyEventMatched(key, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("keydown"), aKeyEvent); @@ -199,8 +203,10 @@ nsresult nsXBLEventHandler::KeyPress(nsIDOMEvent* aKeyEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aKeyEvent, &matched); + if (mProtoHandler) { + nsCOMPtr key(do_QueryInterface(aKeyEvent)); + mProtoHandler->KeyEventMatched(key, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("keypress"), aKeyEvent); @@ -213,8 +219,10 @@ nsresult nsXBLEventHandler::MouseDown(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("mousedown"), aMouseEvent); @@ -227,8 +235,10 @@ nsresult nsXBLEventHandler::MouseUp(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("mouseup"), aMouseEvent); @@ -241,8 +251,10 @@ nsresult nsXBLEventHandler::MouseClick(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("click"), aMouseEvent); @@ -255,8 +267,10 @@ nsresult nsXBLEventHandler::MouseDblClick(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("dblclick"), aMouseEvent); @@ -269,8 +283,10 @@ nsresult nsXBLEventHandler::MouseOver(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("mouseover"), aMouseEvent); @@ -283,8 +299,10 @@ nsresult nsXBLEventHandler::MouseOut(nsIDOMEvent* aMouseEvent) return NS_OK; PRBool matched = PR_FALSE; - if (mProtoHandler) - mProtoHandler->EventMatched(aMouseEvent, &matched); + if (mProtoHandler) { + nsCOMPtr mouse(do_QueryInterface(aMouseEvent)); + mProtoHandler->MouseEventMatched(mouse, &matched); + } if (matched) ExecuteHandler(NS_LITERAL_STRING("mouseout"), aMouseEvent); diff --git a/layout/xbl/src/nsXBLPrototypeHandler.cpp b/layout/xbl/src/nsXBLPrototypeHandler.cpp index f32f08387c2..1c04a2b0fb0 100644 --- a/layout/xbl/src/nsXBLPrototypeHandler.cpp +++ b/layout/xbl/src/nsXBLPrototypeHandler.cpp @@ -106,22 +106,6 @@ nsXBLPrototypeHandler::~nsXBLPrototypeHandler() NS_IMPL_ISUPPORTS1(nsXBLPrototypeHandler, nsIXBLPrototypeHandler) -NS_IMETHODIMP -nsXBLPrototypeHandler::EventMatched(nsIDOMEvent* aEvent, PRBool* aResult) -{ - nsCOMPtr mouse(do_QueryInterface(aEvent)); - if (mouse) - *aResult = MouseEventMatched(mouse); - else { - nsCOMPtr key(do_QueryInterface(aEvent)); - if (key) - *aResult = KeyEventMatched(key); - else *aResult = PR_TRUE; - } - - return NS_OK; -} - NS_IMETHODIMP nsXBLPrototypeHandler::GetHandlerElement(nsIContent** aResult) { @@ -172,14 +156,18 @@ nsXBLPrototypeHandler::InitAccessKey() } -PRBool -nsXBLPrototypeHandler::KeyEventMatched(nsIDOMKeyEvent* aKeyEvent) +NS_IMETHODIMP +nsXBLPrototypeHandler::KeyEventMatched(nsIDOMKeyEvent* aKeyEvent, PRBool* aResult) { - if (!mHandlerElement) - return PR_FALSE; + *aResult = PR_TRUE; + + if (!mHandlerElement) { + *aResult = PR_FALSE; + return NS_OK; + } if (mDetail == 0 && mDetail2 == 0 && mKeyMask == 0) - return PR_TRUE; // No filters set up. It's generic. + return NS_OK; // No filters set up. It's generic. // Get the keycode and charcode of the key event. PRUint32 keyCode, charCode; @@ -188,33 +176,47 @@ nsXBLPrototypeHandler::KeyEventMatched(nsIDOMKeyEvent* aKeyEvent) PRBool keyMatched = (mDetail == (mDetail2 ? charCode : keyCode)); - if (!keyMatched) - return PR_FALSE; + if (!keyMatched) { + *aResult = PR_FALSE; + return NS_OK; + } // Now check modifier keys - return ModifiersMatchMask(aKeyEvent); + PRBool result = ModifiersMatchMask(aKeyEvent); + *aResult = result; + return NS_OK; } -PRBool -nsXBLPrototypeHandler::MouseEventMatched(nsIDOMMouseEvent* aMouseEvent) +NS_IMETHODIMP +nsXBLPrototypeHandler::MouseEventMatched(nsIDOMMouseEvent* aMouseEvent, PRBool* aResult) { - if (!mHandlerElement) - return PR_FALSE; + *aResult = PR_TRUE; + + if (!mHandlerElement) { + *aResult = PR_FALSE; + return NS_OK; + } if (mDetail == 0 && mDetail2 == 0 && mKeyMask == 0) - return PR_TRUE; // No filters set up. It's generic. + return NS_OK; // No filters set up. It's generic. unsigned short button; aMouseEvent->GetButton(&button); - if (mDetail != 0 && (button != mDetail)) - return PR_FALSE; + if (mDetail != 0 && (button != mDetail)) { + *aResult = PR_FALSE; + return NS_OK; + } PRInt32 clickcount; aMouseEvent->GetDetail(&clickcount); - if (mDetail2 != 0 && (clickcount != mDetail2)) - return PR_FALSE; + if (mDetail2 != 0 && (clickcount != mDetail2)) { + *aResult = PR_FALSE; + return NS_OK; + } - return ModifiersMatchMask(aMouseEvent); + PRBool result = ModifiersMatchMask(aMouseEvent); + *aResult = result; + return NS_OK; } enum { diff --git a/layout/xbl/src/nsXBLPrototypeHandler.h b/layout/xbl/src/nsXBLPrototypeHandler.h index 1dfa12073a4..cb37556acac 100644 --- a/layout/xbl/src/nsXBLPrototypeHandler.h +++ b/layout/xbl/src/nsXBLPrototypeHandler.h @@ -44,7 +44,9 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD EventMatched(nsIDOMEvent* aEvent, PRBool* aResult); + NS_IMETHOD MouseEventMatched(nsIDOMMouseEvent* aEvent, PRBool* aResult); + NS_IMETHOD KeyEventMatched(nsIDOMKeyEvent* aEvent, PRBool* aResult); + NS_IMETHOD GetHandlerElement(nsIContent** aResult); NS_IMETHOD GetNextHandler(nsIXBLPrototypeHandler** aResult);