зеркало из https://github.com/mozilla/pjs.git
Bug 377783. Fix crash and clean up table a11y. r=evan.yan
This commit is contained in:
Родитель
ce9670fdd7
Коммит
f2b6379f0f
|
@ -45,7 +45,7 @@ interface nsIFrame;
|
||||||
interface nsObjectFrame;
|
interface nsObjectFrame;
|
||||||
interface nsIContent;
|
interface nsIContent;
|
||||||
|
|
||||||
[uuid(e4cdb7c5-d029-4bee-bff5-99455c6e0057)]
|
[uuid(0e9e2f00-b6f1-440d-821f-6b09d264cdaf)]
|
||||||
interface nsIAccessibilityService : nsIAccessibleRetrieval
|
interface nsIAccessibilityService : nsIAccessibleRetrieval
|
||||||
{
|
{
|
||||||
nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode);
|
nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode);
|
||||||
|
@ -74,6 +74,7 @@ interface nsIAccessibilityService : nsIAccessibleRetrieval
|
||||||
nsIAccessible createHTMLTableHeadAccessible(in nsIDOMNode aDOMNode);
|
nsIAccessible createHTMLTableHeadAccessible(in nsIDOMNode aDOMNode);
|
||||||
nsIAccessible createHTMLTextAccessible(in nsISupports aFrame);
|
nsIAccessible createHTMLTextAccessible(in nsISupports aFrame);
|
||||||
nsIAccessible createHTMLTextFieldAccessible(in nsISupports aFrame);
|
nsIAccessible createHTMLTextFieldAccessible(in nsISupports aFrame);
|
||||||
|
nsIAccessible createHTMLCaptionAccessible(in nsISupports aFrame);
|
||||||
|
|
||||||
nsIAccessible getAccessible(in nsIDOMNode aNode, in nsIPresShell aPresShell,
|
nsIAccessible getAccessible(in nsIDOMNode aNode, in nsIPresShell aPresShell,
|
||||||
in nsIWeakReference aWeakShell,
|
in nsIWeakReference aWeakShell,
|
||||||
|
|
|
@ -43,11 +43,11 @@
|
||||||
|
|
||||||
interface nsIAccessible;
|
interface nsIAccessible;
|
||||||
|
|
||||||
[scriptable, uuid(a776fee4-c0b8-4872-9e1e-72017243383f)]
|
[scriptable, uuid(dc13d184-a6df-45a1-92f0-5476fdaebc5a)]
|
||||||
interface nsIAccessibleTable : nsISupports
|
interface nsIAccessibleTable : nsISupports
|
||||||
{
|
{
|
||||||
attribute nsIAccessible caption;
|
readonly attribute nsIAccessible caption;
|
||||||
attribute AString summary;
|
readonly attribute AString summary;
|
||||||
readonly attribute long columns;
|
readonly attribute long columns;
|
||||||
readonly attribute nsIAccessibleTable columnHeader;
|
readonly attribute nsIAccessibleTable columnHeader;
|
||||||
readonly attribute long rows;
|
readonly attribute long rows;
|
||||||
|
|
|
@ -50,7 +50,6 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeAccessibleWrap, nsXULTreeAccessible, nsIAc
|
||||||
nsXULTreeAccessibleWrap::nsXULTreeAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
|
nsXULTreeAccessibleWrap::nsXULTreeAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
|
||||||
nsXULTreeAccessible(aDOMNode, aShell)
|
nsXULTreeAccessible(aDOMNode, aShell)
|
||||||
{
|
{
|
||||||
mCaption = nsnull;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tree's children count is row count * col count + treecols count
|
// tree's children count is row count * col count + treecols count
|
||||||
|
@ -78,26 +77,13 @@ NS_IMETHODIMP nsXULTreeAccessibleWrap::GetChildCount(PRInt32 *aAccChildCount)
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULTreeAccessibleWrap::GetCaption(nsIAccessible **aCaption)
|
NS_IMETHODIMP nsXULTreeAccessibleWrap::GetCaption(nsIAccessible **aCaption)
|
||||||
{
|
{
|
||||||
*aCaption = mCaption;
|
*aCaption = nsnull;
|
||||||
NS_IF_ADDREF(*aCaption);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULTreeAccessibleWrap::SetCaption(nsIAccessible *aCaption)
|
|
||||||
{
|
|
||||||
mCaption = aCaption;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULTreeAccessibleWrap::GetSummary(nsAString &aSummary)
|
NS_IMETHODIMP nsXULTreeAccessibleWrap::GetSummary(nsAString &aSummary)
|
||||||
{
|
{
|
||||||
aSummary = mSummary;
|
aSummary.Truncate();
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULTreeAccessibleWrap::SetSummary(const nsAString &aSummary)
|
|
||||||
{
|
|
||||||
mSummary = aSummary;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,32 +412,17 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeColumnsAccessibleWrap, nsXULTreeColumnsAcc
|
||||||
nsXULTreeColumnsAccessibleWrap::nsXULTreeColumnsAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
|
nsXULTreeColumnsAccessibleWrap::nsXULTreeColumnsAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
|
||||||
nsXULTreeColumnsAccessible(aDOMNode, aShell)
|
nsXULTreeColumnsAccessible(aDOMNode, aShell)
|
||||||
{
|
{
|
||||||
mCaption = nsnull;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetCaption(nsIAccessible **aCaption)
|
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetCaption(nsIAccessible **aCaption)
|
||||||
{
|
{
|
||||||
*aCaption = mCaption;
|
*aCaption = nsnull;
|
||||||
NS_IF_ADDREF(*aCaption);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::SetCaption(nsIAccessible *aCaption)
|
|
||||||
{
|
|
||||||
mCaption = aCaption;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetSummary(nsAString &aSummary)
|
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::GetSummary(nsAString &aSummary)
|
||||||
{
|
{
|
||||||
aSummary = mSummary;
|
aSummary.Truncate();
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULTreeColumnsAccessibleWrap::SetSummary(const nsAString &aSummary)
|
|
||||||
{
|
|
||||||
mSummary = aSummary;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,6 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetChildCount(PRInt32 *_retval);
|
NS_IMETHOD GetChildCount(PRInt32 *_retval);
|
||||||
NS_IMETHOD ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState);
|
NS_IMETHOD ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState);
|
||||||
|
|
||||||
private:
|
|
||||||
nsCOMPtr<nsIAccessible> mCaption;
|
|
||||||
nsString mSummary;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsXULTreeColumnsAccessibleWrap : public nsXULTreeColumnsAccessible,
|
class nsXULTreeColumnsAccessibleWrap : public nsXULTreeColumnsAccessible,
|
||||||
|
@ -72,10 +68,6 @@ public:
|
||||||
|
|
||||||
nsXULTreeColumnsAccessibleWrap(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
nsXULTreeColumnsAccessibleWrap(nsIDOMNode* aDOMNode, nsIWeakReference* aShell);
|
||||||
virtual ~nsXULTreeColumnsAccessibleWrap() {}
|
virtual ~nsXULTreeColumnsAccessibleWrap() {}
|
||||||
|
|
||||||
private:
|
|
||||||
nsCOMPtr<nsIAccessible> mCaption;
|
|
||||||
nsString mSummary;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -90,7 +90,6 @@ ACCESSIBILITY_ATOM(area, "area")
|
||||||
ACCESSIBILITY_ATOM(blockquote, "blockquote")
|
ACCESSIBILITY_ATOM(blockquote, "blockquote")
|
||||||
ACCESSIBILITY_ATOM(br, "br")
|
ACCESSIBILITY_ATOM(br, "br")
|
||||||
ACCESSIBILITY_ATOM(body, "body")
|
ACCESSIBILITY_ATOM(body, "body")
|
||||||
ACCESSIBILITY_ATOM(caption, "caption")
|
|
||||||
ACCESSIBILITY_ATOM(choices, "choices") // XForms
|
ACCESSIBILITY_ATOM(choices, "choices") // XForms
|
||||||
ACCESSIBILITY_ATOM(description, "description") // XUL
|
ACCESSIBILITY_ATOM(description, "description") // XUL
|
||||||
ACCESSIBILITY_ATOM(dd, "dd")
|
ACCESSIBILITY_ATOM(dd, "dd")
|
||||||
|
|
|
@ -477,7 +477,6 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame *aFrame,
|
||||||
else if (tag == nsAccessibilityAtoms::abbr ||
|
else if (tag == nsAccessibilityAtoms::abbr ||
|
||||||
tag == nsAccessibilityAtoms::acronym ||
|
tag == nsAccessibilityAtoms::acronym ||
|
||||||
tag == nsAccessibilityAtoms::blockquote ||
|
tag == nsAccessibilityAtoms::blockquote ||
|
||||||
tag == nsAccessibilityAtoms::caption ||
|
|
||||||
tag == nsAccessibilityAtoms::dd ||
|
tag == nsAccessibilityAtoms::dd ||
|
||||||
tag == nsAccessibilityAtoms::dl ||
|
tag == nsAccessibilityAtoms::dl ||
|
||||||
tag == nsAccessibilityAtoms::dt ||
|
tag == nsAccessibilityAtoms::dt ||
|
||||||
|
@ -882,6 +881,24 @@ nsAccessibilityService::CreateHTMLBRAccessible(nsISupports *aFrame, nsIAccessibl
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsAccessibilityService::CreateHTMLCaptionAccessible(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 nsHTMLCaptionAccessible(node, weakShell);
|
||||||
|
if (! *_retval)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
NS_ADDREF(*_retval);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsAccessibilityService::GetCachedAccessible(nsIDOMNode *aNode,
|
NS_IMETHODIMP nsAccessibilityService::GetCachedAccessible(nsIDOMNode *aNode,
|
||||||
nsIWeakReference *aWeakShell,
|
nsIWeakReference *aWeakShell,
|
||||||
nsIAccessible **aAccessible)
|
nsIAccessible **aAccessible)
|
||||||
|
@ -1369,6 +1386,10 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tryFrame) {
|
if (tryFrame) {
|
||||||
|
if (frame->GetRect().IsEmpty()) {
|
||||||
|
*aIsHidden = PR_TRUE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
frame->GetAccessible(getter_AddRefs(newAcc)); // Try using frame to do it
|
frame->GetAccessible(getter_AddRefs(newAcc)); // Try using frame to do it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
#include "nsIAccessibilityService.h"
|
#include "nsIAccessibilityService.h"
|
||||||
#include "nsIDOMCSSStyleDeclaration.h"
|
#include "nsIDOMCSSStyleDeclaration.h"
|
||||||
#include "nsIDOMHTMLCollection.h"
|
#include "nsIDOMHTMLCollection.h"
|
||||||
#include "nsIDOMHTMLTableCaptionElem.h"
|
|
||||||
#include "nsIDOMHTMLTableCellElement.h"
|
#include "nsIDOMHTMLTableCellElement.h"
|
||||||
#include "nsIDOMHTMLTableElement.h"
|
#include "nsIDOMHTMLTableElement.h"
|
||||||
#include "nsIDOMHTMLTableRowElement.h"
|
#include "nsIDOMHTMLTableRowElement.h"
|
||||||
|
@ -92,7 +91,6 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLTableAccessible, nsAccessible, nsIAccessibleT
|
||||||
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
nsHTMLTableAccessible::nsHTMLTableAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
|
||||||
nsAccessibleWrap(aDomNode, aShell)
|
nsAccessibleWrap(aDomNode, aShell)
|
||||||
{
|
{
|
||||||
mHasCaption = PR_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLTableAccessible::CacheChildren()
|
void nsHTMLTableAccessible::CacheChildren()
|
||||||
|
@ -102,51 +100,37 @@ void nsHTMLTableAccessible::CacheChildren()
|
||||||
mAccChildCount = eChildCountUninitialized;
|
mAccChildCount = eChildCountUninitialized;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAccChildCount == eChildCountUninitialized) {
|
if (mAccChildCount == eChildCountUninitialized) {
|
||||||
PRInt32 childCount = 0;
|
nsAccessible::CacheChildren();
|
||||||
nsCOMPtr<nsPIAccessible> privatePrevAccessible;
|
|
||||||
nsCOMPtr<nsIAccessible> captionAccessible;
|
nsCOMPtr<nsIAccessible> captionAccessible;
|
||||||
GetCaption(getter_AddRefs(captionAccessible));
|
while (NextChild(captionAccessible)) {
|
||||||
if (captionAccessible) {
|
if (Role(captionAccessible) == nsIAccessibleRole::ROLE_CAPTION) {
|
||||||
mHasCaption = PR_TRUE;
|
nsCOMPtr<nsIAccessible> captionParentAccessible;
|
||||||
SetFirstChild(captionAccessible);
|
captionAccessible->GetParent(getter_AddRefs(captionParentAccessible));
|
||||||
++ childCount;
|
if (captionParentAccessible != this) {
|
||||||
privatePrevAccessible = do_QueryInterface(captionAccessible);
|
NS_WARNING("Should not happen: parser ensures caption is the table's child, not the tbody's");
|
||||||
privatePrevAccessible->SetParent(this);
|
return;
|
||||||
}
|
}
|
||||||
else {
|
nsCOMPtr<nsIAccessible> beforeCaptionAccessible;
|
||||||
mHasCaption = PR_FALSE;
|
captionAccessible->GetPreviousSibling(getter_AddRefs(beforeCaptionAccessible));
|
||||||
}
|
if (beforeCaptionAccessible) {
|
||||||
|
// Move caption accessible so that it's the first child
|
||||||
PRBool allowsAnonChildren = PR_FALSE;
|
nsCOMPtr<nsIAccessible> afterCaptionAccessible;
|
||||||
GetAllowsAnonChildAccessibles(&allowsAnonChildren);
|
captionAccessible->GetNextSibling(getter_AddRefs(afterCaptionAccessible));
|
||||||
nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, allowsAnonChildren);
|
nsCOMPtr<nsPIAccessible> privateAcc = do_QueryInterface(beforeCaptionAccessible);
|
||||||
walker.mState.frame = GetFrame();
|
privateAcc->SetNextSibling(afterCaptionAccessible);
|
||||||
|
GetFirstChild(getter_AddRefs(afterCaptionAccessible));
|
||||||
walker.GetFirstChild();
|
SetFirstChild(captionAccessible);
|
||||||
while (walker.mState.accessible) {
|
privateAcc = do_QueryInterface(captionAccessible);
|
||||||
nsCOMPtr<nsIContent> content(do_QueryInterface(walker.mState.domNode));
|
privateAcc->SetNextSibling(afterCaptionAccessible);
|
||||||
NS_ASSERTION(content, "Creating accessible for node in HTMLTable with no content");
|
}
|
||||||
if (content && content->IsNodeOfType(nsINode::eHTML) &&
|
// Don't check for more captions, because nsAccessibilityService ensures
|
||||||
content->Tag() == nsAccessibilityAtoms::caption) {
|
// we don't create accessibles for the other captions, since only the
|
||||||
// We have already dealt with caption, ignore this one
|
// first is actually visible
|
||||||
walker.GetNextSibling();
|
break;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++ childCount;
|
|
||||||
if (privatePrevAccessible) {
|
|
||||||
privatePrevAccessible->SetNextSibling(walker.mState.accessible);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SetFirstChild(walker.mState.accessible);
|
|
||||||
}
|
|
||||||
privatePrevAccessible = do_QueryInterface(walker.mState.accessible);
|
|
||||||
privatePrevAccessible->SetParent(this);
|
|
||||||
walker.GetNextSibling();
|
|
||||||
}
|
}
|
||||||
mAccChildCount = childCount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,34 +157,14 @@ NS_IMETHODIMP nsHTMLTableAccessible::GetName(nsAString& aName)
|
||||||
{
|
{
|
||||||
aName.Truncate(); // Default name is blank
|
aName.Truncate(); // Default name is blank
|
||||||
|
|
||||||
if (mRoleMapEntry) {
|
nsAccessible::GetName(aName);
|
||||||
nsAccessible::GetName(aName);
|
if (aName.IsEmpty()) {
|
||||||
if (!aName.IsEmpty()) {
|
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||||
return NS_OK;
|
if (content) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
|
|
||||||
if (element) {
|
|
||||||
nsCOMPtr<nsIDOMNodeList> captions;
|
|
||||||
nsAutoString nameSpaceURI;
|
|
||||||
element->GetNamespaceURI(nameSpaceURI);
|
|
||||||
element->GetElementsByTagNameNS(nameSpaceURI, NS_LITERAL_STRING("caption"),
|
|
||||||
getter_AddRefs(captions));
|
|
||||||
if (captions) {
|
|
||||||
nsCOMPtr<nsIDOMNode> captionNode;
|
|
||||||
captions->Item(0, getter_AddRefs(captionNode));
|
|
||||||
if (captionNode) {
|
|
||||||
nsCOMPtr<nsIContent> captionContent(do_QueryInterface(captionNode));
|
|
||||||
AppendFlatStringFromSubtree(captionContent, &aName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (aName.IsEmpty()) {
|
|
||||||
nsCOMPtr<nsIContent> content(do_QueryInterface(element));
|
|
||||||
NS_ASSERTION(content, "No content for DOM element");
|
|
||||||
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary, aName);
|
content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary, aName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,65 +190,39 @@ nsHTMLTableAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLTableAccessible::GetCaption(nsIAccessible **aCaption)
|
nsHTMLTableAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||||
|
nsIAccessible **aRelated)
|
||||||
{
|
{
|
||||||
*aCaption = nsnull;
|
NS_ENSURE_ARG_POINTER(aRelated);
|
||||||
nsresult rv = NS_OK;
|
*aRelated = nsnull;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
if (!mDOMNode) {
|
||||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement> caption;
|
|
||||||
rv = table->GetCaption(getter_AddRefs(caption));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> captionNode(do_QueryInterface(caption));
|
|
||||||
if (!captionNode) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIAccessibilityService> accService = GetAccService();
|
nsresult rv = nsAccessibleWrap::GetAccessibleRelated(aRelationType, aRelated);
|
||||||
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
|
if (NS_FAILED(rv) || *aRelated) {
|
||||||
|
// Either the node is shut down, or another relation mechanism has been used
|
||||||
accService->GetCachedAccessible(captionNode, mWeakShell, aCaption);
|
return rv;
|
||||||
if (*aCaption)
|
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> presShell(GetPresShell());
|
|
||||||
nsCOMPtr<nsIContent> content(do_QueryInterface(captionNode));
|
|
||||||
NS_ENSURE_TRUE(presShell && content, NS_ERROR_FAILURE);
|
|
||||||
nsIFrame* frame = presShell->GetPrimaryFrameFor(content);
|
|
||||||
if (!frame) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
accService->CreateHyperTextAccessible(frame, aCaption);
|
|
||||||
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(*aCaption));
|
if (aRelationType == nsIAccessibleRelation::RELATION_DESCRIBED_BY) {
|
||||||
return accessNode ? accessNode->Init() : NS_ERROR_FAILURE;
|
return GetCaption(aRelated);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLTableAccessible::SetCaption(nsIAccessible *aCaption)
|
nsHTMLTableAccessible::GetCaption(nsIAccessible **aCaption)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsCOMPtr<nsIAccessible> firstChild;
|
||||||
|
GetFirstChild(getter_AddRefs(firstChild));
|
||||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
if (firstChild && Role(firstChild) == nsIAccessibleRole::ROLE_CAPTION) {
|
||||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
NS_ADDREF(*aCaption = firstChild);
|
||||||
|
}
|
||||||
nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(aCaption));
|
return NS_OK;
|
||||||
NS_ASSERTION(accessNode, "Unable to QI to nsIAccessNode");
|
|
||||||
nsCOMPtr<nsIDOMNode> domNode;
|
|
||||||
rv = accessNode->GetDOMNode(getter_AddRefs(domNode));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> newDOMNode;
|
|
||||||
rv = domNode->CloneNode(PR_TRUE, getter_AddRefs(newDOMNode));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLTableCaptionElement>
|
|
||||||
captionElement(do_QueryInterface(newDOMNode));
|
|
||||||
NS_ENSURE_TRUE(captionElement, NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
return table->SetCaption(captionElement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -296,15 +234,6 @@ nsHTMLTableAccessible::GetSummary(nsAString &aSummary)
|
||||||
return table->GetSummary(aSummary);
|
return table->GetSummary(aSummary);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsHTMLTableAccessible::SetSummary(const nsAString &aSummary)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mDOMNode));
|
|
||||||
NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
|
|
||||||
|
|
||||||
return table->SetSummary(aSummary);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLTableAccessible::GetColumns(PRInt32 *aColumns)
|
nsHTMLTableAccessible::GetColumns(PRInt32 *aColumns)
|
||||||
{
|
{
|
||||||
|
@ -820,20 +749,39 @@ nsHTMLTableAccessible::GetCellAt(PRInt32 aRowIndex,
|
||||||
isSelected);
|
isSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHOW_LAYOUT_HEURISTIC
|
|
||||||
NS_IMETHODIMP nsHTMLTableAccessible::GetDescription(nsAString& aDescription)
|
NS_IMETHODIMP nsHTMLTableAccessible::GetDescription(nsAString& aDescription)
|
||||||
{
|
{
|
||||||
// Helpful for debugging layout vs. data tables
|
// Helpful for debugging layout vs. data tables
|
||||||
aDescription.Truncate();
|
aDescription.Truncate();
|
||||||
PRBool isProbablyForLayout;
|
nsAccessible::GetDescription(aDescription);
|
||||||
IsProbablyForLayout(&isProbablyForLayout);
|
if (!aDescription.IsEmpty()) {
|
||||||
aDescription = mLayoutHeuristic;
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIAccessible> captionAccessible;
|
||||||
|
GetCaption(getter_AddRefs(captionAccessible));
|
||||||
|
nsCOMPtr<nsIAccessNode> captionAccessNode = do_QueryInterface(captionAccessible);
|
||||||
|
if (captionAccessNode) {
|
||||||
|
nsCOMPtr<nsIDOMNode> captionNode;
|
||||||
|
captionAccessNode->GetDOMNode(getter_AddRefs(captionNode));
|
||||||
|
nsCOMPtr<nsIContent> captionContent = do_QueryInterface(captionNode);
|
||||||
|
if (captionContent) {
|
||||||
|
AppendFlatStringFromSubtree(captionContent, &aDescription);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef SHOW_LAYOUT_HEURISTIC
|
||||||
|
if (aDescription.IsEmpty()) {
|
||||||
|
PRBool isProbablyForLayout;
|
||||||
|
IsProbablyForLayout(&isProbablyForLayout);
|
||||||
|
aDescription = mLayoutHeuristic;
|
||||||
|
}
|
||||||
#ifdef DEBUG_A11Y
|
#ifdef DEBUG_A11Y
|
||||||
printf("\nTABLE: %s\n", NS_ConvertUTF16toUTF8(mLayoutHeuristic).get());
|
printf("\nTABLE: %s\n", NS_ConvertUTF16toUTF8(mLayoutHeuristic).get());
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
PRBool nsHTMLTableAccessible::HasDescendant(char *aTagName, PRBool aAllowEmpty)
|
PRBool nsHTMLTableAccessible::HasDescendant(char *aTagName, PRBool aAllowEmpty)
|
||||||
{
|
{
|
||||||
|
@ -1059,24 +1007,12 @@ nsHTMLTableHeadAccessible::GetCaption(nsIAccessible **aCaption)
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsHTMLTableHeadAccessible::SetCaption(nsIAccessible *aCaption)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLTableHeadAccessible::GetSummary(nsAString &aSummary)
|
nsHTMLTableHeadAccessible::GetSummary(nsAString &aSummary)
|
||||||
{
|
{
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsHTMLTableHeadAccessible::SetSummary(const nsAString &aSummary)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLTableHeadAccessible::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
|
nsHTMLTableHeadAccessible::GetColumnHeader(nsIAccessibleTable **aColumnHeader)
|
||||||
{
|
{
|
||||||
|
@ -1098,3 +1034,29 @@ nsHTMLTableHeadAccessible::GetRows(PRInt32 *aRows)
|
||||||
return rows->GetLength((PRUint32 *)aRows);
|
return rows->GetLength((PRUint32 *)aRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsHTMLCaptionAccessible::GetAccessibleRelated(PRUint32 aRelationType,
|
||||||
|
nsIAccessible **aRelated)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aRelated);
|
||||||
|
*aRelated = nsnull;
|
||||||
|
|
||||||
|
if (!mDOMNode) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult rv = nsHyperTextAccessible::GetAccessibleRelated(aRelationType, aRelated);
|
||||||
|
if (NS_FAILED(rv) || *aRelated) {
|
||||||
|
// Either the node is shut down, or another relation mechanism has been used
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aRelationType == nsIAccessibleRelation::RELATION_DESCRIPTION_FOR) {
|
||||||
|
return GetParent(aRelated);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,9 +71,8 @@ public:
|
||||||
NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
|
NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
|
||||||
NS_IMETHOD GetName(nsAString& aResult);
|
NS_IMETHOD GetName(nsAString& aResult);
|
||||||
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
|
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
|
||||||
#ifdef SHOW_LAYOUT_HEURISTIC
|
|
||||||
NS_IMETHOD GetDescription(nsAString& aDescription);
|
NS_IMETHOD GetDescription(nsAString& aDescription);
|
||||||
#endif
|
NS_IMETHOD GetAccessibleRelated(PRUint32 aRelationType, nsIAccessible **aRelated);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -106,7 +105,6 @@ protected:
|
||||||
PRInt32 aColIndex,
|
PRInt32 aColIndex,
|
||||||
nsIDOMElement* &aCell);
|
nsIDOMElement* &aCell);
|
||||||
PRBool HasDescendant(char *aTagName, PRBool aAllowEmpty = PR_TRUE);
|
PRBool HasDescendant(char *aTagName, PRBool aAllowEmpty = PR_TRUE);
|
||||||
PRBool mHasCaption;
|
|
||||||
#ifdef SHOW_LAYOUT_HEURISTIC
|
#ifdef SHOW_LAYOUT_HEURISTIC
|
||||||
nsAutoString mLayoutHeuristic;
|
nsAutoString mLayoutHeuristic;
|
||||||
#endif
|
#endif
|
||||||
|
@ -124,11 +122,21 @@ public:
|
||||||
|
|
||||||
/* nsIAccessibleTable */
|
/* nsIAccessibleTable */
|
||||||
NS_IMETHOD GetCaption(nsIAccessible **aCaption);
|
NS_IMETHOD GetCaption(nsIAccessible **aCaption);
|
||||||
NS_IMETHOD SetCaption(nsIAccessible *aCaption);
|
|
||||||
NS_IMETHOD GetSummary(nsAString &aSummary);
|
NS_IMETHOD GetSummary(nsAString &aSummary);
|
||||||
NS_IMETHOD SetSummary(const nsAString &aSummary);
|
|
||||||
NS_IMETHOD GetColumnHeader(nsIAccessibleTable **aColumnHeader);
|
NS_IMETHOD GetColumnHeader(nsIAccessibleTable **aColumnHeader);
|
||||||
NS_IMETHOD GetRows(PRInt32 *aRows);
|
NS_IMETHOD GetRows(PRInt32 *aRows);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class nsHTMLCaptionAccessible : public nsHyperTextAccessibleWrap
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
nsHTMLCaptionAccessible(nsIDOMNode *aDomNode, nsIWeakReference *aShell) :
|
||||||
|
nsHyperTextAccessibleWrap(aDomNode, aShell) { }
|
||||||
|
|
||||||
|
// nsIAccessible
|
||||||
|
NS_IMETHOD GetRole(PRUint32 *aRole)
|
||||||
|
{ *aRole = nsIAccessibleRole::ROLE_CAPTION; return NS_OK; }
|
||||||
|
NS_IMETHOD GetAccessibleRelated(PRUint32 aRelationType, nsIAccessible **aRelated);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -140,10 +140,7 @@ NS_IMETHODIMP nsHyperTextAccessible::GetRole(PRUint32 *aRole)
|
||||||
|
|
||||||
nsIAtom *tag = content->Tag();
|
nsIAtom *tag = content->Tag();
|
||||||
|
|
||||||
if (tag == nsAccessibilityAtoms::caption) {
|
if (tag == nsAccessibilityAtoms::form) {
|
||||||
*aRole = nsIAccessibleRole::ROLE_CAPTION;
|
|
||||||
}
|
|
||||||
else if (tag == nsAccessibilityAtoms::form) {
|
|
||||||
*aRole = nsIAccessibleRole::ROLE_FORM;
|
*aRole = nsIAccessibleRole::ROLE_FORM;
|
||||||
}
|
}
|
||||||
else if (tag == nsAccessibilityAtoms::div ||
|
else if (tag == nsAccessibilityAtoms::div ||
|
||||||
|
|
|
@ -137,6 +137,21 @@ nsTableCaptionFrame::GetParentStyleContextFrame(nsPresContext* aPresContext,
|
||||||
aIsChild);
|
aIsChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ACCESSIBILITY
|
||||||
|
NS_IMETHODIMP nsTableCaptionFrame::GetAccessible(nsIAccessible** aAccessible)
|
||||||
|
{
|
||||||
|
*aAccessible = nsnull;
|
||||||
|
if (!GetRect().IsEmpty()) {
|
||||||
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
||||||
|
if (accService) {
|
||||||
|
return accService->CreateHTMLCaptionAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTableCaptionFrame::GetFrameName(nsAString& aResult) const
|
nsTableCaptionFrame::GetFrameName(nsAString& aResult) const
|
||||||
|
|
|
@ -60,6 +60,10 @@ public:
|
||||||
NS_IMETHOD GetParentStyleContextFrame(nsPresContext* aPresContext,
|
NS_IMETHOD GetParentStyleContextFrame(nsPresContext* aPresContext,
|
||||||
nsIFrame** aProviderFrame,
|
nsIFrame** aProviderFrame,
|
||||||
PRBool* aIsChild);
|
PRBool* aIsChild);
|
||||||
|
#ifdef ACCESSIBILITY
|
||||||
|
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче