зеркало из https://github.com/mozilla/pjs.git
Bug 289491. Doc loaded events broken for accessibility. r=biesi, sr=tor, a=shaver
This commit is contained in:
Родитель
ce9de0bfba
Коммит
e086bd155f
|
@ -41,11 +41,13 @@
|
|||
interface nsIAccessNode;
|
||||
interface nsIDOMNode;
|
||||
|
||||
[uuid(F0809603-74E8-4284-8366-B293A5D0B758)]
|
||||
[uuid(EEECD0A1-5F34-428e-8D7A-5D8C755EE18A)]
|
||||
interface nsPIAccessibleDocument : nsISupports
|
||||
{
|
||||
void invalidateCacheSubtree(in nsIDOMNode aStartNode);
|
||||
void cacheAccessNode(in voidPtr aUniqueID, in nsIAccessNode aAccessNode);
|
||||
void destroy();
|
||||
void flushPendingEvents();
|
||||
void fireDocLoadingEvent(in boolean isFinished);
|
||||
void fireAnchorJumpEvent();
|
||||
};
|
||||
|
|
|
@ -531,3 +531,20 @@ void nsDocAccessibleWrap::CheckForEditor()
|
|||
if (mEditor)
|
||||
SetEditor(mEditor); // set editor for nsAccessibleEditableText
|
||||
}
|
||||
|
||||
void nsDocAccessibleWrap::FireDocLoadingEvent(PRBool aIsFinished)
|
||||
{
|
||||
if (!mDocument || !mWeakShell)
|
||||
return NS_OK; // Document has been shut down
|
||||
|
||||
if (!aIsFinished) {
|
||||
// Load has been verified, it will occur, about to commence
|
||||
AtkChildrenChange childrenData;
|
||||
childrenData.index = -1;
|
||||
childrenData.child = 0;
|
||||
childrenData.add = PR_FALSE;
|
||||
FireToolkitEvent(nsIAccessibleEvent::EVENT_REORDER, this, &childrenData);
|
||||
}
|
||||
|
||||
return nsDocAccessible::FireDocLoadingEvent(aIsFinished);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
virtual ~nsDocAccessibleWrap();
|
||||
NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible,
|
||||
void* aData);
|
||||
|
||||
NS_IMETHOD FireDocLoadingEvent(PRBool isFinished);
|
||||
NS_IMETHOD Shutdown();
|
||||
NS_IMETHOD GetRole(PRUint32 *aAccRole);
|
||||
|
||||
|
|
|
@ -487,9 +487,8 @@ nsAccessNode::GetPresShellFor(nsIDOMNode *aNode)
|
|||
|
||||
|
||||
already_AddRefed<nsIDocShellTreeItem>
|
||||
nsAccessNode::GetSameTypeRootFor(nsIDOMNode *aStartNode)
|
||||
nsAccessNode::GetDocShellTreeItemFor(nsIDOMNode *aStartNode)
|
||||
{
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aStartNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
|
@ -498,13 +497,10 @@ nsAccessNode::GetSameTypeRootFor(nsIDOMNode *aStartNode)
|
|||
}
|
||||
NS_ASSERTION(doc, "No document for node passed in");
|
||||
nsCOMPtr<nsISupports> container = doc->GetContainer();
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem(do_QueryInterface(container));
|
||||
NS_ENSURE_TRUE(docShellTreeItem, nsnull);
|
||||
nsIDocShellTreeItem *topOfDocShellTree = nsnull;
|
||||
docShellTreeItem->GetSameTypeRootTreeItem(&topOfDocShellTree);
|
||||
NS_ASSERTION(topOfDocShellTree, "No same type root tree item for doc shell");
|
||||
nsIDocShellTreeItem *docShellTreeItem = nsnull;
|
||||
CallQueryInterface(container, &docShellTreeItem);
|
||||
|
||||
return topOfDocShellTree;
|
||||
return docShellTreeItem;
|
||||
}
|
||||
|
||||
void nsAccessNode::PutCacheEntry(nsInterfaceHashtable<nsVoidHashKey, nsIAccessNode> &aCache,
|
||||
|
|
|
@ -119,7 +119,7 @@ class nsAccessNode: public nsIAccessNode, public nsPIAccessNode
|
|||
static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsISupports *aContainer);
|
||||
static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDOMNode *aNode);
|
||||
|
||||
static already_AddRefed<nsIDocShellTreeItem> GetSameTypeRootFor(nsIDOMNode *aStartNode);
|
||||
static already_AddRefed<nsIDocShellTreeItem> GetDocShellTreeItemFor(nsIDOMNode *aStartNode);
|
||||
static already_AddRefed<nsIPresShell> GetPresShellFor(nsIDOMNode *aStartNode);
|
||||
|
||||
static nsIDOMNode *gLastFocusedNode;
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
#include "nsRootAccessibleWrap.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsPIAccessNode.h"
|
||||
#include "nsIWebProgress.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULAlertAccessible.h"
|
||||
|
@ -116,7 +117,8 @@ nsAccessibilityService::nsAccessibilityService()
|
|||
nsCOMPtr<nsIWebProgress> progress(do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID));
|
||||
if (progress) {
|
||||
progress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*,this),
|
||||
nsIWebProgress::NOTIFY_STATE_DOCUMENT);
|
||||
nsIWebProgress::NOTIFY_STATE_DOCUMENT |
|
||||
nsIWebProgress::NOTIFY_LOCATION);
|
||||
}
|
||||
nsAccessNodeWrap::InitAccessibility();
|
||||
}
|
||||
|
@ -142,37 +144,75 @@ nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic,
|
|||
if (observerService) {
|
||||
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
}
|
||||
nsCOMPtr<nsIWebProgress> progress(do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID));
|
||||
if (progress) {
|
||||
progress->RemoveProgressListener(NS_STATIC_CAST(nsIWebProgressListener*,this));
|
||||
}
|
||||
nsAccessNodeWrap::ShutdownAccessibility();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIWebProgressListener
|
||||
|
||||
NS_IMETHODIMP nsAccessibilityService::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus)
|
||||
{
|
||||
const PRUint32 kRequiredFlags = STATE_IS_DOCUMENT | STATE_TRANSFERRING;
|
||||
if ((aStateFlags & kRequiredFlags ) != kRequiredFlags) {
|
||||
NS_ASSERTION(aStateFlags & STATE_IS_DOCUMENT, "Other notifications excluded");
|
||||
|
||||
// Not interested in START_STOP, because document object has not been created yet
|
||||
if (0 == (aStateFlags & (STATE_TRANSFERRING | STATE_STOP))) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
||||
// Bug 214049 OnStateChange can come from non UI threads.
|
||||
if (!domWindow)
|
||||
return NS_OK;
|
||||
NS_ASSERTION(domWindow, "DOM Window for state change is null");
|
||||
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
domWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDOMNode> domDocRootNode(do_QueryInterface(domDoc));
|
||||
NS_ENSURE_TRUE(domDocRootNode, NS_ERROR_FAILURE);
|
||||
|
||||
// Get the accessible for the new document
|
||||
// This will cache the doc's accessible and set up event listeners
|
||||
// so that toolkit and internal accessibility events will get fired
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
|
||||
nsAccessNode::GetDocShellTreeItemFor(domDocRootNode);
|
||||
NS_ASSERTION(docShellTreeItem, "No doc shell tree item for loading document");
|
||||
NS_ENSURE_TRUE(docShellTreeItem, NS_ERROR_FAILURE);
|
||||
PRInt32 contentType;
|
||||
docShellTreeItem->GetItemType(&contentType);
|
||||
if (contentType != nsIDocShellTreeItem::typeContent) {
|
||||
return NS_OK; // Not interested in chrome loading, just content
|
||||
}
|
||||
nsCOMPtr<nsIDocShellTreeItem> sameTypeRoot;
|
||||
docShellTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot));
|
||||
if (sameTypeRoot != docShellTreeItem) {
|
||||
return NS_OK; // Not interested in frames or iframes, just the root content
|
||||
}
|
||||
|
||||
if (nsAccessNode::gLastFocusedNode) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> focusedDocShellTreeItem =
|
||||
nsAccessNode::GetDocShellTreeItemFor(nsAccessNode::gLastFocusedNode);
|
||||
nsCOMPtr<nsIDocShellTreeItem> focusedRootTreeItem;
|
||||
focusedDocShellTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(focusedRootTreeItem));
|
||||
|
||||
if (focusedRootTreeItem != sameTypeRoot) {
|
||||
// Load is not occuring in the currently focused tab, so don't fire
|
||||
// doc load event there, otherwise assistive technology may become confused
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the accessible for the new document.
|
||||
// If it not created yet this will create it & cache it, as well as
|
||||
// set up event listeners so that MSAA/ATK toolkit and internal
|
||||
// accessibility events will get fired.
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
GetAccessibleFor(domDocRootNode, getter_AddRefs(accessible));
|
||||
nsCOMPtr<nsPIAccessibleDocument> docAccessible =
|
||||
do_QueryInterface(accessible);
|
||||
NS_ENSURE_TRUE(docAccessible, NS_ERROR_FAILURE);
|
||||
docAccessible->FireDocLoadingEvent(!(aStateFlags & STATE_TRANSFERRING));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -189,8 +229,29 @@ NS_IMETHODIMP nsAccessibilityService::OnProgressChange(nsIWebProgress *aWebProgr
|
|||
NS_IMETHODIMP nsAccessibilityService::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, nsIURI *location)
|
||||
{
|
||||
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
|
||||
// If the document is already loaded, this will just check to see
|
||||
// if an anchor jump event needs to be fired.
|
||||
// If there is no accessible for the document, we will ignore
|
||||
// this and the anchor jump event will be fired via OnStateChange
|
||||
// and STATE_STOP
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
||||
NS_ASSERTION(domWindow, "DOM Window for state change is null");
|
||||
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
domWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDOMNode> domDocRootNode(do_QueryInterface(domDoc));
|
||||
NS_ENSURE_TRUE(domDocRootNode, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessibleDocument> accessibleDoc =
|
||||
nsAccessNode::GetDocAccessibleFor(domDocRootNode);
|
||||
nsCOMPtr<nsPIAccessibleDocument> privateAccessibleDoc =
|
||||
do_QueryInterface(accessibleDoc);
|
||||
if (!privateAccessibleDoc) {
|
||||
return NS_OK;
|
||||
}
|
||||
return privateAccessibleDoc->FireAnchorJumpEvent();
|
||||
}
|
||||
|
||||
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
|
||||
|
@ -296,15 +357,19 @@ nsAccessibilityService::CreateRootAccessible(nsIPresShell *aShell,
|
|||
nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(aDocument));
|
||||
NS_ENSURE_TRUE(rootNode, NS_ERROR_FAILURE);
|
||||
|
||||
nsIDocument *parentDoc = aDocument->GetParentDocument();
|
||||
|
||||
nsIPresShell *presShell = aShell;
|
||||
if (!presShell) {
|
||||
presShell = aDocument->GetShellAt(0);
|
||||
}
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(presShell));
|
||||
|
||||
if (parentDoc) {
|
||||
nsCOMPtr<nsISupports> container = aDocument->GetContainer();
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
|
||||
do_QueryInterface(container);
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
||||
docShellTreeItem->GetParent(getter_AddRefs(parentTreeItem));
|
||||
|
||||
if (parentTreeItem) {
|
||||
// We only create root accessibles for the true root, othewise create a
|
||||
// doc accessible
|
||||
*aRootAcc = new nsDocAccessibleWrap(rootNode, weakShell);
|
||||
|
|
|
@ -80,9 +80,7 @@
|
|||
//-----------------------------------------------------
|
||||
nsDocAccessible::nsDocAccessible(nsIDOMNode *aDOMNode, nsIWeakReference* aShell):
|
||||
nsBlockAccessible(aDOMNode, aShell), mWnd(nsnull),
|
||||
mWebProgress(nsnull), mEditor(nsnull),
|
||||
mBusy(eBusyStateUninitialized),
|
||||
mScrollPositionChangedTicks(0), mIsNewDocument(PR_FALSE)
|
||||
mEditor(nsnull), mScrollPositionChangedTicks(0)
|
||||
{
|
||||
// Because of the way document loading happens, the new nsIWidget is created before
|
||||
// the old one is removed. Since it creates the nsDocAccessible, for a brief moment
|
||||
|
@ -118,7 +116,6 @@ nsDocAccessible::~nsDocAccessible()
|
|||
NS_INTERFACE_MAP_BEGIN(nsDocAccessible)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsPIAccessibleDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMutationListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScrollPositionListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
|
@ -147,10 +144,22 @@ NS_IMETHODIMP nsDocAccessible::GetValue(nsAString& aValue)
|
|||
|
||||
NS_IMETHODIMP nsDocAccessible::GetState(PRUint32 *aState)
|
||||
{
|
||||
if (!mDOMNode) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsAccessible::GetState(aState);
|
||||
*aState |= STATE_FOCUSABLE;
|
||||
if (mBusy == eBusyStateLoading)
|
||||
*aState |= STATE_BUSY; // If busy, not sure if visible yet or not
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
|
||||
GetDocShellTreeItemFor(mDOMNode);
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(docShellTreeItem));
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 busyFlags;
|
||||
docShell->GetBusyFlags(&busyFlags);
|
||||
if (busyFlags != nsIDocShell::BUSY_FLAGS_NONE) {
|
||||
*aState |= STATE_BUSY;
|
||||
}
|
||||
|
||||
// Is it visible?
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mWeakShell));
|
||||
|
@ -409,22 +418,12 @@ NS_IMETHODIMP nsDocAccessible::Shutdown()
|
|||
|
||||
mEditor = nsnull;
|
||||
|
||||
if (mScrollWatchTimer) {
|
||||
mScrollWatchTimer->Cancel();
|
||||
mScrollWatchTimer = nsnull;
|
||||
}
|
||||
if (mDocLoadTimer) {
|
||||
mDocLoadTimer->Cancel();
|
||||
mDocLoadTimer = nsnull;
|
||||
}
|
||||
if (mFireEventTimer) {
|
||||
mFireEventTimer->Cancel();
|
||||
mFireEventTimer = nsnull;
|
||||
}
|
||||
mEventsToFire.Clear();
|
||||
|
||||
mWebProgress = nsnull;
|
||||
|
||||
ClearCache(mAccessNodeCache);
|
||||
|
||||
mDocument = nsnull;
|
||||
|
@ -519,23 +518,6 @@ nsresult nsDocAccessible::AddEventListeners()
|
|||
commandManager->AddCommandObserver(this, "obs_documentCreated");
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we're the top content doc shell
|
||||
// We don't want to listen to iframe progress
|
||||
nsCOMPtr<nsIDocShellTreeItem> topOfContentTree;
|
||||
docShellTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(topOfContentTree));
|
||||
if (topOfContentTree != docShellTreeItem) {
|
||||
mBusy = eBusyStateDone;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mWebProgress = do_GetInterface(docShellTreeItem);
|
||||
NS_ENSURE_TRUE(mWebProgress, NS_ERROR_FAILURE);
|
||||
|
||||
mWebProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT |
|
||||
nsIWebProgress::NOTIFY_LOCATION);
|
||||
mIsNewDocument = PR_TRUE;
|
||||
mBusy = eBusyStateLoading;
|
||||
}
|
||||
|
||||
// add ourself as a mutation event listener
|
||||
|
@ -568,13 +550,6 @@ nsresult nsDocAccessible::AddEventListeners()
|
|||
nsresult nsDocAccessible::RemoveEventListeners()
|
||||
{
|
||||
// Remove listeners associated with content documents
|
||||
|
||||
// Remove web progress listener
|
||||
if (mWebProgress) {
|
||||
mWebProgress->RemoveProgressListener(this);
|
||||
mWebProgress = nsnull;
|
||||
}
|
||||
|
||||
// Remove scroll position listener
|
||||
RemoveScrollListener();
|
||||
|
||||
|
@ -592,11 +567,6 @@ nsresult nsDocAccessible::RemoveEventListeners()
|
|||
mScrollWatchTimer = nsnull;
|
||||
}
|
||||
|
||||
if (mDocLoadTimer) {
|
||||
mDocLoadTimer->Cancel();
|
||||
mDocLoadTimer = nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> container = mDocument->GetContainer();
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem(do_QueryInterface(container));
|
||||
NS_ENSURE_TRUE(docShellTreeItem, NS_ERROR_FAILURE);
|
||||
|
@ -613,21 +583,23 @@ nsresult nsDocAccessible::RemoveEventListeners()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDocAccessible::FireDocLoadFinished()
|
||||
NS_IMETHODIMP nsDocAccessible::FireAnchorJumpEvent()
|
||||
{
|
||||
if (!mDocument || !mWeakShell)
|
||||
return; // Document has been shut down
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint32 state;
|
||||
GetState(&state);
|
||||
if ((state & STATE_INVISIBLE) == 0) {
|
||||
// Don't consider load finished until window unhidden
|
||||
mIsNewDocument = PR_FALSE;
|
||||
if (mBusy != eBusyStateDone) {
|
||||
NS_IMETHODIMP nsDocAccessible::FireDocLoadingEvent(PRBool aIsFinished)
|
||||
{
|
||||
if (!mDocument || !mWeakShell) {
|
||||
return NS_OK; // Document has been shut down
|
||||
}
|
||||
|
||||
if (aIsFinished) {
|
||||
// Need to wait until scrollable view is available
|
||||
AddScrollListener();
|
||||
}
|
||||
mBusy = eBusyStateDone;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDocAccessible::ScrollTimerCallback(nsITimer *aTimer, void *aClosure)
|
||||
|
@ -706,104 +678,6 @@ NS_IMETHODIMP nsDocAccessible::ScrollPositionDidChange(nsIScrollableView *aScrol
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessible::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
if (!(aStateFlags & (STATE_START | STATE_STOP))) {
|
||||
return NS_OK; // We don't care about STATE_TRANSFERRING
|
||||
}
|
||||
NS_ASSERTION(aStateFlags & STATE_IS_DOCUMENT, "Should not be listening to other OnStateChange types (should be document)");
|
||||
if (!mWeakShell || !mDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMWindow> domWin;
|
||||
aWebProgress->GetDOMWindow(getter_AddRefs(domWin));
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
domWin->GetDocument(getter_AddRefs(domDoc));
|
||||
if (!SameCOMIdentity(mDocument, domDoc)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aStateFlags & STATE_STOP) {
|
||||
FireDocLoadFinished();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// STATE_START
|
||||
if (!mIsNewDocument) {
|
||||
return NS_OK; // Already fired for this document
|
||||
}
|
||||
|
||||
if (gLastFocusedNode) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> topOfLoadingContentTree =
|
||||
GetSameTypeRootFor(mDOMNode);
|
||||
nsCOMPtr<nsIDocShellTreeItem> topOfFocusedContentTree =
|
||||
GetSameTypeRootFor(gLastFocusedNode);
|
||||
|
||||
if (topOfLoadingContentTree != topOfFocusedContentTree) {
|
||||
// Load is not occuring in the currently focused tab, so don't fire
|
||||
// doc load event there, otherwise assistive technology may become confused
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Load has been verified, it will occur, about to commence
|
||||
|
||||
// We won't fire a "doc finished loading" event on this nsDocAccessible
|
||||
// Instead we fire that on the new nsDocAccessible that is created for the new doc
|
||||
mIsNewDocument = PR_FALSE; // We're a doc that's going away
|
||||
|
||||
if (mBusy != eBusyStateLoading) {
|
||||
mBusy = eBusyStateLoading;
|
||||
// Fire a "new doc has started to load" event if at top of content tree
|
||||
#ifndef MOZ_ACCESSIBILITY_ATK
|
||||
FireToolkitEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, this, nsnull);
|
||||
#else
|
||||
AtkChildrenChange childrenData;
|
||||
childrenData.index = -1;
|
||||
childrenData.child = 0;
|
||||
childrenData.add = PR_FALSE;
|
||||
FireToolkitEvent(nsIAccessibleEvent::EVENT_REORDER , this, &childrenData);
|
||||
#endif
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
|
||||
NS_IMETHODIMP nsDocAccessible::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */
|
||||
NS_IMETHODIMP nsDocAccessible::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, nsIURI *location)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
|
||||
NS_IMETHODIMP nsDocAccessible::OnStatusChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
|
||||
{
|
||||
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
|
||||
NS_IMETHODIMP nsDocAccessible::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, PRUint32 state)
|
||||
{
|
||||
NS_NOTREACHED("notification excluded in AddProgressListener(...)");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessible::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
|
@ -891,7 +765,8 @@ NS_IMETHODIMP nsDocAccessible::AttrModified(nsIDOMEvent* aMutationEvent)
|
|||
eventType = nsIAccessibleEvent::EVENT_STATE_CHANGE;
|
||||
}
|
||||
else if (attrName.EqualsLiteral("readonly") ||
|
||||
attrName.EqualsLiteral("disabled") || attrName.EqualsLiteral("required") ||
|
||||
attrName.EqualsLiteral("disabled") ||
|
||||
attrName.EqualsLiteral("required") ||
|
||||
attrName.EqualsLiteral("invalid")) {
|
||||
eventType = nsIAccessibleEvent::EVENT_STATE_CHANGE;
|
||||
}
|
||||
|
@ -1086,11 +961,6 @@ nsDocAccessible::GetAccessibleInParentChain(nsIDOMNode *aNode,
|
|||
|
||||
void nsDocAccessible::HandleMutationEvent(nsIDOMEvent *aEvent, PRUint32 aAccessibleEventType)
|
||||
{
|
||||
if (mBusy == eBusyStateLoading) {
|
||||
// We need this unless bug 90983 is fixed --
|
||||
// We only want mutation events after the doc is finished loading
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIDOMMutationEvent> mutationEvent(do_QueryInterface(aEvent));
|
||||
NS_ASSERTION(mutationEvent, "Not a mutation event!");
|
||||
|
||||
|
|
|
@ -51,8 +51,6 @@
|
|||
#include "nsIScrollPositionListener.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
|
||||
class nsIScrollableView;
|
||||
|
||||
|
@ -61,7 +59,6 @@ const PRUint32 kDefaultCacheSize = 256;
|
|||
class nsDocAccessible : public nsBlockAccessible,
|
||||
public nsIAccessibleDocument,
|
||||
public nsPIAccessibleDocument,
|
||||
public nsIWebProgressListener,
|
||||
public nsIObserver,
|
||||
public nsIDOMMutationListener,
|
||||
public nsIScrollPositionListener,
|
||||
|
@ -96,8 +93,6 @@ class nsDocAccessible : public nsBlockAccessible,
|
|||
NS_IMETHOD AttrModified(nsIDOMEvent* aMutationEvent);
|
||||
NS_IMETHOD CharacterDataModified(nsIDOMEvent* aMutationEvent);
|
||||
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible, void* aData);
|
||||
static void FlushEventsCallback(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
|
@ -109,14 +104,11 @@ class nsDocAccessible : public nsBlockAccessible,
|
|||
NS_IMETHOD_(nsIFrame *) GetFrame(void);
|
||||
|
||||
protected:
|
||||
enum EBusyState {eBusyStateUninitialized, eBusyStateLoading, eBusyStateDone};
|
||||
|
||||
virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual nsresult AddEventListeners();
|
||||
virtual nsresult RemoveEventListeners();
|
||||
void AddScrollListener();
|
||||
void RemoveScrollListener();
|
||||
virtual void FireDocLoadFinished();
|
||||
void HandleMutationEvent(nsIDOMEvent *aEvent, PRUint32 aEventType);
|
||||
static void ScrollTimerCallback(nsITimer *aTimer, void *aClosure);
|
||||
virtual void CheckForEditor();
|
||||
|
@ -125,11 +117,8 @@ class nsDocAccessible : public nsBlockAccessible,
|
|||
void *mWnd;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsITimer> mScrollWatchTimer;
|
||||
nsCOMPtr<nsITimer> mDocLoadTimer;
|
||||
nsCOMPtr<nsITimer> mFireEventTimer;
|
||||
nsCOMPtr<nsIWebProgress> mWebProgress;
|
||||
nsCOMPtr<nsIEditor> mEditor; // Editor, if there is one
|
||||
EBusyState mBusy;
|
||||
PRUint16 mScrollPositionChangedTicks; // Used for tracking scroll events
|
||||
PRPackedBool mIsNewDocument;
|
||||
nsCOMArray<nsIAccessibleEvent> mEventsToFire;
|
||||
|
|
|
@ -163,6 +163,15 @@ STDMETHODIMP nsDocAccessibleWrap::get_accChild(
|
|||
return nsAccessibleWrap::get_accChild(varChild, ppdispChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleWrap::Shutdown()
|
||||
{
|
||||
if (mDocLoadTimer) {
|
||||
mDocLoadTimer->Cancel();
|
||||
mDocLoadTimer = nsnull;
|
||||
}
|
||||
return nsDocAccessible::Shutdown();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleWrap::FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible, void* aData)
|
||||
{
|
||||
if (!mWeakShell) { // Means we're not active
|
||||
|
@ -268,7 +277,7 @@ nsDocAccessibleWrap::GetFirstLeafAccessible(nsIDOMNode *aStartNode)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
void nsDocAccessibleWrap::FireAnchorJumpEvent()
|
||||
NS_IMETHODIMP nsDocAccessibleWrap::FireAnchorJumpEvent()
|
||||
{
|
||||
// Staying on the same page, jumping to a named anchor
|
||||
// Fire EVENT_SELECTION_WITHIN on first leaf accessible -- because some
|
||||
|
@ -276,6 +285,11 @@ void nsDocAccessibleWrap::FireAnchorJumpEvent()
|
|||
// the can only relate events back to their internal model if it's a leaf.
|
||||
// There is usually an accessible for the focus node, but if it's an empty text node
|
||||
// we have to move forward in the document to get one
|
||||
PRUint32 state;
|
||||
GetState(&state);
|
||||
if (state & STATE_BUSY) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsISupports> container = mDocument->GetContainer();
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(container));
|
||||
nsCAutoString theURL;
|
||||
|
@ -296,7 +310,7 @@ void nsDocAccessibleWrap::FireAnchorJumpEvent()
|
|||
// This way we still know to fire the SELECTION_WITHIN event when we
|
||||
// move from a named anchor back to the top.
|
||||
if (!mWasAnchor && !hasAnchor) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
mWasAnchor = hasAnchor;
|
||||
|
||||
|
@ -304,12 +318,12 @@ void nsDocAccessibleWrap::FireAnchorJumpEvent()
|
|||
if (hasAnchor) {
|
||||
nsCOMPtr<nsISelectionController> selCon(do_QueryReferent(mWeakShell));
|
||||
if (!selCon) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsISelection> domSel;
|
||||
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel));
|
||||
if (!domSel) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
domSel->GetFocusNode(getter_AddRefs(focusNode));
|
||||
}
|
||||
|
@ -323,42 +337,46 @@ void nsDocAccessibleWrap::FireAnchorJumpEvent()
|
|||
privateAccessible->FireToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
|
||||
accessible, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDocAccessibleWrap::FireDocLoadFinished()
|
||||
void nsDocAccessibleWrap::DocLoadCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
// Doc has finished loading, fire "load finished" event
|
||||
// By using short timer we can wait for MS Windows to make the window visible,
|
||||
// which it does asynchronously. This avoids confusing the screen reader with a
|
||||
// hidden window.
|
||||
|
||||
nsDocAccessibleWrap *docAcc =
|
||||
NS_REINTERPRET_CAST(nsDocAccessibleWrap*, aClosure);
|
||||
if (docAcc) {
|
||||
docAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE,
|
||||
docAcc, nsnull);
|
||||
docAcc->FireAnchorJumpEvent();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleWrap::FireDocLoadingEvent(PRBool aIsFinished)
|
||||
{
|
||||
if (!mDocument || !mWeakShell)
|
||||
return; // Document has been shut down
|
||||
return NS_OK; // Document has been shut down
|
||||
|
||||
PRUint32 state;
|
||||
GetState(&state);
|
||||
if ((state & STATE_INVISIBLE) != 0) {
|
||||
return; // Don't consider load finished until window unhidden
|
||||
if (aIsFinished) {
|
||||
// Use short timer before firing state change event for finished doc,
|
||||
// because the window is made visible asynchronously by Microsoft Windows
|
||||
if (!mDocLoadTimer) {
|
||||
mDocLoadTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
}
|
||||
if (mDocLoadTimer) {
|
||||
mDocLoadTimer->InitWithFuncCallback(DocLoadCallback, this, 0,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
FireToolkitEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE, this, nsnull);
|
||||
}
|
||||
|
||||
// Cache decision before nsDocAccessible::FireDocLoadFinished
|
||||
// changes mIsNewDocument and mBusy
|
||||
PRBool fireStateChange = mIsNewDocument && mBusy != eBusyStateDone;
|
||||
|
||||
nsDocAccessible::FireDocLoadFinished();
|
||||
|
||||
if (fireStateChange) {
|
||||
FireToolkitEvent(nsIAccessibleEvent::EVENT_STATE_CHANGE,
|
||||
this, nsnull);
|
||||
}
|
||||
FireAnchorJumpEvent();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleWrap::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsIURI *location)
|
||||
{
|
||||
if (!mWeakShell || !mDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
FireAnchorJumpEvent();
|
||||
return NS_OK;
|
||||
return nsDocAccessible::FireDocLoadingEvent(aIsFinished);
|
||||
}
|
||||
|
||||
STDMETHODIMP nsDocAccessibleWrap::get_URL(/* [out] */ BSTR __RPC_FAR *aURL)
|
||||
|
|
|
@ -89,14 +89,15 @@ public:
|
|||
/* [in] */ VARIANT varChild,
|
||||
/* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispChild);
|
||||
|
||||
NS_IMETHOD Shutdown();
|
||||
NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible, void* aData);
|
||||
NS_IMETHOD OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest, nsIURI *location);
|
||||
protected:
|
||||
void FireDocLoadFinished();
|
||||
NS_IMETHOD FireDocLoadingEvent(PRBool isFinished);
|
||||
NS_IMETHOD FireAnchorJumpEvent();
|
||||
|
||||
private:
|
||||
void FireAnchorJumpEvent();
|
||||
static void DocLoadCallback(nsITimer *aTimer, void *aClosure);
|
||||
already_AddRefed<nsIAccessible> GetFirstLeafAccessible(nsIDOMNode *aStartNode);
|
||||
nsCOMPtr<nsITimer> mDocLoadTimer;
|
||||
PRPackedBool mWasAnchor;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче