From 24e9e4a700102a7a65ca151f06676b6ca5d1388a Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Thu, 14 Jul 2016 22:57:00 +0900 Subject: [PATCH] Bug 1286464 part.2 GetFirstFrameInRange() should return node offset since it may return different node's frame r=m_kato GetFirstFrameInRange() uses AdjustTextRectNode() which may return different node before retrieving the result frame. Therefore, the caller may need offset in the new node. MozReview-Commit-ID: 2AQU5WfahT9 --HG-- extra : rebase_source : c753d34dc2691da2ec25c9f5a6fe17d67af24a70 --- dom/events/ContentEventHandler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp index 08adb306109b..cb9d8cc5a365 100644 --- a/dom/events/ContentEventHandler.cpp +++ b/dom/events/ContentEventHandler.cpp @@ -1397,20 +1397,20 @@ static nsINode* AdjustTextRectNode(nsINode* aNode, static nsIFrame* -GetFirstFrameInRange(nsRange* aRange) +GetFirstFrameInRange(nsRange* aRange, int32_t& aNodeOffset) { // used to iterate over all contents and their frames nsCOMPtr iter = NS_NewContentIterator(); iter->Init(aRange); // get the starting frame - int32_t nodeOffset = aRange->StartOffset(); + aNodeOffset = aRange->StartOffset(); nsINode* node = iter->GetCurrentNode(); if (!node) { - node = AdjustTextRectNode(aRange->GetStartParent(), nodeOffset); + node = AdjustTextRectNode(aRange->GetStartParent(), aNodeOffset); } nsIFrame* firstFrame = nullptr; - GetFrameForTextRect(node, nodeOffset, true, &firstFrame); + GetFrameForTextRect(node, aNodeOffset, true, &firstFrame); return firstFrame; } @@ -1436,7 +1436,8 @@ ContentEventHandler::OnQueryTextRectArray(WidgetQueryContentEvent* aEvent) } // get the starting frame - nsIFrame* firstFrame = GetFirstFrameInRange(range); + int32_t nodeOffset = -1; + nsIFrame* firstFrame = GetFirstFrameInRange(range, nodeOffset); if (NS_WARN_IF(!firstFrame)) { return NS_ERROR_FAILURE; } @@ -1448,7 +1449,6 @@ ContentEventHandler::OnQueryTextRectArray(WidgetQueryContentEvent* aEvent) return rv; } - int32_t nodeOffset = range->StartOffset(); AutoTArray charRects; rv = firstFrame->GetCharacterRectsInRange(nodeOffset, kEndOffset - offset, charRects);