Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9b13b53b41a196d0fa64076a7d0239843b4eec09
https://github.com/WebKit/WebKit/commit/9b13b53b41a196d0fa64076a7d0239843b4eec09
Author: Charlie Wolfe <[email protected]>
Date: 2025-01-03 (Fri, 03 Jan 2025)
Changed paths:
M Source/WebCore/Headers.cmake
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/history/BackForwardCache.cpp
M Source/WebCore/history/BackForwardClient.h
M Source/WebCore/history/BackForwardController.cpp
M Source/WebCore/history/BackForwardController.h
A Source/WebCore/history/BackForwardFrameItemIdentifier.h
M Source/WebCore/history/HistoryItem.cpp
M Source/WebCore/history/HistoryItem.h
M Source/WebCore/loader/EmptyClients.cpp
M Source/WebCore/loader/EmptyFrameLoaderClient.h
M Source/WebCore/loader/FrameLoader.cpp
M Source/WebCore/loader/HistoryController.cpp
M Source/WebCore/loader/HistoryController.h
M Source/WebCore/loader/LocalFrameLoaderClient.h
M Source/WebCore/loader/NavigationAction.cpp
M Source/WebCore/loader/NavigationScheduler.cpp
M Source/WebCore/page/Page.cpp
M Source/WebKit/Scripts/webkit/messages.py
M Source/WebKit/Scripts/webkit/tests/MessageArgumentDescriptions.cpp
M Source/WebKit/Shared/ProcessQualified.serialization.in
M Source/WebKit/Shared/SessionState.cpp
M Source/WebKit/Shared/SessionState.h
M Source/WebKit/Shared/SessionState.serialization.in
M Source/WebKit/Shared/WTFArgumentCoders.serialization.in
M Source/WebKit/Shared/WebBackForwardListFrameItem.cpp
M Source/WebKit/Shared/WebBackForwardListFrameItem.h
M Source/WebKit/Shared/WebBackForwardListItem.cpp
M Source/WebKit/Shared/WebBackForwardListItem.h
M Source/WebKit/UIProcess/API/APINavigation.cpp
M Source/WebKit/UIProcess/API/APINavigation.h
M Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItem.mm
M Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
M Source/WebKit/UIProcess/ProvisionalPageProxy.h
M Source/WebKit/UIProcess/WebBackForwardCache.cpp
M Source/WebKit/UIProcess/WebBackForwardList.cpp
M Source/WebKit/UIProcess/WebBackForwardList.h
M Source/WebKit/UIProcess/WebFrameProxy.cpp
M Source/WebKit/UIProcess/WebNavigationState.cpp
M Source/WebKit/UIProcess/WebNavigationState.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/WebPageProxy.messages.in
M Source/WebKit/UIProcess/WebProcessProxy.cpp
M Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm
M Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp
M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp
M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.h
M Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp
M Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Source/WebKitLegacy/mac/History/BackForwardList.h
M Source/WebKitLegacy/mac/History/BackForwardList.mm
M Source/WebKitLegacy/mac/History/WebBackForwardList.mm
M Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
M Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
M Source/WebKitLegacy/mac/WebView/WebView.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm
M Tools/TestWebKitAPI/cocoa/TestWKWebView.h
M Tools/TestWebKitAPI/cocoa/TestWKWebView.mm
Log Message:
-----------
Web processes should only commit history state for navigating frames and
their children
https://bugs.webkit.org/show_bug.cgi?id=285224
rdar://142134339
Reviewed by Alex Christensen.
Currently, when a frame navigates, the web process creates history state for
the entire frame tree to be
committed to the UI process. This needs to change with site isolation because a
navigating iframe may
have parent frames that are out-of-process, which we cannot synchronously
create history state for.
Instead, when a frame navigates, the web process should only create and commit
history state for the
navigating frame and its children. If the navigating frame is a child frame, we
can use the current item
in the UI process's back/forward list to populate the history state for its
ancestors.
On navigation, only frames that navigate will be assigned a new
WebBackForwardListFrameItem, while the
history item tree created for the new navigation will always receive a new
WebBackForwardListItem. This
allows the UI process to correctly update the history for isolated iframes that
did not navigate but had
a sibling in another process that did.
No change in behavior with site isolation disabled (hopefully). More details
below.
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/history/BackForwardCache.cpp:
(WebCore::BackForwardCache::addIfCacheable):
(WebCore::BackForwardCache::take):
(WebCore::BackForwardCache::get):
(WebCore::BackForwardCache::remove):
* Source/WebCore/history/BackForwardClient.h:
* Source/WebCore/history/BackForwardController.cpp:
(WebCore::BackForwardController::addItem):
(WebCore::BackForwardController::setChildItem):
* Source/WebCore/history/BackForwardController.h:
* Source/WebCore/history/BackForwardFrameItemIdentifier.h: Added.
* Source/WebCore/history/HistoryItem.cpp:
(WebCore::HistoryItem::HistoryItem):
(WebCore::HistoryItem::isInBackForwardCache const):
(WebCore::HistoryItem::hasCachedPageExpired const):
(WebCore::HistoryItem::shouldDoSameDocumentNavigationTo const):
(WebCore::HistoryItem::logString const):
* Source/WebCore/history/HistoryItem.h:
(WebCore::HistoryItem::create):
(WebCore::HistoryItem::itemID const):
(WebCore::HistoryItem::frameItemID const):
(WebCore::HistoryItem::operator== const):
(WebCore::HistoryItem::identifier const): Deleted.
Assign HistoryItems a BackForwardFrameItemIdentifier, which is unique for each
frame in a history item
tree. BackForwardItemIdentifier now only identifies history item trees.
* Source/WebCore/loader/EmptyClients.cpp:
(WebCore::EmptyFrameLoaderClient::createHistoryItemTree const):
* Source/WebCore/loader/EmptyFrameLoaderClient.h:
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
* Source/WebCore/loader/HistoryController.cpp:
(WebCore::HistoryController::restoreDocumentState):
(WebCore::HistoryController::goToItem):
(WebCore::HistoryController::goToItemForNavigationAPI):
(WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
(WebCore::HistoryController::createItem):
(WebCore::HistoryController::createItemTree):
(WebCore::HistoryController::itemsAreClones):
(WebCore::HistoryController::updateBackForwardListClippedAtTarget):
Call createItemTree on the navigating frame instead of the root frame. Disabled
for WebKit1.
(WebCore::HistoryController::pushState):
* Source/WebCore/loader/HistoryController.h:
* Source/WebCore/loader/LocalFrameLoaderClient.h:
* Source/WebCore/loader/NavigationAction.cpp:
(WebCore::NavigationAction::setTargetBackForwardItem):
(WebCore::NavigationAction::setSourceBackForwardItem):
* Source/WebCore/loader/NavigationScheduler.cpp:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::clearPreviousItemFromAllPages):
(WebCore::Page::goToItem):
(WebCore::Page::goToItemForNavigationAPI):
* Source/WebKit/Scripts/webkit/messages.py:
(serialized_identifiers):
(types_that_cannot_be_forward_declared):
(headers_for_type):
* Source/WebKit/Scripts/webkit/tests/MessageArgumentDescriptions.cpp:
(IPC::serializedIdentifiers):
* Source/WebKit/Shared/ProcessQualified.serialization.in:
* Source/WebKit/Shared/SessionState.cpp:
(WebKit::FrameState::FrameState):
(WebKit::FrameState::copy):
(WebKit::FrameState::replaceChildFrameState):
* Source/WebKit/Shared/SessionState.h:
* Source/WebKit/Shared/SessionState.serialization.in:
* Source/WebKit/Shared/WTFArgumentCoders.serialization.in:
* Source/WebKit/Shared/WebBackForwardListFrameItem.cpp:
(WebKit::WebBackForwardListFrameItem::create):
(WebKit::WebBackForwardListFrameItem::WebBackForwardListFrameItem):
(WebKit::WebBackForwardListFrameItem::~WebBackForwardListFrameItem):
(WebKit::WebBackForwardListFrameItem::allItems):
(WebKit::WebBackForwardListFrameItem::itemForID):
(WebKit::WebBackForwardListFrameItem::url const):
(WebKit::WebBackForwardListFrameItem::childItemForTarget):
(WebKit::WebBackForwardListFrameItem::setChild):
(WebKit::WebBackForwardListFrameItem::mainFrame):
(WebKit::WebBackForwardListFrameItem::protectedMainFrame):
(WebKit::WebBackForwardListFrameItem::setFrameState):
(WebKit::WebBackForwardListFrameItem::identifier const): Deleted.
* Source/WebKit/Shared/WebBackForwardListFrameItem.h:
(WebKit::WebBackForwardListFrameItem::identifier const):
* Source/WebKit/Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::create):
(WebKit::WebBackForwardListItem::WebBackForwardListItem):
(WebKit::WebBackForwardListItem::~WebBackForwardListItem):
(WebKit::WebBackForwardListItem::itemIsInSameDocument const):
(WebKit::WebBackForwardListItem::itemIsClone):
(WebKit::WebBackForwardListItem::navigatedFrameState const):
(WebKit::WebBackForwardListItem::mainFrameState const):
(WebKit::WebBackForwardListItem::originalURL const):
(WebKit::WebBackForwardListItem::url const):
(WebKit::WebBackForwardListItem::title const):
(WebKit::WebBackForwardListItem::wasCreatedByJSWithoutUserInteraction const):
(WebKit::WebBackForwardListItem::setWasRestoredFromSession):
(WebKit::WebBackForwardListItem::navigatedFrameItem const):
(WebKit::WebBackForwardListItem::protectedNavigatedFrameItem const):
(WebKit::WebBackForwardListItem::mainFrameItem const):
(WebKit::WebBackForwardListItem::loggingString):
(WebKit::WebBackForwardListItem::itemID const): Deleted.
(WebKit::WebBackForwardListItem::setRootFrameState): Deleted.
(WebKit::WebBackForwardListItem::rootFrameState const): Deleted.
(WebKit::WebBackForwardListItem::protectedRootFrameItem): Deleted.
(WebKit::WebBackForwardListItem::setParentFromItem): Deleted.
This function is no longer needed because items for remote child frame
navigations now have their parents
set during WebBackForwardListItem construction.
* Source/WebKit/Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::identifier const):
(WebKit::WebBackForwardListItem::setNavigatedFrameID): Deleted.
(WebKit::WebBackForwardListItem::rootFrameItem): Deleted.
Replace rootFrameState() and rootFrameItem() with mainFrameState() and
mainFrameItem(), as each item
should now have a WebBackForwardListFrameItem for the main frame.
* Source/WebKit/UIProcess/API/APINavigation.cpp:
(API::Navigation::Navigation):
(API::Navigation::targetItem const):
(API::Navigation::loggingString const):
Changed m_targetItem to hold a WebBackForwardListFrameItem, so we can use it to
navigate the correct
frame in ProvisionalPageProxy::goToBackForwardItem().
* Source/WebKit/UIProcess/API/APINavigation.h:
(API::Navigation::create):
(API::Navigation::protectedTargetItem const):
(API::Navigation::targetFrameItem const):
(API::Navigation::targetItem const): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItem.mm:
(-[WKBackForwardListItem _scrollPosition]):
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::goToBackForwardItem):
(WebKit::ProvisionalPageProxy::backForwardAddItem):
* Source/WebKit/UIProcess/ProvisionalPageProxy.h:
* Source/WebKit/UIProcess/WebBackForwardCache.cpp:
(WebKit::WebBackForwardCache::addEntry):
(WebKit::WebBackForwardCache::removeEntry):
(WebKit::WebBackForwardCache::takeSuspendedPage):
* Source/WebKit/UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::itemForID):
(WebKit::WebBackForwardList::addItem):
(WebKit::WebBackForwardList::goToItemInternal):
(WebKit::WebBackForwardList::backForwardListState const):
(WebKit::setBackForwardItemIdentifiers):
(WebKit::WebBackForwardList::restoreFromState):
completeFrameStateForNavigation() needs to refer to the current back/forward
item to correctly complete
frame state for navigating child frame items. So, m_provisionalIndex is cleared
earlier, and
m_currentIndex now points to the last entry in m_entries during restoration of
the back/forward list.
(WebKit::WebBackForwardList::didRemoveItem):
(WebKit::setBackForwardItemIdentifier):
(WebKit::WebBackForwardList::completeFrameStateForNavigation):
This function completes the FrameState for navigating child frames. The
BackForwardItemIdentifiers from
the current item are regenerated when set on the new item, as the web process
must be able to uniquely
address each WebBackForwardListFrameItem.
* Source/WebKit/UIProcess/WebBackForwardList.h:
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::loadData):
This is needed to pass the message checks in
WebPageProxy::backForwardAddItemShared, since the added item
can now be a child frame URL.
* Source/WebKit/UIProcess/WebNavigationState.cpp:
(WebKit::WebNavigationState::createBackForwardNavigation):
* Source/WebKit/UIProcess/WebNavigationState.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::suspendCurrentPageIfPossible):
(WebKit::WebPageProxy::launchProcessForReload):
(WebKit::WebPageProxy::goForward):
(WebKit::WebPageProxy::goBack):
(WebKit::WebPageProxy::goToBackForwardItem):
If a frame no longer exists, such as when the web process crashes and the page
is reloaded, we cannot
instruct the web process to load a history item into it and should instead send
the entire frame tree.
Not doing this would mean loading an iframe URL in the main frame.
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::backForwardAddItem):
(WebKit::WebPageProxy::backForwardAddItemShared):
(WebKit::WebPageProxy::backForwardSetChildItem):
(WebKit::WebPageProxy::backForwardUpdateItem):
(WebKit::WebPageProxy::backForwardClearProvisionalItem):
(WebKit::WebPageProxy::backForwardItemAtIndex):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::shouldSendPendingMessage):
* Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
* Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp:
(WebKit::toFrameState):
(WebKit::applyFrameState):
(WebKit::toHistoryItem):
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::shouldGoToHistoryItem const):
(WebKit::WebLocalFrameLoaderClient::createHistoryItemTree const):
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.h:
* Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::WebBackForwardListProxy::addItem):
The parameter indicating which frame is being navigated can be removed, since
the frame at the top of the
tree being committed will now always be the navigating frame.
(WebKit::WebBackForwardListProxy::setChildItem):
(WebKit::WebBackForwardListProxy::goToItem):
(WebKit::WebBackForwardListProxy::goToProvisionalItem):
(WebKit::WebBackForwardListProxy::clearProvisionalItem):
(WebKit::WebBackForwardListProxy::containsItem const):
* Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::goToBackForwardItem):
* Source/WebKitLegacy/mac/History/BackForwardList.h:
* Source/WebKitLegacy/mac/History/BackForwardList.mm:
(BackForwardList::addItem):
* Source/WebKitLegacy/mac/History/WebBackForwardList.mm:
(-[WebBackForwardList addItem:]):
(-[WebBackForwardList setToMatchDictionaryRepresentation:]):
* Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h:
* Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::createHistoryItemTree const):
Creating history item trees from the navigating frame doesn't make sense in
WebKit1, so disable it.
* Source/WebKitLegacy/mac/WebView/WebView.mm:
(-[WebView _loadBackForwardListFromOtherView:]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::TEST(SiteIsolation,
GoBackToNestedIframeCreatedAfterNavigatingSibling)):
* Tools/TestWebKitAPI/cocoa/TestWKWebView.h:
* Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView secondChildFrame]):
Canonical link: https://commits.webkit.org/288409@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