mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 877974 - reorg getTextAtOffset for line boundary, r=tbsaunde
This commit is contained in:
parent
fd9b995e51
commit
e330d68c2a
@ -782,8 +782,9 @@ HyperTextAccessible::GetRelativeOffset(nsIPresShell* aPresShell,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
HyperTextAccessible::FindWordBoundary(int32_t aOffset, nsDirection aDirection,
|
HyperTextAccessible::FindBoundary(int32_t aOffset, nsDirection aDirection,
|
||||||
EWordMovementType aWordMovementType)
|
nsSelectionAmount aAmount,
|
||||||
|
EWordMovementType aWordMovementType)
|
||||||
{
|
{
|
||||||
// Convert hypertext offset to frame-relative offset.
|
// Convert hypertext offset to frame-relative offset.
|
||||||
int32_t offsetInFrame = aOffset, notUsedOffset = aOffset;
|
int32_t offsetInFrame = aOffset, notUsedOffset = aOffset;
|
||||||
@ -807,8 +808,8 @@ HyperTextAccessible::FindWordBoundary(int32_t aOffset, nsDirection aDirection,
|
|||||||
|
|
||||||
// Return hypertext offset of the boundary of the found word.
|
// Return hypertext offset of the boundary of the found word.
|
||||||
return GetRelativeOffset(mDoc->PresShell(), frameAtOffset, offsetInFrame,
|
return GetRelativeOffset(mDoc->PresShell(), frameAtOffset, offsetInFrame,
|
||||||
accAtOffset, eSelectWord, aDirection,
|
accAtOffset, aAmount, aDirection,
|
||||||
(aWordMovementType == eStartWord),
|
(aWordMovementType == eStartWord || aAmount == eSelectBeginLine),
|
||||||
aWordMovementType);
|
aWordMovementType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1080,8 +1081,29 @@ HyperTextAccessible::GetTextAtOffset(int32_t aOffset,
|
|||||||
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
|
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
|
||||||
return GetText(*aStartOffset, *aEndOffset, aText);
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||||
|
|
||||||
case BOUNDARY_LINE_START:
|
case BOUNDARY_LINE_START: {
|
||||||
case BOUNDARY_LINE_END:
|
// Home key, arrow down and if not on last line then home key.
|
||||||
|
*aStartOffset = FindLineBoundary(offset, eDirPrevious, eSelectBeginLine);
|
||||||
|
*aEndOffset = FindLineBoundary(offset, eDirNext, eSelectLine);
|
||||||
|
int32_t tmpOffset = FindLineBoundary(*aEndOffset, eDirPrevious, eSelectBeginLine);
|
||||||
|
if (tmpOffset != *aStartOffset)
|
||||||
|
*aEndOffset = tmpOffset;
|
||||||
|
|
||||||
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||||
|
}
|
||||||
|
|
||||||
|
case BOUNDARY_LINE_END: {
|
||||||
|
// In contrast to word end boundary we follow the spec here. End key,
|
||||||
|
// then up arrow and if not on first line then end key.
|
||||||
|
*aEndOffset = FindLineBoundary(offset, eDirNext, eSelectEndLine);
|
||||||
|
int32_t tmpOffset = FindLineBoundary(offset, eDirPrevious, eSelectLine);
|
||||||
|
*aStartOffset = FindLineBoundary(tmpOffset, eDirNext, eSelectEndLine);
|
||||||
|
if (*aStartOffset == *aEndOffset)
|
||||||
|
*aStartOffset = 0;
|
||||||
|
|
||||||
|
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||||
|
}
|
||||||
|
|
||||||
case BOUNDARY_ATTRIBUTE_RANGE:
|
case BOUNDARY_ATTRIBUTE_RANGE:
|
||||||
return GetTextHelper(eGetAt, aBoundaryType, aOffset,
|
return GetTextHelper(eGetAt, aBoundaryType, aOffset,
|
||||||
aStartOffset, aEndOffset, aText);
|
aStartOffset, aEndOffset, aText);
|
||||||
|
@ -267,7 +267,26 @@ protected:
|
|||||||
* Return an offset of the found word boundary.
|
* Return an offset of the found word boundary.
|
||||||
*/
|
*/
|
||||||
int32_t FindWordBoundary(int32_t aOffset, nsDirection aDirection,
|
int32_t FindWordBoundary(int32_t aOffset, nsDirection aDirection,
|
||||||
EWordMovementType aWordMovementType);
|
EWordMovementType aWordMovementType)
|
||||||
|
{
|
||||||
|
return FindBoundary(aOffset, aDirection, eSelectWord, aWordMovementType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an offset of the found line boundary.
|
||||||
|
*/
|
||||||
|
int32_t FindLineBoundary(int32_t aOffset, nsDirection aDirection,
|
||||||
|
nsSelectionAmount aAmount)
|
||||||
|
{
|
||||||
|
return FindBoundary(aOffset, aDirection, aAmount, eDefaultBehavior);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an offset of the found word or line boundary. Helper.
|
||||||
|
*/
|
||||||
|
int32_t FindBoundary(int32_t aOffset, nsDirection aDirection,
|
||||||
|
nsSelectionAmount aAmount,
|
||||||
|
EWordMovementType aWordMovementType = eDefaultBehavior);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This does the work for nsIAccessibleText::GetText[At|Before|After]Offset
|
* This does the work for nsIAccessibleText::GetText[At|Before|After]Offset
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
"textarea", kTodo, kTodo, kOk);
|
"textarea", kTodo, kTodo, kOk);
|
||||||
|
|
||||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "words", 10, 15,
|
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "words", 10, 15,
|
||||||
"textarea", kTodo, kTodo, kTodo);
|
"textarea", kTodo, kTodo, kOk);
|
||||||
|
|
||||||
testTextBeforeOffset(kCaretOffset, BOUNDARY_LINE_START, "words", 10, 15,
|
testTextBeforeOffset(kCaretOffset, BOUNDARY_LINE_START, "words", 10, 15,
|
||||||
"textarea", kOk, kOk, kOk);
|
"textarea", kOk, kOk, kOk);
|
||||||
@ -113,7 +113,7 @@
|
|||||||
"textarea", kOk, kOk, kOk);
|
"textarea", kOk, kOk, kOk);
|
||||||
|
|
||||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "\ntwo ", 5, 10,
|
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "\ntwo ", 5, 10,
|
||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kTodo, kTodo, kTodo);
|
||||||
|
|
||||||
testTextBeforeOffset(kCaretOffset, BOUNDARY_LINE_START, "aword\n", 0, 6,
|
testTextBeforeOffset(kCaretOffset, BOUNDARY_LINE_START, "aword\n", 0, 6,
|
||||||
"textarea", kTodo, kTodo, kOk);
|
"textarea", kTodo, kTodo, kOk);
|
||||||
@ -141,7 +141,7 @@
|
|||||||
"textarea", kTodo, kTodo, kOk);
|
"textarea", kTodo, kTodo, kOk);
|
||||||
|
|
||||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "two ", 6, 10,
|
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "two ", 6, 10,
|
||||||
"textarea", kOk, kOk, kOk);
|
"textarea", kTodo, kTodo, kTodo);
|
||||||
|
|
||||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "\ntwo ", 5, 10,
|
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "\ntwo ", 5, 10,
|
||||||
"textarea", kTodo, kTodo, kTodo);
|
"textarea", kTodo, kTodo, kTodo);
|
||||||
@ -172,7 +172,7 @@
|
|||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kTodo, kOk, kTodo);
|
||||||
|
|
||||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "aword\n", 0, 6,
|
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "aword\n", 0, 6,
|
||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kOk, kOk, kOk);
|
||||||
|
|
||||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "", 0, 0,
|
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "", 0, 0,
|
||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kTodo, kOk, kTodo);
|
||||||
@ -203,10 +203,10 @@
|
|||||||
"textarea", kTodo, kTodo, kTodo);
|
"textarea", kTodo, kTodo, kTodo);
|
||||||
|
|
||||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "aword\n", 0, 6,
|
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "aword\n", 0, 6,
|
||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kOk, kOk, kOk);
|
||||||
|
|
||||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "aword", 0, 5,
|
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "aword", 0, 5,
|
||||||
"textarea", kOk, kOk, kOk);
|
"textarea", kTodo, kOk, kTodo);
|
||||||
|
|
||||||
testTextBeforeOffset(kCaretOffset, BOUNDARY_LINE_START, "", 0, 0,
|
testTextBeforeOffset(kCaretOffset, BOUNDARY_LINE_START, "", 0, 0,
|
||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kTodo, kOk, kTodo);
|
||||||
@ -224,7 +224,7 @@
|
|||||||
var gQueue = null;
|
var gQueue = null;
|
||||||
function doTest()
|
function doTest()
|
||||||
{
|
{
|
||||||
SimpleTest.expectAssertions(7);
|
SimpleTest.expectAssertions(6);
|
||||||
|
|
||||||
gQueue = new eventQueue();
|
gQueue = new eventQueue();
|
||||||
gQueue.push(new moveToLastLineEnd());
|
gQueue.push(new moveToLastLineEnd());
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
function doTest()
|
function doTest()
|
||||||
{
|
{
|
||||||
SimpleTest.expectAssertions(46);
|
SimpleTest.expectAssertions(38);
|
||||||
|
|
||||||
// __o__n__e__w__o__r__d__\n
|
// __o__n__e__w__o__r__d__\n
|
||||||
// 0 1 2 3 4 5 6 7
|
// 0 1 2 3 4 5 6 7
|
||||||
@ -180,48 +180,18 @@
|
|||||||
// getTextAtOffset
|
// getTextAtOffset
|
||||||
|
|
||||||
// BOUNDARY_LINE_START
|
// BOUNDARY_LINE_START
|
||||||
testTextAtOffset(0, BOUNDARY_LINE_START, "oneword\n", 0, 8,
|
testTextAtOffset(0, BOUNDARY_LINE_START, "oneword\n", 0, 8, IDs);
|
||||||
"div", kTodo, kOk, kTodo,
|
testTextAtOffset(7, BOUNDARY_LINE_START, "oneword\n", 0, 8, IDs);
|
||||||
"divbr", kOk, kOk, kOk,
|
testTextAtOffset(8, BOUNDARY_LINE_START, "\n", 8, 9, IDs);
|
||||||
"editable", kTodo, kOk, kTodo,
|
testTextAtOffset(9, BOUNDARY_LINE_START, "two words\n", 9, 19, IDs);
|
||||||
"editablebr", kOk, kOk, kOk,
|
testTextAtOffset(13, BOUNDARY_LINE_START, "two words\n", 9, 19, IDs);
|
||||||
"textarea", kTodo, kOk, kTodo);
|
testTextAtOffset(18, BOUNDARY_LINE_START, "two words\n", 9, 19, IDs);
|
||||||
testTextAtOffset(7, BOUNDARY_LINE_START, "oneword\n", 0, 8,
|
|
||||||
"div", kOk, kOk, kOk,
|
|
||||||
"divbr", kOk, kOk, kOk,
|
|
||||||
"editable", kOk, kOk, kOk,
|
|
||||||
"editablebr", kOk, kOk, kOk,
|
|
||||||
"textarea", kOk, kOk, kOk);
|
|
||||||
testTextAtOffset(8, BOUNDARY_LINE_START, "\n", 8, 9,
|
|
||||||
"div", kOk, kOk, kOk,
|
|
||||||
"divbr", kOk, kOk, kOk,
|
|
||||||
"editable", kOk, kOk, kOk,
|
|
||||||
"editablebr", kOk, kOk, kOk,
|
|
||||||
"textarea", kOk, kOk, kOk);
|
|
||||||
testTextAtOffset(9, BOUNDARY_LINE_START, "two words\n", 9, 19,
|
|
||||||
"div", kTodo, kOk, kTodo,
|
|
||||||
"divbr", kOk, kOk, kOk,
|
|
||||||
"editable", kTodo, kOk, kTodo,
|
|
||||||
"editablebr", kOk, kOk, kOk,
|
|
||||||
"textarea", kTodo, kOk, kTodo);
|
|
||||||
testTextAtOffset(13, BOUNDARY_LINE_START, "two words\n", 9, 19,
|
|
||||||
"div", kTodo, kOk, kTodo,
|
|
||||||
"divbr", kOk, kOk, kOk,
|
|
||||||
"editable", kTodo, kOk, kTodo,
|
|
||||||
"editablebr", kOk, kOk, kOk,
|
|
||||||
"textarea", kTodo, kOk, kTodo);
|
|
||||||
testTextAtOffset(18, BOUNDARY_LINE_START, "two words\n", 9, 19,
|
|
||||||
"div", kOk, kOk, kOk,
|
|
||||||
"divbr", kOk, kOk, kOk,
|
|
||||||
"editable", kOk, kOk, kOk,
|
|
||||||
"editablebr", kOk, kOk, kOk,
|
|
||||||
"textarea", kOk, kOk, kOk);
|
|
||||||
testTextAtOffset(19, BOUNDARY_LINE_START, "", 19, 19,
|
testTextAtOffset(19, BOUNDARY_LINE_START, "", 19, 19,
|
||||||
"div", kTodo, kTodo, kTodo,
|
"div", kTodo, kTodo, kOk,
|
||||||
"divbr", kTodo, kTodo, kOk,
|
"divbr", kTodo, kTodo, kOk,
|
||||||
"editable", kTodo, kTodo, kTodo,
|
"editable", kTodo, kTodo, kOk,
|
||||||
"editablebr", kTodo, kTodo, kOk,
|
"editablebr", kTodo, kTodo, kOk,
|
||||||
"textarea", kTodo, kTodo, kTodo);
|
"textarea", kTodo, kTodo, kOk);
|
||||||
|
|
||||||
// BOUNDARY_LINE_END
|
// BOUNDARY_LINE_END
|
||||||
testTextAtOffset(0, BOUNDARY_LINE_END, "oneword", 0, 7,
|
testTextAtOffset(0, BOUNDARY_LINE_END, "oneword", 0, 7,
|
||||||
@ -231,35 +201,35 @@
|
|||||||
"editablebr", kOk, kOk, kOk,
|
"editablebr", kOk, kOk, kOk,
|
||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kTodo, kOk, kTodo);
|
||||||
testTextAtOffset(7, BOUNDARY_LINE_END, "oneword", 0, 7,
|
testTextAtOffset(7, BOUNDARY_LINE_END, "oneword", 0, 7,
|
||||||
"div", kTodo, kTodo, kTodo,
|
"div", kTodo, kOk, kTodo,
|
||||||
"divbr", kTodo, kTodo, kTodo,
|
"divbr", kOk, kOk, kOk,
|
||||||
"editable", kTodo, kTodo, kTodo,
|
"editable", kTodo, kOk, kTodo,
|
||||||
"editablebr", kTodo, kTodo, kTodo,
|
"editablebr", kOk, kOk, kOk,
|
||||||
"textarea", kTodo, kTodo, kTodo);
|
"textarea", kTodo, kOk, kTodo);
|
||||||
testTextAtOffset(8, BOUNDARY_LINE_END, "\n", 7, 8,
|
testTextAtOffset(8, BOUNDARY_LINE_END, "\n", 7, 8,
|
||||||
"div", kTodo, kTodo, kTodo,
|
"div", kTodo, kTodo, kTodo,
|
||||||
"divbr", kTodo, kTodo, kTodo,
|
"divbr", kOk, kOk, kOk,
|
||||||
"editable", kTodo, kTodo, kTodo,
|
"editable", kTodo, kTodo, kTodo,
|
||||||
"editablebr", kTodo, kTodo, kTodo,
|
"editablebr", kOk, kOk, kOk,
|
||||||
"textarea", kTodo, kTodo, kTodo);
|
"textarea", kTodo, kTodo, kTodo);
|
||||||
testTextAtOffset(9, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
testTextAtOffset(9, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
||||||
"div", kTodo, kOk, kTodo,
|
"div", kTodo, kTodo, kTodo,
|
||||||
"divbr", kOk, kOk, kOk,
|
"divbr", kOk, kOk, kOk,
|
||||||
"editable", kTodo, kOk, kTodo,
|
"editable", kTodo, kTodo, kTodo,
|
||||||
"editablebr", kOk, kOk, kOk,
|
"editablebr", kOk, kOk, kOk,
|
||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kTodo, kTodo, kTodo);
|
||||||
testTextAtOffset(17, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
testTextAtOffset(17, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
||||||
"div", kOk, kOk, kOk,
|
"div", kTodo, kTodo, kTodo,
|
||||||
"divbr", kOk, kOk, kOk,
|
"divbr", kOk, kOk, kOk,
|
||||||
"editable", kOk, kOk, kOk,
|
"editable", kTodo, kTodo, kTodo,
|
||||||
"editablebr", kOk, kOk, kOk,
|
"editablebr", kOk, kOk, kOk,
|
||||||
"textarea", kOk, kOk, kOk);
|
"textarea", kTodo, kTodo, kTodo);
|
||||||
testTextAtOffset(18, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
testTextAtOffset(18, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
||||||
"div", kTodo, kOk, kTodo,
|
"div", kTodo, kTodo, kTodo,
|
||||||
"divbr", kTodo, kOk, kTodo,
|
"divbr", kOk, kOk, kOk,
|
||||||
"editable", kTodo, kOk, kTodo,
|
"editable", kTodo, kTodo, kTodo,
|
||||||
"editablebr", kTodo, kOk, kTodo,
|
"editablebr", kOk, kOk, kOk,
|
||||||
"textarea", kTodo, kOk, kTodo);
|
"textarea", kTodo, kTodo, kTodo);
|
||||||
testTextAtOffset(19, BOUNDARY_LINE_END, "\n", 18, 19,
|
testTextAtOffset(19, BOUNDARY_LINE_END, "\n", 18, 19,
|
||||||
"div", kTodo, kTodo, kTodo,
|
"div", kTodo, kTodo, kTodo,
|
||||||
"divbr", kTodo, kTodo, kTodo,
|
"divbr", kTodo, kTodo, kTodo,
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
src="../text.js"></script>
|
src="../text.js"></script>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
if (navigator.platform.startsWith("Mac")) {
|
if (navigator.platform.startsWith("Mac")) {
|
||||||
SimpleTest.expectAssertions(0, 16);
|
SimpleTest.expectAssertions(0, 12);
|
||||||
} else {
|
} else {
|
||||||
SimpleTest.expectAssertions(16);
|
SimpleTest.expectAssertions(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
function doTest()
|
function doTest()
|
||||||
@ -130,26 +130,10 @@
|
|||||||
testTextAtOffset(15, BOUNDARY_LINE_START, "hello my friend", 0, 15, IDs);
|
testTextAtOffset(15, BOUNDARY_LINE_START, "hello my friend", 0, 15, IDs);
|
||||||
|
|
||||||
// BOUNDARY_LINE_END
|
// BOUNDARY_LINE_END
|
||||||
testTextAtOffset(0, BOUNDARY_LINE_END, "hello my friend", 0, 15,
|
testTextAtOffset(0, BOUNDARY_LINE_END, "hello my friend", 0, 15, IDs);
|
||||||
"input", kOk, kOk, kOk,
|
testTextAtOffset(1, BOUNDARY_LINE_END, "hello my friend", 0, 15, IDs);
|
||||||
"div", kOk, kOk, kOk,
|
testTextAtOffset(14, BOUNDARY_LINE_END, "hello my friend", 0, 15, IDs);
|
||||||
"editable", kOk, kOk, kOk,
|
testTextAtOffset(15, BOUNDARY_LINE_END, "hello my friend", 0, 15, IDs);
|
||||||
"textarea", kOk, kOk, kOk);
|
|
||||||
testTextAtOffset(1, BOUNDARY_LINE_END, "hello my friend", 0, 15,
|
|
||||||
"input", kOk, kOk, kOk,
|
|
||||||
"div", kOk, kOk, kOk,
|
|
||||||
"editable", kOk, kOk, kOk,
|
|
||||||
"textarea", kOk, kOk, kOk);
|
|
||||||
testTextAtOffset(14, BOUNDARY_LINE_END, "hello my friend", 0, 15,
|
|
||||||
"input", kOk, kOk, kOk,
|
|
||||||
"div", kOk, kOk, kOk,
|
|
||||||
"editable", kOk, kOk, kOk,
|
|
||||||
"textarea", kOk, kOk, kOk);
|
|
||||||
testTextAtOffset(15, BOUNDARY_LINE_END, "hello my friend", 0, 15,
|
|
||||||
"input", kTodo, kOk, kTodo,
|
|
||||||
"div", kTodo, kOk, kTodo,
|
|
||||||
"editable", kTodo, kOk, kTodo,
|
|
||||||
"textarea", kTodo, kOk, kTodo);
|
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
@ -184,6 +168,7 @@
|
|||||||
<div id="div">hello my friend</div>
|
<div id="div">hello my friend</div>
|
||||||
<div id="editable" contenteditable="true">hello my friend</div>
|
<div id="editable" contenteditable="true">hello my friend</div>
|
||||||
<textarea id="textarea">hello my friend</textarea>
|
<textarea id="textarea">hello my friend</textarea>
|
||||||
|
<div>XXX: a hack to make text areas/inputs working</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user