Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace unique frame names with frame identifiers in the history controller #28385

Conversation

charliewolfe
Copy link
Member

@charliewolfe charliewolfe commented May 10, 2024

686240c

Replace unique frame names with frame identifiers in the history controller
https://bugs.webkit.org/show_bug.cgi?id=273995
rdar://127870100

Reviewed by Alex Christensen.

With site isolation, unique frame names should not be used to identify frames. This patch replaces most
of their usage in the history controller with frame identifiers. We cannot remove unique frame names from
`HistoryItem` because logic in `FrameLoader::loadURLIntoChildFrame` requires us to match current frames
with frames from a previous page. Unique frame names are also still used from session state and history
test output.

This also fixes a bug introduced by 277393@main, where shifting frames after a navigation could cause
the back/forward list to target an incorrect frame.

* Source/WebCore/history/HistoryItem.cpp:
(WebCore::HistoryItem::HistoryItem):
(WebCore::HistoryItem::reset):
(WebCore::HistoryItem::addChildItem):
(WebCore::HistoryItem::childItemWithFrameID):
* Source/WebCore/history/HistoryItem.h:
(WebCore::HistoryItem::frameID const):
(WebCore::HistoryItem::setFrameID):
* Source/WebCore/loader/HistoryController.cpp:
(WebCore::HistoryController::initializeItem):
(WebCore::HistoryController::recursiveSetProvisionalItem):
(WebCore::HistoryController::recursiveGoToItem):
* Source/WebCore/page/FrameTree.cpp:
(WebCore::FrameTree::childByFrameID const):
(WebCore::FrameTree::childByUniqueName const): Deleted.
* Source/WebCore/page/FrameTree.h:
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::formControlStateOfPreviousHistoryItem):
(WebCore::Internals::setFormControlStateOfPreviousHistoryItem):
* Source/WebKit/Shared/SessionState.h:
* Source/WebKit/Shared/SessionState.serialization.in:
* Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp:
(WebKit::toFrameState):
(WebKit::applyFrameState):
* Tools/TestWebKitAPI/Tests/WebKit/WKBackForwardListTests.mm:
(TEST(WKBackForwardList, BackForwardListRemoveAndAddSubframes)):

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

7259570

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac   πŸ§ͺ api-wpe
  πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 ⏳ πŸ›  wpe-skia
  πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2   πŸ§ͺ gtk-wk2
  πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress   πŸ§ͺ api-gtk
βœ… πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge   πŸ›  watch-sim

@charliewolfe charliewolfe self-assigned this May 10, 2024
@charliewolfe charliewolfe added the History For bugs involving global and per-WebView history, including back/forward list. label May 10, 2024
@charliewolfe charliewolfe force-pushed the eng/Replace-unique-frame-names-with-frame-identifiers-in-the-history-controller branch from 4a782f6 to 4260d1c Compare May 10, 2024 10:13
@charliewolfe charliewolfe marked this pull request as ready for review May 10, 2024 18:31
@charliewolfe charliewolfe requested a review from cdumez as a code owner May 10, 2024 18:31
@charliewolfe charliewolfe force-pushed the eng/Replace-unique-frame-names-with-frame-identifiers-in-the-history-controller branch from 4260d1c to 7259570 Compare May 10, 2024 20:53
@charliewolfe charliewolfe added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 10, 2024
…roller

https://bugs.webkit.org/show_bug.cgi?id=273995
rdar://127870100

Reviewed by Alex Christensen.

With site isolation, unique frame names should not be used to identify frames. This patch replaces most
of their usage in the history controller with frame identifiers. We cannot remove unique frame names from
`HistoryItem` because logic in `FrameLoader::loadURLIntoChildFrame` requires us to match current frames
with frames from a previous page. Unique frame names are also still used from session state and history
test output.

This also fixes a bug introduced by 277393@main, where shifting frames after a navigation could cause
the back/forward list to target an incorrect frame.

* Source/WebCore/history/HistoryItem.cpp:
(WebCore::HistoryItem::HistoryItem):
(WebCore::HistoryItem::reset):
(WebCore::HistoryItem::addChildItem):
(WebCore::HistoryItem::childItemWithFrameID):
* Source/WebCore/history/HistoryItem.h:
(WebCore::HistoryItem::frameID const):
(WebCore::HistoryItem::setFrameID):
* Source/WebCore/loader/HistoryController.cpp:
(WebCore::HistoryController::initializeItem):
(WebCore::HistoryController::recursiveSetProvisionalItem):
(WebCore::HistoryController::recursiveGoToItem):
* Source/WebCore/page/FrameTree.cpp:
(WebCore::FrameTree::childByFrameID const):
(WebCore::FrameTree::childByUniqueName const): Deleted.
* Source/WebCore/page/FrameTree.h:
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::formControlStateOfPreviousHistoryItem):
(WebCore::Internals::setFormControlStateOfPreviousHistoryItem):
* Source/WebKit/Shared/SessionState.h:
* Source/WebKit/Shared/SessionState.serialization.in:
* Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp:
(WebKit::toFrameState):
(WebKit::applyFrameState):
* Tools/TestWebKitAPI/Tests/WebKit/WKBackForwardListTests.mm:
(TEST(WKBackForwardList, BackForwardListRemoveAndAddSubframes)):

Canonical link: https://commits.webkit.org/278629@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Replace-unique-frame-names-with-frame-identifiers-in-the-history-controller branch from 7259570 to 686240c Compare May 10, 2024 21:22
@webkit-commit-queue
Copy link
Collaborator

Committed 278629@main (686240c): https://commits.webkit.org/278629@main

Reviewed commits have been landed. Closing PR #28385 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 686240c into WebKit:main May 10, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
History For bugs involving global and per-WebView history, including back/forward list.
Projects
None yet
4 participants