mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1714390 - P6: Make more attribute keys static atoms. r=Jamie
Keys should be static atoms whenever possible. Differential Revision: https://phabricator.services.mozilla.com/D116787
This commit is contained in:
parent
4fc2c36ea8
commit
349592fb91
@ -811,8 +811,8 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
|
|||||||
GECKOBUNDLE_PUT(nodeInfo, "collectionItemInfo", collectionItemInfo);
|
GECKOBUNDLE_PUT(nodeInfo, "collectionItemInfo", collectionItemInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<nsAtom> attrAtom = NS_Atomize("child-item-count"_ns);
|
Maybe<int32_t> rowCount =
|
||||||
Maybe<int32_t> rowCount = aAttributes->GetAttribute<int32_t>(attrAtom);
|
aAttributes->GetAttribute<int32_t>(nsGkAtoms::child_item_count);
|
||||||
if (rowCount) {
|
if (rowCount) {
|
||||||
GECKOBUNDLE_START(collectionInfo);
|
GECKOBUNDLE_START(collectionInfo);
|
||||||
GECKOBUNDLE_PUT(collectionInfo, "rowCount",
|
GECKOBUNDLE_PUT(collectionInfo, "rowCount",
|
||||||
@ -820,8 +820,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle(
|
|||||||
GECKOBUNDLE_PUT(collectionInfo, "columnCount",
|
GECKOBUNDLE_PUT(collectionInfo, "columnCount",
|
||||||
java::sdk::Integer::ValueOf(1));
|
java::sdk::Integer::ValueOf(1));
|
||||||
|
|
||||||
attrAtom = NS_Atomize("hierarchical"_ns);
|
if (aAttributes->HasAttribute(nsGkAtoms::tree)) {
|
||||||
if (aAttributes->HasAttribute(attrAtom)) {
|
|
||||||
GECKOBUNDLE_PUT(collectionInfo, "isHierarchical",
|
GECKOBUNDLE_PUT(collectionInfo, "isHierarchical",
|
||||||
java::sdk::Boolean::TRUE());
|
java::sdk::Boolean::TRUE());
|
||||||
}
|
}
|
||||||
|
@ -66,20 +66,6 @@ class AccAttributes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: This will be removed in a later patch in the stack. This is
|
|
||||||
// just a stop-gap before we transtion to atom-only keys.
|
|
||||||
template <typename T>
|
|
||||||
void SetAttribute(const nsAString& aAttrName, const T& aAttrValue) {
|
|
||||||
RefPtr<nsAtom> attrAtom = NS_Atomize(aAttrName);
|
|
||||||
if constexpr (std::is_base_of_v<nsAtom, std::remove_pointer_t<T>>) {
|
|
||||||
mData.InsertOrUpdate(attrAtom, AsVariant(RefPtr<nsAtom>(aAttrValue)));
|
|
||||||
} else if constexpr (std::is_base_of_v<detail::nsStringRepr, T>) {
|
|
||||||
mData.InsertOrUpdate(attrAtom, AsVariant(nsString(aAttrValue)));
|
|
||||||
} else {
|
|
||||||
mData.InsertOrUpdate(attrAtom, AsVariant(aAttrValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Maybe<T> GetAttribute(nsAtom* aAttrName) {
|
Maybe<T> GetAttribute(nsAtom* aAttrName) {
|
||||||
if (auto value = mData.Lookup(aAttrName)) {
|
if (auto value = mData.Lookup(aAttrName)) {
|
||||||
|
@ -40,7 +40,7 @@ already_AddRefed<AccAttributes> ARIAGridAccessible::NativeAttributes() {
|
|||||||
RefPtr<AccAttributes> attributes = AccessibleWrap::NativeAttributes();
|
RefPtr<AccAttributes> attributes = AccessibleWrap::NativeAttributes();
|
||||||
|
|
||||||
if (IsProbablyLayoutTable()) {
|
if (IsProbablyLayoutTable()) {
|
||||||
attributes->SetAttribute(u"layout-guess"_ns, true);
|
attributes->SetAttribute(nsGkAtoms::layout_guess, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return attributes.forget();
|
return attributes.forget();
|
||||||
@ -608,7 +608,8 @@ already_AddRefed<AccAttributes> ARIAGridCellAccessible::NativeAttributes() {
|
|||||||
rowIdx * colCount + colIdx);
|
rowIdx * colCount + colIdx);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
attributes->SetAttribute(u"cppclass"_ns, u"ARIAGridCellAccessible"_ns);
|
RefPtr<nsAtom> cppClass = NS_Atomize(u"cppclass"_ns);
|
||||||
|
attributes->SetAttribute(cppClass, u"ARIAGridCellAccessible"_ns);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return attributes.forget();
|
return attributes.forget();
|
||||||
|
@ -1411,7 +1411,7 @@ already_AddRefed<AccAttributes> HyperTextAccessible::NativeAttributes() {
|
|||||||
// instead.
|
// instead.
|
||||||
nsIFrame* frame = GetFrame();
|
nsIFrame* frame = GetFrame();
|
||||||
if (frame && frame->IsBlockFrame()) {
|
if (frame && frame->IsBlockFrame()) {
|
||||||
attributes->SetAttribute(u"formatting"_ns, nsGkAtoms::block);
|
attributes->SetAttribute(nsGkAtoms::formatting, nsGkAtoms::block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FocusMgr()->IsFocused(this)) {
|
if (FocusMgr()->IsFocused(this)) {
|
||||||
|
@ -1019,7 +1019,7 @@ already_AddRefed<AccAttributes> LocalAccessible::NativeAttributes() {
|
|||||||
if (HasNumericValue()) {
|
if (HasNumericValue()) {
|
||||||
nsAutoString valuetext;
|
nsAutoString valuetext;
|
||||||
Value(valuetext);
|
Value(valuetext);
|
||||||
attributes->SetAttribute(u"valuetext"_ns, valuetext);
|
attributes->SetAttribute(nsGkAtoms::aria_valuetext, valuetext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expose checkable object attribute if the accessible has checkable state
|
// Expose checkable object attribute if the accessible has checkable state
|
||||||
@ -1030,7 +1030,7 @@ already_AddRefed<AccAttributes> LocalAccessible::NativeAttributes() {
|
|||||||
// Expose 'explicit-name' attribute.
|
// Expose 'explicit-name' attribute.
|
||||||
nsAutoString name;
|
nsAutoString name;
|
||||||
if (Name(name) != eNameFromSubtree && !name.IsVoid()) {
|
if (Name(name) != eNameFromSubtree && !name.IsVoid()) {
|
||||||
attributes->SetAttribute(u"explicit-name"_ns, true);
|
attributes->SetAttribute(nsGkAtoms::explicit_name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group attributes (level/setsize/posinset)
|
// Group attributes (level/setsize/posinset)
|
||||||
@ -1041,12 +1041,12 @@ already_AddRefed<AccAttributes> LocalAccessible::NativeAttributes() {
|
|||||||
bool hierarchical = false;
|
bool hierarchical = false;
|
||||||
uint32_t itemCount = AccGroupInfo::TotalItemCount(this, &hierarchical);
|
uint32_t itemCount = AccGroupInfo::TotalItemCount(this, &hierarchical);
|
||||||
if (itemCount) {
|
if (itemCount) {
|
||||||
attributes->SetAttribute(u"child-item-count"_ns,
|
attributes->SetAttribute(nsGkAtoms::child_item_count,
|
||||||
static_cast<int32_t>(itemCount));
|
static_cast<int32_t>(itemCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hierarchical) {
|
if (hierarchical) {
|
||||||
attributes->SetAttribute(u"hierarchical"_ns, true);
|
attributes->SetAttribute(nsGkAtoms::tree, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the accessible doesn't have own content (such as list item bullet or
|
// If the accessible doesn't have own content (such as list item bullet or
|
||||||
|
@ -118,7 +118,8 @@ already_AddRefed<AccAttributes> HTMLTableCellAccessible::NativeAttributes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
attributes->SetAttribute(u"cppclass"_ns, u"HTMLTableCellAccessible"_ns);
|
RefPtr<nsAtom> cppClass = NS_Atomize(u"cppclass"_ns);
|
||||||
|
attributes->SetAttribute(cppClass, u"HTMLTableCellAccessible"_ns);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return attributes.forget();
|
return attributes.forget();
|
||||||
@ -398,7 +399,7 @@ already_AddRefed<AccAttributes> HTMLTableAccessible::NativeAttributes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsProbablyLayoutTable()) {
|
if (IsProbablyLayoutTable()) {
|
||||||
attributes->SetAttribute(u"layout-guess"_ns, true);
|
attributes->SetAttribute(nsGkAtoms::layout_guess, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return attributes.forget();
|
return attributes.forget();
|
||||||
|
@ -58,8 +58,8 @@ using namespace mozilla::a11y;
|
|||||||
// Per the MathML 3 spec, the latter happens iff the linethickness
|
// Per the MathML 3 spec, the latter happens iff the linethickness
|
||||||
// attribute is of the form [zero-float][optional-unit]. In that case we
|
// 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.
|
// set line thickness to zero and in the other cases we set it to one.
|
||||||
RefPtr<nsAtom> attrName = NS_Atomize("thickness"_ns);
|
if (NSString* thickness =
|
||||||
if (NSString* thickness = utils::GetAccAttr(self, attrName)) {
|
utils::GetAccAttr(self, nsGkAtoms::linethickness_)) {
|
||||||
NSNumberFormatter* formatter =
|
NSNumberFormatter* formatter =
|
||||||
[[[NSNumberFormatter alloc] init] autorelease];
|
[[[NSNumberFormatter alloc] init] autorelease];
|
||||||
NSNumber* value = [formatter numberFromString:thickness];
|
NSNumber* value = [formatter numberFromString:thickness];
|
||||||
|
@ -138,9 +138,9 @@ function testGroupParentAttrs(aAccOrElmOrID, aChildItemCount, aIsHierarchical) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (aIsHierarchical) {
|
if (aIsHierarchical) {
|
||||||
testAttrs(aAccOrElmOrID, { hierarchical: "true" }, true);
|
testAttrs(aAccOrElmOrID, { tree: "true" }, true);
|
||||||
} else {
|
} else {
|
||||||
testAbsentAttrs(aAccOrElmOrID, { hierarchical: "true" });
|
testAbsentAttrs(aAccOrElmOrID, { tree: "true" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@
|
|||||||
testGroupAttrs("h5", 0, 0, 5);
|
testGroupAttrs("h5", 0, 0, 5);
|
||||||
testGroupAttrs("h6", 0, 0, 6);
|
testGroupAttrs("h6", 0, 0, 6);
|
||||||
testGroupAttrs("ariaHeadingNoLevel", 0, 0, 2);
|
testGroupAttrs("ariaHeadingNoLevel", 0, 0, 2);
|
||||||
// No child item counts or "hierarchical" flag for parent of headings
|
// No child item counts or "tree" flag for parent of headings
|
||||||
testAbsentAttrs("headings", {"child-item-count": "", "hierarchical": ""});
|
testAbsentAttrs("headings", {"child-item-count": "", "tree": ""});
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////////
|
||||||
// ARIA combobox
|
// ARIA combobox
|
||||||
|
@ -26,7 +26,8 @@ already_AddRefed<AccAttributes> ApplicationAccessibleWrap::NativeAttributes() {
|
|||||||
if (gfxInfo) {
|
if (gfxInfo) {
|
||||||
bool isD2DEnabled = false;
|
bool isD2DEnabled = false;
|
||||||
gfxInfo->GetD2DEnabled(&isD2DEnabled);
|
gfxInfo->GetD2DEnabled(&isD2DEnabled);
|
||||||
attributes->SetAttribute(u"D2D"_ns, isD2DEnabled);
|
RefPtr<nsAtom> attrName = NS_Atomize(u"D2D"_ns);
|
||||||
|
attributes->SetAttribute(attrName, isD2DEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
return attributes.forget();
|
return attributes.forget();
|
||||||
|
@ -378,8 +378,8 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes) {
|
|||||||
proxy->Attributes(&attrs);
|
proxy->Attributes(&attrs);
|
||||||
uint32_t attrCount = attrs.Length();
|
uint32_t attrCount = attrs.Length();
|
||||||
for (uint32_t i = 0; i < attrCount; i++) {
|
for (uint32_t i = 0; i < attrCount; i++) {
|
||||||
attributes->SetAttribute(NS_ConvertUTF8toUTF16(attrs[i].Name()),
|
RefPtr<nsAtom> nameAttr = NS_Atomize(attrs[i].Name());
|
||||||
attrs[i].Value());
|
attributes->SetAttribute(nameAttr, attrs[i].Value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +224,7 @@ STATIC_ATOMS = [
|
|||||||
Atom("child", "child"),
|
Atom("child", "child"),
|
||||||
Atom("children", "children"),
|
Atom("children", "children"),
|
||||||
Atom("childList", "childList"),
|
Atom("childList", "childList"),
|
||||||
|
Atom("child_item_count", "child-item-count"),
|
||||||
Atom("choose", "choose"),
|
Atom("choose", "choose"),
|
||||||
Atom("chromemargin", "chromemargin"),
|
Atom("chromemargin", "chromemargin"),
|
||||||
Atom("exposeToUntrustedContent", "exposeToUntrustedContent"),
|
Atom("exposeToUntrustedContent", "exposeToUntrustedContent"),
|
||||||
@ -422,6 +423,7 @@ STATIC_ATOMS = [
|
|||||||
Atom("events", "events"),
|
Atom("events", "events"),
|
||||||
Atom("excludeResultPrefixes", "exclude-result-prefixes"),
|
Atom("excludeResultPrefixes", "exclude-result-prefixes"),
|
||||||
Atom("exportparts", "exportparts"),
|
Atom("exportparts", "exportparts"),
|
||||||
|
Atom("explicit_name", "explicit-name"),
|
||||||
Atom("extends", "extends"),
|
Atom("extends", "extends"),
|
||||||
Atom("extensionElementPrefixes", "extension-element-prefixes"),
|
Atom("extensionElementPrefixes", "extension-element-prefixes"),
|
||||||
Atom("face", "face"),
|
Atom("face", "face"),
|
||||||
@ -583,6 +585,7 @@ STATIC_ATOMS = [
|
|||||||
Atom("last", "last"),
|
Atom("last", "last"),
|
||||||
Atom("layer", "layer"),
|
Atom("layer", "layer"),
|
||||||
Atom("LayerActivity", "LayerActivity"),
|
Atom("LayerActivity", "LayerActivity"),
|
||||||
|
Atom("layout_guess", "layout-guess"),
|
||||||
Atom("leading", "leading"),
|
Atom("leading", "leading"),
|
||||||
Atom("leaf", "leaf"),
|
Atom("leaf", "leaf"),
|
||||||
Atom("left", "left"),
|
Atom("left", "left"),
|
||||||
@ -1398,6 +1401,7 @@ STATIC_ATOMS = [
|
|||||||
Atom("font_stretch", "font-stretch"),
|
Atom("font_stretch", "font-stretch"),
|
||||||
Atom("font_style", "font-style"),
|
Atom("font_style", "font-style"),
|
||||||
Atom("font_variant", "font-variant"),
|
Atom("font_variant", "font-variant"),
|
||||||
|
Atom("formatting", "formatting"),
|
||||||
Atom("foreignObject", "foreignObject"),
|
Atom("foreignObject", "foreignObject"),
|
||||||
Atom("fractalNoise", "fractalNoise"),
|
Atom("fractalNoise", "fractalNoise"),
|
||||||
Atom("fr", "fr"),
|
Atom("fr", "fr"),
|
||||||
|
Loading…
Reference in New Issue
Block a user