зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1700264 - Cache names. r=Jamie
Eventually we will want to add the Name method as an abstract method in Accessible and implemented it platform-independent in RemoteAccessibleBase. Differential Revision: https://phabricator.services.mozilla.com/D121925
This commit is contained in:
Родитель
b3e528f978
Коммит
5090a9049a
|
@ -75,6 +75,7 @@
|
|||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ProfilerMarkers.h"
|
||||
#include "mozilla/StaticPrefs_accessibility.h"
|
||||
#include "mozilla/StaticPrefs_ui.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2D.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
@ -954,6 +955,21 @@ nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) {
|
|||
ipcDoc->SendTextSelectionChangeEvent(id, textRangeData);
|
||||
break;
|
||||
}
|
||||
case nsIAccessibleEvent::EVENT_NAME_CHANGE: {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
nsAutoString name;
|
||||
int32_t nameFlag = Name(name);
|
||||
RefPtr<AccAttributes> fields = new AccAttributes();
|
||||
fields->SetAttribute(nsGkAtoms::explicit_name, nameFlag);
|
||||
fields->SetAttribute(nsGkAtoms::name, name);
|
||||
nsTArray<CacheData> data;
|
||||
data.AppendElement(CacheData(
|
||||
IsDoc() ? 0 : reinterpret_cast<uint64_t>(UniqueID()), fields));
|
||||
ipcDoc->SendCache(1, data, true);
|
||||
}
|
||||
ipcDoc->SendEvent(id, aEvent->GetEventType());
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
ipcDoc->SendEvent(id, aEvent->GetEventType());
|
||||
|
@ -2973,6 +2989,16 @@ AccGroupInfo* LocalAccessible::GetGroupInfo() const {
|
|||
return mBits.groupInfo;
|
||||
}
|
||||
|
||||
already_AddRefed<AccAttributes> LocalAccessible::BundleFieldsForCache() {
|
||||
RefPtr<AccAttributes> fields = new AccAttributes();
|
||||
nsAutoString name;
|
||||
int32_t nameFlag = Name(name);
|
||||
fields->SetAttribute(nsGkAtoms::explicit_name, nameFlag);
|
||||
fields->SetAttribute(nsGkAtoms::name, name);
|
||||
|
||||
return fields.forget();
|
||||
}
|
||||
|
||||
void LocalAccessible::MaybeFireFocusableStateChange(bool aPreviouslyFocusable) {
|
||||
bool isFocusable = (State() & states::FOCUSABLE);
|
||||
if (isFocusable != aPreviouslyFocusable) {
|
||||
|
|
|
@ -36,6 +36,7 @@ class AccAttributes;
|
|||
class AccEvent;
|
||||
class AccGroupInfo;
|
||||
class ApplicationAccessible;
|
||||
class CacheData;
|
||||
class DocAccessible;
|
||||
class EmbeddedObjCollector;
|
||||
class EventTree;
|
||||
|
@ -910,6 +911,8 @@ class LocalAccessible : public nsISupports, public Accessible {
|
|||
|
||||
virtual bool IsRemote() const override { return false; }
|
||||
|
||||
already_AddRefed<AccAttributes> BundleFieldsForCache();
|
||||
|
||||
protected:
|
||||
virtual ~LocalAccessible();
|
||||
|
||||
|
|
|
@ -76,6 +76,15 @@ void DocAccessibleChildBase::InsertIntoIpcTree(LocalAccessible* aParent,
|
|||
aSuppressShowEvent);
|
||||
SerializeTree(shownTree, data.NewTree());
|
||||
MaybeSendShowEvent(data, false);
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
nsTArray<CacheData> cache(shownTree.Length());
|
||||
for (LocalAccessible* acc : shownTree) {
|
||||
uint64_t id = reinterpret_cast<uint64_t>(acc->UniqueID());
|
||||
RefPtr<AccAttributes> fields = acc->BundleFieldsForCache();
|
||||
cache.AppendElement(CacheData(id, fields));
|
||||
}
|
||||
Unused << SendCache(0, cache, true);
|
||||
}
|
||||
}
|
||||
|
||||
void DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "RemoteAccessible.h"
|
||||
#include "mozilla/a11y/DocAccessibleParent.h"
|
||||
#include "DocAccessible.h"
|
||||
#include "AccAttributes.h"
|
||||
#include "mozilla/a11y/DocManager.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/BrowserParent.h"
|
||||
|
@ -31,8 +32,16 @@ uint64_t RemoteAccessible::NativeState() const {
|
|||
}
|
||||
|
||||
uint32_t RemoteAccessible::Name(nsString& aName) const {
|
||||
uint32_t flag;
|
||||
Unused << mDoc->SendName(mID, &aName, &flag);
|
||||
uint32_t flag = 0;
|
||||
if (mCachedFields) {
|
||||
if (mCachedFields->GetAttribute(nsGkAtoms::name, aName)) {
|
||||
auto nameFlag =
|
||||
mCachedFields->GetAttribute<int32_t>(nsGkAtoms::explicit_name);
|
||||
flag = nameFlag ? *nameFlag : 0;
|
||||
}
|
||||
} else {
|
||||
Unused << mDoc->SendName(mID, &aName, &flag);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче