mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
8655c2747d
- Bug 1412825 - fix lz4 deprecated attribute with clang and c++14; r=RyanVM (059d86484b)
- Bug 1245886 - Manually stop the profiler module at the end of all tests, r=me (1e00edd00c)
- Bug 1262359 (part 1) - Remove unused |hashRef| parameter from nsDataHandler::ParseURI(). r=jduell. (dcae9e057a)
- Bug 1262359 (part 2) - Make the filling in of two parameters optional in nsDataHandler::ParseURI(). r=jduell. (142ff6c86d)
- Bug 1262359 (part 3) - Add a missing fallible nsTSubstring_CharT::Assign() variant. r=erahm. (df93f41b86)
- Bug 1262359 (part 4) - Make data URL payload assignment fallible in nsDataHandler::ParseURI(). r=jduell. (05868a4269)
- Bug 1262359 (part 5) - Add a missing rv check for call to nsDataHandler::ParseURI(). r=jduell. (67d8a9c642)
- Bug 1263764 - Make the external string API's Truncate compatible with the internal API's Truncate. r=froydnj (b369693809)
- bug 1262563 - stop passing an event to FireShowHideEvent() r=davidb (b2893a18c2)
- bug 1262563 - fix how FireShowHideEvent gets the parent of a hide event target r=davidb (fbf7c39766)
- bug 1262563 - make FireShowHideEvent() return void r=davidb (c77c6c1d57)
- bug 1262563 - make FireShowHideEvent() a method of MaiAtkObject r=davidb (b0cc3aaf06)
- Bug 1260237 - remove InvalidateChildren, r=yzen (1eecf43b01)
- Bug 1251680 - get container accessible computation should take into account the HTML select, r=marcoz (553274c049)
- Bug 1252857 - test value change events for closed HTML select, r=marcoz (e3248842f5)
- Bug 1252857 - value change events for HTML:select have wrong target, r=marcoz (734ace8006)
- Bug 1105611 - Add tests of nsIAccessibleEditableText with contentediable editors which have ::before or ::after, patch=nakano, surkov, r=yzen (3b423d91cd)
- Bug 1249400 - add a test for missed hide events in case of accessible stealing, r=yzen (901c61e650)
- Bug 1255009 - insert children into the tree on content insertion instead the recaching, r=yzen (8074d82484)
- Bug 1255614 - make ProcessInvalidationList to insert accessibles instead the recaching, r=yzen (89a81d8b3f)
- Bug 1255617 - make PutChildrenBack to insert accessibles instead the recaching, r=yzen (39548b5922)
- Bug 1260187 - remove recaching version of DocAccessible::UpdateTreeOnInsertion, r=yzen (4bf8b09193)
- Bug 1260277 - remove empty CacheChildren's, r=marcoz (4eabc70d60)
- Bug 1256461 - merge MoveChild and SeizeChild methods, r=yzen (649b87dfad)
- Bug 1260494 - rebuild child indexes by AutoTreeMutation guard, r=yzen (e49a381192)
- Bug 1260862 - "remove Cache/EnsureChildren". r=mzehe (10751f0792)
- Bug 1260860 - stop illicit accessible stealing, r=yzen (55621a1af3)
- Bug 1260496 - get rid of CacheChildren for application accessible, r=marcoz (cde59765c3)
- Bug 1250878 - add acceptable child check for HTML select, r=marcoz (6e70925079)
- Bug 1252260 - get rid of HTML table CacheChildren, r=marcoz (7108ee2e06)
- Bug 1261165 - remove Accessible::ChildrenFlags, r=yzen (6e6c4db99d)
- Bug 1261167 - remove Accessible::TestChildCache, r=marcoz (69c9276da0)
- Bug 1261170 - add a single node ProcessContentInserted method version, r=yzen (5385e407b8)
- Bug 1261177 - split GetOrCreateAccessible method into two (Get and Create versions), r=yzen (ded9e7c0e5)
- Bug 1261408 - detect ARIA owned children early to avoid tree moving, r=yzen (ffd090ff2c)
- Bug 1261425 - coalesce mutation events by a tree structure, r=yzen (14ca8f3978)
- bug 1261144 - rename AccCollector.{h,cpp} to EmbeddedObjCollector.{h,cpp} r=lsocks (386be7f834)
- bug 1259023 - make nsIAccessible.parent work with proxies r=yzen (d611ef1fbf)
308 lines
8.0 KiB
C++
308 lines
8.0 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 "TreeWalker.h"
|
|
|
|
#include "Accessible.h"
|
|
#include "AccIterator.h"
|
|
#include "nsAccessibilityService.h"
|
|
#include "DocAccessible.h"
|
|
|
|
#include "mozilla/dom/ChildIterator.h"
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::a11y;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// TreeWalker
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
TreeWalker::
|
|
TreeWalker(Accessible* aContext) :
|
|
mDoc(aContext->Document()), mContext(aContext), mAnchorNode(nullptr),
|
|
mARIAOwnsIdx(0),
|
|
mChildFilter(nsIContent::eSkipPlaceholderContent), mFlags(0),
|
|
mPhase(eAtStart)
|
|
{
|
|
mChildFilter |= mContext->NoXBLKids() ?
|
|
nsIContent::eAllButXBL : nsIContent::eAllChildren;
|
|
|
|
mAnchorNode = mContext->IsDoc() ?
|
|
mDoc->DocumentNode()->GetRootElement() : mContext->GetContent();
|
|
|
|
MOZ_COUNT_CTOR(TreeWalker);
|
|
}
|
|
|
|
TreeWalker::
|
|
TreeWalker(Accessible* aContext, nsIContent* aAnchorNode, uint32_t aFlags) :
|
|
mDoc(aContext->Document()), mContext(aContext), mAnchorNode(aAnchorNode),
|
|
mARIAOwnsIdx(0),
|
|
mChildFilter(nsIContent::eSkipPlaceholderContent), mFlags(aFlags),
|
|
mPhase(eAtStart)
|
|
{
|
|
MOZ_ASSERT(mFlags & eWalkCache, "This constructor cannot be used for tree creation");
|
|
MOZ_ASSERT(aAnchorNode, "No anchor node for the accessible tree walker");
|
|
|
|
mChildFilter |= mContext->NoXBLKids() ?
|
|
nsIContent::eAllButXBL : nsIContent::eAllChildren;
|
|
|
|
MOZ_COUNT_CTOR(TreeWalker);
|
|
}
|
|
|
|
TreeWalker::~TreeWalker()
|
|
{
|
|
MOZ_COUNT_DTOR(TreeWalker);
|
|
}
|
|
|
|
bool
|
|
TreeWalker::Seek(nsIContent* aChildNode)
|
|
{
|
|
MOZ_ASSERT(aChildNode, "Child cannot be null");
|
|
|
|
mPhase = eAtStart;
|
|
mStateStack.Clear();
|
|
mARIAOwnsIdx = 0;
|
|
|
|
nsIContent* childNode = nullptr;
|
|
nsINode* parentNode = aChildNode;
|
|
do {
|
|
childNode = parentNode->AsContent();
|
|
parentNode = childNode->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) &&
|
|
(mChildFilter & nsIContent::eAllButXBL) ?
|
|
childNode->GetParentNode() : childNode->GetFlattenedTreeParent();
|
|
|
|
if (!parentNode || !parentNode->IsElement()) {
|
|
return false;
|
|
}
|
|
|
|
// If ARIA owned child.
|
|
Accessible* child = mDoc->GetAccessible(childNode);
|
|
if (child && child->IsRelocated()) {
|
|
if (child->Parent() != mContext) {
|
|
return false;
|
|
}
|
|
|
|
Accessible* ownedChild = nullptr;
|
|
while ((ownedChild = mDoc->ARIAOwnedAt(mContext, mARIAOwnsIdx++)) &&
|
|
ownedChild != child);
|
|
|
|
MOZ_ASSERT(ownedChild, "A child has to be in ARIA owned elements");
|
|
mPhase = eAtARIAOwns;
|
|
return true;
|
|
}
|
|
|
|
// Look in DOM.
|
|
dom::AllChildrenIterator* iter = PrependState(parentNode->AsElement(), true);
|
|
if (!iter->Seek(childNode)) {
|
|
return false;
|
|
}
|
|
|
|
if (parentNode == mAnchorNode) {
|
|
mPhase = eAtDOM;
|
|
return true;
|
|
}
|
|
} while (true);
|
|
|
|
return false;
|
|
}
|
|
|
|
Accessible*
|
|
TreeWalker::Next(nsIContent* aStopNode)
|
|
{
|
|
if (mStateStack.IsEmpty()) {
|
|
if (mPhase == eAtEnd) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (mPhase == eAtDOM || mPhase == eAtARIAOwns) {
|
|
mPhase = eAtARIAOwns;
|
|
Accessible* child = mDoc->ARIAOwnedAt(mContext, mARIAOwnsIdx);
|
|
if (child) {
|
|
mARIAOwnsIdx++;
|
|
return child;
|
|
}
|
|
mPhase = eAtEnd;
|
|
return nullptr;
|
|
}
|
|
|
|
if (!mAnchorNode) {
|
|
mPhase = eAtEnd;
|
|
return nullptr;
|
|
}
|
|
|
|
mPhase = eAtDOM;
|
|
PushState(mAnchorNode, true);
|
|
}
|
|
|
|
dom::AllChildrenIterator* top = &mStateStack[mStateStack.Length() - 1];
|
|
while (top) {
|
|
if (aStopNode && top->Get() == aStopNode) {
|
|
return nullptr;
|
|
}
|
|
|
|
while (nsIContent* childNode = top->GetNextChild()) {
|
|
bool skipSubtree = false;
|
|
Accessible* child = AccessibleFor(childNode, mFlags, &skipSubtree);
|
|
if (child) {
|
|
return child;
|
|
}
|
|
|
|
// Walk down the subtree if allowed, otherwise check if we have reached
|
|
// a stop node.
|
|
if (!skipSubtree && childNode->IsElement()) {
|
|
top = PushState(childNode, true);
|
|
}
|
|
else if (childNode == aStopNode) {
|
|
return nullptr;
|
|
}
|
|
}
|
|
top = PopState();
|
|
}
|
|
|
|
// If we traversed the whole subtree of the anchor node. Move to next node
|
|
// relative anchor node within the context subtree if asked.
|
|
if (mFlags != eWalkContextTree) {
|
|
// eWalkCache flag presence indicates that the search is scoped to the
|
|
// anchor (no ARIA owns stuff).
|
|
if (mFlags & eWalkCache) {
|
|
mPhase = eAtEnd;
|
|
return nullptr;
|
|
}
|
|
return Next(aStopNode);
|
|
}
|
|
|
|
nsINode* contextNode = mContext->GetNode();
|
|
while (mAnchorNode != contextNode) {
|
|
nsINode* parentNode = mAnchorNode->GetFlattenedTreeParent();
|
|
if (!parentNode || !parentNode->IsElement())
|
|
return nullptr;
|
|
|
|
nsIContent* parent = parentNode->AsElement();
|
|
top = PushState(parent, true);
|
|
if (top->Seek(mAnchorNode)) {
|
|
mAnchorNode = parent;
|
|
return Next(aStopNode);
|
|
}
|
|
|
|
// XXX We really should never get here, it means we're trying to find an
|
|
// accessible for a dom node where iterating over its parent's children
|
|
// doesn't return it. However this sometimes happens when we're asked for
|
|
// the nearest accessible to place holder content which we ignore.
|
|
mAnchorNode = parent;
|
|
}
|
|
|
|
return Next(aStopNode);
|
|
}
|
|
|
|
Accessible*
|
|
TreeWalker::Prev()
|
|
{
|
|
if (mStateStack.IsEmpty()) {
|
|
if (mPhase == eAtStart || mPhase == eAtDOM) {
|
|
mPhase = eAtStart;
|
|
return nullptr;
|
|
}
|
|
|
|
if (mPhase == eAtEnd) {
|
|
mARIAOwnsIdx = mDoc->ARIAOwnedCount(mContext);
|
|
mPhase = eAtARIAOwns;
|
|
}
|
|
|
|
if (mPhase == eAtARIAOwns) {
|
|
if (mARIAOwnsIdx > 0) {
|
|
return mDoc->ARIAOwnedAt(mContext, --mARIAOwnsIdx);
|
|
}
|
|
|
|
if (!mAnchorNode) {
|
|
mPhase = eAtStart;
|
|
return nullptr;
|
|
}
|
|
|
|
mPhase = eAtDOM;
|
|
PushState(mAnchorNode, false);
|
|
}
|
|
}
|
|
|
|
dom::AllChildrenIterator* top = &mStateStack[mStateStack.Length() - 1];
|
|
while (top) {
|
|
while (nsIContent* childNode = top->GetPreviousChild()) {
|
|
// No accessible creation on the way back.
|
|
bool skipSubtree = false;
|
|
Accessible* child = AccessibleFor(childNode, eWalkCache, &skipSubtree);
|
|
if (child) {
|
|
return child;
|
|
}
|
|
|
|
// Walk down into subtree to find accessibles.
|
|
if (!skipSubtree && childNode->IsElement()) {
|
|
top = PushState(childNode, false);
|
|
}
|
|
}
|
|
top = PopState();
|
|
}
|
|
|
|
// Move to a previous node relative the anchor node within the context
|
|
// subtree if asked.
|
|
if (mFlags != eWalkContextTree) {
|
|
mPhase = eAtStart;
|
|
return nullptr;
|
|
}
|
|
|
|
nsINode* contextNode = mContext->GetNode();
|
|
while (mAnchorNode != contextNode) {
|
|
nsINode* parentNode = mAnchorNode->GetFlattenedTreeParent();
|
|
if (!parentNode || !parentNode->IsElement()) {
|
|
return nullptr;
|
|
}
|
|
|
|
nsIContent* parent = parentNode->AsElement();
|
|
top = PushState(parent, true);
|
|
if (top->Seek(mAnchorNode)) {
|
|
mAnchorNode = parent;
|
|
return Prev();
|
|
}
|
|
|
|
mAnchorNode = parent;
|
|
}
|
|
|
|
mPhase = eAtStart;
|
|
return nullptr;
|
|
}
|
|
|
|
Accessible*
|
|
TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags, bool* aSkipSubtree)
|
|
{
|
|
// Ignore the accessible and its subtree if it was repositioned by means
|
|
// of aria-owns.
|
|
Accessible* child = mDoc->GetAccessible(aNode);
|
|
if (child) {
|
|
if (child->IsRelocated()) {
|
|
*aSkipSubtree = true;
|
|
return nullptr;
|
|
}
|
|
return child;
|
|
}
|
|
|
|
// Create an accessible if allowed.
|
|
if (!(aFlags & eWalkCache) && mContext->IsAcceptableChild(aNode)) {
|
|
if (mDoc->RelocateARIAOwnedIfNeeded(aNode)) {
|
|
*aSkipSubtree = true;
|
|
return nullptr;
|
|
}
|
|
return GetAccService()->CreateAccessible(aNode, mContext, aSkipSubtree);
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
dom::AllChildrenIterator*
|
|
TreeWalker::PopState()
|
|
{
|
|
size_t length = mStateStack.Length();
|
|
mStateStack.RemoveElementAt(length - 1);
|
|
return mStateStack.IsEmpty() ? nullptr : &mStateStack.LastElement();
|
|
}
|