mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
Make generic DOM datanodes implement GetBindingParent in a semi-useful way so
that event retargeting works (bug 97634, bug 183878). Also remove some code that's no longer needed now that we have retargeting. r=bryner, sr=jst
This commit is contained in:
parent
bd6e613fb1
commit
c238e33fe5
@ -1007,7 +1007,8 @@ nsGenericDOMDataNode::RemoveFocus(nsIPresContext* aPresContext)
|
||||
NS_IMETHODIMP_(nsIContent*)
|
||||
nsGenericDOMDataNode::GetBindingParent() const
|
||||
{
|
||||
return nsnull;
|
||||
nsIContent* parent = GetParent();
|
||||
return parent ? parent->GetBindingParent() : nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1428,54 +1428,6 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
// If we're a file input we have anonymous content underneath
|
||||
// that we need to hide. We need to set the event target now
|
||||
// to ourselves and the original target to the previous target.
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> oldTarget;
|
||||
if (mType == NS_FORM_INPUT_FILE || mType == NS_FORM_INPUT_TEXT ) {
|
||||
// If the event is starting here that's fine. If it's not
|
||||
// init'ing here it started beneath us and needs modification.
|
||||
// XXX This happens twice (unnecessarily) since there is both a capture
|
||||
// and a bubble stage.
|
||||
if (!(NS_EVENT_FLAG_INIT & aFlags)) {
|
||||
// Create the DOM event.
|
||||
if (!*aDOMEvent) {
|
||||
// We haven't made a DOMEvent yet. Force making one now.
|
||||
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
||||
rv = GetListenerManager(getter_AddRefs(listenerManager));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString empty;
|
||||
rv = listenerManager->CreateEvent(aPresContext, aEvent, empty,
|
||||
aDOMEvent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// See if there is an original target already. If not, set it to the
|
||||
// current event target.
|
||||
nsCOMPtr<nsIDOMEventTarget> originalTarget;
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(*aDOMEvent));
|
||||
if (nsevent) {
|
||||
nsevent->GetOriginalTarget(getter_AddRefs(originalTarget));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(*aDOMEvent));
|
||||
NS_ENSURE_TRUE(privateEvent, NS_ERROR_FAILURE);
|
||||
|
||||
(*aDOMEvent)->GetTarget(getter_AddRefs(oldTarget));
|
||||
if (!originalTarget) {
|
||||
privateEvent->SetOriginalTarget(oldTarget);
|
||||
}
|
||||
|
||||
// Set the target to us now.
|
||||
nsCOMPtr<nsIDOMEventTarget>
|
||||
target(do_QueryInterface((nsIDOMHTMLInputElement*)this));
|
||||
|
||||
privateEvent->SetTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Web pages expect the value of a radio button or checkbox to be set
|
||||
// *before* onclick fires, and they expect that if they set the value
|
||||
@ -1609,26 +1561,6 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
// Finish the special file control processing...
|
||||
if (oldTarget) {
|
||||
// If the event is starting here that's fine. If it's not
|
||||
// init'ing here it started beneath us and needs modification.
|
||||
if (!(NS_EVENT_FLAG_INIT & aFlags)) {
|
||||
if (!*aDOMEvent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent =
|
||||
do_QueryInterface(*aDOMEvent);
|
||||
|
||||
if (!privateEvent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// This will reset the target to its original value
|
||||
privateEvent->SetTarget(oldTarget);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
!(aFlags & NS_EVENT_FLAG_CAPTURE) &&
|
||||
!(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
|
||||
|
@ -696,48 +696,6 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We have anonymous content underneath
|
||||
// that we need to hide. We need to set the event target now
|
||||
// to ourselves
|
||||
|
||||
// If the event is starting here that's fine. If it's not
|
||||
// init'ing here it started beneath us and needs modification.
|
||||
if (!(NS_EVENT_FLAG_INIT & aFlags)) {
|
||||
if (!*aDOMEvent) {
|
||||
// We haven't made a DOMEvent yet. Force making one now.
|
||||
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
||||
|
||||
rv = GetListenerManager(getter_AddRefs(listenerManager));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString empty;
|
||||
|
||||
rv = listenerManager->CreateEvent(aPresContext, aEvent, empty,
|
||||
aDOMEvent);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!*aDOMEvent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(*aDOMEvent));
|
||||
|
||||
if (!privateEvent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIDOMHTMLTextAreaElement *, this)));
|
||||
|
||||
privateEvent->SetTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
// If NS_EVENT_FLAG_NO_CONTENT_DISPATCH is set we will not allow content to handle
|
||||
// this event. But to allow middle mouse button paste to work we must allow
|
||||
// middle clicks to go to text fields anyway.
|
||||
@ -761,23 +719,6 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
// Reset the flag for other content besides this text field
|
||||
aEvent->flags |= noContentDispatch ? NS_EVENT_FLAG_NO_CONTENT_DISPATCH : NS_EVENT_FLAG_NONE;
|
||||
|
||||
// Finish the special anonymous content processing...
|
||||
// If the event is starting here that's fine. If it's not
|
||||
// init'ing here it started beneath us and needs modification.
|
||||
if (!(NS_EVENT_FLAG_INIT & aFlags)) {
|
||||
if (!*aDOMEvent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
|
||||
if (!privateEvent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// This will reset the target to its original value
|
||||
privateEvent->SetTarget(nsnull);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user