зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1661758 - Part 3: Implement AXTextMarkerRangeForUIElement. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D89065
This commit is contained in:
Родитель
1959904dc6
Коммит
237178d7dd
|
@ -169,6 +169,14 @@ mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvOffsetAtIndex(
|
|||
mozilla::ipc::IPCResult DocAccessiblePlatformExtChild::RecvRangeOfChild(
|
||||
const uint64_t& aID, const uint64_t& aChild, int32_t* aStartOffset,
|
||||
int32_t* aEndOffset) {
|
||||
HyperTextAccessibleWrap* acc = IdToHyperTextAccessibleWrap(aID);
|
||||
Accessible* child =
|
||||
static_cast<DocAccessibleChild*>(Manager())->IdToAccessible(aChild);
|
||||
if (!acc || !child) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
acc->RangeOfChild(child, aStartOffset, aEndOffset);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,8 @@ class GeckoTextMarkerRange final {
|
|||
GeckoTextMarkerRange(AccessibleOrProxy aDoc,
|
||||
AXTextMarkerRangeRef aTextMarkerRange);
|
||||
|
||||
explicit GeckoTextMarkerRange(const AccessibleOrProxy& aAccessible);
|
||||
|
||||
id CreateAXTextMarkerRange();
|
||||
|
||||
bool IsValid() const {
|
||||
|
|
|
@ -288,6 +288,21 @@ GeckoTextMarkerRange::GeckoTextMarkerRange(
|
|||
CFRelease(end_marker);
|
||||
}
|
||||
|
||||
GeckoTextMarkerRange::GeckoTextMarkerRange(
|
||||
const AccessibleOrProxy& aAccessible) {
|
||||
mStart = GeckoTextMarker(aAccessible.Parent(), 0);
|
||||
mEnd = GeckoTextMarker(aAccessible.Parent(), 0);
|
||||
if (mStart.mContainer.IsProxy()) {
|
||||
DocAccessibleParent* ipcDoc = mStart.mContainer.AsProxy()->Document();
|
||||
Unused << ipcDoc->GetPlatformExtension()->SendRangeOfChild(
|
||||
mStart.mContainer.AsProxy()->ID(), aAccessible.AsProxy()->ID(),
|
||||
&mStart.mOffset, &mEnd.mOffset);
|
||||
} else if (auto htWrap = mStart.ContainerAsHyperTextWrap()) {
|
||||
htWrap->RangeOfChild(aAccessible.AsAccessible(), &mStart.mOffset,
|
||||
&mEnd.mOffset);
|
||||
}
|
||||
}
|
||||
|
||||
id GeckoTextMarkerRange::CreateAXTextMarkerRange() {
|
||||
AXTextMarkerRangeRef cf_text_marker_range =
|
||||
AXTextMarkerRangeCreate(kCFAllocatorDefault, mStart.CreateAXTextMarker(),
|
||||
|
|
|
@ -46,6 +46,9 @@ class HyperTextAccessibleWrap : public HyperTextAccessible {
|
|||
void PreviousClusterAt(int32_t aOffset, HyperTextAccessible** aPrevContainer,
|
||||
int32_t* aPrevOffset);
|
||||
|
||||
void RangeOfChild(Accessible* aChild, int32_t* aStartOffset,
|
||||
int32_t* aEndOffset);
|
||||
|
||||
protected:
|
||||
~HyperTextAccessibleWrap() {}
|
||||
|
||||
|
|
|
@ -351,6 +351,20 @@ void HyperTextAccessibleWrap::PreviousClusterAt(
|
|||
*aPrevOffset = prev.mOffset;
|
||||
}
|
||||
|
||||
void HyperTextAccessibleWrap::RangeOfChild(Accessible* aChild,
|
||||
int32_t* aStartOffset,
|
||||
int32_t* aEndOffset) {
|
||||
MOZ_ASSERT(aChild->Parent() == this);
|
||||
*aStartOffset = *aEndOffset = -1;
|
||||
int32_t index = GetIndexOf(aChild);
|
||||
if (index != -1) {
|
||||
*aStartOffset = GetChildOffset(index);
|
||||
// If this is the last child index + 1 will return the total
|
||||
// chracter count.
|
||||
*aEndOffset = GetChildOffset(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TextPoint HyperTextAccessibleWrap::FindTextPoint(
|
||||
int32_t aOffset, nsDirection aDirection, nsSelectionAmount aAmount,
|
||||
EWordMovementType aWordMovementType) {
|
||||
|
|
|
@ -398,4 +398,7 @@
|
|||
// AXTextMarkerForIndex
|
||||
- (id _Nullable)moxTextMarkerForIndex:(NSNumber* _Nonnull)index;
|
||||
|
||||
// AXTextMarkerRangeForUIElement
|
||||
- (id _Nullable)moxTextMarkerRangeForUIElement:(id _Nonnull)element;
|
||||
|
||||
@end
|
||||
|
|
|
@ -74,4 +74,7 @@
|
|||
// override
|
||||
- (NSValue*)moxBoundsForTextMarkerRange:(id)textMarkerRange;
|
||||
|
||||
// override
|
||||
- (id)moxTextMarkerRangeForUIElement:(id)element;
|
||||
|
||||
@end
|
||||
|
|
|
@ -243,4 +243,13 @@ static nsDataHashtable<nsUint64HashKey, MOXTextMarkerDelegate*> sDelegates;
|
|||
return geckoTextMarker.CreateAXTextMarker();
|
||||
}
|
||||
|
||||
- (id)moxTextMarkerRangeForUIElement:(id)element {
|
||||
if (![element isKindOfClass:[mozAccessible class]]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
GeckoTextMarkerRange range([element geckoAccessible]);
|
||||
return range.CreateAXTextMarkerRange();
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Загрузка…
Ссылка в новой задаче