Add command() method to nsIDOMXULElement, fixes bug 56137 and some other accessibility bugs (83614). r=kerz sr=ben a=asa

git-svn-id: svn://10.0.0.236/trunk@97531 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
blakeross%telocity.com 2001-06-20 02:02:57 +00:00
parent ee3bf62e44
commit e76bd70e30
4 changed files with 36 additions and 20 deletions

View File

@ -3727,14 +3727,6 @@ nsXULElement::GetRangeList(nsVoidArray*& aResult) const
//----------------------------------------------------------------------
// nsIDOMXULElement interface
NS_IMETHODIMP
nsXULElement::DoCommand()
{
return NS_OK;
}
NS_IMETHODIMP
nsXULElement::AddBroadcastListener(const nsAReadableString& attr,
nsIDOMElement* anElement)
@ -4439,8 +4431,6 @@ nsXULElement::Click()
PRInt32 numShells = doc->GetNumberOfShells();
nsCOMPtr<nsIPresShell> shell; // Strong
nsCOMPtr<nsIPresContext> context;
nsAutoString tagName;
PRBool isButton = NodeInfo()->Equals(NS_LITERAL_STRING("button"));
for (PRInt32 i=0; i<numShells; i++) {
shell = getter_AddRefs(doc->GetShellAt(i));
@ -4457,14 +4447,32 @@ nsXULElement::Click()
event.clickCount = 0;
event.widget = nsnull;
HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}
return NS_OK;
}
if (isButton) {
nsMouseEvent evt;
evt.eventStructType = NS_EVENT;
evt.message = NS_MENU_ACTION;
nsEventStatus sts = nsEventStatus_eIgnore;
HandleDOMEvent(context, &evt, nsnull, NS_EVENT_FLAG_INIT, &sts);
}
NS_IMETHODIMP
nsXULElement::Command()
{
nsCOMPtr<nsIDocument> doc;
GetDocument(*getter_AddRefs(doc));
if (doc) {
PRInt32 numShells = doc->GetNumberOfShells();
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIPresContext> context;
PRBool isButton = NodeInfo()->Equals(NS_LITERAL_STRING("button"));
for (PRInt32 i=0; i<numShells; i++) {
shell = getter_AddRefs(doc->GetShellAt(i));
shell->GetPresContext(getter_AddRefs(context));
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_MENU_ACTION;
HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}

View File

@ -50,11 +50,11 @@ interface nsIDOMXULElement : nsIDOMElement
in nsIDOMElement element);
void removeBroadcastListener(in DOMString attr,
in nsIDOMElement element);
void doCommand();
void focus();
void blur();
void click();
void command();
nsIDOMNodeList getElementsByAttribute(in DOMString name,
in DOMString value);

View File

@ -33,7 +33,14 @@
</implementation>
<handlers>
<handler event="click" button="0" action="if (!this.disabled) this.checked = !this.checked;"/>
<handler event="keypress" key=" " action="if (!this.disabled) this.checked = !this.checked;"/>
<handler event="keypress" key=" ">
<![CDATA[
if (!this.disabled) {
this.checked = !this.checked;
this.command();
}
]]>
</handler>
</handlers>
</binding>

View File

@ -120,6 +120,7 @@
break;
}
}
this.selectedItem.command();
]]>
</body>
</method>
@ -133,7 +134,7 @@
]]>
</handler>
<handler event="mousedown" button="0">
<![CDATA[
if (event.target.localName == "radio" && !event.target.disabled)