mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 706067 - Make takeFocus work on widget items, r=marcoz, tbsaunde
This commit is contained in:
parent
dcf8e4c27d
commit
aef288f412
@ -1066,7 +1066,6 @@ NS_IMETHODIMP nsAccessible::TakeSelection()
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* void takeFocus (); */
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAccessible::TakeFocus()
|
nsAccessible::TakeFocus()
|
||||||
{
|
{
|
||||||
@ -1078,30 +1077,16 @@ nsAccessible::TakeFocus()
|
|||||||
|
|
||||||
nsIContent* focusContent = mContent;
|
nsIContent* focusContent = mContent;
|
||||||
|
|
||||||
// If the current element can't take real DOM focus and if it has an ID and
|
// If the accessible focus is managed by container widget then focus the
|
||||||
// an ancestor with an aria-activedescendant attribute present, then set DOM
|
// widget and set the accessible as its current item.
|
||||||
// focus to that ancestor and set aria-activedescendant on the ancestor to
|
|
||||||
// the ID of the desired element.
|
|
||||||
if (!frame->IsFocusable()) {
|
if (!frame->IsFocusable()) {
|
||||||
nsAutoString id;
|
nsAccessible* widget = ContainerWidget();
|
||||||
if (nsCoreUtils::GetID(mContent, id)) {
|
if (widget && widget->AreItemsOperable()) {
|
||||||
|
nsIContent* widgetElm = widget->GetContent();
|
||||||
nsIContent* ancestorContent = mContent;
|
nsIFrame* widgetFrame = widgetElm->GetPrimaryFrame();
|
||||||
while ((ancestorContent = ancestorContent->GetParent()) &&
|
if (widgetFrame && widgetFrame->IsFocusable()) {
|
||||||
!ancestorContent->HasAttr(kNameSpaceID_None,
|
focusContent = widgetElm;
|
||||||
nsGkAtoms::aria_activedescendant));
|
widget->SetCurrentItem(this);
|
||||||
|
|
||||||
if (ancestorContent) {
|
|
||||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
|
|
||||||
if (presShell) {
|
|
||||||
nsIFrame *frame = ancestorContent->GetPrimaryFrame();
|
|
||||||
if (frame && frame->IsFocusable()) {
|
|
||||||
focusContent = ancestorContent;
|
|
||||||
focusContent->SetAttr(kNameSpaceID_None,
|
|
||||||
nsGkAtoms::aria_activedescendant,
|
|
||||||
id, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2937,6 +2922,18 @@ nsAccessible::CurrentItem()
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsAccessible::SetCurrentItem(nsAccessible* aItem)
|
||||||
|
{
|
||||||
|
nsIAtom* id = aItem->GetContent()->GetID();
|
||||||
|
if (id) {
|
||||||
|
nsAutoString idStr;
|
||||||
|
id->ToString(idStr);
|
||||||
|
mContent->SetAttr(kNameSpaceID_None,
|
||||||
|
nsGkAtoms::aria_activedescendant, idStr, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsAccessible*
|
nsAccessible*
|
||||||
nsAccessible::ContainerWidget() const
|
nsAccessible::ContainerWidget() const
|
||||||
{
|
{
|
||||||
|
@ -588,6 +588,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual nsAccessible* CurrentItem();
|
virtual nsAccessible* CurrentItem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current item of the widget.
|
||||||
|
*/
|
||||||
|
virtual void SetCurrentItem(nsAccessible* aItem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return container widget this accessible belongs to.
|
* Return container widget this accessible belongs to.
|
||||||
*/
|
*/
|
||||||
|
@ -151,6 +151,14 @@ nsHTMLSelectListAccessible::CurrentItem()
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsHTMLSelectListAccessible::SetCurrentItem(nsAccessible* aItem)
|
||||||
|
{
|
||||||
|
aItem->GetContent()->SetAttr(kNameSpaceID_None,
|
||||||
|
nsGkAtoms::selected, NS_LITERAL_STRING("true"),
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// nsHTMLSelectListAccessible: nsAccessible protected
|
// nsHTMLSelectListAccessible: nsAccessible protected
|
||||||
|
|
||||||
@ -686,6 +694,13 @@ nsHTMLComboboxAccessible::CurrentItem()
|
|||||||
return AreItemsOperable() ? mListAccessible->CurrentItem() : nsnull;
|
return AreItemsOperable() ? mListAccessible->CurrentItem() : nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsHTMLComboboxAccessible::SetCurrentItem(nsAccessible* aItem)
|
||||||
|
{
|
||||||
|
if (AreItemsOperable())
|
||||||
|
mListAccessible->SetCurrentItem(aItem);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// nsHTMLComboboxAccessible: protected
|
// nsHTMLComboboxAccessible: protected
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ public:
|
|||||||
virtual bool IsActiveWidget() const;
|
virtual bool IsActiveWidget() const;
|
||||||
virtual bool AreItemsOperable() const;
|
virtual bool AreItemsOperable() const;
|
||||||
virtual nsAccessible* CurrentItem();
|
virtual nsAccessible* CurrentItem();
|
||||||
|
virtual void SetCurrentItem(nsAccessible* aItem);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -209,6 +210,7 @@ public:
|
|||||||
virtual bool IsActiveWidget() const;
|
virtual bool IsActiveWidget() const;
|
||||||
virtual bool AreItemsOperable() const;
|
virtual bool AreItemsOperable() const;
|
||||||
virtual nsAccessible* CurrentItem();
|
virtual nsAccessible* CurrentItem();
|
||||||
|
virtual void SetCurrentItem(nsAccessible* aItem);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// nsAccessible
|
// nsAccessible
|
||||||
|
@ -302,6 +302,22 @@ nsXULSelectableAccessible::CurrentItem()
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsXULSelectableAccessible::SetCurrentItem(nsAccessible* aItem)
|
||||||
|
{
|
||||||
|
if (!mSelectControl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
|
||||||
|
do_QueryInterface(aItem->GetContent());
|
||||||
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSelectControl =
|
||||||
|
do_QueryInterface(mSelectControl);
|
||||||
|
if (multiSelectControl)
|
||||||
|
multiSelectControl->SetCurrentItem(itemElm);
|
||||||
|
else
|
||||||
|
mSelectControl->SetSelectedItem(itemElm);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// nsXULMenuitemAccessible
|
// nsXULMenuitemAccessible
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -893,3 +909,9 @@ nsXULMenubarAccessible::CurrentItem()
|
|||||||
}
|
}
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsXULMenubarAccessible::SetCurrentItem(nsAccessible* aItem)
|
||||||
|
{
|
||||||
|
NS_ERROR("nsXULMenubarAccessible::SetCurrentItem not implemented");
|
||||||
|
}
|
||||||
|
@ -67,6 +67,7 @@ public:
|
|||||||
|
|
||||||
// Widgets
|
// Widgets
|
||||||
virtual nsAccessible* CurrentItem();
|
virtual nsAccessible* CurrentItem();
|
||||||
|
virtual void SetCurrentItem(nsAccessible* aItem);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// nsIDOMXULMultiSelectControlElement inherits from this, so we'll always have
|
// nsIDOMXULMultiSelectControlElement inherits from this, so we'll always have
|
||||||
@ -170,6 +171,7 @@ public:
|
|||||||
virtual bool IsActiveWidget() const;
|
virtual bool IsActiveWidget() const;
|
||||||
virtual bool AreItemsOperable() const;
|
virtual bool AreItemsOperable() const;
|
||||||
virtual nsAccessible* CurrentItem();
|
virtual nsAccessible* CurrentItem();
|
||||||
|
virtual void SetCurrentItem(nsAccessible* aItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -279,6 +279,12 @@ nsXULTreeAccessible::CurrentItem()
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsXULTreeAccessible::SetCurrentItem(nsAccessible* aItem)
|
||||||
|
{
|
||||||
|
NS_ERROR("nsXULTreeAccessible::SetCurrentItem not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIArray>
|
already_AddRefed<nsIArray>
|
||||||
nsXULTreeAccessible::SelectedItems()
|
nsXULTreeAccessible::SelectedItems()
|
||||||
{
|
{
|
||||||
|
@ -106,6 +106,7 @@ public:
|
|||||||
virtual bool IsActiveWidget() const;
|
virtual bool IsActiveWidget() const;
|
||||||
virtual bool AreItemsOperable() const;
|
virtual bool AreItemsOperable() const;
|
||||||
virtual nsAccessible* CurrentItem();
|
virtual nsAccessible* CurrentItem();
|
||||||
|
virtual void SetCurrentItem(nsAccessible* aItem);
|
||||||
|
|
||||||
virtual nsAccessible* ContainerWidget() const;
|
virtual nsAccessible* ContainerWidget() const;
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ include $(topsrcdir)/config/rules.mk
|
|||||||
_TEST_FILES =\
|
_TEST_FILES =\
|
||||||
test_focusedChild.html \
|
test_focusedChild.html \
|
||||||
test_takeFocus.html \
|
test_takeFocus.html \
|
||||||
|
test_takeFocus.xul \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Test
|
// Invokers
|
||||||
|
|
||||||
var gQueue = null;
|
|
||||||
|
|
||||||
function takeFocusInvoker(aID)
|
function takeFocusInvoker(aID)
|
||||||
{
|
{
|
||||||
@ -39,6 +37,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Test
|
||||||
|
|
||||||
|
//gA11yEventDumpToConsole = true; // debug stuff
|
||||||
|
|
||||||
|
var gQueue = null;
|
||||||
function doTest()
|
function doTest()
|
||||||
{
|
{
|
||||||
gQueue = new eventQueue();
|
gQueue = new eventQueue();
|
||||||
@ -49,6 +53,7 @@
|
|||||||
gQueue.push(new takeFocusInvoker("item2"));
|
gQueue.push(new takeFocusInvoker("item2"));
|
||||||
gQueue.push(new takeFocusInvoker("plugin"));
|
gQueue.push(new takeFocusInvoker("plugin"));
|
||||||
gQueue.push(new takeFocusInvoker(document));
|
gQueue.push(new takeFocusInvoker(document));
|
||||||
|
gQueue.push(new takeFocusInvoker("lb_item2"));
|
||||||
|
|
||||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||||
}
|
}
|
||||||
@ -75,6 +80,11 @@
|
|||||||
title="No focus event fired on document when focus is set to the document while focused in a plugin">
|
title="No focus event fired on document when focus is set to the document while focused in a plugin">
|
||||||
Mozilla Bug 646361
|
Mozilla Bug 646361
|
||||||
</a>
|
</a>
|
||||||
|
<a target="_blank"
|
||||||
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=706067"
|
||||||
|
title="Make takeFocus work on widget items">
|
||||||
|
Mozilla Bug 706067
|
||||||
|
</a>
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
<div id="content" style="display: none"></div>
|
<div id="content" style="display: none"></div>
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
@ -92,5 +102,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<embed id="plugin" type="application/x-test" width="200" height="200" wmode="window"></embed>
|
<embed id="plugin" type="application/x-test" width="200" height="200" wmode="window"></embed>
|
||||||
|
|
||||||
|
<select id="listbox" size="5">
|
||||||
|
<option id="lb_item1">item1</option>
|
||||||
|
<option id="lb_item2">item2</option>
|
||||||
|
</select>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
125
accessible/tests/mochitest/focus/test_takeFocus.xul
Normal file
125
accessible/tests/mochitest/focus/test_takeFocus.xul
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||||
|
type="text/css"?>
|
||||||
|
|
||||||
|
<?xml-stylesheet href="chrome://browser/content/browser.css"
|
||||||
|
type="text/css"?>
|
||||||
|
|
||||||
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
|
title="Accessible focus testing">
|
||||||
|
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||||
|
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="../common.js" />
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="../states.js" />
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="../events.js" />
|
||||||
|
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="../treeview.js" />
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Invokers
|
||||||
|
|
||||||
|
function setTreeView(aTreeID, aView)
|
||||||
|
{
|
||||||
|
this.DOMNode = getNode(aTreeID);
|
||||||
|
|
||||||
|
this.eventSeq = [
|
||||||
|
new invokerChecker(EVENT_REORDER, this.DOMNode)
|
||||||
|
];
|
||||||
|
|
||||||
|
this.invoke = function setTreeView_invoke()
|
||||||
|
{
|
||||||
|
this.DOMNode.treeBoxObject.view = aView;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getID = function setTreeView_getID()
|
||||||
|
{ return "set tree view for " + prettyName(aTreeID); }
|
||||||
|
};
|
||||||
|
|
||||||
|
function takeFocusInvoker(aID, aArgConverterFunc)
|
||||||
|
{
|
||||||
|
this.targetFunc = aArgConverterFunc ? aArgConverterFunc : getAccessible;
|
||||||
|
|
||||||
|
this.eventSeq = [ new focusChecker(this.targetFunc, aID) ];
|
||||||
|
|
||||||
|
this.invoke = function takeFocusInvoker_invoke()
|
||||||
|
{
|
||||||
|
this.targetFunc.call(null, aID).takeFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getID = function takeFocusInvoker_getID()
|
||||||
|
{
|
||||||
|
return "takeFocus for " + prettyName(aID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLastChild(aID)
|
||||||
|
{
|
||||||
|
return getAccessible(aID).lastChild;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Tests
|
||||||
|
|
||||||
|
//gA11yEventDumpID = "eventdump"; // debug stuff
|
||||||
|
//gA11yEventDumpToConsole = true; // debug stuff
|
||||||
|
|
||||||
|
var gQueue = null;
|
||||||
|
function doTests()
|
||||||
|
{
|
||||||
|
// Test focus events.
|
||||||
|
gQueue = new eventQueue();
|
||||||
|
|
||||||
|
gQueue.push(new setTreeView("tree", new nsTableTreeView(5)));
|
||||||
|
gQueue.push(new takeFocusInvoker("tree", getLastChild));
|
||||||
|
gQueue.push(new takeFocusInvoker("listitem2"));
|
||||||
|
|
||||||
|
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
addA11yLoadEvent(doTests);
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<hbox flex="1" style="overflow: auto;">
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<a target="_blank"
|
||||||
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=706067"
|
||||||
|
title="Make takeFocus work on widget items">
|
||||||
|
Mozilla Bug 706067
|
||||||
|
</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none"></div>
|
||||||
|
<pre id="test">
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<vbox flex="1">
|
||||||
|
<tree id="tree" flex="1">
|
||||||
|
<treecols>
|
||||||
|
<treecol id="col1" flex="1" primary="true" label="column"/>
|
||||||
|
<treecol id="col2" flex="1" label="column 2"/>
|
||||||
|
</treecols>
|
||||||
|
<treechildren id="treechildren"/>
|
||||||
|
</tree>
|
||||||
|
|
||||||
|
<listbox id="listbox">
|
||||||
|
<listitem id="listitem1">item1</listitem>
|
||||||
|
<listitem id="listitem2">item2</listitem>
|
||||||
|
</listbox>
|
||||||
|
|
||||||
|
<vbox id="eventdump"/>
|
||||||
|
</vbox>
|
||||||
|
</hbox>
|
||||||
|
</window>
|
Loading…
Reference in New Issue
Block a user