Bug 1394758 - Part 2. WSRunObject::InsertBreak should convert space to NBSP when current position is first text run object. r=masayuki

After applying part 1 fix, it doesn't pass test_bug430392.html like the following..

1. content is <span contenteditable=false>A</span>[caret] ;
2. [VK_RETURN]
3. content is <span contenteditable=false>A</span><br>; <- whitespace is removed

Since we started to treat readonly text nodes as WSType::special with previous patch, WSRunObject::InsertBreak doesn't convert space (after caret) to NBSP because WSRunObject::InsertBreak does it only when inserted position isn't first text run object.

So even if this is first text run object, space after caret should be converted to NBSP.

MozReview-Commit-ID: Hj0i3wm45c3

--HG--
extra : rebase_source : 2d0ae7c47c6187e56d6c29e8eb48974f7ab7ff72
This commit is contained in:
Makoto Kato 2017-09-04 15:01:16 +09:00
Родитель bf93a68c34
Коммит 6b536f8760
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -202,7 +202,8 @@ WSRunObject::InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
WSPoint thePoint = GetCharAfter(*aInOutParent, *aInOutOffset);
if (thePoint.mTextNode && nsCRT::IsAsciiSpace(thePoint.mChar)) {
WSPoint prevPoint = GetCharBefore(thePoint);
if (prevPoint.mTextNode && !nsCRT::IsAsciiSpace(prevPoint.mChar)) {
if (!prevPoint.mTextNode ||
(prevPoint.mTextNode && !nsCRT::IsAsciiSpace(prevPoint.mChar))) {
// We are at start of non-nbsps. Convert to a single nbsp.
nsresult rv = ConvertToNBSP(thePoint);
NS_ENSURE_SUCCESS(rv, nullptr);