From 325c013e351348dd7d4cdfc5916b2a309b37eb81 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 19 Jun 2008 09:17:08 -0700 Subject: [PATCH] Backed out changeset b0d1180627db (caused tinderbox oranges from leaks) --- content/xbl/public/nsIXBLService.h | 5 +- content/xbl/src/nsXBLService.cpp | 50 +------ content/xbl/src/nsXBLService.h | 1 - content/xbl/src/nsXBLWindowKeyHandler.cpp | 7 - content/xul/document/src/nsXULDocument.cpp | 8 -- toolkit/content/tests/chrome/Makefile.in | 2 - toolkit/content/tests/chrome/test_keys.xul | 31 ----- toolkit/content/tests/chrome/window_keys.xul | 129 ------------------- 8 files changed, 4 insertions(+), 229 deletions(-) delete mode 100644 toolkit/content/tests/chrome/test_keys.xul delete mode 100644 toolkit/content/tests/chrome/window_keys.xul diff --git a/content/xbl/public/nsIXBLService.h b/content/xbl/public/nsIXBLService.h index 0830e514124a..4da9624d004b 100644 --- a/content/xbl/public/nsIXBLService.h +++ b/content/xbl/public/nsIXBLService.h @@ -58,8 +58,8 @@ class nsIAtom; class nsIPrincipal; #define NS_IXBLSERVICE_IID \ -{ 0x8d3b37f5, 0xde7e, 0x4595, \ - { 0xb8, 0x56, 0xf7, 0x11, 0xe8, 0xe7, 0xb5, 0x59 } } +{ 0x98b28f4e, 0x698f, 0x4f77, \ + { 0xa8, 0x9e, 0x65, 0xf5, 0xd0, 0xde, 0x6a, 0xbf } } class nsIXBLService : public nsISupports { @@ -90,7 +90,6 @@ public: // Hooks up the global key event handlers to the document root. NS_IMETHOD AttachGlobalKeyHandler(nsPIDOMEventTarget* aTarget)=0; - NS_IMETHOD DetachGlobalKeyHandler(nsPIDOMEventTarget* aTarget)=0; }; diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index b5c2e280fc31..6a863158fac8 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -673,10 +673,6 @@ nsXBLService::AttachGlobalKeyHandler(nsPIDOMEventTarget* aTarget) if (!piTarget) return NS_ERROR_FAILURE; - - // the listener already exists, so skip this - if (contentNode && contentNode->GetProperty(nsGkAtoms::listener)) - return NS_OK; nsCOMPtr elt(do_QueryInterface(contentNode)); @@ -698,50 +694,8 @@ nsXBLService::AttachGlobalKeyHandler(nsPIDOMEventTarget* aTarget) target->AddGroupedEventListener(NS_LITERAL_STRING("keypress"), handler, PR_FALSE, systemGroup); - // the reference added in NS_NewXBLWindowKeyHandler will be taken by the property - if (contentNode) - return contentNode->SetProperty(nsGkAtoms::listener, handler, - nsPropertyTable::SupportsDtorFunc, PR_TRUE); - return NS_OK; -} - -// -// DetachGlobalKeyHandler -// -// Removes a key handler added by DeatchGlobalKeyHandler. -// -NS_IMETHODIMP -nsXBLService::DetachGlobalKeyHandler(nsPIDOMEventTarget* aTarget) -{ - nsCOMPtr piTarget = aTarget; - nsCOMPtr contentNode(do_QueryInterface(aTarget)); - if (!contentNode) // detaching is only supported for content nodes - return NS_ERROR_FAILURE; - - // Only attach if we're really in a document - nsCOMPtr doc = contentNode->GetCurrentDoc(); - if (doc) - piTarget = do_QueryInterface(doc); - if (!piTarget) - return NS_ERROR_FAILURE; - - nsIDOMEventListener* handler = - static_cast(contentNode->GetProperty(nsGkAtoms::listener)); - if (!handler) - return NS_ERROR_FAILURE; - - nsCOMPtr systemGroup; - piTarget->GetSystemEventGroup(getter_AddRefs(systemGroup)); - nsCOMPtr target = do_QueryInterface(piTarget); - - target->RemoveGroupedEventListener(NS_LITERAL_STRING("keydown"), handler, - PR_FALSE, systemGroup); - target->RemoveGroupedEventListener(NS_LITERAL_STRING("keyup"), handler, - PR_FALSE, systemGroup); - target->RemoveGroupedEventListener(NS_LITERAL_STRING("keypress"), handler, - PR_FALSE, systemGroup); - - contentNode->DeleteProperty(nsGkAtoms::listener); + // Release. Do this so that only the event receiver holds onto the key handler. + NS_RELEASE(handler); return NS_OK; } diff --git a/content/xbl/src/nsXBLService.h b/content/xbl/src/nsXBLService.h index 62ed170adf58..b6bb9a2ebdc4 100644 --- a/content/xbl/src/nsXBLService.h +++ b/content/xbl/src/nsXBLService.h @@ -88,7 +88,6 @@ class nsXBLService : public nsIXBLService, // Used by XUL key bindings and for window XBL. NS_IMETHOD AttachGlobalKeyHandler(nsPIDOMEventTarget* aTarget); - NS_IMETHOD DetachGlobalKeyHandler(nsPIDOMEventTarget* aTarget); NS_DECL_NSIOBSERVER diff --git a/content/xbl/src/nsXBLWindowKeyHandler.cpp b/content/xbl/src/nsXBLWindowKeyHandler.cpp index c501904e77cd..265f519a13d7 100644 --- a/content/xbl/src/nsXBLWindowKeyHandler.cpp +++ b/content/xbl/src/nsXBLWindowKeyHandler.cpp @@ -356,13 +356,6 @@ nsXBLWindowKeyHandler::WalkHandlers(nsIDOMEvent* aKeyEvent, nsIAtom* aEventType) } } - nsCOMPtr content = do_QueryInterface(el); - // skip keysets that are disabled - if (content && content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled, - nsGkAtoms::_true, eCaseMatters)) { - return NS_OK; - } - WalkHandlersInternal(aKeyEvent, aEventType, mHandler); nsINativeKeyBindings *nativeBindings; diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index e87721dc31d1..b79d94b90db5 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -1689,14 +1689,6 @@ nsXULDocument::RemoveSubtreeFromDocument(nsIContent* aElement) // document. nsresult rv; - if (aElement->NodeInfo()->Equals(nsGkAtoms::keyset, kNameSpaceID_XUL)) { - nsCOMPtr xblService(do_GetService("@mozilla.org/xbl;1")); - if (xblService) { - nsCOMPtr piTarget(do_QueryInterface(aElement)); - xblService->DetachGlobalKeyHandler(piTarget); - } - } - // 1. Remove any children from the document. PRUint32 count = aElement->GetChildCount(); diff --git a/toolkit/content/tests/chrome/Makefile.in b/toolkit/content/tests/chrome/Makefile.in index 43d258ed0a21..c3df3388a48d 100644 --- a/toolkit/content/tests/chrome/Makefile.in +++ b/toolkit/content/tests/chrome/Makefile.in @@ -64,8 +64,6 @@ _TEST_FILES = bug288254_window.xul \ frame_popup_anchor.xul \ test_preferences.xul \ window_preferences.xul \ - test_keys.xul \ - window_keys.xul \ $(NULL) ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) diff --git a/toolkit/content/tests/chrome/test_keys.xul b/toolkit/content/tests/chrome/test_keys.xul deleted file mode 100644 index 96758a9be59f..000000000000 --- a/toolkit/content/tests/chrome/test_keys.xul +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - -

-

- -
-
- - -
diff --git a/toolkit/content/tests/chrome/window_keys.xul b/toolkit/content/tests/chrome/window_keys.xul deleted file mode 100644 index 3413ce754c96..000000000000 --- a/toolkit/content/tests/chrome/window_keys.xul +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-

- -
-
- - -