From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- accessible/ipc/DocAccessibleChildBase.cpp | 97 +++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 accessible/ipc/DocAccessibleChildBase.cpp (limited to 'accessible/ipc/DocAccessibleChildBase.cpp') diff --git a/accessible/ipc/DocAccessibleChildBase.cpp b/accessible/ipc/DocAccessibleChildBase.cpp new file mode 100644 index 000000000..6a0ad9b7d --- /dev/null +++ b/accessible/ipc/DocAccessibleChildBase.cpp @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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 "mozilla/a11y/DocAccessibleChildBase.h" +#include "mozilla/a11y/ProxyAccessible.h" + +#include "Accessible-inl.h" + +namespace mozilla { +namespace a11y { + +/* static */ uint32_t +DocAccessibleChildBase::InterfacesFor(Accessible* aAcc) +{ + uint32_t interfaces = 0; + if (aAcc->IsHyperText() && aAcc->AsHyperText()->IsTextRole()) + interfaces |= Interfaces::HYPERTEXT; + + if (aAcc->IsLink()) + interfaces |= Interfaces::HYPERLINK; + + if (aAcc->HasNumericValue()) + interfaces |= Interfaces::VALUE; + + if (aAcc->IsImage()) + interfaces |= Interfaces::IMAGE; + + if (aAcc->IsTable()) { + interfaces |= Interfaces::TABLE; + } + + if (aAcc->IsTableCell()) + interfaces |= Interfaces::TABLECELL; + + if (aAcc->IsDoc()) + interfaces |= Interfaces::DOCUMENT; + + if (aAcc->IsSelect()) { + interfaces |= Interfaces::SELECTION; + } + + if (aAcc->ActionCount()) { + interfaces |= Interfaces::ACTION; + } + + return interfaces; +} + +/* static */ void +DocAccessibleChildBase::SerializeTree(Accessible* aRoot, + nsTArray& aTree) +{ + uint64_t id = reinterpret_cast(aRoot->UniqueID()); +#if defined(XP_WIN) + int32_t msaaId = AccessibleWrap::GetChildIDFor(aRoot); +#endif + uint32_t role = aRoot->Role(); + uint32_t childCount = aRoot->ChildCount(); + uint32_t interfaces = InterfacesFor(aRoot); + + // OuterDocAccessibles are special because we don't want to serialize the + // child doc here, we'll call PDocAccessibleConstructor in + // NotificationController. + MOZ_ASSERT(!aRoot->IsDoc(), "documents shouldn't be serialized"); + if (aRoot->IsOuterDoc()) { + childCount = 0; + } + +#if defined(XP_WIN) + aTree.AppendElement(AccessibleData(id, msaaId, role, childCount, interfaces)); +#else + aTree.AppendElement(AccessibleData(id, role, childCount, interfaces)); +#endif + + for (uint32_t i = 0; i < childCount; i++) { + SerializeTree(aRoot->GetChildAt(i), aTree); + } +} + +void +DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent) +{ + Accessible* parent = aShowEvent->Parent(); + uint64_t parentID = parent->IsDoc() ? 0 : reinterpret_cast(parent->UniqueID()); + uint32_t idxInParent = aShowEvent->GetAccessible()->IndexInParent(); + nsTArray shownTree; + ShowEventData data(parentID, idxInParent, shownTree); + SerializeTree(aShowEvent->GetAccessible(), data.NewTree()); + MaybeSendShowEvent(data, aShowEvent->IsFromUserInput()); +} + +} // namespace a11y +} // namespace mozilla + -- cgit v1.2.3