Bug 1727643 - P2: Send numeric value fields to cache. r=morgan

Also added double to AccAttributes.

Differential Revision: https://phabricator.services.mozilla.com/D123696
This commit is contained in:
Eitan Isaacson 2021-08-26 19:40:05 +00:00
Родитель 3c7fe28200
Коммит 17e9670742
3 изменённых файлов: 35 добавлений и 9 удалений

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

@ -30,6 +30,7 @@ void AccAttributes::StringFromValueAndName(nsAtom* aAttrName,
aValueString.AppendFloat(val * 100);
aValueString.Append(u"%");
},
[&aValueString](const double& val) { aValueString.AppendFloat(val); },
[&aValueString](const int32_t& val) { aValueString.AppendInt(val); },
[&aValueString](const RefPtr<nsAtom>& val) {
val->ToString(aValueString);

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

@ -38,8 +38,8 @@ struct Color {
class AccAttributes {
friend struct IPC::ParamTraits<AccAttributes*>;
using AttrValueType =
Variant<bool, float, int32_t, RefPtr<nsAtom>, CSSCoord, FontSize, Color>;
using AttrValueType = Variant<bool, float, double, int32_t, RefPtr<nsAtom>,
CSSCoord, FontSize, Color>;
static_assert(sizeof(AttrValueType) <= 16);
using AtomVariantMap = nsTHashMap<nsRefPtrHashKey<nsAtom>, AttrValueType>;

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

@ -963,6 +963,11 @@ nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) {
ipcDoc->SendEvent(id, aEvent->GetEventType());
break;
}
case nsIAccessibleEvent::EVENT_VALUE_CHANGE: {
SendCacheUpdate(CacheDomain::Value);
ipcDoc->SendEvent(id, aEvent->GetEventType());
break;
}
default:
ipcDoc->SendEvent(id, aEvent->GetEventType());
}
@ -1227,19 +1232,32 @@ void LocalAccessible::DOMAttributeChanged(int32_t aNameSpaceID,
dom::Element* elm = Elm();
if (HasNumericValue() &&
(aAttribute == nsGkAtoms::aria_valuemax ||
aAttribute == nsGkAtoms::aria_valuemin || aAttribute == nsGkAtoms::min ||
aAttribute == nsGkAtoms::max || aAttribute == nsGkAtoms::step)) {
SendCacheUpdate(CacheDomain::Value);
return;
}
// Fire text value change event whenever aria-valuetext is changed.
if (aAttribute == nsGkAtoms::aria_valuetext) {
mDoc->FireDelayedEvent(nsIAccessibleEvent::EVENT_TEXT_VALUE_CHANGE, this);
return;
}
// Fire numeric value change event when aria-valuenow is changed and
// aria-valuetext is empty
if (aAttribute == nsGkAtoms::aria_valuenow &&
(!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_valuetext) ||
elm->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_valuetext,
nsGkAtoms::_empty, eCaseMatters))) {
mDoc->FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, this);
if (aAttribute == nsGkAtoms::aria_valuenow) {
if (!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_valuetext) ||
elm->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_valuetext,
nsGkAtoms::_empty, eCaseMatters)) {
// Fire numeric value change event when aria-valuenow is changed and
// aria-valuetext is empty
mDoc->FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, this);
} else {
// We need to update the cache here since we won't get an event if
// aria-valuenow is shadowed by aria-valuetext.
SendCacheUpdate(CacheDomain::Value);
}
return;
}
@ -3010,6 +3028,13 @@ already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache(
fields->SetAttribute(nsGkAtoms::name, name);
}
if ((aCacheDomain & CacheDomain::Value) && HasNumericValue()) {
fields->SetAttribute(nsGkAtoms::value, CurValue());
fields->SetAttribute(nsGkAtoms::max, MaxValue());
fields->SetAttribute(nsGkAtoms::min, MinValue());
fields->SetAttribute(nsGkAtoms::step, Step());
}
return fields.forget();
}