Bug 1347809 Set Selection::mCalledByJS to false before moving focus in NotifySelectionListeners() because non-*JS() methods don't set it to false r=smaug

Currently, Selection::NotifySelectionListeners() moves focus before setting mCalledByJS to false.  Therefore, if moving focus causes some calls of internal Selection methods, it may cause moving focus due to mCalledByJS being still true.  So, mCalledByJS should be set to false before moving focus in NotifySelectionListeners().

MozReview-Commit-ID: F879bOmhZlv

--HG--
extra : rebase_source : 80790d24f1c78d9aeb20e5735e0c7c45111e69b3
This commit is contained in:
Masayuki Nakano 2017-03-16 17:15:20 +09:00
Родитель e5be7ba973
Коммит 0ef47eccb5
1 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

@ -6401,11 +6401,17 @@ Selection::NotifySelectionListeners()
if (!mFrameSelection)
return NS_OK;//nothing to do
// Our internal code should not move focus with using this class while
// this moves focus nor from selection listeners.
AutoRestore<bool> calledByJSRestorer(mCalledByJS);
mCalledByJS = false;
// When normal selection is changed by Selection API, we need to move focus
// if common ancestor of all ranges are in an editing host. Note that we
// don't need to move focus *to* the other focusable node because other
// browsers don't do it either.
if (mSelectionType == SelectionType::eNormal && mCalledByJS) {
if (mSelectionType == SelectionType::eNormal &&
calledByJSRestorer.SavedValue()) {
nsPIDOMWindowOuter* window = GetWindow();
nsIDocument* document = GetDocument();
// If the document is in design mode or doesn't have contenteditable
@ -6439,11 +6445,6 @@ Selection::NotifySelectionListeners()
}
}
// After moving focus, especially in selection listeners, our internal code
// should not move focus with using this class.
AutoRestore<bool> calledFromExternalRestorer(mCalledByJS);
mCalledByJS = false;
if (mFrameSelection->GetBatching()) {
mFrameSelection->SetDirty();
return NS_OK;