зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1730088 part 8: Move ToTextLeafPoint to HyperTextAccessibleBase. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D127213
This commit is contained in:
Родитель
eb660a098e
Коммит
ddbabe9849
|
@ -8,6 +8,7 @@
|
|||
#include "mozilla/a11y/Accessible.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsIAccessibleText.h"
|
||||
#include "TextLeafRange.h"
|
||||
|
||||
namespace mozilla::a11y {
|
||||
|
||||
|
@ -160,4 +161,23 @@ bool HyperTextAccessibleBase::CharAt(int32_t aOffset, nsAString& aChar,
|
|||
return true;
|
||||
}
|
||||
|
||||
TextLeafPoint HyperTextAccessibleBase::ToTextLeafPoint(int32_t aOffset,
|
||||
bool aDescendToEnd) {
|
||||
Accessible* thisAcc = Acc();
|
||||
if (!thisAcc->HasChildren()) {
|
||||
return TextLeafPoint(thisAcc, 0);
|
||||
}
|
||||
Accessible* child = GetChildAtOffset(aOffset);
|
||||
if (!child) {
|
||||
return TextLeafPoint();
|
||||
}
|
||||
if (HyperTextAccessibleBase* childHt = child->AsHyperTextBase()) {
|
||||
return childHt->ToTextLeafPoint(
|
||||
aDescendToEnd ? static_cast<int32_t>(childHt->CharacterCount()) : 0,
|
||||
aDescendToEnd);
|
||||
}
|
||||
int32_t offset = aOffset - GetChildOffset(child);
|
||||
return TextLeafPoint(child, offset);
|
||||
}
|
||||
|
||||
} // namespace mozilla::a11y
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
namespace mozilla::a11y {
|
||||
class Accessible;
|
||||
class TextLeafPoint;
|
||||
|
||||
// This character marks where in the text returned via Text interface,
|
||||
// that embedded object characters exist
|
||||
|
@ -93,6 +94,14 @@ class HyperTextAccessibleBase {
|
|||
bool CharAt(int32_t aOffset, nsAString& aChar,
|
||||
int32_t* aStartOffset = nullptr, int32_t* aEndOffset = nullptr);
|
||||
|
||||
/**
|
||||
* Get a TextLeafPoint for a given offset in this HyperTextAccessible.
|
||||
* If the offset points to an embedded object and aDescendToEnd is true,
|
||||
* the point right at the end of this subtree will be returned instead of the
|
||||
* start.
|
||||
*/
|
||||
TextLeafPoint ToTextLeafPoint(int32_t aOffset, bool aDescendToEnd = false);
|
||||
|
||||
protected:
|
||||
virtual const Accessible* Acc() const = 0;
|
||||
Accessible* Acc() {
|
||||
|
|
|
@ -2087,24 +2087,6 @@ void HyperTextAccessible::RangeAtPoint(int32_t aX, int32_t aY,
|
|||
}
|
||||
}
|
||||
|
||||
TextLeafPoint HyperTextAccessible::ToTextLeafPoint(int32_t aOffset,
|
||||
bool aDescendToEnd) {
|
||||
if (!HasChildren()) {
|
||||
return TextLeafPoint(this, 0);
|
||||
}
|
||||
LocalAccessible* child = GetChildAtOffset(aOffset);
|
||||
if (!child) {
|
||||
return TextLeafPoint();
|
||||
}
|
||||
if (HyperTextAccessible* childHt = child->AsHyperText()) {
|
||||
return childHt->ToTextLeafPoint(
|
||||
aDescendToEnd ? static_cast<int32_t>(childHt->CharacterCount()) : 0,
|
||||
aDescendToEnd);
|
||||
}
|
||||
int32_t offset = aOffset - GetChildOffset(child);
|
||||
return TextLeafPoint(child, offset);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// LocalAccessible public
|
||||
|
||||
|
|
|
@ -326,14 +326,6 @@ class HyperTextAccessible : public AccessibleWrap,
|
|||
*/
|
||||
void RangeAtPoint(int32_t aX, int32_t aY, TextRange& aRange) const;
|
||||
|
||||
/**
|
||||
* Get a TextLeafPoint for a given offset in this HyperTextAccessible.
|
||||
* If the offset points to an embedded object and aDescendToEnd is true,
|
||||
* the point right at the end of this subtree will be returned instead of the
|
||||
* start.
|
||||
*/
|
||||
TextLeafPoint ToTextLeafPoint(int32_t aOffset, bool aDescendToEnd = false);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// EditableTextAccessible
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче