зеркало из https://github.com/mozilla/gecko-dev.git
Bug 855732 - getTextBeforeOffset for word boundaries: evolving, r=tbsaunde
This commit is contained in:
Родитель
4bc0b85925
Коммит
d8a307c8c0
|
@ -781,6 +781,37 @@ HyperTextAccessible::GetRelativeOffset(nsIPresShell* aPresShell,
|
|||
return hyperTextOffset;
|
||||
}
|
||||
|
||||
int32_t
|
||||
HyperTextAccessible::FindWordBoundary(int32_t aOffset, nsDirection aDirection,
|
||||
EWordMovementType aWordMovementType)
|
||||
{
|
||||
// Convert hypertext offset to frame-relative offset.
|
||||
int32_t offsetInFrame = aOffset, notUsedOffset = aOffset;
|
||||
nsRefPtr<Accessible> accAtOffset;
|
||||
nsIFrame* frameAtOffset =
|
||||
GetPosAndText(offsetInFrame, notUsedOffset, nullptr, nullptr,
|
||||
nullptr, getter_AddRefs(accAtOffset));
|
||||
if (!frameAtOffset) {
|
||||
if (aOffset == CharacterCount()) {
|
||||
// Asking for start of line, while on last character.
|
||||
if (accAtOffset)
|
||||
frameAtOffset = accAtOffset->GetFrame();
|
||||
}
|
||||
NS_ASSERTION(frameAtOffset, "No start frame for text getting!");
|
||||
if (!frameAtOffset)
|
||||
return -1;
|
||||
|
||||
// We're on the last continuation since we're on the last character.
|
||||
frameAtOffset = frameAtOffset->GetLastContinuation();
|
||||
}
|
||||
|
||||
// Return hypertext offset of the boundary of the found word.
|
||||
return GetRelativeOffset(mDoc->PresShell(), frameAtOffset, offsetInFrame,
|
||||
accAtOffset, eSelectWord, aDirection,
|
||||
(aWordMovementType == eStartWord),
|
||||
aWordMovementType);
|
||||
}
|
||||
|
||||
/*
|
||||
Gets the specified text relative to aBoundaryType, which means:
|
||||
BOUNDARY_CHAR The character before/at/after the offset is returned.
|
||||
|
@ -973,13 +1004,57 @@ HyperTextAccessible::GetTextBeforeOffset(int32_t aOffset,
|
|||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aBoundaryType == BOUNDARY_CHAR) {
|
||||
GetCharAt(aOffset, eGetBefore, aText, aStartOffset, aEndOffset);
|
||||
int32_t offset = ConvertMagicOffset(aOffset);
|
||||
if (offset < 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
switch (aBoundaryType) {
|
||||
case BOUNDARY_CHAR:
|
||||
GetCharAt(offset, eGetBefore, aText, aStartOffset, aEndOffset);
|
||||
return NS_OK;
|
||||
|
||||
case BOUNDARY_WORD_START: {
|
||||
if (offset == 0) { // no word before 0 offset
|
||||
*aStartOffset = *aEndOffset = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If the offset is a word start then move backward to find start offset
|
||||
// (end offset is the given offset). Otherwise move backward twice to find
|
||||
// both start and end offsets.
|
||||
int32_t midOffset = FindWordBoundary(offset, eDirPrevious, eStartWord);
|
||||
*aEndOffset = FindWordBoundary(midOffset, eDirNext, eStartWord);
|
||||
if (*aEndOffset == offset) {
|
||||
*aStartOffset = midOffset;
|
||||
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||
}
|
||||
|
||||
*aStartOffset = FindWordBoundary(midOffset, eDirPrevious, eStartWord);
|
||||
*aEndOffset = midOffset;
|
||||
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||
}
|
||||
|
||||
case BOUNDARY_WORD_END: {
|
||||
if (offset == 0) { // no word before 0 offset
|
||||
*aStartOffset = *aEndOffset = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Move word backward twice to find start and end offsets.
|
||||
*aEndOffset = FindWordBoundary(offset, eDirPrevious, eEndWord);
|
||||
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
|
||||
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||
}
|
||||
|
||||
case BOUNDARY_LINE_START:
|
||||
case BOUNDARY_LINE_END:
|
||||
case BOUNDARY_ATTRIBUTE_RANGE:
|
||||
return GetTextHelper(eGetBefore, aBoundaryType, aOffset,
|
||||
aStartOffset, aEndOffset, aText);
|
||||
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -991,119 +1066,52 @@ HyperTextAccessible::GetTextAtOffset(int32_t aOffset,
|
|||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsSelectionAmount selectionAmount = eSelectWord;
|
||||
int32_t offset = ConvertMagicOffset(aOffset);
|
||||
if (offset < 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
EWordMovementType wordMovementType = eDefaultBehavior;
|
||||
bool forwardBack = true;
|
||||
bool moveForwardThenBack = true;
|
||||
|
||||
switch (aBoundaryType) {
|
||||
case BOUNDARY_CHAR:
|
||||
return GetCharAt(aOffset, eGetAt, aText, aStartOffset, aEndOffset) ?
|
||||
NS_OK : NS_ERROR_INVALID_ARG;
|
||||
|
||||
case BOUNDARY_WORD_START:
|
||||
wordMovementType = eStartWord;
|
||||
break;
|
||||
|
||||
case BOUNDARY_WORD_END:
|
||||
wordMovementType = eEndWord;
|
||||
forwardBack = false;
|
||||
break;
|
||||
|
||||
case BOUNDARY_LINE_START:
|
||||
case BOUNDARY_LINE_END:
|
||||
return GetTextHelper(eGetAt, aBoundaryType, aOffset,
|
||||
aStartOffset, aEndOffset, aText);
|
||||
break;
|
||||
|
||||
case BOUNDARY_ATTRIBUTE_RANGE:
|
||||
{
|
||||
nsresult rv = GetTextAttributes(false, aOffset,
|
||||
aStartOffset, aEndOffset, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||
}
|
||||
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
int32_t offset = ConvertMagicOffset(aOffset);
|
||||
if (offset < 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
case BOUNDARY_WORD_START: {
|
||||
uint32_t textLen = CharacterCount();
|
||||
if (forwardBack) {
|
||||
if (offset == textLen) {
|
||||
*aStartOffset = *aEndOffset = textLen;
|
||||
return NS_OK;
|
||||
}
|
||||
} else {
|
||||
|
||||
*aEndOffset = FindWordBoundary(offset, eDirNext, eStartWord);
|
||||
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eStartWord);
|
||||
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||
}
|
||||
|
||||
case BOUNDARY_WORD_END: {
|
||||
if (offset == 0) {
|
||||
*aStartOffset = *aEndOffset = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert offsets to frame-relative
|
||||
int32_t startOffset = offset, endOffset = offset;
|
||||
nsRefPtr<Accessible> startAcc;
|
||||
nsIFrame* startFrame = GetPosAndText(startOffset, endOffset, nullptr, nullptr,
|
||||
nullptr, getter_AddRefs(startAcc));
|
||||
if (!startFrame) {
|
||||
if (offset == textLen) {
|
||||
// Asking for start of line, while on last character
|
||||
if (startAcc)
|
||||
startFrame = startAcc->GetFrame();
|
||||
}
|
||||
NS_ASSERTION(startFrame, "No start frame for text getting!");
|
||||
if (!startFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// We're on the last continuation since we're on the last character.
|
||||
startFrame = startFrame->GetLastContinuation();
|
||||
}
|
||||
|
||||
offset = GetRelativeOffset(mDoc->PresShell(), startFrame, startOffset,
|
||||
startAcc, selectionAmount,
|
||||
(forwardBack ? eDirNext : eDirPrevious),
|
||||
forwardBack, wordMovementType);
|
||||
|
||||
if (forwardBack)
|
||||
*aEndOffset = offset;
|
||||
else
|
||||
*aStartOffset = offset;
|
||||
|
||||
startOffset = endOffset = offset;
|
||||
startFrame = GetPosAndText(startOffset, endOffset, nullptr, nullptr,
|
||||
nullptr, getter_AddRefs(startAcc));
|
||||
if (!startFrame) {
|
||||
if (offset == textLen) {
|
||||
// Asking for start of line, while on last character
|
||||
if (startAcc)
|
||||
startFrame = startAcc->GetFrame();
|
||||
}
|
||||
NS_ASSERTION(startFrame, "No start frame for text getting!");
|
||||
if (!startFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// We're on the last continuation since we're on the last character.
|
||||
startFrame = startFrame->GetLastContinuation();
|
||||
}
|
||||
|
||||
offset = GetRelativeOffset(mDoc->PresShell(), startFrame, startOffset,
|
||||
startAcc, selectionAmount,
|
||||
(forwardBack ? eDirPrevious : eDirNext),
|
||||
forwardBack, wordMovementType);
|
||||
|
||||
if (forwardBack)
|
||||
*aStartOffset = offset;
|
||||
else
|
||||
*aEndOffset = offset;
|
||||
|
||||
*aStartOffset = FindWordBoundary(offset, eDirPrevious, eEndWord);
|
||||
*aEndOffset = FindWordBoundary(*aStartOffset, eDirNext, eEndWord);
|
||||
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||
}
|
||||
|
||||
case BOUNDARY_LINE_START:
|
||||
case BOUNDARY_LINE_END:
|
||||
case BOUNDARY_ATTRIBUTE_RANGE:
|
||||
return GetTextHelper(eGetAt, aBoundaryType, aOffset,
|
||||
aStartOffset, aEndOffset, aText);
|
||||
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HyperTextAccessible::GetTextAfterOffset(int32_t aOffset,
|
||||
AccessibleTextBoundary aBoundaryType,
|
||||
|
|
|
@ -263,6 +263,12 @@ protected:
|
|||
return aOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an offset of the found word boundary.
|
||||
*/
|
||||
int32_t FindWordBoundary(int32_t aOffset, nsDirection aDirection,
|
||||
EWordMovementType aWordMovementType);
|
||||
|
||||
/*
|
||||
* This does the work for nsIAccessibleText::GetText[At|Before|After]Offset
|
||||
* @param aType, eGetBefore, eGetAt, eGetAfter
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
function doTest()
|
||||
{
|
||||
SimpleTest.expectAssertions(54);
|
||||
SimpleTest.expectAssertions(44);
|
||||
|
||||
// __o__n__e__w__o__r__d__\n
|
||||
// 0 1 2 3 4 5 6 7
|
||||
|
@ -197,96 +197,36 @@
|
|||
"textarea", kOk, kOk, kOk);
|
||||
|
||||
// BOUNDARY_WORD_START
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"div", kOk, kOk, kOk,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"divbr", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"editablebr", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"divbr", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"editablebr", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_START, "oneword\n\n", 0, 9,
|
||||
"div", kOk, kOk, kOk,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(13, BOUNDARY_WORD_START, "two ", 9, 13,
|
||||
"div", kOk, kOk, kOk,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(18, BOUNDARY_WORD_START, "two ", 9, 13,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(19, BOUNDARY_WORD_START, "two ", 9, 13,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_START, "oneword\n\n", 0, 9, IDs);
|
||||
testTextBeforeOffset(13, BOUNDARY_WORD_START, "two ", 9, 13, IDs);
|
||||
testTextBeforeOffset(18, BOUNDARY_WORD_START, "two ", 9, 13, IDs);
|
||||
testTextBeforeOffset(19, BOUNDARY_WORD_START, "words\n", 13, 19, IDs);
|
||||
|
||||
// BOUNDARY_WORD_END
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"div", kOk, kOk, kOk,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"divbr", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"editablebr", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_END, "oneword", 0, 7,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"div", kOk, kOk, kOk,
|
||||
"divbr", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"editablebr", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_END, "oneword", 0, 7,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"div", kOk, kOk, kOk,
|
||||
"divbr", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"editablebr", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(12, BOUNDARY_WORD_END, "oneword", 0, 7,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(12, BOUNDARY_WORD_END, "oneword", 0, 7, IDs);
|
||||
testTextBeforeOffset(13, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, IDs);
|
||||
testTextBeforeOffset(18, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, IDs);
|
||||
testTextBeforeOffset(19, BOUNDARY_WORD_END, " words", 12, 18,
|
||||
"div", kOk, kOk, kOk,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(13, BOUNDARY_WORD_END, "\n\ntwo", 7, 12,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(18, BOUNDARY_WORD_END, "\n\ntwo", 7, 12,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(19, BOUNDARY_WORD_END, " words", 13, 18,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"editablebr", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
|
||||
|
@ -523,6 +463,16 @@
|
|||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=612331">
|
||||
Bug 612331
|
||||
</a>
|
||||
<a target="_blank"
|
||||
title="getTextAtOffset for word boundaries: beginning of a new life"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=853340">
|
||||
Bug 853340
|
||||
</a>
|
||||
<a target="_blank"
|
||||
title="getTextBeforeOffset for word boundaries: evolving"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=855732">
|
||||
Bug 855732
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
src="../text.js"></script>
|
||||
<script type="application/javascript">
|
||||
if (navigator.platform.startsWith("Mac")) {
|
||||
SimpleTest.expectAssertions(0, 28);
|
||||
SimpleTest.expectAssertions(0, 20);
|
||||
} else {
|
||||
SimpleTest.expectAssertions(28);
|
||||
SimpleTest.expectAssertions(20);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
|
@ -218,108 +218,28 @@
|
|||
testCharBeforeOffset(IDs, 15, "d", 14, 15);
|
||||
|
||||
// BOUNDARY_WORD_START
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(1, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(5, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(6, BOUNDARY_WORD_START, "hello ", 0, 6,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_START, "hello ", 0, 6,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_START, "hello ", 0, 6,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_START, "my ", 6, 9,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(10, BOUNDARY_WORD_START, "my ", 6, 9,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(14, BOUNDARY_WORD_START, "my ", 6, 9,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(15, BOUNDARY_WORD_START, "my ", 6, 9,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(1, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(5, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(6, BOUNDARY_WORD_START, "hello ", 0, 6, IDs);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_START, "hello ", 0, 6, IDs);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_START, "hello ", 0, 6, IDs);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_START, "my ", 6, 9, IDs);
|
||||
testTextBeforeOffset(10, BOUNDARY_WORD_START, "my ", 6, 9, IDs);
|
||||
testTextBeforeOffset(14, BOUNDARY_WORD_START, "my ", 6, 9, IDs);
|
||||
testTextBeforeOffset(15, BOUNDARY_WORD_START, "friend", 9, 15, IDs);
|
||||
|
||||
// BOUNDARY_WORD_END
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(1, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(5, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(6, BOUNDARY_WORD_END, "hello ", 0, 6,
|
||||
"input", kTodo, kTodo, kOk,
|
||||
"div", kTodo, kTodo, kOk,
|
||||
"editable", kTodo, kTodo, kOk,
|
||||
"textarea", kTodo, kTodo, kOk);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_END, "hello ", 0, 6,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_END, "hello ", 0, 6,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_END, " my", 5, 8,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(10, BOUNDARY_WORD_END, " my", 5, 8,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(14, BOUNDARY_WORD_END, " my", 5, 8,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(15, BOUNDARY_WORD_END, " my", 5, 8,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(1, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(5, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(6, BOUNDARY_WORD_END, "hello", 0, 5, IDs);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_END, "hello", 0, 5, IDs);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_END, "hello", 0, 5, IDs);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_END, " my", 5, 8, IDs);
|
||||
testTextBeforeOffset(10, BOUNDARY_WORD_END, " my", 5, 8, IDs);
|
||||
testTextBeforeOffset(14, BOUNDARY_WORD_END, " my", 5, 8, IDs);
|
||||
testTextBeforeOffset(15, BOUNDARY_WORD_END, " my", 5, 8, IDs);
|
||||
|
||||
// BOUNDARY_LINE_START
|
||||
testTextBeforeOffset(0, BOUNDARY_LINE_START, "", 0, 0,
|
||||
|
@ -463,7 +383,19 @@
|
|||
|
||||
<a target="_blank"
|
||||
title="nsIAccessibleText getText related function tests for html:input,html:div and html:textarea"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=452769">Mozilla Bug 452769</a>
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=452769">
|
||||
Bug 452769
|
||||
</a>
|
||||
<a target="_blank"
|
||||
title="getTextAtOffset for word boundaries: beginning of a new life"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=853340">
|
||||
Bug 853340
|
||||
</a>
|
||||
<a target="_blank"
|
||||
title="getTextBeforeOffset for word boundaries: evolving"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=855732">
|
||||
Bug 855732
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
src="../text.js"></script>
|
||||
<script type="application/javascript">
|
||||
if (navigator.platform.startsWith("Mac")) {
|
||||
SimpleTest.expectAssertions(0, 11);
|
||||
SimpleTest.expectAssertions(0, 3);
|
||||
} else {
|
||||
SimpleTest.expectAssertions(11);
|
||||
SimpleTest.expectAssertions(3);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
|
@ -198,163 +198,39 @@
|
|||
testCharBeforeOffset(IDs, 19, " ", 18, 19);
|
||||
|
||||
// BOUNDARY_WORD_START
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(1, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(5, BOUNDARY_WORD_START, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(6, BOUNDARY_WORD_START, "Brave ", 0, 6,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_START, "Brave ", 0, 6,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(10, BOUNDARY_WORD_START, "Brave ", 0, 6,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(11, BOUNDARY_WORD_START, "Sir ", 6, 11,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(15, BOUNDARY_WORD_START, "Sir ", 6, 11,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(16, BOUNDARY_WORD_START, "Sir ", 6, 11,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(17, BOUNDARY_WORD_START, "Sir ", 6, 11,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(18, BOUNDARY_WORD_START, "Sir ", 6, 11,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(19, BOUNDARY_WORD_START, "Robin ", 11, 19,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(20, BOUNDARY_WORD_START, "Robin ", 11, 19,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(21, BOUNDARY_WORD_START, "Robin ", 11, 19,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(1, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(5, BOUNDARY_WORD_START, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(6, BOUNDARY_WORD_START, "Brave ", 0, 6, IDs);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_START, "Brave ", 0, 6, IDs);
|
||||
testTextBeforeOffset(10, BOUNDARY_WORD_START, "Brave ", 0, 6, IDs);
|
||||
testTextBeforeOffset(11, BOUNDARY_WORD_START, "Sir ", 6, 11, IDs);
|
||||
testTextBeforeOffset(15, BOUNDARY_WORD_START, "Sir ", 6, 11, IDs);
|
||||
testTextBeforeOffset(16, BOUNDARY_WORD_START, "Sir ", 6, 11, IDs);
|
||||
testTextBeforeOffset(17, BOUNDARY_WORD_START, "Sir ", 6, 11, IDs);
|
||||
testTextBeforeOffset(18, BOUNDARY_WORD_START, "Sir ", 6, 11, IDs);
|
||||
testTextBeforeOffset(19, BOUNDARY_WORD_START, "Robin ", 11, 19, IDs);
|
||||
testTextBeforeOffset(20, BOUNDARY_WORD_START, "Robin ", 11, 19, IDs);
|
||||
testTextBeforeOffset(21, BOUNDARY_WORD_START, "Robin ", 11, 19, IDs);
|
||||
|
||||
// BOUNDARY_WORD_END
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"input", kOk, kOk, kOk,
|
||||
"div", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
testTextBeforeOffset(1, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(4, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(5, BOUNDARY_WORD_END, "", 0, 0,
|
||||
"input", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextBeforeOffset(6, BOUNDARY_WORD_END, "Brave", 0, 5,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_END, "Brave", 0, 5,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_END, "Brave", 0, 5,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_END, "Brave", 0, 5,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(10, BOUNDARY_WORD_END, " Sir", 5, 9,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(11, BOUNDARY_WORD_END, " Sir", 5, 9,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(15, BOUNDARY_WORD_END, " Sir", 5, 9,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(16, BOUNDARY_WORD_END, " Sir", 5, 9,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(17, BOUNDARY_WORD_END, " Robin", 9, 16,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(18, BOUNDARY_WORD_END, " Robin", 9, 16,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(19, BOUNDARY_WORD_END, " Robin", 9, 16,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(21, BOUNDARY_WORD_END, " Robin", 9, 16,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(22, BOUNDARY_WORD_END, " Robin", 9, 16,
|
||||
"input", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextBeforeOffset(0, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(1, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(4, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(5, BOUNDARY_WORD_END, "", 0, 0, IDs);
|
||||
testTextBeforeOffset(6, BOUNDARY_WORD_END, "Brave", 0, 5, IDs);
|
||||
testTextBeforeOffset(7, BOUNDARY_WORD_END, "Brave", 0, 5, IDs);
|
||||
testTextBeforeOffset(8, BOUNDARY_WORD_END, "Brave", 0, 5, IDs);
|
||||
testTextBeforeOffset(9, BOUNDARY_WORD_END, "Brave", 0, 5, IDs);
|
||||
testTextBeforeOffset(10, BOUNDARY_WORD_END, " Sir", 5, 9, IDs);
|
||||
testTextBeforeOffset(11, BOUNDARY_WORD_END, " Sir", 5, 9, IDs);
|
||||
testTextBeforeOffset(15, BOUNDARY_WORD_END, " Sir", 5, 9, IDs);
|
||||
testTextBeforeOffset(16, BOUNDARY_WORD_END, " Sir", 5, 9, IDs);
|
||||
testTextBeforeOffset(17, BOUNDARY_WORD_END, " Robin", 9, 16, IDs);
|
||||
testTextBeforeOffset(18, BOUNDARY_WORD_END, " Robin", 9, 16, IDs);
|
||||
testTextBeforeOffset(19, BOUNDARY_WORD_END, " Robin", 9, 16, IDs);
|
||||
testTextBeforeOffset(21, BOUNDARY_WORD_END, " Robin", 9, 16, IDs);
|
||||
testTextBeforeOffset(22, BOUNDARY_WORD_END, " Robin", 9, 16, IDs);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// getTextAtOffset
|
||||
|
@ -492,7 +368,19 @@
|
|||
|
||||
<a target="_blank"
|
||||
title="getText... methods tests on string with whitespaces for plain text containers"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=610568">Mozilla Bug 610568</a>
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=610568">
|
||||
Bug 610568
|
||||
</a>
|
||||
<a target="_blank"
|
||||
title="getTextAtOffset for word boundaries: beginning of a new life"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=853340">
|
||||
Bug 853340
|
||||
</a>
|
||||
<a target="_blank"
|
||||
title="getTextBeforeOffset for word boundaries: evolving"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=855732">
|
||||
Bug 855732
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
|
|
Загрузка…
Ссылка в новой задаче