Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
nsPLDOMEvent Struct Reference

Use nsPLDOMEvent to fire a DOM event that requires safe a stable DOM. More...

#include <nsPLDOMEvent.h>

Inheritance diagram for nsPLDOMEvent:
Inheritance graph
[legend]
Collaboration diagram for nsPLDOMEvent:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsPLDOMEvent (nsIDOMNode *aEventNode, const nsAString &aEventType)
void HandleEvent ()
nsresult PostDOMEvent ()

Public Attributes

nsCOMPtr< nsIDOMNodemEventNode
nsString mEventType
PRCList link
PLHandleEventProc handler
PLDestroyEventProc destructor
voidowner
voidsynchronousResult
PRLocklock
PRCondVarcondVar
PRBool handled

Detailed Description

Use nsPLDOMEvent to fire a DOM event that requires safe a stable DOM.

For example, you may need to fire an event from within layout, but want to ensure that the event handler doesn't mutate the DOM at the wrong time, in order to avoid resulting instability.

Definition at line 52 of file nsPLDOMEvent.h.


Constructor & Destructor Documentation

nsPLDOMEvent::nsPLDOMEvent ( nsIDOMNode aEventNode,
const nsAString &  aEventType 
) [inline]

Definition at line 53 of file nsPLDOMEvent.h.

    : mEventNode(aEventNode), mEventType(aEventType)
  { }

Member Function Documentation

Definition at line 46 of file nsPLDOMEvent.cpp.

{
  if (!mEventNode) {
    return;
  }
  
  nsCOMPtr<nsIDOMDocument> domDoc;
  mEventNode->GetOwnerDocument(getter_AddRefs(domDoc));
  nsCOMPtr<nsIDOMDocumentEvent> domEventDoc = do_QueryInterface(domDoc);
  if (domEventDoc) {
    nsCOMPtr<nsIDOMEvent> domEvent;
    domEventDoc->CreateEvent(NS_LITERAL_STRING("Events"),
                        getter_AddRefs(domEvent));

    nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(domEvent));
    if (privateEvent && NS_SUCCEEDED(domEvent->InitEvent(mEventType, PR_TRUE, PR_TRUE))) {
      privateEvent->SetTrusted(PR_TRUE);

      nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(mEventNode);
      PRBool defaultActionEnabled; // This is not used because the caller is async
      target->DispatchEvent(domEvent, &defaultActionEnabled);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 71 of file nsPLDOMEvent.cpp.

{
  nsCOMPtr<nsIEventQueue> eventQueue;
  nsresult rv = NS_GetCurrentEventQ(getter_AddRefs(eventQueue));
  if (NS_SUCCEEDED(rv)) {
    PL_InitEvent(this, nsnull, (PLHandleEventProc) ::HandlePLDOMEvent, (PLDestroyEventProc) ::DestroyPLDOMEvent);
    rv = eventQueue->PostEvent(this);
  }

  return rv;
}

Here is the call graph for this function:


Member Data Documentation

PRCondVar * PLEvent::condVar [inherited]

Definition at line 514 of file nsIEventQueueService.idl.

Definition at line 510 of file nsIEventQueueService.idl.

PRBool PLEvent::handled [inherited]

Definition at line 515 of file nsIEventQueueService.idl.

Definition at line 509 of file nsIEventQueueService.idl.

PRCList PLEvent::link [inherited]

Definition at line 508 of file nsIEventQueueService.idl.

PRLock * PLEvent::lock [inherited]

Definition at line 513 of file nsIEventQueueService.idl.

Definition at line 60 of file nsPLDOMEvent.h.

Definition at line 61 of file nsPLDOMEvent.h.

void * PLEvent::owner [inherited]

Definition at line 511 of file nsIEventQueueService.idl.

Definition at line 512 of file nsIEventQueueService.idl.


The documentation for this struct was generated from the following files: