зеркало из https://github.com/mozilla/gecko-dev.git
Bug 394752. Skip over preformatted newlines when moving caret; the caret will appear at the end of a line when it is positioned at the start of the next line with a HINTLEFT. r=smontagu
This commit is contained in:
Родитель
9a701e3d48
Коммит
62a072317b
|
@ -4489,6 +4489,19 @@ private:
|
|||
PRPackedBool mHaveWordBreak;
|
||||
};
|
||||
|
||||
static PRBool
|
||||
IsAcceptableCaretPosition(const gfxSkipCharsIterator& aIter, gfxTextRun* aTextRun,
|
||||
nsIFrame* aFrame)
|
||||
{
|
||||
if (aIter.IsOriginalCharSkipped())
|
||||
return PR_FALSE;
|
||||
PRUint32 index = aIter.GetSkippedOffset();
|
||||
if (!aTextRun->IsClusterStart(index))
|
||||
return PR_FALSE;
|
||||
return !(aFrame->GetStyleText()->WhiteSpaceIsSignificant() &&
|
||||
aTextRun->GetChar(index) == '\n');
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsTextFrame::PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset)
|
||||
{
|
||||
|
@ -4515,8 +4528,7 @@ nsTextFrame::PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset)
|
|||
for (i = PR_MIN(trimmed.GetEnd(), startOffset) - 1;
|
||||
i >= trimmed.mStart; --i) {
|
||||
iter.SetOriginalOffset(i);
|
||||
if (!iter.IsOriginalCharSkipped() &&
|
||||
mTextRun->IsClusterStart(iter.GetSkippedOffset())) {
|
||||
if (IsAcceptableCaretPosition(iter, mTextRun, this)) {
|
||||
*aOffset = i - mContentOffset;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -4530,8 +4542,7 @@ nsTextFrame::PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset)
|
|||
// but we really have no choice right now. We need to do a deeper
|
||||
// fix/restructuring of PeekOffsetCharacter
|
||||
if (i == trimmed.GetEnd() ||
|
||||
(!iter.IsOriginalCharSkipped() &&
|
||||
mTextRun->IsClusterStart(iter.GetSkippedOffset()))) {
|
||||
IsAcceptableCaretPosition(iter, mTextRun, this)) {
|
||||
*aOffset = i - mContentOffset;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,19 @@ function test() {
|
|||
testLeft(editor.firstChild, 1);
|
||||
testLeft(editor.firstChild, 0);
|
||||
|
||||
editor.innerHTML = "<pre>aa\nbb</pre>";
|
||||
sel.collapse(editor.firstChild.firstChild, 0);
|
||||
testRight(editor.firstChild.firstChild, 1);
|
||||
// at the 'bb' but HINTLEFT so appears at the end of the first line
|
||||
testRight(editor.firstChild.firstChild, 3);
|
||||
testRight(editor.firstChild.firstChild, 3);
|
||||
testRight(editor.firstChild.firstChild, 4);
|
||||
testLeft(editor.firstChild.firstChild, 3);
|
||||
// at the 'bb' but HINTLEFT so appears at the end of the first line
|
||||
testLeft(editor.firstChild.firstChild, 3);
|
||||
testLeft(editor.firstChild.firstChild, 1);
|
||||
testLeft(editor.firstChild.firstChild, 0);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче