Bug 280220. General fixup for the way we expose links and named anhcors. r=pkw, sr=bz

This commit is contained in:
aaronleventhal%moonset.net 2005-01-30 01:31:50 +00:00
Родитель ed86fda23a
Коммит 85ea8bc25f
3 изменённых файлов: 44 добавлений и 94 удалений

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

@ -63,6 +63,7 @@ ACCESSIBILITY_ATOM(textFrame, "TextFrame")
// Alphabetical list of tag names
ACCESSIBILITY_ATOM(a, "a")
ACCESSIBILITY_ATOM(area, "area")
ACCESSIBILITY_ATOM(blockquote, "blockquote")
ACCESSIBILITY_ATOM(form, "form")
ACCESSIBILITY_ATOM(h1, "h1")
@ -84,6 +85,7 @@ ACCESSIBILITY_ATOM(accesskey, "accesskey")
ACCESSIBILITY_ATOM(control, "control")
ACCESSIBILITY_ATOM(_for, "for")
ACCESSIBILITY_ATOM(id, "id")
ACCESSIBILITY_ATOM(name, "name")
ACCESSIBILITY_ATOM(tabindex, "tabindex")
// DHTML accessibility attributes

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

@ -47,6 +47,7 @@
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsIServiceManager.h"
#include "nsIURI.h"
// ------------
// nsBlockAccessible
@ -193,19 +194,17 @@ NS_IMETHODIMP nsLinkableAccessible::GetState(PRUint32 *aState)
*aState |= orState;
}
}
if (!mLinkContent->IsFocusable()) {
*aState &= ~STATE_FOCUSABLE; // Links must have href or tabindex
}
}
if (!mLinkContent->IsFocusable()) {
*aState &= ~STATE_FOCUSABLE; // Links must have href or tabindex
}
else {
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
if (docAccessible) {
PRBool isEditable;
docAccessible->GetIsEditable(&isEditable);
if (isEditable) {
*aState &= ~(STATE_FOCUSED | STATE_FOCUSABLE); // Links not focusable in editor
}
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
if (docAccessible) {
PRBool isEditable;
docAccessible->GetIsEditable(&isEditable);
if (isEditable) {
*aState &= ~(STATE_FOCUSED | STATE_FOCUSABLE); // Links not focusable in editor
}
}
return NS_OK;
@ -296,15 +295,24 @@ PRBool nsLinkableAccessible::IsALink()
for (nsCOMPtr<nsIContent> walkUpContent(do_QueryInterface(mDOMNode));
walkUpContent;
walkUpContent = walkUpContent->GetParent()) {
nsCOMPtr<nsILink> link(do_QueryInterface(walkUpContent));
if (link) {
mLinkContent = walkUpContent;
mIsALinkCached = PR_TRUE;
nsLinkState linkState;
link->GetLinkState(linkState);
if (linkState == eLinkState_Visited)
mIsLinkVisited = PR_TRUE;
return PR_TRUE;
nsIAtom *tag = walkUpContent->Tag();
if ((tag == nsAccessibilityAtoms::a || nsAccessibilityAtoms::area)) {
// Currently we do not expose <link> tags, because they are not typically
// in <body> and rendered.
// We do not yet support xlinks
nsCOMPtr<nsILink> link = do_QueryInterface(walkUpContent);
NS_ASSERTION(link, "No nsILink for area or a");
nsCOMPtr<nsIURI> uri;
link->GetHrefURI(getter_AddRefs(uri));
if (uri) {
mLinkContent = walkUpContent;
mIsALinkCached = PR_TRUE;
nsLinkState linkState;
link->GetLinkState(linkState);
if (linkState == eLinkState_Visited)
mIsLinkVisited = PR_TRUE;
return PR_TRUE;
}
}
}
mIsALinkCached = PR_TRUE; // Cached that there is no link
@ -317,74 +325,3 @@ NS_IMETHODIMP nsLinkableAccessible::Shutdown()
return nsAccessibleWrap::Shutdown();
}
//----------------
// nsGenericAccessible
//----------------
nsGenericAccessible::nsGenericAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :
nsAccessibleWrap(aNode, aShell)
{
}
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
}
content->SetFocus(nsCOMPtr<nsPresContext>(GetPresContext()));
return NS_OK;
}
NS_IMETHODIMP nsGenericAccessible::GetRole(PRUint32 *aRole)
{
*aRole = ROLE_NOTHING;
return NS_OK;
}
NS_IMETHODIMP nsGenericAccessible::GetState(PRUint32 *aState)
{
// XXX todo: use DHTML state attribs to fill in accessible states
nsAccessible::GetState(aState);
return NS_OK;
}
NS_IMETHODIMP nsGenericAccessible::GetValue(nsAString& aValue)
{
// XXX todo: use value attrib or property to fill in accessible value
return NS_ERROR_NOT_IMPLEMENTED;
}
/* PRUint8 getAccNumActions (); */
NS_IMETHODIMP nsGenericAccessible::GetNumActions(PRUint8 *aNumActions)
{
// XXX todo: use XML events to fill in accessible actions
*aNumActions = 0;
return NS_OK;
}
/* wstring getAccActionName (in PRUint8 index); */
NS_IMETHODIMP nsGenericAccessible::GetActionName(PRUint8 index, nsAString& _retval)
{
// XXX todo: use XML events to fill in accessible actions
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void accDoAction (in PRUint8 index); */
NS_IMETHODIMP nsGenericAccessible::DoAction(PRUint8 index)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -37,6 +37,8 @@
* ***** END LICENSE BLOCK ***** */
#include "nsHTMLLinkAccessible.h"
#include "nsAccessibilityAtoms.h"
#include "nsINameSpaceManager.h"
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLLinkAccessible, nsLinkableAccessible)
@ -62,10 +64,19 @@ NS_IMETHODIMP nsHTMLLinkAccessible::GetRole(PRUint32 *_retval)
return NS_OK;
}
NS_IMETHODIMP nsHTMLLinkAccessible::GetState(PRUint32 *_retval)
NS_IMETHODIMP nsHTMLLinkAccessible::GetState(PRUint32 *aState)
{
nsLinkableAccessible::GetState(_retval);
*_retval &= ~(STATE_READONLY|STATE_SELECTABLE);
nsLinkableAccessible::GetState(aState);
*aState &= ~STATE_READONLY;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content && content->HasAttr(kNameSpaceID_None,
nsAccessibilityAtoms::name)) {
// This is how we indicate it is a named anchor
// In other words, this anchor can be selected as a location :)
// There is no other better state to use to indicate this.
*aState |= STATE_SELECTABLE;
}
return NS_OK;
}