зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1661758 - Part 4: Implement AXUIElementForTextMarker. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D89066
This commit is contained in:
Родитель
0ced3240bb
Коммит
debfb84ee9
|
@ -182,6 +182,17 @@ mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvRangeOfChild(
|
||||||
|
|
||||||
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvLeafAtOffset(
|
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvLeafAtOffset(
|
||||||
const uint64_t& aID, const int32_t& aOffset, uint64_t* aLeaf) {
|
const uint64_t& aID, const int32_t& aOffset, uint64_t* aLeaf) {
|
||||||
|
HyperTextAccessibleWrap* acc = IdToHyperTextAccessibleWrap(aID);
|
||||||
|
if (!acc) {
|
||||||
|
return IPC_OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
Accessible* leaf = acc->LeafAtOffset(aOffset);
|
||||||
|
|
||||||
|
MOZ_ASSERT(!leaf || leaf->Document() == acc->Document());
|
||||||
|
|
||||||
|
*aLeaf = UNIQUE_ID(leaf);
|
||||||
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ class GeckoTextMarker final {
|
||||||
// Return a word range right of the given offset.
|
// Return a word range right of the given offset.
|
||||||
GeckoTextMarkerRange RightWordRange();
|
GeckoTextMarkerRange RightWordRange();
|
||||||
|
|
||||||
|
AccessibleOrProxy Leaf();
|
||||||
|
|
||||||
bool IsValid() const { return !mContainer.IsNull(); };
|
bool IsValid() const { return !mContainer.IsNull(); };
|
||||||
|
|
||||||
bool operator<(const GeckoTextMarker& aPoint) const;
|
bool operator<(const GeckoTextMarker& aPoint) const;
|
||||||
|
|
|
@ -269,6 +269,21 @@ GeckoTextMarkerRange GeckoTextMarker::RightWordRange() {
|
||||||
return GeckoTextMarkerRange(GeckoTextMarker(), GeckoTextMarker());
|
return GeckoTextMarkerRange(GeckoTextMarker(), GeckoTextMarker());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AccessibleOrProxy GeckoTextMarker::Leaf() {
|
||||||
|
MOZ_ASSERT(!mContainer.IsNull());
|
||||||
|
if (mContainer.IsProxy()) {
|
||||||
|
uint64_t leafID = 0;
|
||||||
|
DocAccessibleParent* ipcDoc = mContainer.AsProxy()->Document();
|
||||||
|
Unused << ipcDoc->GetPlatformExtension()->SendLeafAtOffset(
|
||||||
|
mContainer.AsProxy()->ID(), mOffset, &leafID);
|
||||||
|
return ipcDoc->GetAccessible(leafID);
|
||||||
|
} else if (auto htWrap = ContainerAsHyperTextWrap()) {
|
||||||
|
return htWrap->LeafAtOffset(mOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mContainer;
|
||||||
|
}
|
||||||
|
|
||||||
// GeckoTextMarkerRange
|
// GeckoTextMarkerRange
|
||||||
|
|
||||||
GeckoTextMarkerRange::GeckoTextMarkerRange(
|
GeckoTextMarkerRange::GeckoTextMarkerRange(
|
||||||
|
|
|
@ -49,6 +49,8 @@ class HyperTextAccessibleWrap : public HyperTextAccessible {
|
||||||
void RangeOfChild(Accessible* aChild, int32_t* aStartOffset,
|
void RangeOfChild(Accessible* aChild, int32_t* aStartOffset,
|
||||||
int32_t* aEndOffset);
|
int32_t* aEndOffset);
|
||||||
|
|
||||||
|
Accessible* LeafAtOffset(int32_t aOffset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~HyperTextAccessibleWrap() {}
|
~HyperTextAccessibleWrap() {}
|
||||||
|
|
||||||
|
|
|
@ -365,6 +365,29 @@ void HyperTextAccessibleWrap::RangeOfChild(Accessible* aChild,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Accessible* HyperTextAccessibleWrap::LeafAtOffset(int32_t aOffset) {
|
||||||
|
HyperTextAccessible* text = this;
|
||||||
|
Accessible* child = nullptr;
|
||||||
|
int32_t innerOffset = aOffset;
|
||||||
|
do {
|
||||||
|
int32_t childIdx = text->GetChildIndexAtOffset(innerOffset);
|
||||||
|
if (childIdx == -1) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
child = text->GetChildAt(childIdx);
|
||||||
|
if (!child || nsAccUtils::MustPrune(child)) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
innerOffset -= text->GetChildOffset(childIdx);
|
||||||
|
|
||||||
|
text = child->AsHyperText();
|
||||||
|
} while (text);
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
TextPoint HyperTextAccessibleWrap::FindTextPoint(
|
TextPoint HyperTextAccessibleWrap::FindTextPoint(
|
||||||
int32_t aOffset, nsDirection aDirection, nsSelectionAmount aAmount,
|
int32_t aOffset, nsDirection aDirection, nsSelectionAmount aAmount,
|
||||||
EWordMovementType aWordMovementType) {
|
EWordMovementType aWordMovementType) {
|
||||||
|
|
|
@ -398,6 +398,9 @@
|
||||||
// AXTextMarkerForIndex
|
// AXTextMarkerForIndex
|
||||||
- (id _Nullable)moxTextMarkerForIndex:(NSNumber* _Nonnull)index;
|
- (id _Nullable)moxTextMarkerForIndex:(NSNumber* _Nonnull)index;
|
||||||
|
|
||||||
|
// AXUIElementForTextMarker
|
||||||
|
- (id _Nullable)moxUIElementForTextMarker:(id _Nonnull)textMarker;
|
||||||
|
|
||||||
// AXTextMarkerRangeForUIElement
|
// AXTextMarkerRangeForUIElement
|
||||||
- (id _Nullable)moxTextMarkerRangeForUIElement:(id _Nonnull)element;
|
- (id _Nullable)moxTextMarkerRangeForUIElement:(id _Nonnull)element;
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,9 @@
|
||||||
// override
|
// override
|
||||||
- (NSValue*)moxBoundsForTextMarkerRange:(id)textMarkerRange;
|
- (NSValue*)moxBoundsForTextMarkerRange:(id)textMarkerRange;
|
||||||
|
|
||||||
|
// override
|
||||||
|
- (id)moxUIElementForTextMarker:(id)textMarker;
|
||||||
|
|
||||||
// override
|
// override
|
||||||
- (id)moxTextMarkerRangeForUIElement:(id)element;
|
- (id)moxTextMarkerRangeForUIElement:(id)element;
|
||||||
|
|
||||||
|
|
|
@ -243,6 +243,15 @@ static nsDataHashtable<nsUint64HashKey, MOXTextMarkerDelegate*> sDelegates;
|
||||||
return geckoTextMarker.CreateAXTextMarker();
|
return geckoTextMarker.CreateAXTextMarker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id)moxUIElementForTextMarker:(id)textMarker {
|
||||||
|
GeckoTextMarker geckoTextMarker(mGeckoDocAccessible, textMarker);
|
||||||
|
if (!geckoTextMarker.IsValid()) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetNativeFromGeckoAccessible(geckoTextMarker.Leaf());
|
||||||
|
}
|
||||||
|
|
||||||
- (id)moxTextMarkerRangeForUIElement:(id)element {
|
- (id)moxTextMarkerRangeForUIElement:(id)element {
|
||||||
if (![element isKindOfClass:[mozAccessible class]]) {
|
if (![element isKindOfClass:[mozAccessible class]]) {
|
||||||
return nil;
|
return nil;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче