mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 22:04:36 +00:00
Implement bindingDetached. r=ben
This commit is contained in:
parent
72b52d0663
commit
9948b2ece0
@ -70,6 +70,8 @@ public:
|
||||
NS_IMETHOD ClearAttachedQueue()=0;
|
||||
NS_IMETHOD ProcessAttachedQueue()=0;
|
||||
|
||||
NS_IMETHOD ExecuteDetachedHandlers()=0;
|
||||
|
||||
NS_IMETHOD PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo)=0;
|
||||
NS_IMETHOD GetXBLDocumentInfo(const nsCString& aURL, nsIXBLDocumentInfo** aResult)=0;
|
||||
|
||||
|
@ -205,6 +205,8 @@ public:
|
||||
NS_IMETHOD ClearAttachedQueue();
|
||||
NS_IMETHOD ProcessAttachedQueue();
|
||||
|
||||
NS_IMETHOD ExecuteDetachedHandlers();
|
||||
|
||||
NS_IMETHOD PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo);
|
||||
NS_IMETHOD GetXBLDocumentInfo(const nsCString& aURL, nsIXBLDocumentInfo** aResult);
|
||||
|
||||
@ -483,6 +485,23 @@ nsBindingManager::ProcessAttachedQueue()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool PR_CALLBACK ExecuteDetachedHandler(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
nsIXBLBinding* binding = (nsIXBLBinding*)aData;
|
||||
binding->ExecuteDetachedHandler();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::ExecuteDetachedHandlers()
|
||||
{
|
||||
// Walk our hashtable of bindings.
|
||||
if (mBindingTable)
|
||||
mBindingTable->Enumerate(ExecuteDetachedHandler);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo)
|
||||
{
|
||||
|
@ -196,6 +196,7 @@ nsIAtom* nsXBLBinding::kNameAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kReadOnlyAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kAttachToAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kBindingAttachedAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kBindingDetachedAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kInheritStyleAtom = nsnull;
|
||||
|
||||
nsIXBLService* nsXBLBinding::gXBLService = nsnull;
|
||||
@ -308,6 +309,7 @@ nsXBLBinding::nsXBLBinding(const nsCString& aDocURI, const nsCString& aID)
|
||||
kReadOnlyAtom = NS_NewAtom("readonly");
|
||||
kAttachToAtom = NS_NewAtom("attachto");
|
||||
kBindingAttachedAtom = NS_NewAtom("bindingattached");
|
||||
kBindingDetachedAtom = NS_NewAtom("bindingdetached");
|
||||
kInheritStyleAtom = NS_NewAtom("inheritstyle");
|
||||
|
||||
nsServiceManager::GetService("component://netscape/xbl",
|
||||
@ -602,7 +604,8 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement, nsIXBLBinding** aB
|
||||
PRBool found = PR_FALSE;
|
||||
PRBool special = PR_FALSE;
|
||||
nsCOMPtr<nsIAtom> eventAtom = getter_AddRefs(NS_NewAtom(type));
|
||||
if (eventAtom.get() == kBindingAttachedAtom) {
|
||||
if (eventAtom.get() == kBindingAttachedAtom ||
|
||||
eventAtom.get() == kBindingDetachedAtom) {
|
||||
*aBinding = this;
|
||||
NS_ADDREF(*aBinding);
|
||||
special = PR_TRUE;
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
static nsIAtom* kReadOnlyAtom;
|
||||
static nsIAtom* kAttachToAtom;
|
||||
static nsIAtom* kBindingAttachedAtom;
|
||||
static nsIAtom* kBindingDetachedAtom;
|
||||
static nsIAtom* kInheritStyleAtom;
|
||||
|
||||
static nsIXBLService* gXBLService;
|
||||
|
@ -155,7 +155,45 @@ nsXBLEventHandler::BindingAttached()
|
||||
NS_IMETHODIMP
|
||||
nsXBLEventHandler::BindingDetached()
|
||||
{
|
||||
// XXX Write me!!!!
|
||||
nsresult ret;
|
||||
if (mEventName == NS_LITERAL_STRING("bindingdetached")) {
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_MENU_ACTION;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
|
||||
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
||||
if (NS_FAILED(ret = mEventReceiver->GetListenerManager(getter_AddRefs(listenerManager)))) {
|
||||
NS_ERROR("Unable to instantiate a listener manager on this event.");
|
||||
return ret;
|
||||
}
|
||||
nsAutoString empty;
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
if (NS_FAILED(ret = listenerManager->CreateEvent(nsnull, &event, empty, getter_AddRefs(domEvent)))) {
|
||||
NS_ERROR("The binding attach handler will fail without the ability to create the event early.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// We need to explicitly set the target here, because the
|
||||
// DOM implementation will try to compute the target from
|
||||
// the frame. If we don't have a frame then that breaks.
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
|
||||
if (privateEvent) {
|
||||
privateEvent->SetTarget(mEventReceiver);
|
||||
}
|
||||
|
||||
ExecuteHandler(mEventName, domEvent);
|
||||
}
|
||||
|
||||
if (mNextHandler)
|
||||
return mNextHandler->BindingAttached();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,8 @@ public:
|
||||
NS_IMETHOD ClearAttachedQueue()=0;
|
||||
NS_IMETHOD ProcessAttachedQueue()=0;
|
||||
|
||||
NS_IMETHOD ExecuteDetachedHandlers()=0;
|
||||
|
||||
NS_IMETHOD PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo)=0;
|
||||
NS_IMETHOD GetXBLDocumentInfo(const nsCString& aURL, nsIXBLDocumentInfo** aResult)=0;
|
||||
|
||||
|
@ -205,6 +205,8 @@ public:
|
||||
NS_IMETHOD ClearAttachedQueue();
|
||||
NS_IMETHOD ProcessAttachedQueue();
|
||||
|
||||
NS_IMETHOD ExecuteDetachedHandlers();
|
||||
|
||||
NS_IMETHOD PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo);
|
||||
NS_IMETHOD GetXBLDocumentInfo(const nsCString& aURL, nsIXBLDocumentInfo** aResult);
|
||||
|
||||
@ -483,6 +485,23 @@ nsBindingManager::ProcessAttachedQueue()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool PR_CALLBACK ExecuteDetachedHandler(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
nsIXBLBinding* binding = (nsIXBLBinding*)aData;
|
||||
binding->ExecuteDetachedHandler();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::ExecuteDetachedHandlers()
|
||||
{
|
||||
// Walk our hashtable of bindings.
|
||||
if (mBindingTable)
|
||||
mBindingTable->Enumerate(ExecuteDetachedHandler);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo)
|
||||
{
|
||||
|
@ -196,6 +196,7 @@ nsIAtom* nsXBLBinding::kNameAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kReadOnlyAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kAttachToAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kBindingAttachedAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kBindingDetachedAtom = nsnull;
|
||||
nsIAtom* nsXBLBinding::kInheritStyleAtom = nsnull;
|
||||
|
||||
nsIXBLService* nsXBLBinding::gXBLService = nsnull;
|
||||
@ -308,6 +309,7 @@ nsXBLBinding::nsXBLBinding(const nsCString& aDocURI, const nsCString& aID)
|
||||
kReadOnlyAtom = NS_NewAtom("readonly");
|
||||
kAttachToAtom = NS_NewAtom("attachto");
|
||||
kBindingAttachedAtom = NS_NewAtom("bindingattached");
|
||||
kBindingDetachedAtom = NS_NewAtom("bindingdetached");
|
||||
kInheritStyleAtom = NS_NewAtom("inheritstyle");
|
||||
|
||||
nsServiceManager::GetService("component://netscape/xbl",
|
||||
@ -602,7 +604,8 @@ nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement, nsIXBLBinding** aB
|
||||
PRBool found = PR_FALSE;
|
||||
PRBool special = PR_FALSE;
|
||||
nsCOMPtr<nsIAtom> eventAtom = getter_AddRefs(NS_NewAtom(type));
|
||||
if (eventAtom.get() == kBindingAttachedAtom) {
|
||||
if (eventAtom.get() == kBindingAttachedAtom ||
|
||||
eventAtom.get() == kBindingDetachedAtom) {
|
||||
*aBinding = this;
|
||||
NS_ADDREF(*aBinding);
|
||||
special = PR_TRUE;
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
static nsIAtom* kReadOnlyAtom;
|
||||
static nsIAtom* kAttachToAtom;
|
||||
static nsIAtom* kBindingAttachedAtom;
|
||||
static nsIAtom* kBindingDetachedAtom;
|
||||
static nsIAtom* kInheritStyleAtom;
|
||||
|
||||
static nsIXBLService* gXBLService;
|
||||
|
@ -155,7 +155,45 @@ nsXBLEventHandler::BindingAttached()
|
||||
NS_IMETHODIMP
|
||||
nsXBLEventHandler::BindingDetached()
|
||||
{
|
||||
// XXX Write me!!!!
|
||||
nsresult ret;
|
||||
if (mEventName == NS_LITERAL_STRING("bindingdetached")) {
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_MENU_ACTION;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
|
||||
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
||||
if (NS_FAILED(ret = mEventReceiver->GetListenerManager(getter_AddRefs(listenerManager)))) {
|
||||
NS_ERROR("Unable to instantiate a listener manager on this event.");
|
||||
return ret;
|
||||
}
|
||||
nsAutoString empty;
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
if (NS_FAILED(ret = listenerManager->CreateEvent(nsnull, &event, empty, getter_AddRefs(domEvent)))) {
|
||||
NS_ERROR("The binding attach handler will fail without the ability to create the event early.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// We need to explicitly set the target here, because the
|
||||
// DOM implementation will try to compute the target from
|
||||
// the frame. If we don't have a frame then that breaks.
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
|
||||
if (privateEvent) {
|
||||
privateEvent->SetTarget(mEventReceiver);
|
||||
}
|
||||
|
||||
ExecuteHandler(mEventName, domEvent);
|
||||
}
|
||||
|
||||
if (mNextHandler)
|
||||
return mNextHandler->BindingAttached();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user