Loading accessible/base/Logging.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,8 @@ static ModuleRep sModuleMap[] = {{"docload", logging::eDocLoad}, {"notifications", logging::eNotifications}, {"stack", logging::eStack}, {"verbose", logging::eVerbose}}; {"verbose", logging::eVerbose}, {"cache", logging::eCache}}; static void EnableLogging(const char* aModulesStr) { sModules = 0; Loading accessible/base/Logging.h +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ enum EModules { // extras eStack = 1 << 12, eVerbose = 1 << 13 eVerbose = 1 << 13, eCache = 1 << 14, }; /** Loading accessible/ipc/DocAccessibleChildBase.cpp +68 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,9 @@ #include "mozilla/StaticPrefs_accessibility.h" #include "LocalAccessible-inl.h" #ifdef A11Y_LOG # include "Logging.h" #endif namespace mozilla { namespace a11y { Loading Loading @@ -97,5 +100,70 @@ void DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent) { 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 mozilla accessible/ipc/DocAccessibleChildBase.h +6 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,10 @@ class DocAccessibleChildBase : public PDocAccessibleChild { mDoc = nullptr; } virtual mozilla::ipc::IPCResult RecvVerifyCache( const uint64_t& aID, const uint64_t& aCacheDomain, AccAttributes* aFields) override; protected: static void FlattenTree(LocalAccessible* aRoot, nsTArray<LocalAccessible*>& aTree); Loading @@ -78,6 +82,8 @@ class DocAccessibleChildBase : public PDocAccessibleChild { bool IsConstructedInParentProcess() const { return mIsRemoteConstructed; } void SetConstructedInParentProcess() { mIsRemoteConstructed = true; } LocalAccessible* IdToAccessible(const uint64_t& aID) const; DocAccessible* mDoc; bool mIsRemoteConstructed; Loading accessible/ipc/RemoteAccessibleBase.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,19 @@ #include "RelationType.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 a11y { Loading Loading @@ -169,6 +182,7 @@ ENameValueFlag RemoteAccessibleBase<Derived>::Name(nsString& aName) const { if (mCachedFields && mCachedFields->GetAttribute(nsGkAtoms::name, aName)) { auto nameFlag = mCachedFields->GetAttribute<int32_t>(nsGkAtoms::explicit_name); VERIFY_CACHE(CacheDomain::NameAndDescription); return nameFlag ? static_cast<ENameValueFlag>(*nameFlag) : eNameOK; } Loading @@ -179,12 +193,14 @@ template <class Derived> void RemoteAccessibleBase<Derived>::Description(nsString& aDescription) const { if (mCachedFields) { mCachedFields->GetAttribute(nsGkAtoms::description, aDescription); VERIFY_CACHE(CacheDomain::NameAndDescription); } } template <class Derived> double RemoteAccessibleBase<Derived>::CurValue() const { if (auto value = mCachedFields->GetAttribute<double>(nsGkAtoms::value)) { VERIFY_CACHE(CacheDomain::Value); return *value; } Loading @@ -194,6 +210,7 @@ double RemoteAccessibleBase<Derived>::CurValue() const { template <class Derived> double RemoteAccessibleBase<Derived>::MinValue() const { if (auto min = mCachedFields->GetAttribute<double>(nsGkAtoms::min)) { VERIFY_CACHE(CacheDomain::Value); return *min; } Loading @@ -203,6 +220,7 @@ double RemoteAccessibleBase<Derived>::MinValue() const { template <class Derived> double RemoteAccessibleBase<Derived>::MaxValue() const { if (auto max = mCachedFields->GetAttribute<double>(nsGkAtoms::max)) { VERIFY_CACHE(CacheDomain::Value); return *max; } Loading @@ -212,6 +230,7 @@ double RemoteAccessibleBase<Derived>::MaxValue() const { template <class Derived> double RemoteAccessibleBase<Derived>::Step() const { if (auto step = mCachedFields->GetAttribute<double>(nsGkAtoms::step)) { VERIFY_CACHE(CacheDomain::Value); return *step; } Loading Loading
accessible/base/Logging.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,8 @@ static ModuleRep sModuleMap[] = {{"docload", logging::eDocLoad}, {"notifications", logging::eNotifications}, {"stack", logging::eStack}, {"verbose", logging::eVerbose}}; {"verbose", logging::eVerbose}, {"cache", logging::eCache}}; static void EnableLogging(const char* aModulesStr) { sModules = 0; Loading
accessible/base/Logging.h +2 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ enum EModules { // extras eStack = 1 << 12, eVerbose = 1 << 13 eVerbose = 1 << 13, eCache = 1 << 14, }; /** Loading
accessible/ipc/DocAccessibleChildBase.cpp +68 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,9 @@ #include "mozilla/StaticPrefs_accessibility.h" #include "LocalAccessible-inl.h" #ifdef A11Y_LOG # include "Logging.h" #endif namespace mozilla { namespace a11y { Loading Loading @@ -97,5 +100,70 @@ void DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent) { 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 mozilla
accessible/ipc/DocAccessibleChildBase.h +6 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,10 @@ class DocAccessibleChildBase : public PDocAccessibleChild { mDoc = nullptr; } virtual mozilla::ipc::IPCResult RecvVerifyCache( const uint64_t& aID, const uint64_t& aCacheDomain, AccAttributes* aFields) override; protected: static void FlattenTree(LocalAccessible* aRoot, nsTArray<LocalAccessible*>& aTree); Loading @@ -78,6 +82,8 @@ class DocAccessibleChildBase : public PDocAccessibleChild { bool IsConstructedInParentProcess() const { return mIsRemoteConstructed; } void SetConstructedInParentProcess() { mIsRemoteConstructed = true; } LocalAccessible* IdToAccessible(const uint64_t& aID) const; DocAccessible* mDoc; bool mIsRemoteConstructed; Loading
accessible/ipc/RemoteAccessibleBase.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,19 @@ #include "RelationType.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 a11y { Loading Loading @@ -169,6 +182,7 @@ ENameValueFlag RemoteAccessibleBase<Derived>::Name(nsString& aName) const { if (mCachedFields && mCachedFields->GetAttribute(nsGkAtoms::name, aName)) { auto nameFlag = mCachedFields->GetAttribute<int32_t>(nsGkAtoms::explicit_name); VERIFY_CACHE(CacheDomain::NameAndDescription); return nameFlag ? static_cast<ENameValueFlag>(*nameFlag) : eNameOK; } Loading @@ -179,12 +193,14 @@ template <class Derived> void RemoteAccessibleBase<Derived>::Description(nsString& aDescription) const { if (mCachedFields) { mCachedFields->GetAttribute(nsGkAtoms::description, aDescription); VERIFY_CACHE(CacheDomain::NameAndDescription); } } template <class Derived> double RemoteAccessibleBase<Derived>::CurValue() const { if (auto value = mCachedFields->GetAttribute<double>(nsGkAtoms::value)) { VERIFY_CACHE(CacheDomain::Value); return *value; } Loading @@ -194,6 +210,7 @@ double RemoteAccessibleBase<Derived>::CurValue() const { template <class Derived> double RemoteAccessibleBase<Derived>::MinValue() const { if (auto min = mCachedFields->GetAttribute<double>(nsGkAtoms::min)) { VERIFY_CACHE(CacheDomain::Value); return *min; } Loading @@ -203,6 +220,7 @@ double RemoteAccessibleBase<Derived>::MinValue() const { template <class Derived> double RemoteAccessibleBase<Derived>::MaxValue() const { if (auto max = mCachedFields->GetAttribute<double>(nsGkAtoms::max)) { VERIFY_CACHE(CacheDomain::Value); return *max; } Loading @@ -212,6 +230,7 @@ double RemoteAccessibleBase<Derived>::MaxValue() const { template <class Derived> double RemoteAccessibleBase<Derived>::Step() const { if (auto step = mCachedFields->GetAttribute<double>(nsGkAtoms::step)) { VERIFY_CACHE(CacheDomain::Value); return *step; } Loading