зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1746833 - P2: Move Value() to Accessible and calculate or use cached value remotely. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D138948
This commit is contained in:
Родитель
7f1f3ec926
Коммит
6159254eee
|
@ -168,6 +168,11 @@ class Accessible {
|
|||
*/
|
||||
virtual void Description(nsString& aDescription) const = 0;
|
||||
|
||||
/**
|
||||
* Get the value of this accessible.
|
||||
*/
|
||||
virtual void Value(nsString& aValue) const = 0;
|
||||
|
||||
virtual double CurValue() const = 0;
|
||||
virtual double MinValue() const = 0;
|
||||
virtual double MaxValue() const = 0;
|
||||
|
|
|
@ -137,7 +137,7 @@ class LocalAccessible : public nsISupports, public Accessible {
|
|||
/**
|
||||
* Get the value of this accessible.
|
||||
*/
|
||||
virtual void Value(nsString& aValue) const;
|
||||
virtual void Value(nsString& aValue) const override;
|
||||
|
||||
/**
|
||||
* Get help string for the accessible.
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* 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 "ARIAMap.h"
|
||||
#include "DocAccessible.h"
|
||||
#include "mozilla/a11y/DocAccessibleParent.h"
|
||||
#include "mozilla/a11y/DocManager.h"
|
||||
|
@ -206,6 +207,47 @@ void RemoteAccessibleBase<Derived>::Description(nsString& aDescription) const {
|
|||
}
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
void RemoteAccessibleBase<Derived>::Value(nsString& aValue) const {
|
||||
if (mCachedFields) {
|
||||
if (mCachedFields->HasAttribute(nsGkAtoms::aria_valuetext)) {
|
||||
mCachedFields->GetAttribute(nsGkAtoms::aria_valuetext, aValue);
|
||||
VERIFY_CACHE(CacheDomain::Value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasNumericValue()) {
|
||||
double checkValue = CurValue();
|
||||
if (!IsNaN(checkValue)) {
|
||||
aValue.AppendFloat(checkValue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const nsRoleMapEntry* roleMapEntry = ARIARoleMap();
|
||||
// Value of textbox is a textified subtree.
|
||||
if (roleMapEntry && roleMapEntry->Is(nsGkAtoms::textbox)) {
|
||||
// XXX: nsTextEquivUtils::GetTextEquivFromSubtree(this, aValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsCombobox()) {
|
||||
Pivot p = Pivot(const_cast<RemoteAccessibleBase<Derived>*>(this));
|
||||
PivotStateRule rule(states::ACTIVE);
|
||||
Accessible* option = p.First(rule);
|
||||
if (!option) {
|
||||
option =
|
||||
const_cast<RemoteAccessibleBase<Derived>*>(this)->GetSelectedItem(
|
||||
0);
|
||||
}
|
||||
|
||||
if (option) {
|
||||
option->Name(aValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
double RemoteAccessibleBase<Derived>::CurValue() const {
|
||||
if (mCachedFields) {
|
||||
|
|
|
@ -166,6 +166,7 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
|
|||
|
||||
virtual ENameValueFlag Name(nsString& aName) const override;
|
||||
virtual void Description(nsString& aDescription) const override;
|
||||
virtual void Value(nsString& aValue) const override;
|
||||
|
||||
virtual double CurValue() const override;
|
||||
virtual double MinValue() const override;
|
||||
|
|
|
@ -31,7 +31,7 @@ ENameValueFlag Name(nsString& aName) const override;
|
|||
/*
|
||||
* Set aValue to the value of the proxied accessible.
|
||||
*/
|
||||
void Value(nsString& aValue) const;
|
||||
void Value(nsString& aValue) const override;
|
||||
|
||||
/*
|
||||
* Set aHelp to the help string of the proxied accessible.
|
||||
|
|
|
@ -46,6 +46,11 @@ ENameValueFlag RemoteAccessible::Name(nsString& aName) const {
|
|||
}
|
||||
|
||||
void RemoteAccessible::Value(nsString& aValue) const {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
RemoteAccessibleBase<RemoteAccessible>::Value(aValue);
|
||||
return;
|
||||
}
|
||||
|
||||
Unused << mDoc->SendValue(mID, &aValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -151,6 +151,11 @@ ENameValueFlag RemoteAccessible::Name(nsString& aName) const {
|
|||
}
|
||||
|
||||
void RemoteAccessible::Value(nsString& aValue) const {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
RemoteAccessibleBase<RemoteAccessible>::Value(aValue);
|
||||
return;
|
||||
}
|
||||
|
||||
aValue.Truncate();
|
||||
RefPtr<IAccessible> acc;
|
||||
if (!GetCOMInterface((void**)getter_AddRefs(acc))) {
|
||||
|
|
|
@ -612,11 +612,7 @@ struct RoleDescrComparator {
|
|||
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
|
||||
|
||||
nsAutoString value;
|
||||
if (LocalAccessible* acc = mGeckoAccessible->AsLocal()) {
|
||||
acc->Value(value);
|
||||
} else {
|
||||
mGeckoAccessible->AsRemote()->Value(value);
|
||||
}
|
||||
mGeckoAccessible->Value(value);
|
||||
|
||||
return nsCocoaUtils::ToNSString(value);
|
||||
|
||||
|
|
|
@ -48,11 +48,7 @@ using namespace mozilla::a11y;
|
|||
|
||||
- (NSURL*)moxURL {
|
||||
nsAutoString value;
|
||||
if (LocalAccessible* acc = mGeckoAccessible->AsLocal()) {
|
||||
acc->Value(value);
|
||||
} else if (RemoteAccessible* proxy = mGeckoAccessible->AsRemote()) {
|
||||
proxy->Value(value);
|
||||
}
|
||||
mGeckoAccessible->Value(value);
|
||||
|
||||
NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value);
|
||||
if (!urlString) return nil;
|
||||
|
|
|
@ -1005,12 +1005,9 @@ MsaaAccessible::get_accValue(
|
|||
if (accessible) {
|
||||
return accessible->get_accValue(kVarChildIdSelf, pszValue);
|
||||
}
|
||||
if (mAcc->IsRemote()) {
|
||||
return E_NOTIMPL; // XXX Not supported for RemoteAccessible yet.
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
LocalAcc()->Value(value);
|
||||
Acc()->Value(value);
|
||||
|
||||
// See bug 438784: need to expose URL on doc's value attribute. For this,
|
||||
// reverting part of fix for bug 425693 to make this MSAA method behave
|
||||
|
|
|
@ -282,11 +282,7 @@ xpcAccessible::GetValue(nsAString& aValue) {
|
|||
if (!IntlGeneric()) return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString value;
|
||||
if (RemoteAccessible* proxy = IntlGeneric()->AsRemote()) {
|
||||
proxy->Value(value);
|
||||
} else {
|
||||
Intl()->Value(value);
|
||||
}
|
||||
IntlGeneric()->Value(value);
|
||||
|
||||
aValue.Assign(value);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче