forked from mirrors/gecko-dev
Bug 1729061 - Introduce cache verification logging. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D124486
This commit is contained in:
parent
f287b980e0
commit
a5dc06abb2
9 changed files with 109 additions and 11 deletions
|
|
@ -63,7 +63,8 @@ static ModuleRep sModuleMap[] = {{"docload", logging::eDocLoad},
|
||||||
{"notifications", logging::eNotifications},
|
{"notifications", logging::eNotifications},
|
||||||
|
|
||||||
{"stack", logging::eStack},
|
{"stack", logging::eStack},
|
||||||
{"verbose", logging::eVerbose}};
|
{"verbose", logging::eVerbose},
|
||||||
|
{"cache", logging::eCache}};
|
||||||
|
|
||||||
static void EnableLogging(const char* aModulesStr) {
|
static void EnableLogging(const char* aModulesStr) {
|
||||||
sModules = 0;
|
sModules = 0;
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,8 @@ enum EModules {
|
||||||
|
|
||||||
// extras
|
// extras
|
||||||
eStack = 1 << 12,
|
eStack = 1 << 12,
|
||||||
eVerbose = 1 << 13
|
eVerbose = 1 << 13,
|
||||||
|
eCache = 1 << 14,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@
|
||||||
#include "mozilla/StaticPrefs_accessibility.h"
|
#include "mozilla/StaticPrefs_accessibility.h"
|
||||||
|
|
||||||
#include "LocalAccessible-inl.h"
|
#include "LocalAccessible-inl.h"
|
||||||
|
#ifdef A11Y_LOG
|
||||||
|
# include "Logging.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
@ -97,5 +100,70 @@ void DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent) {
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mozilla::ipc::IPCResult DocAccessibleChildBase::RecvVerifyCache(
|
||||||
|
const uint64_t& aID, const uint64_t& aCacheDomain, AccAttributes* aFields) {
|
||||||
|
#ifdef A11Y_LOG
|
||||||
|
LocalAccessible* acc = IdToAccessible(aID);
|
||||||
|
if (!acc) {
|
||||||
|
return IPC_OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<AccAttributes> localFields =
|
||||||
|
acc->BundleFieldsForCache(aCacheDomain, CacheUpdateType::Update);
|
||||||
|
bool mismatches = false;
|
||||||
|
|
||||||
|
for (auto prop : *localFields) {
|
||||||
|
if (prop.Value<DeleteEntry>()) {
|
||||||
|
if (aFields->HasAttribute(prop.Name())) {
|
||||||
|
if (!mismatches) {
|
||||||
|
logging::MsgBegin("Mismatch!", "Local and remote values differ");
|
||||||
|
logging::AccessibleInfo("", acc);
|
||||||
|
mismatches = true;
|
||||||
|
}
|
||||||
|
nsAutoCString propName;
|
||||||
|
prop.Name()->ToUTF8String(propName);
|
||||||
|
nsAutoString val;
|
||||||
|
aFields->GetAttribute(prop.Name(), val);
|
||||||
|
logging::MsgEntry(
|
||||||
|
"Remote value for %s should be empty, but instead it is '%s'",
|
||||||
|
propName.get(), NS_ConvertUTF16toUTF8(val).get());
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsAutoString localVal;
|
||||||
|
prop.ValueAsString(localVal);
|
||||||
|
nsAutoString remoteVal;
|
||||||
|
aFields->GetAttribute(prop.Name(), remoteVal);
|
||||||
|
if (!localVal.Equals(remoteVal)) {
|
||||||
|
if (!mismatches) {
|
||||||
|
logging::MsgBegin("Mismatch!", "");
|
||||||
|
logging::AccessibleInfo("", acc);
|
||||||
|
mismatches = true;
|
||||||
|
}
|
||||||
|
nsAutoCString propName;
|
||||||
|
prop.Name()->ToUTF8String(propName);
|
||||||
|
logging::MsgEntry("Fields differ: %s '%s' != '%s'", propName.get(),
|
||||||
|
NS_ConvertUTF16toUTF8(remoteVal).get(),
|
||||||
|
NS_ConvertUTF16toUTF8(localVal).get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mismatches) {
|
||||||
|
logging::MsgEnd();
|
||||||
|
}
|
||||||
|
#endif // A11Y_LOG
|
||||||
|
|
||||||
|
return IPC_OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalAccessible* DocAccessibleChildBase::IdToAccessible(
|
||||||
|
const uint64_t& aID) const {
|
||||||
|
if (!aID) return mDoc;
|
||||||
|
|
||||||
|
if (!mDoc) return nullptr;
|
||||||
|
|
||||||
|
return mDoc->GetAccessibleByUniqueID(reinterpret_cast<void*>(aID));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ class DocAccessibleChildBase : public PDocAccessibleChild {
|
||||||
mDoc = nullptr;
|
mDoc = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual mozilla::ipc::IPCResult RecvVerifyCache(
|
||||||
|
const uint64_t& aID, const uint64_t& aCacheDomain,
|
||||||
|
AccAttributes* aFields) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void FlattenTree(LocalAccessible* aRoot,
|
static void FlattenTree(LocalAccessible* aRoot,
|
||||||
nsTArray<LocalAccessible*>& aTree);
|
nsTArray<LocalAccessible*>& aTree);
|
||||||
|
|
@ -78,6 +82,8 @@ class DocAccessibleChildBase : public PDocAccessibleChild {
|
||||||
bool IsConstructedInParentProcess() const { return mIsRemoteConstructed; }
|
bool IsConstructedInParentProcess() const { return mIsRemoteConstructed; }
|
||||||
void SetConstructedInParentProcess() { mIsRemoteConstructed = true; }
|
void SetConstructedInParentProcess() { mIsRemoteConstructed = true; }
|
||||||
|
|
||||||
|
LocalAccessible* IdToAccessible(const uint64_t& aID) const;
|
||||||
|
|
||||||
DocAccessible* mDoc;
|
DocAccessible* mDoc;
|
||||||
bool mIsRemoteConstructed;
|
bool mIsRemoteConstructed;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,19 @@
|
||||||
#include "RelationType.h"
|
#include "RelationType.h"
|
||||||
#include "xpcAccessibleDocument.h"
|
#include "xpcAccessibleDocument.h"
|
||||||
|
|
||||||
|
#ifdef A11Y_LOG
|
||||||
|
# include "Logging.h"
|
||||||
|
# define VERIFY_CACHE(domain) \
|
||||||
|
if (logging::IsEnabled(logging::eCache)) { \
|
||||||
|
Unused << mDoc->SendVerifyCache(mID, domain, mCachedFields); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define VERIFY_CACHE(domain) \
|
||||||
|
do { \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
|
|
@ -169,6 +182,7 @@ ENameValueFlag RemoteAccessibleBase<Derived>::Name(nsString& aName) const {
|
||||||
if (mCachedFields && mCachedFields->GetAttribute(nsGkAtoms::name, aName)) {
|
if (mCachedFields && mCachedFields->GetAttribute(nsGkAtoms::name, aName)) {
|
||||||
auto nameFlag =
|
auto nameFlag =
|
||||||
mCachedFields->GetAttribute<int32_t>(nsGkAtoms::explicit_name);
|
mCachedFields->GetAttribute<int32_t>(nsGkAtoms::explicit_name);
|
||||||
|
VERIFY_CACHE(CacheDomain::NameAndDescription);
|
||||||
return nameFlag ? static_cast<ENameValueFlag>(*nameFlag) : eNameOK;
|
return nameFlag ? static_cast<ENameValueFlag>(*nameFlag) : eNameOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,12 +193,14 @@ template <class Derived>
|
||||||
void RemoteAccessibleBase<Derived>::Description(nsString& aDescription) const {
|
void RemoteAccessibleBase<Derived>::Description(nsString& aDescription) const {
|
||||||
if (mCachedFields) {
|
if (mCachedFields) {
|
||||||
mCachedFields->GetAttribute(nsGkAtoms::description, aDescription);
|
mCachedFields->GetAttribute(nsGkAtoms::description, aDescription);
|
||||||
|
VERIFY_CACHE(CacheDomain::NameAndDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Derived>
|
template <class Derived>
|
||||||
double RemoteAccessibleBase<Derived>::CurValue() const {
|
double RemoteAccessibleBase<Derived>::CurValue() const {
|
||||||
if (auto value = mCachedFields->GetAttribute<double>(nsGkAtoms::value)) {
|
if (auto value = mCachedFields->GetAttribute<double>(nsGkAtoms::value)) {
|
||||||
|
VERIFY_CACHE(CacheDomain::Value);
|
||||||
return *value;
|
return *value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,6 +210,7 @@ double RemoteAccessibleBase<Derived>::CurValue() const {
|
||||||
template <class Derived>
|
template <class Derived>
|
||||||
double RemoteAccessibleBase<Derived>::MinValue() const {
|
double RemoteAccessibleBase<Derived>::MinValue() const {
|
||||||
if (auto min = mCachedFields->GetAttribute<double>(nsGkAtoms::min)) {
|
if (auto min = mCachedFields->GetAttribute<double>(nsGkAtoms::min)) {
|
||||||
|
VERIFY_CACHE(CacheDomain::Value);
|
||||||
return *min;
|
return *min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,6 +220,7 @@ double RemoteAccessibleBase<Derived>::MinValue() const {
|
||||||
template <class Derived>
|
template <class Derived>
|
||||||
double RemoteAccessibleBase<Derived>::MaxValue() const {
|
double RemoteAccessibleBase<Derived>::MaxValue() const {
|
||||||
if (auto max = mCachedFields->GetAttribute<double>(nsGkAtoms::max)) {
|
if (auto max = mCachedFields->GetAttribute<double>(nsGkAtoms::max)) {
|
||||||
|
VERIFY_CACHE(CacheDomain::Value);
|
||||||
return *max;
|
return *max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,6 +230,7 @@ double RemoteAccessibleBase<Derived>::MaxValue() const {
|
||||||
template <class Derived>
|
template <class Derived>
|
||||||
double RemoteAccessibleBase<Derived>::Step() const {
|
double RemoteAccessibleBase<Derived>::Step() const {
|
||||||
if (auto step = mCachedFields->GetAttribute<double>(nsGkAtoms::step)) {
|
if (auto step = mCachedFields->GetAttribute<double>(nsGkAtoms::step)) {
|
||||||
|
VERIFY_CACHE(CacheDomain::Value);
|
||||||
return *step;
|
return *step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,6 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
|
||||||
LocalAccessible* DocAccessibleChild::IdToAccessible(const uint64_t& aID) const {
|
|
||||||
if (!aID) return mDoc;
|
|
||||||
|
|
||||||
if (!mDoc) return nullptr;
|
|
||||||
|
|
||||||
return mDoc->GetAccessibleByUniqueID(reinterpret_cast<void*>(aID));
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalAccessible* DocAccessibleChild::IdToAccessibleLink(
|
LocalAccessible* DocAccessibleChild::IdToAccessibleLink(
|
||||||
const uint64_t& aID) const {
|
const uint64_t& aID) const {
|
||||||
LocalAccessible* acc = IdToAccessible(aID);
|
LocalAccessible* acc = IdToAccessible(aID);
|
||||||
|
|
|
||||||
|
|
@ -485,7 +485,6 @@ class DocAccessibleChild : public DocAccessibleChildBase {
|
||||||
DocAccessiblePlatformExtChild* GetPlatformExtension();
|
DocAccessiblePlatformExtChild* GetPlatformExtension();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LocalAccessible* IdToAccessible(const uint64_t& aID) const;
|
|
||||||
LocalAccessible* IdToAccessibleLink(const uint64_t& aID) const;
|
LocalAccessible* IdToAccessibleLink(const uint64_t& aID) const;
|
||||||
LocalAccessible* IdToAccessibleSelect(const uint64_t& aID) const;
|
LocalAccessible* IdToAccessibleSelect(const uint64_t& aID) const;
|
||||||
HyperTextAccessible* IdToHyperTextAccessible(const uint64_t& aID) const;
|
HyperTextAccessible* IdToHyperTextAccessible(const uint64_t& aID) const;
|
||||||
|
|
|
||||||
|
|
@ -336,6 +336,12 @@ child:
|
||||||
[Nested=inside_sync] sync ExtentsInCSSPixels(uint64_t aID)
|
[Nested=inside_sync] sync ExtentsInCSSPixels(uint64_t aID)
|
||||||
returns(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight);
|
returns(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight);
|
||||||
[Nested=inside_sync] sync DOMNodeID(uint64_t aID) returns(nsString aDOMNodeID);
|
[Nested=inside_sync] sync DOMNodeID(uint64_t aID) returns(nsString aDOMNodeID);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Verify the cache. Used for testing purposes.
|
||||||
|
*/
|
||||||
|
async VerifyCache(uint64_t aID, uint64_t aCacheDomain, AccAttributes aFields);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ using mozilla::a11y::IDispatchHolder from "mozilla/a11y/IPCTypes.h";
|
||||||
using mozilla::a11y::AccType from "mozilla/a11y/IPCTypes.h";
|
using mozilla::a11y::AccType from "mozilla/a11y/IPCTypes.h";
|
||||||
using mozilla::a11y::AccGenericType from "mozilla/a11y/IPCTypes.h";
|
using mozilla::a11y::AccGenericType from "mozilla/a11y/IPCTypes.h";
|
||||||
using mozilla::a11y::CacheUpdateType from "mozilla/a11y/IPCTypes.h";
|
using mozilla::a11y::CacheUpdateType from "mozilla/a11y/IPCTypes.h";
|
||||||
|
[RefCounted] using mozilla::a11y::AccAttributes from "mozilla/a11y/IPCTypes.h";
|
||||||
using mozilla::WindowsHandle from "mozilla/ipc/IPCTypes.h";
|
using mozilla::WindowsHandle from "mozilla/ipc/IPCTypes.h";
|
||||||
using mozilla::LayoutDeviceIntRect from "Units.h";
|
using mozilla::LayoutDeviceIntRect from "Units.h";
|
||||||
|
|
||||||
|
|
@ -110,6 +111,11 @@ child:
|
||||||
*/
|
*/
|
||||||
async RestoreFocus();
|
async RestoreFocus();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Verify the cache. Used for testing purposes.
|
||||||
|
*/
|
||||||
|
async VerifyCache(uint64_t aID, uint64_t aCacheDomain, AccAttributes aFields);
|
||||||
|
|
||||||
async __delete__();
|
async __delete__();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue