зеркало из https://github.com/mozilla/pjs.git
Bug 259385. Expose h1-h6, q, blockquote in MSAA as well as elements with a defined xhtml2:role attribute. r=pkw, sr=jst
This commit is contained in:
Родитель
1f6b488a6a
Коммит
aa771d370c
|
@ -294,8 +294,7 @@ interface nsIAccessible : nsISupports
|
|||
*
|
||||
* ROLE_TITLEBAR, ROLE_SOUND, ROLE_CURSOR, ROLE_CARET, ROLE_BORDER,
|
||||
* ROLE_GROUPING, ROLE_EQUATION, ROLE_COLUMN, ROLE_ROW, ROLE_LINK,
|
||||
* ROLE_WHITESPACE, ROLE_CLOCK,
|
||||
* ROLE_IPADDRESS
|
||||
* ROLE_WHITESPACE, ROLE_CLOCK, ROLE_IPADDRESS, ROLE_NOTHING
|
||||
*
|
||||
* ROLE_GRIP
|
||||
* The object represents a special mouse pointer, which allows a user to
|
||||
|
@ -414,7 +413,7 @@ interface nsIAccessible : nsISupports
|
|||
// directly adjacent to the button
|
||||
enum { ROLE_SPLITBUTTON = 42U }; // ATK_ROLE_PUSH_BUTTON
|
||||
enum { ROLE_IPADDRESS = 66U }; // ATK_ROLE_UNKNOWN
|
||||
enum { ROLE_NOTHING = 0U }; // ATK_ROLE_INVALID
|
||||
enum { ROLE_NOTHING = 66U }; // ATK_ROLE_UNKNOWN
|
||||
// Represent top level window
|
||||
enum { ROLE_FRAME = 22U }; // ATK_ROLE_FRAME
|
||||
|
||||
|
@ -523,6 +522,10 @@ interface nsIAccessible : nsISupports
|
|||
enum { ROLE_IPADDRESS = 63U };
|
||||
enum { ROLE_NOTHING = 4294967295U };
|
||||
|
||||
// Make up for ATK roles that we don't have in MSAA
|
||||
// When in doubt map them to ROLE_NOTHING so that the role string is exposed
|
||||
enum { ROLE_ICON = ROLE_NOTHING };
|
||||
enum { ROLE_PASSWORD_TEXT = ROLE_TEXT };
|
||||
#endif
|
||||
%}
|
||||
};
|
||||
|
|
|
@ -63,10 +63,18 @@ ACCESSIBILITY_ATOM(textFrame, "TextFrame")
|
|||
|
||||
// Alphabetical list of tag names
|
||||
ACCESSIBILITY_ATOM(a, "a")
|
||||
ACCESSIBILITY_ATOM(blockquote, "blockquote")
|
||||
ACCESSIBILITY_ATOM(h1, "h1")
|
||||
ACCESSIBILITY_ATOM(h2, "h2")
|
||||
ACCESSIBILITY_ATOM(h3, "h3")
|
||||
ACCESSIBILITY_ATOM(h4, "h4")
|
||||
ACCESSIBILITY_ATOM(h5, "h5")
|
||||
ACCESSIBILITY_ATOM(h6, "h6")
|
||||
ACCESSIBILITY_ATOM(label, "label")
|
||||
ACCESSIBILITY_ATOM(ol, "ol")
|
||||
ACCESSIBILITY_ATOM(optgroup, "optgroup")
|
||||
ACCESSIBILITY_ATOM(option, "option")
|
||||
ACCESSIBILITY_ATOM(q, "q")
|
||||
ACCESSIBILITY_ATOM(select, "select")
|
||||
ACCESSIBILITY_ATOM(ul, "ul")
|
||||
|
||||
|
@ -77,3 +85,4 @@ ACCESSIBILITY_ATOM(_for, "for")
|
|||
ACCESSIBILITY_ATOM(form, "form")
|
||||
ACCESSIBILITY_ATOM(id, "id")
|
||||
ACCESSIBILITY_ATOM(tabindex, "tabindex")
|
||||
ACCESSIBILITY_ATOM(role, "role")
|
||||
|
|
|
@ -448,15 +448,27 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsISupports *aFrame,
|
|||
*aAccessible = new nsHTMLLinkAccessible(node, weakShell, frame);
|
||||
}
|
||||
#endif
|
||||
else if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::tabindex)) {
|
||||
else if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::tabindex)
|
||||
#ifndef MOZ_ACCESSIBILITY_ATK
|
||||
||
|
||||
tag == nsAccessibilityAtoms::blockquote ||
|
||||
tag == nsAccessibilityAtoms::h1 ||
|
||||
tag == nsAccessibilityAtoms::h2 ||
|
||||
tag == nsAccessibilityAtoms::h3 ||
|
||||
tag == nsAccessibilityAtoms::h4 ||
|
||||
tag == nsAccessibilityAtoms::h5 ||
|
||||
tag == nsAccessibilityAtoms::h6
|
||||
#endif
|
||||
) {
|
||||
*aAccessible = new nsGenericAccessible(node, weakShell);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
nsAutoString role;
|
||||
if (content->GetAttr(kNameSpaceID_XHTML2_Unofficial, nsAccessibilityAtoms::role, role) == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
*aAccessible = new nsGenericAccessible(node, weakShell);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(aAccessible, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ADDREF(*aAccessible);
|
||||
NS_IF_ADDREF(*aAccessible);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,11 +37,13 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsBaseWidgetAccessible.h"
|
||||
#include "nsAccessibilityAtoms.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsAccessibleWrap.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -323,7 +325,7 @@ nsGenericAccessible::nsGenericAccessible(nsIDOMNode* aNode, nsIWeakReference* aS
|
|||
NS_IMPL_ISUPPORTS_INHERITED0(nsGenericAccessible, nsAccessible)
|
||||
|
||||
NS_IMETHODIMP nsGenericAccessible::TakeFocus()
|
||||
{
|
||||
{
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
if (!content || !mWeakShell) {
|
||||
return NS_ERROR_FAILURE; // Node already shut down
|
||||
|
@ -337,8 +339,24 @@ NS_IMETHODIMP nsGenericAccessible::TakeFocus()
|
|||
NS_IMETHODIMP nsGenericAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
// XXX todo: use DHTML role attribs to fill in accessible role
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE; // Node already shut down
|
||||
}
|
||||
|
||||
*aRole = ROLE_PANE;
|
||||
*aRole = ROLE_NOTHING;
|
||||
|
||||
nsAutoString role;
|
||||
if (content->GetAttr(kNameSpaceID_XHTML2_Unofficial, nsAccessibilityAtoms::role, role) != NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (role.EqualsLiteral("button")) {
|
||||
*aRole = ROLE_PUSHBUTTON;
|
||||
}
|
||||
else if (role.EqualsLiteral("checkbox")) {
|
||||
*aRole = ROLE_CHECKBUTTON;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -37,12 +37,15 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAccessibleWrap.h"
|
||||
#include "nsAccessibilityAtoms.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
#include "nsIAccessibleWin32Object.h"
|
||||
#include "nsArray.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
// for the COM IEnumVARIANT solution in get_AccSelection()
|
||||
#define _ATLBASE_IMPL
|
||||
|
@ -268,7 +271,6 @@ STDMETHODIMP nsAccessibleWrap::get_accRole(
|
|||
/* [retval][out] */ VARIANT __RPC_FAR *pvarRole)
|
||||
{
|
||||
VariantInit(pvarRole);
|
||||
pvarRole->vt = VT_I4;
|
||||
|
||||
nsCOMPtr<nsIAccessible> xpAccessible;
|
||||
GetXPAccessibleFor(varChild, getter_AddRefs(xpAccessible));
|
||||
|
@ -280,8 +282,44 @@ STDMETHODIMP nsAccessibleWrap::get_accRole(
|
|||
if (NS_FAILED(xpAccessible->GetRole(&role)))
|
||||
return E_FAIL;
|
||||
|
||||
pvarRole->lVal = role;
|
||||
return S_OK;
|
||||
// -- Try enumerated role
|
||||
if (role != ROLE_NOTHING) {
|
||||
pvarRole->vt = VT_I4;
|
||||
pvarRole->lVal = role; // Normal enumerated role
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// -- Try BSTR role
|
||||
// Could not map to known enumerated MSAA role like ROLE_BUTTON
|
||||
// Use BSTR role to expose role attribute or tag name + namespace
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(xpAccessible));
|
||||
NS_ASSERTION(accessNode, "No accessnode for accessible");
|
||||
accessNode->GetDOMNode(getter_AddRefs(domNode));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(domNode));
|
||||
NS_ASSERTION(content, "No content for accessible");
|
||||
if (content) {
|
||||
nsAutoString roleString;
|
||||
content->GetAttr(kNameSpaceID_XHTML2_Unofficial, nsAccessibilityAtoms::role, roleString);
|
||||
if (roleString.IsEmpty()) {
|
||||
nsINodeInfo *nodeInfo = content->GetNodeInfo();
|
||||
if (nodeInfo) {
|
||||
nodeInfo->GetName(roleString);
|
||||
nsAutoString nameSpaceURI;
|
||||
nodeInfo->GetNamespaceURI(nameSpaceURI);
|
||||
if (!nameSpaceURI.IsEmpty()) {
|
||||
// Only append name space if different from that of current document
|
||||
roleString += NS_LITERAL_STRING(", ") + nameSpaceURI;
|
||||
}
|
||||
if (!roleString.IsEmpty()) {
|
||||
pvarRole->vt = VT_BSTR;
|
||||
pvarRole->bstrVal = ::SysAllocString(roleString.get());
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
STDMETHODIMP nsAccessibleWrap::get_accState(
|
||||
|
|
|
@ -58,7 +58,8 @@ class nsINameSpace;
|
|||
#define kNameSpaceID_XUL 9
|
||||
#define kNameSpaceID_SVG 10
|
||||
#define kNameSpaceID_XMLEvents 11
|
||||
#define kNameSpaceID_LastBuiltin 11 // last 'built-in' namespace
|
||||
#define kNameSpaceID_XHTML2_Unofficial 12
|
||||
#define kNameSpaceID_LastBuiltin 12 // last 'built-in' namespace
|
||||
|
||||
#define NS_NAMESPACEMANAGER_CONTRACTID "@mozilla.org/content/namespacemanager;1"
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
|||
#define kXULNameSpaceURI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
#define kSVGNameSpaceURI "http://www.w3.org/2000/svg"
|
||||
#define kXMLEventsNameSpaceURI "http://www.w3.org/2001/xml-events"
|
||||
#define kXHTML2UnofficialNameSpaceURI "http://www.w3.org/TR/xhtml2" // Will eventually change
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Name Space
|
||||
|
@ -309,6 +310,7 @@ nsresult NameSpaceManagerImpl::Init()
|
|||
AddNameSpace(NS_LITERAL_STRING(kXULNameSpaceURI), kNameSpaceID_XUL);
|
||||
AddNameSpace(NS_LITERAL_STRING(kSVGNameSpaceURI), kNameSpaceID_SVG);
|
||||
AddNameSpace(NS_LITERAL_STRING(kXMLEventsNameSpaceURI), kNameSpaceID_XMLEvents);
|
||||
AddNameSpace(NS_LITERAL_STRING(kXHTML2UnofficialNameSpaceURI), kNameSpaceID_XHTML2_Unofficial);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче