зеркало из https://github.com/mozilla/pjs.git
Fixing bug 257431. Make the tabbrowser code only listen to events initiated by the user. r=trev@gtchat.de, sr=bzbarsky@mit.edu
This commit is contained in:
Родитель
7ead66e29a
Коммит
00e4d5d5e3
|
@ -46,9 +46,9 @@ class nsPresContext;
|
|||
* Event listener manager interface.
|
||||
*/
|
||||
#define NS_IPRIVATEDOMEVENT_IID \
|
||||
{ /* 80a98c80-2036-11d2-bd89-00805f8ae3f4 */ \
|
||||
0x80a98c80, 0x2036, 0x11d2, \
|
||||
{0xbd, 0x89, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
|
||||
{ /* 25e6626c-8e54-409b-87b5-2beceaac399e */ \
|
||||
0x25e6626c, 0x8e54, 0x409b, \
|
||||
{0x87, 0xb5, 0x2b, 0xec, 0xea, 0xac, 0x39, 0x9e} }
|
||||
|
||||
class nsIDOMEventTarget;
|
||||
class nsIDOMEvent;
|
||||
|
@ -66,7 +66,6 @@ public:
|
|||
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchPrevented) = 0;
|
||||
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent) = 0;
|
||||
NS_IMETHOD HasOriginalTarget(PRBool* aResult)=0;
|
||||
NS_IMETHOD IsTrustedEvent(PRBool* aResult)=0;
|
||||
NS_IMETHOD SetTrusted(PRBool aTrusted)=0;
|
||||
};
|
||||
|
||||
|
|
|
@ -283,13 +283,6 @@ nsDOMEvent::HasOriginalTarget(PRBool* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::IsTrustedEvent(PRBool* aResult)
|
||||
{
|
||||
*aResult = mEventIsTrusted;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::SetTrusted(PRBool aTrusted)
|
||||
{
|
||||
|
@ -364,6 +357,14 @@ nsDOMEvent::PreventCapture()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetIsTrusted(PRBool *aIsTrusted)
|
||||
{
|
||||
*aIsTrusted = mEventIsTrusted;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::PreventDefault()
|
||||
{
|
||||
|
|
|
@ -141,7 +141,6 @@ public:
|
|||
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchStopped);
|
||||
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent);
|
||||
NS_IMETHOD HasOriginalTarget(PRBool* aResult);
|
||||
NS_IMETHOD IsTrustedEvent(PRBool* aResult);
|
||||
NS_IMETHOD SetTrusted(PRBool aTrusted);
|
||||
|
||||
NS_IMETHOD IsHandled(PRBool* aHandled);
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPIWindowRoot.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
@ -228,14 +229,15 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver,
|
|||
// XUL handlers and commands shouldn't be triggered by non-trusted
|
||||
// events.
|
||||
if (isXULKey || isXBLCommand) {
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aEvent);
|
||||
if (privateEvent) {
|
||||
PRBool trustedEvent;
|
||||
privateEvent->IsTrustedEvent(&trustedEvent);
|
||||
nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aEvent);
|
||||
PRBool trustedEvent = PR_FALSE;
|
||||
if (domNSEvent) {
|
||||
domNSEvent->GetIsTrusted(&trustedEvent);
|
||||
}
|
||||
|
||||
if (!trustedEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool isReceiverCommandElement = PR_FALSE;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aReceiver));
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsXBLService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
@ -124,14 +124,16 @@ nsXBLWindowKeyHandler::WalkHandlers(nsIDOMEvent* aKeyEvent, nsIAtom* aEventType)
|
|||
if (prevent)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aKeyEvent);
|
||||
if (privateEvent) {
|
||||
nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aKeyEvent);
|
||||
PRBool trustedEvent = PR_FALSE;
|
||||
|
||||
if (domNSEvent) {
|
||||
//Don't process the event if it was not dispatched from a trusted source
|
||||
PRBool trustedEvent;
|
||||
privateEvent->IsTrustedEvent(&trustedEvent);
|
||||
domNSEvent->GetIsTrusted(&trustedEvent);
|
||||
}
|
||||
|
||||
if (!trustedEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Make sure our event is really a key event
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent(do_QueryInterface(aKeyEvent));
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(a90977dd-a80b-49bb-8169-cc90e3d1da98)]
|
||||
[scriptable, uuid(e565d518-4510-407f-a3d9-3b4107549c6d)]
|
||||
interface nsIDOMNSEvent : nsISupports
|
||||
{
|
||||
const long MOUSEDOWN = 0x00000001;
|
||||
|
@ -100,4 +100,6 @@ interface nsIDOMNSEvent : nsISupports
|
|||
|
||||
void preventBubble();
|
||||
void preventCapture();
|
||||
|
||||
readonly attribute boolean isTrusted;
|
||||
};
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
|
||||
// Drag & Drop, Clipboard
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -142,15 +141,15 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent)
|
|||
InitAccessKey();
|
||||
|
||||
//handlers shouldn't be triggered by non-trusted events.
|
||||
if (aKeyEvent) {
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aKeyEvent);
|
||||
if (privateEvent) {
|
||||
PRBool trustedEvent;
|
||||
privateEvent->IsTrustedEvent(&trustedEvent);
|
||||
nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aKeyEvent);
|
||||
PRBool trustedEvent = PR_FALSE;
|
||||
|
||||
if (domNSEvent) {
|
||||
domNSEvent->GetIsTrusted(&trustedEvent);
|
||||
}
|
||||
|
||||
if (!trustedEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (mAccessKey && mAccessKeyFocuses)
|
||||
{
|
||||
|
@ -202,15 +201,14 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
}
|
||||
|
||||
//handlers shouldn't be triggered by non-trusted events.
|
||||
if (aKeyEvent) {
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aKeyEvent);
|
||||
if (privateEvent) {
|
||||
PRBool trustedEvent;
|
||||
privateEvent->IsTrustedEvent(&trustedEvent);
|
||||
nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aKeyEvent);
|
||||
PRBool trustedEvent = PR_FALSE;
|
||||
if (domNSEvent) {
|
||||
domNSEvent->GetIsTrusted(&trustedEvent);
|
||||
}
|
||||
|
||||
if (!trustedEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult retVal = NS_OK; // default is to not consume event
|
||||
|
||||
|
@ -322,15 +320,15 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
InitAccessKey();
|
||||
|
||||
//handlers shouldn't be triggered by non-trusted events.
|
||||
if (aKeyEvent) {
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aKeyEvent);
|
||||
if (privateEvent) {
|
||||
PRBool trustedEvent;
|
||||
privateEvent->IsTrustedEvent(&trustedEvent);
|
||||
nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aKeyEvent);
|
||||
PRBool trustedEvent = PR_FALSE;
|
||||
|
||||
if (domNSEvent) {
|
||||
domNSEvent->GetIsTrusted(&trustedEvent);
|
||||
}
|
||||
|
||||
if (!trustedEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (mAccessKey && mAccessKeyFocuses)
|
||||
{
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
// Drag & Drop, Clipboard
|
||||
|
@ -52,7 +51,7 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
@ -173,15 +172,15 @@ nsMenuListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
}
|
||||
|
||||
//handlers shouldn't be triggered by non-trusted events.
|
||||
if (aKeyEvent) {
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aKeyEvent);
|
||||
if (privateEvent) {
|
||||
PRBool trustedEvent;
|
||||
privateEvent->IsTrustedEvent(&trustedEvent);
|
||||
nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aKeyEvent);
|
||||
PRBool trustedEvent = PR_FALSE;
|
||||
|
||||
if (domNSEvent) {
|
||||
domNSEvent->GetIsTrusted(&trustedEvent);
|
||||
}
|
||||
|
||||
if (!trustedEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
|
||||
PRUint32 theChar;
|
||||
|
|
|
@ -114,6 +114,11 @@
|
|||
<![CDATA[({
|
||||
tabbox: this,
|
||||
handleEvent: function handleEvent(event) {
|
||||
if (!event.isTrusted) {
|
||||
// Don't let untrusted events mess with tabs.
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.keyCode) {
|
||||
case event.DOM_VK_TAB:
|
||||
if (event.ctrlKey && !event.altKey && !event.metaKey)
|
||||
|
|
|
@ -114,6 +114,11 @@
|
|||
<![CDATA[({
|
||||
tabbox: this,
|
||||
handleEvent: function handleEvent(event) {
|
||||
if (!event.isTrusted) {
|
||||
// Don't let untrusted events mess with tabs.
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.keyCode) {
|
||||
case event.DOM_VK_TAB:
|
||||
if (event.ctrlKey && !event.altKey && !event.metaKey)
|
||||
|
|
Загрузка…
Ссылка в новой задаче