2010-06-08 09:39:58 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef nsAccDocManager_h_
|
|
|
|
#define nsAccDocManager_h_
|
|
|
|
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
2011-01-27 20:38:14 -08:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2010-06-08 09:39:58 -07:00
|
|
|
#include "nsIWebProgress.h"
|
|
|
|
#include "nsIWebProgressListener.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
2011-01-27 20:38:14 -08:00
|
|
|
class nsAccessible;
|
2010-06-08 09:39:58 -07:00
|
|
|
class nsDocAccessible;
|
|
|
|
|
2010-06-17 19:44:09 -07:00
|
|
|
//#define DEBUG_ACCDOCMGR
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
/**
|
|
|
|
* Manage the document accessible life cycle.
|
|
|
|
*/
|
|
|
|
class nsAccDocManager : public nsIWebProgressListener,
|
|
|
|
public nsIDOMEventListener,
|
|
|
|
public nsSupportsWeakReference
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~nsAccDocManager() { };
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIWEBPROGRESSLISTENER
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return document accessible for the given DOM node.
|
|
|
|
*/
|
|
|
|
nsDocAccessible *GetDocAccessible(nsIDocument *aDocument);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search through all document accessibles for an accessible with the given
|
|
|
|
* unique id.
|
|
|
|
*/
|
2010-10-20 21:16:10 -07:00
|
|
|
nsAccessible* FindAccessibleInCache(nsINode* aNode) const;
|
2010-06-08 09:39:58 -07:00
|
|
|
|
2010-06-17 19:44:09 -07:00
|
|
|
/**
|
|
|
|
* Return document accessible from the cache. Convenient method for testing.
|
|
|
|
*/
|
|
|
|
inline nsDocAccessible* GetDocAccessibleFromCache(nsIDocument* aDocument) const
|
|
|
|
{
|
2010-10-20 21:16:10 -07:00
|
|
|
return mDocAccessibleCache.GetWeak(aDocument);
|
2010-06-17 19:44:09 -07:00
|
|
|
}
|
|
|
|
|
2010-10-28 02:34:26 -07:00
|
|
|
/**
|
|
|
|
* Called by document accessible when it gets shutdown.
|
|
|
|
*/
|
|
|
|
inline void NotifyOfDocumentShutdown(nsIDocument* aDocument)
|
|
|
|
{
|
|
|
|
mDocAccessibleCache.Remove(aDocument);
|
|
|
|
}
|
|
|
|
|
2011-10-05 19:10:30 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
bool IsProcessingRefreshDriverNotification() const;
|
|
|
|
#endif
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
protected:
|
|
|
|
nsAccDocManager() { };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the manager.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Init();
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shutdown the manager.
|
|
|
|
*/
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsAccDocManager(const nsAccDocManager&);
|
|
|
|
nsAccDocManager& operator =(const nsAccDocManager&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Create an accessible document if it was't created and fire accessibility
|
|
|
|
* events if needed.
|
|
|
|
*
|
|
|
|
* @param aDocument [in] loaded DOM document
|
|
|
|
* @param aLoadEventType [in] specifies the event type to fire load event,
|
|
|
|
* if 0 then no event is fired
|
|
|
|
*/
|
|
|
|
void HandleDOMDocumentLoad(nsIDocument *aDocument,
|
2010-11-22 00:22:04 -08:00
|
|
|
PRUint32 aLoadEventType);
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
/**
|
2010-06-17 19:44:09 -07:00
|
|
|
* Add 'pagehide' and 'DOMContentLoaded' event listeners.
|
2010-06-08 09:39:58 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void AddListeners(nsIDocument *aDocument, bool aAddPageShowListener);
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create document or root accessible.
|
|
|
|
*/
|
|
|
|
nsDocAccessible *CreateDocOrRootAccessible(nsIDocument *aDocument);
|
|
|
|
|
2010-10-20 21:16:10 -07:00
|
|
|
typedef nsRefPtrHashtable<nsPtrHashKey<const nsIDocument>, nsDocAccessible>
|
2010-06-08 09:39:58 -07:00
|
|
|
nsDocAccessibleHashtable;
|
|
|
|
|
|
|
|
/**
|
2010-12-02 08:07:14 -08:00
|
|
|
* Get first entry of the document accessible from cache.
|
2010-06-08 09:39:58 -07:00
|
|
|
*/
|
|
|
|
static PLDHashOperator
|
2010-12-02 08:07:14 -08:00
|
|
|
GetFirstEntryInDocCache(const nsIDocument* aKey,
|
|
|
|
nsDocAccessible* aDocAccessible,
|
|
|
|
void* aUserArg);
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the cache and shutdown the document accessibles.
|
|
|
|
*/
|
2010-12-02 08:07:14 -08:00
|
|
|
void ClearDocCache();
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
struct nsSearchAccessibleInCacheArg
|
|
|
|
{
|
2010-06-11 21:04:35 -07:00
|
|
|
nsAccessible *mAccessible;
|
2010-10-20 21:16:10 -07:00
|
|
|
nsINode* mNode;
|
2010-06-08 09:39:58 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static PLDHashOperator
|
2010-10-20 21:16:10 -07:00
|
|
|
SearchAccessibleInDocCache(const nsIDocument* aKey,
|
2010-06-08 09:39:58 -07:00
|
|
|
nsDocAccessible* aDocAccessible,
|
|
|
|
void* aUserArg);
|
|
|
|
|
2011-10-05 19:10:30 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
static PLDHashOperator
|
|
|
|
SearchIfDocIsRefreshing(const nsIDocument* aKey,
|
|
|
|
nsDocAccessible* aDocAccessible, void* aUserArg);
|
|
|
|
#endif
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
nsDocAccessibleHashtable mDocAccessibleCache;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsAccDocManager debugging macros.
|
|
|
|
*/
|
|
|
|
#ifdef DEBUG_ACCDOCMGR
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
#include "nsTraceRefcntImpl.h"
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
// Enable these to log accessible document loading, creation or destruction.
|
|
|
|
#define DEBUG_ACCDOCMGR_DOCLOAD
|
|
|
|
#define DEBUG_ACCDOCMGR_DOCCREATE
|
|
|
|
#define DEBUG_ACCDOCMGR_DOCDESTROY
|
|
|
|
|
|
|
|
// Common macros, do not use directly.
|
|
|
|
#define NS_LOG_ACCDOC_ADDRESS(aDocument, aDocAcc) \
|
2010-06-17 19:44:09 -07:00
|
|
|
printf("DOM id: %p, acc id: %p", aDocument, aDocAcc);
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_URI(aDocument) \
|
|
|
|
nsIURI *uri = aDocument->GetDocumentURI(); \
|
|
|
|
nsCAutoString spec; \
|
|
|
|
uri->GetSpec(spec); \
|
|
|
|
printf("uri: %s", spec);
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_TYPE(aDocument) \
|
2011-05-21 00:00:14 -07:00
|
|
|
if (aDocument->IsActive()) { \
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isContent = nsCoreUtils::IsContentDocument(aDocument); \
|
2011-05-21 00:00:14 -07:00
|
|
|
printf("%s document", (isContent ? "content" : "chrome")); \
|
|
|
|
} else { \
|
|
|
|
printf("document type: [failed]"); \
|
|
|
|
}
|
2010-06-08 09:39:58 -07:00
|
|
|
|
2011-07-21 17:49:35 -07:00
|
|
|
#define NS_LOG_ACCDOC_DOCSHELLTREE(aDocument) \
|
|
|
|
if (aDocument->IsActive()) { \
|
|
|
|
nsCOMPtr<nsISupports> container = aDocument->GetContainer(); \
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(container)); \
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem; \
|
|
|
|
treeItem->GetParent(getter_AddRefs(parentTreeItem)); \
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> rootTreeItem; \
|
|
|
|
treeItem->GetRootTreeItem(getter_AddRefs(rootTreeItem)); \
|
|
|
|
printf("docshell hierarchy, parent: %p, root: %p, is tab document: %s;", \
|
|
|
|
parentTreeItem, rootTreeItem, \
|
|
|
|
(nsCoreUtils::IsTabDocument(aDocument) ? "yes" : "no")); \
|
|
|
|
}
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
#define NS_LOG_ACCDOC_SHELLSTATE(aDocument) \
|
|
|
|
nsCAutoString docShellBusy; \
|
2011-05-21 00:00:14 -07:00
|
|
|
nsCOMPtr<nsISupports> container = aDocument->GetContainer(); \
|
|
|
|
if (container) { \
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container); \
|
|
|
|
PRUint32 busyFlags = nsIDocShell::BUSY_FLAGS_NONE; \
|
|
|
|
docShell->GetBusyFlags(&busyFlags); \
|
|
|
|
if (busyFlags == nsIDocShell::BUSY_FLAGS_NONE) \
|
|
|
|
docShellBusy.AppendLiteral("'none'"); \
|
|
|
|
if (busyFlags & nsIDocShell::BUSY_FLAGS_BUSY) \
|
|
|
|
docShellBusy.AppendLiteral("'busy'"); \
|
|
|
|
if (busyFlags & nsIDocShell::BUSY_FLAGS_BEFORE_PAGE_LOAD) \
|
|
|
|
docShellBusy.AppendLiteral(", 'before page load'"); \
|
|
|
|
if (busyFlags & nsIDocShell::BUSY_FLAGS_PAGE_LOADING) \
|
|
|
|
docShellBusy.AppendLiteral(", 'page loading'"); \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
docShellBusy.AppendLiteral("[failed]"); \
|
|
|
|
} \
|
2010-06-08 09:39:58 -07:00
|
|
|
printf("docshell busy: %s", docShellBusy.get());
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_DOCSTATES(aDocument) \
|
|
|
|
const char *docState = 0; \
|
|
|
|
nsIDocument::ReadyState docStateFlag = aDocument->GetReadyStateEnum(); \
|
|
|
|
switch (docStateFlag) { \
|
|
|
|
case nsIDocument::READYSTATE_UNINITIALIZED: \
|
|
|
|
docState = "uninitialized"; \
|
|
|
|
break; \
|
|
|
|
case nsIDocument::READYSTATE_LOADING: \
|
|
|
|
docState = "loading"; \
|
|
|
|
break; \
|
|
|
|
case nsIDocument::READYSTATE_INTERACTIVE: \
|
|
|
|
docState = "interactive"; \
|
|
|
|
break; \
|
|
|
|
case nsIDocument::READYSTATE_COMPLETE: \
|
|
|
|
docState = "complete"; \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
printf("doc state: %s", docState); \
|
|
|
|
printf(", %sinitial", aDocument->IsInitialDocument() ? "" : "not "); \
|
|
|
|
printf(", %sshowing", aDocument->IsShowing() ? "" : "not "); \
|
|
|
|
printf(", %svisible", aDocument->IsVisible() ? "" : "not "); \
|
|
|
|
printf(", %sactive", aDocument->IsActive() ? "" : "not ");
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_DOCPRESSHELL(aDocument) \
|
2010-06-25 06:59:57 -07:00
|
|
|
nsIPresShell *ps = aDocument->GetShell(); \
|
2010-06-17 19:44:09 -07:00
|
|
|
printf("presshell: %p", ps); \
|
2010-06-08 09:39:58 -07:00
|
|
|
nsIScrollableFrame *sf = ps ? \
|
|
|
|
ps->GetRootScrollFrameAsScrollableExternal() : nsnull; \
|
2010-06-17 19:44:09 -07:00
|
|
|
printf(", root scroll frame: %p", sf);
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_DOCLOADGROUP(aDocument) \
|
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup = aDocument->GetDocumentLoadGroup(); \
|
2010-06-17 19:44:09 -07:00
|
|
|
printf("load group: %p", loadGroup);
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_DOCPARENT(aDocument) \
|
|
|
|
nsIDocument *parentDoc = aDocument->GetParentDocument(); \
|
2010-06-17 19:44:09 -07:00
|
|
|
printf("parent id: %p", parentDoc); \
|
2010-06-08 09:39:58 -07:00
|
|
|
if (parentDoc) { \
|
|
|
|
printf("\n parent "); \
|
|
|
|
NS_LOG_ACCDOC_URI(parentDoc) \
|
|
|
|
printf("\n"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_SHELLLOADTYPE(aDocShell) \
|
|
|
|
{ \
|
|
|
|
printf("load type: "); \
|
|
|
|
PRUint32 loadType; \
|
|
|
|
docShell->GetLoadType(&loadType); \
|
|
|
|
switch (loadType) { \
|
|
|
|
case LOAD_NORMAL: \
|
|
|
|
printf("normal; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_NORMAL_REPLACE: \
|
|
|
|
printf("normal replace; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_NORMAL_EXTERNAL: \
|
|
|
|
printf("normal external; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_HISTORY: \
|
|
|
|
printf("history; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_NORMAL_BYPASS_CACHE: \
|
|
|
|
printf("normal bypass cache; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_NORMAL_BYPASS_PROXY: \
|
|
|
|
printf("normal bypass proxy; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE: \
|
|
|
|
printf("normal bypass proxy and cache; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_RELOAD_NORMAL: \
|
|
|
|
printf("reload normal; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_RELOAD_BYPASS_CACHE: \
|
|
|
|
printf("reload bypass cache; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_RELOAD_BYPASS_PROXY: \
|
|
|
|
printf("reload bypass proxy; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE: \
|
|
|
|
printf("reload bypass proxy and cache; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_LINK: \
|
|
|
|
printf("link; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_REFRESH: \
|
|
|
|
printf("refresh; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_RELOAD_CHARSET_CHANGE: \
|
|
|
|
printf("reload charset change; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_BYPASS_HISTORY: \
|
|
|
|
printf("bypass history; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_STOP_CONTENT: \
|
|
|
|
printf("stop content; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_STOP_CONTENT_AND_REPLACE: \
|
|
|
|
printf("stop content and replace; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_PUSHSTATE: \
|
|
|
|
printf("load pushstate; "); \
|
|
|
|
break; \
|
|
|
|
case LOAD_ERROR_PAGE: \
|
|
|
|
printf("error page;"); \
|
|
|
|
break; \
|
|
|
|
default: \
|
|
|
|
printf("unknown"); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_DOCINFO_BEGIN \
|
|
|
|
printf(" {\n");
|
|
|
|
#define NS_LOG_ACCDOC_DOCINFO_BODY(aDocument, aDocAcc) \
|
|
|
|
{ \
|
|
|
|
printf(" "); \
|
|
|
|
NS_LOG_ACCDOC_ADDRESS(aDocument, aDocAcc) \
|
|
|
|
printf("\n "); \
|
2011-05-21 00:00:14 -07:00
|
|
|
if (aDocument) { \
|
|
|
|
NS_LOG_ACCDOC_URI(aDocument) \
|
|
|
|
printf("\n "); \
|
|
|
|
NS_LOG_ACCDOC_SHELLSTATE(aDocument) \
|
|
|
|
printf("; "); \
|
|
|
|
NS_LOG_ACCDOC_TYPE(aDocument) \
|
|
|
|
printf("\n "); \
|
2011-07-21 17:49:35 -07:00
|
|
|
NS_LOG_ACCDOC_DOCSHELLTREE(aDocument) \
|
|
|
|
printf("\n "); \
|
2011-05-21 00:00:14 -07:00
|
|
|
NS_LOG_ACCDOC_DOCSTATES(aDocument) \
|
|
|
|
printf("\n "); \
|
|
|
|
NS_LOG_ACCDOC_DOCPRESSHELL(aDocument) \
|
|
|
|
printf("\n "); \
|
|
|
|
NS_LOG_ACCDOC_DOCLOADGROUP(aDocument) \
|
|
|
|
printf(", "); \
|
|
|
|
NS_LOG_ACCDOC_DOCPARENT(aDocument) \
|
|
|
|
printf("\n"); \
|
|
|
|
} \
|
2010-06-08 09:39:58 -07:00
|
|
|
}
|
|
|
|
#define NS_LOG_ACCDOC_DOCINFO_END \
|
|
|
|
printf(" }\n");
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_DOCINFO(aDocument, aDocAcc) \
|
|
|
|
NS_LOG_ACCDOC_DOCINFO_BEGIN \
|
|
|
|
NS_LOG_ACCDOC_DOCINFO_BODY(aDocument, aDocAcc) \
|
|
|
|
NS_LOG_ACCDOC_DOCINFO_END
|
|
|
|
|
|
|
|
#define NS_GET_ACCDOC_EVENTTYPE(aEvent) \
|
|
|
|
nsCAutoString strEventType; \
|
|
|
|
PRUint32 type = aEvent->GetEventType(); \
|
|
|
|
if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED) { \
|
|
|
|
strEventType.AssignLiteral("load stopped"); \
|
|
|
|
} else if (type == nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE) { \
|
|
|
|
strEventType.AssignLiteral("load complete"); \
|
|
|
|
} else if (type == nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD) { \
|
|
|
|
strEventType.AssignLiteral("reload"); \
|
|
|
|
} else if (type == nsIAccessibleEvent::EVENT_STATE_CHANGE) { \
|
2010-08-24 19:08:28 -07:00
|
|
|
AccStateChangeEvent* event = downcast_accEvent(aEvent); \
|
2011-04-09 16:38:06 -07:00
|
|
|
if (event->GetState() == states::BUSY) { \
|
2010-06-08 09:39:58 -07:00
|
|
|
strEventType.AssignLiteral("busy "); \
|
2010-06-14 23:16:16 -07:00
|
|
|
if (event->IsStateEnabled()) \
|
2010-06-08 09:39:58 -07:00
|
|
|
strEventType.AppendLiteral("true"); \
|
|
|
|
else \
|
|
|
|
strEventType.AppendLiteral("false"); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2010-06-17 19:44:09 -07:00
|
|
|
#define NS_LOG_ACCDOC_ACCADDRESS(aName, aAcc) \
|
|
|
|
{ \
|
|
|
|
nsINode* node = aAcc->GetNode(); \
|
|
|
|
nsIDocument* doc = aAcc->GetDocumentNode(); \
|
|
|
|
nsDocAccessible *docacc = GetAccService()->GetDocAccessibleFromCache(doc); \
|
|
|
|
printf(" " aName " accessible: %p, node: %p\n", aAcc, node); \
|
|
|
|
printf(" docacc for " aName " accessible: %p, node: %p\n", docacc, doc); \
|
|
|
|
printf(" "); \
|
|
|
|
NS_LOG_ACCDOC_URI(doc) \
|
|
|
|
printf("\n"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOC_MSG(aMsg) \
|
|
|
|
printf("\n" aMsg "\n"); \
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
#define NS_LOG_ACCDOC_TEXT(aMsg) \
|
|
|
|
printf(" " aMsg "\n");
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
#define NS_LOG_ACCDOC_STACK \
|
|
|
|
printf(" stack: \n"); \
|
|
|
|
nsTraceRefcntImpl::WalkTheStack(stdout);
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
// Accessible document loading macros.
|
|
|
|
#ifdef DEBUG_ACCDOCMGR_DOCLOAD
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCLOAD_REQUEST(aRequest) \
|
|
|
|
if (aRequest) { \
|
|
|
|
nsCAutoString name; \
|
|
|
|
aRequest->GetName(name); \
|
|
|
|
printf(" request spec: %s\n", name.get()); \
|
|
|
|
PRUint32 loadFlags = 0; \
|
|
|
|
aRequest->GetLoadFlags(&loadFlags); \
|
|
|
|
printf(" request load flags: %x; ", loadFlags); \
|
|
|
|
if (loadFlags & nsIChannel::LOAD_DOCUMENT_URI) \
|
|
|
|
printf("document uri; "); \
|
|
|
|
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) \
|
|
|
|
printf("retargeted document uri; "); \
|
|
|
|
if (loadFlags & nsIChannel::LOAD_REPLACE) \
|
|
|
|
printf("replace; "); \
|
|
|
|
if (loadFlags & nsIChannel::LOAD_INITIAL_DOCUMENT_URI) \
|
|
|
|
printf("initial document uri; "); \
|
|
|
|
if (loadFlags & nsIChannel::LOAD_TARGETED) \
|
|
|
|
printf("targeted; "); \
|
|
|
|
if (loadFlags & nsIChannel::LOAD_CALL_CONTENT_SNIFFERS) \
|
|
|
|
printf("call content sniffers; "); \
|
|
|
|
if (loadFlags & nsIChannel::LOAD_CLASSIFY_URI) \
|
|
|
|
printf("classify uri; "); \
|
|
|
|
} else { \
|
|
|
|
printf(" no request"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCLOAD(aMsg, aWebProgress, aRequest, aStateFlags) \
|
|
|
|
{ \
|
2010-06-17 19:44:09 -07:00
|
|
|
NS_LOG_ACCDOC_MSG("A11Y DOCLOAD: " aMsg); \
|
2010-06-08 09:39:58 -07:00
|
|
|
\
|
|
|
|
nsCOMPtr<nsIDOMWindow> DOMWindow; \
|
|
|
|
aWebProgress->GetDOMWindow(getter_AddRefs(DOMWindow)); \
|
|
|
|
if (DOMWindow) { \
|
|
|
|
nsCOMPtr<nsIDOMDocument> DOMDocument; \
|
|
|
|
DOMWindow->GetDocument(getter_AddRefs(DOMDocument)); \
|
|
|
|
if (DOMDocument) { \
|
|
|
|
nsCOMPtr<nsIDocument> document(do_QueryInterface(DOMDocument)); \
|
|
|
|
nsDocAccessible *docAcc = \
|
2010-06-17 19:44:09 -07:00
|
|
|
GetAccService()->GetDocAccessibleFromCache(document); \
|
2010-06-08 09:39:58 -07:00
|
|
|
NS_LOG_ACCDOC_DOCINFO(document, docAcc) \
|
|
|
|
\
|
|
|
|
printf(" {\n"); \
|
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(DOMWindow)); \
|
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav)); \
|
|
|
|
printf(" "); \
|
|
|
|
NS_LOG_ACCDOC_SHELLLOADTYPE(docShell) \
|
|
|
|
printf("\n"); \
|
|
|
|
NS_LOG_ACCDOCLOAD_REQUEST(aRequest) \
|
|
|
|
printf("\n"); \
|
|
|
|
printf(" state flags: %x", aStateFlags); \
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isDocLoading; \
|
2010-06-08 09:39:58 -07:00
|
|
|
aWebProgress->GetIsLoadingDocument(&isDocLoading); \
|
|
|
|
printf(", document is %sloading\n", (isDocLoading ? "" : "not ")); \
|
|
|
|
printf(" }\n"); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCLOAD2(aMsg, aDocument) \
|
|
|
|
{ \
|
2010-06-17 19:44:09 -07:00
|
|
|
NS_LOG_ACCDOC_MSG("A11Y DOCLOAD: " aMsg); \
|
2010-06-08 09:39:58 -07:00
|
|
|
nsDocAccessible *docAcc = \
|
2010-06-17 19:44:09 -07:00
|
|
|
GetAccService()->GetDocAccessibleFromCache(aDocument); \
|
2010-06-08 09:39:58 -07:00
|
|
|
NS_LOG_ACCDOC_DOCINFO(aDocument, docAcc) \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCLOAD_FIREEVENT(aEvent) \
|
|
|
|
{ \
|
|
|
|
NS_GET_ACCDOC_EVENTTYPE(aEvent) \
|
|
|
|
if (!strEventType.IsEmpty()) \
|
|
|
|
printf(" fire: %s\n", strEventType.get()); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCLOAD_HANDLEEVENT(aEvent) \
|
|
|
|
{ \
|
|
|
|
NS_GET_ACCDOC_EVENTTYPE(aEvent) \
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(aEvent->GetNode())); \
|
|
|
|
if (doc && !strEventType.IsEmpty()) { \
|
|
|
|
printf("\nA11Y DOCEVENT: handled '%s' event ", strEventType.get()); \
|
|
|
|
nsDocAccessible *docAcc = aEvent->GetDocAccessible(); \
|
|
|
|
NS_LOG_ACCDOC_DOCINFO(doc, docAcc) \
|
|
|
|
printf("\n"); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCLOAD_TEXT(aMsg) \
|
|
|
|
NS_LOG_ACCDOC_TEXT(aMsg)
|
|
|
|
|
|
|
|
#endif // DEBUG_ACCDOCMGR_DOCLOAD
|
|
|
|
|
|
|
|
// Accessible document creation macros.
|
|
|
|
#ifdef DEBUG_ACCDOCMGR_DOCCREATE
|
|
|
|
#define NS_LOG_ACCDOCCREATE_FOR(aMsg, aDocument, aDocAcc) \
|
2010-06-17 19:44:09 -07:00
|
|
|
NS_LOG_ACCDOC_MSG("A11Y DOCCREATE: " aMsg); \
|
2010-06-08 09:39:58 -07:00
|
|
|
NS_LOG_ACCDOC_DOCINFO(aDocument, aDocAcc)
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCCREATE(aMsg, aDocument) \
|
|
|
|
{ \
|
|
|
|
nsDocAccessible *docAcc = \
|
2010-06-17 19:44:09 -07:00
|
|
|
GetAccService()->GetDocAccessibleFromCache(aDocument); \
|
2010-06-08 09:39:58 -07:00
|
|
|
NS_LOG_ACCDOCCREATE_FOR(aMsg, aDocument, docAcc) \
|
|
|
|
}
|
|
|
|
|
2010-06-17 19:44:09 -07:00
|
|
|
#define NS_LOG_ACCDOCCREATE_ACCADDRESS(aName, aAcc) \
|
|
|
|
NS_LOG_ACCDOC_ACCADDRESS(aName, aAcc)
|
|
|
|
|
2010-06-08 09:39:58 -07:00
|
|
|
#define NS_LOG_ACCDOCCREATE_TEXT(aMsg) \
|
2011-09-27 18:46:11 -07:00
|
|
|
NS_LOG_ACCDOC_TEXT(aMsg)
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCCREATE_STACK \
|
|
|
|
NS_LOG_ACCDOC_STACK
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
#endif // DEBUG_ACCDOCMGR_DOCCREATE
|
|
|
|
|
|
|
|
// Accessible document destruction macros.
|
|
|
|
#ifdef DEBUG_ACCDOCMGR_DOCDESTROY
|
|
|
|
#define NS_LOG_ACCDOCDESTROY_FOR(aMsg, aDocument, aDocAcc) \
|
2010-06-17 19:44:09 -07:00
|
|
|
NS_LOG_ACCDOC_MSG("A11Y DOCDESTROY: " aMsg); \
|
2010-06-08 09:39:58 -07:00
|
|
|
NS_LOG_ACCDOC_DOCINFO(aDocument, aDocAcc)
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCDESTROY(aMsg, aDocument) \
|
2010-06-17 19:44:09 -07:00
|
|
|
{ \
|
|
|
|
nsDocAccessible* docAcc = \
|
|
|
|
GetAccService()->GetDocAccessibleFromCache(aDocument); \
|
|
|
|
NS_LOG_ACCDOCDESTROY_FOR(aMsg, aDocument, docAcc) \
|
|
|
|
}
|
2010-06-08 09:39:58 -07:00
|
|
|
|
2010-06-17 19:44:09 -07:00
|
|
|
#define NS_LOG_ACCDOCDESTROY_ACCADDRESS(aName, aAcc) \
|
|
|
|
NS_LOG_ACCDOC_ACCADDRESS(aName, aAcc)
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCDESTROY_MSG(aMsg) \
|
|
|
|
NS_LOG_ACCDOC_MSG(aMsg)
|
|
|
|
|
|
|
|
#define NS_LOG_ACCDOCDESTROY_TEXT(aMsg) \
|
|
|
|
NS_LOG_ACCDOC_TEXT(aMsg)
|
2010-06-08 09:39:58 -07:00
|
|
|
|
|
|
|
#endif // DEBUG_ACCDOCMGR_DOCDESTROY
|
|
|
|
|
|
|
|
#endif // DEBUG_ACCDOCMGR
|
|
|
|
|
|
|
|
#ifndef DEBUG_ACCDOCMGR_DOCLOAD
|
|
|
|
#define NS_LOG_ACCDOCLOAD(aMsg, aWebProgress, aRequest, aStateFlags)
|
|
|
|
#define NS_LOG_ACCDOCLOAD2(aMsg, aDocument)
|
|
|
|
#define NS_LOG_ACCDOCLOAD_EVENT(aMsg, aEvent)
|
|
|
|
#define NS_LOG_ACCDOCLOAD_FIREEVENT(aEvent)
|
|
|
|
#define NS_LOG_ACCDOCLOAD_HANDLEEVENT(aEvent)
|
|
|
|
#define NS_LOG_ACCDOCLOAD_TEXT(aMsg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef DEBUG_ACCDOCMGR_DOCCREATE
|
|
|
|
#define NS_LOG_ACCDOCCREATE_FOR(aMsg, aDocument, aDocAcc)
|
|
|
|
#define NS_LOG_ACCDOCCREATE(aMsg, aDocument)
|
2010-06-17 19:44:09 -07:00
|
|
|
#define NS_LOG_ACCDOCCREATE_ACCADDRESS(aName, aAcc)
|
2010-06-08 09:39:58 -07:00
|
|
|
#define NS_LOG_ACCDOCCREATE_TEXT(aMsg)
|
2011-09-27 18:46:11 -07:00
|
|
|
#define NS_LOG_ACCDOCCREATE_STACK
|
2010-06-08 09:39:58 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef DEBUG_ACCDOCMGR_DOCDESTROY
|
|
|
|
#define NS_LOG_ACCDOCDESTROY_FOR(aMsg, aDocument, aDocAcc)
|
|
|
|
#define NS_LOG_ACCDOCDESTROY(aMsg, aDocument)
|
2010-06-17 19:44:09 -07:00
|
|
|
#define NS_LOG_ACCDOCDESTROY_MSG(aMsg)
|
|
|
|
#define NS_LOG_ACCDOCDESTROY_ACCADDRESS(aName, aAcc)
|
2010-06-08 09:39:58 -07:00
|
|
|
#define NS_LOG_ACCDOCDESTROY_TEXT(aMsg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // nsAccDocManager_h_
|