Bug 177451 [Active Accessibility] implement support for <toolbar>

r=aaronl, sr=jst
Bug 177453 [Active Accessibility] implement support for <hr>
r=aaronl, sr=jst
Bug 177646 [Active Accessibility] implement support for <tooltip>
r=aaronl, sr=jst
This commit is contained in:
kyle.yuan%sun.com 2002-11-06 01:29:58 +00:00
Родитель bca2d86078
Коммит b9d7d687c2
12 изменённых файлов: 242 добавлений и 21 удалений

Просмотреть файл

@ -62,6 +62,7 @@ interface nsIAccessibilityService : nsISupports
nsIAccessible createHTMLTableHeadAccessible(in nsIDOMNode aDOMNode);
nsIAccessible createHTMLTextAccessible(in nsISupports aFrame);
nsIAccessible createHTMLTextFieldAccessible(in nsISupports aFrame);
nsIAccessible createHTMLHRAccessible(in nsISupports aFrame);
nsIAccessible createXULButtonAccessible(in nsIDOMNode aNode);
nsIAccessible createXULCheckboxAccessible(in nsIDOMNode aNode);
@ -91,6 +92,9 @@ interface nsIAccessibilityService : nsISupports
nsIAccessible createXULTreeAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTreeColumnsAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTreeColumnitemAccessible(in nsIDOMNode aNode);
nsIAccessible createXULToolbarAccessible(in nsIDOMNode aNode);
nsIAccessible createXULToolbarSeparatorAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTooltipAccessible(in nsIDOMNode aNode);
nsIAccessible getAccessibleFor(in nsIDOMNode aNode);
};

Просмотреть файл

@ -834,6 +834,24 @@ nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports *aFrame, nsIAc
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLHRAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{
nsIFrame* frame;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIWeakReference> weakShell;
nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node));
if (NS_FAILED(rv))
return rv;
*_retval = new nsHTMLHRAccessible(node, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
return NS_OK;
}
/**
* XUL widget creation
* we can't ifdef this whole block because there is no way to exclude
@ -1307,6 +1325,57 @@ NS_IMETHODIMP nsAccessibilityService::CreateXULTabsAccessible(nsIDOMNode *aNode,
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::CreateXULToolbarAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
#ifdef MOZ_XUL
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsXULToolbarAccessible(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
#else
*_retval = nsnull;
#endif // MOZ_XUL
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::CreateXULToolbarSeparatorAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
#ifdef MOZ_XUL
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsXULToolbarSeparatorAccessible(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
#else
*_retval = nsnull;
#endif // MOZ_XUL
return NS_OK;
}
NS_IMETHODIMP nsAccessibilityService::CreateXULTooltipAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
#ifdef MOZ_XUL
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsXULTooltipAccessible(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
#else
*_retval = nsnull;
#endif // MOZ_XUL
return NS_OK;
}
/**
* We can have several cases here.
* 1) a text or html embedded document where the contentDocument

Просмотреть файл

@ -19,9 +19,10 @@
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Original Author: Eric Vaughan (evaughan@netscape.com)
* Contributor(s):
* Author: Eric Vaughan (evaughan@netscape.com)
*
* Aaron Leventhal (aaronl@netscape.com)
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -44,7 +45,6 @@ nsTextAccessible(aDomNode, aShell)
{
}
/* wstring getAccName (); */
NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(nsAString& _retval)
{
nsAutoString accName;
@ -54,3 +54,21 @@ NS_IMETHODIMP nsHTMLTextAccessible::GetAccName(nsAString& _retval)
_retval = accName;
return NS_OK;
}
nsHTMLHRAccessible::nsHTMLHRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsLeafAccessible(aDomNode, aShell)
{
}
NS_IMETHODIMP nsHTMLHRAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_SEPARATOR;
return NS_OK;
}
NS_IMETHODIMP nsHTMLHRAccessible::GetAccState(PRUint32 *_retval)
{
nsLeafAccessible::GetAccState(_retval);
*_retval &= ~STATE_FOCUSABLE;
return NS_OK;
}

Просмотреть файл

@ -20,7 +20,8 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Aaron Leventhal (aaronl@netscape.com)
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -51,4 +52,13 @@ public:
NS_IMETHOD GetAccName(nsAString& _retval);
};
class nsHTMLHRAccessible : public nsLeafAccessible
{
public:
nsHTMLHRAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
#endif

Просмотреть файл

@ -19,9 +19,10 @@
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Original Author: John Gaunt (jgaunt@netscape.com)
* Contributor(s):
* Author: John Gaunt (jgaunt@netscape.com)
*
* Aaron Leventhal (aaronl@netscape.com)
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -638,3 +639,46 @@ NS_IMETHODIMP nsXULStatusBarAccessible::GetAccState(PRUint32 *_retval)
*_retval = 0; // no special state flags for status bar
return NS_OK;
}
/**
* XUL ToolBar
*/
nsXULToolbarAccessible::nsXULToolbarAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsAccessible(aNode, aShell)
{
}
NS_IMETHODIMP nsXULToolbarAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_TOOLBAR;
return NS_OK;
}
NS_IMETHODIMP nsXULToolbarAccessible::GetAccState(PRUint32 *_retval)
{
nsAccessible::GetAccState(_retval);
*_retval &= ~STATE_FOCUSABLE; // toolbar is not focusable
return NS_OK;
}
/**
* XUL Toolbar Separator
*/
nsXULToolbarSeparatorAccessible::nsXULToolbarSeparatorAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsLeafAccessible(aNode, aShell)
{
}
NS_IMETHODIMP nsXULToolbarSeparatorAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_SEPARATOR;
return NS_OK;
}
NS_IMETHODIMP nsXULToolbarSeparatorAccessible::GetAccState(PRUint32 *_retval)
{
*_retval = 0; // no special state flags for toolbar separator
return NS_OK;
}

Просмотреть файл

@ -19,9 +19,10 @@
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Original Author: John Gaunt (jgaunt@netscape.com)
* Contributor(s):
* Author: John Gaunt (jgaunt@netscape.com)
*
* Aaron Leventhal (aaronl@netscape.com)
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -135,5 +136,21 @@ public:
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
class nsXULToolbarAccessible : public nsAccessible
{
public:
nsXULToolbarAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
class nsXULToolbarSeparatorAccessible : public nsLeafAccessible
{
public:
nsXULToolbarSeparatorAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
#endif

Просмотреть файл

@ -19,9 +19,10 @@
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Original Author: John Gaunt (jgaunt@netscape.com)
* Contributor(s):
* Author: John Gaunt (jgaunt@netscape.com)
*
* Aaron Leventhal (aaronl@netscape.com)
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -68,3 +69,32 @@ NS_IMETHODIMP nsXULTextAccessible::GetAccState(PRUint32 *_retval)
*_retval = STATE_READONLY;
return NS_OK;
}
/**
* For XUL tooltip
*/
nsXULTooltipAccessible::nsXULTooltipAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsLeafAccessible(aDomNode, aShell)
{
}
NS_IMETHODIMP nsXULTooltipAccessible::GetAccName(nsAString& _retval)
{
//XXX, kyle.yuan@sun.com, we don't know how to get at this information at the moment,
// because it is not loaded until it shows.
return NS_OK;
}
NS_IMETHODIMP nsXULTooltipAccessible::GetAccState(PRUint32 *_retval)
{
nsLeafAccessible::GetAccState(_retval);
*_retval &= ~STATE_FOCUSABLE;
*_retval |= STATE_READONLY;
return NS_OK;
}
NS_IMETHODIMP nsXULTooltipAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_TOOLTIP;
return NS_OK;
}

Просмотреть файл

@ -19,9 +19,10 @@
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Original Author: John Gaunt (jgaunt@netscape.com)
* Contributor(s):
* Author: John Gaunt (jgaunt@netscape.com)
*
* Aaron Leventhal (aaronl@netscape.com)
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -53,4 +54,14 @@ public:
NS_IMETHOD GetAccState(PRUint32 *_retval);
};
class nsXULTooltipAccessible : public nsLeafAccessible
{
public:
nsXULTooltipAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccName(nsAString& _retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
};
#endif

Просмотреть файл

@ -895,15 +895,17 @@ NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible)
*aAccessible = nsnull;
nsCOMPtr<nsIAtom> tagAtom;
mContent->GetTag(*getter_AddRefs(tagAtom));
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input) {
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input || tagAtom == nsHTMLAtoms::hr) {
// Only get accessibility service if we're going to use it
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
if (!accService)
return NS_ERROR_FAILURE;
if (tagAtom == nsHTMLAtoms::input) // Broken <input type=image ... />
return accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
// Create accessible for broken <img>
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
else if (tagAtom == nsHTMLAtoms::img) // Create accessible for broken <img>
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
// Create accessible for <hr>
return accService->CreateHTMLHRAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
}
return NS_ERROR_FAILURE;

Просмотреть файл

@ -895,15 +895,17 @@ NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible)
*aAccessible = nsnull;
nsCOMPtr<nsIAtom> tagAtom;
mContent->GetTag(*getter_AddRefs(tagAtom));
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input) {
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input || tagAtom == nsHTMLAtoms::hr) {
// Only get accessibility service if we're going to use it
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
if (!accService)
return NS_ERROR_FAILURE;
if (tagAtom == nsHTMLAtoms::input) // Broken <input type=image ... />
return accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
// Create accessible for broken <img>
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
else if (tagAtom == nsHTMLAtoms::img) // Create accessible for broken <img>
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
// Create accessible for <hr>
return accService->CreateHTMLHRAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
}
return NS_ERROR_FAILURE;

Просмотреть файл

@ -22,10 +22,11 @@
<property name="accessible">
<getter>
<![CDATA[
if (this.localName == "popup" || this.localName == "menupopup") {
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
if (this.localName == "popup" || this.localName == "menupopup")
return (this.parentNode.localName == "menulist")? accService.createXULSelectListAccessible(this): accService.createXULMenupopupAccessible(this);
}
else if (this.localName == "tooltip")
return accService.createXULTooltipAccessible(this);
return null;
]]>
</getter>

Просмотреть файл

@ -9,6 +9,19 @@
<resources>
<stylesheet src="chrome://global/skin/toolbar.css"/>
</resources>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
if (this.localName == "toolbarseparator")
return accService.createXULToolbarSeparatorAccessible(this);
else
return accService.createXULToolbarAccessible(this);
]]>
</getter>
</property>
</implementation>
</binding>
<binding id="toolbar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">