Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: be5caf9bf0c4db410091fd1dc0d655780f3b7b4e
      
https://github.com/WebKit/WebKit/commit/be5caf9bf0c4db410091fd1dc0d655780f3b7b4e
  Author: Charlie Wolfe <[email protected]>
  Date:   2024-10-21 (Mon, 21 Oct 2024)

  Changed paths:
    M Source/WebCore/history/BackForwardCache.cpp
    M Source/WebCore/history/BackForwardCache.h
    M Source/WebCore/history/HistoryItem.cpp
    M Source/WebCore/loader/FrameLoader.cpp
    M Source/WebCore/loader/HistoryController.cpp
    M Source/WebCore/loader/NavigationScheduler.cpp
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebKit/Shared/GoToBackForwardItemParameters.h
    M Source/WebKit/Shared/GoToBackForwardItemParameters.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/WebBackForwardListFrameItem.cpp
    M Source/WebKit/Shared/WebBackForwardListFrameItem.h
    M Source/WebKit/Shared/WebBackForwardListItem.cpp
    M Source/WebKit/Shared/WebBackForwardListItem.h
    M Source/WebKit/Shared/WebPageCreationParameters.h
    M Source/WebKit/Shared/WebPageCreationParameters.serialization.in
    M Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
    M Source/WebKit/UIProcess/WebBackForwardList.cpp
    M Source/WebKit/UIProcess/WebBackForwardList.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/WebProcess/WebCoreSupport/SessionStateConversion.cpp
    M Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp
    M Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
    M Source/WebKit/WebProcess/WebProcess.cpp

  Log Message:
  -----------
  Remove web process history item maps and begin using session state stored in 
the UI process
https://bugs.webkit.org/show_bug.cgi?id=281844
rdar://138295365

Reviewed by Alex Christensen.

This patch removes the hash maps that store all history items in the web 
process, replacing them with the
session state stored in the UI process. Now, instead of the UI process using 
`BackForwardItemIdentifier`
to reference history items in the web process, the full history state is sent 
over IPC. This change will
make the implementation of navigation and session history with site isolation 
much simpler.

I needed to make the following changes to make this work correctly:
 - Compare history items using `BackForwardItemIdentifier` instead of their 
addresses in memory. Since
   history items are now constructed using state retrieved from the UI process, 
they can no longer be
   compared using their addresses. `BackForwardItemIdentifier` is unique per 
history item, and preserved
   when sent between processes.

 - Track back/forward state restored from another session in the UI process. 
Previously, when restoring
   session state, the state was sent to the web process to be stored in the 
history maps, and a boolean
   was set to indicate that the history item was restored.

 - Add state to `FrameState` that previously only existed on `HistoryItem`.

 - Update session state on `WebBackForwardListFrameItem` when its corresponding 
`HistoryItem` in the web
   process changes.

More details provided below.

* Source/WebCore/history/BackForwardCache.cpp:
(WebCore::BackForwardCache::remove):
* Source/WebCore/history/BackForwardCache.h:
Add a remove function that takes a `BackForwardItemIdentifier`, so the UI 
process can remove back/forward
cache state without a `HistoryItem`.

* Source/WebCore/history/HistoryItem.cpp:
(WebCore::HistoryItem::clearChildren):
Notify the UI process when a history item’s children have been cleared.

(WebCore::HistoryItem::setDocumentState):
Notify the UI process when a history item's document state has been updated.

(WebCore::HistoryItem::shouldDoSameDocumentNavigationTo const):

(WebCore::HistoryItem::~HistoryItem): Deleted.
HistoryItem can now be destroyed without removing its back/forward cache state, 
so remove this assertion.

* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
* Source/WebCore/loader/HistoryController.cpp:
(WebCore::HistoryController::restoreDocumentState):
(WebCore::HistoryController::itemsAreClones const):
(WebCore::HistoryController::replaceState):
* Source/WebCore/loader/NavigationScheduler.cpp:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::clearPreviousItemFromAllPages):
* Source/WebCore/page/Page.h:
* Source/WebKit/Shared/GoToBackForwardItemParameters.h:
* Source/WebKit/Shared/GoToBackForwardItemParameters.serialization.in:

* Source/WebKit/Shared/SessionState.cpp:
(WebKit::FrameState::FrameState):
(WebKit::FrameState::copy):
* Source/WebKit/Shared/SessionState.h:
* Source/WebKit/Shared/SessionState.serialization.in:
Add `wasRestoredFromSession` to `FrameState`, since this state is now stored in 
the UI process and needs
to be included when sent to the web process.

* Source/WebKit/Shared/WebBackForwardListFrameItem.cpp:
(WebKit::WebBackForwardListFrameItem::setWasRestoredFromSession):

(WebKit::WebBackForwardListFrameItem::setChild):
(WebKit::WebBackForwardListFrameItem::updateChildFrameState):
(WebKit::WebBackForwardListFrameItem::setFrameState):
(WebKit::WebBackForwardListFrameItem::addChild): Deleted.
* Source/WebKit/Shared/WebBackForwardListFrameItem.h:
(WebKit::WebBackForwardListFrameItem::setFrameState): Deleted.
Update these functions to correctly update their state when a history item that 
does not correspond to a
root frame is updated in the web process.

* Source/WebKit/Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::protectedRootFrameItem):
(WebKit::WebBackForwardListItem::setRootFrameState):
(WebKit::WebBackForwardListItem::setWasRestoredFromSession):
* Source/WebKit/Shared/WebBackForwardListItem.h:

* Source/WebKit/Shared/WebPageCreationParameters.h:
* Source/WebKit/Shared/WebPageCreationParameters.serialization.in:
`itemStates` no longer needs to be sent to the web process on page creation.

* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::goToBackForwardItem):
Mark items that are being restored from another session in the UI process, and 
remove the IPC message
that did the same for the items in the web process.

* Source/WebKit/UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::setItemsAsRestoredFromSession):
(WebKit::WebBackForwardList::setItemsAsRestoredFromSessionIf):
(WebKit::WebBackForwardList::filteredItemStates const): Deleted.
(WebKit::WebBackForwardList::itemStates const): Deleted.
* Source/WebKit/UIProcess/WebBackForwardList.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::launchProcessForReload):
(WebKit::WebPageProxy::goToBackForwardItem):
(WebKit::WebPageProxy::restoreFromSessionState):
(WebKit::WebPageProxy::backForwardAddItemShared):
(WebKit::WebPageProxy::backForwardSetChildItem):
(WebKit::WebPageProxy::backForwardItemAtIndex):
(WebKit::WebPageProxy::creationParameters):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::shouldSendPendingMessage):
(WebKit::WebProcessProxy::updateBackForwardItem):
Change this function to be able to update session state for non-root frames.

* Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp:
(WebKit::toFrameState):
(WebKit::applyFrameState):
Update session state conversion to include `wasRestoredFromSession`. Also add a 
missing call to
`setWasCreatedByJSWithoutUserInteraction` when converting from `FrameState` to 
`HistoryItem`.

* Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::WebBackForwardListProxy::removeItem):
(WebKit::WebBackForwardListProxy::addItem):
(WebKit::WebBackForwardListProxy::itemAtIndex):
(WebKit::WebBackForwardListProxy::containsItem const):
(WebKit::idToHistoryItemMap): Deleted.
(WebKit::WebBackForwardListProxy::addItemFromUIProcess): Deleted.
(WebKit::WebBackForwardListProxy::itemForID): Deleted.
* Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h:
Remove all code needed to interact with the history item hash maps.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::m_textAnimationController):
(WebKit::WebPage::goToBackForwardItem):
Use `toHistoryItem()` to convert from `FrameState`. UI process session state 
should not be updated during
this conversion.

(WebKit::WebPage::setCurrentHistoryItemForReattach):
(WebKit::WebPage::restoreSessionInternal): Deleted.
(WebKit::WebPage::restoreSession): Deleted.
(WebKit::WebPage::updateBackForwardListForReattach): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
Remove now unneeded functions used to add history items from another session.

* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::clearCachedPage):

Canonical link: https://commits.webkit.org/285517@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