mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
89d38b5d7a
- Bug 1173364 - support ARIA table and cell roles, r=marcoz (c6f9fc891e) - Bug 1205318 - make aria-owns loop alg more sophisticated, r=yzen (d287b1e41c) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList(), r=smaug (bf920abdd3) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList(), part3, r=davidb (675c3a0ee2) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList, part2, r=davidb (a7cd835169) - Bug 1186786 - Replace nsBaseHashtable::EnumerateRead() calls in accessible/ with iterators. r=tbsaunde. (172fcbe18f) - Bug 1219299 - rework aria-owns implementation, r=yzen (c297a84b41) - Bug 1219744 - no child_of/parent_of relations for aria-owns, r=yzen (38ea8be268) - Bug 1205341 - get rid of aria-owns provided relations, part1: remove ARIA combobox special support (bug 819273 backout), r=yzen (0ca03a27bd) - Bug 1219743 - remove special ARIA owns support for ARIA menus, r=yzen (64468fdfd1) - Bug 1200595 - Introduce TextureData and implement it for X11. r=mattwoodrow, Bas, sotaro (2e6bc3f02c) - Bug 1200595 - Buffer TextureData implementation. r=mattwoodrow (1cb3ffd937) - Bug 1227415 - Fix copy buffer size r=jolin (344130daec) - Bug 1200595 - Gralloc TextureData implementation. r=sotaro (a0726233ca) - Bug 1205725 - Add basic SidebandStream handling to HwcComposer2D r=mwu,nical (42bea59a5f) - namespace (ab69730d53) - Bug 1194775 - Paper over a crash in ContentClient. r=Bas (998051cee4) - minor (c24c0b069d) - Bug 1197315 - remove PR_snprintf calls in gfx/; r=froydnj (f153fed9c8) - Bug 1157664 - Initialize mozilla::layers::FPSCOUNTER::mIteratorIndex. r=nical (cf5d2203ee) - Bug 1157663 - Init mMap in the constructor to avoid half initialized structures. r=nical (d972306493) - Bug 1167370: Check for Map() call failing. r=bas (707eda52ff) - Bug 1221276 - Don't crash if we don't have a surface. r=nical (c53141ea3d) - Bug 1219230 - Use the valid region for determining buffer size instead of the visible region. r=mstange (f2d4783eef) - Pass the correct moz2d backend in CanvasClients. (bug 1212499, r=mattwoodrow) (c16688afbb) - Bug 1179987 - Simplify unlocking of tiled texture hosts. r=nical (781200f702) - Bug 1170189 - Fix tiling crash on Linux. r=jrmuizel (879bbfb506) - Bug 1170189 - fix a comment in the tiling code. r=BenWa (62b47f1bbd) - Bug 1179987 - Make tiled TextureSource recycling based on pointer comparisons rather than trying to do it geometrically. r=nical (7bde534929) - Bug 1189710 - Use correct offset for LayerRenderState in TiledContentHost. r=jrmuizel (cb93c2f98a) - Bug 1215050 - Make layerscope support TiledPaintedLayer when using HWC. r=mattwoodrow, r=cjku (6bffac30f8) - Bug 1186208 - Fix crash when tiling is enabled on linux. r=mattwoodrow (b2f2c85734) - Bug 1197713 - Add missing gfxPrefs.h include to TiledContentHost.cpp. r=nical (22bce4e071) - Bug 1143575. Async image invalidation does not necessarily need to invalidate the layer; LayerTreeInvalidation will do that for us. r=mattwoodrow (a6144b7127) - Bug 1219529 - Don't attempt to deallocate shmems after the ipdl protocol is shut down. r=sotaro (3bb89ef36e) - Bug 1143575. Add assertion for diagnostic purposes. r=nical (e4944dd72f) - Bug 1202175 - Guard GLX-specific call in SurfaceDescriptorX11. r=jgilbert (167a4aa49b) - Bug 1132528 - Handle non existent key r=nical (6c12df1446) - Bug 1137151: Marked destructor of |GrallocReporter| as protected, r=jmuizelaar (57605c4472) - Bug 1145389 - Add gralloc allocation requet size check r=nical (47c6065148) - Bug 1181197 - Fix null dereference in SharedPlanarYCbCrImage destructor. r=jgilbert (3f8c390a6f) - Bug 1195110 - Check if GLContext is destroyed before freeing resources in CompositingRenderTargetOGL. r=jrmuizel (8eac603d84) - bug 1178956 - Specify precision in OGLShaderProgram.cpp to fix compositor on iOS. r=kip (daa6d9db20) - Bug 1186725 - InitTextures should check if LockRect() returns an error, r=mattwoodrow (bc87f908a7) - Bug 1170143 - Add some error checks around the creation of dxgi ycbcrvideo frames. r=Bas (c96e4d9e79) - Bug 1170143 - Build fix. r=me (a9d0064bc3) - Bug 1202700 - Use d3d9 device to upload YCbCr surfaces on the client side if possible. r=Bas (3ccd0c68f5) - Bug 1199361 - Add texture memory reporters for YCbCr TextureClients. r=jrmuizel (723e9d4b10) - bug 1183967 - fixup correct case of mfidl.h (e9abd04709) - Bug 1133007 - followup - make CreateServerSocketRunnable's constructor explicit; r=bustage (5de0ec7900) - Bug 1195653 - Part1.1: Dump SecondaryEffects (EffectTypes::MASK) on Layerscope viewer. r=dglastonbury (v2, carry r+) (a6736ad381) - Bug 1195653 - Part1.2: Use sSentTextureIds instead of sTextureIdList and move HasTextureIdBeenSent into SendTextureSource. r=dglastonbury (v3, carry r+) (7e0b14bca6) - Bug 1195653 - Part1.3: Add isMask attribute field to LayerScopePacket.proto. r=dglastonbury (v2, carry r+) (510e50e09a) - Bug 1195653 - Part1.4: Generated file diffs from patched LayerScopePacket.proto. r=dglastonbury (v1, carry r+) (f1824afcb3) - Bug 1195653 - Part1.5: Send isMask info to LayerScope viewer by TexturePacket. r=dglastonbury (v3) (1722e5e6fe) - Bug 1205521 - Part1: (v3) Add texture/mask attribute fields in LayerScopePacket.proto. r=dglastonbury (0cca15f8f5) - Bug 1205521 - Part2: (v3) Generated file diffs from patched LayerScopePacket.proto. r=dglastonbury (6253724bcf) - Bug 1205521 - Part3: (v3) Dump texture/mask attributes on layerscope viewer. r=dglastonbury (31d346bad1) - Bug 1205521 - Part4: (v2) Align LayerScopePacket to fit changes in Bug 1211324. r=dglastonbury (712da0fe9c) - Bug 1177023 - Log the IsRootContent flag when dumping framemetrics. r=botond (9bea51f318) - Bug 1153724 - Only assert if the size was reasonable to start. r=mchang (c3d61bbee1) - namespace (edcce0a0b3) - Bug 1195857: Make nsPresContext::HasAuthorSpecifiedRules()'s arg 'const', to remove need for const_cast in callers. r=jwatt (274fe66dca) - Bug 1182414, part 1 - Fix printing crash with range input controls. r=dholbert (352a408a83) - Bug 1182414, part 2 - Add printing crash test. r=dholbert (0fc9bd4529) - Bug 1099103 - Prevent numbers input using a grouping separator from being mis-processed as if the separator was a decimal separator. r=dholbert (90276c2f6b) - Bug 1157142 - Support logical (inline/block) in addition to physical orientation for the <input type=range> element; make inline the default behavior so that range sliders respect writing mode. r=jwatt (2ec37cbba8)
535 lines
16 KiB
C++
535 lines
16 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=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 "DocManager.h"
|
|
|
|
#include "ApplicationAccessible.h"
|
|
#include "ARIAMap.h"
|
|
#include "DocAccessible-inl.h"
|
|
#include "DocAccessibleChild.h"
|
|
#include "DocAccessibleParent.h"
|
|
#include "nsAccessibilityService.h"
|
|
#include "Platform.h"
|
|
#include "RootAccessibleWrap.h"
|
|
#include "xpcAccessibleDocument.h"
|
|
|
|
#ifdef A11Y_LOG
|
|
#include "Logging.h"
|
|
#endif
|
|
|
|
#include "mozilla/EventListenerManager.h"
|
|
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
|
|
#include "nsCURILoader.h"
|
|
#include "nsDocShellLoadTypes.h"
|
|
#include "nsIChannel.h"
|
|
#include "nsIDOMDocument.h"
|
|
#include "nsIDOMWindow.h"
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
#include "nsIWebNavigation.h"
|
|
#include "nsServiceManagerUtils.h"
|
|
#include "nsIWebProgress.h"
|
|
#include "nsCoreUtils.h"
|
|
#include "nsXULAppAPI.h"
|
|
#include "mozilla/dom/TabChild.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::a11y;
|
|
using namespace mozilla::dom;
|
|
|
|
StaticAutoPtr<nsTArray<DocAccessibleParent*>> DocManager::sRemoteDocuments;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// DocManager
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
DocManager::DocManager()
|
|
: mDocAccessibleCache(2), mXPCDocumentCache(0)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// DocManager public
|
|
|
|
DocAccessible*
|
|
DocManager::GetDocAccessible(nsIDocument* aDocument)
|
|
{
|
|
if (!aDocument)
|
|
return nullptr;
|
|
|
|
// Ensure CacheChildren is called before we query cache.
|
|
ApplicationAcc()->EnsureChildren();
|
|
|
|
DocAccessible* docAcc = GetExistingDocAccessible(aDocument);
|
|
if (docAcc)
|
|
return docAcc;
|
|
|
|
return CreateDocOrRootAccessible(aDocument);
|
|
}
|
|
|
|
Accessible*
|
|
DocManager::FindAccessibleInCache(nsINode* aNode) const
|
|
{
|
|
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
|
|
DocAccessible* docAccessible = iter.UserData();
|
|
NS_ASSERTION(docAccessible,
|
|
"No doc accessible for the object in doc accessible cache!");
|
|
|
|
if (docAccessible) {
|
|
Accessible* accessible = docAccessible->GetAccessible(aNode);
|
|
if (accessible) {
|
|
return accessible;
|
|
}
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void
|
|
DocManager::NotifyOfDocumentShutdown(DocAccessible* aDocument,
|
|
nsIDocument* aDOMDocument)
|
|
{
|
|
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
|
|
if (xpcDoc) {
|
|
xpcDoc->Shutdown();
|
|
mXPCDocumentCache.Remove(aDocument);
|
|
}
|
|
|
|
mDocAccessibleCache.Remove(aDOMDocument);
|
|
RemoveListeners(aDOMDocument);
|
|
}
|
|
|
|
xpcAccessibleDocument*
|
|
DocManager::GetXPCDocument(DocAccessible* aDocument)
|
|
{
|
|
if (!aDocument)
|
|
return nullptr;
|
|
|
|
xpcAccessibleDocument* xpcDoc = mXPCDocumentCache.GetWeak(aDocument);
|
|
if (!xpcDoc) {
|
|
xpcDoc = new xpcAccessibleDocument(aDocument);
|
|
mXPCDocumentCache.Put(aDocument, xpcDoc);
|
|
}
|
|
return xpcDoc;
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
bool
|
|
DocManager::IsProcessingRefreshDriverNotification() const
|
|
{
|
|
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
|
|
DocAccessible* docAccessible = iter.UserData();
|
|
NS_ASSERTION(docAccessible,
|
|
"No doc accessible for the object in doc accessible cache!");
|
|
|
|
if (docAccessible && docAccessible->mNotificationController &&
|
|
docAccessible->mNotificationController->IsUpdating()) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// DocManager protected
|
|
|
|
bool
|
|
DocManager::Init()
|
|
{
|
|
nsCOMPtr<nsIWebProgress> progress =
|
|
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
|
|
|
|
if (!progress)
|
|
return false;
|
|
|
|
progress->AddProgressListener(static_cast<nsIWebProgressListener*>(this),
|
|
nsIWebProgress::NOTIFY_STATE_DOCUMENT);
|
|
|
|
return true;
|
|
}
|
|
|
|
void
|
|
DocManager::Shutdown()
|
|
{
|
|
nsCOMPtr<nsIWebProgress> progress =
|
|
do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
|
|
|
|
if (progress)
|
|
progress->RemoveProgressListener(static_cast<nsIWebProgressListener*>(this));
|
|
|
|
ClearDocCache();
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// nsISupports
|
|
|
|
NS_IMPL_ISUPPORTS(DocManager,
|
|
nsIWebProgressListener,
|
|
nsIDOMEventListener,
|
|
nsISupportsWeakReference)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// nsIWebProgressListener
|
|
|
|
NS_IMETHODIMP
|
|
DocManager::OnStateChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest, uint32_t aStateFlags,
|
|
nsresult aStatus)
|
|
{
|
|
NS_ASSERTION(aStateFlags & STATE_IS_DOCUMENT, "Other notifications excluded");
|
|
|
|
if (nsAccessibilityService::IsShutdown() || !aWebProgress ||
|
|
(aStateFlags & (STATE_START | STATE_STOP)) == 0)
|
|
return NS_OK;
|
|
|
|
nsCOMPtr<nsIDOMWindow> DOMWindow;
|
|
aWebProgress->GetDOMWindow(getter_AddRefs(DOMWindow));
|
|
NS_ENSURE_STATE(DOMWindow);
|
|
|
|
nsCOMPtr<nsIDOMDocument> DOMDocument;
|
|
DOMWindow->GetDocument(getter_AddRefs(DOMDocument));
|
|
NS_ENSURE_STATE(DOMDocument);
|
|
|
|
nsCOMPtr<nsIDocument> document(do_QueryInterface(DOMDocument));
|
|
|
|
// Document was loaded.
|
|
if (aStateFlags & STATE_STOP) {
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eDocLoad))
|
|
logging::DocLoad("document loaded", aWebProgress, aRequest, aStateFlags);
|
|
#endif
|
|
|
|
// Figure out an event type to notify the document has been loaded.
|
|
uint32_t eventType = nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED;
|
|
|
|
// Some XUL documents get start state and then stop state with failure
|
|
// status when everything is ok. Fire document load complete event in this
|
|
// case.
|
|
if (NS_SUCCEEDED(aStatus) || !nsCoreUtils::IsContentDocument(document))
|
|
eventType = nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE;
|
|
|
|
// If end consumer has been retargeted for loaded content then do not fire
|
|
// any event because it means no new document has been loaded, for example,
|
|
// it happens when user clicks on file link.
|
|
if (aRequest) {
|
|
uint32_t loadFlags = 0;
|
|
aRequest->GetLoadFlags(&loadFlags);
|
|
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
|
|
eventType = 0;
|
|
}
|
|
|
|
HandleDOMDocumentLoad(document, eventType);
|
|
return NS_OK;
|
|
}
|
|
|
|
// Document loading was started.
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eDocLoad))
|
|
logging::DocLoad("start document loading", aWebProgress, aRequest, aStateFlags);
|
|
#endif
|
|
|
|
DocAccessible* docAcc = GetExistingDocAccessible(document);
|
|
if (!docAcc)
|
|
return NS_OK;
|
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(DOMWindow));
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
|
|
NS_ENSURE_STATE(docShell);
|
|
|
|
bool isReloading = false;
|
|
uint32_t loadType;
|
|
docShell->GetLoadType(&loadType);
|
|
if (loadType == LOAD_RELOAD_NORMAL ||
|
|
loadType == LOAD_RELOAD_BYPASS_CACHE ||
|
|
loadType == LOAD_RELOAD_BYPASS_PROXY ||
|
|
loadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE ||
|
|
loadType == LOAD_RELOAD_ALLOW_MIXED_CONTENT) {
|
|
isReloading = true;
|
|
}
|
|
|
|
docAcc->NotifyOfLoading(isReloading);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DocManager::OnProgressChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest,
|
|
int32_t aCurSelfProgress,
|
|
int32_t aMaxSelfProgress,
|
|
int32_t aCurTotalProgress,
|
|
int32_t aMaxTotalProgress)
|
|
{
|
|
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DocManager::OnLocationChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest, nsIURI* aLocation,
|
|
uint32_t aFlags)
|
|
{
|
|
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DocManager::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest, nsresult aStatus,
|
|
const char16_t* aMessage)
|
|
{
|
|
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DocManager::OnSecurityChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest,
|
|
uint32_t aState)
|
|
{
|
|
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
|
|
return NS_OK;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// nsIDOMEventListener
|
|
|
|
NS_IMETHODIMP
|
|
DocManager::HandleEvent(nsIDOMEvent* aEvent)
|
|
{
|
|
nsAutoString type;
|
|
aEvent->GetType(type);
|
|
|
|
nsCOMPtr<nsIDocument> document =
|
|
do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
|
|
NS_ASSERTION(document, "pagehide or DOMContentLoaded for non document!");
|
|
if (!document)
|
|
return NS_OK;
|
|
|
|
if (type.EqualsLiteral("pagehide")) {
|
|
// 'pagehide' event is registered on every DOM document we create an
|
|
// accessible for, process the event for the target. This document
|
|
// accessible and all its sub document accessible are shutdown as result of
|
|
// processing.
|
|
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eDocDestroy))
|
|
logging::DocDestroy("received 'pagehide' event", document);
|
|
#endif
|
|
|
|
// Shutdown this one and sub document accessibles.
|
|
|
|
// We're allowed to not remove listeners when accessible document is
|
|
// shutdown since we don't keep strong reference on chrome event target and
|
|
// listeners are removed automatically when chrome event target goes away.
|
|
DocAccessible* docAccessible = GetExistingDocAccessible(document);
|
|
if (docAccessible)
|
|
docAccessible->Shutdown();
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
// XXX: handle error pages loading separately since they get neither
|
|
// webprogress notifications nor 'pageshow' event.
|
|
if (type.EqualsLiteral("DOMContentLoaded") &&
|
|
nsCoreUtils::IsErrorPage(document)) {
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eDocLoad))
|
|
logging::DocLoad("handled 'DOMContentLoaded' event", document);
|
|
#endif
|
|
|
|
HandleDOMDocumentLoad(document,
|
|
nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// DocManager private
|
|
|
|
void
|
|
DocManager::HandleDOMDocumentLoad(nsIDocument* aDocument,
|
|
uint32_t aLoadEventType)
|
|
{
|
|
// Document accessible can be created before we were notified the DOM document
|
|
// was loaded completely. However if it's not created yet then create it.
|
|
DocAccessible* docAcc = GetExistingDocAccessible(aDocument);
|
|
if (!docAcc) {
|
|
docAcc = CreateDocOrRootAccessible(aDocument);
|
|
if (!docAcc)
|
|
return;
|
|
}
|
|
|
|
docAcc->NotifyOfLoad(aLoadEventType);
|
|
}
|
|
|
|
void
|
|
DocManager::AddListeners(nsIDocument* aDocument,
|
|
bool aAddDOMContentLoadedListener)
|
|
{
|
|
nsPIDOMWindow* window = aDocument->GetWindow();
|
|
EventTarget* target = window->GetChromeEventHandler();
|
|
EventListenerManager* elm = target->GetOrCreateListenerManager();
|
|
elm->AddEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
|
|
TrustedEventsAtCapture());
|
|
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eDocCreate))
|
|
logging::Text("added 'pagehide' listener");
|
|
#endif
|
|
|
|
if (aAddDOMContentLoadedListener) {
|
|
elm->AddEventListenerByType(this, NS_LITERAL_STRING("DOMContentLoaded"),
|
|
TrustedEventsAtCapture());
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eDocCreate))
|
|
logging::Text("added 'DOMContentLoaded' listener");
|
|
#endif
|
|
}
|
|
}
|
|
|
|
void
|
|
DocManager::RemoveListeners(nsIDocument* aDocument)
|
|
{
|
|
nsPIDOMWindow* window = aDocument->GetWindow();
|
|
if (!window)
|
|
return;
|
|
|
|
EventTarget* target = window->GetChromeEventHandler();
|
|
if (!target)
|
|
return;
|
|
|
|
EventListenerManager* elm = target->GetOrCreateListenerManager();
|
|
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
|
|
TrustedEventsAtCapture());
|
|
|
|
elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("DOMContentLoaded"),
|
|
TrustedEventsAtCapture());
|
|
}
|
|
|
|
DocAccessible*
|
|
DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
|
|
{
|
|
// Ignore hiding, resource documents and documents without docshell.
|
|
if (!aDocument->IsVisibleConsideringAncestors() ||
|
|
aDocument->IsResourceDoc() || !aDocument->IsActive())
|
|
return nullptr;
|
|
|
|
// Ignore documents without presshell and not having root frame.
|
|
nsIPresShell* presShell = aDocument->GetShell();
|
|
if (!presShell || presShell->IsDestroying())
|
|
return nullptr;
|
|
|
|
bool isRootDoc = nsCoreUtils::IsRootDocument(aDocument);
|
|
|
|
DocAccessible* parentDocAcc = nullptr;
|
|
if (!isRootDoc) {
|
|
// XXXaaronl: ideally we would traverse the presshell chain. Since there's
|
|
// no easy way to do that, we cheat and use the document hierarchy.
|
|
parentDocAcc = GetDocAccessible(aDocument->GetParentDocument());
|
|
NS_ASSERTION(parentDocAcc,
|
|
"Can't create an accessible for the document!");
|
|
if (!parentDocAcc)
|
|
return nullptr;
|
|
}
|
|
|
|
// We only create root accessibles for the true root, otherwise create a
|
|
// doc accessible.
|
|
nsIContent *rootElm = nsCoreUtils::GetRoleContent(aDocument);
|
|
RefPtr<DocAccessible> docAcc = isRootDoc ?
|
|
new RootAccessibleWrap(aDocument, rootElm, presShell) :
|
|
new DocAccessibleWrap(aDocument, rootElm, presShell);
|
|
|
|
// Cache the document accessible into document cache.
|
|
mDocAccessibleCache.Put(aDocument, docAcc);
|
|
|
|
// Initialize the document accessible.
|
|
docAcc->Init();
|
|
docAcc->SetRoleMapEntry(aria::GetRoleMap(aDocument));
|
|
|
|
// Bind the document to the tree.
|
|
if (isRootDoc) {
|
|
if (!ApplicationAcc()->AppendChild(docAcc)) {
|
|
docAcc->Shutdown();
|
|
return nullptr;
|
|
}
|
|
|
|
// Fire reorder event to notify new accessible document has been attached to
|
|
// the tree. The reorder event is delivered after the document tree is
|
|
// constructed because event processing and tree construction are done by
|
|
// the same document.
|
|
// Note: don't use AccReorderEvent to avoid coalsecense and special reorder
|
|
// events processing.
|
|
docAcc->FireDelayedEvent(nsIAccessibleEvent::EVENT_REORDER,
|
|
ApplicationAcc());
|
|
|
|
if (IPCAccessibilityActive()) {
|
|
nsIDocShell* docShell = aDocument->GetDocShell();
|
|
if (docShell) {
|
|
nsCOMPtr<nsITabChild> tabChild = do_GetInterface(docShell);
|
|
|
|
// XXX We may need to handle the case that we don't have a tab child
|
|
// differently. It may be that this will cause us to fail to notify
|
|
// the parent process about important accessible documents.
|
|
if (tabChild) {
|
|
DocAccessibleChild* ipcDoc = new DocAccessibleChild(docAcc);
|
|
docAcc->SetIPCDoc(ipcDoc);
|
|
static_cast<TabChild*>(tabChild.get())->
|
|
SendPDocAccessibleConstructor(ipcDoc, nullptr, 0);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
parentDocAcc->BindChildDocument(docAcc);
|
|
}
|
|
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eDocCreate)) {
|
|
logging::DocCreate("document creation finished", aDocument);
|
|
logging::Stack();
|
|
}
|
|
#endif
|
|
|
|
AddListeners(aDocument, isRootDoc);
|
|
return docAcc;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// DocManager static
|
|
|
|
void
|
|
DocManager::ClearDocCache()
|
|
{
|
|
// This unusual do-one-element-per-iterator approach is required because each
|
|
// DocAccessible is removed elsewhere upon its Shutdown() method being
|
|
// called, which invalidates the existing iterator.
|
|
while (mDocAccessibleCache.Count() > 0) {
|
|
auto iter = mDocAccessibleCache.Iter();
|
|
MOZ_ASSERT(!iter.Done());
|
|
DocAccessible* docAcc = iter.UserData();
|
|
NS_ASSERTION(docAcc,
|
|
"No doc accessible for the object in doc accessible cache!");
|
|
if (docAcc) {
|
|
docAcc->Shutdown();
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
DocManager::RemoteDocAdded(DocAccessibleParent* aDoc)
|
|
{
|
|
if (!sRemoteDocuments) {
|
|
sRemoteDocuments = new nsTArray<DocAccessibleParent*>;
|
|
ClearOnShutdown(&sRemoteDocuments);
|
|
}
|
|
|
|
MOZ_ASSERT(!sRemoteDocuments->Contains(aDoc),
|
|
"How did we already have the doc!");
|
|
sRemoteDocuments->AppendElement(aDoc);
|
|
ProxyCreated(aDoc, Interfaces::DOCUMENT | Interfaces::HYPERTEXT);
|
|
}
|