mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1679075 - Don't go past empty input field in HyperTextIterator::Next. r=morgan
The normalize function was putting the current container/offset past the end boundary. This caused overruns with getting the text for the range of the input object, and some unexpected invalid ranges. Differential Revision: https://phabricator.services.mozilla.com/D98236
This commit is contained in:
parent
f6cf2a4d4c
commit
c86df09ea1
@ -79,6 +79,12 @@ bool HyperTextIterator::NormalizeForward() {
|
||||
mCurrentContainer = mCurrentContainer->Parent()->AsHyperText();
|
||||
mCurrentStartOffset = endOffset;
|
||||
|
||||
if (mCurrentContainer == mEndContainer &&
|
||||
mCurrentStartOffset >= mEndOffset) {
|
||||
// Reached end boundary.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Call NormalizeForward recursively to get top-most link if at the end of
|
||||
// one, or innermost link if at the beginning.
|
||||
NormalizeForward();
|
||||
@ -98,6 +104,12 @@ bool HyperTextIterator::NormalizeForward() {
|
||||
mCurrentStartOffset = 0;
|
||||
}
|
||||
|
||||
if (mCurrentContainer == mEndContainer &&
|
||||
mCurrentStartOffset >= mEndOffset) {
|
||||
// Reached end boundary.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Call NormalizeForward recursively to get top-most embedding ancestor
|
||||
// if at the end of one, or innermost link if at the beginning.
|
||||
NormalizeForward();
|
||||
|
@ -171,10 +171,8 @@ inline NSString* ToNSString(id aValue) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
GeckoTextMarker startMarker =
|
||||
GeckoTextMarker::MarkerFromIndex(mGeckoAccessible, 0);
|
||||
|
||||
GeckoTextMarkerRange fromStartToSelection(startMarker, selection.mStart);
|
||||
GeckoTextMarkerRange fromStartToSelection(
|
||||
GeckoTextMarker(mGeckoAccessible, 0), selection.mStart);
|
||||
|
||||
return [NSValue valueWithRange:NSMakeRange(fromStartToSelection.Length(),
|
||||
selection.Length())];
|
||||
@ -268,6 +266,10 @@ inline NSString* ToNSString(id aValue) {
|
||||
- (NSString*)moxStringForRange:(NSValue*)range {
|
||||
GeckoTextMarkerRange markerRange = [self textMarkerRangeFromRange:range];
|
||||
|
||||
if (!markerRange.IsValid()) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return markerRange.Text();
|
||||
}
|
||||
|
||||
|
@ -245,3 +245,21 @@ addAccessibleTask(
|
||||
is(stringForRange(macDoc, range), "ello good");
|
||||
}
|
||||
);
|
||||
|
||||
addAccessibleTask(
|
||||
`<input id="input" value=""><a href="#">goodbye</a>`,
|
||||
async (browser, accDoc) => {
|
||||
let macDoc = accDoc.nativeInterface.QueryInterface(
|
||||
Ci.nsIAccessibleMacInterface
|
||||
);
|
||||
|
||||
let input = getNativeInterface(accDoc, "input");
|
||||
|
||||
let range = macDoc.getParameterizedAttributeValue(
|
||||
"AXTextMarkerRangeForUIElement",
|
||||
input
|
||||
);
|
||||
|
||||
is(stringForRange(macDoc, range), "", "string value is correct");
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user