gecko-dev/accessible/generic/OuterDocAccessible.cpp
Wes Kocher 021a12c86f Backed out changesets e4a39e456f89 (bug 1268544) for mass build bustage a=backout CLOSED TREE
***
Backed out changeset 119a4b187938 (bug 1268544)
***
Backed out changeset d83cba382cfe (bug 1268544)
***
Backed out changeset a0085eb5ffe7 (bug 1268544)
***
Backed out changeset eefa457c3680 (bug 1288843)
***
Backed out changeset 17dc46beb1a5 (bug 1288841)
***
Backed out changeset e76f58f328d4 (bug 1268544)
***
Backed out changeset ffc8ee715fdb (bug 1268544)
***
Backed out changeset 99f0ea19b8f5 (bug 1268544)
***
Backed out changeset 2bdfb9514317 (bug 1268544)
***
Backed out changeset e4b3a5e1756d (bug 1268544)

--HG--
rename : accessible/ipc/other/DocAccessibleChild.cpp => accessible/ipc/DocAccessibleChild.cpp
rename : accessible/ipc/other/DocAccessibleChild.h => accessible/ipc/DocAccessibleChild.h
rename : accessible/ipc/win/PDocAccessible.ipdl => accessible/ipc/PDocAccessible.ipdl
rename : accessible/ipc/win/ProxyAccessible.cpp => accessible/ipc/ProxyAccessible.cpp
rename : accessible/ipc/win/ProxyAccessible.h => accessible/ipc/ProxyAccessible.h
extra : amend_source : dc73ec117c7279539cab36af821637bb1b0236bd
extra : histedit_source : 438ce81f07a53af61b1cabf7620f30b090e7d5e2%2Ccb6472913fe0d7d2ec66bf0cedc18f2e4d00678e
2016-08-15 15:58:45 -07:00

185 lines
5.3 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "OuterDocAccessible.h"
#include "Accessible-inl.h"
#include "nsAccUtils.h"
#include "DocAccessible-inl.h"
#include "mozilla/a11y/DocAccessibleParent.h"
#include "mozilla/dom/TabParent.h"
#include "Role.h"
#include "States.h"
#ifdef A11Y_LOG
#include "Logging.h"
#endif
using namespace mozilla;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// OuterDocAccessible
////////////////////////////////////////////////////////////////////////////////
OuterDocAccessible::
OuterDocAccessible(nsIContent* aContent, DocAccessible* aDoc) :
AccessibleWrap(aContent, aDoc)
{
mType = eOuterDocType;
// Request document accessible for the content document to make sure it's
// created. It will appended to outerdoc accessible children asynchronously.
nsIDocument* outerDoc = mContent->GetUncomposedDoc();
if (outerDoc) {
nsIDocument* innerDoc = outerDoc->GetSubDocumentFor(mContent);
if (innerDoc)
GetAccService()->GetDocAccessible(innerDoc);
}
}
OuterDocAccessible::~OuterDocAccessible()
{
}
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED0(OuterDocAccessible,
Accessible)
////////////////////////////////////////////////////////////////////////////////
// Accessible public (DON'T add methods here)
role
OuterDocAccessible::NativeRole()
{
return roles::INTERNAL_FRAME;
}
Accessible*
OuterDocAccessible::ChildAtPoint(int32_t aX, int32_t aY,
EWhichChildAtPoint aWhichChild)
{
nsIntRect docRect = Bounds();
if (aX < docRect.x || aX >= docRect.x + docRect.width ||
aY < docRect.y || aY >= docRect.y + docRect.height)
return nullptr;
// Always return the inner doc as direct child accessible unless bounds
// outside of it.
Accessible* child = GetChildAt(0);
NS_ENSURE_TRUE(child, nullptr);
if (aWhichChild == eDeepestChild)
return child->ChildAtPoint(aX, aY, eDeepestChild);
return child;
}
////////////////////////////////////////////////////////////////////////////////
// Accessible public
void
OuterDocAccessible::Shutdown()
{
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy))
logging::OuterDocDestroy(this);
#endif
Accessible* child = mChildren.SafeElementAt(0, nullptr);
if (child) {
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy)) {
logging::DocDestroy("outerdoc's child document rebind is scheduled",
child->AsDoc()->DocumentNode());
}
#endif
RemoveChild(child);
// XXX: sometimes outerdoc accessible is shutdown because of layout style
// change however the presshell of underlying document isn't destroyed and
// the document doesn't get pagehide events. Schedule a document rebind
// to its parent document. Otherwise a document accessible may be lost if
// its outerdoc has being recreated (see bug 862863 for details).
if (!mDoc->IsDefunct()) {
mDoc->BindChildDocument(child->AsDoc());
}
}
AccessibleWrap::Shutdown();
}
bool
OuterDocAccessible::InsertChildAt(uint32_t aIdx, Accessible* aAccessible)
{
MOZ_RELEASE_ASSERT(aAccessible->IsDoc(),
"OuterDocAccessible can have a document child only!");
// We keep showing the old document for a bit after creating the new one,
// and while building the new DOM and frame tree. That's done on purpose
// to avoid weird flashes of default background color.
// The old viewer will be destroyed after the new one is created.
// For a11y, it should be safe to shut down the old document now.
if (mChildren.Length())
mChildren[0]->Shutdown();
if (!AccessibleWrap::InsertChildAt(0, aAccessible))
return false;
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate)) {
logging::DocCreate("append document to outerdoc",
aAccessible->AsDoc()->DocumentNode());
logging::Address("outerdoc", this);
}
#endif
return true;
}
bool
OuterDocAccessible::RemoveChild(Accessible* aAccessible)
{
Accessible* child = mChildren.SafeElementAt(0, nullptr);
if (child != aAccessible) {
NS_ERROR("Wrong child to remove!");
return false;
}
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy)) {
logging::DocDestroy("remove document from outerdoc",
child->AsDoc()->DocumentNode(), child->AsDoc());
logging::Address("outerdoc", this);
}
#endif
bool wasRemoved = AccessibleWrap::RemoveChild(child);
NS_ASSERTION(!mChildren.Length(),
"This child document of outerdoc accessible wasn't removed!");
return wasRemoved;
}
bool
OuterDocAccessible::IsAcceptableChild(nsIContent* aEl) const
{
// outer document accessible doesn't not participate in ordinal tree
// mutations.
return false;
}
ProxyAccessible*
OuterDocAccessible::RemoteChildDoc() const
{
dom::TabParent* tab = dom::TabParent::GetFrom(GetContent());
if (!tab)
return nullptr;
return tab->GetTopLevelDocAccessible();
}