Bug 1295354 part.1 ContentEventHandler::GetLastFrameInRangeForTextRect() shouldn't set nextNodeOfRangeEnd to the start node of aRange because the start node should always be in the range r?smaug
nextNodeOfRangeEnd is used for excluding unnecessary node for computing text rect. When aRange ends at start of a text node, the frames which are created for the text node shouldn't be used. However, if the end node of aRange is same as the start node of aRange, the node is not outside of aRange.
This could occur when it's called with empty range or there are some empty text nodes.
MozReview-Commit-ID: C1yCN5WrULe
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -1548,17 +1548,21 @@ ContentEventHandler::GetLastFrameInRange
// +----+
// So, if this method includes the 2nd text frame's rect to its result, the
// caller will return too tall rect which includes 2 lines in this case isn't
// expected by native IME (e.g., popup of IME will be positioned at bottom
// of "d" instead of right-bottom of "c"). Therefore, this method shouldn't
// include the last frame when its content isn't really in aRange.
nsINode* nextNodeOfRangeEnd = nullptr;
if (endNode->IsNodeOfType(nsINode::eTEXT)) {
- if (!endOffset) {
+ // Don't set nextNodeOfRangeEnd to the start node of aRange because if
+ // endNode is same as start node of the range, the text node shouldn't be
+ // next of range end even if the offset is 0. This could occur with empty
+ // text node.
+ if (!endOffset && aRange->GetStartParent() != endNode) {
nextNodeOfRangeEnd = endNode;
}
} else if (endOffset < endNode->GetChildCount()) {
nextNodeOfRangeEnd = endNode->GetChildAt(endOffset);
}
for (iter->Last(); !iter->IsDone(); iter->Prev()) {
nsINode* node = iter->GetCurrentNode();