void nsFormFillController::RemoveWindowListeners(nsIDOMWindow *aWindow) { if (!aWindow) return; StopControllingInput(); nsCOMPtr<nsIDOMDocument> domDoc; aWindow->GetDocument(getter_AddRefs(domDoc)); mPwmgrInputs.Enumerate(RemoveForDOMDocumentEnumerator, domDoc); nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow)); nsIDOMEventTarget* target = nsnull; if (privateDOMWindow) target = privateDOMWindow->GetChromeEventHandler(); if (!target) return; target->RemoveEventListener(NS_LITERAL_STRING("focus"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("blur"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("pagehide"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("mousedown"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("input"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("compositionstart"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("compositionend"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("contextmenu"), this, true); }
void nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow) { if (!aWindow) return; nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow)); nsIDOMEventTarget* target = nsnull; if (privateDOMWindow) target = privateDOMWindow->GetChromeEventHandler(); if (!target) return; target->AddEventListener(NS_LITERAL_STRING("focus"), this, true, false); target->AddEventListener(NS_LITERAL_STRING("blur"), this, true, false); target->AddEventListener(NS_LITERAL_STRING("pagehide"), this, true, false); target->AddEventListener(NS_LITERAL_STRING("mousedown"), this, true, false); target->AddEventListener(NS_LITERAL_STRING("input"), this, true, false); target->AddEventListener(NS_LITERAL_STRING("compositionstart"), this, true, false); target->AddEventListener(NS_LITERAL_STRING("compositionend"), this, true, false); target->AddEventListener(NS_LITERAL_STRING("contextmenu"), this, true, false); // Note that any additional listeners added should ensure that they ignore // untrusted events, which might be sent by content that's up to no good. }
void nsFormFillController::RemoveWindowListeners(nsIDOMWindow *aWindow) { if (!aWindow) return; StopControllingInput(); nsCOMPtr<nsIDOMDocument> domDoc; aWindow->GetDocument(getter_AddRefs(domDoc)); mPwmgrInputs.Enumerate(RemoveForDOMDocumentEnumerator, domDoc); nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow)); nsPIDOMEventTarget* chromeEventHandler = nsnull; if (privateDOMWindow) chromeEventHandler = privateDOMWindow->GetChromeEventHandler(); nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(chromeEventHandler)); if (!target) return; target->RemoveEventListener(NS_LITERAL_STRING("focus"), static_cast<nsIDOMFocusListener *>(this), PR_TRUE); target->RemoveEventListener(NS_LITERAL_STRING("blur"), static_cast<nsIDOMFocusListener *>(this), PR_TRUE); target->RemoveEventListener(NS_LITERAL_STRING("pagehide"), static_cast<nsIDOMFocusListener *>(this), PR_TRUE); target->RemoveEventListener(NS_LITERAL_STRING("mousedown"), static_cast<nsIDOMMouseListener *>(this), PR_TRUE); target->RemoveEventListener(NS_LITERAL_STRING("click"), static_cast<nsIDOMMouseListener *>(this), PR_TRUE); target->RemoveEventListener(NS_LITERAL_STRING("input"), static_cast<nsIDOMFormListener *>(this), PR_TRUE); target->RemoveEventListener(NS_LITERAL_STRING("compositionstart"), static_cast<nsIDOMCompositionListener *>(this), PR_TRUE); target->RemoveEventListener(NS_LITERAL_STRING("compositionend"), static_cast<nsIDOMCompositionListener *>(this), PR_TRUE); target->RemoveEventListener(NS_LITERAL_STRING("contextmenu"), static_cast<nsIDOMContextMenuListener *>(this), PR_TRUE); }
void nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow) { if (!aWindow) return; nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow)); nsPIDOMEventTarget* chromeEventHandler = nsnull; if (privateDOMWindow) chromeEventHandler = privateDOMWindow->GetChromeEventHandler(); nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(chromeEventHandler)); if (!target) return; target->AddEventListener(NS_LITERAL_STRING("focus"), static_cast<nsIDOMFocusListener *>(this), PR_TRUE); target->AddEventListener(NS_LITERAL_STRING("blur"), static_cast<nsIDOMFocusListener *>(this), PR_TRUE); target->AddEventListener(NS_LITERAL_STRING("pagehide"), static_cast<nsIDOMFocusListener *>(this), PR_TRUE); target->AddEventListener(NS_LITERAL_STRING("mousedown"), static_cast<nsIDOMMouseListener *>(this), PR_TRUE); target->AddEventListener(NS_LITERAL_STRING("click"), static_cast<nsIDOMMouseListener *>(this), PR_TRUE); target->AddEventListener(NS_LITERAL_STRING("input"), static_cast<nsIDOMFormListener *>(this), PR_TRUE); target->AddEventListener(NS_LITERAL_STRING("compositionstart"), static_cast<nsIDOMCompositionListener *>(this), PR_TRUE); target->AddEventListener(NS_LITERAL_STRING("compositionend"), static_cast<nsIDOMCompositionListener *>(this), PR_TRUE); target->AddEventListener(NS_LITERAL_STRING("contextmenu"), static_cast<nsIDOMContextMenuListener *>(this), PR_TRUE); // Note that any additional listeners added should ensure that they ignore // untrusted events, which might be sent by content that's up to no good. }
void nsWidgetUtils::GetChromeEventHandler(nsIDOMWindow *aDOMWin, nsIDOMEventTarget **aChromeTarget) { nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aDOMWin)); nsIDOMEventTarget* chromeEventHandler = nullptr; if (privateDOMWindow) { chromeEventHandler = privateDOMWindow->GetChromeEventHandler(); } NS_IF_ADDREF(*aChromeTarget = chromeEventHandler); }