--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -268,17 +268,17 @@ Accessible::Name(nsString& aName)
nsCOMPtr<nsIXBLAccessible> xblAccessible(do_QueryInterface(mContent));
if (xblAccessible) {
xblAccessible->GetAccessibleName(aName);
if (!aName.IsEmpty())
return eNameOK;
}
- nsresult rv = GetNameInternal(aName);
+ ENameValueFlag nameFlag = NativeName(aName);
if (!aName.IsEmpty())
return eNameOK;
// In the end get the name from tooltip.
if (mContent->IsHTML()) {
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName)) {
aName.CompressWhitespace();
return eNameFromTooltip;
@@ -287,17 +287,17 @@ Accessible::Name(nsString& aName)
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::tooltiptext, aName)) {
aName.CompressWhitespace();
return eNameFromTooltip;
}
} else {
return eNameOK;
}
- if (rv != NS_OK_EMPTY_NAME)
+ if (nameFlag != eNoNameOnPurpose)
aName.SetIsVoid(true);
return eNameOK;
}
NS_IMETHODIMP
Accessible::GetDescription(nsAString& aDescription)
{
@@ -1050,120 +1050,105 @@ Accessible::TakeFocus()
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(focusContent));
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm)
fm->SetFocus(element, 0);
return NS_OK;
}
-nsresult
-Accessible::GetHTMLName(nsAString& aLabel)
+void
+Accessible::GetHTMLName(nsString& aLabel)
{
- nsAutoString label;
-
Accessible* labelAcc = nullptr;
HTMLLabelIterator iter(Document(), this);
while ((labelAcc = iter.Next())) {
- nsresult rv = nsTextEquivUtils::
- AppendTextEquivFromContent(this, labelAcc->GetContent(), &label);
- NS_ENSURE_SUCCESS(rv, rv);
-
- label.CompressWhitespace();
+ nsTextEquivUtils::AppendTextEquivFromContent(this, labelAcc->GetContent(),
+ &aLabel);
+ aLabel.CompressWhitespace();
}
- if (label.IsEmpty())
- return nsTextEquivUtils::GetNameFromSubtree(this, aLabel);
-
- aLabel = label;
- return NS_OK;
+ if (aLabel.IsEmpty())
+ nsTextEquivUtils::GetNameFromSubtree(this, aLabel);
}
/**
* 3 main cases for XUL Controls to be labeled
* 1 - control contains label="foo"
* 2 - control has, as a child, a label element
* - label has either value="foo" or children
* 3 - non-child label contains control="controlID"
* - label has either value="foo" or children
* Once a label is found, the search is discontinued, so a control
* that has a label child as well as having a label external to
* the control that uses the control="controlID" syntax will use
* the child label for its Name.
*/
-nsresult
-Accessible::GetXULName(nsAString& aLabel)
+void
+Accessible::GetXULName(nsString& aName)
{
// CASE #1 (via label attribute) -- great majority of the cases
- nsresult rv = NS_OK;
-
- nsAutoString label;
- nsCOMPtr<nsIDOMXULLabeledControlElement> labeledEl(do_QueryInterface(mContent));
+ nsCOMPtr<nsIDOMXULLabeledControlElement> labeledEl =
+ do_QueryInterface(mContent);
if (labeledEl) {
- rv = labeledEl->GetLabel(label);
- }
- else {
- nsCOMPtr<nsIDOMXULSelectControlItemElement> itemEl(do_QueryInterface(mContent));
+ labeledEl->GetLabel(aName);
+ } else {
+ nsCOMPtr<nsIDOMXULSelectControlItemElement> itemEl =
+ do_QueryInterface(mContent);
if (itemEl) {
- rv = itemEl->GetLabel(label);
- }
- else {
- nsCOMPtr<nsIDOMXULSelectControlElement> select(do_QueryInterface(mContent));
+ itemEl->GetLabel(aName);
+ } else {
+ nsCOMPtr<nsIDOMXULSelectControlElement> select =
+ do_QueryInterface(mContent);
// Use label if this is not a select control element which
// uses label attribute to indicate which option is selected
if (!select) {
nsCOMPtr<nsIDOMXULElement> xulEl(do_QueryInterface(mContent));
- if (xulEl) {
- rv = xulEl->GetAttribute(NS_LITERAL_STRING("label"), label);
- }
+ if (xulEl)
+ xulEl->GetAttribute(NS_LITERAL_STRING("label"), aName);
}
}
}
// CASES #2 and #3 ------ label as a child or <label control="id" ... > </label>
- if (NS_FAILED(rv) || label.IsEmpty()) {
- label.Truncate();
-
+ if (aName.IsEmpty()) {
Accessible* labelAcc = nullptr;
XULLabelIterator iter(Document(), mContent);
while ((labelAcc = iter.Next())) {
nsCOMPtr<nsIDOMXULLabelElement> xulLabel =
do_QueryInterface(labelAcc->GetContent());
// Check if label's value attribute is used
- if (xulLabel && NS_SUCCEEDED(xulLabel->GetValue(label)) && label.IsEmpty()) {
+ if (xulLabel && NS_SUCCEEDED(xulLabel->GetValue(aName)) && aName.IsEmpty()) {
// If no value attribute, a non-empty label must contain
// children that define its text -- possibly using HTML
nsTextEquivUtils::
- AppendTextEquivFromContent(this, labelAcc->GetContent(), &label);
+ AppendTextEquivFromContent(this, labelAcc->GetContent(), &aName);
}
}
}
// XXX If CompressWhiteSpace worked on nsAString we could avoid a copy
- label.CompressWhitespace();
- if (!label.IsEmpty()) {
- aLabel = label;
- return NS_OK;
- }
+ aName.CompressWhitespace();
+ if (!aName.IsEmpty())
+ return;
// Can get text from title of <toolbaritem> if we're a child of a <toolbaritem>
nsIContent *bindingParent = mContent->GetBindingParent();
nsIContent *parent = bindingParent? bindingParent->GetParent() :
mContent->GetParent();
while (parent) {
if (parent->Tag() == nsGkAtoms::toolbaritem &&
- parent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, label)) {
- label.CompressWhitespace();
- aLabel = label;
- return NS_OK;
+ parent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName)) {
+ aName.CompressWhitespace();
+ return;
}
parent = parent->GetParent();
}
- return nsTextEquivUtils::GetNameFromSubtree(this, aLabel);
+ nsTextEquivUtils::GetNameFromSubtree(this, aName);
}
nsresult
Accessible::HandleAccEvent(AccEvent* aEvent)
{
NS_ENSURE_ARG_POINTER(aEvent);
nsCOMPtr<nsIObserverService> obsService =
@@ -2428,19 +2413,16 @@ Accessible::Shutdown()
InvalidateChildren();
if (mParent)
mParent->RemoveChild(this);
nsAccessNodeWrap::Shutdown();
}
-////////////////////////////////////////////////////////////////////////////////
-// Accessible public methods
-
// Accessible protected
void
Accessible::ARIAName(nsAString& aName)
{
nsAutoString label;
// aria-labelledby now takes precedence over aria-label
nsresult rv = nsTextEquivUtils::
@@ -2453,26 +2435,26 @@ Accessible::ARIAName(nsAString& aName)
if (label.IsEmpty() &&
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_label,
label)) {
label.CompressWhitespace();
aName = label;
}
}
-nsresult
-Accessible::GetNameInternal(nsAString& aName)
+// Accessible protected
+ENameValueFlag
+Accessible::NativeName(nsString& aName)
{
if (mContent->IsHTML())
- return GetHTMLName(aName);
-
- if (mContent->IsXUL())
- return GetXULName(aName);
-
- return NS_OK;
+ GetHTMLName(aName);
+ else if (mContent->IsXUL())
+ GetXULName(aName);
+
+ return eNameOK;
}
// Accessible protected
void
Accessible::BindToParent(Accessible* aParent, uint32_t aIndexInParent)
{
NS_PRECONDITION(aParent, "This method isn't used to set null parent!");
@@ -2485,25 +2467,29 @@ Accessible::BindToParent(Accessible* aPa
return;
}
}
mParent = aParent;
mIndexInParent = aIndexInParent;
}
+// Accessible protected
void
Accessible::UnbindFromParent()
{
mParent = nullptr;
mIndexInParent = -1;
mIndexOfEmbeddedChild = -1;
mGroupInfo = nullptr;
}
+////////////////////////////////////////////////////////////////////////////////
+// Accessible public methods
+
void
Accessible::InvalidateChildren()
{
int32_t childCount = mChildren.Length();
for (int32_t childIdx = 0; childIdx < childCount; childIdx++) {
Accessible* child = mChildren.ElementAt(childIdx);
child->UnbindFromParent();
}
--- a/accessible/src/generic/Accessible.h
+++ b/accessible/src/generic/Accessible.h
@@ -44,20 +44,29 @@ class XULTreeAccessible;
/**
* Name type flags.
*/
enum ENameValueFlag {
/**
* Name either
* a) present (not empty): !name.IsEmpty()
* b) no name (was missed): name.IsVoid()
- * c) was left empty by the author on demand: name.IsEmpty() && !name.IsVoid()
*/
eNameOK,
- eNameFromTooltip // Tooltip was used as a name
+
+ /**
+ * Name was left empty by the author on purpose:
+ * name.IsEmpty() && !name.IsVoid().
+ */
+ eNoNameOnPurpose,
+
+ /**
+ * Tooltip was used as a name.
+ */
+ eNameFromTooltip
};
/**
* Group position (level, position in set and set size).
*/
struct GroupPos
{
GroupPos() : level(0), posInSet(0), setSize(0) { }
@@ -127,16 +136,19 @@ public:
/**
* Get the value of this accessible.
*/
virtual void Value(nsString& aValue);
/**
* Get the name of this accessible.
+ *
+ * Note: aName.IsVoid() when name was left empty by the author on purpose.
+ * aName.IsEmpty() when the author missed name, AT can try to repair a name.
*/
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
/**
* Return DOM node associated with this accessible.
*/
inline already_AddRefed<nsIDOMNode> DOMNode() const
{
@@ -151,28 +163,16 @@ public:
* argument should hold states for accessible before you pass it into this
* method.
*
* @param [in/out] where to fill the states into.
*/
virtual void ApplyARIAState(uint64_t* aState) const;
/**
- * Returns the accessible name provided by native markup. It doesn't take
- * into account ARIA markup used to specify the name.
- *
- * @param aName [out] the accessible name
- *
- * @return NS_OK_EMPTY_NAME points empty name was specified by native markup
- * explicitly (see nsIAccessible::name attribute for
- * details)
- */
- virtual nsresult GetNameInternal(nsAString& aName);
-
- /**
* Return enumerated accessible role (see constants in Role.h).
*/
mozilla::a11y::role Role();
/**
* Return true if ARIA role is specified on the element.
*/
bool HasARIARole() const
@@ -789,29 +789,31 @@ protected:
* Return ARIA role (helper method).
*/
mozilla::a11y::role ARIATransformRole(mozilla::a11y::role aRole);
//////////////////////////////////////////////////////////////////////////////
// Name helpers
/**
+ * Return the accessible name provided by native markup. It doesn't take
+ * into account ARIA markup used to specify the name.
+ */
+ virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName);
+
+ /**
* Returns the accessible name specified by ARIA.
*/
void ARIAName(nsAString& aName);
/**
- * Compute the name of HTML node.
+ * Compute the name of HTML/XUL node.
*/
- nsresult GetHTMLName(nsAString& aName);
-
- /**
- * Compute the name for XUL node.
- */
- nsresult GetXULName(nsAString& aName);
+ void GetHTMLName(nsString& aName);
+ void GetXULName(nsString& aName);
// helper method to verify frames
static nsresult GetFullKeyName(const nsAString& aModifierName, const nsAString& aKeyName, nsAString& aStringOut);
/**
* Return an accessible for the given DOM node, or if that node isn't
* accessible, return the accessible for the next DOM node which has one
* (based on forward depth first search).
--- a/accessible/src/generic/HyperTextAccessible.cpp
+++ b/accessible/src/generic/HyperTextAccessible.cpp
@@ -1944,33 +1944,30 @@ HyperTextAccessible::ScrollSubstringToPo
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// Accessible public
-nsresult
-HyperTextAccessible::GetNameInternal(nsAString& aName)
+// Accessible protected
+ENameValueFlag
+HyperTextAccessible::NativeName(nsString& aName)
{
- nsresult rv = AccessibleWrap::GetNameInternal(aName);
- NS_ENSURE_SUCCESS(rv, rv);
+ AccessibleWrap::NativeName(aName);
// Get name from title attribute for HTML abbr and acronym elements making it
// a valid name from markup. Otherwise their name isn't picked up by recursive
// name computation algorithm. See NS_OK_NAME_FROM_TOOLTIP.
- if (aName.IsEmpty() && IsAbbreviation()) {
- nsAutoString name;
- if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, name)) {
- name.CompressWhitespace();
- aName = name;
- }
- }
- return NS_OK;
+ if (aName.IsEmpty() && IsAbbreviation() &&
+ mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName))
+ aName.CompressWhitespace();
+
+ return eNameOK;
}
void
HyperTextAccessible::InvalidateChildren()
{
mOffsets.Clear();
AccessibleWrap::InvalidateChildren();
--- a/accessible/src/generic/HyperTextAccessible.h
+++ b/accessible/src/generic/HyperTextAccessible.h
@@ -47,17 +47,16 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLETEXT
NS_DECL_NSIACCESSIBLEHYPERTEXT
NS_DECL_NSIACCESSIBLEEDITABLETEXT
// Accessible
virtual int32_t GetLevelInternal();
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual uint64_t NativeState();
virtual void InvalidateChildren();
virtual bool RemoveChild(Accessible* aAccessible);
// HyperTextAccessible (static helper method)
@@ -238,16 +237,19 @@ public:
// EditableTextAccessible
/**
* Return the editor associated with the accessible.
*/
virtual already_AddRefed<nsIEditor> GetEditor() const;
protected:
+ // Accessible
+ virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
+
// HyperTextAccessible
/**
* Transform magic offset into text offset.
*/
int32_t ConvertMagicOffset(int32_t aOffset)
{
if (aOffset == nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT)
--- a/accessible/src/generic/ImageAccessible.cpp
+++ b/accessible/src/generic/ImageAccessible.cpp
@@ -64,36 +64,34 @@ ImageAccessible::NativeState()
imgContainer->GetAnimated(&animated);
if (animated)
state |= states::ANIMATED;
}
return state;
}
-nsresult
-ImageAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+ImageAccessible::NativeName(nsString& aName)
{
bool hasAltAttrib =
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName);
if (!aName.IsEmpty())
- return NS_OK;
+ return eNameOK;
- nsresult rv = Accessible::GetNameInternal(aName);
- NS_ENSURE_SUCCESS(rv, rv);
-
+ Accessible::NativeName(aName);
if (aName.IsEmpty() && hasAltAttrib) {
// No accessible name but empty 'alt' attribute is present. If further name
// computation algorithm doesn't provide non empty name then it means
// an empty 'alt' attribute was used to indicate a decorative image (see
// nsIAccessible::name attribute for details).
- return NS_OK_EMPTY_NAME;
+ return eNoNameOnPurpose;
}
- return NS_OK;
+ return eNameOK;
}
role
ImageAccessible::NativeRole()
{
return roles::GRAPHIC;
}
--- a/accessible/src/generic/ImageAccessible.h
+++ b/accessible/src/generic/ImageAccessible.h
@@ -31,24 +31,27 @@ public:
// nsIAccessible
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
NS_IMETHOD DoAction(uint8_t index);
// nsIAccessibleImage
NS_DECL_NSIACCESSIBLEIMAGE
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
// ActionAccessible
virtual uint8_t ActionCount();
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
+
private:
/**
* Return whether the element has a longdesc URI.
*/
bool HasLongDesc() const
{
nsCOMPtr<nsIURI> uri = GetLongDescURI();
return uri;
--- a/accessible/src/html/HTMLElementAccessibles.cpp
+++ b/accessible/src/html/HTMLElementAccessibles.cpp
@@ -36,33 +36,34 @@ HTMLBRAccessible::NativeRole()
}
uint64_t
HTMLBRAccessible::NativeState()
{
return states::READONLY;
}
-nsresult
-HTMLBRAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLBRAccessible::NativeName(nsString& aName)
{
aName = static_cast<PRUnichar>('\n'); // Newline char
- return NS_OK;
+ return eNameOK;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLLabelAccessible
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED0(HTMLLabelAccessible, HyperTextAccessible)
-nsresult
-HTMLLabelAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLLabelAccessible::NativeName(nsString& aName)
{
- return nsTextEquivUtils::GetNameFromSubtree(this, aName);
+ nsTextEquivUtils::GetNameFromSubtree(this, aName);
+ return eNameOK;
}
role
HTMLLabelAccessible::NativeRole()
{
return roles::LABEL;
}
--- a/accessible/src/html/HTMLElementAccessibles.h
+++ b/accessible/src/html/HTMLElementAccessibles.h
@@ -27,41 +27,45 @@ public:
};
/**
* Used for HTML br element.
*/
class HTMLBRAccessible : public LeafAccessible
{
public:
-
HTMLBRAccessible(nsIContent* aContent, DocAccessible* aDoc) :
LeafAccessible(aContent, aDoc) {};
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Used for HTML label element.
*/
class HTMLLabelAccessible : public HyperTextAccessibleWrap
{
public:
HTMLLabelAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc) {};
NS_DECL_ISUPPORTS_INHERITED
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
+
+protected:
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Used for HTML output element.
*/
class HTMLOutputAccessible : public HyperTextAccessibleWrap
{
public:
--- a/accessible/src/html/HTMLFormControlAccessible.cpp
+++ b/accessible/src/html/HTMLFormControlAccessible.cpp
@@ -251,47 +251,42 @@ HTMLButtonAccessible::NativeState()
}
role
HTMLButtonAccessible::NativeRole()
{
return roles::PUSHBUTTON;
}
-nsresult
-HTMLButtonAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLButtonAccessible::NativeName(nsString& aName)
{
- Accessible::GetNameInternal(aName);
+ Accessible::NativeName(aName);
if (!aName.IsEmpty() || mContent->Tag() != nsGkAtoms::input)
- return NS_OK;
+ return eNameOK;
// No name from HTML or ARIA
- nsAutoString name;
- if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value,
- name) &&
- !mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt,
- name)) {
+ if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName) &&
+ !mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName)) {
// Use the button's (default) label if nothing else works
nsIFrame* frame = GetFrame();
if (frame) {
nsIFormControlFrame* fcFrame = do_QueryFrame(frame);
if (fcFrame)
- fcFrame->GetFormProperty(nsGkAtoms::defaultLabel, name);
+ fcFrame->GetFormProperty(nsGkAtoms::defaultLabel, aName);
}
}
- if (name.IsEmpty() &&
- !mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, name)) {
- mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, name);
+ if (aName.IsEmpty() &&
+ !mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, aName)) {
+ mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, aName);
}
- name.CompressWhitespace();
- aName = name;
-
- return NS_OK;
+ aName.CompressWhitespace();
+ return eNameOK;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLButtonAccessible: Widgets
bool
HTMLButtonAccessible::IsWidget() const
{
@@ -320,44 +315,40 @@ HTMLTextFieldAccessible::NativeRole()
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
nsGkAtoms::password, eIgnoreCase)) {
return roles::PASSWORD_TEXT;
}
return roles::ENTRY;
}
-nsresult
-HTMLTextFieldAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLTextFieldAccessible::NativeName(nsString& aName)
{
- nsresult rv = Accessible::GetNameInternal(aName);
- NS_ENSURE_SUCCESS(rv, rv);
+ Accessible::NativeName(aName);
+ if (!aName.IsEmpty())
+ return eNameOK;
- if (!aName.IsEmpty())
- return NS_OK;
-
- if (mContent->GetBindingParent())
- {
+ if (mContent->GetBindingParent()) {
// XXX: bug 459640
// There's a binding parent.
// This means we're part of another control, so use parent accessible for name.
// This ensures that a textbox inside of a XUL widget gets
// an accessible name.
Accessible* parent = Parent();
if (parent)
parent->GetName(aName);
}
if (!aName.IsEmpty())
- return NS_OK;
+ return eNameOK;
// text inputs and textareas might have useful placeholder text
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, aName);
-
- return NS_OK;
+ return eNameOK;
}
void
HTMLTextFieldAccessible::Value(nsString& aValue)
{
aValue.Truncate();
if (NativeState() & states::PROTECTED) // Don't return password text!
return;
@@ -614,32 +605,28 @@ HTMLGroupboxAccessible::GetLegend()
// Either XHTML namespace or no namespace
return legendContent;
}
}
return nullptr;
}
-nsresult
-HTMLGroupboxAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLGroupboxAccessible::NativeName(nsString& aName)
{
- nsresult rv = Accessible::GetNameInternal(aName);
- NS_ENSURE_SUCCESS(rv, rv);
-
+ Accessible::NativeName(aName);
if (!aName.IsEmpty())
- return NS_OK;
+ return eNameOK;
- nsIContent *legendContent = GetLegend();
- if (legendContent) {
- return nsTextEquivUtils::
- AppendTextEquivFromContent(this, legendContent, &aName);
- }
+ nsIContent* legendContent = GetLegend();
+ if (legendContent)
+ nsTextEquivUtils::AppendTextEquivFromContent(this, legendContent, &aName);
- return NS_OK;
+ return eNameOK;
}
Relation
HTMLGroupboxAccessible::RelationByType(uint32_t aType)
{
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
// No override for label, so use <legend> for this <fieldset>
if (aType == nsIAccessibleRelation::RELATION_LABELLED_BY)
@@ -701,32 +688,28 @@ HTMLFigureAccessible::GetAttributesInter
}
role
HTMLFigureAccessible::NativeRole()
{
return roles::FIGURE;
}
-nsresult
-HTMLFigureAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLFigureAccessible::NativeName(nsString& aName)
{
- nsresult rv = HyperTextAccessibleWrap::GetNameInternal(aName);
- NS_ENSURE_SUCCESS(rv, rv);
-
+ HyperTextAccessibleWrap::NativeName(aName);
if (!aName.IsEmpty())
- return NS_OK;
+ return eNameOK;
nsIContent* captionContent = Caption();
- if (captionContent) {
- return nsTextEquivUtils::
- AppendTextEquivFromContent(this, captionContent, &aName);
- }
+ if (captionContent)
+ nsTextEquivUtils::AppendTextEquivFromContent(this, captionContent, &aName);
- return NS_OK;
+ return eNameOK;
}
Relation
HTMLFigureAccessible::RelationByType(uint32_t aType)
{
Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
if (aType == nsIAccessibleRelation::RELATION_LABELLED_BY)
rel.AppendTarget(mDoc, Caption());
--- a/accessible/src/html/HTMLFormControlAccessible.h
+++ b/accessible/src/html/HTMLFormControlAccessible.h
@@ -72,26 +72,29 @@ public:
HTMLButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
NS_IMETHOD DoAction(uint8_t index);
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual uint64_t State();
virtual uint64_t NativeState();
// ActionAccessible
virtual uint8_t ActionCount();
// Widgets
virtual bool IsWidget() const;
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Accessible for HTML input@type="text" element.
*/
class HTMLTextFieldAccessible : public HyperTextAccessibleWrap
{
@@ -108,27 +111,30 @@ public:
NS_IMETHOD DoAction(uint8_t index);
// HyperTextAccessible
virtual already_AddRefed<nsIEditor> GetEditor() const;
// Accessible
virtual void Value(nsString& aValue);
virtual void ApplyARIAState(uint64_t* aState) const;
- virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual uint64_t State();
virtual uint64_t NativeState();
// ActionAccessible
virtual uint8_t ActionCount();
// Widgets
virtual bool IsWidget() const;
virtual Accessible* ContainerWidget() const;
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Accessible for input@type="file" element.
*/
class HTMLFileInputAccessible : public HyperTextAccessibleWrap
{
@@ -144,21 +150,24 @@ public:
* Accessible for HTML fieldset element.
*/
class HTMLGroupboxAccessible : public HyperTextAccessibleWrap
{
public:
HTMLGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual Relation RelationByType(uint32_t aType);
protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
+
+ // HTMLGroupboxAccessible
nsIContent* GetLegend();
};
/**
* Accessible for HTML legend element.
*/
class HTMLLegendAccessible : public HyperTextAccessibleWrap
@@ -176,21 +185,24 @@ public:
*/
class HTMLFigureAccessible : public HyperTextAccessibleWrap
{
public:
HTMLFigureAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual nsresult GetAttributesInternal(nsIPersistentProperties* aAttributes);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual Relation RelationByType(uint32_t aType);
protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
+
+ // HTMLLegendAccessible
nsIContent* Caption() const;
};
/**
* Accessible for HTML5 figcaption element.
*/
class HTMLFigcaptionAccessible : public HyperTextAccessibleWrap
--- a/accessible/src/html/HTMLImageMapAccessible.cpp
+++ b/accessible/src/html/HTMLImageMapAccessible.cpp
@@ -155,29 +155,27 @@ HTMLAreaAccessible::
// Make HTML area DOM element not accessible. HTML image map accessible
// manages its tree itself.
mFlags |= eNotNodeMapEntry;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLAreaAccessible: nsIAccessible
-nsresult
-HTMLAreaAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLAreaAccessible::NativeName(nsString& aName)
{
- nsresult rv = Accessible::GetNameInternal(aName);
- NS_ENSURE_SUCCESS(rv, rv);
-
+ Accessible::NativeName(aName);
if (!aName.IsEmpty())
- return NS_OK;
+ return eNameOK;
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName))
- return GetValue(aName);
+ GetValue(aName);
- return NS_OK;
+ return eNameOK;
}
void
HTMLAreaAccessible::Description(nsString& aDescription)
{
aDescription.Truncate();
// Still to do - follow IE's standard here
--- a/accessible/src/html/HTMLImageMapAccessible.h
+++ b/accessible/src/html/HTMLImageMapAccessible.h
@@ -50,28 +50,27 @@ protected:
class HTMLAreaAccessible : public HTMLLinkAccessible
{
public:
HTMLAreaAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual void Description(nsString& aDescription);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
EWhichChildAtPoint aWhichChild);
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
// HyperLinkAccessible
virtual uint32_t StartOffset();
virtual uint32_t EndOffset();
protected:
-
// Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
virtual void CacheChildren();
};
} // namespace a11y
} // namespace mozilla
////////////////////////////////////////////////////////////////////////////////
// Accessible downcasting method
--- a/accessible/src/html/HTMLSelectAccessible.cpp
+++ b/accessible/src/html/HTMLSelectAccessible.cpp
@@ -180,44 +180,34 @@ role
HTMLSelectOptionAccessible::NativeRole()
{
if (mParent && mParent->Role() == roles::COMBOBOX_LIST)
return roles::COMBOBOX_OPTION;
return roles::OPTION;
}
-nsresult
-HTMLSelectOptionAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLSelectOptionAccessible::NativeName(nsString& aName)
{
// CASE #1 -- great majority of the cases
// find the label attribute - this is what the W3C says we should use
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
if (!aName.IsEmpty())
- return NS_OK;
+ return eNameOK;
// CASE #2 -- no label parameter, get the first child,
// use it if it is a text node
nsIContent* text = mContent->GetFirstChild();
- if (!text)
- return NS_OK;
-
- if (text->IsNodeOfType(nsINode::eTEXT)) {
- nsAutoString txtValue;
- nsresult rv = nsTextEquivUtils::
- AppendTextEquivFromTextContent(text, &txtValue);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Temp var (txtValue) needed until CompressWhitespace built for nsAString
- txtValue.CompressWhitespace();
- aName.Assign(txtValue);
- return NS_OK;
+ if (text && text->IsNodeOfType(nsINode::eTEXT)) {
+ nsTextEquivUtils::AppendTextEquivFromTextContent(text, &aName);
+ aName.CompressWhitespace();
}
- return NS_OK;
+ return eNameOK;
}
uint64_t
HTMLSelectOptionAccessible::NativeState()
{
// As a HTMLSelectOptionAccessible we can have the following states:
// SELECTABLE, SELECTED, FOCUSED, FOCUSABLE, OFFSCREEN
// Upcall to Accessible, but skip HyperTextAccessible impl
--- a/accessible/src/html/HTMLSelectAccessible.h
+++ b/accessible/src/html/HTMLSelectAccessible.h
@@ -79,30 +79,33 @@ public:
virtual ~HTMLSelectOptionAccessible() {}
// nsIAccessible
NS_IMETHOD DoAction(uint8_t index);
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
NS_IMETHOD SetSelected(bool aSelect);
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual uint64_t NativeInteractiveState() const;
virtual int32_t GetLevelInternal();
virtual void GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame);
// ActionAccessible
virtual uint8_t ActionCount();
// Widgets
virtual Accessible* ContainerWidget() const;
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
+
private:
/**
* Return a select accessible the option belongs to if any.
*/
Accessible* GetSelect() const
{
if (mParent && mParent->IsListControl()) {
--- a/accessible/src/html/HTMLTableAccessible.cpp
+++ b/accessible/src/html/HTMLTableAccessible.cpp
@@ -380,37 +380,37 @@ HTMLTableAccessible::NativeRole()
}
uint64_t
HTMLTableAccessible::NativeState()
{
return Accessible::NativeState() | states::READONLY;
}
-nsresult
-HTMLTableAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+HTMLTableAccessible::NativeName(nsString& aName)
{
- Accessible::GetNameInternal(aName);
+ Accessible::NativeName(aName);
if (!aName.IsEmpty())
- return NS_OK;
+ return eNameOK;
// Use table caption as a name.
Accessible* caption = Caption();
if (caption) {
nsIContent* captionContent = caption->GetContent();
if (captionContent) {
nsTextEquivUtils::AppendTextEquivFromContent(this, captionContent, &aName);
if (!aName.IsEmpty())
- return NS_OK;
+ return eNameOK;
}
}
// If no caption then use summary as a name.
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::summary, aName);
- return NS_OK;
+ return eNameOK;
}
nsresult
HTMLTableAccessible::GetAttributesInternal(nsIPersistentProperties* aAttributes)
{
nsresult rv = AccessibleWrap::GetAttributesInternal(aAttributes);
NS_ENSURE_SUCCESS(rv, rv);
--- a/accessible/src/html/HTMLTableAccessible.h
+++ b/accessible/src/html/HTMLTableAccessible.h
@@ -138,17 +138,16 @@ public:
virtual Accessible* AsAccessible() { return this; }
// nsAccessNode
virtual void Shutdown();
// Accessible
virtual TableAccessible* AsTable() { return this; }
virtual void Description(nsString& aDescription);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
virtual Relation RelationByType(uint32_t aRelationType);
// HTMLTableAccessible
/**
@@ -158,18 +157,18 @@ public:
nsIDOMElement* &aCell);
/**
* Return nsITableLayout for the frame of the accessible table.
*/
nsITableLayout* GetTableLayout();
protected:
-
// Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
virtual void CacheChildren();
// HTMLTableAccessible
/**
* Add row or column to selection.
*
* @param aIndex [in] index of row or column to be selected
--- a/accessible/src/msaa/AccessibleWrap.cpp
+++ b/accessible/src/msaa/AccessibleWrap.cpp
@@ -259,17 +259,17 @@ AccessibleWrap::get_accName(
if (xpAccessible->IsDefunct())
return CO_E_OBJNOTCONNECTED;
nsAutoString name;
xpAccessible->Name(name);
// The name was not provided, e.g. no alt attribute for an image. A screen
// reader may choose to invent its own accessible name, e.g. from an image src
- // attribute. Refer to NS_OK_EMPTY_NAME return value.
+ // attribute. Refer to eNoNameOnPurpose return value.
if (name.IsVoid())
return S_FALSE;
*pszName = ::SysAllocStringLen(name.get(), name.Length());
if (!*pszName)
return E_OUTOFMEMORY;
} __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
--- a/accessible/src/xforms/nsXFormsAccessible.cpp
+++ b/accessible/src/xforms/nsXFormsAccessible.cpp
@@ -153,21 +153,22 @@ nsXFormsAccessible::NativelyUnavailable(
{
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
bool isRelevant = false;
sXFormsService->IsRelevant(DOMNode, &isRelevant);
return !isRelevant;
}
-nsresult
-nsXFormsAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+nsXFormsAccessible::NativeName(nsString& aName)
{
// search the xforms:label element
- return GetBoundChildElementValue(NS_LITERAL_STRING("label"), aName);
+ GetBoundChildElementValue(NS_LITERAL_STRING("label"), aName);
+ return eNameOK;
}
void
nsXFormsAccessible::Description(nsString& aDescription)
{
nsTextEquivUtils::
GetTextEquivFromIDRefs(this, nsGkAtoms::aria_describedby,
aDescription);
--- a/accessible/src/xforms/nsXFormsAccessible.h
+++ b/accessible/src/xforms/nsXFormsAccessible.h
@@ -41,29 +41,31 @@ public:
// Accessible
// Returns value of child xforms 'hint' element.
virtual void Description(nsString& aDescription);
// Returns value of instance node that xforms element is bound to.
virtual void Value(nsString& aValue);
- // Returns value of child xforms 'label' element.
- virtual nsresult GetNameInternal(nsAString& aName);
-
// Returns state of xforms element taking into account state of instance node
// that it is bound to.
virtual uint64_t NativeState();
virtual bool NativelyUnavailable() const;
// Denies accessible nodes in anonymous content of xforms element by
// always returning false value.
virtual bool CanHaveAnonChildren();
+
protected:
+ // Accessible
+ // Returns value of child xforms 'label' element.
+ virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
+
// Returns value of first child xforms element by tagname that is bound to
// instance node.
nsresult GetBoundChildElementValue(const nsAString& aTagName,
nsAString& aValue);
// Cache accessible child item/choices elements. For example, the method is
// used for full appearance select/select1 elements or for their child choices
// element. Note, those select/select1 elements that use native widget
--- a/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp
+++ b/accessible/src/xforms/nsXFormsFormControlsAccessible.cpp
@@ -22,21 +22,21 @@ nsXFormsLabelAccessible::
}
role
nsXFormsLabelAccessible::NativeRole()
{
return roles::LABEL;
}
-nsresult
-nsXFormsLabelAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+nsXFormsLabelAccessible::NativeName(nsString& aName)
{
// XXX Correct name calculation for this, see bug 453594.
- return NS_OK;
+ return eNameOK;
}
void
nsXFormsLabelAccessible::Description(nsString& aDescription)
{
nsTextEquivUtils::
GetTextEquivFromIDRefs(this, nsGkAtoms::aria_describedby,
aDescription);
--- a/accessible/src/xforms/nsXFormsFormControlsAccessible.h
+++ b/accessible/src/xforms/nsXFormsFormControlsAccessible.h
@@ -14,18 +14,21 @@
class nsXFormsLabelAccessible : public nsXFormsAccessible
{
public:
nsXFormsLabelAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual void Description(nsString& aDescription);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
+
+protected:
+ // Accessible
+ virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Accessible object for xforms:output.
*/
class nsXFormsOutputAccessible : public nsXFormsAccessible
{
--- a/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp
+++ b/accessible/src/xforms/nsXFormsWidgetsAccessible.cpp
@@ -128,22 +128,22 @@ nsXFormsComboboxPopupWidgetAccessible::N
}
uint64_t
nsXFormsComboboxPopupWidgetAccessible::NativeInteractiveState() const
{
return NativelyUnavailable() ? states::UNAVAILABLE : states::FOCUSABLE;
}
-nsresult
-nsXFormsComboboxPopupWidgetAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+nsXFormsComboboxPopupWidgetAccessible::NativeName(nsString& aName)
{
// Override nsXFormsAccessible::GetName() to prevent name calculation by
// XForms rules.
- return NS_OK;
+ return eNameOK;
}
void
nsXFormsComboboxPopupWidgetAccessible::Description(nsString& aDescription)
{
aDescription.Truncate();
}
--- a/accessible/src/xforms/nsXFormsWidgetsAccessible.h
+++ b/accessible/src/xforms/nsXFormsWidgetsAccessible.h
@@ -56,19 +56,19 @@ class nsXFormsComboboxPopupWidgetAccessi
{
public:
nsXFormsComboboxPopupWidgetAccessible(nsIContent* aContent,
DocAccessible* aDoc);
// Accessible
virtual void Description(nsString& aDescription);
virtual void Value(nsString& aValue);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole();
virtual uint64_t NativeState();
virtual uint64_t NativeInteractiveState() const;
protected:
// Accessible
+ virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
virtual void CacheChildren();
};
#endif
--- a/accessible/src/xul/XULElementAccessibles.cpp
+++ b/accessible/src/xul/XULElementAccessibles.cpp
@@ -27,23 +27,23 @@ using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
XULLabelAccessible::
XULLabelAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc)
{
}
-nsresult
-XULLabelAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULLabelAccessible::NativeName(nsString& aName)
{
// if the value attr doesn't exist, the screen reader must get the accessible text
// from the accessible text interface or from the children
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName);
- return NS_OK;
+ return eNameOK;
}
role
XULLabelAccessible::NativeRole()
{
return roles::LABEL;
}
@@ -116,24 +116,24 @@ NS_IMPL_ISUPPORTS_INHERITED1(XULLinkAcce
void
XULLinkAccessible::Value(nsString& aValue)
{
aValue.Truncate();
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, aValue);
}
-nsresult
-XULLinkAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULLinkAccessible::NativeName(nsString& aName)
{
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName);
- if (!aName.IsEmpty())
- return NS_OK;
+ if (aName.IsEmpty())
+ nsTextEquivUtils::GetNameFromSubtree(this, aName);
- return nsTextEquivUtils::GetNameFromSubtree(this, aName);
+ return eNameOK;
}
role
XULLinkAccessible::NativeRole()
{
return roles::LINK;
}
--- a/accessible/src/xul/XULElementAccessibles.h
+++ b/accessible/src/xul/XULElementAccessibles.h
@@ -16,20 +16,23 @@ namespace a11y {
* Used for XUL description and label elements.
*/
class XULLabelAccessible : public HyperTextAccessibleWrap
{
public:
XULLabelAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual Relation RelationByType(uint32_t aRelationType);
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Used for XUL tooltip element.
*/
class XULTooltipAccessible : public LeafAccessible
{
@@ -50,30 +53,32 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
NS_IMETHOD DoAction(uint8_t aIndex);
// Accessible
virtual void Value(nsString& aValue);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeLinkState() const;
// ActionAccessible
virtual uint8_t ActionCount();
// HyperLinkAccessible
virtual bool IsLink();
virtual uint32_t StartOffset();
virtual uint32_t EndOffset();
virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
+
enum { eAction_Jump = 0 };
};
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/src/xul/XULFormControlAccessible.cpp
+++ b/accessible/src/xul/XULFormControlAccessible.cpp
@@ -408,26 +408,26 @@ XULGroupboxAccessible::
}
role
XULGroupboxAccessible::NativeRole()
{
return roles::GROUPING;
}
-nsresult
-XULGroupboxAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULGroupboxAccessible::NativeName(nsString& aName)
{
// XXX: we use the first related accessible only.
Accessible* label =
RelationByType(nsIAccessibleRelation::RELATION_LABELLED_BY).Next();
if (label)
- return label->GetName(aName);
+ return label->Name(aName);
- return NS_OK;
+ return eNameOK;
}
Relation
XULGroupboxAccessible::RelationByType(uint32_t aType)
{
Relation rel = AccessibleWrap::RelationByType(aType);
if (aType != nsIAccessibleRelation::RELATION_LABELLED_BY)
return rel;
@@ -634,26 +634,23 @@ XULToolbarAccessible::
}
role
XULToolbarAccessible::NativeRole()
{
return roles::TOOLBAR;
}
-nsresult
-XULToolbarAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULToolbarAccessible::NativeName(nsString& aName)
{
- nsAutoString name;
- if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::toolbarname, name)) {
- name.CompressWhitespace();
- aName = name;
- }
+ if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::toolbarname, aName))
+ aName.CompressWhitespace();
- return NS_OK;
+ return eNameOK;
}
////////////////////////////////////////////////////////////////////////////////
// XULToolbarAccessible
////////////////////////////////////////////////////////////////////////////////
XULToolbarSeparatorAccessible::
--- a/accessible/src/xul/XULFormControlAccessible.h
+++ b/accessible/src/xul/XULFormControlAccessible.h
@@ -112,18 +112,21 @@ private:
*/
class XULGroupboxAccessible : public AccessibleWrap
{
public:
XULGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual mozilla::a11y::role NativeRole();
- virtual nsresult GetNameInternal(nsAString& aName);
virtual Relation RelationByType(uint32_t aRelationType);
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Used for XUL radio element (radio button).
*/
class XULRadioButtonAccessible : public RadioButtonAccessible
{
@@ -189,17 +192,20 @@ public:
*/
class XULToolbarAccessible : public AccessibleWrap
{
public:
XULToolbarAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual mozilla::a11y::role NativeRole();
- virtual nsresult GetNameInternal(nsAString& aName);
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Used for XUL toolbarseparator element.
*/
class XULToolbarSeparatorAccessible : public LeafAccessible
{
public:
--- a/accessible/src/xul/XULListboxAccessible.cpp
+++ b/accessible/src/xul/XULListboxAccessible.cpp
@@ -617,28 +617,30 @@ XULListitemAccessible::Description(nsStr
////////////////////////////////////////////////////////////////////////////////
// XULListitemAccessible. nsIAccessible
/**
* If there is a Listcell as a child ( not anonymous ) use it, otherwise
* default to getting the name from GetXULName
*/
-nsresult
-XULListitemAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULListitemAccessible::NativeName(nsString& aName)
{
nsIContent* childContent = mContent->GetFirstChild();
if (childContent) {
if (childContent->NodeInfo()->Equals(nsGkAtoms::listcell,
kNameSpaceID_XUL)) {
childContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
- return NS_OK;
+ return eNameOK;
}
}
- return GetXULName(aName);
+
+ GetXULName(aName);
+ return eNameOK;
}
role
XULListitemAccessible::NativeRole()
{
Accessible* list = GetListAccessible();
if (!list) {
NS_ERROR("No list accessible for listitem accessible!");
--- a/accessible/src/xul/XULListboxAccessible.h
+++ b/accessible/src/xul/XULListboxAccessible.h
@@ -126,26 +126,30 @@ public:
virtual ~XULListitemAccessible() {}
// nsIAccessible
NS_IMETHOD GetActionName(uint8_t index, nsAString& aName);
// Don't use XUL menuitems's description attribute
// Accessible
virtual void Description(nsString& aDesc);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual uint64_t NativeInteractiveState() const;
virtual bool CanHaveAnonChildren();
// Widgets
virtual Accessible* ContainerWidget() const;
protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
+
+ // XULListitemAccessible
+
/**
* Return listbox accessible for the listitem.
*/
Accessible* GetListAccessible();
private:
bool mIsCheckbox;
};
--- a/accessible/src/xul/XULMenuAccessible.cpp
+++ b/accessible/src/xul/XULMenuAccessible.cpp
@@ -129,21 +129,21 @@ XULMenuitemAccessible::NativeInteractive
return states::UNAVAILABLE;
return states::UNAVAILABLE | states::FOCUSABLE | states::SELECTABLE;
}
return states::FOCUSABLE | states::SELECTABLE;
}
-nsresult
-XULMenuitemAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULMenuitemAccessible::NativeName(nsString& aName)
{
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
- return NS_OK;
+ return eNameOK;
}
void
XULMenuitemAccessible::Description(nsString& aDescription)
{
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::description,
aDescription);
}
@@ -391,20 +391,20 @@ XULMenuSeparatorAccessible::
uint64_t
XULMenuSeparatorAccessible::NativeState()
{
// Isn't focusable, but can be offscreen/invisible -- only copy those states
return XULMenuitemAccessible::NativeState() &
(states::OFFSCREEN | states::INVISIBLE);
}
-nsresult
-XULMenuSeparatorAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULMenuSeparatorAccessible::NativeName(nsString& aName)
{
- return NS_OK;
+ return eNameOK;
}
role
XULMenuSeparatorAccessible::NativeRole()
{
return roles::SEPARATOR;
}
@@ -464,26 +464,26 @@ XULMenupopupAccessible::NativeState()
#endif
if (state & states::INVISIBLE)
state |= states::OFFSCREEN | states::COLLAPSED;
return state;
}
-nsresult
-XULMenupopupAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULMenupopupAccessible::NativeName(nsString& aName)
{
- nsIContent *content = mContent;
+ nsIContent* content = mContent;
while (content && aName.IsEmpty()) {
content->GetAttr(kNameSpaceID_None, nsGkAtoms::label, aName);
content = content->GetParent();
}
- return NS_OK;
+ return eNameOK;
}
role
XULMenupopupAccessible::NativeRole()
{
// If accessible is not bound to the tree (this happens while children are
// cached) return general role.
if (mParent) {
@@ -567,21 +567,21 @@ XULMenupopupAccessible::ContainerWidget(
////////////////////////////////////////////////////////////////////////////////
XULMenubarAccessible::
XULMenubarAccessible(nsIContent* aContent, DocAccessible* aDoc) :
AccessibleWrap(aContent, aDoc)
{
}
-nsresult
-XULMenubarAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULMenubarAccessible::NativeName(nsString& aName)
{
aName.AssignLiteral("Application");
- return NS_OK;
+ return eNameOK;
}
role
XULMenubarAccessible::NativeRole()
{
return roles::MENUBAR;
}
--- a/accessible/src/xul/XULMenuAccessible.h
+++ b/accessible/src/xul/XULMenuAccessible.h
@@ -24,93 +24,105 @@ public:
XULMenuitemAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD DoAction(uint8_t index);
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
// Accessible
virtual void Description(nsString& aDescription);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
virtual uint64_t NativeInteractiveState() const;
virtual int32_t GetLevelInternal();
virtual bool CanHaveAnonChildren();
// ActionAccessible
virtual uint8_t ActionCount();
virtual KeyBinding AccessKey() const;
virtual KeyBinding KeyboardShortcut() const;
// Widgets
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual Accessible* ContainerWidget() const;
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Used for XUL menuseparator element.
*/
class XULMenuSeparatorAccessible : public XULMenuitemAccessible
{
public:
XULMenuSeparatorAccessible(nsIContent* aContent, DocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD DoAction(uint8_t index);
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
// ActionAccessible
virtual uint8_t ActionCount();
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Used for XUL menupopup and panel.
*/
class XULMenupopupAccessible : public XULSelectControlAccessible
{
public:
XULMenupopupAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
virtual uint64_t NativeState();
// Widgets
virtual bool IsWidget() const;
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual Accessible* ContainerWidget() const;
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* Used for XUL menubar element.
*/
class XULMenubarAccessible : public AccessibleWrap
{
public:
XULMenubarAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
// Widget
virtual bool IsActiveWidget() const;
virtual bool AreItemsOperable() const;
virtual Accessible* CurrentItem();
virtual void SetCurrentItem(Accessible* aItem);
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
} // namespace a11y
} // namespace mozilla
#endif
--- a/accessible/src/xul/XULTabAccessible.cpp
+++ b/accessible/src/xul/XULTabAccessible.cpp
@@ -149,21 +149,21 @@ XULTabsAccessible::ActionCount()
}
void
XULTabsAccessible::Value(nsString& aValue)
{
aValue.Truncate();
}
-nsresult
-XULTabsAccessible::GetNameInternal(nsAString& aName)
+ENameValueFlag
+XULTabsAccessible::NativeName(nsString& aName)
{
// no name
- return NS_OK;
+ return eNameOK;
}
////////////////////////////////////////////////////////////////////////////////
// XULDeckAccessible
////////////////////////////////////////////////////////////////////////////////
role
--- a/accessible/src/xul/XULTabAccessible.h
+++ b/accessible/src/xul/XULTabAccessible.h
@@ -43,21 +43,24 @@ public:
*/
class XULTabsAccessible : public XULSelectControlAccessible
{
public:
XULTabsAccessible(nsIContent* aContent, DocAccessible* aDoc);
// Accessible
virtual void Value(nsString& aValue);
- virtual nsresult GetNameInternal(nsAString& aName);
virtual a11y::role NativeRole();
// ActionAccessible
virtual uint8_t ActionCount();
+
+protected:
+ // Accessible
+ virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
};
/**
* A container of tab panels, xul:tabpanels element.
*/
class XULDeckAccessible : public AccessibleWrap
{
--- a/xpcom/base/ErrorList.h
+++ b/xpcom/base/ErrorList.h
@@ -900,14 +900,11 @@
/* a11y */
/* raised when current pivot's position is needed but it's not in the tree */
ERROR(NS_ERROR_NOT_IN_TREE, FAILURE(38)),
/* see Accessible::GetAttrValue */
ERROR(NS_OK_NO_ARIA_VALUE, SUCCESS(33)),
ERROR(NS_OK_DEFUNCT_OBJECT, SUCCESS(34)),
- /* see Accessible::GetNameInternal */
- ERROR(NS_OK_EMPTY_NAME, SUCCESS(35)),
- ERROR(NS_OK_NO_NAME_CLAUSE_HANDLED, SUCCESS(36)),
- /* see Accessible::GetNameInternal */
- ERROR(NS_OK_NAME_FROM_TOOLTIP, SUCCESS(37))
+ /* see nsTextEquivUtils */
+ ERROR(NS_OK_NO_NAME_CLAUSE_HANDLED, SUCCESS(35))
#undef MODULE