From 0283c8daef4615b494476c01b6988a9cfa05dc2c Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 16 Aug 2016 14:37:40 +0900 Subject: [PATCH] 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 --HG-- extra : rebase_source : 35d5b8feecd351bef29fe4af79a0f6f5bdad8bec --- dom/events/ContentEventHandler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp index 013f81ed4d8a..8670f591ba78 100644 --- a/dom/events/ContentEventHandler.cpp +++ b/dom/events/ContentEventHandler.cpp @@ -1553,7 +1553,11 @@ ContentEventHandler::GetLastFrameInRangeForTextRect(nsRange* aRange) // 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()) {