зеркало из https://github.com/mozilla/gecko-dev.git
Bug 864040 - Set range to after text node when offset is at the end of text node; r=masayuki
This commit is contained in:
Родитель
14195d6497
Коммит
caabfdcd8b
|
@ -1006,12 +1006,23 @@ static void AdjustRangeForSelection(nsIContent* aRoot,
|
|||
{
|
||||
nsINode* node = *aNode;
|
||||
int32_t offset = *aOffset;
|
||||
if (aRoot != node && node->GetParent() &&
|
||||
!node->IsNodeOfType(nsINode::eTEXT)) {
|
||||
node = node->GetParent();
|
||||
offset = node->IndexOf(*aNode) + (offset ? 1 : 0);
|
||||
if (aRoot != node && node->GetParent()) {
|
||||
if (node->IsNodeOfType(nsINode::eTEXT)) {
|
||||
// When the offset is at the end of the text node, set it to after the
|
||||
// text node, to make sure the caret is drawn on a new line when the last
|
||||
// character of the text node is '\n'
|
||||
int32_t length = (int32_t)(static_cast<nsIContent*>(node)->TextLength());
|
||||
MOZ_ASSERT(offset <= length, "Offset is past length of text node");
|
||||
if (offset == length) {
|
||||
node = node->GetParent();
|
||||
offset = node->IndexOf(*aNode) + 1;
|
||||
}
|
||||
} else {
|
||||
node = node->GetParent();
|
||||
offset = node->IndexOf(*aNode) + (offset ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsIContent* brContent = node->GetChildAt(offset - 1);
|
||||
while (brContent && brContent->IsHTML()) {
|
||||
if (brContent->Tag() != nsGkAtoms::br || IsContentBR(brContent))
|
||||
|
|
Загрузка…
Ссылка в новой задаче