Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 17a1ef8126c8d8187ebb7e09f0732da4e5d89501
      
https://github.com/WebKit/WebKit/commit/17a1ef8126c8d8187ebb7e09f0732da4e5d89501
  Author: Brent Fulgham <[email protected]>
  Date:   2025-02-05 (Wed, 05 Feb 2025)

  Changed paths:
    M Source/WebCore/Headers.cmake
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    A Source/WebCore/dom/DocumentEnums.h
    M Source/WebCore/loader/FrameLoader.cpp
    M Source/WebCore/loader/NavigationScheduler.cpp
    M Source/WebCore/page/DOMWindow.cpp
    M Source/WebCore/page/DOMWindow.h
    M Source/WebCore/page/History.cpp
    M Source/WebCore/page/LocalDOMWindow.cpp
    M Source/WebCore/page/LocalDOMWindow.h
    M Source/WebCore/page/Location.cpp
    M Source/WebCore/page/Navigation.cpp
    M Source/WebCore/page/RemoteDOMWindow.cpp
    M Source/WebCore/page/RemoteDOMWindow.h

  Log Message:
  -----------
  Avoid performing a `canNavigate` check multiple times on the same URL during 
a load
https://bugs.webkit.org/show_bug.cgi?id=285706
<rdar://142633698>

Reviewed by Alex Christensen.

The various refactoring involved in SiteIsolation cause `setLocation` to do two 
checks
of `canNavigate`, when only one check is needed. Since this is a costly 
operation, we
should avoid this duplicate call.

Both Local- and Remote-DOMWindow instances `setLocation` are called from 
`Location::setLocation`,
which performs the `canNavigate` check so that it can generate a required JS 
Exception. This
means the Local- and Remote-DOMWindow copies of this check are unneeded.

Help prevent future developers from failing to call `canNavigate` before 
`setLocation` by
creating an enum to represent navigability. Trigger an ASSERT if the caller 
uses the
default `CanNavigateState`. If the caller indicates that the document cannot 
navigate, fall
back to the current behavior of checking `canNavigate`.

* Source/WebCore/Headers.cmake: Add new header.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj: Ditto.
* Source/WebCore/dom/Document.h: Use new header.
* Source/WebCore/dom/DocumentEnums.h: Added.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::canNavigate): Return a new enum value for navigability.
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::findFrameForNavigation): Update canNavigate call for new 
return type.
* Source/WebCore/loader/NavigationScheduler.cpp:
* Source/WebCore/page/DOMWindow.cpp:
(WebCore::DOMWindow::close): Ditto.
* Source/WebCore/page/DOMWindow.h:
* Source/WebCore/page/History.cpp:
(WebCore::History::go): Ditto.
* Source/WebCore/page/LocalDOMWindow.cpp:
(WebCore::LocalDOMWindow::setLocation): Implement new logic to confirm 
navigability is valid, and fall
back to checking canNavigate (the current behavior) if it's in an unusual 
state. We should fast-past
to not calling canNavigate in all known use cases, but should avoid a change in 
behavior if a developer
forgets to check navigation state before calling.
(WebCore::LocalDOMWindow::open): Update to new canNavigate return type.
* Source/WebCore/page/Location.cpp:
(WebCore::Location::setLocation): Pass new canNavigate return type.
* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::performTraversal): Ditto.
* Source/WebCore/page/RemoteDOMWindow.cpp:
(WebCore::RemoteDOMWindow::setLocation): Same changes as 
LocalDOMWindow::setLocation.

Canonical link: https://commits.webkit.org/289890@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to