2014-09-23 16:23:02 +04:00
|
|
|
/* -*- 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"
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
#include "DocAccessible.h"
|
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#include "xpcAccessibleApplication.h"
|
|
|
|
#include "xpcAccessibleHyperText.h"
|
|
|
|
|
2014-09-23 16:23:02 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
/**
|
|
|
|
* XPCOM wrapper around DocAccessible class.
|
|
|
|
*/
|
|
|
|
class xpcAccessibleDocument : public xpcAccessibleHyperText,
|
|
|
|
public nsIAccessibleDocument
|
2014-09-23 16:23:02 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-10-11 01:28:35 +04:00
|
|
|
explicit xpcAccessibleDocument(DocAccessible* aIntl) :
|
2016-01-19 19:46:00 +03:00
|
|
|
xpcAccessibleHyperText(aIntl), mCache(kDefaultCacheLength), mRemote(false) { }
|
2014-10-22 04:49:28 +04:00
|
|
|
|
2016-01-19 17:47:52 +03:00
|
|
|
xpcAccessibleDocument(ProxyAccessible* aProxy, uint32_t aInterfaces) :
|
2016-01-19 19:46:00 +03:00
|
|
|
xpcAccessibleHyperText(aProxy, aInterfaces), mCache(kDefaultCacheLength),
|
|
|
|
mRemote(true) {}
|
2016-01-19 17:47:52 +03:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIAccessibleDocument
|
2018-02-06 09:46:57 +03:00
|
|
|
NS_IMETHOD GetURL(nsAString& aURL) final;
|
|
|
|
NS_IMETHOD GetTitle(nsAString& aTitle) final;
|
|
|
|
NS_IMETHOD GetMimeType(nsAString& aType) final;
|
|
|
|
NS_IMETHOD GetDocType(nsAString& aType) final;
|
|
|
|
NS_IMETHOD GetDOMDocument(nsIDOMDocument** aDOMDocument) final;
|
|
|
|
NS_IMETHOD GetWindow(mozIDOMWindowProxy** aDOMWindow) final;
|
2015-01-15 23:39:04 +03:00
|
|
|
NS_IMETHOD GetParentDocument(nsIAccessibleDocument** aDocument)
|
2018-02-06 09:46:57 +03:00
|
|
|
final;
|
|
|
|
NS_IMETHOD GetChildDocumentCount(uint32_t* aCount) final;
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMETHOD GetChildDocumentAt(uint32_t aIndex,
|
2015-01-15 23:39:04 +03:00
|
|
|
nsIAccessibleDocument** aDocument)
|
2018-02-06 09:46:57 +03:00
|
|
|
final;
|
2015-01-15 23:39:04 +03:00
|
|
|
NS_IMETHOD GetVirtualCursor(nsIAccessiblePivot** aVirtualCursor)
|
2018-02-06 09:46:57 +03:00
|
|
|
final;
|
2014-09-23 16:23:02 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
/**
|
|
|
|
* Return XPCOM wrapper for the internal accessible.
|
|
|
|
*/
|
|
|
|
xpcAccessibleGeneric* GetAccessible(Accessible* aAccessible);
|
2016-01-19 22:49:35 +03:00
|
|
|
xpcAccessibleGeneric* GetXPCAccessible(ProxyAccessible* aProxy);
|
2014-10-22 04:49:28 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Shutdown() override;
|
2014-10-22 04:49:28 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~xpcAccessibleDocument() {}
|
|
|
|
|
2014-09-23 16:23:02 +04:00
|
|
|
private:
|
2016-01-21 08:07:56 +03:00
|
|
|
DocAccessible* Intl()
|
|
|
|
{
|
|
|
|
if (Accessible* acc = mIntl.AsAccessible()) {
|
|
|
|
return acc->AsDoc();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-10-22 04:49:28 +04:00
|
|
|
|
|
|
|
void NotifyOfShutdown(Accessible* aAccessible)
|
|
|
|
{
|
2016-01-19 19:46:00 +03:00
|
|
|
MOZ_ASSERT(!mRemote);
|
2016-11-19 07:29:10 +03:00
|
|
|
xpcAccessibleGeneric* xpcAcc = mCache.Get(aAccessible);
|
|
|
|
if (xpcAcc) {
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAcc->Shutdown();
|
2016-11-19 07:29:10 +03:00
|
|
|
}
|
2014-09-23 16:23:02 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
mCache.Remove(aAccessible);
|
2016-11-19 07:29:10 +03:00
|
|
|
if (mCache.Count() == 0 && mRefCnt == 1) {
|
|
|
|
GetAccService()->RemoveFromXPCDocumentCache(
|
|
|
|
mIntl.AsAccessible()->AsDoc());
|
|
|
|
}
|
2014-10-22 04:49:28 +04:00
|
|
|
}
|
|
|
|
|
2016-01-19 22:49:35 +03:00
|
|
|
void NotifyOfShutdown(ProxyAccessible* aProxy)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mRemote);
|
2016-11-19 07:29:10 +03:00
|
|
|
xpcAccessibleGeneric* xpcAcc = mCache.Get(aProxy);
|
|
|
|
if (xpcAcc) {
|
|
|
|
xpcAcc->Shutdown();
|
2016-01-19 22:49:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mCache.Remove(aProxy);
|
2016-11-19 07:29:10 +03:00
|
|
|
if (mCache.Count() == 0 && mRefCnt == 1) {
|
|
|
|
GetAccService()->RemoveFromRemoteXPCDocumentCache(
|
|
|
|
mIntl.AsProxy()->AsDoc());
|
|
|
|
}
|
2016-01-19 22:49:35 +03:00
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
friend class DocManager;
|
|
|
|
friend class DocAccessible;
|
2016-01-19 22:49:35 +03:00
|
|
|
friend class ProxyAccessible;
|
2016-08-19 22:16:42 +03:00
|
|
|
friend class ProxyAccessibleBase<ProxyAccessible>;
|
2016-11-19 07:29:10 +03:00
|
|
|
friend class xpcAccessibleGeneric;
|
2014-09-23 16:23:02 +04:00
|
|
|
|
2015-01-07 02:35:02 +03:00
|
|
|
xpcAccessibleDocument(const xpcAccessibleDocument&) = delete;
|
|
|
|
xpcAccessibleDocument& operator =(const xpcAccessibleDocument&) = delete;
|
2014-10-22 04:49:28 +04:00
|
|
|
|
2016-11-19 07:29:10 +03:00
|
|
|
nsDataHashtable<nsPtrHashKey<const void>, xpcAccessibleGeneric*> mCache;
|
2016-01-19 19:46:00 +03:00
|
|
|
bool mRemote;
|
2014-09-23 16:23:02 +04:00
|
|
|
};
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-01-22 13:52:53 +03:00
|
|
|
xpcAccessibleGeneric* ToXPC(AccessibleOrProxy aAcc);
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-01-22 13:52:53 +03:00
|
|
|
inline xpcAccessibleDocument*
|
|
|
|
ToXPCDocument(DocAccessibleParent* aAccessible)
|
|
|
|
{
|
|
|
|
return GetAccService()->GetXPCDocument(aAccessible);
|
|
|
|
}
|
|
|
|
|
2014-09-23 16:23:02 +04:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|