2011-01-18 00:03:38 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2011-01-18 00:03:38 -08:00
|
|
|
|
2011-01-31 07:53:09 -08:00
|
|
|
#include "NotificationController.h"
|
2011-01-18 00:03:38 -08:00
|
|
|
|
2012-12-26 20:25:27 -08:00
|
|
|
#include "DocAccessible-inl.h"
|
2014-03-07 13:35:19 -08:00
|
|
|
#include "DocAccessibleChild.h"
|
2012-05-23 11:05:57 -07:00
|
|
|
#include "TextLeafAccessible.h"
|
2011-02-07 20:48:41 -08:00
|
|
|
#include "TextUpdater.h"
|
2011-09-27 18:46:11 -07:00
|
|
|
|
2015-05-21 10:04:58 -07:00
|
|
|
#include "mozilla/dom/TabChild.h"
|
2011-07-20 12:18:54 -07:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-07-20 13:23:38 -07:00
|
|
|
#include "mozilla/Telemetry.h"
|
2011-01-18 00:03:38 -08:00
|
|
|
|
2012-07-20 13:23:38 -07:00
|
|
|
using namespace mozilla;
|
2011-09-27 18:46:11 -07:00
|
|
|
using namespace mozilla::a11y;
|
2011-01-18 00:03:38 -08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-27 02:01:40 -07:00
|
|
|
NotificationController::NotificationController(DocAccessible* aDocument,
|
2011-01-18 00:03:38 -08:00
|
|
|
nsIPresShell* aPresShell) :
|
2013-01-29 02:00:58 -08:00
|
|
|
EventQueue(aDocument), mObservingState(eNotObservingRefresh),
|
2011-08-08 00:55:36 -07:00
|
|
|
mPresShell(aPresShell)
|
2011-01-18 00:03:38 -08:00
|
|
|
{
|
2011-01-23 18:58:00 -08:00
|
|
|
// Schedule initial accessible tree construction.
|
|
|
|
ScheduleProcessing();
|
2011-01-18 00:03:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NotificationController::~NotificationController()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mDocument, "Controller wasn't shutdown properly!");
|
|
|
|
if (mDocument)
|
|
|
|
Shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector: AddRef/Release and cycle collection
|
|
|
|
|
2012-08-24 09:50:06 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(NotificationController)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE(NotificationController)
|
2011-01-18 00:03:38 -08:00
|
|
|
|
2013-08-01 18:29:05 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(NotificationController)
|
|
|
|
|
2012-11-22 09:15:38 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(NotificationController)
|
2011-02-01 08:08:28 -08:00
|
|
|
if (tmp->mDocument)
|
|
|
|
tmp->Shutdown();
|
2011-01-18 00:03:38 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2012-11-22 09:15:38 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NotificationController)
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mHangingChildDocuments)
|
2016-02-18 06:31:42 -08:00
|
|
|
for (auto it = tmp->mContentInsertions.ConstIter(); !it.Done(); it.Next()) {
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mContentInsertions key");
|
|
|
|
cb.NoteXPCOMChild(it.Key());
|
|
|
|
nsTArray<nsCOMPtr<nsIContent>>* list = it.UserData();
|
|
|
|
for (uint32_t i = 0; i < list->Length(); i++) {
|
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
|
|
|
|
"mContentInsertions value item");
|
|
|
|
cb.NoteXPCOMChild(list->ElementAt(i));
|
|
|
|
}
|
|
|
|
}
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEvents)
|
2015-10-29 15:08:48 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelocations)
|
2011-01-18 00:03:38 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(NotificationController, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(NotificationController, Release)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector: public
|
|
|
|
|
|
|
|
void
|
|
|
|
NotificationController::Shutdown()
|
|
|
|
{
|
|
|
|
if (mObservingState != eNotObservingRefresh &&
|
|
|
|
mPresShell->RemoveRefreshObserver(this, Flush_Display)) {
|
|
|
|
mObservingState = eNotObservingRefresh;
|
|
|
|
}
|
|
|
|
|
2011-01-25 22:35:51 -08:00
|
|
|
// Shutdown handling child documents.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t childDocCount = mHangingChildDocuments.Length();
|
|
|
|
for (int32_t idx = childDocCount - 1; idx >= 0; idx--) {
|
2012-03-14 13:37:50 -07:00
|
|
|
if (!mHangingChildDocuments[idx]->IsDefunct())
|
|
|
|
mHangingChildDocuments[idx]->Shutdown();
|
|
|
|
}
|
2011-01-25 22:35:51 -08:00
|
|
|
|
|
|
|
mHangingChildDocuments.Clear();
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
mDocument = nullptr;
|
|
|
|
mPresShell = nullptr;
|
2011-01-25 22:35:51 -08:00
|
|
|
|
2011-01-28 00:42:22 -08:00
|
|
|
mTextHash.Clear();
|
2011-01-18 00:03:38 -08:00
|
|
|
mContentInsertions.Clear();
|
|
|
|
mNotifications.Clear();
|
|
|
|
mEvents.Clear();
|
2015-10-29 15:08:48 -07:00
|
|
|
mRelocations.Clear();
|
2011-01-18 00:03:38 -08:00
|
|
|
}
|
|
|
|
|
2011-01-25 22:35:51 -08:00
|
|
|
void
|
2012-05-27 02:01:40 -07:00
|
|
|
NotificationController::ScheduleChildDocBinding(DocAccessible* aDocument)
|
2011-01-25 22:35:51 -08:00
|
|
|
{
|
|
|
|
// Schedule child document binding to the tree.
|
|
|
|
mHangingChildDocuments.AppendElement(aDocument);
|
|
|
|
ScheduleProcessing();
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
void
|
2012-05-28 18:18:45 -07:00
|
|
|
NotificationController::ScheduleContentInsertion(Accessible* aContainer,
|
2011-01-18 00:03:38 -08:00
|
|
|
nsIContent* aStartChildNode,
|
|
|
|
nsIContent* aEndChildNode)
|
|
|
|
{
|
2016-02-18 06:31:42 -08:00
|
|
|
nsTArray<nsCOMPtr<nsIContent>>* list =
|
|
|
|
mContentInsertions.LookupOrAdd(aContainer);
|
|
|
|
|
|
|
|
bool needsProcessing = false;
|
|
|
|
nsIContent* node = aStartChildNode;
|
|
|
|
while (node != aEndChildNode) {
|
|
|
|
// Notification triggers for content insertion even if no content was
|
|
|
|
// actually inserted, check if the given content has a frame to discard
|
|
|
|
// this case early.
|
|
|
|
if (node->GetPrimaryFrame()) {
|
|
|
|
if (list->AppendElement(node))
|
|
|
|
needsProcessing = true;
|
|
|
|
}
|
|
|
|
node = node->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needsProcessing) {
|
2011-01-18 00:03:38 -08:00
|
|
|
ScheduleProcessing();
|
2011-04-06 22:17:29 -07:00
|
|
|
}
|
2011-01-18 00:03:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NotificationController::ScheduleProcessing()
|
|
|
|
{
|
|
|
|
// If notification flush isn't planed yet start notification flush
|
|
|
|
// asynchronously (after style and layout).
|
|
|
|
if (mObservingState == eNotObservingRefresh) {
|
|
|
|
if (mPresShell->AddRefreshObserver(this, Flush_Display))
|
|
|
|
mObservingState = eRefreshObserving;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-15 09:01:51 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector: protected
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
bool
|
|
|
|
NotificationController::IsUpdatePending()
|
|
|
|
{
|
2011-03-31 14:33:46 -07:00
|
|
|
return mPresShell->IsLayoutFlushObserver() ||
|
2011-01-18 00:03:38 -08:00
|
|
|
mObservingState == eRefreshProcessingForUpdate ||
|
2016-02-18 06:31:42 -08:00
|
|
|
mContentInsertions.Count() != 0 || mNotifications.Length() != 0 ||
|
2011-09-27 18:46:11 -07:00
|
|
|
mTextHash.Count() != 0 ||
|
2012-05-27 02:01:40 -07:00
|
|
|
!mDocument->HasLoadState(DocAccessible::eTreeConstructed);
|
2011-01-18 00:03:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector: private
|
|
|
|
|
|
|
|
void
|
|
|
|
NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|
|
|
{
|
2016-01-14 14:03:11 -08:00
|
|
|
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
2012-07-27 21:21:44 -07:00
|
|
|
Telemetry::AutoTimer<Telemetry::A11Y_UPDATE_TIME> updateTimer;
|
2012-07-20 13:23:38 -07:00
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
// If the document accessible that notification collector was created for is
|
|
|
|
// now shut down, don't process notifications anymore.
|
|
|
|
NS_ASSERTION(mDocument,
|
|
|
|
"The document was shut down while refresh observer is attached!");
|
|
|
|
if (!mDocument)
|
|
|
|
return;
|
|
|
|
|
2013-05-24 11:24:19 -07:00
|
|
|
if (mObservingState == eRefreshProcessing ||
|
|
|
|
mObservingState == eRefreshProcessingForUpdate)
|
|
|
|
return;
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
// Any generic notifications should be queued if we're processing content
|
|
|
|
// insertions or generic notifications.
|
|
|
|
mObservingState = eRefreshProcessingForUpdate;
|
|
|
|
|
2011-01-23 18:58:00 -08:00
|
|
|
// Initial accessible tree construction.
|
2012-05-27 02:01:40 -07:00
|
|
|
if (!mDocument->HasLoadState(DocAccessible::eTreeConstructed)) {
|
2011-01-25 22:35:51 -08:00
|
|
|
// If document is not bound to parent at this point then the document is not
|
|
|
|
// ready yet (process notifications later).
|
2011-10-13 19:33:41 -07:00
|
|
|
if (!mDocument->IsBoundToParent()) {
|
|
|
|
mObservingState = eRefreshObserving;
|
2011-01-25 22:35:51 -08:00
|
|
|
return;
|
2011-10-13 19:33:41 -07:00
|
|
|
}
|
2011-01-25 22:35:51 -08:00
|
|
|
|
2012-10-04 02:57:09 -07:00
|
|
|
#ifdef A11Y_LOG
|
2012-05-31 21:27:25 -07:00
|
|
|
if (logging::IsEnabled(logging::eTree)) {
|
|
|
|
logging::MsgBegin("TREE", "initial tree created");
|
|
|
|
logging::Address("document", mDocument);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
2011-01-28 00:42:22 -08:00
|
|
|
#endif
|
|
|
|
|
2011-08-08 00:55:36 -07:00
|
|
|
mDocument->DoInitialUpdate();
|
2011-03-02 22:41:46 -08:00
|
|
|
|
2016-02-18 06:31:42 -08:00
|
|
|
NS_ASSERTION(mContentInsertions.Count() == 0,
|
2011-01-23 18:58:00 -08:00
|
|
|
"Pending content insertions while initial accessible tree isn't created!");
|
|
|
|
}
|
|
|
|
|
2012-12-26 20:25:27 -08:00
|
|
|
// Initialize scroll support if needed.
|
|
|
|
if (!(mDocument->mDocFlags & DocAccessible::eScrollInitialized))
|
|
|
|
mDocument->AddScrollListener();
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
// Process content inserted notifications to update the tree. Process other
|
|
|
|
// notifications like DOM events and then flush event queue. If any new
|
|
|
|
// notifications are queued during this processing then they will be processed
|
|
|
|
// on next refresh. If notification processing queues up new events then they
|
|
|
|
// are processed in this refresh. If events processing queues up new events
|
|
|
|
// then new events are processed on next refresh.
|
|
|
|
// Note: notification processing or event handling may shut down the owning
|
|
|
|
// document accessible.
|
|
|
|
|
|
|
|
// Process only currently queued content inserted notifications.
|
2016-02-18 06:31:42 -08:00
|
|
|
for (auto iter = mContentInsertions.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
mDocument->ProcessContentInserted(iter.Key(), iter.UserData());
|
|
|
|
if (!mDocument) {
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2016-02-18 06:31:42 -08:00
|
|
|
}
|
2011-01-18 00:03:38 -08:00
|
|
|
}
|
2016-02-18 06:31:42 -08:00
|
|
|
mContentInsertions.Clear();
|
2011-01-18 00:03:38 -08:00
|
|
|
|
2011-01-28 00:42:22 -08:00
|
|
|
// Process rendered text change notifications.
|
2015-07-22 20:49:25 -07:00
|
|
|
for (auto iter = mTextHash.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
nsCOMPtrHashKey<nsIContent>* entry = iter.Get();
|
|
|
|
nsIContent* textNode = entry->GetKey();
|
|
|
|
Accessible* textAcc = mDocument->GetAccessible(textNode);
|
|
|
|
|
|
|
|
// If the text node is not in tree or doesn't have frame then this case should
|
|
|
|
// have been handled already by content removal notifications.
|
|
|
|
nsINode* containerNode = textNode->GetParentNode();
|
|
|
|
if (!containerNode) {
|
|
|
|
NS_ASSERTION(!textAcc,
|
|
|
|
"Text node was removed but accessible is kept alive!");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* textFrame = textNode->GetPrimaryFrame();
|
|
|
|
if (!textFrame) {
|
|
|
|
NS_ASSERTION(!textAcc,
|
|
|
|
"Text node isn't rendered but accessible is kept alive!");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent* containerElm = containerNode->IsElement() ?
|
|
|
|
containerNode->AsElement() : nullptr;
|
|
|
|
|
2015-11-30 05:21:25 -08:00
|
|
|
nsIFrame::RenderedText text = textFrame->GetRenderedText(0,
|
|
|
|
UINT32_MAX, nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
|
|
|
|
nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE);
|
2015-07-22 20:49:25 -07:00
|
|
|
|
|
|
|
// Remove text accessible if rendered text is empty.
|
|
|
|
if (textAcc) {
|
2015-10-29 23:23:10 -07:00
|
|
|
if (text.mString.IsEmpty()) {
|
2015-07-22 20:49:25 -07:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eTree | logging::eText)) {
|
|
|
|
logging::MsgBegin("TREE", "text node lost its content");
|
|
|
|
logging::Node("container", containerElm);
|
|
|
|
logging::Node("content", textNode);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mDocument->ContentRemoved(containerElm, textNode);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update text of the accessible and fire text change events.
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eText)) {
|
|
|
|
logging::MsgBegin("TEXT", "text may be changed");
|
|
|
|
logging::Node("container", containerElm);
|
|
|
|
logging::Node("content", textNode);
|
|
|
|
logging::MsgEntry("old text '%s'",
|
|
|
|
NS_ConvertUTF16toUTF8(textAcc->AsTextLeaf()->Text()).get());
|
|
|
|
logging::MsgEntry("new text: '%s'",
|
2015-10-29 23:23:10 -07:00
|
|
|
NS_ConvertUTF16toUTF8(text.mString).get());
|
2015-07-22 20:49:25 -07:00
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-29 23:23:10 -07:00
|
|
|
TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text.mString);
|
2015-07-22 20:49:25 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append an accessible if rendered text is not empty.
|
2015-10-29 23:23:10 -07:00
|
|
|
if (!text.mString.IsEmpty()) {
|
2015-07-22 20:49:25 -07:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eTree | logging::eText)) {
|
|
|
|
logging::MsgBegin("TREE", "text node gains new content");
|
|
|
|
logging::Node("container", containerElm);
|
|
|
|
logging::Node("content", textNode);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Make sure the text node is in accessible document still.
|
|
|
|
Accessible* container = mDocument->GetAccessibleOrContainer(containerNode);
|
|
|
|
NS_ASSERTION(container,
|
|
|
|
"Text node having rendered text hasn't accessible document!");
|
|
|
|
if (container) {
|
|
|
|
nsTArray<nsCOMPtr<nsIContent> > insertedContents;
|
|
|
|
insertedContents.AppendElement(textNode);
|
|
|
|
mDocument->ProcessContentInserted(container, &insertedContents);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-28 00:42:22 -08:00
|
|
|
mTextHash.Clear();
|
|
|
|
|
2011-01-25 22:35:51 -08:00
|
|
|
// Bind hanging child documents.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t hangingDocCnt = mHangingChildDocuments.Length();
|
2015-10-17 22:24:48 -07:00
|
|
|
nsTArray<RefPtr<DocAccessible>> newChildDocs;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t idx = 0; idx < hangingDocCnt; idx++) {
|
2012-05-27 02:01:40 -07:00
|
|
|
DocAccessible* childDoc = mHangingChildDocuments[idx];
|
2012-03-14 13:37:50 -07:00
|
|
|
if (childDoc->IsDefunct())
|
|
|
|
continue;
|
2011-01-25 22:35:51 -08:00
|
|
|
|
2012-10-11 19:25:34 -07:00
|
|
|
nsIContent* ownerContent = mDocument->DocumentNode()->
|
|
|
|
FindContentForSubDocument(childDoc->DocumentNode());
|
2011-01-25 22:35:51 -08:00
|
|
|
if (ownerContent) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* outerDocAcc = mDocument->GetAccessible(ownerContent);
|
2011-01-25 22:35:51 -08:00
|
|
|
if (outerDocAcc && outerDocAcc->AppendChild(childDoc)) {
|
2014-03-07 13:35:19 -08:00
|
|
|
if (mDocument->AppendChildDocument(childDoc)) {
|
2015-01-07 12:16:37 -08:00
|
|
|
newChildDocs.AppendElement(Move(mHangingChildDocuments[idx]));
|
2011-01-25 22:35:51 -08:00
|
|
|
continue;
|
2014-03-07 13:35:19 -08:00
|
|
|
}
|
2011-07-19 01:30:32 -07:00
|
|
|
|
2011-01-25 22:35:51 -08:00
|
|
|
outerDocAcc->RemoveChild(childDoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Failed to bind the child document, destroy it.
|
|
|
|
childDoc->Shutdown();
|
|
|
|
}
|
|
|
|
}
|
2014-10-28 11:18:03 -07:00
|
|
|
|
2015-01-07 12:16:37 -08:00
|
|
|
mHangingChildDocuments.Clear();
|
2011-01-25 22:35:51 -08:00
|
|
|
|
2011-08-08 00:55:36 -07:00
|
|
|
// If the document is ready and all its subdocuments are completely loaded
|
|
|
|
// then process the document load.
|
2012-05-27 02:01:40 -07:00
|
|
|
if (mDocument->HasLoadState(DocAccessible::eReady) &&
|
|
|
|
!mDocument->HasLoadState(DocAccessible::eCompletelyLoaded) &&
|
2011-08-08 00:55:36 -07:00
|
|
|
hangingDocCnt == 0) {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childDocCnt = mDocument->ChildDocumentCount(), childDocIdx = 0;
|
2011-08-08 00:55:36 -07:00
|
|
|
for (; childDocIdx < childDocCnt; childDocIdx++) {
|
2012-05-27 02:01:40 -07:00
|
|
|
DocAccessible* childDoc = mDocument->GetChildDocumentAt(childDocIdx);
|
|
|
|
if (!childDoc->HasLoadState(DocAccessible::eCompletelyLoaded))
|
2011-08-08 00:55:36 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (childDocIdx == childDocCnt) {
|
|
|
|
mDocument->ProcessLoad();
|
|
|
|
if (!mDocument)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
// Process only currently queued generic notifications.
|
2015-10-17 22:24:48 -07:00
|
|
|
nsTArray < RefPtr<Notification> > notifications;
|
2011-01-18 00:03:38 -08:00
|
|
|
notifications.SwapElements(mNotifications);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t notificationCount = notifications.Length();
|
|
|
|
for (uint32_t idx = 0; idx < notificationCount; idx++) {
|
2011-01-18 00:03:38 -08:00
|
|
|
notifications[idx]->Process();
|
|
|
|
if (!mDocument)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-07-24 20:15:37 -07:00
|
|
|
// Process invalidation list of the document after all accessible tree
|
|
|
|
// modification are done.
|
|
|
|
mDocument->ProcessInvalidationList();
|
|
|
|
|
2015-10-29 15:08:48 -07:00
|
|
|
// We cannot rely on DOM tree to keep aria-owns relations updated. Make
|
|
|
|
// a validation to remove dead links.
|
|
|
|
mDocument->ValidateARIAOwned();
|
|
|
|
|
|
|
|
// Process relocation list.
|
|
|
|
for (uint32_t idx = 0; idx < mRelocations.Length(); idx++) {
|
|
|
|
mDocument->DoARIAOwnsRelocation(mRelocations[idx]);
|
|
|
|
}
|
|
|
|
mRelocations.Clear();
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
// If a generic notification occurs after this point then we may be allowed to
|
2013-05-24 11:24:19 -07:00
|
|
|
// process it synchronously. However we do not want to reenter if fireing
|
|
|
|
// events causes script to run.
|
|
|
|
mObservingState = eRefreshProcessing;
|
2011-01-18 00:03:38 -08:00
|
|
|
|
2012-11-12 22:29:22 -08:00
|
|
|
ProcessEventQueue();
|
2014-10-28 11:18:03 -07:00
|
|
|
|
|
|
|
if (IPCAccessibilityActive()) {
|
|
|
|
size_t newDocCount = newChildDocs.Length();
|
|
|
|
for (size_t i = 0; i < newDocCount; i++) {
|
|
|
|
DocAccessible* childDoc = newChildDocs[i];
|
2015-03-24 10:52:59 -07:00
|
|
|
Accessible* parent = childDoc->Parent();
|
2014-10-28 11:18:03 -07:00
|
|
|
DocAccessibleChild* parentIPCDoc = mDocument->IPCDoc();
|
2015-03-24 10:52:59 -07:00
|
|
|
uint64_t id = reinterpret_cast<uintptr_t>(parent->UniqueID());
|
2015-01-07 12:16:37 -08:00
|
|
|
MOZ_ASSERT(id);
|
2015-03-24 10:52:59 -07:00
|
|
|
DocAccessibleChild* ipcDoc = childDoc->IPCDoc();
|
|
|
|
if (ipcDoc) {
|
|
|
|
parentIPCDoc->SendBindChildDoc(ipcDoc, id);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipcDoc = new DocAccessibleChild(childDoc);
|
|
|
|
childDoc->SetIPCDoc(ipcDoc);
|
2015-05-21 10:04:58 -07:00
|
|
|
nsCOMPtr<nsITabChild> tabChild =
|
|
|
|
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
|
2015-12-14 08:00:48 -08:00
|
|
|
if (tabChild) {
|
|
|
|
static_cast<TabChild*>(tabChild.get())->
|
|
|
|
SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id);
|
|
|
|
}
|
2014-10-28 11:18:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-24 11:24:19 -07:00
|
|
|
mObservingState = eRefreshObserving;
|
2012-11-12 22:29:22 -08:00
|
|
|
if (!mDocument)
|
|
|
|
return;
|
2011-01-18 00:03:38 -08:00
|
|
|
|
2011-08-08 00:55:36 -07:00
|
|
|
// Stop further processing if there are no new notifications of any kind or
|
|
|
|
// events and document load is processed.
|
2016-02-18 06:31:42 -08:00
|
|
|
if (mContentInsertions.Count() == 0 && mNotifications.IsEmpty() &&
|
2013-05-24 11:24:19 -07:00
|
|
|
mEvents.IsEmpty() && mTextHash.Count() == 0 &&
|
|
|
|
mHangingChildDocuments.IsEmpty() &&
|
2012-05-27 02:01:40 -07:00
|
|
|
mDocument->HasLoadState(DocAccessible::eCompletelyLoaded) &&
|
2011-01-18 00:03:38 -08:00
|
|
|
mPresShell->RemoveRefreshObserver(this, Flush_Display)) {
|
|
|
|
mObservingState = eNotObservingRefresh;
|
|
|
|
}
|
|
|
|
}
|