summaryrefslogtreecommitdiffstats
path: root/accessible/xpcom/xpcAccessibleDocument.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /accessible/xpcom/xpcAccessibleDocument.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'accessible/xpcom/xpcAccessibleDocument.h')
-rw-r--r--accessible/xpcom/xpcAccessibleDocument.h150
1 files changed, 150 insertions, 0 deletions
diff --git a/accessible/xpcom/xpcAccessibleDocument.h b/accessible/xpcom/xpcAccessibleDocument.h
new file mode 100644
index 000000000..651fe2255
--- /dev/null
+++ b/accessible/xpcom/xpcAccessibleDocument.h
@@ -0,0 +1,150 @@
+/* -*- 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/. */
+
+#ifndef mozilla_a11y_xpcAccessibleDocument_h_
+#define mozilla_a11y_xpcAccessibleDocument_h_
+
+#include "nsIAccessibleDocument.h"
+
+#include "DocAccessible.h"
+#include "nsAccessibilityService.h"
+#include "xpcAccessibleApplication.h"
+#include "xpcAccessibleHyperText.h"
+
+namespace mozilla {
+namespace a11y {
+
+/**
+ * XPCOM wrapper around DocAccessible class.
+ */
+class xpcAccessibleDocument : public xpcAccessibleHyperText,
+ public nsIAccessibleDocument
+{
+public:
+ explicit xpcAccessibleDocument(DocAccessible* aIntl) :
+ xpcAccessibleHyperText(aIntl), mCache(kDefaultCacheLength), mRemote(false) { }
+
+ xpcAccessibleDocument(ProxyAccessible* aProxy, uint32_t aInterfaces) :
+ xpcAccessibleHyperText(aProxy, aInterfaces), mCache(kDefaultCacheLength),
+ mRemote(true) {}
+
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(xpcAccessibleDocument,
+ xpcAccessibleGeneric)
+
+ // nsIAccessibleDocument
+ NS_IMETHOD GetURL(nsAString& aURL) final override;
+ NS_IMETHOD GetTitle(nsAString& aTitle) final override;
+ NS_IMETHOD GetMimeType(nsAString& aType) final override;
+ NS_IMETHOD GetDocType(nsAString& aType) final override;
+ NS_IMETHOD GetDOMDocument(nsIDOMDocument** aDOMDocument) final override;
+ NS_IMETHOD GetWindow(mozIDOMWindowProxy** aDOMWindow) final override;
+ NS_IMETHOD GetParentDocument(nsIAccessibleDocument** aDocument)
+ final override;
+ NS_IMETHOD GetChildDocumentCount(uint32_t* aCount) final override;
+ NS_IMETHOD GetChildDocumentAt(uint32_t aIndex,
+ nsIAccessibleDocument** aDocument)
+ final override;
+ NS_IMETHOD GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor)
+ final override;
+
+ /**
+ * Return XPCOM wrapper for the internal accessible.
+ */
+ xpcAccessibleGeneric* GetAccessible(Accessible* aAccessible);
+ xpcAccessibleGeneric* GetXPCAccessible(ProxyAccessible* aProxy);
+
+ virtual void Shutdown() override;
+
+protected:
+ virtual ~xpcAccessibleDocument() {}
+
+private:
+ DocAccessible* Intl()
+ {
+ if (Accessible* acc = mIntl.AsAccessible()) {
+ return acc->AsDoc();
+ }
+
+ return nullptr;
+ }
+
+ void NotifyOfShutdown(Accessible* aAccessible)
+ {
+ MOZ_ASSERT(!mRemote);
+ xpcAccessibleGeneric* xpcAcc = mCache.GetWeak(aAccessible);
+ if (xpcAcc)
+ xpcAcc->Shutdown();
+
+ mCache.Remove(aAccessible);
+ }
+
+ void NotifyOfShutdown(ProxyAccessible* aProxy)
+ {
+ MOZ_ASSERT(mRemote);
+ xpcAccessibleGeneric* acc = mCache.GetWeak(aProxy);
+ if (acc) {
+ acc->Shutdown();
+ }
+
+ mCache.Remove(aProxy);
+ }
+
+ friend class DocManager;
+ friend class DocAccessible;
+ friend class ProxyAccessible;
+ friend class ProxyAccessibleBase<ProxyAccessible>;
+
+ xpcAccessibleDocument(const xpcAccessibleDocument&) = delete;
+ xpcAccessibleDocument& operator =(const xpcAccessibleDocument&) = delete;
+
+ nsRefPtrHashtable<nsPtrHashKey<const void>, xpcAccessibleGeneric> mCache;
+ bool mRemote;
+};
+
+inline xpcAccessibleGeneric*
+ToXPC(Accessible* aAccessible)
+{
+ if (!aAccessible)
+ return nullptr;
+
+ if (aAccessible->IsApplication())
+ return XPCApplicationAcc();
+
+ xpcAccessibleDocument* xpcDoc =
+ GetAccService()->GetXPCDocument(aAccessible->Document());
+ return xpcDoc ? xpcDoc->GetAccessible(aAccessible) : nullptr;
+}
+
+xpcAccessibleGeneric* ToXPC(AccessibleOrProxy aAcc);
+
+inline xpcAccessibleHyperText*
+ToXPCText(HyperTextAccessible* aAccessible)
+{
+ if (!aAccessible)
+ return nullptr;
+
+ xpcAccessibleDocument* xpcDoc =
+ GetAccService()->GetXPCDocument(aAccessible->Document());
+ return static_cast<xpcAccessibleHyperText*>(xpcDoc->GetAccessible(aAccessible));
+}
+
+inline xpcAccessibleDocument*
+ToXPCDocument(DocAccessible* aAccessible)
+{
+ return GetAccService()->GetXPCDocument(aAccessible);
+}
+
+inline xpcAccessibleDocument*
+ToXPCDocument(DocAccessibleParent* aAccessible)
+{
+ return GetAccService()->GetXPCDocument(aAccessible);
+}
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif