mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1742915 part 1: Move Attributes to base Accessible. r=morgan
The RemoteAccessibleBase implementation is a stub for now, but will be expanded in the next patch. Differential Revision: https://phabricator.services.mozilla.com/D132652
This commit is contained in:
parent
97f96f4f0b
commit
25f7ff3485
@ -658,20 +658,12 @@ static AtkAttributeSet* ConvertToAtkAttributeSet(AccAttributes* aAttributes) {
|
||||
return objAttributeSet;
|
||||
}
|
||||
|
||||
AtkAttributeSet* GetAttributeSet(LocalAccessible* aAccessible) {
|
||||
RefPtr<AccAttributes> attributes = aAccessible->Attributes();
|
||||
return ConvertToAtkAttributeSet(attributes);
|
||||
}
|
||||
|
||||
AtkAttributeSet* getAttributesCB(AtkObject* aAtkObj) {
|
||||
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
||||
if (accWrap) return GetAttributeSet(accWrap);
|
||||
|
||||
RemoteAccessible* proxy = GetProxy(aAtkObj);
|
||||
if (!proxy) return nullptr;
|
||||
|
||||
RefPtr<AccAttributes> attributes = nullptr;
|
||||
proxy->Attributes(&attributes);
|
||||
Accessible* acc = GetInternalObj(aAtkObj);
|
||||
if (!acc) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<AccAttributes> attributes = acc->Attributes();
|
||||
return ConvertToAtkAttributeSet(attributes);
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ struct nsRoleMapEntry;
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class AccAttributes;
|
||||
class HyperTextAccessibleBase;
|
||||
class LocalAccessible;
|
||||
class RemoteAccessible;
|
||||
@ -163,6 +164,11 @@ class Accessible {
|
||||
*/
|
||||
virtual uint32_t StartOffset();
|
||||
|
||||
/**
|
||||
* Return object attributes for the accessible.
|
||||
*/
|
||||
virtual already_AddRefed<AccAttributes> Attributes() = 0;
|
||||
|
||||
// Methods that interact with content.
|
||||
|
||||
virtual void TakeFocus() const = 0;
|
||||
|
@ -242,10 +242,7 @@ class LocalAccessible : public nsISupports, public Accessible {
|
||||
*/
|
||||
virtual bool NativelyUnavailable() const;
|
||||
|
||||
/**
|
||||
* Return object attributes for the accessible.
|
||||
*/
|
||||
virtual already_AddRefed<AccAttributes> Attributes();
|
||||
virtual already_AddRefed<AccAttributes> Attributes() override;
|
||||
|
||||
/**
|
||||
* Return group position (level, position in set and set size).
|
||||
|
@ -467,6 +467,12 @@ uint64_t RemoteAccessibleBase<Derived>::State() {
|
||||
return state;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
already_AddRefed<AccAttributes> RemoteAccessibleBase<Derived>::Attributes() {
|
||||
RefPtr<AccAttributes> attributes = new AccAttributes();
|
||||
return attributes.forget();
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
void RemoteAccessibleBase<Derived>::TakeFocus() const {
|
||||
Unused << mDoc->SendTakeFocus(mID);
|
||||
|
@ -180,6 +180,8 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
|
||||
|
||||
virtual uint64_t State() override;
|
||||
|
||||
virtual already_AddRefed<AccAttributes> Attributes() override;
|
||||
|
||||
// Methods that interact with content.
|
||||
|
||||
virtual void TakeFocus() const override;
|
||||
|
@ -46,7 +46,7 @@ void Description(nsString& aDesc) const override;
|
||||
/**
|
||||
* Get the set of attributes on the proxied accessible.
|
||||
*/
|
||||
void Attributes(RefPtr<AccAttributes>* aAttributes) const;
|
||||
virtual already_AddRefed<AccAttributes> Attributes() override;
|
||||
|
||||
/**
|
||||
* Return set of targets of given relation type.
|
||||
|
@ -62,8 +62,13 @@ void RemoteAccessible::Description(nsString& aDesc) const {
|
||||
Unused << mDoc->SendDescription(mID, &aDesc);
|
||||
}
|
||||
|
||||
void RemoteAccessible::Attributes(RefPtr<AccAttributes>* aAttributes) const {
|
||||
Unused << mDoc->SendAttributes(mID, aAttributes);
|
||||
already_AddRefed<AccAttributes> RemoteAccessible::Attributes() {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
return RemoteAccessibleBase<RemoteAccessible>::Attributes();
|
||||
}
|
||||
RefPtr<AccAttributes> attrs;
|
||||
Unused << mDoc->SendAttributes(mID, &attrs);
|
||||
return attrs.forget();
|
||||
}
|
||||
|
||||
nsTArray<RemoteAccessible*> RemoteAccessible::RelationByType(
|
||||
|
@ -353,28 +353,32 @@ static bool ConvertBSTRAttributesToAccAttributes(
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoteAccessible::Attributes(RefPtr<AccAttributes>* aAttrs) const {
|
||||
already_AddRefed<AccAttributes> RemoteAccessible::Attributes() {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
return RemoteAccessibleBase<RemoteAccessible>::Attributes();
|
||||
}
|
||||
RefPtr<AccAttributes> attrsObj = new AccAttributes();
|
||||
RefPtr<IAccessible> acc;
|
||||
if (!GetCOMInterface((void**)getter_AddRefs(acc))) {
|
||||
return;
|
||||
return attrsObj.forget();
|
||||
}
|
||||
|
||||
RefPtr<IAccessible2> acc2;
|
||||
if (FAILED(acc->QueryInterface(IID_IAccessible2,
|
||||
(void**)getter_AddRefs(acc2)))) {
|
||||
return;
|
||||
return attrsObj.forget();
|
||||
}
|
||||
|
||||
BSTR attrs;
|
||||
HRESULT hr = acc2->get_attributes(&attrs);
|
||||
_bstr_t attrsWrap(attrs, false);
|
||||
if (FAILED(hr)) {
|
||||
return;
|
||||
return attrsObj.forget();
|
||||
}
|
||||
|
||||
*aAttrs = new AccAttributes();
|
||||
ConvertBSTRAttributesToAccAttributes(
|
||||
nsDependentString((wchar_t*)attrs, attrsWrap.length()), *aAttrs);
|
||||
nsDependentString((wchar_t*)attrs, attrsWrap.length()), attrsObj);
|
||||
return attrsObj.forget();
|
||||
}
|
||||
|
||||
nsTArray<RemoteAccessible*> RemoteAccessible::RelationByType(
|
||||
|
@ -62,13 +62,8 @@ NSString* LocalizedString(const nsString& aString) {
|
||||
|
||||
NSString* GetAccAttr(mozAccessible* aNativeAccessible, nsAtom* aAttrName) {
|
||||
nsAutoString result;
|
||||
RefPtr<AccAttributes> attributes;
|
||||
if (LocalAccessible* acc = [aNativeAccessible geckoAccessible]->AsLocal()) {
|
||||
attributes = acc->Attributes();
|
||||
} else if (RemoteAccessible* proxy =
|
||||
[aNativeAccessible geckoAccessible]->AsRemote()) {
|
||||
proxy->Attributes(&attributes);
|
||||
}
|
||||
Accessible* acc = [aNativeAccessible geckoAccessible];
|
||||
RefPtr<AccAttributes> attributes = acc->Attributes();
|
||||
|
||||
attributes->GetAttribute(aAttrName, result);
|
||||
|
||||
|
@ -453,12 +453,9 @@ ia2Accessible::get_attributes(BSTR* aAttributes) {
|
||||
if (!aAttributes) return E_INVALIDARG;
|
||||
*aAttributes = nullptr;
|
||||
|
||||
if (!Acc()) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
AccessibleWrap* acc = LocalAcc();
|
||||
Accessible* acc = Acc();
|
||||
if (!acc) {
|
||||
return E_NOTIMPL; // XXX Not supported for RemoteAccessible yet.
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
|
||||
// The format is name:value;name:value; with \ for escaping these
|
||||
|
@ -359,13 +359,7 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes) {
|
||||
|
||||
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
|
||||
|
||||
RefPtr<AccAttributes> attributes;
|
||||
if (LocalAccessible* acc = Intl()) {
|
||||
attributes = acc->Attributes();
|
||||
} else {
|
||||
RemoteAccessible* proxy = IntlGeneric()->AsRemote();
|
||||
proxy->Attributes(&attributes);
|
||||
}
|
||||
RefPtr<AccAttributes> attributes = IntlGeneric()->Attributes();
|
||||
|
||||
nsAutoString unused;
|
||||
for (auto iter : *attributes) {
|
||||
|
Loading…
Reference in New Issue
Block a user