зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1680611 - part 11: Mark `nsFocusManager::NotifyOfReFocus()` as `MOZ_CAN_RUN_SCRIPT` r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147072
This commit is contained in:
Родитель
971efcf6d8
Коммит
5a48a0f346
|
@ -447,10 +447,11 @@ int32_t Element::TabIndex() {
|
|||
|
||||
void Element::Focus(const FocusOptions& aOptions, CallerType aCallerType,
|
||||
ErrorResult& aError) {
|
||||
RefPtr<nsFocusManager> fm = nsFocusManager::GetFocusManager();
|
||||
if (!fm) {
|
||||
const RefPtr<nsFocusManager> fm = nsFocusManager::GetFocusManager();
|
||||
if (MOZ_UNLIKELY(!fm)) {
|
||||
return;
|
||||
}
|
||||
const OwningNonNull<Element> kungFuDeathGrip(*this);
|
||||
// Also other browsers seem to have the hack to not re-focus (and flush) when
|
||||
// the element is already focused.
|
||||
// Until https://github.com/whatwg/html/issues/4512 is clarified, we'll
|
||||
|
@ -458,7 +459,7 @@ void Element::Focus(const FocusOptions& aOptions, CallerType aCallerType,
|
|||
// I.e., `focus({ preventScroll: true})` followed by `focus( { preventScroll:
|
||||
// false })` won't re-focus.
|
||||
if (fm->CanSkipFocus(this)) {
|
||||
fm->NotifyOfReFocus(*this);
|
||||
fm->NotifyOfReFocus(kungFuDeathGrip);
|
||||
fm->NeedsFlushBeforeEventHandling(this);
|
||||
return;
|
||||
}
|
||||
|
@ -466,7 +467,7 @@ void Element::Focus(const FocusOptions& aOptions, CallerType aCallerType,
|
|||
if (aCallerType == CallerType::NonSystem) {
|
||||
fmFlags |= nsIFocusManager::FLAG_NONSYSTEMCALLER;
|
||||
}
|
||||
aError = fm->SetFocus(this, fmFlags);
|
||||
aError = fm->SetFocus(kungFuDeathGrip, fmFlags);
|
||||
}
|
||||
|
||||
void Element::SetTabIndex(int32_t aTabIndex, mozilla::ErrorResult& aError) {
|
||||
|
|
|
@ -301,6 +301,8 @@ class Element : public FragmentOrElement {
|
|||
/**
|
||||
* Make focus on this element.
|
||||
*/
|
||||
// TODO: Convert Focus() to MOZ_CAN_RUN_SCRIPT and get rid of the
|
||||
// kungFuDeathGrip in it.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void Focus(const FocusOptions& aOptions,
|
||||
const CallerType aCallerType,
|
||||
ErrorResult& aError);
|
||||
|
|
|
@ -290,7 +290,7 @@ class nsFocusManager final : public nsIFocusManager,
|
|||
*
|
||||
* aContent is focused content.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void NotifyOfReFocus(nsIContent& aContent);
|
||||
MOZ_CAN_RUN_SCRIPT void NotifyOfReFocus(nsIContent& aContent);
|
||||
|
||||
static void MarkUncollectableForCCGeneration(uint32_t aGeneration);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче