Bug Summary

File:root/firefox-clang/dom/events/NavigateEvent.cpp
Warning:line 365, column 5
Value stored to 'focusTarget' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_dom_events2.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/events -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/events -resource-dir /usr/lib/llvm-21/lib/clang/21 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D _GLIBCXX_ASSERTIONS -D DEBUG=1 -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/dom/events -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/events -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/docshell/base -I /root/firefox-clang/dom/base -I /root/firefox-clang/dom/html -I /root/firefox-clang/dom/storage -I /root/firefox-clang/dom/xml -I /root/firefox-clang/dom/xul -I /root/firefox-clang/js/xpconnect/wrappers -I /root/firefox-clang/layout/forms -I /root/firefox-clang/layout/generic -I /root/firefox-clang/layout/xul -I /root/firefox-clang/layout/xul/tree -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2025-06-27-100320-3286336-1 -x c++ Unified_cpp_dom_events2.cpp
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* vim:set ts=2 sw=2 sts=2 et cindent: */
3/* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7#include "nsGlobalWindowInner.h"
8#include "nsDocShell.h"
9
10#include "mozilla/HoldDropJSObjects.h"
11#include "mozilla/PresShell.h"
12
13#include "mozilla/dom/AbortController.h"
14#include "mozilla/dom/NavigateEvent.h"
15#include "mozilla/dom/NavigateEventBinding.h"
16#include "mozilla/dom/Navigation.h"
17#include "mozilla/dom/SessionHistoryEntry.h"
18
19namespace mozilla::dom {
20
21NS_IMPL_CYCLE_COLLECTION_INHERITED_WITH_JS_MEMBERS(NavigateEvent, Event,NavigateEvent::cycleCollection NavigateEvent::_cycleCollectorGlobal
; void NavigateEvent::cycleCollection::Unlink(void* p) { NavigateEvent
* tmp = DowncastCCParticipant<NavigateEvent>(p); nsISupports
* s = static_cast<nsISupports*>(p); Event::cycleCollection
::Unlink(s); using ::ImplCycleCollectionUnlink; ImplCycleCollectionUnlink
(tmp->mDestination); ImplCycleCollectionUnlink(tmp->mSignal
); ImplCycleCollectionUnlink(tmp->mFormData); ImplCycleCollectionUnlink
(tmp->mSourceElement); ImplCycleCollectionUnlink(tmp->mNavigationHandlerList
); ImplCycleCollectionUnlink(tmp->mAbortController); ImplCycleCollectionUnlink
(tmp->mInfo); (void)tmp; } nsresult NavigateEvent::cycleCollection
::TraverseNative( void* p, nsCycleCollectionTraversalCallback
& cb) { NavigateEvent* tmp = DowncastCCParticipant<NavigateEvent
>(p); nsISupports* s = static_cast<nsISupports*>(p);
if (Event::cycleCollection::TraverseNative(s, cb) == NS_SUCCESS_INTERRUPTED_TRAVERSE
) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } ImplCycleCollectionTraverse
(cb, tmp->mDestination, "mDestination", 0); ImplCycleCollectionTraverse
(cb, tmp->mSignal, "mSignal", 0); ImplCycleCollectionTraverse
(cb, tmp->mFormData, "mFormData", 0); ImplCycleCollectionTraverse
(cb, tmp->mSourceElement, "mSourceElement", 0); ImplCycleCollectionTraverse
(cb, tmp->mNavigationHandlerList, "mNavigationHandlerList"
, 0); ImplCycleCollectionTraverse(cb, tmp->mAbortController
, "mAbortController", 0); (void)tmp; return NS_OK; } void NavigateEvent
::cycleCollection::Trace( void* p, const TraceCallbacks& aCallbacks
, void* aClosure) { NavigateEvent* tmp = DowncastCCParticipant
<NavigateEvent>(p); nsISupports* s = static_cast<nsISupports
*>(p); Event::cycleCollection::Trace(s, aCallbacks, aClosure
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(!IsSingleZoneJSHolder())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsSingleZoneJSHolder()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsSingleZoneJSHolder()"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 26); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "!IsSingleZoneJSHolder()" ")"); do { MOZ_CrashSequence
(__null, 26); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false); ImplCycleCollectionTrace(aCallbacks, tmp
->mInfo, "mInfo", aClosure); (void)tmp; }
22 (mDestination, mSignal,NavigateEvent::cycleCollection NavigateEvent::_cycleCollectorGlobal
; void NavigateEvent::cycleCollection::Unlink(void* p) { NavigateEvent
* tmp = DowncastCCParticipant<NavigateEvent>(p); nsISupports
* s = static_cast<nsISupports*>(p); Event::cycleCollection
::Unlink(s); using ::ImplCycleCollectionUnlink; ImplCycleCollectionUnlink
(tmp->mDestination); ImplCycleCollectionUnlink(tmp->mSignal
); ImplCycleCollectionUnlink(tmp->mFormData); ImplCycleCollectionUnlink
(tmp->mSourceElement); ImplCycleCollectionUnlink(tmp->mNavigationHandlerList
); ImplCycleCollectionUnlink(tmp->mAbortController); ImplCycleCollectionUnlink
(tmp->mInfo); (void)tmp; } nsresult NavigateEvent::cycleCollection
::TraverseNative( void* p, nsCycleCollectionTraversalCallback
& cb) { NavigateEvent* tmp = DowncastCCParticipant<NavigateEvent
>(p); nsISupports* s = static_cast<nsISupports*>(p);
if (Event::cycleCollection::TraverseNative(s, cb) == NS_SUCCESS_INTERRUPTED_TRAVERSE
) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } ImplCycleCollectionTraverse
(cb, tmp->mDestination, "mDestination", 0); ImplCycleCollectionTraverse
(cb, tmp->mSignal, "mSignal", 0); ImplCycleCollectionTraverse
(cb, tmp->mFormData, "mFormData", 0); ImplCycleCollectionTraverse
(cb, tmp->mSourceElement, "mSourceElement", 0); ImplCycleCollectionTraverse
(cb, tmp->mNavigationHandlerList, "mNavigationHandlerList"
, 0); ImplCycleCollectionTraverse(cb, tmp->mAbortController
, "mAbortController", 0); (void)tmp; return NS_OK; } void NavigateEvent
::cycleCollection::Trace( void* p, const TraceCallbacks& aCallbacks
, void* aClosure) { NavigateEvent* tmp = DowncastCCParticipant
<NavigateEvent>(p); nsISupports* s = static_cast<nsISupports
*>(p); Event::cycleCollection::Trace(s, aCallbacks, aClosure
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(!IsSingleZoneJSHolder())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsSingleZoneJSHolder()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsSingleZoneJSHolder()"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 26); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "!IsSingleZoneJSHolder()" ")"); do { MOZ_CrashSequence
(__null, 26); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false); ImplCycleCollectionTrace(aCallbacks, tmp
->mInfo, "mInfo", aClosure); (void)tmp; }
23 mFormData, mSourceElement,NavigateEvent::cycleCollection NavigateEvent::_cycleCollectorGlobal
; void NavigateEvent::cycleCollection::Unlink(void* p) { NavigateEvent
* tmp = DowncastCCParticipant<NavigateEvent>(p); nsISupports
* s = static_cast<nsISupports*>(p); Event::cycleCollection
::Unlink(s); using ::ImplCycleCollectionUnlink; ImplCycleCollectionUnlink
(tmp->mDestination); ImplCycleCollectionUnlink(tmp->mSignal
); ImplCycleCollectionUnlink(tmp->mFormData); ImplCycleCollectionUnlink
(tmp->mSourceElement); ImplCycleCollectionUnlink(tmp->mNavigationHandlerList
); ImplCycleCollectionUnlink(tmp->mAbortController); ImplCycleCollectionUnlink
(tmp->mInfo); (void)tmp; } nsresult NavigateEvent::cycleCollection
::TraverseNative( void* p, nsCycleCollectionTraversalCallback
& cb) { NavigateEvent* tmp = DowncastCCParticipant<NavigateEvent
>(p); nsISupports* s = static_cast<nsISupports*>(p);
if (Event::cycleCollection::TraverseNative(s, cb) == NS_SUCCESS_INTERRUPTED_TRAVERSE
) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } ImplCycleCollectionTraverse
(cb, tmp->mDestination, "mDestination", 0); ImplCycleCollectionTraverse
(cb, tmp->mSignal, "mSignal", 0); ImplCycleCollectionTraverse
(cb, tmp->mFormData, "mFormData", 0); ImplCycleCollectionTraverse
(cb, tmp->mSourceElement, "mSourceElement", 0); ImplCycleCollectionTraverse
(cb, tmp->mNavigationHandlerList, "mNavigationHandlerList"
, 0); ImplCycleCollectionTraverse(cb, tmp->mAbortController
, "mAbortController", 0); (void)tmp; return NS_OK; } void NavigateEvent
::cycleCollection::Trace( void* p, const TraceCallbacks& aCallbacks
, void* aClosure) { NavigateEvent* tmp = DowncastCCParticipant
<NavigateEvent>(p); nsISupports* s = static_cast<nsISupports
*>(p); Event::cycleCollection::Trace(s, aCallbacks, aClosure
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(!IsSingleZoneJSHolder())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsSingleZoneJSHolder()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsSingleZoneJSHolder()"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 26); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "!IsSingleZoneJSHolder()" ")"); do { MOZ_CrashSequence
(__null, 26); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false); ImplCycleCollectionTrace(aCallbacks, tmp
->mInfo, "mInfo", aClosure); (void)tmp; }
24 mNavigationHandlerList,NavigateEvent::cycleCollection NavigateEvent::_cycleCollectorGlobal
; void NavigateEvent::cycleCollection::Unlink(void* p) { NavigateEvent
* tmp = DowncastCCParticipant<NavigateEvent>(p); nsISupports
* s = static_cast<nsISupports*>(p); Event::cycleCollection
::Unlink(s); using ::ImplCycleCollectionUnlink; ImplCycleCollectionUnlink
(tmp->mDestination); ImplCycleCollectionUnlink(tmp->mSignal
); ImplCycleCollectionUnlink(tmp->mFormData); ImplCycleCollectionUnlink
(tmp->mSourceElement); ImplCycleCollectionUnlink(tmp->mNavigationHandlerList
); ImplCycleCollectionUnlink(tmp->mAbortController); ImplCycleCollectionUnlink
(tmp->mInfo); (void)tmp; } nsresult NavigateEvent::cycleCollection
::TraverseNative( void* p, nsCycleCollectionTraversalCallback
& cb) { NavigateEvent* tmp = DowncastCCParticipant<NavigateEvent
>(p); nsISupports* s = static_cast<nsISupports*>(p);
if (Event::cycleCollection::TraverseNative(s, cb) == NS_SUCCESS_INTERRUPTED_TRAVERSE
) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } ImplCycleCollectionTraverse
(cb, tmp->mDestination, "mDestination", 0); ImplCycleCollectionTraverse
(cb, tmp->mSignal, "mSignal", 0); ImplCycleCollectionTraverse
(cb, tmp->mFormData, "mFormData", 0); ImplCycleCollectionTraverse
(cb, tmp->mSourceElement, "mSourceElement", 0); ImplCycleCollectionTraverse
(cb, tmp->mNavigationHandlerList, "mNavigationHandlerList"
, 0); ImplCycleCollectionTraverse(cb, tmp->mAbortController
, "mAbortController", 0); (void)tmp; return NS_OK; } void NavigateEvent
::cycleCollection::Trace( void* p, const TraceCallbacks& aCallbacks
, void* aClosure) { NavigateEvent* tmp = DowncastCCParticipant
<NavigateEvent>(p); nsISupports* s = static_cast<nsISupports
*>(p); Event::cycleCollection::Trace(s, aCallbacks, aClosure
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(!IsSingleZoneJSHolder())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsSingleZoneJSHolder()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsSingleZoneJSHolder()"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 26); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "!IsSingleZoneJSHolder()" ")"); do { MOZ_CrashSequence
(__null, 26); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false); ImplCycleCollectionTrace(aCallbacks, tmp
->mInfo, "mInfo", aClosure); (void)tmp; }
25 mAbortController),NavigateEvent::cycleCollection NavigateEvent::_cycleCollectorGlobal
; void NavigateEvent::cycleCollection::Unlink(void* p) { NavigateEvent
* tmp = DowncastCCParticipant<NavigateEvent>(p); nsISupports
* s = static_cast<nsISupports*>(p); Event::cycleCollection
::Unlink(s); using ::ImplCycleCollectionUnlink; ImplCycleCollectionUnlink
(tmp->mDestination); ImplCycleCollectionUnlink(tmp->mSignal
); ImplCycleCollectionUnlink(tmp->mFormData); ImplCycleCollectionUnlink
(tmp->mSourceElement); ImplCycleCollectionUnlink(tmp->mNavigationHandlerList
); ImplCycleCollectionUnlink(tmp->mAbortController); ImplCycleCollectionUnlink
(tmp->mInfo); (void)tmp; } nsresult NavigateEvent::cycleCollection
::TraverseNative( void* p, nsCycleCollectionTraversalCallback
& cb) { NavigateEvent* tmp = DowncastCCParticipant<NavigateEvent
>(p); nsISupports* s = static_cast<nsISupports*>(p);
if (Event::cycleCollection::TraverseNative(s, cb) == NS_SUCCESS_INTERRUPTED_TRAVERSE
) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } ImplCycleCollectionTraverse
(cb, tmp->mDestination, "mDestination", 0); ImplCycleCollectionTraverse
(cb, tmp->mSignal, "mSignal", 0); ImplCycleCollectionTraverse
(cb, tmp->mFormData, "mFormData", 0); ImplCycleCollectionTraverse
(cb, tmp->mSourceElement, "mSourceElement", 0); ImplCycleCollectionTraverse
(cb, tmp->mNavigationHandlerList, "mNavigationHandlerList"
, 0); ImplCycleCollectionTraverse(cb, tmp->mAbortController
, "mAbortController", 0); (void)tmp; return NS_OK; } void NavigateEvent
::cycleCollection::Trace( void* p, const TraceCallbacks& aCallbacks
, void* aClosure) { NavigateEvent* tmp = DowncastCCParticipant
<NavigateEvent>(p); nsISupports* s = static_cast<nsISupports
*>(p); Event::cycleCollection::Trace(s, aCallbacks, aClosure
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(!IsSingleZoneJSHolder())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsSingleZoneJSHolder()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsSingleZoneJSHolder()"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 26); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "!IsSingleZoneJSHolder()" ")"); do { MOZ_CrashSequence
(__null, 26); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false); ImplCycleCollectionTrace(aCallbacks, tmp
->mInfo, "mInfo", aClosure); (void)tmp; }
26 (mInfo))NavigateEvent::cycleCollection NavigateEvent::_cycleCollectorGlobal
; void NavigateEvent::cycleCollection::Unlink(void* p) { NavigateEvent
* tmp = DowncastCCParticipant<NavigateEvent>(p); nsISupports
* s = static_cast<nsISupports*>(p); Event::cycleCollection
::Unlink(s); using ::ImplCycleCollectionUnlink; ImplCycleCollectionUnlink
(tmp->mDestination); ImplCycleCollectionUnlink(tmp->mSignal
); ImplCycleCollectionUnlink(tmp->mFormData); ImplCycleCollectionUnlink
(tmp->mSourceElement); ImplCycleCollectionUnlink(tmp->mNavigationHandlerList
); ImplCycleCollectionUnlink(tmp->mAbortController); ImplCycleCollectionUnlink
(tmp->mInfo); (void)tmp; } nsresult NavigateEvent::cycleCollection
::TraverseNative( void* p, nsCycleCollectionTraversalCallback
& cb) { NavigateEvent* tmp = DowncastCCParticipant<NavigateEvent
>(p); nsISupports* s = static_cast<nsISupports*>(p);
if (Event::cycleCollection::TraverseNative(s, cb) == NS_SUCCESS_INTERRUPTED_TRAVERSE
) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } ImplCycleCollectionTraverse
(cb, tmp->mDestination, "mDestination", 0); ImplCycleCollectionTraverse
(cb, tmp->mSignal, "mSignal", 0); ImplCycleCollectionTraverse
(cb, tmp->mFormData, "mFormData", 0); ImplCycleCollectionTraverse
(cb, tmp->mSourceElement, "mSourceElement", 0); ImplCycleCollectionTraverse
(cb, tmp->mNavigationHandlerList, "mNavigationHandlerList"
, 0); ImplCycleCollectionTraverse(cb, tmp->mAbortController
, "mAbortController", 0); (void)tmp; return NS_OK; } void NavigateEvent
::cycleCollection::Trace( void* p, const TraceCallbacks& aCallbacks
, void* aClosure) { NavigateEvent* tmp = DowncastCCParticipant
<NavigateEvent>(p); nsISupports* s = static_cast<nsISupports
*>(p); Event::cycleCollection::Trace(s, aCallbacks, aClosure
); do { static_assert( mozilla::detail::AssertionConditionType
<decltype(!IsSingleZoneJSHolder())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!IsSingleZoneJSHolder()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("!IsSingleZoneJSHolder()"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 26); AnnotateMozCrashReason
("MOZ_ASSERT" "(" "!IsSingleZoneJSHolder()" ")"); do { MOZ_CrashSequence
(__null, 26); __attribute__((nomerge)) ::abort(); } while (false
); } } while (false); ImplCycleCollectionTrace(aCallbacks, tmp
->mInfo, "mInfo", aClosure); (void)tmp; }
27
28NS_IMPL_ADDREF_INHERITED(NavigateEvent, Event)MozExternalRefCountType NavigateEvent::AddRef(void) { static_assert
(!std::is_destructible_v<NavigateEvent>, "Reference-counted class "
"NavigateEvent" " should not have a public destructor. " "Make this class's destructor non-public"
); nsrefcnt r = Event::AddRef(); if constexpr (::mozilla::detail
::ShouldLogInheritedRefcnt<NavigateEvent>) { NS_LogAddRef
((this), (r), ("NavigateEvent"), (uint32_t)(sizeof(*this))); }
return r; }
29NS_IMPL_RELEASE_INHERITED(NavigateEvent, Event)MozExternalRefCountType NavigateEvent::Release(void) { nsrefcnt
r = Event::Release(); if constexpr (::mozilla::detail::ShouldLogInheritedRefcnt
<NavigateEvent>) { NS_LogRelease((this), (r), ("NavigateEvent"
)); } return r; }
30
31NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(NavigateEvent)nsresult NavigateEvent::QueryInterface(const nsIID& aIID,
void** aInstancePtr) { do { if (!(aInstancePtr)) { NS_DebugBreak
(NS_DEBUG_ASSERTION, "QueryInterface requires a non-NULL destination!"
, "aInstancePtr", "/root/firefox-clang/dom/events/NavigateEvent.cpp"
, 31); MOZ_PretendNoReturn(); } } while (0); nsISupports* foundInterface
; if (TopThreeWordsEquals( aIID, (nsXPCOMCycleCollectionParticipant
::kIID), (nsCycleCollectionISupports::kIID)) && (LowWordEquals
(aIID, (nsXPCOMCycleCollectionParticipant::kIID)) || LowWordEquals
(aIID, (nsCycleCollectionISupports::kIID)))) { if (LowWordEquals
(aIID, (nsXPCOMCycleCollectionParticipant::kIID))) { *aInstancePtr
= NavigateEvent::cycleCollection::GetParticipant(); return NS_OK
; } if (LowWordEquals(aIID, (nsCycleCollectionISupports::kIID
))) { *aInstancePtr = NavigateEvent::cycleCollection::Upcast(
this); return NS_OK; } foundInterface = nullptr; } else
32NS_INTERFACE_MAP_END_INHERITING(Event)foundInterface = 0; nsresult status; if (!foundInterface) status
= Event::QueryInterface(aIID, (void**)&foundInterface); else
{ (foundInterface)->AddRef(); status = NS_OK; } *aInstancePtr
= foundInterface; return status; }
33
34JSObject* NavigateEvent::WrapObjectInternal(JSContext* aCx,
35 JS::Handle<JSObject*> aGivenProto) {
36 return NavigateEvent_Binding::Wrap(aCx, this, aGivenProto);
37}
38
39/* static */
40already_AddRefed<NavigateEvent> NavigateEvent::Constructor(
41 const GlobalObject& aGlobal, const nsAString& aType,
42 const NavigateEventInit& aEventInitDict) {
43 nsCOMPtr<mozilla::dom::EventTarget> eventTarget =
44 do_QueryInterface(aGlobal.GetAsSupports());
45 return Constructor(eventTarget, aType, aEventInitDict);
46}
47
48/* static */
49already_AddRefed<NavigateEvent> NavigateEvent::Constructor(
50 EventTarget* aEventTarget, const nsAString& aType,
51 const NavigateEventInit& aEventInitDict) {
52 RefPtr<NavigateEvent> event = new NavigateEvent(aEventTarget);
53 bool trusted = event->Init(aEventTarget);
54 event->InitEvent(
55 aType, aEventInitDict.mBubbles ? CanBubble::eYes : CanBubble::eNo,
56 aEventInitDict.mCancelable ? Cancelable::eYes : Cancelable::eNo,
57 aEventInitDict.mComposed ? Composed::eYes : Composed::eNo);
58 event->InitNavigateEvent(aEventInitDict);
59 event->SetTrusted(trusted);
60 return event.forget();
61}
62
63/* static */
64already_AddRefed<NavigateEvent> NavigateEvent::Constructor(
65 EventTarget* aEventTarget, const nsAString& aType,
66 const NavigateEventInit& aEventInitDict,
67 nsIStructuredCloneContainer* aClassicHistoryAPIState,
68 class AbortController* aAbortController) {
69 RefPtr<NavigateEvent> event =
70 Constructor(aEventTarget, aType, aEventInitDict);
71
72 event->mAbortController = aAbortController;
73 MOZ_DIAGNOSTIC_ASSERT(event->mSignal == aAbortController->Signal())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(event->mSignal == aAbortController->Signal())>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(event->mSignal == aAbortController->Signal()))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("event->mSignal == aAbortController->Signal()"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 73); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "event->mSignal == aAbortController->Signal()"
")"); do { MOZ_CrashSequence(__null, 73); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
74
75 event->mClassicHistoryAPIState = aClassicHistoryAPIState;
76
77 return event.forget();
78}
79
80NavigationType NavigateEvent::NavigationType() const { return mNavigationType; }
81
82already_AddRefed<NavigationDestination> NavigateEvent::Destination() const {
83 return do_AddRef(mDestination);
84}
85
86bool NavigateEvent::CanIntercept() const { return mCanIntercept; }
87
88bool NavigateEvent::UserInitiated() const { return mUserInitiated; }
89
90bool NavigateEvent::HashChange() const { return mHashChange; }
91
92AbortSignal* NavigateEvent::Signal() const { return mSignal; }
93
94already_AddRefed<FormData> NavigateEvent::GetFormData() const {
95 return do_AddRef(mFormData);
96}
97
98void NavigateEvent::GetDownloadRequest(nsAString& aDownloadRequest) const {
99 aDownloadRequest = mDownloadRequest;
100}
101
102void NavigateEvent::GetInfo(JSContext* aCx,
103 JS::MutableHandle<JS::Value> aInfo) const {
104 aInfo.set(mInfo);
105}
106
107bool NavigateEvent::HasUAVisualTransition() const {
108 return mHasUAVisualTransition;
109}
110
111Element* NavigateEvent::GetSourceElement() const { return mSourceElement; }
112
113template <typename OptionEnum>
114static void MaybeReportWarningToConsole(Document* aDocument,
115 const nsString& aOption,
116 OptionEnum aPrevious, OptionEnum aNew) {
117 if (!aDocument) {
118 return;
119 }
120
121 nsTArray<nsString> params = {aOption,
122 NS_ConvertUTF8toUTF16(GetEnumString(aNew)),
123 NS_ConvertUTF8toUTF16(GetEnumString(aPrevious))};
124 nsContentUtils::ReportToConsole(
125 nsIScriptError::warningFlag, "DOM"_ns, aDocument,
126 nsContentUtils::eDOM_PROPERTIES,
127 "PreviousInterceptCallOptionOverriddenWarning", params);
128}
129
130// https://html.spec.whatwg.org/#dom-navigateevent-intercept
131void NavigateEvent::Intercept(const NavigationInterceptOptions& aOptions,
132 ErrorResult& aRv) {
133 // Step 1
134 if (PerformSharedChecks(aRv); aRv.Failed()) {
135 return;
136 }
137
138 // Step 2
139 if (!mCanIntercept) {
140 aRv.ThrowSecurityError("Event's canIntercept was initialized to false");
141 return;
142 }
143
144 // Step 3
145 if (!IsBeingDispatched()) {
146 aRv.ThrowInvalidStateError("Event has never been dispatched");
147 return;
148 }
149
150 // Step 4
151 MOZ_DIAGNOSTIC_ASSERT(mInterceptionState == InterceptionState::None ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mInterceptionState == InterceptionState::None || mInterceptionState
== InterceptionState::Intercepted)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mInterceptionState == InterceptionState
::None || mInterceptionState == InterceptionState::Intercepted
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"mInterceptionState == InterceptionState::None || mInterceptionState == InterceptionState::Intercepted"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 152); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "mInterceptionState == InterceptionState::None || mInterceptionState == InterceptionState::Intercepted"
")"); do { MOZ_CrashSequence(__null, 152); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
152 mInterceptionState == InterceptionState::Intercepted)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mInterceptionState == InterceptionState::None || mInterceptionState
== InterceptionState::Intercepted)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mInterceptionState == InterceptionState
::None || mInterceptionState == InterceptionState::Intercepted
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"mInterceptionState == InterceptionState::None || mInterceptionState == InterceptionState::Intercepted"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 152); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "mInterceptionState == InterceptionState::None || mInterceptionState == InterceptionState::Intercepted"
")"); do { MOZ_CrashSequence(__null, 152); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
153
154 // Step 5
155 mInterceptionState = InterceptionState::Intercepted;
156
157 // Step 6
158 if (aOptions.mHandler.WasPassed()) {
159 mNavigationHandlerList.AppendElement(
160 aOptions.mHandler.InternalValue().get());
161 }
162
163 // Step 7
164 if (aOptions.mFocusReset.WasPassed()) {
165 // Step 7.1
166 if (mFocusResetBehavior &&
167 *mFocusResetBehavior != aOptions.mFocusReset.Value()) {
168 RefPtr<Document> document = GetDocument();
169 MaybeReportWarningToConsole(document, u"focusReset"_ns,
170 *mFocusResetBehavior,
171 aOptions.mFocusReset.Value());
172 }
173
174 // Step 7.2
175 mFocusResetBehavior.emplace(aOptions.mFocusReset.Value());
176 }
177
178 // Step 8
179 if (aOptions.mScroll.WasPassed()) {
180 // Step 8.1
181 if (mScrollBehavior && *mScrollBehavior != aOptions.mScroll.Value()) {
182 RefPtr<Document> document = GetDocument();
183 MaybeReportWarningToConsole(document, u"scroll"_ns, *mScrollBehavior,
184 aOptions.mScroll.Value());
185 }
186
187 // Step 8.2
188 mScrollBehavior.emplace(aOptions.mScroll.Value());
189 }
190}
191
192// https://html.spec.whatwg.org/#dom-navigateevent-scroll
193void NavigateEvent::Scroll(ErrorResult& aRv) {
194 // Step 1
195 if (PerformSharedChecks(aRv); aRv.Failed()) {
196 return;
197 }
198
199 // Step 2
200 if (mInterceptionState != InterceptionState::Committed) {
201 aRv.ThrowInvalidStateError("NavigateEvent was not committed");
202 return;
203 }
204
205 // Step 3
206 ProcessScrollBehavior();
207}
208
209NavigateEvent::NavigateEvent(EventTarget* aOwner)
210 : Event(aOwner, nullptr, nullptr) {
211 mozilla::HoldJSObjects(this);
212}
213
214NavigateEvent::~NavigateEvent() { DropJSObjects(this); }
215
216void NavigateEvent::InitNavigateEvent(const NavigateEventInit& aEventInitDict) {
217 mNavigationType = aEventInitDict.mNavigationType;
218 mDestination = aEventInitDict.mDestination;
219 mCanIntercept = aEventInitDict.mCanIntercept;
220 mUserInitiated = aEventInitDict.mUserInitiated;
221 mHashChange = aEventInitDict.mHashChange;
222 mSignal = aEventInitDict.mSignal;
223 mFormData = aEventInitDict.mFormData;
224 mDownloadRequest = aEventInitDict.mDownloadRequest;
225 mInfo = aEventInitDict.mInfo;
226 mHasUAVisualTransition = aEventInitDict.mHasUAVisualTransition;
227 mSourceElement = aEventInitDict.mSourceElement;
228}
229
230void NavigateEvent::SetCanIntercept(bool aCanIntercept) {
231 mCanIntercept = aCanIntercept;
232}
233
234enum NavigateEvent::InterceptionState NavigateEvent::InterceptionState() const {
235 return mInterceptionState;
236}
237
238void NavigateEvent::SetInterceptionState(
239 enum InterceptionState aInterceptionState) {
240 mInterceptionState = aInterceptionState;
241}
242
243nsIStructuredCloneContainer* NavigateEvent::ClassicHistoryAPIState() const {
244 return mClassicHistoryAPIState;
245}
246
247nsTArray<RefPtr<NavigationInterceptHandler>>&
248NavigateEvent::NavigationHandlerList() {
249 return mNavigationHandlerList;
250}
251
252AbortController* NavigateEvent::AbortController() const {
253 return mAbortController;
254}
255
256bool NavigateEvent::IsBeingDispatched() const {
257 return mEvent->mFlags.mIsBeingDispatched;
258}
259
260// https://html.spec.whatwg.org/#navigateevent-finish
261void NavigateEvent::Finish(bool aDidFulfill) {
262 switch (mInterceptionState) {
263 // Step 1
264 case InterceptionState::Intercepted:
265 case InterceptionState::Finished:
266 MOZ_DIAGNOSTIC_ASSERT(false)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false", "/root/firefox-clang/dom/events/NavigateEvent.cpp"
, 266); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
")"); do { MOZ_CrashSequence(__null, 266); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
267 break;
268 // Step 2
269 case InterceptionState::None:
270 return;
271 default:
272 break;
273 }
274
275 // Step 3
276 PotentiallyResetFocus();
277
278 // Step 4
279 if (aDidFulfill) {
280 PotentiallyProcessScrollBehavior();
281 }
282
283 // Step 5
284 mInterceptionState = InterceptionState::Finished;
285}
286
287// https://html.spec.whatwg.org/#navigateevent-perform-shared-checks
288void NavigateEvent::PerformSharedChecks(ErrorResult& aRv) {
289 // Step 1
290 if (RefPtr document = GetDocument();
291 !document || !document->IsFullyActive()) {
292 aRv.ThrowInvalidStateError("Document isn't fully active");
293 return;
294 }
295
296 // Step 2
297 if (!IsTrusted()) {
298 aRv.ThrowSecurityError("Event is untrusted");
299 return;
300 }
301
302 // Step 3
303 if (DefaultPrevented()) {
304 aRv.ThrowInvalidStateError("Event was canceled");
305 }
306}
307
308// https://html.spec.whatwg.org/#potentially-reset-the-focus
309void NavigateEvent::PotentiallyResetFocus() {
310 // Step 1
311 MOZ_DIAGNOSTIC_ASSERT(mInterceptionState == InterceptionState::Committed ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mInterceptionState == InterceptionState::Committed ||
mInterceptionState == InterceptionState::Scrolled)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(mInterceptionState == InterceptionState::Committed || mInterceptionState
== InterceptionState::Scrolled))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("mInterceptionState == InterceptionState::Committed || mInterceptionState == InterceptionState::Scrolled"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 312); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "mInterceptionState == InterceptionState::Committed || mInterceptionState == InterceptionState::Scrolled"
")"); do { MOZ_CrashSequence(__null, 312); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
312 mInterceptionState == InterceptionState::Scrolled)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mInterceptionState == InterceptionState::Committed ||
mInterceptionState == InterceptionState::Scrolled)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(mInterceptionState == InterceptionState::Committed || mInterceptionState
== InterceptionState::Scrolled))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("mInterceptionState == InterceptionState::Committed || mInterceptionState == InterceptionState::Scrolled"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 312); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "mInterceptionState == InterceptionState::Committed || mInterceptionState == InterceptionState::Scrolled"
")"); do { MOZ_CrashSequence(__null, 312); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
313
314 // Step 2
315 nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetParentObject());
316
317 // If we don't have a window here, there's not much we can do. This could
318 // potentially happen in a chrome context, and in the end it's just better to
319 // be sure and null check.
320 if (NS_WARN_IF(!window)NS_warn_if_impl(!window, "!window", "/root/firefox-clang/dom/events/NavigateEvent.cpp"
, 320)
) {
321 return;
322 }
323
324 Navigation* navigation = window->Navigation();
325
326 // Step 3
327 bool focusChanged = navigation->FocusedChangedDuringOngoingNavigation();
328
329 // Step 4
330 navigation->SetFocusedChangedDuringOngoingNavigation(false);
331
332 // Step 5
333 if (focusChanged) {
334 return;
335 }
336
337 // Step 6
338 if (mFocusResetBehavior &&
339 *mFocusResetBehavior == NavigationFocusReset::Manual) {
340 return;
341 }
342
343 // Step 7
344 Document* document = window->GetExtantDoc();
345
346 // If we don't have a document here, there's not much we can do.
347 if (NS_WARN_IF(!document)NS_warn_if_impl(!document, "!document", "/root/firefox-clang/dom/events/NavigateEvent.cpp"
, 347)
) {
348 return;
349 }
350
351 // Step 8
352 Element* focusTarget = document->GetDocumentElement();
353 if (focusTarget) {
354 focusTarget =
355 focusTarget->GetAutofocusDelegate(mozilla::IsFocusableFlags(0));
356 }
357
358 // Step 9
359 if (!focusTarget) {
360 focusTarget = document->GetBody();
361 }
362
363 // Step 10
364 if (!focusTarget) {
365 focusTarget = document->GetDocumentElement();
Value stored to 'focusTarget' is never read
366 }
367
368 // The remaining steps will be implemented in Bug 1948253.
369
370 // Step 11: Run the focusing steps for focusTarget, with document's viewport
371 // as the fallback target.
372 // Step 12: Move the sequential focus navigation starting point to
373 // focusTarget.
374}
375
376// https://html.spec.whatwg.org/#potentially-process-scroll-behavior
377void NavigateEvent::PotentiallyProcessScrollBehavior() {
378 // Step 1
379 MOZ_DIAGNOSTIC_ASSERT(mInterceptionState == InterceptionState::Committed ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mInterceptionState == InterceptionState::Committed ||
mInterceptionState == InterceptionState::Scrolled)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(mInterceptionState == InterceptionState::Committed || mInterceptionState
== InterceptionState::Scrolled))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("mInterceptionState == InterceptionState::Committed || mInterceptionState == InterceptionState::Scrolled"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 380); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "mInterceptionState == InterceptionState::Committed || mInterceptionState == InterceptionState::Scrolled"
")"); do { MOZ_CrashSequence(__null, 380); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
380 mInterceptionState == InterceptionState::Scrolled)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mInterceptionState == InterceptionState::Committed ||
mInterceptionState == InterceptionState::Scrolled)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(mInterceptionState == InterceptionState::Committed || mInterceptionState
== InterceptionState::Scrolled))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("mInterceptionState == InterceptionState::Committed || mInterceptionState == InterceptionState::Scrolled"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 380); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "mInterceptionState == InterceptionState::Committed || mInterceptionState == InterceptionState::Scrolled"
")"); do { MOZ_CrashSequence(__null, 380); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
381
382 // Step 2
383 if (mInterceptionState == InterceptionState::Scrolled) {
384 return;
385 }
386
387 // Step 3
388 if (mScrollBehavior && *mScrollBehavior == NavigationScrollBehavior::Manual) {
389 return;
390 }
391
392 // Process 4
393 ProcessScrollBehavior();
394}
395
396// Here we want to scroll to the beginning of the document, as described in
397// https://drafts.csswg.org/cssom-view/#scroll-to-the-beginning-of-the-document
398MOZ_CAN_RUN_SCRIPT
399static void ScrollToBeginningOfDocument(Document& aDocument) {
400 RefPtr<PresShell> presShell = aDocument.GetPresShell();
401 if (!presShell) {
402 return;
403 }
404
405 RefPtr<Element> rootElement = aDocument.GetRootElement();
406 ScrollAxis vertical(WhereToScroll::Start, WhenToScroll::Always);
407 presShell->ScrollContentIntoView(rootElement, vertical, ScrollAxis(),
408 ScrollFlags::TriggeredByScript);
409}
410
411// https://html.spec.whatwg.org/#restore-scroll-position-data
412static void RestoreScrollPositionData(Document* aDocument) {
413 if (!aDocument || aDocument->HasBeenScrolled()) {
414 return;
415 }
416
417 // This will be implemented in Bug 1955947. Make sure to move this to
418 // `SessionHistoryEntry`/`SessionHistoryInfo`.
419}
420
421// https://html.spec.whatwg.org/#process-scroll-behavior
422void NavigateEvent::ProcessScrollBehavior() {
423 // Step 1
424 MOZ_DIAGNOSTIC_ASSERT(mInterceptionState == InterceptionState::Committed)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mInterceptionState == InterceptionState::Committed)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(mInterceptionState == InterceptionState::Committed))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("mInterceptionState == InterceptionState::Committed"
, "/root/firefox-clang/dom/events/NavigateEvent.cpp", 424); AnnotateMozCrashReason
("MOZ_DIAGNOSTIC_ASSERT" "(" "mInterceptionState == InterceptionState::Committed"
")"); do { MOZ_CrashSequence(__null, 424); __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
425
426 // Step 2
427 mInterceptionState = InterceptionState::Scrolled;
428
429 // Step 3
430 if (mNavigationType == NavigationType::Traverse ||
431 mNavigationType == NavigationType::Reload) {
432 RefPtr<Document> document = GetDocument();
433 RestoreScrollPositionData(document);
434 return;
435 }
436
437 // Step 4.1
438 RefPtr<Document> document = GetDocument();
439 // If there is no document there's not much to do.
440 if (!document) {
441 return;
442 }
443
444 // Step 4.2
445 nsAutoCString ref;
446 if (nsIURI* uri = document->GetDocumentURI();
447 NS_SUCCEEDED(uri->GetRef(ref))((bool)(__builtin_expect(!!(!NS_FAILED_impl(uri->GetRef(ref
))), 1)))
&&
448 !nsContentUtils::GetTargetElement(document, NS_ConvertUTF8toUTF16(ref))) {
449 ScrollToBeginningOfDocument(*document);
450 return;
451 }
452
453 // Step 4.3
454 document->ScrollToRef();
455}
456} // namespace mozilla::dom