Bug 1680167 - Part 8: MOZ_CAN_RUN_SCRIPT_BOUNDARY in toolkit r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D98631
This commit is contained in:
Kagami Sascha Rosylight 2020-12-03 22:58:14 +00:00
Родитель 24a88545bc
Коммит 9fc2fee9e3
3 изменённых файлов: 7 добавлений и 7 удалений

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

@ -346,8 +346,7 @@ void nsWebBrowserFind::SetSelectionAndScroll(nsPIDOMWindowOuter* aWindow,
selection->AddRangeAndSelectFramesAndNotifyListeners(*aRange,
IgnoreErrors());
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
if (RefPtr<nsFocusManager> fm = nsFocusManager::GetFocusManager()) {
if (tcFrame) {
RefPtr<Element> newFocusedElement = Element::FromNode(content);
fm->SetFocus(newFocusedElement, nsIFocusManager::FLAG_NOSCROLL);
@ -749,7 +748,7 @@ nsresult nsWebBrowserFind::OnFind(nsPIDOMWindowOuter* aFoundWindow) {
ClearFrameSelection(lastFocusedWindow);
}
if (nsFocusManager* fm = nsFocusManager::GetFocusManager()) {
if (RefPtr<nsFocusManager> fm = nsFocusManager::GetFocusManager()) {
// get the containing frame and focus it. For top-level windows, the right
// window should already be focused.
if (RefPtr<Element> frameElement =

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

@ -59,7 +59,7 @@ class nsWebBrowserFind : public nsIWebBrowserFind,
nsPIDOMWindowOuter* aWindow);
nsresult ClearFrameSelection(nsPIDOMWindowOuter* aWindow);
nsresult OnFind(nsPIDOMWindowOuter* aFoundWindow);
MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult OnFind(nsPIDOMWindowOuter* aFoundWindow);
MOZ_CAN_RUN_SCRIPT_BOUNDARY void SetSelectionAndScroll(
nsPIDOMWindowOuter* aWindow, nsRange* aRange);

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

@ -499,7 +499,7 @@ nsresult nsTypeAheadFind::FindItNow(uint32_t aMode, bool aIsLinksOnly,
NS_ASSERTION(window, "document has no window");
if (!window) return NS_ERROR_UNEXPECTED;
nsFocusManager* fm = nsFocusManager::GetFocusManager();
RefPtr<nsFocusManager> fm = nsFocusManager::GetFocusManager();
if (usesIndependentSelection) {
/* If a search result is found inside an editable element, we'll focus
* the element only if focus is in our content window, i.e.
@ -524,7 +524,7 @@ nsresult nsTypeAheadFind::FindItNow(uint32_t aMode, bool aIsLinksOnly,
// We may be inside an editable element, and therefore the selection
// may be controlled by a different selection controller. Walk up the
// chain of parent nodes to see if we find one.
nsCOMPtr<nsINode> node = returnRange->GetStartContainer();
nsINode* node = returnRange->GetStartContainer();
while (node) {
nsCOMPtr<nsIEditor> editor;
if (RefPtr<HTMLInputElement> input =
@ -557,7 +557,8 @@ nsresult nsTypeAheadFind::FindItNow(uint32_t aMode, bool aIsLinksOnly,
// Otherwise move focus/caret to editable element
if (fm) {
fm->SetFocus(mFoundEditable, 0);
nsCOMPtr<Element> newFocusElement = mFoundEditable;
fm->SetFocus(newFocusElement, 0);
}
break;
}