Bug 1714390 - P2: Use AccAttributes for accessible and text attributes. r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D116783
This commit is contained in:
Eitan Isaacson 2021-06-10 23:07:05 +00:00
Родитель 8ede9994e3
Коммит 62d0cdcad4
57 изменённых файлов: 467 добавлений и 597 удалений

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

@ -8,6 +8,7 @@
#include "JavaBuiltins.h"
#include "LocalAccessible-inl.h"
#include "HyperTextAccessible-inl.h"
#include "AccAttributes.h"
#include "AccEvent.h"
#include "AndroidInputType.h"
#include "DocAccessibleWrap.h"
@ -19,7 +20,6 @@
#include "Platform.h"
#include "nsAccessibilityService.h"
#include "nsEventShell.h"
#include "nsPersistentProperties.h"
#include "nsIAccessibleAnnouncementEvent.h"
#include "nsAccUtils.h"
#include "nsTextEquivUtils.h"
@ -534,16 +534,14 @@ uint32_t AccessibleWrap::GetFlags(role aRole, uint64_t aState,
return flags;
}
void AccessibleWrap::GetRoleDescription(role aRole,
nsIPersistentProperties* aAttributes,
void AccessibleWrap::GetRoleDescription(role aRole, AccAttributes* aAttributes,
nsAString& aGeckoRole,
nsAString& aRoleDescription) {
if (aRole == roles::HEADING && aAttributes) {
// The heading level is an attribute, so we need that.
AutoTArray<nsString, 1> formatString;
nsresult rv = aAttributes->GetStringProperty("level"_ns,
*formatString.AppendElement());
if (NS_SUCCEEDED(rv) &&
if (aAttributes->GetAttribute(nsGkAtoms::level,
*formatString.AppendElement()) &&
LocalizeString("headingLevel", aRoleDescription, formatString)) {
return;
}
@ -551,8 +549,7 @@ void AccessibleWrap::GetRoleDescription(role aRole,
if ((aRole == roles::LANDMARK || aRole == roles::REGION) && aAttributes) {
nsAutoString xmlRoles;
if (NS_SUCCEEDED(
aAttributes->GetStringProperty("xml-roles"_ns, xmlRoles))) {
if (aAttributes->GetAttribute(nsGkAtoms::xmlroles, xmlRoles)) {
nsWhitespaceTokenizer tokenizer(xmlRoles);
while (tokenizer.hasMoreTokens()) {
if (LocalizeString(NS_ConvertUTF16toUTF8(tokenizer.nextToken()).get(),
@ -567,15 +564,13 @@ void AccessibleWrap::GetRoleDescription(role aRole,
LocalizeString(NS_ConvertUTF16toUTF8(aGeckoRole).get(), aRoleDescription);
}
already_AddRefed<nsIPersistentProperties>
AccessibleWrap::AttributeArrayToProperties(
already_AddRefed<AccAttributes> AccessibleWrap::AttributeArrayToProperties(
const nsTArray<Attribute>& aAttributes) {
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
nsAutoString unused;
RefPtr<AccAttributes> props = new AccAttributes();
for (size_t i = 0; i < aAttributes.Length(); i++) {
props->SetStringProperty(aAttributes.ElementAt(i).Name(),
aAttributes.ElementAt(i).Value(), unused);
props->SetAttribute(NS_ConvertUTF8toUTF16(aAttributes.ElementAt(i).Name()),
aAttributes.ElementAt(i).Value());
}
return props.forget();
@ -671,7 +666,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(bool aSmall) {
double step = UnspecifiedNaN<double>();
WrapperRangeInfo(&curValue, &minValue, &maxValue, &step);
nsCOMPtr<nsIPersistentProperties> attributes = Attributes();
RefPtr<AccAttributes> attributes = Attributes();
return ToBundle(State(), Bounds(), ActionCount(), name, textValue, nodeID,
description, curValue, minValue, maxValue, step, attributes);
@ -682,7 +677,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
const nsString& aName, const nsString& aTextValue,
const nsString& aDOMNodeID, const nsString& aDescription,
const double& aCurVal, const double& aMinVal, const double& aMaxVal,
const double& aStep, nsIPersistentProperties* aAttributes) {
const double& aStep, AccAttributes* aAttributes) {
if (!IsProxy() && IsDefunct()) {
return nullptr;
}
@ -792,8 +787,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
if (aAttributes) {
nsString inputTypeAttr;
nsAccUtils::GetAccAttr(aAttributes, nsGkAtoms::textInputType,
inputTypeAttr);
aAttributes->GetAttribute(nsGkAtoms::textInputType, inputTypeAttr);
int32_t inputType = GetInputType(inputTypeAttr);
if (inputType) {
GECKOBUNDLE_PUT(nodeInfo, "inputType",
@ -801,8 +795,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
}
nsString posinset;
nsresult rv = aAttributes->GetStringProperty("posinset"_ns, posinset);
if (NS_SUCCEEDED(rv)) {
if (aAttributes->GetAttribute(nsGkAtoms::posinset, posinset)) {
int32_t rowIndex;
if (sscanf(NS_ConvertUTF16toUTF8(posinset).get(), "%d", &rowIndex) > 0) {
GECKOBUNDLE_START(collectionItemInfo);
@ -821,8 +814,8 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
}
nsString colSize;
rv = aAttributes->GetStringProperty("child-item-count"_ns, colSize);
if (NS_SUCCEEDED(rv)) {
RefPtr<nsAtom> attrAtom = NS_Atomize("child-item-count"_ns);
if (aAttributes->GetAttribute(attrAtom, colSize)) {
int32_t rowCount;
if (sscanf(NS_ConvertUTF16toUTF8(colSize).get(), "%d", &rowCount) > 0) {
GECKOBUNDLE_START(collectionInfo);
@ -831,9 +824,8 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
GECKOBUNDLE_PUT(collectionInfo, "columnCount",
java::sdk::Integer::ValueOf(1));
nsString unused;
rv = aAttributes->GetStringProperty("hierarchical"_ns, unused);
if (NS_SUCCEEDED(rv)) {
attrAtom = NS_Atomize("hierarchical"_ns);
if (aAttributes->HasAttribute(attrAtom)) {
GECKOBUNDLE_PUT(collectionInfo, "isHierarchical",
java::sdk::Boolean::TRUE());
}
@ -895,10 +887,9 @@ bool AccessibleWrap::HandleLiveRegionEvent(AccEvent* aEvent) {
return false;
}
nsCOMPtr<nsIPersistentProperties> attributes = Attributes();
RefPtr<AccAttributes> attributes = Attributes();
nsString live;
nsresult rv = attributes->GetStringProperty("container-live"_ns, live);
if (!NS_SUCCEEDED(rv)) {
if (!attributes->GetAttribute(nsGkAtoms::containerLive, live)) {
return false;
}
@ -907,7 +898,7 @@ bool AccessibleWrap::HandleLiveRegionEvent(AccEvent* aEvent) {
: nsIAccessibleAnnouncementEvent::POLITE;
nsString atomic;
rv = attributes->GetStringProperty("container-atomic"_ns, atomic);
attributes->GetAttribute(nsGkAtoms::containerAtomic, atomic);
LocalAccessible* announcementTarget = this;
nsAutoString announcement;

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

@ -63,7 +63,7 @@ class AccessibleWrap : public LocalAccessible {
const double& aMinVal = UnspecifiedNaN<double>(),
const double& aMaxVal = UnspecifiedNaN<double>(),
const double& aStep = UnspecifiedNaN<double>(),
nsIPersistentProperties* aAttributes = nullptr);
AccAttributes* aAttributes = nullptr);
virtual void WrapperDOMNodeID(nsString& aDOMNodeID);
@ -72,7 +72,7 @@ class AccessibleWrap : public LocalAccessible {
: GetAndroidClass(WrapperRole());
}
static already_AddRefed<nsIPersistentProperties> AttributeArrayToProperties(
static already_AddRefed<AccAttributes> AttributeArrayToProperties(
const nsTArray<Attribute>& aAttributes);
static const int32_t kNoID = -1;
@ -104,8 +104,7 @@ class AccessibleWrap : public LocalAccessible {
void GetSelectionOrCaret(int32_t* aStartOffset, int32_t* aEndOffset);
static void GetRoleDescription(role aRole,
nsIPersistentProperties* aAttributes,
static void GetRoleDescription(role aRole, AccAttributes* aAttributes,
nsAString& aGeckoRole,
nsAString& aRoleDescription);

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

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "LocalAccessible-inl.h"
#include "AccAttributes.h"
#include "AccessibleOrProxy.h"
#include "DocAccessibleChild.h"
#include "DocAccessibleWrap.h"
@ -13,7 +14,6 @@
#include "nsLayoutUtils.h"
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "nsIPersistentProperties2.h"
#include "Pivot.h"
#include "SessionAccessibility.h"
#include "TraversalRule.h"
@ -239,7 +239,7 @@ void DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible) {
acc->WrapperDOMNodeID(nodeID);
nsAutoString description;
acc->Description(description);
nsCOMPtr<nsIPersistentProperties> props = acc->Attributes();
RefPtr<AccAttributes> props = acc->Attributes();
nsTArray<Attribute> attributes;
nsAccUtils::PersistentPropertiesToArray(props, &attributes);
cacheData.AppendElement(

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

@ -6,8 +6,6 @@
#include "RemoteAccessibleWrap.h"
#include "LocalAccessible-inl.h"
#include "nsPersistentProperties.h"
#include "mozilla/a11y/DocAccessiblePlatformExtParent.h"
using namespace mozilla::a11y;
@ -52,7 +50,7 @@ void RemoteAccessibleWrap::Shutdown() {
// LocalAccessible
already_AddRefed<nsIPersistentProperties> RemoteAccessibleWrap::Attributes() {
already_AddRefed<AccAttributes> RemoteAccessibleWrap::Attributes() {
AutoTArray<Attribute, 10> attrs;
Proxy()->Attributes(&attrs);
return AttributeArrayToProperties(attrs);

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

@ -29,7 +29,7 @@ class RemoteAccessibleWrap : public AccessibleWrap {
// LocalAccessible
virtual already_AddRefed<nsIPersistentProperties> Attributes() override;
virtual already_AddRefed<AccAttributes> Attributes() override;
virtual uint32_t ChildCount() const override;

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

@ -8,13 +8,13 @@
#include "AndroidUiThread.h"
#include "DocAccessibleParent.h"
#include "nsThreadUtils.h"
#include "AccAttributes.h"
#include "AccessibilityEvent.h"
#include "HyperTextAccessible.h"
#include "JavaBuiltins.h"
#include "RootAccessibleWrap.h"
#include "nsAccessibilityService.h"
#include "nsViewManager.h"
#include "nsIPersistentProperties2.h"
#include "mozilla/PresShell.h"
#include "mozilla/dom/BrowserParent.h"
@ -416,7 +416,7 @@ void SessionAccessibility::ReplaceFocusPathCache(
if (aData.Length() == aAccessibles.Length()) {
const BatchData& data = aData.ElementAt(i);
nsCOMPtr<nsIPersistentProperties> props =
RefPtr<AccAttributes> props =
AccessibleWrap::AttributeArrayToProperties(data.Attributes());
auto bundle =
acc->ToBundle(data.State(), data.Bounds(), data.ActionCount(),

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

@ -9,9 +9,9 @@
#include "mozilla/dom/DOMStringList.h"
#include "mozilla/StaticPrefs_accessibility.h"
#include "nsContentUtils.h"
#include "nsIPersistentProperties2.h"
#include "nsISimpleEnumerator.h"
#include "AccAttributes.h"
#include "LocalAccessible-inl.h"
#include "nsAccessibilityService.h"
#include "DocAccessible.h"
@ -104,21 +104,10 @@ void AccessibleNode::GetAttributes(nsTArray<nsString>& aAttributes) {
return;
}
nsCOMPtr<nsIPersistentProperties> attrs = mIntl->Attributes();
RefPtr<AccAttributes> attrs = mIntl->Attributes();
nsCOMPtr<nsISimpleEnumerator> props;
attrs->Enumerate(getter_AddRefs(props));
bool hasMore = false;
while (NS_SUCCEEDED(props->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> supp;
props->GetNext(getter_AddRefs(supp));
nsCOMPtr<nsIPropertyElement> prop(do_QueryInterface(supp));
nsAutoCString attr;
prop->GetKey(attr);
aAttributes.AppendElement(NS_ConvertUTF8toUTF16(attr));
for (auto iter : *attrs) {
aAttributes.AppendElement(nsAtomString(iter.Name()));
}
}
@ -153,11 +142,10 @@ bool AccessibleNode::Has(const Sequence<nsString>& aAttributes) {
if (!mIntl) {
return false;
}
nsCOMPtr<nsIPersistentProperties> attrs = mIntl->Attributes();
RefPtr<AccAttributes> attrs = mIntl->Attributes();
for (const auto& attr : aAttributes) {
bool has = false;
attrs->Has(NS_ConvertUTF16toUTF8(attr).get(), &has);
if (!has) {
RefPtr<nsAtom> attrAtom = NS_Atomize(attr);
if (!attrs->HasAttribute(attrAtom)) {
return false;
}
}
@ -172,11 +160,11 @@ void AccessibleNode::Get(JSContext* aCX, const nsAString& aAttribute,
return;
}
nsCOMPtr<nsIPersistentProperties> attrs = mIntl->Attributes();
nsAutoString value;
attrs->GetStringProperty(NS_ConvertUTF16toUTF8(aAttribute), value);
if (!ToJSValue(aCX, value, aValue)) {
RefPtr<nsAtom> attrAtom = NS_Atomize(aAttribute);
RefPtr<AccAttributes> attrs = mIntl->Attributes();
nsAutoString valueStr;
attrs->GetAttribute(attrAtom, valueStr);
if (!ToJSValue(aCX, valueStr, aValue)) {
aRv.NoteJSContextException(aCX);
return;
}

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

@ -7,6 +7,7 @@
#include "AccessibleWrap.h"
#include "LocalAccessible-inl.h"
#include "AccAttributes.h"
#include "ApplicationAccessibleWrap.h"
#include "InterfaceInitFuncs.h"
#include "nsAccUtils.h"
@ -30,7 +31,6 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/Sprintf.h"
#include "nsComponentManagerUtils.h"
#include "nsIPersistentProperties2.h"
using namespace mozilla;
using namespace mozilla::a11y;
@ -635,39 +635,21 @@ AtkRole getRoleCB(AtkObject* aAtkObj) {
return aAtkObj->role;
}
static AtkAttributeSet* ConvertToAtkAttributeSet(
nsIPersistentProperties* aAttributes) {
if (!aAttributes) return nullptr;
static AtkAttributeSet* ConvertToAtkAttributeSet(AccAttributes* aAttributes) {
AtkAttributeSet* objAttributeSet = nullptr;
nsCOMPtr<nsISimpleEnumerator> propEnum;
nsresult rv = aAttributes->Enumerate(getter_AddRefs(propEnum));
NS_ENSURE_SUCCESS(rv, nullptr);
bool hasMore;
while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> sup;
rv = propEnum->GetNext(getter_AddRefs(sup));
NS_ENSURE_SUCCESS(rv, objAttributeSet);
nsCOMPtr<nsIPropertyElement> propElem(do_QueryInterface(sup));
NS_ENSURE_TRUE(propElem, objAttributeSet);
nsAutoCString name;
rv = propElem->GetKey(name);
NS_ENSURE_SUCCESS(rv, objAttributeSet);
nsAutoString value;
rv = propElem->GetValue(value);
NS_ENSURE_SUCCESS(rv, objAttributeSet);
// On ATK, the placeholder attribute is called placeholder-text.
if (name.Equals("placeholder")) {
name.AssignLiteral("placeholder-text");
for (auto iter : *aAttributes) {
nsAutoString name;
iter.NameAsString(name);
if (name.Equals(u"placeholder")) {
name.AssignLiteral(u"placeholder-text");
}
nsAutoString value;
iter.ValueAsString(value);
AtkAttribute* objAttr = (AtkAttribute*)g_malloc(sizeof(AtkAttribute));
objAttr->name = g_strdup(name.get());
objAttr->name = g_strdup(NS_ConvertUTF16toUTF8(name).get());
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(value).get());
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);
}
@ -677,10 +659,8 @@ static AtkAttributeSet* ConvertToAtkAttributeSet(
}
AtkAttributeSet* GetAttributeSet(LocalAccessible* aAccessible) {
nsCOMPtr<nsIPersistentProperties> attributes = aAccessible->Attributes();
if (attributes) return ConvertToAtkAttributeSet(attributes);
return nullptr;
RefPtr<AccAttributes> attributes = aAccessible->Attributes();
return ConvertToAtkAttributeSet(attributes);
}
AtkAttributeSet* getAttributesCB(AtkObject* aAtkObj) {

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

@ -10,9 +10,9 @@
#include "HyperTextAccessible-inl.h"
#include "nsMai.h"
#include "RemoteAccessible.h"
#include "AccAttributes.h"
#include "nsIAccessibleTypes.h"
#include "nsIPersistentProperties2.h"
#include "nsISimpleEnumerator.h"
#include "nsUTF8Utils.h"
@ -83,37 +83,20 @@ static AtkAttributeSet* ConvertToAtkTextAttributeSet(
}
static AtkAttributeSet* ConvertToAtkTextAttributeSet(
nsIPersistentProperties* aAttributes) {
if (!aAttributes) return nullptr;
AccAttributes* aAttributes) {
AtkAttributeSet* objAttributeSet = nullptr;
nsCOMPtr<nsISimpleEnumerator> propEnum;
nsresult rv = aAttributes->Enumerate(getter_AddRefs(propEnum));
NS_ENSURE_SUCCESS(rv, nullptr);
bool hasMore = false;
while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> sup;
rv = propEnum->GetNext(getter_AddRefs(sup));
NS_ENSURE_SUCCESS(rv, objAttributeSet);
nsCOMPtr<nsIPropertyElement> propElem(do_QueryInterface(sup));
NS_ENSURE_TRUE(propElem, objAttributeSet);
nsAutoCString name;
rv = propElem->GetKey(name);
NS_ENSURE_SUCCESS(rv, objAttributeSet);
for (auto iter : *aAttributes) {
nsAutoString name;
iter.NameAsString(name);
nsAutoString value;
rv = propElem->GetValue(value);
NS_ENSURE_SUCCESS(rv, objAttributeSet);
iter.ValueAsString(value);
AtkAttribute* objAttr = (AtkAttribute*)g_malloc(sizeof(AtkAttribute));
objAttr->name = g_strdup(name.get());
objAttr->name = g_strdup(NS_ConvertUTF16toUTF8(name).get());
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(value).get());
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);
ConvertTextAttributeToAtkAttribute(name, value, &objAttributeSet);
}
// libatk-adaptor will free it
@ -314,7 +297,7 @@ static AtkAttributeSet* getRunAttributesCB(AtkText* aText, gint aOffset,
return nullptr;
}
nsCOMPtr<nsIPersistentProperties> attributes =
RefPtr<AccAttributes> attributes =
text->TextAttributes(false, aOffset, &startOffset, &endOffset);
*aStartOffset = startOffset;
@ -343,8 +326,7 @@ static AtkAttributeSet* getDefaultAttributesCB(AtkText* aText) {
return nullptr;
}
nsCOMPtr<nsIPersistentProperties> attributes =
text->DefaultTextAttributes();
RefPtr<AccAttributes> attributes = text->DefaultTextAttributes();
return ConvertToAtkTextAttributeSet(attributes);
}

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

@ -11,6 +11,8 @@
#include "TextLeafAccessible.h"
#include "TextUpdater.h"
#include "nsIContentInlines.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/Element.h"
#include "mozilla/PresShell.h"

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

@ -6,6 +6,7 @@
#include "TextAttrs.h"
#include "LocalAccessible-inl.h"
#include "AccAttributes.h"
#include "nsAccUtils.h"
#include "nsCoreUtils.h"
#include "StyleInfo.h"
@ -26,7 +27,7 @@ using namespace mozilla::a11y;
// TextAttrsMgr
////////////////////////////////////////////////////////////////////////////////
void TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
void TextAttrsMgr::GetAttributes(AccAttributes* aAttributes,
uint32_t* aStartOffset, uint32_t* aEndOffset) {
// 1. Hyper text accessible must be specified always.
// 2. Offset accessible and result hyper text offsets must be specified in
@ -214,9 +215,9 @@ bool TextAttrsMgr::LangTextAttr::GetValueFor(LocalAccessible* aAccessible,
return !aValue->IsEmpty();
}
void TextAttrsMgr::LangTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nsString& aValue) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::language, aValue);
void TextAttrsMgr::LangTextAttr::ExposeValue(AccAttributes* aAttributes,
const nsString& aValue) {
aAttributes->SetAttribute(nsGkAtoms::language, aValue);
}
////////////////////////////////////////////////////////////////////////////////
@ -236,23 +237,23 @@ bool TextAttrsMgr::InvalidTextAttr::GetValueFor(LocalAccessible* aAccessible,
return elm ? GetValue(elm, aValue) : false;
}
void TextAttrsMgr::InvalidTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const uint32_t& aValue) {
void TextAttrsMgr::InvalidTextAttr::ExposeValue(AccAttributes* aAttributes,
const uint32_t& aValue) {
switch (aValue) {
case eFalse:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"false"_ns);
aAttributes->SetAttribute(nsGkAtoms::invalid, u"false"_ns);
break;
case eGrammar:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"grammar"_ns);
aAttributes->SetAttribute(nsGkAtoms::invalid, u"grammar"_ns);
break;
case eSpelling:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"spelling"_ns);
aAttributes->SetAttribute(nsGkAtoms::invalid, u"spelling"_ns);
break;
case eTrue:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"true"_ns);
aAttributes->SetAttribute(nsGkAtoms::invalid, u"true"_ns);
break;
}
}
@ -310,12 +311,11 @@ bool TextAttrsMgr::BGColorTextAttr::GetValueFor(LocalAccessible* aAccessible,
return false;
}
void TextAttrsMgr::BGColorTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nscolor& aValue) {
void TextAttrsMgr::BGColorTextAttr::ExposeValue(AccAttributes* aAttributes,
const nscolor& aValue) {
nsAutoString formattedValue;
StyleInfo::FormatColor(aValue, formattedValue);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::backgroundColor,
formattedValue);
aAttributes->SetAttribute(nsGkAtoms::backgroundColor, formattedValue);
}
bool TextAttrsMgr::BGColorTextAttr::GetColor(nsIFrame* aFrame,
@ -368,11 +368,11 @@ bool TextAttrsMgr::ColorTextAttr::GetValueFor(LocalAccessible* aAccessible,
return false;
}
void TextAttrsMgr::ColorTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nscolor& aValue) {
void TextAttrsMgr::ColorTextAttr::ExposeValue(AccAttributes* aAttributes,
const nscolor& aValue) {
nsAutoString formattedValue;
StyleInfo::FormatColor(aValue, formattedValue);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::color, formattedValue);
aAttributes->SetAttribute(nsGkAtoms::color, formattedValue);
}
////////////////////////////////////////////////////////////////////////////////
@ -399,9 +399,9 @@ bool TextAttrsMgr::FontFamilyTextAttr::GetValueFor(LocalAccessible* aAccessible,
return false;
}
void TextAttrsMgr::FontFamilyTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nsString& aValue) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_family, aValue);
void TextAttrsMgr::FontFamilyTextAttr::ExposeValue(AccAttributes* aAttributes,
const nsString& aValue) {
aAttributes->SetAttribute(nsGkAtoms::font_family, aValue);
}
bool TextAttrsMgr::FontFamilyTextAttr::GetFontFamily(nsIFrame* aFrame,
@ -447,8 +447,8 @@ bool TextAttrsMgr::FontSizeTextAttr::GetValueFor(LocalAccessible* aAccessible,
return false;
}
void TextAttrsMgr::FontSizeTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const nscoord& aValue) {
void TextAttrsMgr::FontSizeTextAttr::ExposeValue(AccAttributes* aAttributes,
const nscoord& aValue) {
// Convert from nscoord to pt.
//
// Note: according to IA2, "The conversion doesn't have to be exact.
@ -465,7 +465,7 @@ void TextAttrsMgr::FontSizeTextAttr::ExposeValue(
value.AppendInt(pts);
value.AppendLiteral("pt");
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_size, value);
aAttributes->SetAttribute(nsGkAtoms::font_size, value);
}
////////////////////////////////////////////////////////////////////////////////
@ -498,10 +498,10 @@ bool TextAttrsMgr::FontStyleTextAttr::GetValueFor(LocalAccessible* aAccessible,
}
void TextAttrsMgr::FontStyleTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const FontSlantStyle& aValue) {
AccAttributes* aAttributes, const FontSlantStyle& aValue) {
nsAutoString string;
nsStyleUtil::AppendFontSlantStyle(aValue, string);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::font_style, string);
aAttributes->SetAttribute(nsGkAtoms::font_style, string);
}
////////////////////////////////////////////////////////////////////////////////
@ -533,12 +533,12 @@ bool TextAttrsMgr::FontWeightTextAttr::GetValueFor(LocalAccessible* aAccessible,
return false;
}
void TextAttrsMgr::FontWeightTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const FontWeight& aValue) {
void TextAttrsMgr::FontWeightTextAttr::ExposeValue(AccAttributes* aAttributes,
const FontWeight& aValue) {
nsAutoString formattedValue;
formattedValue.AppendFloat(aValue.ToFloat());
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::fontWeight, formattedValue);
aAttributes->SetAttribute(nsGkAtoms::fontWeight, formattedValue);
}
FontWeight TextAttrsMgr::FontWeightTextAttr::GetFontWeight(nsIFrame* aFrame) {
@ -592,9 +592,9 @@ bool TextAttrsMgr::AutoGeneratedTextAttr::GetValueFor(
}
void TextAttrsMgr::AutoGeneratedTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const bool& aValue) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::auto_generated,
aValue ? u"true"_ns : u"false"_ns);
AccAttributes* aAttributes, const bool& aValue) {
aAttributes->SetAttribute(nsGkAtoms::auto_generated,
aValue ? u"true"_ns : u"false"_ns);
}
////////////////////////////////////////////////////////////////////////////////
@ -636,30 +636,26 @@ bool TextAttrsMgr::TextDecorTextAttr::GetValueFor(LocalAccessible* aAccessible,
}
void TextAttrsMgr::TextDecorTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const TextDecorValue& aValue) {
AccAttributes* aAttributes, const TextDecorValue& aValue) {
if (aValue.IsUnderline()) {
nsAutoString formattedStyle;
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textUnderlineStyle,
formattedStyle);
aAttributes->SetAttribute(nsGkAtoms::textUnderlineStyle, formattedStyle);
nsAutoString formattedColor;
StyleInfo::FormatColor(aValue.Color(), formattedColor);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textUnderlineColor,
formattedColor);
aAttributes->SetAttribute(nsGkAtoms::textUnderlineColor, formattedColor);
return;
}
if (aValue.IsLineThrough()) {
nsAutoString formattedStyle;
StyleInfo::FormatTextDecorationStyle(aValue.Style(), formattedStyle);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textLineThroughStyle,
formattedStyle);
aAttributes->SetAttribute(nsGkAtoms::textLineThroughStyle, formattedStyle);
nsAutoString formattedColor;
StyleInfo::FormatColor(aValue.Color(), formattedColor);
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textLineThroughColor,
formattedColor);
aAttributes->SetAttribute(nsGkAtoms::textLineThroughColor, formattedColor);
}
}
@ -692,20 +688,19 @@ bool TextAttrsMgr::TextPosTextAttr::GetValueFor(LocalAccessible* aAccessible,
return false;
}
void TextAttrsMgr::TextPosTextAttr::ExposeValue(
nsIPersistentProperties* aAttributes, const TextPosValue& aValue) {
void TextAttrsMgr::TextPosTextAttr::ExposeValue(AccAttributes* aAttributes,
const TextPosValue& aValue) {
switch (aValue) {
case eTextPosBaseline:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition,
u"baseline"_ns);
aAttributes->SetAttribute(nsGkAtoms::textPosition, u"baseline"_ns);
break;
case eTextPosSub:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, u"sub"_ns);
aAttributes->SetAttribute(nsGkAtoms::textPosition, u"sub"_ns);
break;
case eTextPosSuper:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::textPosition, u"super"_ns);
aAttributes->SetAttribute(nsGkAtoms::textPosition, u"super"_ns);
break;
case eTextPosNone:

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

@ -13,13 +13,13 @@
#include "nsStyleConsts.h"
class nsIFrame;
class nsIPersistentProperties;
class nsIContent;
class nsDeviceContext;
namespace mozilla {
namespace a11y {
class AccAttributes;
class LocalAccessible;
class HyperTextAccessible;
@ -71,7 +71,7 @@ class TextAttrsMgr {
* @param aStartHTOffset [out, optional] start hyper text offset
* @param aEndHTOffset [out, optional] end hyper text offset
*/
void GetAttributes(nsIPersistentProperties* aAttributes,
void GetAttributes(AccAttributes* aAttributes,
uint32_t* aStartHTOffset = nullptr,
uint32_t* aEndHTOffset = nullptr);
@ -109,7 +109,7 @@ class TextAttrsMgr {
* @param aIncludeDefAttrValue [in] if true then attribute is exposed even
* if its value is the same as default one
*/
virtual void Expose(nsIPersistentProperties* aAttributes,
virtual void Expose(AccAttributes* aAttributes,
bool aIncludeDefAttrValue) = 0;
/**
@ -128,7 +128,7 @@ class TextAttrsMgr {
explicit TTextAttr(bool aGetRootValue) : mGetRootValue(aGetRootValue) {}
// TextAttr
virtual void Expose(nsIPersistentProperties* aAttributes,
virtual void Expose(AccAttributes* aAttributes,
bool aIncludeDefAttrValue) override {
if (mGetRootValue) {
if (mIsRootDefined) ExposeValue(aAttributes, mRootNativeValue);
@ -162,8 +162,7 @@ class TextAttrsMgr {
protected:
// Expose the text attribute with the given value to attribute set.
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
const T& aValue) = 0;
virtual void ExposeValue(AccAttributes* aAttributes, const T& aValue) = 0;
// Return native value for the given DOM element.
virtual bool GetValueFor(LocalAccessible* aAccessible, T* aValue) = 0;
@ -196,7 +195,7 @@ class TextAttrsMgr {
// TextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
nsString* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const nsString& aValue) override;
private:
@ -220,7 +219,7 @@ class TextAttrsMgr {
// TextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
uint32_t* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const uint32_t& aValue) override;
private:
@ -240,7 +239,7 @@ class TextAttrsMgr {
// TextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
nscolor* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const nscolor& aValue) override;
private:
@ -260,7 +259,7 @@ class TextAttrsMgr {
// TTextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
nscolor* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const nscolor& aValue) override;
};
@ -276,7 +275,7 @@ class TextAttrsMgr {
// TTextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
nsString* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const nsString& aValue) override;
private:
@ -295,7 +294,7 @@ class TextAttrsMgr {
// TTextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
nscoord* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const nscoord& aValue) override;
private:
@ -314,7 +313,7 @@ class TextAttrsMgr {
// TTextAttr
virtual bool GetValueFor(LocalAccessible* aContent,
mozilla::FontSlantStyle* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const mozilla::FontSlantStyle& aValue) override;
};
@ -330,7 +329,7 @@ class TextAttrsMgr {
// TTextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
mozilla::FontWeight* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const mozilla::FontWeight& aValue) override;
private:
@ -350,7 +349,7 @@ class TextAttrsMgr {
// TextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
bool* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const bool& aValue) override;
};
@ -400,7 +399,7 @@ class TextAttrsMgr {
// TextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
TextDecorValue* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const TextDecorValue& aValue) override;
};
@ -424,7 +423,7 @@ class TextAttrsMgr {
// TextAttr
virtual bool GetValueFor(LocalAccessible* aAccessible,
TextPosValue* aValue) override;
virtual void ExposeValue(nsIPersistentProperties* aAttributes,
virtual void ExposeValue(AccAttributes* aAttributes,
const TextPosValue& aValue) override;
private:

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

@ -6,6 +6,7 @@
#include "nsAccUtils.h"
#include "LocalAccessible-inl.h"
#include "AccAttributes.h"
#include "ARIAMap.h"
#include "nsAccessibilityService.h"
#include "nsCoreUtils.h"
@ -17,7 +18,6 @@
#include "TextLeafAccessible.h"
#include "nsIDOMXULContainerElement.h"
#include "nsIPersistentProperties2.h"
#include "nsISimpleEnumerator.h"
#include "mozilla/a11y/PDocAccessibleChild.h"
#include "mozilla/dom/Document.h"
@ -27,45 +27,23 @@
using namespace mozilla;
using namespace mozilla::a11y;
void nsAccUtils::GetAccAttr(nsIPersistentProperties* aAttributes,
nsAtom* aAttrName, nsAString& aAttrValue) {
aAttrValue.Truncate();
aAttributes->GetStringProperty(nsAtomCString(aAttrName), aAttrValue);
}
void nsAccUtils::SetAccAttr(nsIPersistentProperties* aAttributes,
nsAtom* aAttrName, const nsAString& aAttrValue) {
nsAutoString oldValue;
aAttributes->SetStringProperty(nsAtomCString(aAttrName), aAttrValue,
oldValue);
}
void nsAccUtils::SetAccAttr(nsIPersistentProperties* aAttributes,
nsAtom* aAttrName, nsAtom* aAttrValue) {
nsAutoString oldValue;
aAttributes->SetStringProperty(nsAtomCString(aAttrName),
nsAtomString(aAttrValue), oldValue);
}
void nsAccUtils::SetAccGroupAttrs(nsIPersistentProperties* aAttributes,
int32_t aLevel, int32_t aSetSize,
int32_t aPosInSet) {
void nsAccUtils::SetAccGroupAttrs(AccAttributes* aAttributes, int32_t aLevel,
int32_t aSetSize, int32_t aPosInSet) {
nsAutoString value;
if (aLevel) {
value.AppendInt(aLevel);
SetAccAttr(aAttributes, nsGkAtoms::level, value);
aAttributes->SetAttribute(nsGkAtoms::level, value);
}
if (aSetSize && aPosInSet) {
value.Truncate();
value.AppendInt(aPosInSet);
SetAccAttr(aAttributes, nsGkAtoms::posinset, value);
aAttributes->SetAttribute(nsGkAtoms::posinset, value);
value.Truncate();
value.AppendInt(aSetSize);
SetAccAttr(aAttributes, nsGkAtoms::setsize, value);
aAttributes->SetAttribute(nsGkAtoms::setsize, value);
}
}
@ -117,8 +95,8 @@ int32_t nsAccUtils::GetLevelForXULContainerItem(nsIContent* aContent) {
return level;
}
void nsAccUtils::SetLiveContainerAttributes(
nsIPersistentProperties* aAttributes, nsIContent* aStartContent) {
void nsAccUtils::SetLiveContainerAttributes(AccAttributes* aAttributes,
nsIContent* aStartContent) {
nsAutoString live, relevant, busy;
dom::Document* doc = aStartContent->GetComposedDoc();
if (!doc) {
@ -132,7 +110,7 @@ void nsAccUtils::SetLiveContainerAttributes(
HasDefinedARIAToken(ancestor, nsGkAtoms::aria_relevant) &&
ancestor->AsElement()->GetAttr(kNameSpaceID_None,
nsGkAtoms::aria_relevant, relevant)) {
SetAccAttr(aAttributes, nsGkAtoms::containerRelevant, relevant);
aAttributes->SetAttribute(nsGkAtoms::containerRelevant, relevant);
}
// container-live, and container-live-role attributes
@ -152,10 +130,10 @@ void nsAccUtils::SetLiveContainerAttributes(
}
if (!live.IsEmpty()) {
SetAccAttr(aAttributes, nsGkAtoms::containerLive, live);
aAttributes->SetAttribute(nsGkAtoms::containerLive, live);
if (role) {
SetAccAttr(aAttributes, nsGkAtoms::containerLiveRole,
role->ARIARoleString());
aAttributes->SetAttribute(nsGkAtoms::containerLiveRole,
role->ARIARoleString());
}
}
}
@ -164,14 +142,14 @@ void nsAccUtils::SetLiveContainerAttributes(
if (ancestor->IsElement() && ancestor->AsElement()->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::aria_atomic,
nsGkAtoms::_true, eCaseMatters)) {
SetAccAttr(aAttributes, nsGkAtoms::containerAtomic, u"true"_ns);
aAttributes->SetAttribute(nsGkAtoms::containerAtomic, u"true"_ns);
}
// container-busy attribute
if (busy.IsEmpty() && HasDefinedARIAToken(ancestor, nsGkAtoms::aria_busy) &&
ancestor->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_busy,
busy)) {
SetAccAttr(aAttributes, nsGkAtoms::containerBusy, busy);
aAttributes->SetAttribute(nsGkAtoms::containerBusy, busy);
}
if (ancestor == topEl) {
@ -443,33 +421,17 @@ bool nsAccUtils::MustPrune(AccessibleOrProxy aAccessible) {
return childRole == roles::TEXT_LEAF || childRole == roles::STATICTEXT;
}
bool nsAccUtils::PersistentPropertiesToArray(nsIPersistentProperties* aProps,
bool nsAccUtils::PersistentPropertiesToArray(AccAttributes* aProps,
nsTArray<Attribute>* aAttributes) {
if (!aProps) {
return true;
}
nsCOMPtr<nsISimpleEnumerator> propEnum;
nsresult rv = aProps->Enumerate(getter_AddRefs(propEnum));
NS_ENSURE_SUCCESS(rv, false);
bool hasMore;
while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> sup;
rv = propEnum->GetNext(getter_AddRefs(sup));
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIPropertyElement> propElem(do_QueryInterface(sup));
NS_ENSURE_TRUE(propElem, false);
nsAutoCString name;
rv = propElem->GetKey(name);
NS_ENSURE_SUCCESS(rv, false);
for (auto iter : *aProps) {
nsAutoString name;
iter.NameAsString(name);
nsAutoString value;
rv = propElem->GetValue(value);
NS_ENSURE_SUCCESS(rv, false);
iter.ValueAsString(value);
aAttributes->AppendElement(Attribute(name, value));
aAttributes->AppendElement(
Attribute(NS_ConvertUTF16toUTF8(name), value));
}
return true;

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

@ -32,35 +32,11 @@ class Attribute;
class nsAccUtils {
public:
/**
* Returns value of attribute from the given attributes container.
*
* @param aAttributes - attributes container
* @param aAttrName - the name of requested attribute
* @param aAttrValue - value of attribute
*/
static void GetAccAttr(nsIPersistentProperties* aAttributes,
nsAtom* aAttrName, nsAString& aAttrValue);
/**
* Set value of attribute for the given attributes container.
*
* @param aAttributes - attributes container
* @param aAttrName - the name of requested attribute
* @param aAttrValue - new value of attribute
*/
static void SetAccAttr(nsIPersistentProperties* aAttributes,
nsAtom* aAttrName, const nsAString& aAttrValue);
static void SetAccAttr(nsIPersistentProperties* aAttributes,
nsAtom* aAttrName, nsAtom* aAttrValue);
/**
* Set group attributes ('level', 'setsize', 'posinset').
*/
static void SetAccGroupAttrs(nsIPersistentProperties* aAttributes,
int32_t aLevel, int32_t aSetSize,
int32_t aPosInSet);
static void SetAccGroupAttrs(AccAttributes* aAttributes, int32_t aLevel,
int32_t aSetSize, int32_t aPosInSet);
/**
* Get default value of the level for the given accessible.
@ -84,7 +60,7 @@ class nsAccUtils {
* @param aAttributes where to store the attributes
* @param aStartContent node to start from
*/
static void SetLiveContainerAttributes(nsIPersistentProperties* aAttributes,
static void SetLiveContainerAttributes(AccAttributes* aAttributes,
nsIContent* aStartContent);
/**
@ -254,7 +230,7 @@ class nsAccUtils {
*/
static bool MustPrune(AccessibleOrProxy aAccessible);
static bool PersistentPropertiesToArray(nsIPersistentProperties* aProps,
static bool PersistentPropertiesToArray(AccAttributes* aProps,
nsTArray<Attribute>* aAttributes);
/**

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

@ -6,6 +6,7 @@
#include "nsAccessibilityService.h"
// NOTE: alphabetically ordered
#include "AccAttributes.h"
#include "ApplicationAccessibleWrap.h"
#include "ARIAGridAccessibleWrap.h"
#include "ARIAMap.h"
@ -1447,7 +1448,7 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
}
void nsAccessibilityService::MarkupAttributes(
const nsIContent* aContent, nsIPersistentProperties* aAttributes) const {
const nsIContent* aContent, AccAttributes* aAttributes) const {
const mozilla::a11y::MarkupMapInfo* markupMap =
GetMarkupMapInfoForNode(aContent);
if (!markupMap) return;
@ -1461,7 +1462,7 @@ void nsAccessibilityService::MarkupAttributes(
if (aContent->IsElement() && aContent->AsElement()->AttrValueIs(
kNameSpaceID_None, info->DOMAttrName,
info->DOMAttrValue, eCaseMatters)) {
nsAccUtils::SetAccAttr(aAttributes, info->name, info->DOMAttrValue);
aAttributes->SetAttribute(info->name, info->DOMAttrValue);
}
continue;
}
@ -1474,13 +1475,13 @@ void nsAccessibilityService::MarkupAttributes(
}
if (!value.IsEmpty()) {
nsAccUtils::SetAccAttr(aAttributes, info->name, value);
aAttributes->SetAttribute(info->name, value);
}
continue;
}
nsAccUtils::SetAccAttr(aAttributes, info->name, info->value);
aAttributes->SetAttribute(info->name, info->value);
}
}

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

@ -22,7 +22,6 @@
class nsImageFrame;
class nsIArray;
class nsIPersistentProperties;
class nsITreeView;
namespace mozilla {
@ -36,6 +35,7 @@ class Element;
namespace a11y {
class AccAttributes;
class ApplicationAccessible;
class xpcAccessibleApplication;
@ -277,7 +277,7 @@ class nsAccessibilityService final : public mozilla::a11y::DocManager,
* Set the object attribute defined by markup for the given element.
*/
void MarkupAttributes(const nsIContent* aContent,
nsIPersistentProperties* aAttributes) const;
mozilla::a11y::AccAttributes* aAttributes) const;
/**
* A list of possible accessibility service consumers. Accessibility service

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

@ -7,6 +7,7 @@
#include "nsAccUtils.h"
#include "Logging.h"
#include "AccAttributes.h"
#include "mozilla/StaticPtr.h"
@ -57,11 +58,11 @@ void nsEventShell::FireEvent(uint32_t aEventType, LocalAccessible* aAccessible,
}
void nsEventShell::GetEventAttributes(nsINode* aNode,
nsIPersistentProperties* aAttributes) {
AccAttributes* aAttributes) {
if (aNode != sEventTargetNode) return;
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput,
sEventFromUserInput ? u"true"_ns : u"false"_ns);
aAttributes->SetAttribute(nsGkAtoms::eventFromInput,
sEventFromUserInput ? u"true"_ns : u"false"_ns);
}
////////////////////////////////////////////////////////////////////////////////

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

@ -12,7 +12,6 @@ namespace mozilla {
template <typename T>
class StaticRefPtr;
}
class nsIPersistentProperties;
/**
* Used for everything about events.
@ -57,7 +56,7 @@ class nsEventShell {
* @param aAttributes [in, out] the attributes
*/
static void GetEventAttributes(nsINode* aNode,
nsIPersistentProperties* aAttributes);
mozilla::a11y::AccAttributes* aAttributes);
private:
static mozilla::StaticRefPtr<nsINode> sEventTargetNode;

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

@ -6,13 +6,13 @@
#include "ARIAGridAccessible-inl.h"
#include "LocalAccessible-inl.h"
#include "AccAttributes.h"
#include "AccIterator.h"
#include "nsAccUtils.h"
#include "Role.h"
#include "States.h"
#include "mozilla/dom/Element.h"
#include "nsIPersistentProperties2.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla;
@ -36,14 +36,11 @@ role ARIAGridAccessible::NativeRole() const {
return r != roles::NOTHING ? r : roles::TABLE;
}
already_AddRefed<nsIPersistentProperties>
ARIAGridAccessible::NativeAttributes() {
nsCOMPtr<nsIPersistentProperties> attributes =
AccessibleWrap::NativeAttributes();
already_AddRefed<AccAttributes> ARIAGridAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes = AccessibleWrap::NativeAttributes();
if (IsProbablyLayoutTable()) {
nsAutoString unused;
attributes->SetStringProperty("layout-guess"_ns, u"true"_ns, unused);
attributes->SetAttribute(u"layout-guess"_ns, u"true"_ns);
}
return attributes.forget();
@ -581,9 +578,8 @@ void ARIAGridCellAccessible::ApplyARIAState(uint64_t* aState) const {
}
}
already_AddRefed<nsIPersistentProperties>
ARIAGridCellAccessible::NativeAttributes() {
nsCOMPtr<nsIPersistentProperties> attributes =
already_AddRefed<AccAttributes> ARIAGridCellAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes =
HyperTextAccessibleWrap::NativeAttributes();
// Expose "table-cell-index" attribute.
@ -610,12 +606,10 @@ ARIAGridCellAccessible::NativeAttributes() {
nsAutoString stringIdx;
stringIdx.AppendInt(rowIdx * colCount + colIdx);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
attributes->SetAttribute(nsGkAtoms::tableCellIndex, stringIdx);
#ifdef DEBUG
nsAutoString unused;
attributes->SetStringProperty("cppclass"_ns, u"ARIAGridCellAccessible"_ns,
unused);
attributes->SetAttribute(u"cppclass"_ns, u"ARIAGridCellAccessible"_ns);
#endif
return attributes.forget();

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

@ -26,7 +26,7 @@ class ARIAGridAccessible : public HyperTextAccessibleWrap,
// LocalAccessible
virtual a11y::role NativeRole() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual TableAccessible* AsTable() override { return this; }
// TableAccessible
@ -101,7 +101,7 @@ class ARIAGridCellAccessible : public HyperTextAccessibleWrap,
virtual a11y::role NativeRole() const override;
virtual TableCellAccessible* AsTableCell() override { return this; }
virtual void ApplyARIAState(uint64_t* aState) const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual mozilla::a11y::GroupPos GroupPosition() override;
protected:

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

@ -7,6 +7,7 @@
#include "ApplicationAccessible.h"
#include "AccAttributes.h"
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "Relation.h"
@ -66,9 +67,9 @@ uint64_t ApplicationAccessible::State() {
return IsDefunct() ? states::DEFUNCT : 0;
}
already_AddRefed<nsIPersistentProperties>
ApplicationAccessible::NativeAttributes() {
return nullptr;
already_AddRefed<AccAttributes> ApplicationAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes = new AccAttributes();
return attributes.forget();
}
GroupPos ApplicationAccessible::GroupPosition() { return GroupPos(); }

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

@ -35,7 +35,7 @@ class ApplicationAccessible : public AccessibleWrap {
virtual void Shutdown() override;
virtual nsIntRect Bounds() const override;
virtual nsRect BoundsInAppUnits() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual GroupPos GroupPosition() override;
virtual ENameValueFlag Name(nsString& aName) const override;
virtual void ApplyARIAState(uint64_t* aState) const override;

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

@ -6,6 +6,7 @@
#include "LocalAccessible-inl.h"
#include "AccIterator.h"
#include "AccAttributes.h"
#include "DocAccessible-inl.h"
#include "DocAccessibleChild.h"
#include "HTMLImageMapAccessible.h"
@ -31,7 +32,6 @@
#include "nsIFrame.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsImageFrame.h"
#include "nsIPersistentProperties2.h"
#include "nsViewManager.h"
#include "nsIScrollableFrame.h"
#include "nsUnicharUtils.h"
@ -261,9 +261,8 @@ void DocAccessible::ApplyARIAState(uint64_t* aState) const {
if (mParent) mParent->ApplyARIAState(aState);
}
already_AddRefed<nsIPersistentProperties> DocAccessible::Attributes() {
nsCOMPtr<nsIPersistentProperties> attributes =
HyperTextAccessibleWrap::Attributes();
already_AddRefed<AccAttributes> DocAccessible::Attributes() {
RefPtr<AccAttributes> attributes = HyperTextAccessibleWrap::Attributes();
// No attributes if document is not attached to the tree or if it's a root
// document.
@ -273,7 +272,7 @@ already_AddRefed<nsIPersistentProperties> DocAccessible::Attributes() {
aria::AttrIterator attribIter(mParent->GetContent());
nsAutoString name, value, unused;
while (attribIter.Next(name, value)) {
attributes->SetStringProperty(NS_ConvertUTF16toUTF8(name), value, unused);
attributes->SetAttribute(name, value);
}
return attributes.forget();

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

@ -76,7 +76,7 @@ class DocAccessible : public HyperTextAccessibleWrap,
virtual uint64_t NativeInteractiveState() const override;
virtual bool NativelyUnavailable() const override;
virtual void ApplyARIAState(uint64_t* aState) const override;
virtual already_AddRefed<nsIPersistentProperties> Attributes() override;
virtual already_AddRefed<AccAttributes> Attributes() override;
virtual void TakeFocus() const override;

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

@ -6,12 +6,13 @@
#include "HyperTextAccessible-inl.h"
#include "LocalAccessible-inl.h"
#include "nsAccessibilityService.h"
#include "nsAccessiblePivot.h"
#include "nsIAccessibleTypes.h"
#include "AccAttributes.h"
#include "DocAccessible.h"
#include "HTMLListAccessible.h"
#include "LocalAccessible-inl.h"
#include "Pivot.h"
#include "Relation.h"
#include "Role.h"
@ -29,7 +30,6 @@
#include "nsFrameSelection.h"
#include "nsILineIterator.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsPersistentProperties.h"
#include "nsIScrollableFrame.h"
#include "nsIMathMLFrame.h"
#include "nsRange.h"
@ -1200,7 +1200,7 @@ void HyperTextAccessible::TextAfterOffset(int32_t aOffset,
}
}
already_AddRefed<nsIPersistentProperties> HyperTextAccessible::TextAttributes(
already_AddRefed<AccAttributes> HyperTextAccessible::TextAttributes(
bool aIncludeDefAttrs, int32_t aOffset, int32_t* aStartOffset,
int32_t* aEndOffset) {
// 1. Get each attribute and its ranges one after another.
@ -1208,15 +1208,14 @@ already_AddRefed<nsIPersistentProperties> HyperTextAccessible::TextAttributes(
// as in/out parameters. In other words, as attributes are collected,
// the attribute range itself can only stay the same or get smaller.
RefPtr<AccAttributes> attributes = new AccAttributes();
*aStartOffset = *aEndOffset = 0;
index_t offset = ConvertMagicOffset(aOffset);
if (!offset.IsValid() || offset > CharacterCount()) {
NS_ERROR("Wrong in offset!");
return nullptr;
return attributes.forget();
}
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
LocalAccessible* accAtOffset = GetChildAtOffset(offset);
if (!accAtOffset) {
// Offset 0 is correct offset when accessible has empty text. Include
@ -1226,9 +1225,8 @@ already_AddRefed<nsIPersistentProperties> HyperTextAccessible::TextAttributes(
TextAttrsMgr textAttrsMgr(this);
textAttrsMgr.GetAttributes(attributes);
}
return attributes.forget();
}
return nullptr;
return attributes.forget();
}
int32_t accAtOffsetIdx = accAtOffset->IndexInParent();
@ -1256,9 +1254,8 @@ already_AddRefed<nsIPersistentProperties> HyperTextAccessible::TextAttributes(
return attributes.forget();
}
already_AddRefed<nsIPersistentProperties>
HyperTextAccessible::DefaultTextAttributes() {
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
already_AddRefed<AccAttributes> HyperTextAccessible::DefaultTextAttributes() {
RefPtr<AccAttributes> attributes = new AccAttributes();
TextAttrsMgr textAttrsMgr(this);
textAttrsMgr.GetAttributes(attributes);
@ -1272,8 +1269,7 @@ int32_t HyperTextAccessible::GetLevelInternal() {
return AccessibleWrap::GetLevelInternal();
}
void HyperTextAccessible::SetMathMLXMLRoles(
nsIPersistentProperties* aAttributes) {
void HyperTextAccessible::SetMathMLXMLRoles(AccAttributes* aAttributes) {
// Add MathML xmlroles based on the position inside the parent.
LocalAccessible* parent = LocalParent();
if (parent) {
@ -1296,65 +1292,65 @@ void HyperTextAccessible::SetMathMLXMLRoles(
mathMLFrame->GetEmbellishData(embellishData);
if (NS_MATHML_EMBELLISH_IS_FENCE(embellishData.flags)) {
if (!LocalPrevSibling()) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
nsGkAtoms::open_fence);
aAttributes->SetAttribute(nsGkAtoms::xmlroles,
nsGkAtoms::open_fence);
} else if (!LocalNextSibling()) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
nsGkAtoms::close_fence);
aAttributes->SetAttribute(nsGkAtoms::xmlroles,
nsGkAtoms::close_fence);
}
}
if (NS_MATHML_EMBELLISH_IS_SEPARATOR(embellishData.flags)) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
nsGkAtoms::separator_);
aAttributes->SetAttribute(nsGkAtoms::xmlroles,
nsGkAtoms::separator_);
}
}
}
break;
case roles::MATHML_FRACTION:
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
IndexInParent() == 0 ? nsGkAtoms::numerator
: nsGkAtoms::denominator);
aAttributes->SetAttribute(
nsGkAtoms::xmlroles, IndexInParent() == 0 ? nsGkAtoms::numerator
: nsGkAtoms::denominator);
break;
case roles::MATHML_ROOT:
nsAccUtils::SetAccAttr(
aAttributes, nsGkAtoms::xmlroles,
aAttributes->SetAttribute(
nsGkAtoms::xmlroles,
IndexInParent() == 0 ? nsGkAtoms::base : nsGkAtoms::root_index);
break;
case roles::MATHML_SUB:
nsAccUtils::SetAccAttr(
aAttributes, nsGkAtoms::xmlroles,
aAttributes->SetAttribute(
nsGkAtoms::xmlroles,
IndexInParent() == 0 ? nsGkAtoms::base : nsGkAtoms::subscript);
break;
case roles::MATHML_SUP:
nsAccUtils::SetAccAttr(
aAttributes, nsGkAtoms::xmlroles,
aAttributes->SetAttribute(
nsGkAtoms::xmlroles,
IndexInParent() == 0 ? nsGkAtoms::base : nsGkAtoms::superscript);
break;
case roles::MATHML_SUB_SUP: {
int32_t index = IndexInParent();
nsAccUtils::SetAccAttr(
aAttributes, nsGkAtoms::xmlroles,
aAttributes->SetAttribute(
nsGkAtoms::xmlroles,
index == 0
? nsGkAtoms::base
: (index == 1 ? nsGkAtoms::subscript : nsGkAtoms::superscript));
} break;
case roles::MATHML_UNDER:
nsAccUtils::SetAccAttr(
aAttributes, nsGkAtoms::xmlroles,
aAttributes->SetAttribute(
nsGkAtoms::xmlroles,
IndexInParent() == 0 ? nsGkAtoms::base : nsGkAtoms::underscript);
break;
case roles::MATHML_OVER:
nsAccUtils::SetAccAttr(
aAttributes, nsGkAtoms::xmlroles,
aAttributes->SetAttribute(
nsGkAtoms::xmlroles,
IndexInParent() == 0 ? nsGkAtoms::base : nsGkAtoms::overscript);
break;
case roles::MATHML_UNDER_OVER: {
int32_t index = IndexInParent();
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
index == 0
? nsGkAtoms::base
: (index == 1 ? nsGkAtoms::underscript
: nsGkAtoms::overscript));
aAttributes->SetAttribute(nsGkAtoms::xmlroles,
index == 0
? nsGkAtoms::base
: (index == 1 ? nsGkAtoms::underscript
: nsGkAtoms::overscript));
} break;
case roles::MATHML_MULTISCRIPTS: {
// Get the <multiscripts> base.
@ -1371,8 +1367,7 @@ void HyperTextAccessible::SetMathMLXMLRoles(
nsIContent* content = GetContent();
if (child == content) {
// We are the base.
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
nsGkAtoms::base);
aAttributes->SetAttribute(nsGkAtoms::xmlroles, nsGkAtoms::base);
} else {
// Browse the list of scripts to find us and determine our type.
bool postscript = true;
@ -1387,13 +1382,14 @@ void HyperTextAccessible::SetMathMLXMLRoles(
}
if (child == content) {
if (postscript) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
subscript ? nsGkAtoms::subscript
: nsGkAtoms::superscript);
aAttributes->SetAttribute(nsGkAtoms::xmlroles,
subscript ? nsGkAtoms::subscript
: nsGkAtoms::superscript);
} else {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
subscript ? nsGkAtoms::presubscript
: nsGkAtoms::presuperscript);
aAttributes->SetAttribute(nsGkAtoms::xmlroles,
subscript
? nsGkAtoms::presubscript
: nsGkAtoms::presuperscript);
}
break;
}
@ -1408,17 +1404,14 @@ void HyperTextAccessible::SetMathMLXMLRoles(
}
}
already_AddRefed<nsIPersistentProperties>
HyperTextAccessible::NativeAttributes() {
nsCOMPtr<nsIPersistentProperties> attributes =
AccessibleWrap::NativeAttributes();
already_AddRefed<AccAttributes> HyperTextAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes = AccessibleWrap::NativeAttributes();
// 'formatting' attribute is deprecated, 'display' attribute should be
// instead.
nsIFrame* frame = GetFrame();
if (frame && frame->IsBlockFrame()) {
nsAutoString unused;
attributes->SetStringProperty("formatting"_ns, u"block"_ns, unused);
attributes->SetAttribute(u"formatting"_ns, u"block"_ns);
}
if (FocusMgr()->IsFocused(this)) {
@ -1426,7 +1419,7 @@ HyperTextAccessible::NativeAttributes() {
if (lineNumber >= 1) {
nsAutoString strLineNumber;
strLineNumber.AppendInt(lineNumber);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::lineNumber, strLineNumber);
attributes->SetAttribute(nsGkAtoms::lineNumber, strLineNumber);
}
}
@ -2336,9 +2329,10 @@ nsresult HyperTextAccessible::GetDOMPointByFrameOffset(
}
// HyperTextAccessible
void HyperTextAccessible::GetSpellTextAttr(
nsINode* aNode, int32_t aNodeOffset, uint32_t* aStartOffset,
uint32_t* aEndOffset, nsIPersistentProperties* aAttributes) {
void HyperTextAccessible::GetSpellTextAttr(nsINode* aNode, int32_t aNodeOffset,
uint32_t* aStartOffset,
uint32_t* aEndOffset,
AccAttributes* aAttributes) {
RefPtr<nsFrameSelection> fs = FrameSelection();
if (!fs) return;
@ -2392,9 +2386,7 @@ void HyperTextAccessible::GetSpellTextAttr(
if (endOffset < *aEndOffset) *aEndOffset = endOffset;
if (aAttributes) {
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::invalid, u"spelling"_ns);
}
aAttributes->SetAttribute(nsGkAtoms::invalid, u"spelling"_ns);
return;
}

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

@ -55,7 +55,7 @@ class HyperTextAccessible : public AccessibleWrap {
// LocalAccessible
virtual nsAtom* LandmarkRole() const override;
virtual int32_t GetLevelInternal() override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual mozilla::a11y::role NativeRole() const override;
virtual uint64_t NativeState() const override;
@ -214,14 +214,15 @@ class HyperTextAccessible : public AccessibleWrap {
/**
* Return text attributes for the given text range.
*/
already_AddRefed<nsIPersistentProperties> TextAttributes(
bool aIncludeDefAttrs, int32_t aOffset, int32_t* aStartOffset,
int32_t* aEndOffset);
already_AddRefed<AccAttributes> TextAttributes(bool aIncludeDefAttrs,
int32_t aOffset,
int32_t* aStartOffset,
int32_t* aEndOffset);
/**
* Return text attributes applied to the accessible.
*/
already_AddRefed<nsIPersistentProperties> DefaultTextAttributes();
already_AddRefed<AccAttributes> DefaultTextAttributes();
/**
* Return text offset of the given child accessible within hypertext
@ -529,13 +530,13 @@ class HyperTextAccessible : public AccessibleWrap {
*/
void GetSpellTextAttr(nsINode* aNode, int32_t aNodeOffset,
uint32_t* aStartOffset, uint32_t* aEndOffset,
nsIPersistentProperties* aAttributes);
AccAttributes* aAttributes);
/**
* Set xml-roles attributes for MathML elements.
* @param aAttributes
*/
void SetMathMLXMLRoles(nsIPersistentProperties* aAttributes);
void SetMathMLXMLRoles(AccAttributes* aAttributes);
private:
/**

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

@ -7,6 +7,7 @@
#include "nsAccUtils.h"
#include "Role.h"
#include "AccAttributes.h"
#include "AccIterator.h"
#include "States.h"
@ -17,7 +18,6 @@
#include "mozilla/dom/Document.h"
#include "nsContentUtils.h"
#include "nsIImageLoadingContent.h"
#include "nsIPersistentProperties2.h"
#include "nsPIDOMWindow.h"
#include "nsIURI.h"
@ -148,13 +148,12 @@ nsIntPoint ImageAccessible::Position(uint32_t aCoordType) {
nsIntSize ImageAccessible::Size() { return Bounds().Size(); }
// LocalAccessible
already_AddRefed<nsIPersistentProperties> ImageAccessible::NativeAttributes() {
nsCOMPtr<nsIPersistentProperties> attributes =
LinkableAccessible::NativeAttributes();
already_AddRefed<AccAttributes> ImageAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes = LinkableAccessible::NativeAttributes();
nsAutoString src;
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::src, src);
if (!src.IsEmpty()) nsAccUtils::SetAccAttr(attributes, nsGkAtoms::src, src);
if (!src.IsEmpty()) attributes->SetAttribute(nsGkAtoms::src, src);
return attributes.forget();
}

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

@ -23,7 +23,7 @@ class ImageAccessible : public LinkableAccessible {
// LocalAccessible
virtual a11y::role NativeRole() const override;
virtual uint64_t NativeState() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
// ActionAccessible
virtual uint8_t ActionCount() const override;

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

@ -6,6 +6,7 @@
#include "LocalAccessible-inl.h"
#include "EmbeddedObjCollector.h"
#include "AccAttributes.h"
#include "AccGroupInfo.h"
#include "AccIterator.h"
#include "nsAccUtils.h"
@ -62,7 +63,6 @@
#include "nsArrayUtils.h"
#include "nsWhitespaceTokenizer.h"
#include "nsAttrName.h"
#include "nsPersistentProperties.h"
#include "mozilla/Assertions.h"
#include "mozilla/BasicEvents.h"
@ -968,26 +968,25 @@ nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) {
return NS_OK;
}
already_AddRefed<nsIPersistentProperties> LocalAccessible::Attributes() {
nsCOMPtr<nsIPersistentProperties> attributes = NativeAttributes();
already_AddRefed<AccAttributes> LocalAccessible::Attributes() {
RefPtr<AccAttributes> attributes = NativeAttributes();
if (!HasOwnContent() || !mContent->IsElement()) return attributes.forget();
// 'xml-roles' attribute coming from ARIA.
nsAutoString xmlRoles;
if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::role,
xmlRoles)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles, xmlRoles);
attributes->SetAttribute(nsGkAtoms::xmlroles, xmlRoles);
} else if (nsAtom* landmark = LandmarkRole()) {
// 'xml-roles' attribute for landmark.
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles, landmark);
attributes->SetAttribute(nsGkAtoms::xmlroles, landmark);
}
// Expose object attributes from ARIA attributes.
nsAutoString unused;
aria::AttrIterator attribIter(mContent);
nsAutoString name, value;
while (attribIter.Next(name, value)) {
attributes->SetStringProperty(NS_ConvertUTF16toUTF8(name), value, unused);
attributes->SetAttribute(name, value);
}
// If there is no aria-live attribute then expose default value of 'live'
@ -995,15 +994,13 @@ already_AddRefed<nsIPersistentProperties> LocalAccessible::Attributes() {
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
if (roleMapEntry) {
if (roleMapEntry->Is(nsGkAtoms::searchbox)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType,
u"search"_ns);
attributes->SetAttribute(nsGkAtoms::textInputType, u"search"_ns);
}
nsAutoString live;
nsAccUtils::GetAccAttr(attributes, nsGkAtoms::live, live);
if (live.IsEmpty()) {
if (!attributes->HasAttribute(nsGkAtoms::aria_live)) {
nsAutoString live;
if (nsAccUtils::GetLiveAttrValue(roleMapEntry->liveAttRule, live)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::live, live);
attributes->SetAttribute(nsGkAtoms::live, live);
}
}
}
@ -1011,10 +1008,8 @@ already_AddRefed<nsIPersistentProperties> LocalAccessible::Attributes() {
return attributes.forget();
}
already_AddRefed<nsIPersistentProperties> LocalAccessible::NativeAttributes() {
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
nsAutoString unused;
already_AddRefed<AccAttributes> LocalAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes = new AccAttributes();
// We support values, so expose the string value as well, via the valuetext
// object attribute. We test for the value interface because we don't want
@ -1023,18 +1018,18 @@ already_AddRefed<nsIPersistentProperties> LocalAccessible::NativeAttributes() {
if (HasNumericValue()) {
nsAutoString valuetext;
Value(valuetext);
attributes->SetStringProperty("valuetext"_ns, valuetext, unused);
attributes->SetAttribute(u"valuetext"_ns, valuetext);
}
// Expose checkable object attribute if the accessible has checkable state
if (State() & states::CHECKABLE) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::checkable, u"true"_ns);
attributes->SetAttribute(nsGkAtoms::checkable, u"true"_ns);
}
// Expose 'explicit-name' attribute.
nsAutoString name;
if (Name(name) != eNameFromSubtree && !name.IsVoid()) {
attributes->SetStringProperty("explicit-name"_ns, u"true"_ns, unused);
attributes->SetAttribute(u"explicit-name"_ns, u"true"_ns);
}
// Group attributes (level/setsize/posinset)
@ -1047,11 +1042,11 @@ already_AddRefed<nsIPersistentProperties> LocalAccessible::NativeAttributes() {
if (itemCount) {
nsAutoString itemCountStr;
itemCountStr.AppendInt(itemCount);
attributes->SetStringProperty("child-item-count"_ns, itemCountStr, unused);
attributes->SetAttribute(u"child-item-count"_ns, itemCountStr);
}
if (hierarchical) {
attributes->SetStringProperty("hierarchical"_ns, u"true"_ns, unused);
attributes->SetAttribute(u"hierarchical"_ns, u"true"_ns);
}
// If the accessible doesn't have own content (such as list item bullet or
@ -1070,25 +1065,25 @@ already_AddRefed<nsIPersistentProperties> LocalAccessible::NativeAttributes() {
nsAutoString id;
if (nsCoreUtils::GetID(mContent, id)) {
attributes->SetStringProperty("id"_ns, id, unused);
attributes->SetAttribute(nsGkAtoms::id, id);
}
// Expose class because it may have useful microformat information.
nsAutoString _class;
if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::_class,
_class)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::_class, _class);
attributes->SetAttribute(nsGkAtoms::_class, _class);
}
// Expose tag.
nsAutoString tagName;
mContent->NodeInfo()->GetName(tagName);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tag, tagName);
attributes->SetAttribute(nsGkAtoms::tag, tagName);
// Expose draggable object attribute.
if (auto htmlElement = nsGenericHTMLElement::FromNode(mContent)) {
if (htmlElement->Draggable()) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::draggable, u"true"_ns);
attributes->SetAttribute(nsGkAtoms::draggable, u"true"_ns);
}
}
@ -1102,39 +1097,38 @@ already_AddRefed<nsIPersistentProperties> LocalAccessible::NativeAttributes() {
// Expose 'display' attribute.
styleInfo.Display(value);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::display, value);
attributes->SetAttribute(nsGkAtoms::display, value);
// Expose 'text-align' attribute.
styleInfo.TextAlign(value);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textAlign, value);
attributes->SetAttribute(nsGkAtoms::textAlign, value);
// Expose 'text-indent' attribute.
styleInfo.TextIndent(value);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textIndent, value);
attributes->SetAttribute(nsGkAtoms::textIndent, value);
// Expose 'margin-left' attribute.
styleInfo.MarginLeft(value);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::marginLeft, value);
attributes->SetAttribute(nsGkAtoms::marginLeft, value);
// Expose 'margin-right' attribute.
styleInfo.MarginRight(value);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::marginRight, value);
attributes->SetAttribute(nsGkAtoms::marginRight, value);
// Expose 'margin-top' attribute.
styleInfo.MarginTop(value);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::marginTop, value);
attributes->SetAttribute(nsGkAtoms::marginTop, value);
// Expose 'margin-bottom' attribute.
styleInfo.MarginBottom(value);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::marginBottom, value);
attributes->SetAttribute(nsGkAtoms::marginBottom, value);
// Expose data-at-shortcutkeys attribute for web applications and virtual
// cursors. Currently mostly used by JAWS.
nsAutoString atShortcutKeys;
if (mContent->AsElement()->GetAttr(
kNameSpaceID_None, nsGkAtoms::dataAtShortcutkeys, atShortcutKeys)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::dataAtShortcutkeys,
atShortcutKeys);
attributes->SetAttribute(nsGkAtoms::dataAtShortcutkeys, atShortcutKeys);
}
return attributes.forget();

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

@ -21,7 +21,6 @@
struct nsRoleMapEntry;
class nsIFrame;
class nsIPersistentProperties;
namespace mozilla::dom {
class Element;
@ -31,6 +30,7 @@ namespace mozilla {
namespace a11y {
class LocalAccessible;
class AccAttributes;
class AccEvent;
class AccGroupInfo;
class ApplicationAccessible;
@ -288,7 +288,7 @@ class LocalAccessible : public nsISupports, public Accessible {
/**
* Return object attributes for the accessible.
*/
virtual already_AddRefed<nsIPersistentProperties> Attributes();
virtual already_AddRefed<AccAttributes> Attributes();
/**
* Return group position (level, position in set and set size).
@ -927,7 +927,7 @@ class LocalAccessible : public nsISupports, public Accessible {
* Return object attributes provided by native markup. It doesn't take into
* account ARIA.
*/
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes();
virtual already_AddRefed<AccAttributes> NativeAttributes();
//////////////////////////////////////////////////////////////////////////////
// Initializing, cache and tree traverse methods

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

@ -17,7 +17,6 @@
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLTextAreaElement.h"
#include "nsIFormControl.h"
#include "nsIPersistentProperties2.h"
#include "nsITextControlFrame.h"
#include "nsNameSpaceManager.h"
#include "mozilla/dom/ScriptSettings.h"
@ -233,9 +232,8 @@ role HTMLTextFieldAccessible::NativeRole() const {
return roles::ENTRY;
}
already_AddRefed<nsIPersistentProperties>
HTMLTextFieldAccessible::NativeAttributes() {
nsCOMPtr<nsIPersistentProperties> attributes =
already_AddRefed<AccAttributes> HTMLTextFieldAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes =
HyperTextAccessibleWrap::NativeAttributes();
// Expose type for text input elements as it gives some useful context,
@ -251,9 +249,9 @@ HTMLTextFieldAccessible::NativeAttributes() {
nsGkAtoms::type, type)) ||
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::type,
type)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, type);
attributes->SetAttribute(nsGkAtoms::textInputType, type);
if (!ARIARoleMap() && type.EqualsLiteral("search")) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles, u"searchbox"_ns);
attributes->SetAttribute(nsGkAtoms::xmlroles, u"searchbox"_ns);
}
}
@ -265,8 +263,7 @@ HTMLTextFieldAccessible::NativeAttributes() {
nsAutoString name;
const_cast<HTMLTextFieldAccessible*>(this)->Name(name);
if (!name.Equals(placeholderText)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::placeholder,
placeholderText);
attributes->SetAttribute(nsGkAtoms::placeholder, placeholderText);
}
}

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

@ -9,8 +9,8 @@
#include "FormControlAccessible.h"
#include "HyperTextAccessibleWrap.h"
#include "mozilla/dom/Element.h"
#include "AccAttributes.h"
#include "nsAccUtils.h"
#include "nsIPersistentProperties2.h"
#include "Relation.h"
namespace mozilla {
@ -89,7 +89,7 @@ class HTMLTextFieldAccessible : public HyperTextAccessibleWrap {
virtual void ApplyARIAState(uint64_t* aState) const override;
virtual mozilla::a11y::role NativeRole() const override;
virtual uint64_t NativeState() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
// ActionAccessible
virtual uint8_t ActionCount() const override;
@ -336,16 +336,14 @@ class HTMLDateTimeAccessible : public AccessibleWrap {
// LocalAccessible
virtual mozilla::a11y::role NativeRole() const override { return R; }
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes()
override {
nsCOMPtr<nsIPersistentProperties> attributes =
AccessibleWrap::NativeAttributes();
virtual already_AddRefed<AccAttributes> NativeAttributes() override {
RefPtr<AccAttributes> attributes = AccessibleWrap::NativeAttributes();
// Unfortunately, an nsStaticAtom can't be passed as a
// template argument, so fetch the type from the DOM.
nsAutoString type;
if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::type,
type)) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, type);
attributes->SetAttribute(nsGkAtoms::textInputType, type);
}
return attributes.forget();
}

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

@ -6,10 +6,10 @@
#include "HTMLListAccessible.h"
#include "AccAttributes.h"
#include "DocAccessible.h"
#include "EventTree.h"
#include "nsAccUtils.h"
#include "nsPersistentProperties.h"
#include "nsTextEquivUtils.h"
#include "Role.h"
#include "States.h"
@ -119,9 +119,8 @@ uint64_t HTMLListBulletAccessible::NativeState() const {
return LeafAccessible::NativeState() | states::READONLY;
}
already_AddRefed<nsIPersistentProperties>
HTMLListBulletAccessible::NativeAttributes() {
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
already_AddRefed<AccAttributes> HTMLListBulletAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes = new AccAttributes();
return attributes.forget();
}

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

@ -72,7 +72,7 @@ class HTMLListBulletAccessible : public LeafAccessible {
virtual ENameValueFlag Name(nsString& aName) const override;
virtual a11y::role NativeRole() const override;
virtual uint64_t NativeState() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
uint32_t aLength = UINT32_MAX) override;
};

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

@ -7,10 +7,11 @@
#include "mozilla/DebugOnly.h"
#include "LocalAccessible-inl.h"
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
#include "AccAttributes.h"
#include "DocAccessible.h"
#include "LocalAccessible-inl.h"
#include "nsTextEquivUtils.h"
#include "Relation.h"
#include "Role.h"
@ -21,7 +22,6 @@
#include "mozilla/dom/HTMLTableElement.h"
#include "nsIHTMLCollection.h"
#include "mozilla/dom/Document.h"
#include "nsIPersistentProperties2.h"
#include "nsITableCellLayout.h"
#include "nsFrameSelection.h"
#include "nsError.h"
@ -71,9 +71,8 @@ uint64_t HTMLTableCellAccessible::NativeInteractiveState() const {
return HyperTextAccessibleWrap::NativeInteractiveState() | states::SELECTABLE;
}
already_AddRefed<nsIPersistentProperties>
HTMLTableCellAccessible::NativeAttributes() {
nsCOMPtr<nsIPersistentProperties> attributes =
already_AddRefed<AccAttributes> HTMLTableCellAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes =
HyperTextAccessibleWrap::NativeAttributes();
// table-cell-index attribute
@ -86,7 +85,7 @@ HTMLTableCellAccessible::NativeAttributes() {
nsAutoString stringIdx;
stringIdx.AppendInt(table->CellIndexAt(rowIdx, colIdx));
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
attributes->SetAttribute(nsGkAtoms::tableCellIndex, stringIdx);
// abbr attribute
@ -109,20 +108,18 @@ HTMLTableCellAccessible::NativeAttributes() {
}
if (!abbrText.IsEmpty()) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::abbr, abbrText);
attributes->SetAttribute(nsGkAtoms::abbr, abbrText);
}
// axis attribute
nsAutoString axisText;
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::axis, axisText);
if (!axisText.IsEmpty()) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::axis, axisText);
attributes->SetAttribute(nsGkAtoms::axis, axisText);
}
#ifdef DEBUG
nsAutoString unused;
attributes->SetStringProperty("cppclass"_ns, u"HTMLTableCellAccessible"_ns,
unused);
attributes->SetAttribute(u"cppclass"_ns, u"HTMLTableCellAccessible"_ns);
#endif
return attributes.forget();
@ -394,18 +391,15 @@ ENameValueFlag HTMLTableAccessible::NativeName(nsString& aName) const {
return eNameOK;
}
already_AddRefed<nsIPersistentProperties>
HTMLTableAccessible::NativeAttributes() {
nsCOMPtr<nsIPersistentProperties> attributes =
AccessibleWrap::NativeAttributes();
already_AddRefed<AccAttributes> HTMLTableAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes = AccessibleWrap::NativeAttributes();
if (mContent->IsMathMLElement(nsGkAtoms::mtable_)) {
GetAccService()->MarkupAttributes(mContent, attributes);
}
if (IsProbablyLayoutTable()) {
nsAutoString unused;
attributes->SetStringProperty("layout-guess"_ns, u"true"_ns, unused);
attributes->SetAttribute(u"layout-guess"_ns, u"true"_ns);
}
return attributes.forget();

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

@ -37,7 +37,7 @@ class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
virtual a11y::role NativeRole() const override;
virtual uint64_t NativeState() const override;
virtual uint64_t NativeInteractiveState() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual mozilla::a11y::GroupPos GroupPosition() override;
// TableCellAccessible
@ -161,7 +161,7 @@ class HTMLTableAccessible : public HyperTextAccessibleWrap,
virtual void Description(nsString& aDescription) override;
virtual a11y::role NativeRole() const override;
virtual uint64_t NativeState() const override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual Relation RelationByType(RelationType aRelationType) const override;
virtual bool InsertChildAt(uint32_t aIndex, LocalAccessible* aChild) override;

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

@ -6,9 +6,9 @@
#include "DocAccessiblePlatformExtChild.h"
#include "AccAttributes.h"
#include "DocAccessibleChild.h"
#include "HyperTextAccessibleWrap.h"
#include "nsPersistentProperties.h"
#include "nsAccUtils.h"
#define UNIQUE_ID(acc) \
@ -212,7 +212,7 @@ DocAccessiblePlatformExtChild::RecvAttributedTextForRange(
nsTArray<nsString> texts;
nsTArray<LocalAccessible*> containers;
nsTArray<nsCOMPtr<nsIPersistentProperties>> props;
nsTArray<RefPtr<AccAttributes>> props;
acc->AttributedTextForRange(texts, props, containers, aStartOffset,
endContainer, aEndOffset);

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

@ -6,6 +6,7 @@
#include "DocAccessibleChild.h"
#include "AccAttributes.h"
#include "nsAccessibilityService.h"
#include "LocalAccessible-inl.h"
#include "RemoteAccessible.h"
@ -148,7 +149,7 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvAttributes(
LocalAccessible* acc = IdToAccessible(aID);
if (!acc) return IPC_OK();
nsCOMPtr<nsIPersistentProperties> props = acc->Attributes();
RefPtr<AccAttributes> props = acc->Attributes();
if (!nsAccUtils::PersistentPropertiesToArray(props, aAttributes)) {
return IPC_FAIL_NO_REASON(this);
}
@ -409,7 +410,7 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvTextAttributes(
return IPC_OK();
}
nsCOMPtr<nsIPersistentProperties> props =
RefPtr<AccAttributes> props =
acc->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
if (!nsAccUtils::PersistentPropertiesToArray(props, aAttributes)) {
return IPC_FAIL_NO_REASON(this);
@ -424,7 +425,7 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvDefaultTextAttributes(
return IPC_OK();
}
nsCOMPtr<nsIPersistentProperties> props = acc->DefaultTextAttributes();
RefPtr<AccAttributes> props = acc->DefaultTextAttributes();
if (!nsAccUtils::PersistentPropertiesToArray(props, aAttributes)) {
return IPC_FAIL_NO_REASON(this);
}

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

@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DocAccessibleParent.h"
#include "AccAttributes.h"
#include "AccessibleOrProxy.h"
#include "nsCocoaUtils.h"
@ -416,51 +417,63 @@ static NSColor* ColorFromString(const nsString& aColorStr) {
}
static NSDictionary* StringAttributesFromAttributes(
nsTArray<Attribute>& aAttributes, const AccessibleOrProxy& aContainer) {
AccAttributes* aAttributes, const AccessibleOrProxy& aContainer) {
NSMutableDictionary* attrDict =
[NSMutableDictionary dictionaryWithCapacity:aAttributes.Length()];
[NSMutableDictionary dictionaryWithCapacity:aAttributes->Count()];
NSMutableDictionary* fontAttrDict = [[NSMutableDictionary alloc] init];
[attrDict setObject:fontAttrDict forKey:@"AXFont"];
for (size_t ii = 0; ii < aAttributes.Length(); ii++) {
RefPtr<nsAtom> attrName = NS_Atomize(aAttributes.ElementAt(ii).Name());
if (attrName == nsGkAtoms::backgroundColor) {
if (NSColor* color = ColorFromString(aAttributes.ElementAt(ii).Value())) {
for (auto iter : *aAttributes) {
if (iter.Name() == nsGkAtoms::backgroundColor) {
nsAutoString value;
iter.ValueAsString(value);
if (NSColor* color = ColorFromString(value)) {
[attrDict setObject:(__bridge id)color.CGColor
forKey:@"AXBackgroundColor"];
}
} else if (attrName == nsGkAtoms::color) {
if (NSColor* color = ColorFromString(aAttributes.ElementAt(ii).Value())) {
} else if (iter.Name() == nsGkAtoms::color) {
nsAutoString value;
iter.ValueAsString(value);
if (NSColor* color = ColorFromString(value)) {
[attrDict setObject:(__bridge id)color.CGColor
forKey:@"AXForegroundColor"];
}
} else if (attrName == nsGkAtoms::font_size) {
} else if (iter.Name() == nsGkAtoms::font_size) {
float fontPointSize = 0;
if (sscanf(NS_ConvertUTF16toUTF8(aAttributes.ElementAt(ii).Value()).get(),
"%fpt", &fontPointSize) > 0) {
nsAutoString value;
iter.ValueAsString(value);
if (sscanf(NS_ConvertUTF16toUTF8(value).get(), "%fpt", &fontPointSize) >
0) {
int32_t fontPixelSize = static_cast<int32_t>(fontPointSize * 4 / 3);
[fontAttrDict setObject:@(fontPixelSize) forKey:@"AXFontSize"];
}
} else if (attrName == nsGkAtoms::font_family) {
[fontAttrDict
setObject:nsCocoaUtils::ToNSString(aAttributes.ElementAt(ii).Value())
forKey:@"AXFontFamily"];
} else if (attrName == nsGkAtoms::textUnderlineColor) {
} else if (iter.Name() == nsGkAtoms::font_family) {
nsAutoString value;
iter.ValueAsString(value);
[fontAttrDict setObject:nsCocoaUtils::ToNSString(value)
forKey:@"AXFontFamily"];
} else if (iter.Name() == nsGkAtoms::textUnderlineColor) {
[attrDict setObject:@1 forKey:@"AXUnderline"];
if (NSColor* color = ColorFromString(aAttributes.ElementAt(ii).Value())) {
nsAutoString value;
iter.ValueAsString(value);
if (NSColor* color = ColorFromString(value)) {
[attrDict setObject:(__bridge id)color.CGColor
forKey:@"AXUnderlineColor"];
}
} else if (attrName == nsGkAtoms::invalid) {
} else if (iter.Name() == nsGkAtoms::invalid) {
// XXX: There is currently no attribute for grammar
if (aAttributes.ElementAt(ii).Value().EqualsLiteral("spelling")) {
nsAutoString value;
iter.ValueAsString(value);
if (value.EqualsLiteral("spelling")) {
[attrDict setObject:@YES
forKey:NSAccessibilityMarkedMisspelledTextAttribute];
}
} else {
[attrDict
setObject:nsCocoaUtils::ToNSString(aAttributes.ElementAt(ii).Value())
forKey:nsCocoaUtils::ToNSString(NS_ConvertUTF8toUTF16(
aAttributes.ElementAt(ii).Name()))];
nsAutoString valueStr;
iter.ValueAsString(valueStr);
nsAutoString keyStr;
iter.NameAsString(keyStr);
[attrDict setObject:nsCocoaUtils::ToNSString(valueStr)
forKey:nsCocoaUtils::ToNSString(keyStr)];
}
}
@ -496,8 +509,14 @@ NSAttributedString* GeckoTextMarkerRange::AttributedText() const {
mEnd.mContainer.AsProxy()->ID(), mEnd.mOffset, &textAttributesRuns);
for (size_t i = 0; i < textAttributesRuns.Length(); i++) {
nsTArray<Attribute>& attributes =
nsTArray<Attribute>& attribs =
textAttributesRuns.ElementAt(i).TextAttributes();
RefPtr<AccAttributes> attributes = new AccAttributes();
for (size_t ii = 0; ii < attribs.Length(); ii++) {
attributes->SetAttribute(
NS_ConvertUTF8toUTF16(attribs.ElementAt(ii).Name()),
attribs.ElementAt(ii).Value());
}
RemoteAccessible* container =
ipcDoc->GetAccessible(textAttributesRuns.ElementAt(i).ContainerID());
@ -512,7 +531,7 @@ NSAttributedString* GeckoTextMarkerRange::AttributedText() const {
} else if (auto htWrap = mStart.ContainerAsHyperTextWrap()) {
nsTArray<nsString> texts;
nsTArray<LocalAccessible*> containers;
nsTArray<nsCOMPtr<nsIPersistentProperties>> props;
nsTArray<RefPtr<AccAttributes>> props;
htWrap->AttributedTextForRange(texts, props, containers, mStart.mOffset,
mEnd.ContainerAsHyperTextWrap(),
@ -522,13 +541,11 @@ NSAttributedString* GeckoTextMarkerRange::AttributedText() const {
texts.Length() == containers.Length());
for (size_t i = 0; i < texts.Length(); i++) {
nsTArray<Attribute> attributes;
nsAccUtils::PersistentPropertiesToArray(props.ElementAt(i), &attributes);
NSAttributedString* substr = [[[NSAttributedString alloc]
initWithString:nsCocoaUtils::ToNSString(texts.ElementAt(i))
attributes:StringAttributesFromAttributes(
attributes, containers.ElementAt(i))] autorelease];
props.ElementAt(i), containers.ElementAt(i))]
autorelease];
[str appendAttributedString:substr];
}
}

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

@ -22,11 +22,12 @@ class HyperTextAccessibleWrap : public HyperTextAccessible {
void TextForRange(nsAString& aText, int32_t aStartOffset,
HyperTextAccessible* aEndContainer, int32_t aEndOffset);
void AttributedTextForRange(
nsTArray<nsString>& aStrings,
nsTArray<nsCOMPtr<nsIPersistentProperties>>& aProperties,
nsTArray<LocalAccessible*>& aContainers, int32_t aStartOffset,
HyperTextAccessible* aEndContainer, int32_t aEndOffset);
void AttributedTextForRange(nsTArray<nsString>& aStrings,
nsTArray<RefPtr<AccAttributes>>& aProperties,
nsTArray<LocalAccessible*>& aContainers,
int32_t aStartOffset,
HyperTextAccessible* aEndContainer,
int32_t aEndOffset);
nsIntRect BoundsForRange(int32_t aStartOffset,
HyperTextAccessible* aEndContainer,

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

@ -13,7 +13,6 @@
#include "nsFrameSelection.h"
#include "TextRange.h"
#include "TreeWalker.h"
#include "nsPersistentProperties.h"
using namespace mozilla;
using namespace mozilla::a11y;
@ -262,8 +261,7 @@ void HyperTextAccessibleWrap::TextForRange(nsAString& aText,
}
void HyperTextAccessibleWrap::AttributedTextForRange(
nsTArray<nsString>& aStrings,
nsTArray<nsCOMPtr<nsIPersistentProperties>>& aProperties,
nsTArray<nsString>& aStrings, nsTArray<RefPtr<AccAttributes>>& aProperties,
nsTArray<LocalAccessible*>& aContainers, int32_t aStartOffset,
HyperTextAccessible* aEndContainer, int32_t aEndOffset) {
if (IsHTMLListItem()) {
@ -275,11 +273,9 @@ void HyperTextAccessibleWrap::AttributedTextForRange(
TextSubstring(0, nsAccUtils::TextLength(bullet), text);
int32_t unusedAttrStartOffset, unusedAttrEndOffset;
nsCOMPtr<nsIPersistentProperties> props =
RefPtr<AccAttributes> props =
TextAttributes(true, aStartOffset - 1, &unusedAttrStartOffset,
&unusedAttrEndOffset);
nsTArray<Attribute> textAttrArray;
nsAccUtils::PersistentPropertiesToArray(props, &textAttrArray);
aStrings.AppendElement(text);
aProperties.AppendElement(props);
@ -294,9 +290,8 @@ void HyperTextAccessibleWrap::AttributedTextForRange(
int32_t attrEndOffset = iter.mCurrentStartOffset;
do {
int32_t oldEndOffset = attrEndOffset;
nsCOMPtr<nsIPersistentProperties> props =
iter.mCurrentContainer->TextAttributes(
true, attrEndOffset, &attrStartOffset, &attrEndOffset);
RefPtr<AccAttributes> props = iter.mCurrentContainer->TextAttributes(
true, attrEndOffset, &attrStartOffset, &attrEndOffset);
if (oldEndOffset == attrEndOffset) {
MOZ_ASSERT_UNREACHABLE("new attribute end offset should be different");

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

@ -58,7 +58,8 @@ using namespace mozilla::a11y;
// Per the MathML 3 spec, the latter happens iff the linethickness
// attribute is of the form [zero-float][optional-unit]. In that case we
// set line thickness to zero and in the other cases we set it to one.
if (NSString* thickness = utils::GetAccAttr(self, "thickness")) {
RefPtr<nsAtom> attrName = NS_Atomize("thickness"_ns);
if (NSString* thickness = utils::GetAccAttr(self, attrName)) {
NSNumberFormatter* formatter =
[[[NSNumberFormatter alloc] init] autorelease];
NSNumber* value = [formatter numberFromString:thickness];

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

@ -35,7 +35,7 @@ NSString* LocalizedString(const nsString& aString);
* accessible wrapper or proxy, and returns the value as an NSString.
* nil if no attribute is found.
*/
NSString* GetAccAttr(mozAccessible* aNativeAccessible, const char* aAttrName);
NSString* GetAccAttr(mozAccessible* aNativeAccessible, nsAtom* aAttrName);
}
}
}

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

@ -10,7 +10,6 @@
#include "LocalAccessible.h"
#include "nsCocoaUtils.h"
#include "mozilla/a11y/PDocAccessible.h"
#include "nsIPersistentProperties2.h"
namespace mozilla {
namespace a11y {
@ -61,18 +60,18 @@ NSString* LocalizedString(const nsString& aString) {
return text.IsEmpty() ? nil : nsCocoaUtils::ToNSString(text);
}
NSString* GetAccAttr(mozAccessible* aNativeAccessible, const char* aAttrName) {
NSString* GetAccAttr(mozAccessible* aNativeAccessible, nsAtom* aAttrName) {
nsAutoString result;
if (LocalAccessible* acc =
[aNativeAccessible geckoAccessible].AsAccessible()) {
nsCOMPtr<nsIPersistentProperties> attributes = acc->Attributes();
attributes->GetStringProperty(nsCString(aAttrName), result);
RefPtr<AccAttributes> attributes = acc->Attributes();
attributes->GetAttribute(aAttrName, result);
} else if (RemoteAccessible* proxy =
[aNativeAccessible geckoAccessible].AsProxy()) {
AutoTArray<Attribute, 10> attrs;
proxy->Attributes(&attrs);
for (size_t i = 0; i < attrs.Length(); i++) {
if (attrs.ElementAt(i).Name() == aAttrName) {
if (aAttrName->Equals(NS_ConvertUTF8toUTF16(attrs.ElementAt(i).Name()))) {
result = attrs.ElementAt(i).Value();
break;
}

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

@ -15,7 +15,6 @@
#include "LocalAccessible-inl.h"
#include "nsAccUtils.h"
#include "nsIPersistentProperties2.h"
#include "DocAccessibleParent.h"
#include "Relation.h"
#include "Role.h"
@ -532,7 +531,7 @@ struct RoleDescrComparator {
- (NSString*)moxRoleDescription {
if (NSString* ariaRoleDescription =
utils::GetAccAttr(self, "roledescription")) {
utils::GetAccAttr(self, nsGkAtoms::aria_roledescription)) {
if ([ariaRoleDescription length]) {
return ariaRoleDescription;
}
@ -717,19 +716,20 @@ struct RoleDescrComparator {
return nil;
}
return utils::GetAccAttr(self, "current");
return utils::GetAccAttr(self, nsGkAtoms::aria_current);
}
- (NSNumber*)moxARIAAtomic {
return @(utils::GetAccAttr(self, "atomic") != nil);
return @(utils::GetAccAttr(self, nsGkAtoms::aria_atomic) != nil);
}
- (NSString*)moxARIALive {
return utils::GetAccAttr(self, "live");
return utils::GetAccAttr(self, nsGkAtoms::aria_live);
}
- (NSString*)moxARIARelevant {
if (NSString* relevant = utils::GetAccAttr(self, "container-relevant")) {
if (NSString* relevant =
utils::GetAccAttr(self, nsGkAtoms::containerRelevant)) {
return relevant;
}
@ -847,13 +847,13 @@ struct RoleDescrComparator {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
NSMutableString* domInfo = [NSMutableString string];
if (NSString* tagName = utils::GetAccAttr(self, "tag")) {
if (NSString* tagName = utils::GetAccAttr(self, nsGkAtoms::tag)) {
[domInfo appendFormat:@" %@", tagName];
NSString* domID = [self moxDOMIdentifier];
if ([domID length]) {
[domInfo appendFormat:@"#%@", domID];
}
if (NSString* className = utils::GetAccAttr(self, "class")) {
if (NSString* className = utils::GetAccAttr(self, nsGkAtoms::_class)) {
[domInfo
appendFormat:@".%@",
[className stringByReplacingOccurrencesOfString:@" "

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

@ -33,7 +33,7 @@ enum CheckboxValue {
- (NSString*)moxPopupValue {
if ([self stateWithMask:states::HASPOPUP] != 0) {
return utils::GetAccAttr(self, "haspopup");
return utils::GetAccAttr(self, nsGkAtoms::aria_haspopup);
}
return nil;

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

@ -5,11 +5,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "LocalAccessible-inl.h"
#include "AccAttributes.h"
#include "HyperTextAccessible-inl.h"
#include "LocalAccessible-inl.h"
#include "mozilla/a11y/PDocAccessible.h"
#include "nsCocoaUtils.h"
#include "nsIPersistentProperties2.h"
#include "nsObjCExceptions.h"
#include "TextLeafAccessible.h"
@ -84,9 +84,8 @@ inline NSString* ToNSString(id aValue) {
return @"true";
}
nsAutoString invalidStr;
nsCOMPtr<nsIPersistentProperties> attributes =
text->DefaultTextAttributes();
nsAccUtils::GetAccAttr(attributes, nsGkAtoms::invalid, invalidStr);
RefPtr<AccAttributes> attributes = text->DefaultTextAttributes();
attributes->GetAttribute(nsGkAtoms::invalid, invalidStr);
if (invalidStr.IsEmpty()) {
// if the attribute had no value, we should still respect the
// invalid state flag.

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

@ -12,6 +12,7 @@
#include "AccessibleRole.h"
#include "AccessibleStates.h"
#include "AccAttributes.h"
#include "Compatibility.h"
#include "ia2AccessibleRelation.h"
#include "IUnknownImpl.h"
@ -23,7 +24,6 @@
#include "nsAccessibilityService.h"
#include "mozilla/PresShell.h"
#include "nsIPersistentProperties2.h"
#include "nsISimpleEnumerator.h"
using namespace mozilla;
@ -469,7 +469,7 @@ ia2Accessible::get_attributes(BSTR* aAttributes) {
// The format is name:value;name:value; with \ for escaping these
// characters ":;=,\".
if (!acc->IsProxy()) {
nsCOMPtr<nsIPersistentProperties> attributes = acc->Attributes();
RefPtr<AccAttributes> attributes = acc->Attributes();
return ConvertToIA2Attributes(attributes, aAttributes);
}
@ -643,7 +643,7 @@ ia2Accessible::ConvertToIA2Attributes(nsTArray<Attribute>* aAttributes,
}
HRESULT
ia2Accessible::ConvertToIA2Attributes(nsIPersistentProperties* aAttributes,
ia2Accessible::ConvertToIA2Attributes(AccAttributes* aAttributes,
BSTR* aIA2Attributes) {
*aIA2Attributes = nullptr;
@ -652,31 +652,18 @@ ia2Accessible::ConvertToIA2Attributes(nsIPersistentProperties* aAttributes,
if (!aAttributes) return S_FALSE;
nsCOMPtr<nsISimpleEnumerator> propEnum;
aAttributes->Enumerate(getter_AddRefs(propEnum));
if (!propEnum) return E_FAIL;
nsAutoString strAttrs;
bool hasMore = false;
while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> propSupports;
propEnum->GetNext(getter_AddRefs(propSupports));
nsCOMPtr<nsIPropertyElement> propElem(do_QueryInterface(propSupports));
if (!propElem) return E_FAIL;
nsAutoCString name;
if (NS_FAILED(propElem->GetKey(name))) return E_FAIL;
for (auto iter : *aAttributes) {
nsAutoString name;
iter.NameAsString(name);
EscapeAttributeChars(name);
nsAutoString value;
if (NS_FAILED(propElem->GetValue(value))) return E_FAIL;
iter.ValueAsString(value);
EscapeAttributeChars(value);
AppendUTF8toUTF16(name, strAttrs);
strAttrs.Append(name);
strAttrs.Append(':');
strAttrs.Append(value);
strAttrs.Append(';');

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

@ -12,12 +12,11 @@
#include "Accessible2_3.h"
class nsIPersistentProperties;
namespace mozilla {
namespace a11y {
class Attribute;
class Accessible;
class AccAttributes;
class AccessibleWrap;
class ia2Accessible : public IAccessible2_3 {
@ -113,7 +112,7 @@ class ia2Accessible : public IAccessible2_3 {
/* [out, retval] */ long* nRanges);
// Helper method
static HRESULT ConvertToIA2Attributes(nsIPersistentProperties* aAttributes,
static HRESULT ConvertToIA2Attributes(AccAttributes* aAttributes,
BSTR* aIA2Attributes);
static HRESULT ConvertToIA2Attributes(nsTArray<Attribute>* aAttributes,
BSTR* aIA2Attributes);

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

@ -59,7 +59,7 @@ ia2AccessibleText::get_attributes(long aOffset, long* aStartOffset,
}
MOZ_ASSERT(!textAcc->IsProxy());
nsCOMPtr<nsIPersistentProperties> attributes =
RefPtr<AccAttributes> attributes =
textAcc->TextAttributes(true, aOffset, &startOffset, &endOffset);
hr = ia2Accessible::ConvertToIA2Attributes(attributes, aTextAttributes);

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

@ -8,7 +8,7 @@
#include "ApplicationAccessibleWrap.h"
#include "nsIGfxInfo.h"
#include "nsPersistentProperties.h"
#include "AccAttributes.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/Components.h"
@ -19,17 +19,15 @@ using namespace mozilla::a11y;
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED0(ApplicationAccessibleWrap, ApplicationAccessible)
already_AddRefed<nsIPersistentProperties>
ApplicationAccessibleWrap::NativeAttributes() {
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
already_AddRefed<AccAttributes> ApplicationAccessibleWrap::NativeAttributes() {
RefPtr<AccAttributes> attributes = new AccAttributes();
nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service();
if (gfxInfo) {
bool isD2DEnabled = false;
gfxInfo->GetD2DEnabled(&isD2DEnabled);
nsAutoString unused;
attributes->SetStringProperty(
"D2D"_ns, isD2DEnabled ? u"true"_ns : u"false"_ns, unused);
attributes->SetAttribute(u"D2D"_ns,
isD2DEnabled ? u"true"_ns : u"false"_ns);
}
return attributes.forget();

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

@ -21,7 +21,7 @@ class ApplicationAccessibleWrap : public ApplicationAccessible {
NS_DECL_ISUPPORTS_INHERITED
// nsAccessible
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual void Shutdown() override;
};

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

@ -6,10 +6,10 @@
#include "uiaRawElmProvider.h"
#include "LocalAccessible-inl.h"
#include "AccAttributes.h"
#include "AccessibleWrap.h"
#include "ARIAMap.h"
#include "nsIPersistentProperties2.h"
#include "LocalAccessible-inl.h"
using namespace mozilla;
using namespace mozilla::a11y;
@ -147,8 +147,8 @@ uiaRawElmProvider::GetPropertyValue(PROPERTYID aPropertyId,
case UIA_AriaRolePropertyId: {
nsAutoString xmlRoles;
nsCOMPtr<nsIPersistentProperties> attributes = mAcc->Attributes();
attributes->GetStringProperty("xml-roles"_ns, xmlRoles);
RefPtr<AccAttributes> attributes = mAcc->Attributes();
attributes->GetAttribute(nsGkAtoms::xmlroles, xmlRoles);
if (!xmlRoles.IsEmpty()) {
aPropertyValue->vt = VT_BSTR;

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

@ -6,6 +6,7 @@
#include "LocalAccessible-inl.h"
#include "mozilla/a11y/DocAccessibleParent.h"
#include "AccAttributes.h"
#include "nsAccUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsIAccessibleRelation.h"
@ -366,21 +367,31 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes) {
return NS_ERROR_FAILURE;
}
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
RefPtr<AccAttributes> attributes = new AccAttributes();
if (LocalAccessible* acc = Intl()) {
nsCOMPtr<nsIPersistentProperties> attributes = acc->Attributes();
attributes.swap(*aAttributes);
return NS_OK;
attributes = acc->Attributes();
} else {
RemoteAccessible* proxy = IntlGeneric()->AsRemote();
AutoTArray<Attribute, 10> attrs;
proxy->Attributes(&attrs);
uint32_t attrCount = attrs.Length();
for (uint32_t i = 0; i < attrCount; i++) {
attributes->SetAttribute(NS_ConvertUTF8toUTF16(attrs[i].Name()),
attrs[i].Value());
}
}
RemoteAccessible* proxy = IntlGeneric()->AsRemote();
AutoTArray<Attribute, 10> attrs;
proxy->Attributes(&attrs);
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
uint32_t attrCount = attrs.Length();
nsAutoString unused;
for (uint32_t i = 0; i < attrCount; i++) {
props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused);
for (auto iter : *attributes) {
nsAutoString name;
iter.NameAsString(name);
nsAutoString value;
iter.ValueAsString(value);
props->SetStringProperty(NS_ConvertUTF16toUTF8(name), value, unused);
}
props.forget(aAttributes);

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

@ -10,11 +10,12 @@
#include "HyperTextAccessible-inl.h"
#include "mozilla/a11y/PDocAccessible.h"
#include "TextRange.h"
#include "AccAttributes.h"
#include "nsComponentManagerUtils.h"
#include "nsPersistentProperties.h"
#include "xpcAccessibleDocument.h"
#include "xpcAccessibleTextRange.h"
#include "nsIPersistentProperties2.h"
#include "nsIMutableArray.h"
using namespace mozilla::a11y;
@ -177,15 +178,25 @@ xpcAccessibleHyperText::GetTextAttributes(
if (!mIntl) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPersistentProperties> props;
if (mIntl->IsLocal()) {
props = Intl()->TextAttributes(aIncludeDefAttrs, aOffset, aStartOffset,
aEndOffset);
} else {
if (mIntl->IsRemote()) {
return NS_ERROR_NOT_IMPLEMENTED;
}
props.forget(aAttributes);
RefPtr<AccAttributes> attributes = Intl()->TextAttributes(
aIncludeDefAttrs, aOffset, aStartOffset, aEndOffset);
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
nsAutoString unused;
for (auto iter : *attributes) {
nsAutoString name;
iter.NameAsString(name);
nsAutoString value;
iter.ValueAsString(value);
props->SetStringProperty(NS_ConvertUTF16toUTF8(name), value, unused);
}
props.forget(aAttributes);
return NS_OK;
}
@ -197,12 +208,23 @@ xpcAccessibleHyperText::GetDefaultTextAttributes(
if (!mIntl) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPersistentProperties> props;
if (mIntl->IsLocal()) {
props = Intl()->DefaultTextAttributes();
} else {
if (mIntl->IsRemote()) {
return NS_ERROR_NOT_IMPLEMENTED;
}
RefPtr<AccAttributes> attributes = Intl()->DefaultTextAttributes();
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
nsAutoString unused;
for (auto iter : *attributes) {
nsAutoString name;
iter.NameAsString(name);
nsAutoString value;
iter.ValueAsString(value);
props->SetStringProperty(NS_ConvertUTF16toUTF8(name), value, unused);
}
props.forget(aAttributes);
return NS_OK;

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

@ -5,6 +5,7 @@
#include "XULTreeGridAccessibleWrap.h"
#include "AccAttributes.h"
#include "nsAccCache.h"
#include "nsAccessibilityService.h"
#include "nsAccUtils.h"
@ -16,7 +17,6 @@
#include "nsQueryObject.h"
#include "nsTreeColumns.h"
#include "nsPersistentProperties.h"
#include "nsITreeSelection.h"
#include "nsComponentManagerUtils.h"
#include "mozilla/PresShell.h"
@ -530,9 +530,8 @@ bool XULTreeGridCellAccessible::Selected() {
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridCellAccessible: LocalAccessible public implementation
already_AddRefed<nsIPersistentProperties>
XULTreeGridCellAccessible::NativeAttributes() {
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
already_AddRefed<AccAttributes> XULTreeGridCellAccessible::NativeAttributes() {
RefPtr<AccAttributes> attributes = new AccAttributes();
// "table-cell-index" attribute
TableAccessible* table = Table();
@ -540,11 +539,11 @@ XULTreeGridCellAccessible::NativeAttributes() {
nsAutoString stringIdx;
stringIdx.AppendInt(table->CellIndexAt(mRow, ColIdx()));
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
attributes->SetAttribute(nsGkAtoms::tableCellIndex, stringIdx);
// "cycles" attribute
if (mColumn->Cycler()) {
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles, u"true"_ns);
attributes->SetAttribute(nsGkAtoms::cycles, u"true"_ns);
}
return attributes.forget();

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

@ -125,7 +125,7 @@ class XULTreeGridCellAccessible : public LeafAccessible,
virtual nsIntRect BoundsInCSSPixels() const override;
virtual ENameValueFlag Name(nsString& aName) const override;
virtual LocalAccessible* FocusedChild() override;
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual already_AddRefed<AccAttributes> NativeAttributes() override;
virtual int32_t IndexInParent() const override;
virtual Relation RelationByType(RelationType aType) const override;
virtual a11y::role NativeRole() const override;