From 58963742cf9f0e2d0cb42358936c8adf1e40a59e Mon Sep 17 00:00:00 2001 From: Morris Tseng Date: Mon, 2 Feb 2015 22:10:00 -0500 Subject: [PATCH] Bug 1119126 - Send updateposition after reflow when selection is collapsed. r=roc --- dom/browser-element/BrowserElementChildPreload.js | 3 +++ layout/base/SelectionCarets.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js index 4464dd8986cc..b71806c6c14f 100644 --- a/dom/browser-element/BrowserElementChildPreload.js +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -638,6 +638,8 @@ BrowserElementChild.prototype = { // We clear selectionStateChangedTarget if selection carets are invisible. if (e.visible && !isCollapsed) { this._selectionStateChangedTarget = e.target; + } else if (canPaste && isCollapsed) { + this._selectionStateChangedTarget = e.target; } else { this._selectionStateChangedTarget = null; } @@ -1144,6 +1146,7 @@ BrowserElementChild.prototype = { _recvDoCommand: function(data) { if (this._isCommandEnabled(data.json.command)) { + this._selectionStateChangedTarget = null; docShell.doCommand(COMMAND_MAP[data.json.command]); } }, diff --git a/layout/base/SelectionCarets.cpp b/layout/base/SelectionCarets.cpp index e69a7136f012..f8c1b4eaf14c 100644 --- a/layout/base/SelectionCarets.cpp +++ b/layout/base/SelectionCarets.cpp @@ -1220,6 +1220,12 @@ SelectionCarets::ScrollPositionChanged() SelectionState::Updateposition); } } + } else { + nsRefPtr selection = GetSelection(); + if (selection && selection->RangeCount() && selection->IsCollapsed()) { + DispatchSelectionStateChangedEvent(selection, + SelectionState::Updateposition); + } } } @@ -1317,6 +1323,12 @@ SelectionCarets::Reflow(DOMHighResTimeStamp aStart, DOMHighResTimeStamp aEnd) DispatchSelectionStateChangedEvent(GetSelection(), SelectionState::Updateposition); } + } else { + nsRefPtr selection = GetSelection(); + if (selection && selection->RangeCount() && selection->IsCollapsed()) { + DispatchSelectionStateChangedEvent(selection, + SelectionState::Updateposition); + } } return NS_OK; }