Skip to content

nba.com: Unable to scrub volume slider using gaze and pinch [visionOS] and touch [iPadOS] - #60950

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
J0pan:eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS
Mar 30, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
J0pan:eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS

Conversation

@J0pan

@J0pan J0pan commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

11d18b9

nba.com: Unable to scrub volume slider using gaze and pinch [visionOS] and touch [iPadOS]
https://bugs.webkit.org/show_bug.cgi?id=310228
rdar://147428926

Reviewed by Aditya Keerthi.

The problem was that when the user touches a <input type="range">,
the touch had to land precisely on the thumb point of the slider
for it to work (very hard to achieve).
The fix matches UIKit's UISlider behaviour,
it expands the thumb's touch hit area by 12.5pt if the
thumb is smaller than 48pt in either dimension.

Test generated with assistance from Claude.

Test: fast/forms/ios/drag-range-track.html

* LayoutTests/fast/events/touch/ios/touch-event-regions-layer-tree/range-sliders.html:
* LayoutTests/fast/forms/ios/drag-range-track-expected.txt: Added.
* LayoutTests/fast/forms/ios/drag-range-track.html: Added.
* LayoutTests/interaction-region/form-control-refresh/slider-thumb-native-interaction-region-expected.txt:
* LayoutTests/interaction-region/input-type-range-region-expected.txt:
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::handleTouchStart):
* Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::inflateRectForInteractionRegion):

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

b7b199d

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe   🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2   🧪 win-tests
✅ 🧪 webkitperl   🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
  🧪 ios-wk2-wpt   🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
  🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
  🛠 vision   🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress   🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
  🛠 watch
  🛠 watch-sim

@J0pan
J0pan requested review from cdumez and rniwa as code owners March 19, 2026 18:38
@J0pan
J0pan force-pushed the eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS branch from bc62d0e to 47a5ebb Compare March 20, 2026 22:23
@J0pan
J0pan requested a review from aprotyas March 20, 2026 22:35
@lilyspiniolas

Copy link
Copy Markdown
Contributor

Why do we change the size of the thumb in the layout test? Doesn't that defeat the purpose?

@pxlcoder

Copy link
Copy Markdown
Member

Why do we change the size of the thumb in the layout test? Doesn't that defeat the purpose?

I'd hope the values match nba.com.

@lilyspiniolas

Copy link
Copy Markdown
Contributor

nba.com styles the slider thumb with appearance: none so it is unclear to me how expanding the hit box of the thumb would fix this. Have you verified this works? Regardless, I don't think this change makes sense. This is occurring specifically because the site is resizing the control extremely small, so expanding it universally does not seem right to me.

@lilyspiniolas lilyspiniolas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see prior comment)

@J0pan

J0pan commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

nba.com styles the slider thumb with appearance: none so it is unclear to me how expanding the hit box of the thumb would fix this. Have you verified this works? Regardless, I don't think this change makes sense. This is occurring specifically because the site is resizing the control extremely small, so expanding it universally does not seem right to me.

Yes I've verified that this works manually. I was considering making it a quirk, but the issue is also reproducible on other websites. The expanded size is arbitrary, that's why I originally implemented this behavior to match MacOS, where a user could drag the volume up and down anywhere on the track.

@lilyspiniolas

lilyspiniolas commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

nba.com styles the slider thumb with appearance: none so it is unclear to me how expanding the hit box of the thumb would fix this. Have you verified this works? Regardless, I don't think this change makes sense. This is occurring specifically because the site is resizing the control extremely small, so expanding it universally does not seem right to me.

Yes I've verified that this works manually. I was considering making it a quirk, but the issue is also reproducible on other websites. The expanded size is arbitrary, that's why I originally implemented this behavior to match MacOS, where a user could drag the volume up and down anywhere on the track.

At the very least, we should only expand the hit region if the size is below a certain threshold (I'm still not 100% sure how I feel about even that, though. Definitely would like to hear multiple opinions on this). If that does end up being the solution here, we also need to verify that the size of the gaze glow region on visionOS matches the expanded area as well.

@pxlcoder

pxlcoder commented Mar 20, 2026 •

Copy link
Copy Markdown
Member

we should only expand the hit region if the size is below a certain threshold

I think this is the right thing to do. Our controls are intended to follow platform convention, and this is what the platform (UIKit) does. The thumb's hit area is expanded by 12.5pt if the thumb is smaller than 48pt in either dimension.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 21, 2026
@J0pan
J0pan force-pushed the eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS branch from 47a5ebb to 3b61cb2 Compare March 23, 2026 23:52
@J0pan
J0pan requested a review from pxlcoder March 23, 2026 23:53
@J0pan
J0pan force-pushed the eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS branch from 3b61cb2 to d080542 Compare March 24, 2026 03:11
@J0pan
J0pan force-pushed the eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS branch from d080542 to d225de5 Compare March 24, 2026 19:03
@lilyspiniolas

Copy link
Copy Markdown
Contributor

We should have a test in interaction-region which verifies the gaze glow region is also inflated. Updating fast/events/touch/iOS/touch-event-regions-layer-tree/range-sliders.html to include a test case where we inflate the button would be ideal as well.

@J0pan
J0pan force-pushed the eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS branch from d225de5 to 8b62b09 Compare March 27, 2026 20:36
@brentfulgham brentfulgham added the safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks label Mar 27, 2026
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Failed ios-wk2, ios-wk2-wpt, vision-wk2 checks. Please resolve failures and re-apply safe-merge-queue label.

Rejecting #60950 from merge queue.

@webkit-ews-buildbot webkit-ews-buildbot removed the safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks label Mar 28, 2026
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

Safe-Merge-Queue: Build #87912.

@J0pan
J0pan force-pushed the eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS branch from 8b62b09 to b7b199d Compare March 30, 2026 21:50
@brentfulgham brentfulgham added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Mar 30, 2026
…] and touch [iPadOS]

https://bugs.webkit.org/show_bug.cgi?id=310228
rdar://147428926

Reviewed by Aditya Keerthi.

The problem was that when the user touches a <input type="range">,
the touch had to land precisely on the thumb point of the slider
for it to work (very hard to achieve).
The fix matches UIKit's UISlider behaviour,
it expands the thumb's touch hit area by 12.5pt if the
thumb is smaller than 48pt in either dimension.

Test generated with assistance from Claude.

Test: fast/forms/ios/drag-range-track.html

* LayoutTests/fast/events/touch/ios/touch-event-regions-layer-tree/range-sliders.html:
* LayoutTests/fast/forms/ios/drag-range-track-expected.txt: Added.
* LayoutTests/fast/forms/ios/drag-range-track.html: Added.
* LayoutTests/interaction-region/form-control-refresh/slider-thumb-native-interaction-region-expected.txt:
* LayoutTests/interaction-region/input-type-range-region-expected.txt:
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::handleTouchStart):
* Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::inflateRectForInteractionRegion):

Canonical link: https://commits.webkit.org/310265@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/nba-com-Unable-to-scrub-volume-slider-using-gaze-and-pinch-visionOS-and-touch-iPadOS branch from b7b199d to 11d18b9 Compare March 30, 2026 23:17
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 310265@main (11d18b9): https://commits.webkit.org/310265@main

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

@webkit-commit-queue
webkit-commit-queue merged commit 11d18b9 into WebKit:main Mar 30, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 30, 2026
webkit-commit-queue pushed a commit to J0pan/WebKit that referenced this pull request Apr 29, 2026
https://bugs.webkit.org/show_bug.cgi?id=313574
rdar://174429082

Reviewed by Lily Spiniolas, Aditya Keerthi, and Abrar Rahman Protyasha.

The problem: The previous fix 310265@main WebKit#60950
expanded the slider thumb's touch hit area and interaction region by 12.5pt when either
dimension is below 48pt. The touch hit area was correct and matched UIKit, but
the interaction region (the visible gaze glow highlight) was too large.

The fix: UIKit does not enlarge the gaze glow, so to match that behaviour, the
interaction region inflation for slider thumbs in inflateRectForInteractionRegion
is removed.

* LayoutTests/interaction-region/form-control-refresh/slider-thumb-native-interaction-region-expected.txt:
* LayoutTests/interaction-region/input-type-range-region-expected.txt:
* Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::inflateRectForInteractionRegion):

Canonical link: https://commits.webkit.org/312271@main
Jarred-Sumner added a commit to oven-sh/WebKit that referenced this pull request May 1, 2026
* [iOS] currentTime updates only as often as a MediaDeviceRoute updates currentPlaybackPosition
https://bugs.webkit.org/show_bug.cgi?id=313557
rdar://175774587

Reviewed by Eric Carlson.

When MediaPlayerPrivateWirelessPlayback is in use, a media element's currentTime is tied to the
MediaDeviceRoute's currentPlaybackPosition, but from WebKit's perspective there is no guarantee
that currentPlaybackPosition will update at a reasonable interval during playback.

To resolve this, added a CMTimebase to MediaPlayerPrivateWirelessPlayback that is configured with
the route's playbackSpeed and currentPlaybackPosition. A timebase observer is added that fires
every 100ms (in the media timeline) to update currentTime. This interval matches the one we use in
MediaPlayerPrivateAVFoundation's periodic time observer, providing smoothed estimated time updates
during wireless playback.

While here, simplified how we handle seeks. Removed the "pending seek" concept from
MediaPlayerPrivateWirelessPlayback and instead assumed that a seek occurs whenever
currentPlaybackPositionDidChange is called.

Tests: media/wireless-playback-media-player/current-time-advances-between-position-updates.html
       media/wireless-playback-media-player/current-time-resumes-after-pause.html
       media/wireless-playback-media-player/current-time-updates-after-rate-change.html
       media/wireless-playback-media-player/current-time-updates-after-route-seek.html
       media/wireless-playback-media-player/current-time-updates-after-seek.html
       media/wireless-playback-media-player/timeupdate-without-position-updates.html

* LayoutTests/media/wireless-playback-media-player/current-time-advances-between-position-updates-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-advances-between-position-updates.html: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-resumes-after-pause-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-resumes-after-pause.html: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-rate-change-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-rate-change.html: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-route-seek-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-route-seek.html: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-seek-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-seek.html: Added.
* LayoutTests/media/wireless-playback-media-player/timeupdate-without-position-updates-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/timeupdate-without-position-updates.html: Added.
* Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp:
* Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h:
* Source/WebCore/platform/graphics/MediaPlayerPrivateWirelessPlayback.cpp:
(WebCore::MediaPlayerPrivateWirelessPlayback::~MediaPlayerPrivateWirelessPlayback):
(WebCore::MediaPlayerPrivateWirelessPlayback::play):
(WebCore::MediaPlayerPrivateWirelessPlayback::pause):
(WebCore::MediaPlayerPrivateWirelessPlayback::seekToTarget):
(WebCore::MediaPlayerPrivateWirelessPlayback::currentTime const):
(WebCore::MediaPlayerPrivateWirelessPlayback::setRate):
(WebCore::MediaPlayerPrivateWirelessPlayback::currentPlaybackPositionDidChange):
(WebCore::MediaPlayerPrivateWirelessPlayback::ensureTimebase):
(WebCore::MediaPlayerPrivateWirelessPlayback::destroyTimebase):
(WebCore::MediaPlayerPrivateWirelessPlayback::updateTimebaseTimeAndRate):
(WebCore::MediaPlayerPrivateWirelessPlayback::scheduleTimebaseTimer):
(WebCore::MediaPlayerPrivateWirelessPlayback::timebaseTimerFired):
* Source/WebCore/platform/graphics/MediaPlayerPrivateWirelessPlayback.h:

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

* [git-webkit review] Inline comments sometimes missing from the review text file
https://bugs.webkit.org/show_bug.cgi?id=313572

Reviewed by Jonathan Bedard.

Problem:
  `git-webkit review` relies on the `position` field returned by GitHub's
  pull request comments API to place each inline comment in the generated
  review text file. GitHub computes `position` against its own view of the
  pull request diff, but the diff we fetch via `application/vnd.github.diff`
  is computed against the merge base and can have a different hunk layout
  (e.g. a hunk that has already landed on main is absent from our diff).
  When GitHub's `position` lands outside the range of lines in the diff we
  fetched, the count in `insert_diff_comments` never matches and the
  comment is silently dropped — it never appears in the review text file.

Solution:
  Translate comment locations ourselves using the `line` / `original_line`
  field (the new-file line number the comment applies to), which is
  unambiguous regardless of which diff was used to compute it. A new
  `_line_to_position_map` helper walks the diff we actually fetched,
  parses `@@ -a,b +c,d @@` hunk headers, and records the position within
  our diff for each new-file line. `_diff_comments` now uses that map to
  assign each comment a position that matches the diff being displayed,
  falling back to the raw `position` field only when no line number is
  reported (preserves behavior for file-level comments and legacy/mock
  data used by the existing tests).

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:

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

* [Site Isolation] Add multi-process BackForwardCache and CachedFrame support
https://bugs.webkit.org/show_bug.cgi?id=313507
rdar://175721231

Reviewed by Sihui Liu.

Prepare BackForwardCache and CachedFrame for multi-process BFCache with
Site Isolation.

Add a new take(BackForwardFrameItemIdentifier, Page*) overload that
looks up cache entries directly by identifier rather than through a
HistoryItem. This is needed because subframe processes suspend and
restore their BFCache entries using the main frame's identifier passed
from the UIProcess, without access to the HistoryItem. The existing
take(HistoryItem&, Page*) now delegates to the new overload.

Add Page ownership validation to both take() and get(). With
multi-process BFCache, a subframe process caches its Page under the
main frame's BackForwardFrameItemIdentifier via SetSubframesSuspended.
If a different Page in the same process later navigates to the same
back/forward item, the FrameLoader's BFCache lookup can find this
subframe entry instead of a cache miss. Since the subframe's CachedPage
has a RemoteFrame main frame with no DocumentLoader, restoring from it
causes a crash. The Page validation ensures each Page only finds its own
cache entries. The take() overload checks before removing from the map
so mismatched entries are preserved for their rightful owner.

In CachedFrame, restore() now null-guards m_document to support
RemoteFrame entries. In an iframe process under Site Isolation, the
Page's main frame is a RemoteFrame with no Document — the CachedFrame
stores the frame tree structure but not a Document. The child frame
reconstruction loop and pruneDetachedChildFrames() are moved outside
the m_document guard so they execute for both LocalFrame and RemoteFrame
paths. CachedFrame::open() adds a RemoteFrame branch that calls
restore() directly, since RemoteFrames have no FrameLoader to drive the
restoration.

In FrameLoader::continueLoadAfterNavigationPolicy, replace the
isInBackForwardCache() check with BackForwardCache::get(). The former
only checks if the key exists in the cache, while the latter also
validates Page ownership. Without this, the FrameLoader can take the
BFCache restoration path using a subframe's CachedPage, stalling the
navigation instead of proceeding to the normal load path that triggers
a process swap via the UIProcess.

No new tests (no behavior change for single-process BFCache).

* Source/WebCore/history/BackForwardCache.cpp:
(WebCore::BackForwardCache::addIfCacheable):
(WebCore::BackForwardCache::take):
(WebCore::BackForwardCache::get):
* Source/WebCore/history/BackForwardCache.h:
* Source/WebCore/history/CachedFrame.cpp:
(WebCore::CachedFrameBase::restore):
(WebCore::CachedFrame::open):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):

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

* Back button not enabled in JS created windows when it should be
rdar://175516150
https://bugs.webkit.org/show_bug.cgi?id=313487

Reviewed by Richard Robinson.

Say JavaScript creates a new window.
That window starts out with a session history for items the user has never interacted with.

Once the user clicks a link on that document, we push a new session history entry that *does*
have user interaction. But when analyzing the back list we notice the previous item had no
interaction, and therefore don't reveal it to the API back/forward list.

The intention is that once the user makes a new entry by interacting, a series of non-interacted-with
items in the back list are coalesced into one logical step in the list.

311615@main accidentally broke that logic if the series of interaction-free items was at the
start of the list (as in the new window case)

This PR fixes that and gives progressions on some other API tests that had some back counts wrong.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKBackForwardListTests.mm

* Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItem.mm:
(-[WKBackForwardListItem _loggingStringForTesting]):
* Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItemPrivate.h:
* Source/WebKit/UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::itemStartingAtIndexSkippingItemsAddedByJSWithoutUserGesture const):
(WebKit::WebBackForwardList::loggingString const):
(WebKit::WebBackForwardList::loggingString): Deleted.
* Source/WebKit/UIProcess/WebBackForwardList.h:
* Source/WebKit/UIProcess/WebBackForwardList.swift:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKBackForwardListTests.mm:
(runBackForwardNavigationSkipsItemsWithoutUserGestureTest):
(TEST(WKBackForwardList, BackNavigationHijacking)):
(TEST(WKBackForwardList, ForwardSkipIteratesThroughLeadingConsecutiveJSItems)):
(TEST(WKBackForwardList, BackForwardNavigationSkipsPromiseRedirectWithoutUserInteraction)):
(TEST(WKBackForwardList, BackButtonWorksAfterUserClickFromJSCreatedPage)):

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

* [CMake] Add pal.swift to PAL Swift sources
https://bugs.webkit.org/show_bug.cgi?id=313580
rdar://175796349

Reviewed by Pascoe.

pal.swift is the umbrella module entry that re-exports the underlying
Clang module via @_exported public import pal. Sibling Swift files
(CryptoKit+UnsafeOverlays.swift, CryptoTypes.swift, RegexHelper.swift,
CryptoKitShim.swift) import via the umbrella name (pal.Core.crypto.*,
etc.). The Xcode build compiles pal.swift; the CMake build was missing
it. Add it so the umbrella re-export is present on Mac.

* Source/WebCore/PAL/pal/CMakeLists.txt:

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

* Unreviewed, reverting 312031@main.
https://bugs.webkit.org/show_bug.cgi?id=313603

Introduced debug assertion failures in EWS

Reverted changeset:

"[Site Isolation] fast/events/before-unload-navigate-different-window.html fails"

https://bugs.webkit.org/show_bug.cgi?id=313075
https://commits.webkit.org/312031@main
Canonical link: https://commits.webkit.org/312251@main

* Unreview unified build fix for MediaPlayerPrivateWirelessPlayback.cpp.
https://bugs.webkit.org/show_bug.cgi?id=313599
rdar://175804637

Reviewed by Mike Wyrzykowski.

* Source/WebCore/platform/graphics/MediaPlayerPrivateWirelessPlayback.cpp:

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

* [JSC][JSPI] Scan PinballCompletion conservative roots via a GC marking constraint
https://bugs.webkit.org/show_bug.cgi?id=307564
rdar://170156450

Reviewed by Keith Miller.

In the existing JSPI implementation, evacuated Wasm stack slices and callee saves are
registered with the VM and scanned as conservative roots. This creates a potential memory
leak. Here is the reference structure:

    Promise --> PinballCompletion --> EvacuatedStacks, Callee Saves --> ...
                                                ^
                                                |
                                               VM

The Promise is the promise that caused JSPI suspension, and it owns (transitively via
resolution handlers) the PinballCompletion with the suspended computation. Normally, when
the promise is fulfilled or rejected, PinballCompletion unregisters the evacuated stacks
and callee saves it owns, and all these objects become garbage-collectable. Also, if the
promise is forgotten without being resolved and becomes unmarked together with
PinballCompletion, PinballCompletion destructor unregisters the evacuated stacks and
callee saves, so everything is collected. However, if there happens to be a reference
chain starting in evacuated stacks or callee saves and leading back to the promise, this
transitive strong reference from the VM conservative roots will keep the promise and all
the other objects involved alive forever.

This patch prevents such a scenario. It stops treating evacuated stacks and callee saves
as VM conservative roots. Instead, a new GC constraint is introduced for PinballCompletion
objects, to scan the evacuated stacks and callee saves owned by a completion for
conservative roots only when the completion itself is marked.

This change requires some care in the implantation of evacuated stack slices. In the
original implementation the top slice is removed from a PinballCompletion and stored in
PinballHandlerContext by pinballHandlerInitContext(). Control would then return to
assembly code which would prepare the stack space for the slice and then call
pinballHandlerImplantSlice() to copy the slice data onto the stack. This creates a time
window when a stack slice has been taken out of its owner PinballCompletion, but its
contents have not yet been copied onto the stack. If GC were to run in this window, the
slice would not be scanned for conservative roots. This is not an immediate problem
because currently we do nothing in that time window that could start a GC, but it is a
fragility in case the code is changed in the future.

To avoid this fragility, we change the logic so that instead of storing the slice to
implant in PinballHandlerContext, we store the pinball object itself, and the slice is
only taken out of a PinballCompletion immediately before being implanted. We also refactor
the initialization code to make it an initializer of the PinballHandlerContext struct
instead of a static helper function.

Unified sources fixes
---------------------

The change in unified sources order with this patch, combined with the revision of JSC
header includes by https://bugs.webkit.org/show_bug.cgi?id=312585 caused build breakage.
The patch includes these additional changes unrelated to its core logic to fix the
breakage:

- TemporalPlainYearMonth.h / .cpp: Moved the addDurationToYearMonth template definition
  from the header into the .cpp file and added explicit template instantiations for
  AddOrSubtract::Add and AddOrSubtract::Subtract. The header only had a forward
  declaration of JSGlobalObject, so the globalObject->vm() call on line 91 failed with an
  incomplete type error.

- WeakMapImplInlines.h: Added #include "Symbol.h". The canBeHeldWeakly function calls
  asSymbol() which is declared in Symbol.h, but the header only had a forward declaration
  of Symbol via the include chain.

- PinballHandlerContext.cpp: Added #include "StackAlignment.h". The constructor asserts
  !(sliceByteSize % stackAlignmentBytes()), but stackAlignmentBytes() is declared in
  StackAlignment.h which wasn't included directly.

Testing
-------

- Added `jspi-gc-abandoned-suspensions.js` to reproduce the memory leak scenario described
  above.

- Refactoring changes are covered by existing tests.

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

* Avoid redundant data copy in BlobStorage::get() memory cache path
https://bugs.webkit.org/show_bug.cgi?id=313535

Reviewed by Ben Nham.

MemoryCache::get() already returns a standalone copy of the blob data
(via copyBlob) to safely release the lock. The second copyBlob in
BlobStorage::get() was copying that result again unnecessarily.

* Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
(WebKit::NetworkCache::BlobStorage::get):

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

* Fix an occasional UI process crash under SOAuthorizationSession::abort() after closing the web view
https://bugs.webkit.org/show_bug.cgi?id=313566
rdar://175108210

Reviewed by Aditya Keerthi and Abrar Rahman Protyasha.

Return early from a couple `PopUpSOAuthorizationSession` codepaths, in the case where the web view
has already been closed.

Test: SOAuthorizationPopUp.InterceptionCancelAfterClose

* Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:
(WebKit::PopUpSOAuthorizationSession::abortInternal):
(WebKit::PopUpSOAuthorizationSession::completeInternal):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SOAuthorizationTests.mm:
(TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionCancelAfterClose)):

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

* WorkerMessagingProxy objects leak after calling worker.terminate() from JavaScript
<https://bugs.webkit.org/show_bug.cgi?id=313389>
<rdar://175652847>

Reviewed by Chris Dumez.

Handle the case in `workerObjectDestroyed()` where
`workerGlobalScopeDestroyedInternal()` has already run.  When
that happens, the proxy's thread, context, and identifier are
already cleaned up -- the only remaining work is releasing the
initial construction ref via `deref()`.  Without this,
`workerObjectDestroyed()` returns early on the nullopt
identifier, leaving the ref permanently held.

Also clear `m_queuedEarlyTasks` in
`workerGlobalScopeDestroyedInternal()` because tasks queued
before the worker thread is created capture `Ref { *this }`,
forming a retain cycle through the proxy's own member vector
that prevents destruction even after `deref()` is called.

The leak was introduced in Bug 22723 (254597@main) which added
the null-context early return to `workerObjectDestroyed()` and
added `m_scriptExecutionContext = nullptr` to
`workerGlobalScopeDestroyedInternal()` as part of implementing
nested dedicated workers.

Test using `run-webkit-tests --leaks` with:
- workers/worker-set-delete-terminate-crash.html
- workers/worker-terminate-crash.html

* Source/WebCore/workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::workerObjectDestroyed):
(WebCore::WorkerMessagingProxy::workerGlobalScopeDestroyedInternal):

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

* [Site Isolation] https/wpt/resource-timing/crossorigin-servertiming.html fails
https://bugs.webkit.org/show_bug.cgi?id=313280
rdar://175553453

Reviewed by Ryosuke Niwa.

A cross-origin iframe's initial navigation should appear as a
PerformanceResourceTiming entry in the parent document's performance timeline.

Resource timing does not work in site isolation because
ResourceTiming::addResourceTiming() relies on document.parentDocument and
frame->ownerElement(), which are null in the Site Isolation case.

To address this problem, we send the ResourceTiming data to the parent WCP
via IPC in SubresourceLoader::reportResourceTiming().

Then the parent adds the information to the document's Performance
object through the new ResourceTimingInformation::addResourceTimingToDocument().

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/navigation-preload/resource-timing.https-expected.txt:
* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/loader/LocalFrameLoaderClient.cpp:
* Source/WebCore/loader/LocalFrameLoaderClient.h:
* Source/WebCore/loader/ResourceLoadTiming.h:
(WebCore::ResourceLoadTiming::ResourceLoadTiming):
* Source/WebCore/loader/ResourceTiming.cpp:
(WebCore::ResourceTiming::ResourceTiming):
(WebCore::ResourceTiming::isolatedCopy const):
(WebCore::ResourceTiming::isolatedCopy):
* Source/WebCore/loader/ResourceTiming.h:
(WebCore::ResourceTiming::ResourceTiming): Deleted.
* Source/WebCore/loader/ResourceTimingInformation.cpp:
(WebCore::ResourceTimingInformation::addResourceTimingToDocument):
(WebCore::ResourceTimingInformation::addResourceTiming):
* Source/WebCore/loader/ResourceTimingInformation.h:
* Source/WebCore/loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::reportResourceTiming):
* Source/WebCore/page/RemoteFrame.cpp:
(WebCore::RemoteFrame::addResourceTimingFromChild):
* Source/WebCore/page/RemoteFrame.h:
* Source/WebCore/page/RemoteFrameClient.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::addResourceTimingFromSubframe):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
* Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.cpp:
(WebKit::WebRemoteFrameClient::addResourceTimingFromChild):
* Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::addResourceTimingFromSubframe):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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

* ANGLE: Metal: Initialize missing fragment shader output components
https://bugs.webkit.org/show_bug.cgi?id=306150
rdar://167835037

Reviewed by Dan Glastonbury and Kimmo Kinnunen.

When fragment shader output components are expanded for Metal compatibility/validation,
only the original components were being copied in the conversion function.
The missing components were left uninitialized which led to garbage memory being written
to the framebuffer.

So add a second loop in SaturateScalarOrVectorCommon to zero-initialize the
missing components after copying the original components.

Test: webgl/webgl2-init-missing-fragment-output-components.html

* LayoutTests/webgl/webgl2-init-missing-fragment-output-components-expected.txt: Added.
* LayoutTests/webgl/webgl2-init-missing-fragment-output-components.html: Added.
* Source/ThirdParty/ANGLE/src/compiler/translator/msl/ModifyStruct.cpp:
* Source/ThirdParty/ANGLE/src/tests/gl_tests/GLSLTest.cpp:

Originally-landed-as: 305413.216@safari-7624-branch (0df3411b42dc). rdar://173969027
Canonical link: https://commits.webkit.org/312258@main

* [Site Isolation] http/tests/local/blob/navigate-blob.html fails
https://bugs.webkit.org/show_bug.cgi?id=313525

Reviewed by Brady Eidson.

This PR fixes a number of issues with site isolation pertaining to navigate-blob.html

1. Named window lookup fails across processes

When RemotePageProxy::injectPageIntoNewProcess() creates a popup's WebPage in another process,
the opener frame doesn't exist yet (IPC ordering). FrameTree::find() locates the popup by name
but isFrameFamiliarWith() rejects it because the opener is null.

Fix: Deferred opener resolution in WebPage::create() (WebPage.cpp, WebPage.h). Store unresolved
opener ID; when the opener's WebPage is later created in the same process, resolve pending
openers by calling updateOpener().

2. topDocumentSyncData not propagated during main frame process swap

When a main frame navigates cross-origin, didChangeMainDocument() in the new process broadcasts
BroadcastAllDocumentSyncData. This message arrives at ProvisionalPageProxy::didReceiveMessage(),
which has an explicit list of forwarded messages — BroadcastAllDocumentSyncData was not on it.
The message was silently dropped, so the old process (hosting subframes) never learned the new
top-level origin. Blobs created by subframes were registered with the wrong partition key.

Fix: Added BroadcastDocumentSyncData and BroadcastAllDocumentSyncData to the forwarded message
list in ProvisionalPageProxy::didReceiveMessage() (ProvisionalPageProxy.cpp).

3. topDocumentSyncData race conditions during process swap

Page::updateTopDocumentSyncData(Ref<DocumentSyncData>&&) rejected broadcasts when the main frame
was a LocalFrame with a document, so the broadcast arriving before the frame swap was ignored.
In addition, Page::setMainFrame() resets m_topDocumentSyncData unconditionally, wiping
the just-received broadcast when the main frame was replaced with a RemoteFrame.

Fix: Always accept broadcasts in updateTopDocumentSyncData, and only update m_topDocumentSyncData
from the new frame's document when the new frame is a LocalFrame with a document (Page.cpp).

4. Debug assertion failure: null opener frame

WebPageProxy assumed the opener frame still existed when processInheritedFromOpener was true.
With site isolation, the opener frame can be destroyed or replaced between the time the popup was
opened and when it later navigates. The processInheritedFromOpener flag is a sticky property set
at popup creation time. It doesn't track whether the opener frame is still alive. By the time
the popup navigates, the opener frame may have been removed by a process swap, page close, or
DOM mutation.

Fix: Fall back to ensureProcessForSite when the opener frame is gone (WebPageProxy.cpp).

5. Debug assertion in frameWasRemovedInAnotherProcess

frameWasRemovedInAnotherProcess is the normal cross-process frame synchronization message under
site isolation. When a frame is removed in one process, every other process hosting a remote
representation of that frame receives this message to tear down its RemoteFrame.

With the deferred opener resolution fix, more cross-process frame relationships are established
(popups correctly linked to openers across processes). When those frames are later removed
- during navigation, process swap, or DOM manipulation — the synchronization message legitimately
arrives at the WebPage hosting the remote representation. The ASSERT_NOT_REACHED was incorrect
because it treated a normal synchronization path as unreachable.

Fix: Removed the assertion (WebPage.cpp).

Co-authored with Claude.

Test: http/tests/local/blob/navigate-blob.html

* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::setMainFrame):
(WebCore::Page::updateTopDocumentSyncData):
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::didReceiveMessage):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::initializeWebPage):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::create):
(WebKit::WebPage::frameWasRemovedInAnotherProcess):
* Source/WebKit/WebProcess/WebPage/WebPage.h:

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

* [Site Isolation] http/wpt/fetch/fetch-metadata-for-sandbox-iframes.html fails
https://bugs.webkit.org/show_bug.cgi?id=313369

Reviewed by Chris Dumez.

When a subframe navigation triggers a process swap (e.g., localhost -> 127.0.0.1)
and a server redirect sends it back to the parent's site (127.0.0.1 -> localhost),
the UIProcess continues the load in the parent's process. The new process computes
Sec-Fetch-Site fresh - context origin = localhost (inherited from parent), request
URL = localhost - yielding "same-origin". The cross-site redirect through 127.0.0.1
is lost.

Fixed the buy by passing navigation.originalRequest() in LoadParameters's
originalRequest when continuing a redirect in loadContinuingInNonInitiatingProcess
and continueNavigationInNewProcess subframe paths. In computeFetchMetadataSite,
when the DocumentLoader is a continuing load after a provisional load started and
has a different original URL, recompute Sec-Fetch-Site by evaluating the original
URL first, then degrading for the redirect.

Tests: http/wpt/fetch/fetch-metadata-for-sandbox-iframes-reuse.html
       http/wpt/fetch/fetch-metadata-for-sandbox-iframes.html

* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WebCore/loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::SubresourceLoader):
* Source/WebCore/loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::computeFetchMetadataSite):
(WebCore::CachedResourceLoader::updateHTTPRequestHeaders):
* Source/WebCore/loader/cache/CachedResourceLoader.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedNavigationActionPolicyDecision):
(WebKit::WebPageProxy::continueNavigationInNewProcess):

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

* Remove MockParentalControlsURLFilter.h exclusion from WebCore_Private.modulemap
https://bugs.webkit.org/show_bug.cgi?id=313567
rdar://175786669

Reviewed by Richard Robinson.

Excluding it is unnecessary and may cause build issues.

No new tests needed.

* Source/WebCore/WebCore_Private.modulemap:

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

* AX: updateRelationsIfNeeded() walks the entire DOM when it should walk only the elements that have relations-attributes
https://bugs.webkit.org/show_bug.cgi?id=313445
rdar://175681348

Reviewed by Joshua Hoffman.

updateRelationsIfNeeded() previously walked every element in the entire DOM on
every rebuild, checking all 13 relation attributes per element. This is wasteful
because only a small fraction of elements have relation attributes.

Track elements with relation attributes in a WeakHashSet during the initial
full-DOM build, and maintain it incrementally as attributes change. Subsequent
rebuilds (triggered by id changes, reference target changes, etc.) iterate only
the tracked elements instead of the full DOM.

On a page with 1000 DOM elements but only 5 labels and 0 ARIA relation
attributes, the rebuild now walks 5 elements instead of 1000.

This change is a 0.51% improvement on Speedometer 3.1.

* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::handleAttributeChange):
(WebCore::AXObjectCache::performDeferredCacheUpdate):
(WebCore::AXObjectCache::updateRelationsIfNeeded):
(WebCore::AXObjectCache::updateRelationsForTree):
* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/AccessibilityObject.h:

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

* AX: On macOS, attributedStringForTextMarkerRange returns empty string for line ranges spanning nested table boundaries
https://bugs.webkit.org/show_bug.cgi?id=313508
rdar://174349841

Reviewed by Joshua Hoffman.

On macOS, attributedStringForTextMarkerRange used rangeForTextMarkerRange()
to convert text markers to a SimpleRange via CharacterOffset. This path
relies on characterOffsetsInOrder() to determine ordering, which produces
incorrect results for positions spanning across nested table boundaries
(e.g. a text node inside a cell vs. an ancestor tbody position). The
reversed range caused attributedStringForTextMarkerRange to return an
empty string, making VoiceOver read "new line" instead of the actual
line content.

Fix this by matching iOS and switching to simpleRange(), which converts
directly from the text markers' boundary points.

This commit does not address the core bug causing the reversed range. I
attempted to do this, but it ended up being complex, so a FIXME was added instead.
This commit is still a good step forward, decreasing the difference between platforms
and introducing a layout test that reproduces the issue.

* LayoutTests/accessibility/attributed-string-for-line-in-table-expected.txt: Added.
* LayoutTests/accessibility/attributed-string-for-line-in-table.html: Added.
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::characterOffsetsInOrder):
* Source/WebCore/accessibility/cocoa/AccessibilityObjectCocoa.mm:
(WebCore::AccessibilityObject::attributedStringForTextMarkerRange const):

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

* [GTK][WPE] Skia Compositor: Isolate blend-mode children in their own surface
https://bugs.webkit.org/show_bug.cgi?id=313518

Reviewed by Carlos Garcia Campos.

A child layer's blend mode must blend against the contents of its
enclosing stacking context, not whatever the parent canvas happens
to hold from unrelated ancestors.

* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.cpp:
(WebCore::SkiaCompositingLayer::computeTransformsAndAnimations):
(WebCore::SkiaCompositingLayer::recursivePaint):
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.h:

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

* Build fix: angle-bracket includes in ResourceTiming.h

Unreviewed build fix.

ResourceTiming.h is a Private framework header, so includes of
sibling headers must use angle-bracket form.

* Source/WebCore/loader/ResourceTiming.h:

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

* [CMake] Use cmake_{push,pop}_check_state() in WebKitCompilerFlags.cmake
https://bugs.webkit.org/show_bug.cgi?id=313560

Reviewed by Yusuke Suzuki.

This is a follow-up to 312222@main with a small cleanup.

* Source/cmake/WebKitCompilerFlags.cmake: Use cmake_push_check_state()
  and cmake_pop_check_state() consistently to ensure that variables
  are restored to their original values after modifying them for tests.

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

* Add FileSystem::traverseDirectory() to avoid redundant lstat() per directory entry
https://bugs.webkit.org/show_bug.cgi?id=313538

Reviewed by Darin Adler.

FileSystem::listDirectory() uses std::filesystem::directory_iterator internally,
which caches each entry's file type from readdir's d_type field. However, it only
returns filenames, discarding the cached type. Callers that need the entry type
then call FileSystem::fileType() per entry, which does a redundant lstat() syscall
to rediscover what directory_iterator already knew.

Add FileSystem::traverseDirectory() that uses directory_iterator directly and
provides both the filename and file type to the callback, reading the type from
directory_entry::symlink_status() which uses the cached d_type without a syscall.
It also avoids materializing all filenames into an intermediate Vector.

Update the four call sites that were doing listDirectory() + fileType() per entry:
NetworkCacheFileSystem, deleteAllFilesModifiedSince, DirectoryFileListCreator,
and DOMFileSystem::listDirectoryWithMetadata.

* Source/WTF/wtf/FileSystem.cpp:
(WTF::FileSystemImpl::deleteAllFilesModifiedSince):
(WTF::FileSystemImpl::traverseDirectory):
* Source/WTF/wtf/FileSystem.h:
* Source/WTF/wtf/playstation/FileSystemPlayStation.cpp:
(WTF::FileSystemImpl::traverseDirectory):
* Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::listDirectoryWithMetadata):
* Source/WebCore/html/DirectoryFileListCreator.cpp:
(WebCore::appendDirectoryFiles):
* Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp:
(WebKit::NetworkCache::traverseDirectory):

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

* [Win] Prevent cross-compilation from using Linux configs

https://bugs.webkit.org/show_bug.cgi?id=313501

Reviewed by Yusuke Suzuki.

Prevent `PKG_CONFIG_PATH` from pointing to Linux specific configs
(`.pc` files); causing build to fail.

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

* [JSC] Clean up AsyncIterator asyncDispose
https://bugs.webkit.org/show_bug.cgi?id=313345
rdar://175616055

Reviewed by Keith Miller.

1. Make promiseReturnUndefinedOnFulfilled C++ function instead. It is
   just returning an undefined.
2. Clean up asyncDispose code. Using @newResolvedPromise /
   @newRejectedPromise helpers, and coverting entire region with
   try-catch instead.

* Source/JavaScriptCore/builtins/AsyncIteratorPrototype.js:
(overriddenName.string_appeared_here.asyncDispose):
(linkTimeConstant.promiseReturnUndefinedOnFulfilled): Deleted.
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/bytecode/LinkTimeConstant.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSGlobalObject::init):

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

* [cocoa] Explicitly handle cookies with NSHTTPCookieSameSiteNone
https://bugs.webkit.org/show_bug.cgi?id=313010
rdar://175354204

Reviewed by Charlie Wolfe.

A recent change in CFNetwork results in WebKit potentially receiving a @"none"
value for the cookie's SameSite property. This wasn't previously possible
because unspecified and None were handled identically. Since the CFNetwork
change, a debug assertion within WebKit is now being triggered on some sites.
This change adds explicit support for the @"none" SameSite value.

* Source/WebCore/platform/network/cocoa/CookieCocoa.mm:
(WebCore::coreSameSitePolicy):
(WebCore::nsSameSitePolicy):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKHTTPCookieStore.mm:
(TEST(WKHTTPCookieStore, SetCookies)):

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

* REGRESSION (310265@main): Gaze glow region for slider thumb is too large
https://bugs.webkit.org/show_bug.cgi?id=313574
rdar://174429082

Reviewed by Lily Spiniolas, Aditya Keerthi, and Abrar Rahman Protyasha.

The problem: The previous fix 310265@main https://github.com/WebKit/WebKit/pull/60950
expanded the slider thumb's touch hit area and interaction region by 12.5pt when either
dimension is below 48pt. The touch hit area was correct and matched UIKit, but
the interaction region (the visible gaze glow highlight) was too large.

The fix: UIKit does not enlarge the gaze glow, so to match that behaviour, the
interaction region inflation for slider thumbs in inflateRectForInteractionRegion
is removed.

* LayoutTests/interaction-region/form-control-refresh/slider-thumb-native-interaction-region-expected.txt:
* LayoutTests/interaction-region/input-type-range-region-expected.txt:
* Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::inflateRectForInteractionRegion):

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

* [GStreamer] Gardening
https://bugs.webkit.org/show_bug.cgi?id=313632

Unreviewed, flag a webrtc test as flaky.

* LayoutTests/platform/glib/TestExpectations:

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

* [LBSE] Update geometry parsing expectations
https://bugs.webkit.org/show_bug.cgi?id=313628

Reviewed by Nikolas Zimmermann.

Update geometry parsing expectations after 312018@main.

* LayoutTests/platform/mac-tahoe-wk2-lbse-text/imported/w3c/web-platform-tests/svg/geometry/parsing/height-computed-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/imported/w3c/web-platform-tests/svg/geometry/parsing/width-computed-expected.txt:

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

* [GLIB][Debug] Gardening IPC tests
https://bugs.webkit.org/show_bug.cgi?id=306955

Unreviewed gardening.

These tests only crash/fail in debug builds.

* LayoutTests/platform/glib/TestExpectations:

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

* [GTK][WPE] `imported/w3c/web-platform-tests/css/filter-effects/crashtests/fecomponenttransfer-tablevalues-crash.html` is a flaky timeout
https://bugs.webkit.org/show_bug.cgi?id=313641

Unreviewed gardening.

* LayoutTests/platform/glib/TestExpectations:

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

* [Build Speed] Avoid parsing simde in ARM64/Darwin builds
https://bugs.webkit.org/show_bug.cgi?id=313613
rdar://175816799

Reviewed by Yusuke Suzuki.

The built-in NEON module is precompiled and equally capable. This
saves ~9GB of parsing in a full WebKit build.

* Source/WTF/wtf/simde/arm/neon.h:
* Source/WTF/wtf/simde/arm/sve.h: Only use these headers on
non-ARM64/Darwin builds.

* Source/WTF/wtf/simde/simde.h: Declare a simde-compatible API
based on the built-in NEON module. This is still 4kLoC but that's
much smaller than 150kLoC.

NOTE: We may be able to eliminate the 4kLoC in the future by adopting
SIMDE_ENABLE_NATIVE_ALIASES.

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

* REGRESSION(312211@main) [GTK] Broke copy/pasting relative URLs
https://bugs.webkit.org/show_bug.cgi?id=313649

Unreviewed test gardening.

* LayoutTests/platform/gtk/TestExpectations:

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

* REGRESSION(311201@main): Crash when loading drafts.csswg.org/css-grid-3
https://bugs.webkit.org/show_bug.cgi?id=313610
rdar://175790849

Reviewed by Antti Koivisto.

If two text nodes in the same block both get a
text-transform change in the same render tree update (e.g. both ::before
and ::after pseudo-elements), the first call clears the inline layout
and the second call enters the function (layout path is still set),
walks the children, and dereferences the now-null inline layout pointer
when it encounters an out-of-flow element - crash.

The fix adds a null check for inlineLayout() before calling
invalidateLineLayout, matching how the rest of the codebase guards this call.

* LayoutTests/fast/css/pseudo-element-text-transform-invalidation-crash-expected.txt: Added.
* LayoutTests/fast/css/pseudo-element-text-transform-invalidation-crash.html: Added.
* Source/WebCore/rendering/RenderText.cpp:
(WebCore::RenderText::updateRenderedText):

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

* REGRESSION (312195@main): ServiceWorkerProcessSwapWithNoDelay and WindowClientNavigate API tests failing
https://bugs.webkit.org/show_bug.cgi?id=313642

Reviewed by Youenn Fablet.

After 312195@main made service worker registration imports lazy, the origin list
became available much faster than before. This changed timing so that ITP's
ResourceLoadStatisticsStore::removeDataRecords() could discover and clear
service worker registrations before the tests' navigations completed.

Fix by disabling ITP in both tests, matching the pattern already used by
other service worker tests in this file.

Apply this to other tests in this file as well since this is likely causing
flakiness for them too.

Also fix a logging bug introduced in 312195@main where RELEASE_LOG read
result->size() after the HashSet had been moved from, always printing 0.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ServiceWorkerBasic.mm

* Source/WebCore/workers/service/server/SWServer.cpp:
(WebCore::SWServer::SWServer):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ServiceWorkerBasic.mm:
((ServiceWorkers, UserAgentOverride)):
((ServiceWorkers, RestoreFromDisk)):
((ServiceWorkers, UpdateCheckAfterRestoreFromDisk)):
((ServiceWorkers, CheckRegistrationWithoutMainScript)):
((ServiceWorkers, CheckRegistrationWithoutImportedScript)):
((ServiceWorkers, ThirdPartyRestoredFromDisk)):
((ServiceWorkers, CacheStorageRestoreFromDisk)):
((ServiceWorkers, FetchAfterRestoreFromDisk)):
((ServiceWorkers, InterceptFirstLoadAfterRestoreFromDisk)):
((ServiceWorkers, MainThreadSWInterceptsLoad)):
((ServiceWorkers, WaitForPolicyDelegate)):
((ServiceWorkers, SWProcessConnectionCreation)):
((ServiceWorkers, ServiceWorkerProcessCreation)):
((ServiceWorkers, ServiceWorkerCacheAccessEphemeralSession)):
((ServiceWorkers, DifferentSessionsUseDifferentRegistrations)):
((ServiceWorkers, ServiceWorkerAndCacheStorageDefaultDirectories)):
((ServiceWorkers, ServiceWorkerAndCacheStorageSpecificDirectories)):
((ServiceWorkers, ProcessPerSite)):
((ServiceWorkers, ParallelProcessLaunch)):
((ServiceWorkers, LockdownModeInSharedWorkerProcess)):
((ServiceWorkers, ThrottleCrash)):
((ServiceWorkers, LoadData)):
((ServiceWorkers, SuspendNetworkProcess)):
((ServiceWorkers, V2DatabaseUpgrade)):
((ServiceWorkers, ProcessPerSession)):
((ServiceWorkers, ContentRuleList)):
((ServiceWorkers, ClearDOMCacheAlsoIncludesServiceWorkerRegistrations)):
((ServiceWorkers, WebProcessCache)):
((ServiceWorker, ExtensionServiceWorker)):
((ServiceWorker, ExtensionServiceWorkerDisableCORS)):
((ServiceWorker, ExtensionServiceWorkerWithModules)):
((ServiceWorker, ExtensionServiceWorkerFailureBadScript)):
((ServiceWorker, ExtensionServiceWorkerFailureBadURL)):
((ServiceWorker, ExtensionServiceWorkerFailureViewClosed)):
((ServiceWorker, ExtensionServiceWorkerFailureViewDestroyed)):
((ServiceWorker, RemovalOfSameRegistrableDomainButDifferentOrigin)):
((ServiceWorkers, CacheStorageNetworkProcessCrash)):
((ServiceWorker, ServiceWorkerWindowClientFocus)):
((ServiceWorker, ServiceWorkerWindowClientFocusRequiresUserGesture)):
((ServiceWorker, openWindowWithoutDelegate)):
((ServiceWorker, WindowClientNavigate)):
((ServiceWorker, WindowClientNavigateCrossOrigin)):
((ServiceWorker, OpenWindowWebsiteDataStoreDelegate)):
((ServiceWorker, OpenWindowCOOP)):
((ServiceWorker, FocusNotYetLoadedClient)):
((ServiceWorkers, ServiceWorkerStorageTiming)):
((ServiceWorker, ServiceWorkerProcessSwapWithNoDelay)):
((ServiceWorkers, ServiceWorkerCacheReference)):
((ServiceWorker, ServiceWorkerIdleOnMemoryPressure)):
((ServiceWorker, ServiceWorkerReadableStreamDownloadCancel)):

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

* Fix imported/w3c/web-platform-tests/css/css-tables/absolute-tables-007.html
https://bugs.webkit.org/show_bug.cgi?id=313510

Reviewed by Antti Koivisto.

Absolutely positioned tables with explicit height (e.g. height: 100%)
were not resolving their height correctly because two code paths
bypassed the out-of-flow constraint equation:

1. computeOutOfFlowPositionedLogicalHeightUsing had a blanket early
   return for all tables that returned the current content height
   (0, since rows haven't been laid out yet) instead of resolving the specified
   value against the containing block.

   For example (absolute-tables-007):

     <div style="position: relative; width: 100px;">
       <div style="position: absolute; display: table; width: 100%; height: 100%; background: green;"></div>
       <div style="height: 100px; background: red;"></div>
     </div>

   Before:
     computeOutOfFlowPositionedLogicalHeightUsing(height: 100%) -> isRenderTable() -> return 0

   After:
     computeOutOfFlowPositionedLogicalHeightUsing(height: 100%) -> isAuto()? NO -> 100% of containingSize(100) = 100

2. The row distribution height in RenderTable::layout used
   convertStyleLogicalHeightToComputedHeight, which calls the in-flow
   percentage resolution path. For OOF tables this is wrong: it skips
   the constraint equation and in quirks mode walks to the viewport
   through auto-height ancestors.

   For example (no doctype = quirks mode):

     <div style="position: relative; width: 100px;">
       <div style="position: absolute; display: table; width: 100%; height: 100%; background: green;">
         <div style="height: 100px;"></div>
       </div>
     </div>

   Before: table stretched to viewport (~800px) because computePercentageLogicalHeight resolved against the viewport.

   After: computeLogicalHeight uses the constraint equation which gives 100% of containingSize(0) = 0, then content
   expands the table to 100px.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-tables/absolute-tables-height-001-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-tables/absolute-tables-height-001.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-tables/absolute-tables-height-quirks-001-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-tables/absolute-tables-height-quirks-001.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/elementFromPoint-002-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/elementFromPoint-003-expected.txt:
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalHeight const):
(WebCore::RenderBox::computeOutOfFlowPositionedLogicalHeightUsing const):
* Source/WebCore/rendering/RenderTable.cpp:
(WebCore::RenderTable::layout):

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

* `height: 100%` has wrong calculation for img as grid cell nested inside flexbox
rdar://169431440
https://bugs.webkit.org/show_bug.cgi?id=306258

Reviewed by Alan Baradlay.

When a replaced element is a grid item then its containing block becomes
the grid area which is computed during grid layout. The code we are
changing in this patch already has this existing logic, but we do not
currently use it to resolve the percentage because we end up checking
the containing block of the grid item (i.e. the grid) to see if has some
sort of stretched height in the formatting context it participates in.

To fix this issue we just swap the order of these checks becuase the
element being a grid item has a stronger precedence than any logic than
the formatting context the grid is in. Said another way, since grid
layout is responsible for computing and setting the containing block for
the item we should try to respect it.

Test: imported/w3c/web-platform-tests/css/css-grid/replaced-element-percentage-height-in-grid-nested-in-flex-001.html
      imported/w3c/web-platform-tests/css/css-grid/replaced-element-percentage-height-in-grid-nested-in-flex-002.html

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

* Fix format string issue in WebExtension error handling
<https://bugs.webkit.org/show_bug.cgi?id=307732>
<rdar://146743429>

Reviewed by Timothy Hatcher.

Remove variadic formatting from `toErrorString()` entirely by changing
the function signature to accept only fixed parameters and replacing all
`formatString()` calls with safe `makeString()` concatenation.

Covered by existing tests in Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPI*.mm.

* Source/WebKit/Shared/Extensions/WebExtensionUtilities.cpp:
(WebKit::toErrorString):
(WebKit::formatString): Deleted.
* Source/WebKit/Shared/Extensions/WebExtensionUtilities.h:
(WebKit::toWebExtensionError):
* Source/WebKit/UIProcess/Extensions/API/WebExtensionContextAPIDeclarativeNetRequest.cpp:
(WebKit::WebExtensionContext::declarativeNetRequestValidateRulesetIdentifiers):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::declarativeNetRequestUpdateEnabledRulesets):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIScriptingCocoa.mm:
(WebKit::WebExtensionContext::scriptingUpdateRegisteredScripts):
(WebKit::WebExtensionContext::scriptingUnregisterContentScripts):
(WebKit::WebExtensionContext::createInjectedContentForScripts):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:
(WebKit::WebExtensionContext::tabsRemove):
(WebKit::WebExtensionContext::tabsExecuteScript):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWindowsCocoa.mm:
(WebKit::WebExtensionContext::windowsCreate):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIActionCocoa.mm:
(WebKit::WebExtensionAPIAction::parseIconPathsDictionary):
(WebKit::WebExtensionAPIAction::parseIconImageDataDictionary):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPICookiesCocoa.mm:
(WebKit::WebExtensionAPICookies::parseCookieDetails):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateDynamicRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateSessionRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::getMatchedRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::setExtensionActionOptions):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsInspectedWindowCocoa.mm:
(WebKit::WebExtensionAPIDevToolsInspectedWindow::eval):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIMenusCocoa.mm:
(WebKit::WebExtensionAPIMenus::parseCreateAndUpdateProperties):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIPermissionsCocoa.mm:
(WebKit::WebExtensionAPIPermissions::validatePermissionsDetails):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIScriptingCocoa.mm:
(WebKit::WebExtensionAPIScripting::parseTargetInjectionOptions):
(WebKit::WebExtensionAPIScripting::parseRegisteredContentScripts):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPISidebarActionCocoa.mm:
(WebKit::parseDetailsStringFromKey):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm:
(WebKit::WebExtensionAPITabs::parseTabCreateOptions):
(WebKit::WebExtensionAPITabs::parseTabUpdateOptions):
(WebKit::WebExtensionAPITabs::parseTabQueryOptions):
(WebKit::WebExtensionAPITabs::parseSendMessageOptions):
(WebKit::WebExtensionAPITabs::parseScriptOptions):
(WebKit::isValid):
(WebKit::WebExtensionAPITabs::remove):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWindowsCocoa.mm:
(WebKit::WebExtensionAPIWindows::parseWindowCreateOptions):
(WebKit::isValid):
* Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.mm:
(-[_WKWebExtensionWebNavigationURLPredicate initWithTypeString:value:outErrorMessage:]):
* Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.mm:
(toResourceType):

Originally-landed-as: 305413.295@safari-7624-branch (5cbcce761278). rdar://173969352
Canonical link: https://commits.webkit.org/312282@main

* [Navigation API] intercept() wrongly succeeds for cross-subdomain navigations
https://bugs.webkit.org/show_bug.cgi?id=306050
rdar://165690775

Reviewed by Alex Christensen.

Consider that we have two sites that differ in subdomain:
1. page1.example.com
2. page2.example.com

If we navigate from page1 to page2, page1 should not be able to intercept the
navigation because this is a cross-origin navigation. Our bug is that currently,
the intercept succeeds.

How it's supposed to work:

One of the steps in firing a navigate event says:
(Step 9 in https://html.spec.whatwg.org/multipage/nav-history-apis.html#inner-navigate-event-firing-algorithm)

"If document can have its URL rewritten to destination's URL, and either
destination's is same document is true or navigationType is not "traverse", then
initialize event's canIntercept to true. Otherwise, initialize it to false."

One of the steps for checking if the URL can be rewritten to destination's URL is:
(https://html.spec.whatwg.org/multipage/nav-history-apis.html#can-have-its-url-rewritten)

"If targetURL and documentURL differ in their scheme, username, password, host,
or port components, then return false."

Our two URLs differ in host. so canIntercept should be set to false.

Later on, when intercept() is called, it should fail because it's steps say:
(https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigateevent-intercept)

"If this's canIntercept attribute was initialized to false, then throw a
"SecurityError" DOMException."

What's wrong:

Our issue is that the "can-have-its-url-rewritten" check returns true, so
canIntercept is set to true and later on the intercept succeeds. The check is
implemented incorrectly. Instead of checking if the URLS differ in scheme,
username, password, host, or port components, it simply does:

bool isSameSite = documentOrigin->isSameSiteAs(targetOrigin);
bool isSameOrigin = documentOrigin->isSameOriginAs(targetOrigin);
if (!isSameSite && !isSameOrigin)
    return false;

For our two URLs, isSameSite is true, so this check doesn't return false as it
should. Also this check never compares the usernames and passwords. This means
that not only does the cross-origin check fail in the case of URLs that differ by
subdomain but it will also fail for URLs that differ in username and password.

We fix this by changing to check to follow the spec. We also add new API tests for
both the subdomain and username/password cases.

* Source/WebCore/page/Navigation.cpp:
(WebCore::documentCanHaveURLRewritten):
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/NavigationAPI.mm: Added.
(TestWebKitAPI::TEST(NavigationAPI, InterceptFailsForDifferentSubdomain)):
(TestWebKitAPI::TEST(NavigationAPI, InterceptFailsForDifferentUsernameAndPassword)):

Originally-landed-as: 305413.125@safari-7624-branch (67e3366c7a2c). rdar://173969327
Canonical link: https://commits.webkit.org/312283@main

* [WebKit] Install libWebKitPlatform.a when FORCE_TOOL_INSTALL=YES
<https://bugs.webkit.org/show_bug.cgi?id=313552>
<rdar://175765586>

Reviewed by Jonathan Bedard.

Apply the standard `FORCE_TOOL_INSTALL` pattern to
`WebKitPlatform.xcconfig` and add `INSTALL_PATH` so
`libWebKitPlatform.a` is installed to `/usr/local/lib/` when
building roots with `--tools`.  Without this, the static library
is built but never installed into the SDK root, so TestIPC cannot
find it via `-lWebKitPlatform` in Production builds.

* Source/WebKit/Configurations/WebKitPlatform.xcconfig:

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

* [JSC] Use-after-free after growing a resizable buffer on a WebAssembly memory
https://bugs.webkit.org/show_bug.cgi?id=306136
rdar://167095753

Reviewed by Yijia Huang.

This issue is related to earlier work on WebAssembly memory buffers. As part of that work, it became
possible for an ArrayBuffer's underlying storage to change its location in memory as a result of
growing. To deal with this change, two methods were introduced: ArrayBuffer::refreshAfterMemoryGrow
and ArrayBufferContents::refreshAfterMemoryGrow. However:

1. ArrayBufferContents::refreshAfterMemoryGrow does not update the m_data field, which is a direct
   pointer to the memory base.

2. Refreshing array buffer objects is not enough because a JSArrayBufferView has its own direct
   pointer into the underlying buffer's data (m_vector).

The patch makes the following changes to address this:

* JSTests/wasm/stress/resizable-buffer-grow-view-refresh.js: Added.
(i.catch):
* Source/JavaScriptCore/runtime/ArrayBuffer.cpp:
(JSC::ArrayBuffer::refreshAfterWasmMemoryGrow):
(JSC::ArrayBufferContents::refreshAfterWasmMemoryGrow):

Properly updates the m_data field.

* Source/JavaScriptCore/runtime/JSArrayBufferView.h:
* Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:

A new method 'refreshVector' is added to be used by
ArrayBuffer::refreshAfterWasmMemoryGrow.

Test: JSTests/wasm/stress/resizable-buffer-grow-view-refresh.js

Originally-landed-as: 305413.190@safari-7624-branch (59c4a7a31ef6). rdar://173968863
Canonical link: https://commits.webkit.org/312285@main

* [iOS] Transition off deprecated UIApplication.statusBarFrame API in WKFullscreenViewController
rdar://174883276
https://bugs.webkit.org/show_bug.cgi?id=313594

Reviewed by Simon Fraser.

Replace UIApplication.statusBarFrame with UIWindowScene.scene.statusBarFrame.

* Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
(-[WKFullScreenViewController initWithWebView:]):
(-[WKFullScreenViewController _statusBarFrameDidChange:]):

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

* The WebContent process should not prevent local file loads where the Networking process has access by extension
https://bugs.webkit.org/show_bug.cgi?id=308348
rdar://170610201

Reviewed by Chris Dumez.

The UI process is granting the Networking process access to its temp directory. If the UI process is performing
a load of a local file inside that directory, the WebContent process should not block it.

* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::networkProcessHasAccessByExtensions):
(WebKit::NetworkResourceLoadParameters::createSandboxExtensionHandlesIfNecessary):
* Source/WebKit/Shared/WebProcessCreationParameters.h:
* Source/WebKit/Shared/WebProcessCreationParameters.serialization.in:
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* Source/WebKit/WebProcess/WebProcess.h:
* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::accessibilityFocusedUIElement):

Originally-landed-as: 305413.335@safari-7624-branch (00906723527a). rdar://173969195
Canonical link: https://commits.webkit.org/312287@main

* [CSS JIT] Compile :has() argument selectors
https://bugs.webkit.org/show_bug.cgi?id=311203
rdar://problem/173791568

Reviewed by Antti Koivisto.

When :has() is evaluated, the argument selector (e.g., .active in :has(> .active))
is checked per-element via the SelectorChecker interpreter. This patch JIT-compiles
the argument selector so each per-element check runs as native code.

Argument selectors with adjacent/sibling combinators (+, ~) or functional
pseudo-classes (:not, :is) fall back to the interpreter because the CSS JIT
doesn't generate all the style relations needed for :has() invalidation with
sibling relationships. This can be addressed in a follow-up.

* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne const):
(WebCore::compiledHasArgumentSelectorsMap):
(WebCore::SelectorChecker::clearCompiledHasArgumentSelectors):
(WebCore::canJITCompileHasArgument):
(WebCore::SelectorChecker::matchHasPseudoClass const):
(WebCore::SelectorChecker::matchHasArgumentSelector const):
* Source/WebCore/css/SelectorChecker.h:
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::compileSelector):
(WebCore::SelectorCompiler::SelectorCodeGenerator::SelectorCodeGenerator):
(WebCore::SelectorCompiler::constructFragmentsInternal):
(WebCore::SelectorCompiler::constructFragments):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatchesHasScope):
* Source/WebCore/cssjit/SelectorCompiler.h:
* Source/WebCore/page/MemoryRelease.cpp:
(WebCore::releaseNoncriticalMemory):

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

* UserMessageHandler.postMessage should fail if called from another frame
https://bugs.webkit.org/show_bug.cgi?id=307014
rdar://168617144

Reviewed by Chris Dumez.

Before this fix, a reference to the UserMessageHandler can be stored outside the
frame, then the frame can be navigated, then the stored reference can be used to
post messages that appeared to come from the navigated frame.  This adds a restriction
to make it so a UserMessageHandler can only be used by an origin that is the same
as the frame's current origin.

I considered an alternative solution where I just make sure the global objects are
the same, but that would be more of a restriction than this, and it's normal for
frames to be able to access and use each other's JS objects when they are in the same
origin, and this change is less drastic of a change.

Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm

* Source/WebCore/page/UserMessageHandler.cpp:
(WebCore::passesSameOriginCheck):
(WebCore::UserMessageHandler::postMessage):
(WebCore::UserMessageHandler::postLegacySynchronousMessage):
* Source/WebCore/page/UserMessageHandler.h:
(WebCore::UserMessageHandler::descriptor const):
(WebCore::UserMessageHandler::descriptor): Deleted.
* Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp:
(webkit_dom_dom_window_webkit_message_handlers_post_message):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEvaluateJavaScript.mm:
(-[ScriptMessageHandlerThatShouldNotReceiveAnything userContentController:didReceiveScriptMessage:]):
(TEST(WKWebView, MessageHandlerFromIframe)):

Originally-landed-as: 305413.250@safari-7624-branch (c4006ba4ad2a). rdar://173969283
Canonical link: https://commits.webkit.org/312289@main

* [JSC] DFG `iterator_open` / `iterator_next` leave dangling failedBlock when a fast-mode watchpoint is invalidated
https://bugs.webkit.org/show_bug.cgi?id=313570

Reviewed by Yusuke Suzuki.

After 312127@main, seenModes can contain multiple fast modes. When one of
their iterator-protocol watchpoints has already fired, that case was skipped
without decrementing numberOfRemainingModes. The remaining fast mode then
allocated a failedBlock that was never connected, leaving a BasicBlock with
no terminal and crashing in Graph::determineReachability().

Mask out invalidated fast modes from seenModes up front, and drop the
redundant isStillValid() check from each case (addLazily() handles
concurrent invalidation at finalize time).

Test: JSTests/stress/iterator-dfg-fast-path-watchpoint-invalidated.js

* JSTests/stress/iterator-dfg-fast-path-watchpoint-invalidated.js: Added.
(shouldBe):
(sumArrayOrMap):
(noInline.Array.prototype.Symbol.iterator):
(noInline):
(sumMapOrSet):
(noInline.let.set new):
(noInline.Set.prototype.Symbol.iterator):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIteratorOpen):
(JSC::DFG::ByteCodeParser::handleIteratorNext):

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

* Media controls loading indicator overlaps playhead while WebKit bug attachment is loading
https://bugs.webkit.org/show_bug.cgi?id=313471
rdar://174394222

Reviewed by Jer Noble.

The activity indicator's position: absolute removed it from the flex flow
inside .time-control, so the scrubber's flex-grow reclaimed the slot it
should have occupied and put the activity indicator…
Jarred-Sumner added a commit to oven-sh/WebKit that referenced this pull request May 2, 2026
* [iOS] currentTime updates only as often as a MediaDeviceRoute updates currentPlaybackPosition
https://bugs.webkit.org/show_bug.cgi?id=313557
rdar://175774587

Reviewed by Eric Carlson.

When MediaPlayerPrivateWirelessPlayback is in use, a media element's currentTime is tied to the
MediaDeviceRoute's currentPlaybackPosition, but from WebKit's perspective there is no guarantee
that currentPlaybackPosition will update at a reasonable interval during playback.

To resolve this, added a CMTimebase to MediaPlayerPrivateWirelessPlayback that is configured with
the route's playbackSpeed and currentPlaybackPosition. A timebase observer is added that fires
every 100ms (in the media timeline) to update currentTime. This interval matches the one we use in
MediaPlayerPrivateAVFoundation's periodic time observer, providing smoothed estimated time updates
during wireless playback.

While here, simplified how we handle seeks. Removed the "pending seek" concept from
MediaPlayerPrivateWirelessPlayback and instead assumed that a seek occurs whenever
currentPlaybackPositionDidChange is called.

Tests: media/wireless-playback-media-player/current-time-advances-between-position-updates.html
       media/wireless-playback-media-player/current-time-resumes-after-pause.html
       media/wireless-playback-media-player/current-time-updates-after-rate-change.html
       media/wireless-playback-media-player/current-time-updates-after-route-seek.html
       media/wireless-playback-media-player/current-time-updates-after-seek.html
       media/wireless-playback-media-player/timeupdate-without-position-updates.html

* LayoutTests/media/wireless-playback-media-player/current-time-advances-between-position-updates-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-advances-between-position-updates.html: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-resumes-after-pause-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-resumes-after-pause.html: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-rate-change-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-rate-change.html: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-route-seek-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-route-seek.html: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-seek-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/current-time-updates-after-seek.html: Added.
* LayoutTests/media/wireless-playback-media-player/timeupdate-without-position-updates-expected.txt: Added.
* LayoutTests/media/wireless-playback-media-player/timeupdate-without-position-updates.html: Added.
* Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp:
* Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h:
* Source/WebCore/platform/graphics/MediaPlayerPrivateWirelessPlayback.cpp:
(WebCore::MediaPlayerPrivateWirelessPlayback::~MediaPlayerPrivateWirelessPlayback):
(WebCore::MediaPlayerPrivateWirelessPlayback::play):
(WebCore::MediaPlayerPrivateWirelessPlayback::pause):
(WebCore::MediaPlayerPrivateWirelessPlayback::seekToTarget):
(WebCore::MediaPlayerPrivateWirelessPlayback::currentTime const):
(WebCore::MediaPlayerPrivateWirelessPlayback::setRate):
(WebCore::MediaPlayerPrivateWirelessPlayback::currentPlaybackPositionDidChange):
(WebCore::MediaPlayerPrivateWirelessPlayback::ensureTimebase):
(WebCore::MediaPlayerPrivateWirelessPlayback::destroyTimebase):
(WebCore::MediaPlayerPrivateWirelessPlayback::updateTimebaseTimeAndRate):
(WebCore::MediaPlayerPrivateWirelessPlayback::scheduleTimebaseTimer):
(WebCore::MediaPlayerPrivateWirelessPlayback::timebaseTimerFired):
* Source/WebCore/platform/graphics/MediaPlayerPrivateWirelessPlayback.h:

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

* [git-webkit review] Inline comments sometimes missing from the review text file
https://bugs.webkit.org/show_bug.cgi?id=313572

Reviewed by Jonathan Bedard.

Problem:
  `git-webkit review` relies on the `position` field returned by GitHub's
  pull request comments API to place each inline comment in the generated
  review text file. GitHub computes `position` against its own view of the
  pull request diff, but the diff we fetch via `application/vnd.github.diff`
  is computed against the merge base and can have a different hunk layout
  (e.g. a hunk that has already landed on main is absent from our diff).
  When GitHub's `position` lands outside the range of lines in the diff we
  fetched, the count in `insert_diff_comments` never matches and the
  comment is silently dropped — it never appears in the review text file.

Solution:
  Translate comment locations ourselves using the `line` / `original_line`
  field (the new-file line number the comment applies to), which is
  unambiguous regardless of which diff was used to compute it. A new
  `_line_to_position_map` helper walks the diff we actually fetched,
  parses `@@ -a,b +c,d @@` hunk headers, and records the position within
  our diff for each new-file line. `_diff_comments` now uses that map to
  assign each comment a position that matches the diff being displayed,
  falling back to the raw `position` field only when no line number is
  reported (preserves behavior for file-level comments and legacy/mock
  data used by the existing tests).

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/remote/git_hub.py:

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

* [Site Isolation] Add multi-process BackForwardCache and CachedFrame support
https://bugs.webkit.org/show_bug.cgi?id=313507
rdar://175721231

Reviewed by Sihui Liu.

Prepare BackForwardCache and CachedFrame for multi-process BFCache with
Site Isolation.

Add a new take(BackForwardFrameItemIdentifier, Page*) overload that
looks up cache entries directly by identifier rather than through a
HistoryItem. This is needed because subframe processes suspend and
restore their BFCache entries using the main frame's identifier passed
from the UIProcess, without access to the HistoryItem. The existing
take(HistoryItem&, Page*) now delegates to the new overload.

Add Page ownership validation to both take() and get(). With
multi-process BFCache, a subframe process caches its Page under the
main frame's BackForwardFrameItemIdentifier via SetSubframesSuspended.
If a different Page in the same process later navigates to the same
back/forward item, the FrameLoader's BFCache lookup can find this
subframe entry instead of a cache miss. Since the subframe's CachedPage
has a RemoteFrame main frame with no DocumentLoader, restoring from it
causes a crash. The Page validation ensures each Page only finds its own
cache entries. The take() overload checks before removing from the map
so mismatched entries are preserved for their rightful owner.

In CachedFrame, restore() now null-guards m_document to support
RemoteFrame entries. In an iframe process under Site Isolation, the
Page's main frame is a RemoteFrame with no Document — the CachedFrame
stores the frame tree structure but not a Document. The child frame
reconstruction loop and pruneDetachedChildFrames() are moved outside
the m_document guard so they execute for both LocalFrame and RemoteFrame
paths. CachedFrame::open() adds a RemoteFrame branch that calls
restore() directly, since RemoteFrames have no FrameLoader to drive the
restoration.

In FrameLoader::continueLoadAfterNavigationPolicy, replace the
isInBackForwardCache() check with BackForwardCache::get(). The former
only checks if the key exists in the cache, while the latter also
validates Page ownership. Without this, the FrameLoader can take the
BFCache restoration path using a subframe's CachedPage, stalling the
navigation instead of proceeding to the normal load path that triggers
a process swap via the UIProcess.

No new tests (no behavior change for single-process BFCache).

* Source/WebCore/history/BackForwardCache.cpp:
(WebCore::BackForwardCache::addIfCacheable):
(WebCore::BackForwardCache::take):
(WebCore::BackForwardCache::get):
* Source/WebCore/history/BackForwardCache.h:
* Source/WebCore/history/CachedFrame.cpp:
(WebCore::CachedFrameBase::restore):
(WebCore::CachedFrame::open):
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):

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

* Back button not enabled in JS created windows when it should be
rdar://175516150
https://bugs.webkit.org/show_bug.cgi?id=313487

Reviewed by Richard Robinson.

Say JavaScript creates a new window.
That window starts out with a session history for items the user has never interacted with.

Once the user clicks a link on that document, we push a new session history entry that *does*
have user interaction. But when analyzing the back list we notice the previous item had no
interaction, and therefore don't reveal it to the API back/forward list.

The intention is that once the user makes a new entry by interacting, a series of non-interacted-with
items in the back list are coalesced into one logical step in the list.

311615@main accidentally broke that logic if the series of interaction-free items was at the
start of the list (as in the new window case)

This PR fixes that and gives progressions on some other API tests that had some back counts wrong.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKBackForwardListTests.mm

* Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItem.mm:
(-[WKBackForwardListItem _loggingStringForTesting]):
* Source/WebKit/UIProcess/API/Cocoa/WKBackForwardListItemPrivate.h:
* Source/WebKit/UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::itemStartingAtIndexSkippingItemsAddedByJSWithoutUserGesture const):
(WebKit::WebBackForwardList::loggingString const):
(WebKit::WebBackForwardList::loggingString): Deleted.
* Source/WebKit/UIProcess/WebBackForwardList.h:
* Source/WebKit/UIProcess/WebBackForwardList.swift:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKBackForwardListTests.mm:
(runBackForwardNavigationSkipsItemsWithoutUserGestureTest):
(TEST(WKBackForwardList, BackNavigationHijacking)):
(TEST(WKBackForwardList, ForwardSkipIteratesThroughLeadingConsecutiveJSItems)):
(TEST(WKBackForwardList, BackForwardNavigationSkipsPromiseRedirectWithoutUserInteraction)):
(TEST(WKBackForwardList, BackButtonWorksAfterUserClickFromJSCreatedPage)):

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

* [CMake] Add pal.swift to PAL Swift sources
https://bugs.webkit.org/show_bug.cgi?id=313580
rdar://175796349

Reviewed by Pascoe.

pal.swift is the umbrella module entry that re-exports the underlying
Clang module via @_exported public import pal. Sibling Swift files
(CryptoKit+UnsafeOverlays.swift, CryptoTypes.swift, RegexHelper.swift,
CryptoKitShim.swift) import via the umbrella name (pal.Core.crypto.*,
etc.). The Xcode build compiles pal.swift; the CMake build was missing
it. Add it so the umbrella re-export is present on Mac.

* Source/WebCore/PAL/pal/CMakeLists.txt:

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

* Unreviewed, reverting 312031@main.
https://bugs.webkit.org/show_bug.cgi?id=313603

Introduced debug assertion failures in EWS

Reverted changeset:

"[Site Isolation] fast/events/before-unload-navigate-different-window.html fails"

https://bugs.webkit.org/show_bug.cgi?id=313075
https://commits.webkit.org/312031@main
Canonical link: https://commits.webkit.org/312251@main

* Unreview unified build fix for MediaPlayerPrivateWirelessPlayback.cpp.
https://bugs.webkit.org/show_bug.cgi?id=313599
rdar://175804637

Reviewed by Mike Wyrzykowski.

* Source/WebCore/platform/graphics/MediaPlayerPrivateWirelessPlayback.cpp:

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

* [JSC][JSPI] Scan PinballCompletion conservative roots via a GC marking constraint
https://bugs.webkit.org/show_bug.cgi?id=307564
rdar://170156450

Reviewed by Keith Miller.

In the existing JSPI implementation, evacuated Wasm stack slices and callee saves are
registered with the VM and scanned as conservative roots. This creates a potential memory
leak. Here is the reference structure:

    Promise --> PinballCompletion --> EvacuatedStacks, Callee Saves --> ...
                                                ^
                                                |
                                               VM

The Promise is the promise that caused JSPI suspension, and it owns (transitively via
resolution handlers) the PinballCompletion with the suspended computation. Normally, when
the promise is fulfilled or rejected, PinballCompletion unregisters the evacuated stacks
and callee saves it owns, and all these objects become garbage-collectable. Also, if the
promise is forgotten without being resolved and becomes unmarked together with
PinballCompletion, PinballCompletion destructor unregisters the evacuated stacks and
callee saves, so everything is collected. However, if there happens to be a reference
chain starting in evacuated stacks or callee saves and leading back to the promise, this
transitive strong reference from the VM conservative roots will keep the promise and all
the other objects involved alive forever.

This patch prevents such a scenario. It stops treating evacuated stacks and callee saves
as VM conservative roots. Instead, a new GC constraint is introduced for PinballCompletion
objects, to scan the evacuated stacks and callee saves owned by a completion for
conservative roots only when the completion itself is marked.

This change requires some care in the implantation of evacuated stack slices. In the
original implementation the top slice is removed from a PinballCompletion and stored in
PinballHandlerContext by pinballHandlerInitContext(). Control would then return to
assembly code which would prepare the stack space for the slice and then call
pinballHandlerImplantSlice() to copy the slice data onto the stack. This creates a time
window when a stack slice has been taken out of its owner PinballCompletion, but its
contents have not yet been copied onto the stack. If GC were to run in this window, the
slice would not be scanned for conservative roots. This is not an immediate problem
because currently we do nothing in that time window that could start a GC, but it is a
fragility in case the code is changed in the future.

To avoid this fragility, we change the logic so that instead of storing the slice to
implant in PinballHandlerContext, we store the pinball object itself, and the slice is
only taken out of a PinballCompletion immediately before being implanted. We also refactor
the initialization code to make it an initializer of the PinballHandlerContext struct
instead of a static helper function.

Unified sources fixes
---------------------

The change in unified sources order with this patch, combined with the revision of JSC
header includes by https://bugs.webkit.org/show_bug.cgi?id=312585 caused build breakage.
The patch includes these additional changes unrelated to its core logic to fix the
breakage:

- TemporalPlainYearMonth.h / .cpp: Moved the addDurationToYearMonth template definition
  from the header into the .cpp file and added explicit template instantiations for
  AddOrSubtract::Add and AddOrSubtract::Subtract. The header only had a forward
  declaration of JSGlobalObject, so the globalObject->vm() call on line 91 failed with an
  incomplete type error.

- WeakMapImplInlines.h: Added #include "Symbol.h". The canBeHeldWeakly function calls
  asSymbol() which is declared in Symbol.h, but the header only had a forward declaration
  of Symbol via the include chain.

- PinballHandlerContext.cpp: Added #include "StackAlignment.h". The constructor asserts
  !(sliceByteSize % stackAlignmentBytes()), but stackAlignmentBytes() is declared in
  StackAlignment.h which wasn't included directly.

Testing
-------

- Added `jspi-gc-abandoned-suspensions.js` to reproduce the memory leak scenario described
  above.

- Refactoring changes are covered by existing tests.

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

* Avoid redundant data copy in BlobStorage::get() memory cache path
https://bugs.webkit.org/show_bug.cgi?id=313535

Reviewed by Ben Nham.

MemoryCache::get() already returns a standalone copy of the blob data
(via copyBlob) to safely release the lock. The second copyBlob in
BlobStorage::get() was copying that result again unnecessarily.

* Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
(WebKit::NetworkCache::BlobStorage::get):

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

* Fix an occasional UI process crash under SOAuthorizationSession::abort() after closing the web view
https://bugs.webkit.org/show_bug.cgi?id=313566
rdar://175108210

Reviewed by Aditya Keerthi and Abrar Rahman Protyasha.

Return early from a couple `PopUpSOAuthorizationSession` codepaths, in the case where the web view
has already been closed.

Test: SOAuthorizationPopUp.InterceptionCancelAfterClose

* Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:
(WebKit::PopUpSOAuthorizationSession::abortInternal):
(WebKit::PopUpSOAuthorizationSession::completeInternal):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SOAuthorizationTests.mm:
(TestWebKitAPI::TEST(SOAuthorizationPopUp, InterceptionCancelAfterClose)):

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

* WorkerMessagingProxy objects leak after calling worker.terminate() from JavaScript
<https://bugs.webkit.org/show_bug.cgi?id=313389>
<rdar://175652847>

Reviewed by Chris Dumez.

Handle the case in `workerObjectDestroyed()` where
`workerGlobalScopeDestroyedInternal()` has already run.  When
that happens, the proxy's thread, context, and identifier are
already cleaned up -- the only remaining work is releasing the
initial construction ref via `deref()`.  Without this,
`workerObjectDestroyed()` returns early on the nullopt
identifier, leaving the ref permanently held.

Also clear `m_queuedEarlyTasks` in
`workerGlobalScopeDestroyedInternal()` because tasks queued
before the worker thread is created capture `Ref { *this }`,
forming a retain cycle through the proxy's own member vector
that prevents destruction even after `deref()` is called.

The leak was introduced in Bug 22723 (254597@main) which added
the null-context early return to `workerObjectDestroyed()` and
added `m_scriptExecutionContext = nullptr` to
`workerGlobalScopeDestroyedInternal()` as part of implementing
nested dedicated workers.

Test using `run-webkit-tests --leaks` with:
- workers/worker-set-delete-terminate-crash.html
- workers/worker-terminate-crash.html

* Source/WebCore/workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::workerObjectDestroyed):
(WebCore::WorkerMessagingProxy::workerGlobalScopeDestroyedInternal):

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

* [Site Isolation] https/wpt/resource-timing/crossorigin-servertiming.html fails
https://bugs.webkit.org/show_bug.cgi?id=313280
rdar://175553453

Reviewed by Ryosuke Niwa.

A cross-origin iframe's initial navigation should appear as a
PerformanceResourceTiming entry in the parent document's performance timeline.

Resource timing does not work in site isolation because
ResourceTiming::addResourceTiming() relies on document.parentDocument and
frame->ownerElement(), which are null in the Site Isolation case.

To address this problem, we send the ResourceTiming data to the parent WCP
via IPC in SubresourceLoader::reportResourceTiming().

Then the parent adds the information to the document's Performance
object through the new ResourceTimingInformation::addResourceTimingToDocument().

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/navigation-preload/resource-timing.https-expected.txt:
* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/loader/LocalFrameLoaderClient.cpp:
* Source/WebCore/loader/LocalFrameLoaderClient.h:
* Source/WebCore/loader/ResourceLoadTiming.h:
(WebCore::ResourceLoadTiming::ResourceLoadTiming):
* Source/WebCore/loader/ResourceTiming.cpp:
(WebCore::ResourceTiming::ResourceTiming):
(WebCore::ResourceTiming::isolatedCopy const):
(WebCore::ResourceTiming::isolatedCopy):
* Source/WebCore/loader/ResourceTiming.h:
(WebCore::ResourceTiming::ResourceTiming): Deleted.
* Source/WebCore/loader/ResourceTimingInformation.cpp:
(WebCore::ResourceTimingInformation::addResourceTimingToDocument):
(WebCore::ResourceTimingInformation::addResourceTiming):
* Source/WebCore/loader/ResourceTimingInformation.h:
* Source/WebCore/loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::reportResourceTiming):
* Source/WebCore/page/RemoteFrame.cpp:
(WebCore::RemoteFrame::addResourceTimingFromChild):
* Source/WebCore/page/RemoteFrame.h:
* Source/WebCore/page/RemoteFrameClient.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::addResourceTimingFromSubframe):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
* Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.cpp:
(WebKit::WebRemoteFrameClient::addResourceTimingFromChild):
* Source/WebKit/WebProcess/WebCoreSupport/WebRemoteFrameClient.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::addResourceTimingFromSubframe):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

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

* ANGLE: Metal: Initialize missing fragment shader output components
https://bugs.webkit.org/show_bug.cgi?id=306150
rdar://167835037

Reviewed by Dan Glastonbury and Kimmo Kinnunen.

When fragment shader output components are expanded for Metal compatibility/validation,
only the original components were being copied in the conversion function.
The missing components were left uninitialized which led to garbage memory being written
to the framebuffer.

So add a second loop in SaturateScalarOrVectorCommon to zero-initialize the
missing components after copying the original components.

Test: webgl/webgl2-init-missing-fragment-output-components.html

* LayoutTests/webgl/webgl2-init-missing-fragment-output-components-expected.txt: Added.
* LayoutTests/webgl/webgl2-init-missing-fragment-output-components.html: Added.
* Source/ThirdParty/ANGLE/src/compiler/translator/msl/ModifyStruct.cpp:
* Source/ThirdParty/ANGLE/src/tests/gl_tests/GLSLTest.cpp:

Originally-landed-as: 305413.216@safari-7624-branch (0df3411b42dc). rdar://173969027
Canonical link: https://commits.webkit.org/312258@main

* [Site Isolation] http/tests/local/blob/navigate-blob.html fails
https://bugs.webkit.org/show_bug.cgi?id=313525

Reviewed by Brady Eidson.

This PR fixes a number of issues with site isolation pertaining to navigate-blob.html

1. Named window lookup fails across processes

When RemotePageProxy::injectPageIntoNewProcess() creates a popup's WebPage in another process,
the opener frame doesn't exist yet (IPC ordering). FrameTree::find() locates the popup by name
but isFrameFamiliarWith() rejects it because the opener is null.

Fix: Deferred opener resolution in WebPage::create() (WebPage.cpp, WebPage.h). Store unresolved
opener ID; when the opener's WebPage is later created in the same process, resolve pending
openers by calling updateOpener().

2. topDocumentSyncData not propagated during main frame process swap

When a main frame navigates cross-origin, didChangeMainDocument() in the new process broadcasts
BroadcastAllDocumentSyncData. This message arrives at ProvisionalPageProxy::didReceiveMessage(),
which has an explicit list of forwarded messages — BroadcastAllDocumentSyncData was not on it.
The message was silently dropped, so the old process (hosting subframes) never learned the new
top-level origin. Blobs created by subframes were registered with the wrong partition key.

Fix: Added BroadcastDocumentSyncData and BroadcastAllDocumentSyncData to the forwarded message
list in ProvisionalPageProxy::didReceiveMessage() (ProvisionalPageProxy.cpp).

3. topDocumentSyncData race conditions during process swap

Page::updateTopDocumentSyncData(Ref<DocumentSyncData>&&) rejected broadcasts when the main frame
was a LocalFrame with a document, so the broadcast arriving before the frame swap was ignored.
In addition, Page::setMainFrame() resets m_topDocumentSyncData unconditionally, wiping
the just-received broadcast when the main frame was replaced with a RemoteFrame.

Fix: Always accept broadcasts in updateTopDocumentSyncData, and only update m_topDocumentSyncData
from the new frame's document when the new frame is a LocalFrame with a document (Page.cpp).

4. Debug assertion failure: null opener frame

WebPageProxy assumed the opener frame still existed when processInheritedFromOpener was true.
With site isolation, the opener frame can be destroyed or replaced between the time the popup was
opened and when it later navigates. The processInheritedFromOpener flag is a sticky property set
at popup creation time. It doesn't track whether the opener frame is still alive. By the time
the popup navigates, the opener frame may have been removed by a process swap, page close, or
DOM mutation.

Fix: Fall back to ensureProcessForSite when the opener frame is gone (WebPageProxy.cpp).

5. Debug assertion in frameWasRemovedInAnotherProcess

frameWasRemovedInAnotherProcess is the normal cross-process frame synchronization message under
site isolation. When a frame is removed in one process, every other process hosting a remote
representation of that frame receives this message to tear down its RemoteFrame.

With the deferred opener resolution fix, more cross-process frame relationships are established
(popups correctly linked to openers across processes). When those frames are later removed
- during navigation, process swap, or DOM manipulation — the synchronization message legitimately
arrives at the WebPage hosting the remote representation. The ASSERT_NOT_REACHED was incorrect
because it treated a normal synchronization path as unreachable.

Fix: Removed the assertion (WebPage.cpp).

Co-authored with Claude.

Test: http/tests/local/blob/navigate-blob.html

* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::setMainFrame):
(WebCore::Page::updateTopDocumentSyncData):
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::didReceiveMessage):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::initializeWebPage):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::create):
(WebKit::WebPage::frameWasRemovedInAnotherProcess):
* Source/WebKit/WebProcess/WebPage/WebPage.h:

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

* [Site Isolation] http/wpt/fetch/fetch-metadata-for-sandbox-iframes.html fails
https://bugs.webkit.org/show_bug.cgi?id=313369

Reviewed by Chris Dumez.

When a subframe navigation triggers a process swap (e.g., localhost -> 127.0.0.1)
and a server redirect sends it back to the parent's site (127.0.0.1 -> localhost),
the UIProcess continues the load in the parent's process. The new process computes
Sec-Fetch-Site fresh - context origin = localhost (inherited from parent), request
URL = localhost - yielding "same-origin". The cross-site redirect through 127.0.0.1
is lost.

Fixed the buy by passing navigation.originalRequest() in LoadParameters's
originalRequest when continuing a redirect in loadContinuingInNonInitiatingProcess
and continueNavigationInNewProcess subframe paths. In computeFetchMetadataSite,
when the DocumentLoader is a continuing load after a provisional load started and
has a different original URL, recompute Sec-Fetch-Site by evaluating the original
URL first, then degrading for the redirect.

Tests: http/wpt/fetch/fetch-metadata-for-sandbox-iframes-reuse.html
       http/wpt/fetch/fetch-metadata-for-sandbox-iframes.html

* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WebCore/loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::SubresourceLoader):
* Source/WebCore/loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::computeFetchMetadataSite):
(WebCore::CachedResourceLoader::updateHTTPRequestHeaders):
* Source/WebCore/loader/cache/CachedResourceLoader.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedNavigationActionPolicyDecision):
(WebKit::WebPageProxy::continueNavigationInNewProcess):

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

* Remove MockParentalControlsURLFilter.h exclusion from WebCore_Private.modulemap
https://bugs.webkit.org/show_bug.cgi?id=313567
rdar://175786669

Reviewed by Richard Robinson.

Excluding it is unnecessary and may cause build issues.

No new tests needed.

* Source/WebCore/WebCore_Private.modulemap:

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

* AX: updateRelationsIfNeeded() walks the entire DOM when it should walk only the elements that have relations-attributes
https://bugs.webkit.org/show_bug.cgi?id=313445
rdar://175681348

Reviewed by Joshua Hoffman.

updateRelationsIfNeeded() previously walked every element in the entire DOM on
every rebuild, checking all 13 relation attributes per element. This is wasteful
because only a small fraction of elements have relation attributes.

Track elements with relation attributes in a WeakHashSet during the initial
full-DOM build, and maintain it incrementally as attributes change. Subsequent
rebuilds (triggered by id changes, reference target changes, etc.) iterate only
the tracked elements instead of the full DOM.

On a page with 1000 DOM elements but only 5 labels and 0 ARIA relation
attributes, the rebuild now walks 5 elements instead of 1000.

This change is a 0.51% improvement on Speedometer 3.1.

* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::handleAttributeChange):
(WebCore::AXObjectCache::performDeferredCacheUpdate):
(WebCore::AXObjectCache::updateRelationsIfNeeded):
(WebCore::AXObjectCache::updateRelationsForTree):
* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/AccessibilityObject.h:

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

* AX: On macOS, attributedStringForTextMarkerRange returns empty string for line ranges spanning nested table boundaries
https://bugs.webkit.org/show_bug.cgi?id=313508
rdar://174349841

Reviewed by Joshua Hoffman.

On macOS, attributedStringForTextMarkerRange used rangeForTextMarkerRange()
to convert text markers to a SimpleRange via CharacterOffset. This path
relies on characterOffsetsInOrder() to determine ordering, which produces
incorrect results for positions spanning across nested table boundaries
(e.g. a text node inside a cell vs. an ancestor tbody position). The
reversed range caused attributedStringForTextMarkerRange to return an
empty string, making VoiceOver read "new line" instead of the actual
line content.

Fix this by matching iOS and switching to simpleRange(), which converts
directly from the text markers' boundary points.

This commit does not address the core bug causing the reversed range. I
attempted to do this, but it ended up being complex, so a FIXME was added instead.
This commit is still a good step forward, decreasing the difference between platforms
and introducing a layout test that reproduces the issue.

* LayoutTests/accessibility/attributed-string-for-line-in-table-expected.txt: Added.
* LayoutTests/accessibility/attributed-string-for-line-in-table.html: Added.
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::characterOffsetsInOrder):
* Source/WebCore/accessibility/cocoa/AccessibilityObjectCocoa.mm:
(WebCore::AccessibilityObject::attributedStringForTextMarkerRange const):

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

* [GTK][WPE] Skia Compositor: Isolate blend-mode children in their own surface
https://bugs.webkit.org/show_bug.cgi?id=313518

Reviewed by Carlos Garcia Campos.

A child layer's blend mode must blend against the contents of its
enclosing stacking context, not whatever the parent canvas happens
to hold from unrelated ancestors.

* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.cpp:
(WebCore::SkiaCompositingLayer::computeTransformsAndAnimations):
(WebCore::SkiaCompositingLayer::recursivePaint):
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.h:

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

* Build fix: angle-bracket includes in ResourceTiming.h

Unreviewed build fix.

ResourceTiming.h is a Private framework header, so includes of
sibling headers must use angle-bracket form.

* Source/WebCore/loader/ResourceTiming.h:

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

* [CMake] Use cmake_{push,pop}_check_state() in WebKitCompilerFlags.cmake
https://bugs.webkit.org/show_bug.cgi?id=313560

Reviewed by Yusuke Suzuki.

This is a follow-up to 312222@main with a small cleanup.

* Source/cmake/WebKitCompilerFlags.cmake: Use cmake_push_check_state()
  and cmake_pop_check_state() consistently to ensure that variables
  are restored to their original values after modifying them for tests.

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

* Add FileSystem::traverseDirectory() to avoid redundant lstat() per directory entry
https://bugs.webkit.org/show_bug.cgi?id=313538

Reviewed by Darin Adler.

FileSystem::listDirectory() uses std::filesystem::directory_iterator internally,
which caches each entry's file type from readdir's d_type field. However, it only
returns filenames, discarding the cached type. Callers that need the entry type
then call FileSystem::fileType() per entry, which does a redundant lstat() syscall
to rediscover what directory_iterator already knew.

Add FileSystem::traverseDirectory() that uses directory_iterator directly and
provides both the filename and file type to the callback, reading the type from
directory_entry::symlink_status() which uses the cached d_type without a syscall.
It also avoids materializing all filenames into an intermediate Vector.

Update the four call sites that were doing listDirectory() + fileType() per entry:
NetworkCacheFileSystem, deleteAllFilesModifiedSince, DirectoryFileListCreator,
and DOMFileSystem::listDirectoryWithMetadata.

* Source/WTF/wtf/FileSystem.cpp:
(WTF::FileSystemImpl::deleteAllFilesModifiedSince):
(WTF::FileSystemImpl::traverseDirectory):
* Source/WTF/wtf/FileSystem.h:
* Source/WTF/wtf/playstation/FileSystemPlayStation.cpp:
(WTF::FileSystemImpl::traverseDirectory):
* Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::listDirectoryWithMetadata):
* Source/WebCore/html/DirectoryFileListCreator.cpp:
(WebCore::appendDirectoryFiles):
* Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp:
(WebKit::NetworkCache::traverseDirectory):

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

* [Win] Prevent cross-compilation from using Linux configs

https://bugs.webkit.org/show_bug.cgi?id=313501

Reviewed by Yusuke Suzuki.

Prevent `PKG_CONFIG_PATH` from pointing to Linux specific configs
(`.pc` files); causing build to fail.

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

* [JSC] Clean up AsyncIterator asyncDispose
https://bugs.webkit.org/show_bug.cgi?id=313345
rdar://175616055

Reviewed by Keith Miller.

1. Make promiseReturnUndefinedOnFulfilled C++ function instead. It is
   just returning an undefined.
2. Clean up asyncDispose code. Using @newResolvedPromise /
   @newRejectedPromise helpers, and coverting entire region with
   try-catch instead.

* Source/JavaScriptCore/builtins/AsyncIteratorPrototype.js:
(overriddenName.string_appeared_here.asyncDispose):
(linkTimeConstant.promiseReturnUndefinedOnFulfilled): Deleted.
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/bytecode/LinkTimeConstant.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSGlobalObject::init):

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

* [cocoa] Explicitly handle cookies with NSHTTPCookieSameSiteNone
https://bugs.webkit.org/show_bug.cgi?id=313010
rdar://175354204

Reviewed by Charlie Wolfe.

A recent change in CFNetwork results in WebKit potentially receiving a @"none"
value for the cookie's SameSite property. This wasn't previously possible
because unspecified and None were handled identically. Since the CFNetwork
change, a debug assertion within WebKit is now being triggered on some sites.
This change adds explicit support for the @"none" SameSite value.

* Source/WebCore/platform/network/cocoa/CookieCocoa.mm:
(WebCore::coreSameSitePolicy):
(WebCore::nsSameSitePolicy):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKHTTPCookieStore.mm:
(TEST(WKHTTPCookieStore, SetCookies)):

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

* REGRESSION (310265@main): Gaze glow region for slider thumb is too large
https://bugs.webkit.org/show_bug.cgi?id=313574
rdar://174429082

Reviewed by Lily Spiniolas, Aditya Keerthi, and Abrar Rahman Protyasha.

The problem: The previous fix 310265@main https://github.com/WebKit/WebKit/pull/60950
expanded the slider thumb's touch hit area and interaction region by 12.5pt when either
dimension is below 48pt. The touch hit area was correct and matched UIKit, but
the interaction region (the visible gaze glow highlight) was too large.

The fix: UIKit does not enlarge the gaze glow, so to match that behaviour, the
interaction region inflation for slider thumbs in inflateRectForInteractionRegion
is removed.

* LayoutTests/interaction-region/form-control-refresh/slider-thumb-native-interaction-region-expected.txt:
* LayoutTests/interaction-region/input-type-range-region-expected.txt:
* Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::inflateRectForInteractionRegion):

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

* [GStreamer] Gardening
https://bugs.webkit.org/show_bug.cgi?id=313632

Unreviewed, flag a webrtc test as flaky.

* LayoutTests/platform/glib/TestExpectations:

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

* [LBSE] Update geometry parsing expectations
https://bugs.webkit.org/show_bug.cgi?id=313628

Reviewed by Nikolas Zimmermann.

Update geometry parsing expectations after 312018@main.

* LayoutTests/platform/mac-tahoe-wk2-lbse-text/imported/w3c/web-platform-tests/svg/geometry/parsing/height-computed-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/imported/w3c/web-platform-tests/svg/geometry/parsing/width-computed-expected.txt:

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

* [GLIB][Debug] Gardening IPC tests
https://bugs.webkit.org/show_bug.cgi?id=306955

Unreviewed gardening.

These tests only crash/fail in debug builds.

* LayoutTests/platform/glib/TestExpectations:

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

* [GTK][WPE] `imported/w3c/web-platform-tests/css/filter-effects/crashtests/fecomponenttransfer-tablevalues-crash.html` is a flaky timeout
https://bugs.webkit.org/show_bug.cgi?id=313641

Unreviewed gardening.

* LayoutTests/platform/glib/TestExpectations:

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

* [Build Speed] Avoid parsing simde in ARM64/Darwin builds
https://bugs.webkit.org/show_bug.cgi?id=313613
rdar://175816799

Reviewed by Yusuke Suzuki.

The built-in NEON module is precompiled and equally capable. This
saves ~9GB of parsing in a full WebKit build.

* Source/WTF/wtf/simde/arm/neon.h:
* Source/WTF/wtf/simde/arm/sve.h: Only use these headers on
non-ARM64/Darwin builds.

* Source/WTF/wtf/simde/simde.h: Declare a simde-compatible API
based on the built-in NEON module. This is still 4kLoC but that's
much smaller than 150kLoC.

NOTE: We may be able to eliminate the 4kLoC in the future by adopting
SIMDE_ENABLE_NATIVE_ALIASES.

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

* REGRESSION(312211@main) [GTK] Broke copy/pasting relative URLs
https://bugs.webkit.org/show_bug.cgi?id=313649

Unreviewed test gardening.

* LayoutTests/platform/gtk/TestExpectations:

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

* REGRESSION(311201@main): Crash when loading drafts.csswg.org/css-grid-3
https://bugs.webkit.org/show_bug.cgi?id=313610
rdar://175790849

Reviewed by Antti Koivisto.

If two text nodes in the same block both get a
text-transform change in the same render tree update (e.g. both ::before
and ::after pseudo-elements), the first call clears the inline layout
and the second call enters the function (layout path is still set),
walks the children, and dereferences the now-null inline layout pointer
when it encounters an out-of-flow element - crash.

The fix adds a null check for inlineLayout() before calling
invalidateLineLayout, matching how the rest of the codebase guards this call.

* LayoutTests/fast/css/pseudo-element-text-transform-invalidation-crash-expected.txt: Added.
* LayoutTests/fast/css/pseudo-element-text-transform-invalidation-crash.html: Added.
* Source/WebCore/rendering/RenderText.cpp:
(WebCore::RenderText::updateRenderedText):

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

* REGRESSION (312195@main): ServiceWorkerProcessSwapWithNoDelay and WindowClientNavigate API tests failing
https://bugs.webkit.org/show_bug.cgi?id=313642

Reviewed by Youenn Fablet.

After 312195@main made service worker registration imports lazy, the origin list
became available much faster than before. This changed timing so that ITP's
ResourceLoadStatisticsStore::removeDataRecords() could discover and clear
service worker registrations before the tests' navigations completed.

Fix by disabling ITP in both tests, matching the pattern already used by
other service worker tests in this file.

Apply this to other tests in this file as well since this is likely causing
flakiness for them too.

Also fix a logging bug introduced in 312195@main where RELEASE_LOG read
result->size() after the HashSet had been moved from, always printing 0.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ServiceWorkerBasic.mm

* Source/WebCore/workers/service/server/SWServer.cpp:
(WebCore::SWServer::SWServer):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/ServiceWorkerBasic.mm:
((ServiceWorkers, UserAgentOverride)):
((ServiceWorkers, RestoreFromDisk)):
((ServiceWorkers, UpdateCheckAfterRestoreFromDisk)):
((ServiceWorkers, CheckRegistrationWithoutMainScript)):
((ServiceWorkers, CheckRegistrationWithoutImportedScript)):
((ServiceWorkers, ThirdPartyRestoredFromDisk)):
((ServiceWorkers, CacheStorageRestoreFromDisk)):
((ServiceWorkers, FetchAfterRestoreFromDisk)):
((ServiceWorkers, InterceptFirstLoadAfterRestoreFromDisk)):
((ServiceWorkers, MainThreadSWInterceptsLoad)):
((ServiceWorkers, WaitForPolicyDelegate)):
((ServiceWorkers, SWProcessConnectionCreation)):
((ServiceWorkers, ServiceWorkerProcessCreation)):
((ServiceWorkers, ServiceWorkerCacheAccessEphemeralSession)):
((ServiceWorkers, DifferentSessionsUseDifferentRegistrations)):
((ServiceWorkers, ServiceWorkerAndCacheStorageDefaultDirectories)):
((ServiceWorkers, ServiceWorkerAndCacheStorageSpecificDirectories)):
((ServiceWorkers, ProcessPerSite)):
((ServiceWorkers, ParallelProcessLaunch)):
((ServiceWorkers, LockdownModeInSharedWorkerProcess)):
((ServiceWorkers, ThrottleCrash)):
((ServiceWorkers, LoadData)):
((ServiceWorkers, SuspendNetworkProcess)):
((ServiceWorkers, V2DatabaseUpgrade)):
((ServiceWorkers, ProcessPerSession)):
((ServiceWorkers, ContentRuleList)):
((ServiceWorkers, ClearDOMCacheAlsoIncludesServiceWorkerRegistrations)):
((ServiceWorkers, WebProcessCache)):
((ServiceWorker, ExtensionServiceWorker)):
((ServiceWorker, ExtensionServiceWorkerDisableCORS)):
((ServiceWorker, ExtensionServiceWorkerWithModules)):
((ServiceWorker, ExtensionServiceWorkerFailureBadScript)):
((ServiceWorker, ExtensionServiceWorkerFailureBadURL)):
((ServiceWorker, ExtensionServiceWorkerFailureViewClosed)):
((ServiceWorker, ExtensionServiceWorkerFailureViewDestroyed)):
((ServiceWorker, RemovalOfSameRegistrableDomainButDifferentOrigin)):
((ServiceWorkers, CacheStorageNetworkProcessCrash)):
((ServiceWorker, ServiceWorkerWindowClientFocus)):
((ServiceWorker, ServiceWorkerWindowClientFocusRequiresUserGesture)):
((ServiceWorker, openWindowWithoutDelegate)):
((ServiceWorker, WindowClientNavigate)):
((ServiceWorker, WindowClientNavigateCrossOrigin)):
((ServiceWorker, OpenWindowWebsiteDataStoreDelegate)):
((ServiceWorker, OpenWindowCOOP)):
((ServiceWorker, FocusNotYetLoadedClient)):
((ServiceWorkers, ServiceWorkerStorageTiming)):
((ServiceWorker, ServiceWorkerProcessSwapWithNoDelay)):
((ServiceWorkers, ServiceWorkerCacheReference)):
((ServiceWorker, ServiceWorkerIdleOnMemoryPressure)):
((ServiceWorker, ServiceWorkerReadableStreamDownloadCancel)):

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

* Fix imported/w3c/web-platform-tests/css/css-tables/absolute-tables-007.html
https://bugs.webkit.org/show_bug.cgi?id=313510

Reviewed by Antti Koivisto.

Absolutely positioned tables with explicit height (e.g. height: 100%)
were not resolving their height correctly because two code paths
bypassed the out-of-flow constraint equation:

1. computeOutOfFlowPositionedLogicalHeightUsing had a blanket early
   return for all tables that returned the current content height
   (0, since rows haven't been laid out yet) instead of resolving the specified
   value against the containing block.

   For example (absolute-tables-007):

     <div style="position: relative; width: 100px;">
       <div style="position: absolute; display: table; width: 100%; height: 100%; background: green;"></div>
       <div style="height: 100px; background: red;"></div>
     </div>

   Before:
     computeOutOfFlowPositionedLogicalHeightUsing(height: 100%) -> isRenderTable() -> return 0

   After:
     computeOutOfFlowPositionedLogicalHeightUsing(height: 100%) -> isAuto()? NO -> 100% of containingSize(100) = 100

2. The row distribution height in RenderTable::layout used
   convertStyleLogicalHeightToComputedHeight, which calls the in-flow
   percentage resolution path. For OOF tables this is wrong: it skips
   the constraint equation and in quirks mode walks to the viewport
   through auto-height ancestors.

   For example (no doctype = quirks mode):

     <div style="position: relative; width: 100px;">
       <div style="position: absolute; display: table; width: 100%; height: 100%; background: green;">
         <div style="height: 100px;"></div>
       </div>
     </div>

   Before: table stretched to viewport (~800px) because computePercentageLogicalHeight resolved against the viewport.

   After: computeLogicalHeight uses the constraint equation which gives 100% of containingSize(0) = 0, then content
   expands the table to 100px.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-tables/absolute-tables-height-001-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-tables/absolute-tables-height-001.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-tables/absolute-tables-height-quirks-001-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-tables/absolute-tables-height-quirks-001.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/elementFromPoint-002-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/elementFromPoint-003-expected.txt:
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalHeight const):
(WebCore::RenderBox::computeOutOfFlowPositionedLogicalHeightUsing const):
* Source/WebCore/rendering/RenderTable.cpp:
(WebCore::RenderTable::layout):

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

* `height: 100%` has wrong calculation for img as grid cell nested inside flexbox
rdar://169431440
https://bugs.webkit.org/show_bug.cgi?id=306258

Reviewed by Alan Baradlay.

When a replaced element is a grid item then its containing block becomes
the grid area which is computed during grid layout. The code we are
changing in this patch already has this existing logic, but we do not
currently use it to resolve the percentage because we end up checking
the containing block of the grid item (i.e. the grid) to see if has some
sort of stretched height in the formatting context it participates in.

To fix this issue we just swap the order of these checks becuase the
element being a grid item has a stronger precedence than any logic than
the formatting context the grid is in. Said another way, since grid
layout is responsible for computing and setting the containing block for
the item we should try to respect it.

Test: imported/w3c/web-platform-tests/css/css-grid/replaced-element-percentage-height-in-grid-nested-in-flex-001.html
      imported/w3c/web-platform-tests/css/css-grid/replaced-element-percentage-height-in-grid-nested-in-flex-002.html

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

* Fix format string issue in WebExtension error handling
<https://bugs.webkit.org/show_bug.cgi?id=307732>
<rdar://146743429>

Reviewed by Timothy Hatcher.

Remove variadic formatting from `toErrorString()` entirely by changing
the function signature to accept only fixed parameters and replacing all
`formatString()` calls with safe `makeString()` concatenation.

Covered by existing tests in Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPI*.mm.

* Source/WebKit/Shared/Extensions/WebExtensionUtilities.cpp:
(WebKit::toErrorString):
(WebKit::formatString): Deleted.
* Source/WebKit/Shared/Extensions/WebExtensionUtilities.h:
(WebKit::toWebExtensionError):
* Source/WebKit/UIProcess/Extensions/API/WebExtensionContextAPIDeclarativeNetRequest.cpp:
(WebKit::WebExtensionContext::declarativeNetRequestValidateRulesetIdentifiers):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::declarativeNetRequestUpdateEnabledRulesets):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIScriptingCocoa.mm:
(WebKit::WebExtensionContext::scriptingUpdateRegisteredScripts):
(WebKit::WebExtensionContext::scriptingUnregisterContentScripts):
(WebKit::WebExtensionContext::createInjectedContentForScripts):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:
(WebKit::WebExtensionContext::tabsRemove):
(WebKit::WebExtensionContext::tabsExecuteScript):
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWindowsCocoa.mm:
(WebKit::WebExtensionContext::windowsCreate):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIActionCocoa.mm:
(WebKit::WebExtensionAPIAction::parseIconPathsDictionary):
(WebKit::WebExtensionAPIAction::parseIconImageDataDictionary):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPICookiesCocoa.mm:
(WebKit::WebExtensionAPICookies::parseCookieDetails):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateDynamicRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateSessionRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::getMatchedRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::setExtensionActionOptions):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDevToolsInspectedWindowCocoa.mm:
(WebKit::WebExtensionAPIDevToolsInspectedWindow::eval):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIMenusCocoa.mm:
(WebKit::WebExtensionAPIMenus::parseCreateAndUpdateProperties):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIPermissionsCocoa.mm:
(WebKit::WebExtensionAPIPermissions::validatePermissionsDetails):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIScriptingCocoa.mm:
(WebKit::WebExtensionAPIScripting::parseTargetInjectionOptions):
(WebKit::WebExtensionAPIScripting::parseRegisteredContentScripts):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPISidebarActionCocoa.mm:
(WebKit::parseDetailsStringFromKey):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm:
(WebKit::WebExtensionAPITabs::parseTabCreateOptions):
(WebKit::WebExtensionAPITabs::parseTabUpdateOptions):
(WebKit::WebExtensionAPITabs::parseTabQueryOptions):
(WebKit::WebExtensionAPITabs::parseSendMessageOptions):
(WebKit::WebExtensionAPITabs::parseScriptOptions):
(WebKit::isValid):
(WebKit::WebExtensionAPITabs::remove):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWindowsCocoa.mm:
(WebKit::WebExtensionAPIWindows::parseWindowCreateOptions):
(WebKit::isValid):
* Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.mm:
(-[_WKWebExtensionWebNavigationURLPredicate initWithTypeString:value:outErrorMessage:]):
* Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.mm:
(toResourceType):

Originally-landed-as: 305413.295@safari-7624-branch (5cbcce761278). rdar://173969352
Canonical link: https://commits.webkit.org/312282@main

* [Navigation API] intercept() wrongly succeeds for cross-subdomain navigations
https://bugs.webkit.org/show_bug.cgi?id=306050
rdar://165690775

Reviewed by Alex Christensen.

Consider that we have two sites that differ in subdomain:
1. page1.example.com
2. page2.example.com

If we navigate from page1 to page2, page1 should not be able to intercept the
navigation because this is a cross-origin navigation. Our bug is that currently,
the intercept succeeds.

How it's supposed to work:

One of the steps in firing a navigate event says:
(Step 9 in https://html.spec.whatwg.org/multipage/nav-history-apis.html#inner-navigate-event-firing-algorithm)

"If document can have its URL rewritten to destination's URL, and either
destination's is same document is true or navigationType is not "traverse", then
initialize event's canIntercept to true. Otherwise, initialize it to false."

One of the steps for checking if the URL can be rewritten to destination's URL is:
(https://html.spec.whatwg.org/multipage/nav-history-apis.html#can-have-its-url-rewritten)

"If targetURL and documentURL differ in their scheme, username, password, host,
or port components, then return false."

Our two URLs differ in host. so canIntercept should be set to false.

Later on, when intercept() is called, it should fail because it's steps say:
(https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigateevent-intercept)

"If this's canIntercept attribute was initialized to false, then throw a
"SecurityError" DOMException."

What's wrong:

Our issue is that the "can-have-its-url-rewritten" check returns true, so
canIntercept is set to true and later on the intercept succeeds. The check is
implemented incorrectly. Instead of checking if the URLS differ in scheme,
username, password, host, or port components, it simply does:

bool isSameSite = documentOrigin->isSameSiteAs(targetOrigin);
bool isSameOrigin = documentOrigin->isSameOriginAs(targetOrigin);
if (!isSameSite && !isSameOrigin)
    return false;

For our two URLs, isSameSite is true, so this check doesn't return false as it
should. Also this check never compares the usernames and passwords. This means
that not only does the cross-origin check fail in the case of URLs that differ by
subdomain but it will also fail for URLs that differ in username and password.

We fix this by changing to check to follow the spec. We also add new API tests for
both the subdomain and username/password cases.

* Source/WebCore/page/Navigation.cpp:
(WebCore::documentCanHaveURLRewritten):
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/NavigationAPI.mm: Added.
(TestWebKitAPI::TEST(NavigationAPI, InterceptFailsForDifferentSubdomain)):
(TestWebKitAPI::TEST(NavigationAPI, InterceptFailsForDifferentUsernameAndPassword)):

Originally-landed-as: 305413.125@safari-7624-branch (67e3366c7a2c). rdar://173969327
Canonical link: https://commits.webkit.org/312283@main

* [WebKit] Install libWebKitPlatform.a when FORCE_TOOL_INSTALL=YES
<https://bugs.webkit.org/show_bug.cgi?id=313552>
<rdar://175765586>

Reviewed by Jonathan Bedard.

Apply the standard `FORCE_TOOL_INSTALL` pattern to
`WebKitPlatform.xcconfig` and add `INSTALL_PATH` so
`libWebKitPlatform.a` is installed to `/usr/local/lib/` when
building roots with `--tools`.  Without this, the static library
is built but never installed into the SDK root, so TestIPC cannot
find it via `-lWebKitPlatform` in Production builds.

* Source/WebKit/Configurations/WebKitPlatform.xcconfig:

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

* [JSC] Use-after-free after growing a resizable buffer on a WebAssembly memory
https://bugs.webkit.org/show_bug.cgi?id=306136
rdar://167095753

Reviewed by Yijia Huang.

This issue is related to earlier work on WebAssembly memory buffers. As part of that work, it became
possible for an ArrayBuffer's underlying storage to change its location in memory as a result of
growing. To deal with this change, two methods were introduced: ArrayBuffer::refreshAfterMemoryGrow
and ArrayBufferContents::refreshAfterMemoryGrow. However:

1. ArrayBufferContents::refreshAfterMemoryGrow does not update the m_data field, which is a direct
   pointer to the memory base.

2. Refreshing array buffer objects is not enough because a JSArrayBufferView has its own direct
   pointer into the underlying buffer's data (m_vector).

The patch makes the following changes to address this:

* JSTests/wasm/stress/resizable-buffer-grow-view-refresh.js: Added.
(i.catch):
* Source/JavaScriptCore/runtime/ArrayBuffer.cpp:
(JSC::ArrayBuffer::refreshAfterWasmMemoryGrow):
(JSC::ArrayBufferContents::refreshAfterWasmMemoryGrow):

Properly updates the m_data field.

* Source/JavaScriptCore/runtime/JSArrayBufferView.h:
* Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h:

A new method 'refreshVector' is added to be used by
ArrayBuffer::refreshAfterWasmMemoryGrow.

Test: JSTests/wasm/stress/resizable-buffer-grow-view-refresh.js

Originally-landed-as: 305413.190@safari-7624-branch (59c4a7a31ef6). rdar://173968863
Canonical link: https://commits.webkit.org/312285@main

* [iOS] Transition off deprecated UIApplication.statusBarFrame API in WKFullscreenViewController
rdar://174883276
https://bugs.webkit.org/show_bug.cgi?id=313594

Reviewed by Simon Fraser.

Replace UIApplication.statusBarFrame with UIWindowScene.scene.statusBarFrame.

* Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
(-[WKFullScreenViewController initWithWebView:]):
(-[WKFullScreenViewController _statusBarFrameDidChange:]):

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

* The WebContent process should not prevent local file loads where the Networking process has access by extension
https://bugs.webkit.org/show_bug.cgi?id=308348
rdar://170610201

Reviewed by Chris Dumez.

The UI process is granting the Networking process access to its temp directory. If the UI process is performing
a load of a local file inside that directory, the WebContent process should not block it.

* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::networkProcessHasAccessByExtensions):
(WebKit::NetworkResourceLoadParameters::createSandboxExtensionHandlesIfNecessary):
* Source/WebKit/Shared/WebProcessCreationParameters.h:
* Source/WebKit/Shared/WebProcessCreationParameters.serialization.in:
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* Source/WebKit/WebProcess/WebProcess.h:
* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::accessibilityFocusedUIElement):

Originally-landed-as: 305413.335@safari-7624-branch (00906723527a). rdar://173969195
Canonical link: https://commits.webkit.org/312287@main

* [CSS JIT] Compile :has() argument selectors
https://bugs.webkit.org/show_bug.cgi?id=311203
rdar://problem/173791568

Reviewed by Antti Koivisto.

When :has() is evaluated, the argument selector (e.g., .active in :has(> .active))
is checked per-element via the SelectorChecker interpreter. This patch JIT-compiles
the argument selector so each per-element check runs as native code.

Argument selectors with adjacent/sibling combinators (+, ~) or functional
pseudo-classes (:not, :is) fall back to the interpreter because the CSS JIT
doesn't generate all the style relations needed for :has() invalidation with
sibling relationships. This can be addressed in a follow-up.

* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne const):
(WebCore::compiledHasArgumentSelectorsMap):
(WebCore::SelectorChecker::clearCompiledHasArgumentSelectors):
(WebCore::canJITCompileHasArgument):
(WebCore::SelectorChecker::matchHasPseudoClass const):
(WebCore::SelectorChecker::matchHasArgumentSelector const):
* Source/WebCore/css/SelectorChecker.h:
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::compileSelector):
(WebCore::SelectorCompiler::SelectorCodeGenerator::SelectorCodeGenerator):
(WebCore::SelectorCompiler::constructFragmentsInternal):
(WebCore::SelectorCompiler::constructFragments):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatchesHasScope):
* Source/WebCore/cssjit/SelectorCompiler.h:
* Source/WebCore/page/MemoryRelease.cpp:
(WebCore::releaseNoncriticalMemory):

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

* UserMessageHandler.postMessage should fail if called from another frame
https://bugs.webkit.org/show_bug.cgi?id=307014
rdar://168617144

Reviewed by Chris Dumez.

Before this fix, a reference to the UserMessageHandler can be stored outside the
frame, then the frame can be navigated, then the stored reference can be used to
post messages that appeared to come from the navigated frame.  This adds a restriction
to make it so a UserMessageHandler can only be used by an origin that is the same
as the frame's current origin.

I considered an alternative solution where I just make sure the global objects are
the same, but that would be more of a restriction than this, and it's normal for
frames to be able to access and use each other's JS objects when they are in the same
origin, and this change is less drastic of a change.

Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm

* Source/WebCore/page/UserMessageHandler.cpp:
(WebCore::passesSameOriginCheck):
(WebCore::UserMessageHandler::postMessage):
(WebCore::UserMessageHandler::postLegacySynchronousMessage):
* Source/WebCore/page/UserMessageHandler.h:
(WebCore::UserMessageHandler::descriptor const):
(WebCore::UserMessageHandler::descriptor): Deleted.
* Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp:
(webkit_dom_dom_window_webkit_message_handlers_post_message):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEvaluateJavaScript.mm:
(-[ScriptMessageHandlerThatShouldNotReceiveAnything userContentController:didReceiveScriptMessage:]):
(TEST(WKWebView, MessageHandlerFromIframe)):

Originally-landed-as: 305413.250@safari-7624-branch (c4006ba4ad2a). rdar://173969283
Canonical link: https://commits.webkit.org/312289@main

* [JSC] DFG `iterator_open` / `iterator_next` leave dangling failedBlock when a fast-mode watchpoint is invalidated
https://bugs.webkit.org/show_bug.cgi?id=313570

Reviewed by Yusuke Suzuki.

After 312127@main, seenModes can contain multiple fast modes. When one of
their iterator-protocol watchpoints has already fired, that case was skipped
without decrementing numberOfRemainingModes. The remaining fast mode then
allocated a failedBlock that was never connected, leaving a BasicBlock with
no terminal and crashing in Graph::determineReachability().

Mask out invalidated fast modes from seenModes up front, and drop the
redundant isStillValid() check from each case (addLazily() handles
concurrent invalidation at finalize time).

Test: JSTests/stress/iterator-dfg-fast-path-watchpoint-invalidated.js

* JSTests/stress/iterator-dfg-fast-path-watchpoint-invalidated.js: Added.
(shouldBe):
(sumArrayOrMap):
(noInline.Array.prototype.Symbol.iterator):
(noInline):
(sumMapOrSet):
(noInline.let.set new):
(noInline.Set.prototype.Symbol.iterator):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIteratorOpen):
(JSC::DFG::ByteCodeParser::handleIteratorNext):

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

* Media controls loading indicator overlaps playhead while WebKit bug attachment is loading
https://bugs.webkit.org/show_bug.cgi?id=313471
rdar://174394222

Reviewed by Jer Noble.

The activity indicator's position: absolute removed it from the flex flow
inside .time-control, so the scrubber's flex-grow reclaimed the slot it
should have occupied and put the activity indicator…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants