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
d1c2df92fc
commit
716c703de6
@ -782,8 +782,9 @@ HyperTextAccessible::GetRelativeOffset(nsIPresShell* aPresShell,
|
||||
}
|
||||
|
||||
int32_t
|
||||
HyperTextAccessible::FindWordBoundary(int32_t aOffset, nsDirection aDirection,
|
||||
EWordMovementType aWordMovementType)
|
||||
HyperTextAccessible::FindBoundary(int32_t aOffset, nsDirection aDirection,
|
||||
nsSelectionAmount aAmount,
|
||||
EWordMovementType aWordMovementType)
|
||||
{
|
||||
// Convert hypertext offset to frame-relative offset.
|
||||
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 GetRelativeOffset(mDoc->PresShell(), frameAtOffset, offsetInFrame,
|
||||
accAtOffset, eSelectWord, aDirection,
|
||||
(aWordMovementType == eStartWord),
|
||||
accAtOffset, aAmount, aDirection,
|
||||
(aWordMovementType == eStartWord || aAmount == eSelectBeginLine),
|
||||
aWordMovementType);
|
||||
}
|
||||
|
||||
@ -1080,8 +1081,29 @@ HyperTextAccessible::GetTextAtOffset(int32_t aOffset,
|
||||
*aStartOffset = FindWordBoundary(*aEndOffset, eDirPrevious, eEndWord);
|
||||
return GetText(*aStartOffset, *aEndOffset, aText);
|
||||
|
||||
case BOUNDARY_LINE_START:
|
||||
case BOUNDARY_LINE_END:
|
||||
case BOUNDARY_LINE_START: {
|
||||
// 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:
|
||||
return GetTextHelper(eGetAt, aBoundaryType, aOffset,
|
||||
aStartOffset, aEndOffset, aText);
|
||||
|
@ -267,7 +267,26 @@ protected:
|
||||
* Return an offset of the found word boundary.
|
||||
*/
|
||||
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
|
||||
|
@ -50,7 +50,7 @@
|
||||
"textarea", kTodo, kTodo, kOk);
|
||||
|
||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "words", 10, 15,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
"textarea", kTodo, kTodo, kOk);
|
||||
|
||||
testTextBeforeOffset(kCaretOffset, BOUNDARY_LINE_START, "words", 10, 15,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
@ -113,7 +113,7 @@
|
||||
"textarea", kOk, kOk, kOk);
|
||||
|
||||
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,
|
||||
"textarea", kTodo, kTodo, kOk);
|
||||
@ -141,7 +141,7 @@
|
||||
"textarea", kTodo, kTodo, kOk);
|
||||
|
||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "two ", 6, 10,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
|
||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "\ntwo ", 5, 10,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
@ -172,7 +172,7 @@
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
|
||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "aword\n", 0, 6,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
"textarea", kOk, kOk, kOk);
|
||||
|
||||
testTextAtOffset(kCaretOffset, BOUNDARY_LINE_END, "", 0, 0,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
@ -203,10 +203,10 @@
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
|
||||
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,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
|
||||
testTextBeforeOffset(kCaretOffset, BOUNDARY_LINE_START, "", 0, 0,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
@ -224,7 +224,7 @@
|
||||
var gQueue = null;
|
||||
function doTest()
|
||||
{
|
||||
SimpleTest.expectAssertions(7);
|
||||
SimpleTest.expectAssertions(6);
|
||||
|
||||
gQueue = new eventQueue();
|
||||
gQueue.push(new moveToLastLineEnd());
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
function doTest()
|
||||
{
|
||||
SimpleTest.expectAssertions(46);
|
||||
SimpleTest.expectAssertions(38);
|
||||
|
||||
// __o__n__e__w__o__r__d__\n
|
||||
// 0 1 2 3 4 5 6 7
|
||||
@ -180,48 +180,18 @@
|
||||
// getTextAtOffset
|
||||
|
||||
// BOUNDARY_LINE_START
|
||||
testTextAtOffset(0, BOUNDARY_LINE_START, "oneword\n", 0, 8,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
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(0, BOUNDARY_LINE_START, "oneword\n", 0, 8, IDs);
|
||||
testTextAtOffset(7, BOUNDARY_LINE_START, "oneword\n", 0, 8, IDs);
|
||||
testTextAtOffset(8, BOUNDARY_LINE_START, "\n", 8, 9, IDs);
|
||||
testTextAtOffset(9, BOUNDARY_LINE_START, "two words\n", 9, 19, IDs);
|
||||
testTextAtOffset(13, BOUNDARY_LINE_START, "two words\n", 9, 19, IDs);
|
||||
testTextAtOffset(18, BOUNDARY_LINE_START, "two words\n", 9, 19, IDs);
|
||||
testTextAtOffset(19, BOUNDARY_LINE_START, "", 19, 19,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"div", kTodo, kTodo, kOk,
|
||||
"divbr", kTodo, kTodo, kOk,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kOk,
|
||||
"editablebr", kTodo, kTodo, kOk,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
"textarea", kTodo, kTodo, kOk);
|
||||
|
||||
// BOUNDARY_LINE_END
|
||||
testTextAtOffset(0, BOUNDARY_LINE_END, "oneword", 0, 7,
|
||||
@ -231,35 +201,35 @@
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextAtOffset(7, BOUNDARY_LINE_END, "oneword", 0, 7,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kTodo, kTodo, kTodo,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
testTextAtOffset(8, BOUNDARY_LINE_END, "\n", 7, 8,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kTodo, kTodo, kTodo,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextAtOffset(9, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextAtOffset(17, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
||||
"div", kOk, kOk, kOk,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kOk, kOk, kOk,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kOk, kOk, kOk);
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextAtOffset(18, BOUNDARY_LINE_END, "\ntwo words", 8, 18,
|
||||
"div", kTodo, kOk, kTodo,
|
||||
"divbr", kTodo, kOk, kTodo,
|
||||
"editable", kTodo, kOk, kTodo,
|
||||
"editablebr", kTodo, kOk, kTodo,
|
||||
"textarea", kTodo, kOk, kTodo);
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kOk, kOk, kOk,
|
||||
"editable", kTodo, kTodo, kTodo,
|
||||
"editablebr", kOk, kOk, kOk,
|
||||
"textarea", kTodo, kTodo, kTodo);
|
||||
testTextAtOffset(19, BOUNDARY_LINE_END, "\n", 18, 19,
|
||||
"div", kTodo, kTodo, kTodo,
|
||||
"divbr", kTodo, kTodo, kTodo,
|
||||
|
@ -12,9 +12,9 @@
|
||||
src="../text.js"></script>
|
||||
<script type="application/javascript">
|
||||
if (navigator.platform.startsWith("Mac")) {
|
||||
SimpleTest.expectAssertions(0, 16);
|
||||
SimpleTest.expectAssertions(0, 12);
|
||||
} else {
|
||||
SimpleTest.expectAssertions(16);
|
||||
SimpleTest.expectAssertions(12);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
@ -130,26 +130,10 @@
|
||||
testTextAtOffset(15, BOUNDARY_LINE_START, "hello my friend", 0, 15, IDs);
|
||||
|
||||
// BOUNDARY_LINE_END
|
||||
testTextAtOffset(0, 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(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);
|
||||
testTextAtOffset(0, BOUNDARY_LINE_END, "hello my friend", 0, 15, IDs);
|
||||
testTextAtOffset(1, BOUNDARY_LINE_END, "hello my friend", 0, 15, IDs);
|
||||
testTextAtOffset(14, BOUNDARY_LINE_END, "hello my friend", 0, 15, IDs);
|
||||
testTextAtOffset(15, BOUNDARY_LINE_END, "hello my friend", 0, 15, IDs);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
@ -184,6 +168,7 @@
|
||||
<div id="div">hello my friend</div>
|
||||
<div id="editable" contenteditable="true">hello my friend</div>
|
||||
<textarea id="textarea">hello my friend</textarea>
|
||||
<div>XXX: a hack to make text areas/inputs working</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user