2011-01-18 11:03:38 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 11:03:38 +03:00
|
|
|
|
2011-01-31 18:53:09 +03:00
|
|
|
#include "NotificationController.h"
|
2011-01-18 11:03:38 +03:00
|
|
|
|
2012-12-27 08:25:27 +04:00
|
|
|
#include "DocAccessible-inl.h"
|
2014-03-08 01:35:19 +04:00
|
|
|
#include "DocAccessibleChild.h"
|
2012-05-23 22:05:57 +04:00
|
|
|
#include "TextLeafAccessible.h"
|
2011-02-08 07:48:41 +03:00
|
|
|
#include "TextUpdater.h"
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2015-05-21 20:04:58 +03:00
|
|
|
#include "mozilla/dom/TabChild.h"
|
2011-07-20 23:18:54 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-07-21 00:23:38 +04:00
|
|
|
#include "mozilla/Telemetry.h"
|
2011-01-18 11:03:38 +03:00
|
|
|
|
2012-07-21 00:23:38 +04:00
|
|
|
using namespace mozilla;
|
2011-09-28 05:46:11 +04:00
|
|
|
using namespace mozilla::a11y;
|
2011-01-18 11:03:38 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
NotificationController::NotificationController(DocAccessible* aDocument,
|
2011-01-18 11:03:38 +03:00
|
|
|
nsIPresShell* aPresShell) :
|
2013-01-29 14:00:58 +04:00
|
|
|
EventQueue(aDocument), mObservingState(eNotObservingRefresh),
|
2011-08-08 11:55:36 +04:00
|
|
|
mPresShell(aPresShell)
|
2011-01-18 11:03:38 +03:00
|
|
|
{
|
2011-01-24 05:58:00 +03:00
|
|
|
// Schedule initial accessible tree construction.
|
|
|
|
ScheduleProcessing();
|
2011-01-18 11:03:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NotificationController::~NotificationController()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mDocument, "Controller wasn't shutdown properly!");
|
|
|
|
if (mDocument)
|
|
|
|
Shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector: AddRef/Release and cycle collection
|
|
|
|
|
2012-08-24 20:50:06 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_NATIVE_ADDREF(NotificationController)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE(NotificationController)
|
2011-01-18 11:03:38 +03:00
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(NotificationController)
|
|
|
|
|
2012-11-22 21:15:38 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(NotificationController)
|
2011-02-01 19:08:28 +03:00
|
|
|
if (tmp->mDocument)
|
|
|
|
tmp->Shutdown();
|
2011-01-18 11:03:38 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
2012-11-22 21:15:38 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NotificationController)
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mHangingChildDocuments)
|
2016-02-18 17:31:42 +03: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-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEvents)
|
2015-10-30 01:08:48 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelocations)
|
2011-01-18 11:03:38 +03: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-26 09:35:51 +03:00
|
|
|
// Shutdown handling child documents.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t childDocCount = mHangingChildDocuments.Length();
|
|
|
|
for (int32_t idx = childDocCount - 1; idx >= 0; idx--) {
|
2012-03-15 00:37:50 +04:00
|
|
|
if (!mHangingChildDocuments[idx]->IsDefunct())
|
|
|
|
mHangingChildDocuments[idx]->Shutdown();
|
|
|
|
}
|
2011-01-26 09:35:51 +03:00
|
|
|
|
|
|
|
mHangingChildDocuments.Clear();
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mDocument = nullptr;
|
|
|
|
mPresShell = nullptr;
|
2011-01-26 09:35:51 +03:00
|
|
|
|
2011-01-28 11:42:22 +03:00
|
|
|
mTextHash.Clear();
|
2011-01-18 11:03:38 +03:00
|
|
|
mContentInsertions.Clear();
|
|
|
|
mNotifications.Clear();
|
|
|
|
mEvents.Clear();
|
2015-10-30 01:08:48 +03:00
|
|
|
mRelocations.Clear();
|
2011-01-18 11:03:38 +03:00
|
|
|
}
|
|
|
|
|
2011-01-26 09:35:51 +03:00
|
|
|
void
|
2012-05-27 13:01:40 +04:00
|
|
|
NotificationController::ScheduleChildDocBinding(DocAccessible* aDocument)
|
2011-01-26 09:35:51 +03:00
|
|
|
{
|
|
|
|
// Schedule child document binding to the tree.
|
|
|
|
mHangingChildDocuments.AppendElement(aDocument);
|
|
|
|
ScheduleProcessing();
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
void
|
2012-05-29 05:18:45 +04:00
|
|
|
NotificationController::ScheduleContentInsertion(Accessible* aContainer,
|
2011-01-18 11:03:38 +03:00
|
|
|
nsIContent* aStartChildNode,
|
|
|
|
nsIContent* aEndChildNode)
|
|
|
|
{
|
2016-02-18 17:31:42 +03: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 11:03:38 +03:00
|
|
|
ScheduleProcessing();
|
2011-04-07 09:17:29 +04:00
|
|
|
}
|
2011-01-18 11:03:38 +03: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 19:01:51 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector: protected
|
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
bool
|
|
|
|
NotificationController::IsUpdatePending()
|
|
|
|
{
|
2011-04-01 01:33:46 +04:00
|
|
|
return mPresShell->IsLayoutFlushObserver() ||
|
2011-01-18 11:03:38 +03:00
|
|
|
mObservingState == eRefreshProcessingForUpdate ||
|
2016-02-18 17:31:42 +03:00
|
|
|
mContentInsertions.Count() != 0 || mNotifications.Length() != 0 ||
|
2011-09-28 05:46:11 +04:00
|
|
|
mTextHash.Count() != 0 ||
|
2012-05-27 13:01:40 +04:00
|
|
|
!mDocument->HasLoadState(DocAccessible::eTreeConstructed);
|
2011-01-18 11:03:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NotificationCollector: private
|
|
|
|
|
|
|
|
void
|
|
|
|
NotificationController::WillRefresh(mozilla::TimeStamp aTime)
|
|
|
|
{
|
2016-01-15 01:03:11 +03:00
|
|
|
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
2012-07-28 08:21:44 +04:00
|
|
|
Telemetry::AutoTimer<Telemetry::A11Y_UPDATE_TIME> updateTimer;
|
2012-07-21 00:23:38 +04:00
|
|
|
|
2011-01-18 11:03:38 +03: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 22:24:19 +04:00
|
|
|
if (mObservingState == eRefreshProcessing ||
|
|
|
|
mObservingState == eRefreshProcessingForUpdate)
|
|
|
|
return;
|
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
// Any generic notifications should be queued if we're processing content
|
|
|
|
// insertions or generic notifications.
|
|
|
|
mObservingState = eRefreshProcessingForUpdate;
|
|
|
|
|
2011-01-24 05:58:00 +03:00
|
|
|
// Initial accessible tree construction.
|
2012-05-27 13:01:40 +04:00
|
|
|
if (!mDocument->HasLoadState(DocAccessible::eTreeConstructed)) {
|
2011-01-26 09:35:51 +03:00
|
|
|
// If document is not bound to parent at this point then the document is not
|
|
|
|
// ready yet (process notifications later).
|
2011-10-14 06:33:41 +04:00
|
|
|
if (!mDocument->IsBoundToParent()) {
|
|
|
|
mObservingState = eRefreshObserving;
|
2011-01-26 09:35:51 +03:00
|
|
|
return;
|
2011-10-14 06:33:41 +04:00
|
|
|
}
|
2011-01-26 09:35:51 +03:00
|
|
|
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-06-01 08:27:25 +04:00
|
|
|
if (logging::IsEnabled(logging::eTree)) {
|
|
|
|
logging::MsgBegin("TREE", "initial tree created");
|
|
|
|
logging::Address("document", mDocument);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
2011-01-28 11:42:22 +03:00
|
|
|
#endif
|
|
|
|
|
2011-08-08 11:55:36 +04:00
|
|
|
mDocument->DoInitialUpdate();
|
2011-03-03 09:41:46 +03:00
|
|
|
|
2016-02-18 17:31:42 +03:00
|
|
|
NS_ASSERTION(mContentInsertions.Count() == 0,
|
2011-01-24 05:58:00 +03:00
|
|
|
"Pending content insertions while initial accessible tree isn't created!");
|
|
|
|
}
|
|
|
|
|
2012-12-27 08:25:27 +04:00
|
|
|
// Initialize scroll support if needed.
|
|
|
|
if (!(mDocument->mDocFlags & DocAccessible::eScrollInitialized))
|
|
|
|
mDocument->AddScrollListener();
|
|
|
|
|
2011-01-18 11:03:38 +03: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 17:31:42 +03:00
|
|
|
for (auto iter = mContentInsertions.ConstIter(); !iter.Done(); iter.Next()) {
|
|
|
|
mDocument->ProcessContentInserted(iter.Key(), iter.UserData());
|
|
|
|
if (!mDocument) {
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2016-02-18 17:31:42 +03:00
|
|
|
}
|
2011-01-18 11:03:38 +03:00
|
|
|
}
|
2016-02-18 17:31:42 +03:00
|
|
|
mContentInsertions.Clear();
|
2011-01-18 11:03:38 +03:00
|
|
|
|
2011-01-28 11:42:22 +03:00
|
|
|
// Process rendered text change notifications.
|
2015-07-23 06:49:25 +03: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 16:21:25 +03:00
|
|
|
nsIFrame::RenderedText text = textFrame->GetRenderedText(0,
|
|
|
|
UINT32_MAX, nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
|
|
|
|
nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE);
|
2015-07-23 06:49:25 +03:00
|
|
|
|
|
|
|
// Remove text accessible if rendered text is empty.
|
|
|
|
if (textAcc) {
|
2015-10-30 09:23:10 +03:00
|
|
|
if (text.mString.IsEmpty()) {
|
2015-07-23 06:49:25 +03: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-30 09:23:10 +03:00
|
|
|
NS_ConvertUTF16toUTF8(text.mString).get());
|
2015-07-23 06:49:25 +03:00
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-30 09:23:10 +03:00
|
|
|
TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text.mString);
|
2015-07-23 06:49:25 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append an accessible if rendered text is not empty.
|
2015-10-30 09:23:10 +03:00
|
|
|
if (!text.mString.IsEmpty()) {
|
2015-07-23 06:49:25 +03: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.
|
2016-04-06 03:48:30 +03:00
|
|
|
Accessible* container = mDocument->AccessibleOrTrueContainer(containerNode);
|
|
|
|
MOZ_ASSERT(container,
|
|
|
|
"Text node having rendered text hasn't accessible document!");
|
2015-07-23 06:49:25 +03:00
|
|
|
if (container) {
|
2016-04-06 03:48:30 +03:00
|
|
|
mDocument->ProcessContentInserted(container, textNode);
|
2015-07-23 06:49:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-28 11:42:22 +03:00
|
|
|
mTextHash.Clear();
|
|
|
|
|
2011-01-26 09:35:51 +03:00
|
|
|
// Bind hanging child documents.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t hangingDocCnt = mHangingChildDocuments.Length();
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<DocAccessible>> newChildDocs;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t idx = 0; idx < hangingDocCnt; idx++) {
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* childDoc = mHangingChildDocuments[idx];
|
2012-03-15 00:37:50 +04:00
|
|
|
if (childDoc->IsDefunct())
|
|
|
|
continue;
|
2011-01-26 09:35:51 +03:00
|
|
|
|
2012-10-12 06:25:34 +04:00
|
|
|
nsIContent* ownerContent = mDocument->DocumentNode()->
|
|
|
|
FindContentForSubDocument(childDoc->DocumentNode());
|
2011-01-26 09:35:51 +03:00
|
|
|
if (ownerContent) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* outerDocAcc = mDocument->GetAccessible(ownerContent);
|
2011-01-26 09:35:51 +03:00
|
|
|
if (outerDocAcc && outerDocAcc->AppendChild(childDoc)) {
|
2014-03-08 01:35:19 +04:00
|
|
|
if (mDocument->AppendChildDocument(childDoc)) {
|
2015-01-07 23:16:37 +03:00
|
|
|
newChildDocs.AppendElement(Move(mHangingChildDocuments[idx]));
|
2011-01-26 09:35:51 +03:00
|
|
|
continue;
|
2014-03-08 01:35:19 +04:00
|
|
|
}
|
2011-07-19 12:30:32 +04:00
|
|
|
|
2011-01-26 09:35:51 +03:00
|
|
|
outerDocAcc->RemoveChild(childDoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Failed to bind the child document, destroy it.
|
|
|
|
childDoc->Shutdown();
|
|
|
|
}
|
|
|
|
}
|
2014-10-28 21:18:03 +03:00
|
|
|
|
2015-01-07 23:16:37 +03:00
|
|
|
mHangingChildDocuments.Clear();
|
2011-01-26 09:35:51 +03:00
|
|
|
|
2011-08-08 11:55:36 +04:00
|
|
|
// If the document is ready and all its subdocuments are completely loaded
|
|
|
|
// then process the document load.
|
2012-05-27 13:01:40 +04:00
|
|
|
if (mDocument->HasLoadState(DocAccessible::eReady) &&
|
|
|
|
!mDocument->HasLoadState(DocAccessible::eCompletelyLoaded) &&
|
2011-08-08 11:55:36 +04:00
|
|
|
hangingDocCnt == 0) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t childDocCnt = mDocument->ChildDocumentCount(), childDocIdx = 0;
|
2011-08-08 11:55:36 +04:00
|
|
|
for (; childDocIdx < childDocCnt; childDocIdx++) {
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* childDoc = mDocument->GetChildDocumentAt(childDocIdx);
|
|
|
|
if (!childDoc->HasLoadState(DocAccessible::eCompletelyLoaded))
|
2011-08-08 11:55:36 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (childDocIdx == childDocCnt) {
|
|
|
|
mDocument->ProcessLoad();
|
|
|
|
if (!mDocument)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
// Process only currently queued generic notifications.
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray < RefPtr<Notification> > notifications;
|
2011-01-18 11:03:38 +03:00
|
|
|
notifications.SwapElements(mNotifications);
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t notificationCount = notifications.Length();
|
|
|
|
for (uint32_t idx = 0; idx < notificationCount; idx++) {
|
2011-01-18 11:03:38 +03:00
|
|
|
notifications[idx]->Process();
|
|
|
|
if (!mDocument)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-07-25 07:15:37 +04:00
|
|
|
// Process invalidation list of the document after all accessible tree
|
|
|
|
// modification are done.
|
|
|
|
mDocument->ProcessInvalidationList();
|
|
|
|
|
2015-10-30 01:08:48 +03: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 11:03:38 +03:00
|
|
|
// If a generic notification occurs after this point then we may be allowed to
|
2013-05-24 22:24:19 +04:00
|
|
|
// process it synchronously. However we do not want to reenter if fireing
|
|
|
|
// events causes script to run.
|
|
|
|
mObservingState = eRefreshProcessing;
|
2011-01-18 11:03:38 +03:00
|
|
|
|
2012-11-13 10:29:22 +04:00
|
|
|
ProcessEventQueue();
|
2014-10-28 21:18:03 +03:00
|
|
|
|
|
|
|
if (IPCAccessibilityActive()) {
|
|
|
|
size_t newDocCount = newChildDocs.Length();
|
|
|
|
for (size_t i = 0; i < newDocCount; i++) {
|
|
|
|
DocAccessible* childDoc = newChildDocs[i];
|
2015-03-24 20:52:59 +03:00
|
|
|
Accessible* parent = childDoc->Parent();
|
2014-10-28 21:18:03 +03:00
|
|
|
DocAccessibleChild* parentIPCDoc = mDocument->IPCDoc();
|
2015-03-24 20:52:59 +03:00
|
|
|
uint64_t id = reinterpret_cast<uintptr_t>(parent->UniqueID());
|
2015-01-07 23:16:37 +03:00
|
|
|
MOZ_ASSERT(id);
|
2015-03-24 20:52:59 +03:00
|
|
|
DocAccessibleChild* ipcDoc = childDoc->IPCDoc();
|
|
|
|
if (ipcDoc) {
|
|
|
|
parentIPCDoc->SendBindChildDoc(ipcDoc, id);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipcDoc = new DocAccessibleChild(childDoc);
|
|
|
|
childDoc->SetIPCDoc(ipcDoc);
|
2015-05-21 20:04:58 +03:00
|
|
|
nsCOMPtr<nsITabChild> tabChild =
|
|
|
|
do_GetInterface(mDocument->DocumentNode()->GetDocShell());
|
2015-12-14 19:00:48 +03:00
|
|
|
if (tabChild) {
|
|
|
|
static_cast<TabChild*>(tabChild.get())->
|
|
|
|
SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id);
|
|
|
|
}
|
2014-10-28 21:18:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-24 22:24:19 +04:00
|
|
|
mObservingState = eRefreshObserving;
|
2012-11-13 10:29:22 +04:00
|
|
|
if (!mDocument)
|
|
|
|
return;
|
2011-01-18 11:03:38 +03:00
|
|
|
|
2011-08-08 11:55:36 +04:00
|
|
|
// Stop further processing if there are no new notifications of any kind or
|
|
|
|
// events and document load is processed.
|
2016-02-18 17:31:42 +03:00
|
|
|
if (mContentInsertions.Count() == 0 && mNotifications.IsEmpty() &&
|
2013-05-24 22:24:19 +04:00
|
|
|
mEvents.IsEmpty() && mTextHash.Count() == 0 &&
|
|
|
|
mHangingChildDocuments.IsEmpty() &&
|
2012-05-27 13:01:40 +04:00
|
|
|
mDocument->HasLoadState(DocAccessible::eCompletelyLoaded) &&
|
2011-01-18 11:03:38 +03:00
|
|
|
mPresShell->RemoveRefreshObserver(this, Flush_Display)) {
|
|
|
|
mObservingState = eNotObservingRefresh;
|
|
|
|
}
|
|
|
|
}
|