mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
Dispatch a custom DOM event when the selected item is changed, needed for XBL dropdown lists. Bug 112713, r=jkeiser, sr=jst.
This commit is contained in:
parent
0f17dbccdc
commit
869a967c81
@ -64,6 +64,7 @@
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIBoxObject.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
|
||||
// PresState
|
||||
#include "nsVoidArray.h"
|
||||
@ -1326,8 +1327,23 @@ nsHTMLSelectElement::SetOptionsSelectedByIndex(PRInt32 aStartIndex,
|
||||
}
|
||||
|
||||
// Let the caller know whether anything was changed
|
||||
if (aChangedSomething && (optionsSelected || optionsDeselected)) {
|
||||
*aChangedSomething = PR_TRUE;
|
||||
if (optionsSelected || optionsDeselected) {
|
||||
if (aChangedSomething)
|
||||
*aChangedSomething = PR_TRUE;
|
||||
|
||||
// Dispatch an event to notify the subcontent that the selected item has changed
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
GetDocument(*getter_AddRefs(document));
|
||||
nsCOMPtr<nsIDOMDocumentEvent> domDoc = do_QueryInterface(document);
|
||||
if (domDoc) {
|
||||
nsCOMPtr<nsIDOMEvent> selectEvent;
|
||||
domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(selectEvent));
|
||||
selectEvent->InitEvent(NS_LITERAL_STRING("selectedItemChanged"),
|
||||
PR_TRUE, PR_TRUE);
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(NS_STATIC_CAST(nsIDOMNode*, this)));
|
||||
PRBool noDefault;
|
||||
target->DispatchEvent(selectEvent, &noDefault);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user