Add globally-unique HistoryItem identifiers (and have WebKit2 adopt them).
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2018 18:45:40 +0000 (18:45 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2018 18:45:40 +0000 (18:45 +0000)
commita04a29a2ab60b58dc03c9d23ec714caf24eb76b8
tree6d0034e7af4ee549d630b950c82cc182fecac6a9
parent8815c5aedf35282986635bb6aefdfc35069d277e
Add globally-unique HistoryItem identifiers (and have WebKit2 adopt them).
<rdar://problem/39533949> and https://bugs.webkit.org/show_bug.cgi?id=184750

Reviewed by Ryosuke Niwa.

Source/WebCore:

No new tests (Refactor, no behavior change).

In WebCore, we:
- Add a process-unique "BackForwardItemIdentifier"
- Make all HistoryItems have such an identifier as a member

* WebCore.xcodeproj/project.pbxproj:

* history/BackForwardItemIdentifier.h: Added.
(WebCore::BackForwardItemIdentifier::logString const):
(WebCore::operator==):
(WebCore::BackForwardItemIdentifier::encode const):
(WebCore::BackForwardItemIdentifier::decode):
(WebCore::BackForwardItemIdentifier::hash const):
(WTF::BackForwardItemIdentifierHash::hash):
(WTF::BackForwardItemIdentifierHash::equal):
(WTF::HashTraits<WebCore::BackForwardItemIdentifier>::emptyValue):
(WTF::HashTraits<WebCore::BackForwardItemIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::BackForwardItemIdentifier>::isDeletedValue):

* history/HistoryItem.cpp:
(WebCore::HistoryItem::generateSequenceNumber):
(WebCore::HistoryItem::HistoryItem):
(WebCore::generateSequenceNumber): Deleted.

* history/HistoryItem.h:
(WebCore::HistoryItem::create):
(WebCore::HistoryItem::identifier const):

Source/WebKit:

With process swapping, the assumption that "back/forward items belong to a process" is invalid.

All HistoryItem/WebBackForwardListItems now need to be uniquely identified across all processes,
no matter which process they originated from, so there will never be a collision in the UIProcess.

This allows us to:
- Have the UIProcess to keep a single process-wide map of all WebBackForwardListItems
- Get rid of the per-WebProcess WebBackForwardListItem map
- Simplify a lot of WebBackForwardList(Proxy) code that no longer needs to keep that per-process
  map in sync
- Get rid of a lot of other ancillary code

* Shared/SessionState.cpp:
(WebKit::BackForwardListItemState::decode):
* Shared/SessionState.h:

* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::WebBackForwardListItem):
(WebKit::WebBackForwardListItem::~WebBackForwardListItem):
(WebKit::WebBackForwardListItem::itemForID):
(WebKit::WebBackForwardListItem::highestUsedItemID): Deleted.
* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::itemID const):

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:

* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::itemForID):
(WebKit::WebBackForwardList::pageClosed):
(WebKit::WebBackForwardList::addItem):
(WebKit::WebBackForwardList::restoreFromState):
(WebKit::generateWebBackForwardItemID): Deleted.
* UIProcess/WebBackForwardList.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::maybeCreateSuspendedPage):
(WebKit::WebPageProxy::initializeWebPage):
(WebKit::WebPageProxy::willGoToBackForwardListItem):
(WebKit::WebPageProxy::restoreFromSessionState):
(WebKit::WebPageProxy::backForwardAddItem):
(WebKit::WebPageProxy::backForwardGoToItem):
(WebKit::WebPageProxy::backForwardItemAtIndex):
(WebKit::WebPageProxy::creationParameters):
(WebKit::WebPageProxy::backForwardRemovedItem):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

* UIProcess/WebProcessPool.cpp: Explicitly set the UIProcess Process::Identifier so it starts
  at "1" and then the first child process starts at "2", etc etc.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::removeWebPage):
(WebKit::WebProcessProxy::checkURLReceivedFromWebProcess):
(WebKit::WebProcessProxy::updateBackForwardItem):
(WebKit::WebProcessProxy::webBackForwardItem const): Deleted.
(WebKit::WebProcessProxy::registerNewWebBackForwardListItem): Deleted.
(WebKit::WebProcessProxy::removeBackForwardItem): Deleted.
(WebKit::WebProcessProxy::addOrUpdateBackForwardItem): Deleted.
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:

* WebProcess/WebCoreSupport/SessionStateConversion.cpp:
(WebKit::toBackForwardListItemState):
(WebKit::applyFrameState):
(WebKit::toHistoryItem):
(WebKit::toPageState): Deleted.
* WebProcess/WebCoreSupport/SessionStateConversion.h:

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::shouldGoToHistoryItem const):

* WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::WebBackForwardListProxy::addItemFromUIProcess):
(WebKit::WK2NotifyHistoryItemChanged):
(WebKit::WebBackForwardListProxy::itemForID):
(WebKit::WebBackForwardListProxy::removeItem):
(WebKit::WebBackForwardListProxy::addItem): Previously this was a two-step process of adding an item
  to the process and then associating it with the page. Now it's just directly adding it to the page,
  so we don't need to call updateBackForwardItem first.
(WebKit::WebBackForwardListProxy::goToItem):
(WebKit::WebBackForwardListProxy::itemAtIndex):
(WebKit::WebBackForwardListProxy::close):
(WebKit::historyItemToIDMap): Deleted.
(WebKit::generateHistoryItemID): Deleted.
(WebKit::WebBackForwardListProxy::setHighestItemIDFromUIProcess): Deleted.
(WebKit::updateBackForwardItem): Deleted.
(WebKit::WebBackForwardListProxy::idForItem): Deleted.
* WebProcess/WebPage/WebBackForwardListProxy.h:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_credentialsMessenger):
(WebKit::WebPage::goToBackForwardItem):
(WebKit::WebPage::restoreSessionInternal):
(WebKit::WebPage::didRemoveBackForwardItem):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Source/WTF:

* wtf/DebugUtilities.h:
(WTF::debugString):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/DebugUtilities.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/history/BackForwardItemIdentifier.h [new file with mode: 0644]
Source/WebCore/history/HistoryItem.cpp
Source/WebCore/history/HistoryItem.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/SessionState.cpp
Source/WebKit/Shared/SessionState.h
Source/WebKit/Shared/WebBackForwardListItem.cpp
Source/WebKit/Shared/WebBackForwardListItem.h
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/UIProcess/API/glib/WebKitWebViewSessionState.cpp
Source/WebKit/UIProcess/WebBackForwardList.cpp
Source/WebKit/UIProcess/WebBackForwardList.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/UIProcess/WebProcessProxy.messages.in
Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp
Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.h
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp
Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in