mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
0ac9509723
- Bug 1197954 - Extract GLXFBConfig selection code for X11 windows. r=lsalzman (2816a11bdd)
- Bug 1264831 - Use @imports in find_program. r=gps (a4fb8f6062)
- Bug 1257958 - Add a template to construct an environment-set option that sets the corresponding variable. r=glandium (d68ddc35aa)
- Bug 1261439 - replace nsAccUtils::IsEmbeddedObject on a bit flag check, r=marcoz (16319b9295)
- bug 1262563 - add IsFromUserInput to show / hide event messages r=davidb (dc96903cfa)
- bug 1262563 - fire show / hide events for proxied accessibles r=davidb (9b1deb77c9)
- bug 1255009 - make AccShowEvent store the insertion index of the new child r=davidb (5b3d984446)
- bug 1261144 - remove filters::GetEmbeddedObj() because it is unused r=lsocks (837bb1777c)
- bug 1261144 - devirtualize AppendObject() because the base class impl is never called r=lsocks (a8fe470965)
- bug 1261144 - move Count() from AccCollector to EmbeddedObjCollector r=lsocks (11d9734561)
- bug 1261144 - move GetAccessibleAt to EmbeddedObjCollector r=lsocks (6ac2731ec1)
- bug 1261144 - devirtualize GetIndexAt() because the base class version is never called r=lsocks (54cc48712e)
- bug 1261144 - move EnsureNGetObject to EmbeddedObjCollector r=lsocks (225b123fb0)
- bug 1261144 - move EnsureNGetIndex() to EmbeddedObjCollector r=lsocks (81986c9a95)
- bug 1261144 - move the data members of AccCollector to EmbeddedObjCollector r=lsocks (5ba20f1c30)
- bug 1261144 - remove the AccCollector class r=lsocks (6f52909c58)
- bug 1261144 - use filters::GetEmbeddedObject() directly in EmbeddedObjCollector r=lsocks (cb86410837)
- bug 1261144 - devirtualize the dtor of EmbeddedObjCollector r=lsocks (b3d23cf341)
- Bug 1261144 - stop including Filters.h in EmbeddedObjCollector.h r=lsocks (2940a4dc3d)
- bug 1261144 - call Accessible::IsText() directly from EmbeddedObjCollector r=lsocks (b93a86aa2a)
- bug 1262233 - stop using a sync message to implement ProxyAccessible::EmbeddedChildCount() r=lsocks (e2d3b6d608)
- bug 1262233 - stop implementing ProxyAccessible::IndexOfEmbeddedChild() with a sync message r=lsocks (dcedecd9d4)
- bug 1262233 - add ProxyAccessible::IsEmbeddedObject() r=lsocks (084915a784)
- bug 1262233 - stop implementing ProxyAccessible::EmbeddedChildAt() with a sync message r=lsocks (2924d04c4a)
- bug 1241453 - fire nsIAccessibleStateChangeEvents for proxied accessibles r=davidb (e423829903)
- bug 1241453 - fire nsIAccessibleEvents for proxied accessibles r=davidb (6a02c2f8a3)
- bug 1241453 - fire nsIAccessibleCaretMoveEvents for proxies r=davidb (4fb1f5be4f)
- bug 1241453 - fire nsIAccessibleTextChangeEvents for proxies r=davidb (c53a5b5122)
- Bug 1264526 - process ARIA owns relocations for in-the-document accessibles only, r=yzen (e19887eee4)
- Bug 1261174 - more events logging, r=yzen (14b83c693d)
- Bug 1257350 - Use intptr_t to avoid C4312 on VS2015; r=tbsaunde (1fc3ee9b6d)
- bug 1250882 - make xpcAccessible::GetAttributes() work with proxied accessibles r=davidb (fa676531c2)
- bug 1210741 - make AccessibleWrap::get_accLocation work with proxied accessibles r=davidb (6600987ec8)
- bug 1219528 - make NAVDIR_{FIRST,LAST}CHILD and NAVDIR_{NEXT,PREVIOUS} cases of AccessibleWrap::accNavigate deal with proxies r=davidb (c011ebcd2b)
- bug 1219528 - make AccessibleWrap::accNavigate cases using relations work with proxies r=davidb (de20c76bcc)
- bug 1215657 - make AccessibleWrap::accHitTest() work with proxies r=davidb (25da22a733)
- bug 1215657 - make AccessibleWrap::accDoDefaultAction work with proxies r=davidb (029d34d135)
- bug 1208779 - null check aAccessible in GetChildIDFor() for 32 bit as well as 64 bit windows r=davidb (08319d45e7)
- bug 1207862 - refactor GetXPAccessibleFor() so proxies and non proxies are handle in the same place for each type of id r=davidb (3ff1646e02)
- bug 1207862 - make AccessibleWrap::GetXPAccessibleFor() return the AccessibleWrap for proxies r=davidb (1184a0efeb)
- bug 1218564 - remove check for password roles in AccessibleWrap::get_accValue r=surkov (477e0bb92b)
- bug 1219528 - don't bail out of AccessibleWrap::accNavigate if the accessible wraps a proxy r=davidb (9540866b5b)
- Bug 1257303 - Cast to intptr_t to avoid C4312 on VS2015; r=tbsaunde (93af27e0db)
- Bug 1210549 - Fix AccessibleWrap::GetXPAccessibleFor for proxied accessibles r=tbsaunde (b4ed017706)
- Bug 1242101 - Only capture mozscreenshots for Nightlies, try pushes and local builds. r=felipe (c0ea8f5c10)
- Bug 974009 - Telemetry experiments: test experiment conditions and enable experiments. r=felipe,unfocused (5f9aabd724)
- align tests (d3ea5499ea)
- Bug 1098468 - »Show all Bookmarks« should show unsorted bookmarks by default. r=mak (37debf68eb)
- Bug 1205286 - Make about:home Sync icon always link to about:prefereces#sync r=markh (1d423fdae1)
- Bug 983226 - Set up jsfilter with proper healthreport/telemetry payloads, r=felipe (39cebec14e)
- Bug 979474 - Pin the telemetry experiments manifest, r=cviecco (35cfca1318)
- Bug 984879 - Experiment manager shutdown, r=felipe (504e08c2e2)
- Bug 985089 - Allow QA to set a pref to control experiment sampling values, r=felipe (65e5a93353)
- Bug 985682 - Experiment IDs aren't loaded correctly from the cache. Tests will be separate, r=gfritzsche (c0bbae811f)
- Bug 974024 - Add FHR recording of Telemetry Experiments activity; r=bsmedberg (3974e2ccbc)
- Bug 985670 - Telemetry experiments: Don't schedule incorrect timer when there is no pending experiment. r=felipe (a5292fa5d4)
- Bug 985670 - Telemetry experiments: Decouple experiment and addon ids. r=felipe (b445f120c1)
- Bug 983360 - Telemetry experiments: add monitoring data to Telemetry payload. r=bsmedberg (7c650f5fab)
- Bug 977708 - Annotate crash reports with the current experiment, r=felipe (4f2feb9a8c)
381 lines
10 KiB
C++
381 lines
10 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
/* 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 "TextRange-inl.h"
|
|
|
|
#include "Accessible-inl.h"
|
|
#include "nsAccUtils.h"
|
|
|
|
namespace mozilla {
|
|
namespace a11y {
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// TextPoint
|
|
|
|
bool
|
|
TextPoint::operator <(const TextPoint& aPoint) const
|
|
{
|
|
if (mContainer == aPoint.mContainer)
|
|
return mOffset < aPoint.mOffset;
|
|
|
|
// Build the chain of parents
|
|
Accessible* p1 = mContainer;
|
|
Accessible* p2 = aPoint.mContainer;
|
|
AutoTArray<Accessible*, 30> parents1, parents2;
|
|
do {
|
|
parents1.AppendElement(p1);
|
|
p1 = p1->Parent();
|
|
} while (p1);
|
|
do {
|
|
parents2.AppendElement(p2);
|
|
p2 = p2->Parent();
|
|
} while (p2);
|
|
|
|
// Find where the parent chain differs
|
|
uint32_t pos1 = parents1.Length(), pos2 = parents2.Length();
|
|
for (uint32_t len = std::min(pos1, pos2); len > 0; --len) {
|
|
Accessible* child1 = parents1.ElementAt(--pos1);
|
|
Accessible* child2 = parents2.ElementAt(--pos2);
|
|
if (child1 != child2)
|
|
return child1->IndexInParent() < child2->IndexInParent();
|
|
}
|
|
|
|
NS_ERROR("Broken tree?!");
|
|
return false;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// TextRange
|
|
|
|
TextRange::TextRange(HyperTextAccessible* aRoot,
|
|
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
|
|
HyperTextAccessible* aEndContainer, int32_t aEndOffset) :
|
|
mRoot(aRoot), mStartContainer(aStartContainer), mEndContainer(aEndContainer),
|
|
mStartOffset(aStartOffset), mEndOffset(aEndOffset)
|
|
{
|
|
}
|
|
|
|
void
|
|
TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
|
|
{
|
|
if (mStartContainer == mEndContainer) {
|
|
int32_t startIdx = mStartContainer->GetChildIndexAtOffset(mStartOffset);
|
|
int32_t endIdx = mStartContainer->GetChildIndexAtOffset(mEndOffset);
|
|
for (int32_t idx = startIdx; idx <= endIdx; idx++) {
|
|
Accessible* child = mStartContainer->GetChildAt(idx);
|
|
if (!child->IsText()) {
|
|
aChildren->AppendElement(child);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
Accessible* p1 = mStartContainer->GetChildAtOffset(mStartOffset);
|
|
Accessible* p2 = mEndContainer->GetChildAtOffset(mEndOffset);
|
|
|
|
uint32_t pos1 = 0, pos2 = 0;
|
|
AutoTArray<Accessible*, 30> parents1, parents2;
|
|
Accessible* container =
|
|
CommonParent(p1, p2, &parents1, &pos1, &parents2, &pos2);
|
|
|
|
// Traverse the tree up to the container and collect embedded objects.
|
|
for (uint32_t idx = 0; idx < pos1 - 1; idx++) {
|
|
Accessible* parent = parents1[idx + 1];
|
|
Accessible* child = parents1[idx];
|
|
uint32_t childCount = parent->ChildCount();
|
|
for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount; childIdx++) {
|
|
Accessible* next = parent->GetChildAt(childIdx);
|
|
if (!next->IsText()) {
|
|
aChildren->AppendElement(next);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Traverse through direct children in the container.
|
|
int32_t endIdx = parents2[pos2 - 1]->IndexInParent();
|
|
int32_t childIdx = parents1[pos1 - 1]->IndexInParent() + 1;
|
|
for (; childIdx < endIdx; childIdx++) {
|
|
Accessible* next = container->GetChildAt(childIdx);
|
|
if (!next->IsText()) {
|
|
aChildren->AppendElement(next);
|
|
}
|
|
}
|
|
|
|
// Traverse down from the container to end point.
|
|
for (int32_t idx = pos2 - 2; idx > 0; idx--) {
|
|
Accessible* parent = parents2[idx];
|
|
Accessible* child = parents2[idx - 1];
|
|
int32_t endIdx = child->IndexInParent();
|
|
for (int32_t childIdx = 0; childIdx < endIdx; childIdx++) {
|
|
Accessible* next = parent->GetChildAt(childIdx);
|
|
if (!next->IsText()) {
|
|
aChildren->AppendElement(next);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
TextRange::Text(nsAString& aText) const
|
|
{
|
|
Accessible* current = mStartContainer->GetChildAtOffset(mStartOffset);
|
|
uint32_t startIntlOffset =
|
|
mStartOffset - mStartContainer->GetChildOffset(current);
|
|
|
|
while (current && TextInternal(aText, current, startIntlOffset)) {
|
|
current = current->Parent();
|
|
if (!current)
|
|
break;
|
|
|
|
current = current->NextSibling();
|
|
}
|
|
}
|
|
|
|
void
|
|
TextRange::Bounds(nsTArray<nsIntRect> aRects) const
|
|
{
|
|
|
|
}
|
|
|
|
void
|
|
TextRange::Normalize(ETextUnit aUnit)
|
|
{
|
|
|
|
}
|
|
|
|
bool
|
|
TextRange::Crop(Accessible* aContainer)
|
|
{
|
|
uint32_t boundaryPos = 0, containerPos = 0;
|
|
AutoTArray<Accessible*, 30> boundaryParents, containerParents;
|
|
|
|
// Crop the start boundary.
|
|
Accessible* container = nullptr;
|
|
Accessible* boundary = mStartContainer->GetChildAtOffset(mStartOffset);
|
|
if (boundary != aContainer) {
|
|
CommonParent(boundary, aContainer, &boundaryParents, &boundaryPos,
|
|
&containerParents, &containerPos);
|
|
|
|
if (boundaryPos == 0) {
|
|
if (containerPos != 0) {
|
|
// The container is contained by the start boundary, reduce the range to
|
|
// the point starting at the container.
|
|
aContainer->ToTextPoint(mStartContainer.StartAssignment(), &mStartOffset);
|
|
static_cast<Accessible*>(mStartContainer)->AddRef();
|
|
}
|
|
else {
|
|
// The start boundary and the container are siblings.
|
|
container = aContainer;
|
|
}
|
|
}
|
|
else if (containerPos != 0) {
|
|
// The container does not contain the start boundary.
|
|
boundary = boundaryParents[boundaryPos];
|
|
container = containerParents[containerPos];
|
|
}
|
|
|
|
if (container) {
|
|
// If the range start is after the container, then make the range invalid.
|
|
if (boundary->IndexInParent() > container->IndexInParent()) {
|
|
return !!(mRoot = nullptr);
|
|
}
|
|
|
|
// If the range starts before the container, then reduce the range to
|
|
// the point starting at the container.
|
|
if (boundary->IndexInParent() < container->IndexInParent()) {
|
|
container->ToTextPoint(mStartContainer.StartAssignment(), &mStartOffset);
|
|
mStartContainer.get()->AddRef();
|
|
}
|
|
}
|
|
|
|
boundaryParents.SetLengthAndRetainStorage(0);
|
|
containerParents.SetLengthAndRetainStorage(0);
|
|
}
|
|
|
|
boundary = mEndContainer->GetChildAtOffset(mEndOffset);
|
|
if (boundary == aContainer) {
|
|
return true;
|
|
}
|
|
|
|
// Crop the end boundary.
|
|
container = nullptr;
|
|
CommonParent(boundary, aContainer, &boundaryParents, &boundaryPos,
|
|
&containerParents, &containerPos);
|
|
|
|
if (boundaryPos == 0) {
|
|
if (containerPos != 0) {
|
|
aContainer->ToTextPoint(mEndContainer.StartAssignment(), &mEndOffset, false);
|
|
static_cast<Accessible*>(mEndContainer)->AddRef();
|
|
}
|
|
else {
|
|
container = aContainer;
|
|
}
|
|
}
|
|
else if (containerPos != 0) {
|
|
boundary = boundaryParents[boundaryPos];
|
|
container = containerParents[containerPos];
|
|
}
|
|
|
|
if (!container) {
|
|
return true;
|
|
}
|
|
|
|
if (boundary->IndexInParent() < container->IndexInParent()) {
|
|
return !!(mRoot = nullptr);
|
|
}
|
|
|
|
if (boundary->IndexInParent() > container->IndexInParent()) {
|
|
container->ToTextPoint(mEndContainer.StartAssignment(), &mEndOffset, false);
|
|
static_cast<Accessible*>(mEndContainer)->AddRef();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void
|
|
TextRange::FindText(const nsAString& aText, EDirection aDirection,
|
|
nsCaseTreatment aCaseSensitive, TextRange* aFoundRange) const
|
|
{
|
|
|
|
}
|
|
|
|
void
|
|
TextRange::FindAttr(EAttr aAttr, nsIVariant* aValue, EDirection aDirection,
|
|
TextRange* aFoundRange) const
|
|
{
|
|
|
|
}
|
|
|
|
void
|
|
TextRange::AddToSelection() const
|
|
{
|
|
|
|
}
|
|
|
|
void
|
|
TextRange::RemoveFromSelection() const
|
|
{
|
|
|
|
}
|
|
|
|
void
|
|
TextRange::Select() const
|
|
{
|
|
}
|
|
|
|
void
|
|
TextRange::ScrollIntoView(EHowToAlign aHow) const
|
|
{
|
|
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// pivate
|
|
|
|
void
|
|
TextRange::Set(HyperTextAccessible* aRoot,
|
|
HyperTextAccessible* aStartContainer, int32_t aStartOffset,
|
|
HyperTextAccessible* aEndContainer, int32_t aEndOffset)
|
|
{
|
|
mRoot = aRoot;
|
|
mStartContainer = aStartContainer;
|
|
mEndContainer = aEndContainer;
|
|
mStartOffset = aStartOffset;
|
|
mEndOffset = aEndOffset;
|
|
}
|
|
|
|
bool
|
|
TextRange::TextInternal(nsAString& aText, Accessible* aCurrent,
|
|
uint32_t aStartIntlOffset) const
|
|
{
|
|
bool moveNext = true;
|
|
int32_t endIntlOffset = -1;
|
|
if (aCurrent->Parent() == mEndContainer &&
|
|
mEndContainer->GetChildAtOffset(mEndOffset) == aCurrent) {
|
|
|
|
uint32_t currentStartOffset = mEndContainer->GetChildOffset(aCurrent);
|
|
endIntlOffset = mEndOffset - currentStartOffset;
|
|
if (endIntlOffset == 0)
|
|
return false;
|
|
|
|
moveNext = false;
|
|
}
|
|
|
|
if (aCurrent->IsTextLeaf()) {
|
|
aCurrent->AppendTextTo(aText, aStartIntlOffset,
|
|
endIntlOffset - aStartIntlOffset);
|
|
if (!moveNext)
|
|
return false;
|
|
}
|
|
|
|
Accessible* next = aCurrent->FirstChild();
|
|
if (next) {
|
|
if (!TextInternal(aText, next, 0))
|
|
return false;
|
|
}
|
|
|
|
next = aCurrent->NextSibling();
|
|
if (next) {
|
|
if (!TextInternal(aText, next, 0))
|
|
return false;
|
|
}
|
|
|
|
return moveNext;
|
|
}
|
|
|
|
|
|
void
|
|
TextRange::MoveInternal(ETextUnit aUnit, int32_t aCount,
|
|
HyperTextAccessible& aContainer, int32_t aOffset,
|
|
HyperTextAccessible* aStopContainer, int32_t aStopOffset)
|
|
{
|
|
|
|
}
|
|
|
|
Accessible*
|
|
TextRange::CommonParent(Accessible* aAcc1, Accessible* aAcc2,
|
|
nsTArray<Accessible*>* aParents1, uint32_t* aPos1,
|
|
nsTArray<Accessible*>* aParents2, uint32_t* aPos2) const
|
|
{
|
|
if (aAcc1 == aAcc2) {
|
|
return aAcc1;
|
|
}
|
|
|
|
MOZ_ASSERT(aParents1->Length() == 0 || aParents2->Length() == 0,
|
|
"Wrong arguments");
|
|
|
|
// Build the chain of parents.
|
|
Accessible* p1 = aAcc1;
|
|
Accessible* p2 = aAcc2;
|
|
do {
|
|
aParents1->AppendElement(p1);
|
|
p1 = p1->Parent();
|
|
} while (p1);
|
|
do {
|
|
aParents2->AppendElement(p2);
|
|
p2 = p2->Parent();
|
|
} while (p2);
|
|
|
|
// Find where the parent chain differs
|
|
*aPos1 = aParents1->Length();
|
|
*aPos2 = aParents2->Length();
|
|
Accessible* parent = nullptr;
|
|
uint32_t len = 0;
|
|
for (len = std::min(*aPos1, *aPos2); len > 0; --len) {
|
|
Accessible* child1 = aParents1->ElementAt(--(*aPos1));
|
|
Accessible* child2 = aParents2->ElementAt(--(*aPos2));
|
|
if (child1 != child2)
|
|
break;
|
|
|
|
parent = child1;
|
|
}
|
|
|
|
return parent;
|
|
}
|
|
|
|
} // namespace a11y
|
|
} // namespace mozilla
|