зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1089861 - Don't dispatch activate/deactivate to content window objects., r=masayuki
--HG-- extra : rebase_source : 0a6ba0807afeffdbf15176bb2230293881103314
This commit is contained in:
Родитель
1e8333dd1a
Коммит
8d1a51d8ab
|
@ -84,6 +84,14 @@ function test() {
|
|||
}
|
||||
});
|
||||
|
||||
window.messageManager.addMessageListener("Test:ActivateEvent", function(message) {
|
||||
ok(message.data.ok, "Test:ActivateEvent");
|
||||
});
|
||||
|
||||
window.messageManager.addMessageListener("Test:DeactivateEvent", function(message) {
|
||||
ok(message.data.ok, "Test:DeactivateEvent");
|
||||
});
|
||||
|
||||
browser1.addEventListener("load", check, true);
|
||||
browser2.addEventListener("load", check, true);
|
||||
browser1.contentWindow.location = testPage;
|
||||
|
@ -132,6 +140,25 @@ function childFunction()
|
|||
sendAsyncMessage("Test:FocusReceived", { });
|
||||
}, false);
|
||||
|
||||
var windowGotActivate = false;
|
||||
var windowGotDeactivate = false;
|
||||
addEventListener("activate", function() {
|
||||
sendAsyncMessage("Test:ActivateEvent", { ok: !windowGotActivate });
|
||||
windowGotActivate = false;
|
||||
});
|
||||
|
||||
addEventListener("deactivate", function() {
|
||||
sendAsyncMessage("Test:DeactivateEvent", { ok: !windowGotDeactivate });
|
||||
windowGotDeactivate = false;
|
||||
});
|
||||
content.addEventListener("activate", function() {
|
||||
windowGotActivate = true;;
|
||||
});
|
||||
|
||||
content.addEventListener("deactivate", function() {
|
||||
windowGotDeactivate = true;
|
||||
});
|
||||
|
||||
content.setInterval(function () {
|
||||
if (!expectingResponse) {
|
||||
return;
|
||||
|
|
|
@ -3620,7 +3620,8 @@ nsresult
|
|||
nsContentUtils::DispatchEvent(nsIDocument* aDoc, nsISupports* aTarget,
|
||||
const nsAString& aEventName,
|
||||
bool aCanBubble, bool aCancelable,
|
||||
bool aTrusted, bool *aDefaultAction)
|
||||
bool aTrusted, bool *aDefaultAction,
|
||||
bool aOnlyChromeDispatch)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsCOMPtr<EventTarget> target;
|
||||
|
@ -3628,6 +3629,7 @@ nsContentUtils::DispatchEvent(nsIDocument* aDoc, nsISupports* aTarget,
|
|||
aCancelable, aTrusted, getter_AddRefs(event),
|
||||
getter_AddRefs(target));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = aOnlyChromeDispatch;
|
||||
|
||||
bool dummy;
|
||||
return target->DispatchEvent(event, aDefaultAction ? aDefaultAction : &dummy);
|
||||
|
@ -3664,6 +3666,17 @@ nsContentUtils::DispatchChromeEvent(nsIDocument *aDoc,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentUtils::DispatchEventOnlyToChrome(nsIDocument* aDoc,
|
||||
nsISupports* aTarget,
|
||||
const nsAString& aEventName,
|
||||
bool aCanBubble, bool aCancelable,
|
||||
bool* aDefaultAction)
|
||||
{
|
||||
return DispatchEvent(aDoc, aTarget, aEventName, aCanBubble, aCancelable,
|
||||
true, aDefaultAction, true);
|
||||
}
|
||||
|
||||
/* static */
|
||||
Element*
|
||||
nsContentUtils::MatchElementId(nsIContent *aContent, const nsIAtom* aId)
|
||||
|
|
|
@ -987,7 +987,10 @@ public:
|
|||
|
||||
/**
|
||||
* This method creates and dispatches a trusted event to the chrome
|
||||
* event handler.
|
||||
* event handler (the parent object of the DOM Window in the event target
|
||||
* chain). Note, chrome event handler is used even if aTarget is a chrome
|
||||
* object. Use DispatchEventOnlyToChrome if the normal event dispatching is
|
||||
* wanted in case aTarget is a chrome object.
|
||||
* Works only with events which can be created by calling
|
||||
* nsIDOMDocument::CreateEvent() with parameter "Events".
|
||||
* @param aDocument The document which will be used to create the event,
|
||||
|
@ -1007,6 +1010,32 @@ public:
|
|||
bool aCancelable,
|
||||
bool *aDefaultAction = nullptr);
|
||||
|
||||
|
||||
/**
|
||||
* This method creates and dispatches a trusted event.
|
||||
* If aTarget is not a chrome object, the nearest chrome object in the
|
||||
* propagation path will be used as the start of the event target chain.
|
||||
* This method is different than DispatchChromeEvent, which always dispatches
|
||||
* events to chrome event handler. DispatchEventOnlyToChrome works like
|
||||
* DispatchTrustedEvent in the case aTarget is a chrome object.
|
||||
* Works only with events which can be created by calling
|
||||
* nsIDOMDocument::CreateEvent() with parameter "Events".
|
||||
* @param aDoc The document which will be used to create the event.
|
||||
* @param aTarget The target of the event, should be QIable to
|
||||
* nsIDOMEventTarget.
|
||||
* @param aEventName The name of the event.
|
||||
* @param aCanBubble Whether the event can bubble.
|
||||
* @param aCancelable Is the event cancelable.
|
||||
* @param aDefaultAction Set to true if default action should be taken,
|
||||
* see nsIDOMEventTarget::DispatchEvent.
|
||||
*/
|
||||
static nsresult DispatchEventOnlyToChrome(nsIDocument* aDoc,
|
||||
nsISupports* aTarget,
|
||||
const nsAString& aEventName,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
bool *aDefaultAction = nullptr);
|
||||
|
||||
/**
|
||||
* Determines if an event attribute name (such as onclick) is valid for
|
||||
* a given element type. Types are from the EventNameType enumeration
|
||||
|
@ -2253,7 +2282,8 @@ private:
|
|||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
bool aTrusted,
|
||||
bool *aDefaultAction = nullptr);
|
||||
bool *aDefaultAction = nullptr,
|
||||
bool aOnlyChromeDispatch = false);
|
||||
|
||||
static void InitializeModifierStrings();
|
||||
|
||||
|
|
|
@ -1145,11 +1145,12 @@ nsFocusManager::ActivateOrDeactivate(nsPIDOMWindow* aWindow, bool aActive)
|
|||
aWindow->ActivateOrDeactivate(aActive);
|
||||
|
||||
// Send the activate event.
|
||||
nsContentUtils::DispatchTrustedEvent(aWindow->GetExtantDoc(),
|
||||
aWindow,
|
||||
aActive ? NS_LITERAL_STRING("activate") :
|
||||
NS_LITERAL_STRING("deactivate"),
|
||||
true, true, nullptr);
|
||||
nsContentUtils::DispatchEventOnlyToChrome(aWindow->GetExtantDoc(),
|
||||
aWindow,
|
||||
aActive ?
|
||||
NS_LITERAL_STRING("activate") :
|
||||
NS_LITERAL_STRING("deactivate"),
|
||||
true, true, nullptr);
|
||||
|
||||
// Look for any remote child frames, iterate over them and send the activation notification.
|
||||
nsContentUtils::CallOnAllRemoteChildren(aWindow, ActivateOrDeactivateChild,
|
||||
|
|
Загрузка…
Ссылка в новой задаче