<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277688] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277688">277688</a></dd>
<dt>Author</dt> <dd>akeerthi@apple.com</dd>
<dt>Date</dt> <dd>2021-05-18 16:15:23 -0700 (Tue, 18 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[macOS] Titlebar separator doesn't show when WKWebView is scrolled
https://bugs.webkit.org/show_bug.cgi?id=220633
<rdar://problem/71094055>

Reviewed by Darin Adler.

Source/WebKit:

Starting in Big Sur, NSWindows with a titlebar display a separator if
there is a scrolled NSScrollView adjacent to the titlebar. Since
WKWebViews are scrollable views, but not backed by NSScrollView, we
need to adopt SPI to support this functionality.

This patch updates WKWebView to conform to the NSScrollViewSeparatorTrackingAdapter
protocol, ensuring the titlebar separator is displayed when
necessary. Note that since WKWebViews are not actually NSScrollView's we
don't already have the scroll position of the view in the UIProcess. To
determine whether or not the view is scrolled, this patch adds plumbing
so that the WebProcess can tell the UIProcess the new scroll position
when a page is scrolled.

Tests: WKWebViewTitlebarSeparatorTests.BackForwardCache
       WKWebViewTitlebarSeparatorTests.ChangeTitlebarAdjacency
       WKWebViewTitlebarSeparatorTests.ChangeViewVisibility
       WKWebViewTitlebarSeparatorTests.NavigationResetsTitlebarAppearance
       WKWebViewTitlebarSeparatorTests.ParentWhileScrolled
       WKWebViewTitlebarSeparatorTests.ScrollWithTitlebarAdjacency
       WKWebViewTitlebarSeparatorTests.ScrollWithoutTitlebarAdjacency

* Platform/spi/mac/AppKitSPI.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView scrollViewFrame]):
(-[WKView hasScrolledContentsUnderTitlebar]):
* UIProcess/API/mac/WKWebViewMac.mm:
(-[WKWebView scrollViewFrame]):
(-[WKWebView hasScrolledContentsUnderTitlebar]):
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::updateWindowAndViewFrames):

If the WKWebView's frame changes, update the titlebar adjacency
state and notify observers of the change.

(WebKit::WebViewImpl::viewWillMoveToWindowImpl):

Unregister the WKWebView as an NSScrollViewSeparatorTrackingAdapter if
it is removed from the window.

(WebKit::WebViewImpl::viewDidHide):

Hidden views are not adjacent to the titlebar.

(WebKit::WebViewImpl::viewDidUnhide):

An unhidden view may be adjacent to the titlebar.

(WebKit::WebViewImpl::pageDidScroll):

Use the scroll position of the page to determine whether or not the
WKWebView is scrolled.

(WebKit::WebViewImpl::scrollViewFrame):

Needed to conform to NSScrollViewSeparatorTrackingAdapter.

(WebKit::WebViewImpl::hasScrolledContentsUnderTitlebar):

Needed to conform to NSScrollViewSeparatorTrackingAdapter. Returns true
if the view is registered as an NSScrollViewSeparatorTrackingAdapter
and is scrolled.

(WebKit::WebViewImpl::updateTitlebarAdjacencyState):

The WKWebView needs to be registered as an NSScrollViewSeparatorTrackingAdapter
if it's adjacent to the titlebar and unregistered otherwise.

* UIProcess/PageClient.h:
(WebKit::PageClient::pageDidScroll):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::pageDidScroll):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::didCommitLoadForMainFrame):

Reset the scroll position upon navigation, as pageDidScroll does not get
called when navigating.

(WebKit::PageClientImpl::pageDidScroll):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::pageDidScroll):

Pass the current scroll position when the page is scrolled, so that the
UIProcess knows whether or not the page has a non-zero scroll position.

Source/WTF:

* wtf/PlatformHave.h: Defined HAVE_NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER.

Tools:

Added API tests to verify that the delegate implementation returns the
correct value for `hasScrolledContentsUnderTitlebar` depending on
the view's scroll position, visibility, and frame.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h:
* TestWebKitAPI/Tests/mac/WKWebViewTitlebarSeparatorTests.mm: Added.
(-[TitlebarSeparatorTestWKWebView initWithFrame:configuration:]):
(-[TitlebarSeparatorTestWKWebView separatorTrackingAdapter]):
(BackForwardCache):
(ChangeTitlebarAdjacency):
(ChangeViewVisibility):
(NavigationResetsTitlebarAppearance):
(ParentWhileScrolled):
(ScrollWithTitlebarAdjacency):
(ScrollWithoutTitlebarAdjacency):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformHaveh">trunk/Source/WTF/wtf/PlatformHave.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitPlatformspimacAppKitSPIh">trunk/Source/WebKit/Platform/spi/mac/AppKitSPI.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPImacWKViewmm">trunk/Source/WebKit/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPImacWKWebViewMacmm">trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaWebViewImplh">trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaWebViewImplmm">trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessPageClienth">trunk/Source/WebKit/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxymessagesin">trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacPageClientImplMach">trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacPageClientImplMacmm">trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsTestWebKitAPImacAppKitSPIh">trunk/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsmacWKWebViewTitlebarSeparatorTestsmm">trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewTitlebarSeparatorTests.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WTF/ChangeLog  2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2021-05-18  Aditya Keerthi  <akeerthi@apple.com>
+
+        [macOS] Titlebar separator doesn't show when WKWebView is scrolled
+        https://bugs.webkit.org/show_bug.cgi?id=220633
+        <rdar://problem/71094055>
+
+        Reviewed by Darin Adler.
+
+        * wtf/PlatformHave.h: Defined HAVE_NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER.
+
</ins><span class="cx"> 2021-05-18  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
</span><span class="cx"> 
</span><span class="cx">         [PlayStation] Fix PlayStation port
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformHaveh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformHave.h (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformHave.h      2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -921,6 +921,7 @@
</span><span class="cx"> #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
</span><span class="cx"> #define HAVE_STATIC_FONT_REGISTRY 1
</span><span class="cx"> #define HAVE_DATA_DETECTORS_MAC_ACTION 1
</span><ins>+#define HAVE_NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER 1
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000) \
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/ChangeLog       2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -1,3 +1,99 @@
</span><ins>+2021-05-18  Aditya Keerthi  <akeerthi@apple.com>
+
+        [macOS] Titlebar separator doesn't show when WKWebView is scrolled
+        https://bugs.webkit.org/show_bug.cgi?id=220633
+        <rdar://problem/71094055>
+
+        Reviewed by Darin Adler.
+
+        Starting in Big Sur, NSWindows with a titlebar display a separator if
+        there is a scrolled NSScrollView adjacent to the titlebar. Since
+        WKWebViews are scrollable views, but not backed by NSScrollView, we
+        need to adopt SPI to support this functionality.
+
+        This patch updates WKWebView to conform to the NSScrollViewSeparatorTrackingAdapter
+        protocol, ensuring the titlebar separator is displayed when
+        necessary. Note that since WKWebViews are not actually NSScrollView's we
+        don't already have the scroll position of the view in the UIProcess. To
+        determine whether or not the view is scrolled, this patch adds plumbing
+        so that the WebProcess can tell the UIProcess the new scroll position
+        when a page is scrolled.
+
+        Tests: WKWebViewTitlebarSeparatorTests.BackForwardCache
+               WKWebViewTitlebarSeparatorTests.ChangeTitlebarAdjacency
+               WKWebViewTitlebarSeparatorTests.ChangeViewVisibility
+               WKWebViewTitlebarSeparatorTests.NavigationResetsTitlebarAppearance
+               WKWebViewTitlebarSeparatorTests.ParentWhileScrolled
+               WKWebViewTitlebarSeparatorTests.ScrollWithTitlebarAdjacency
+               WKWebViewTitlebarSeparatorTests.ScrollWithoutTitlebarAdjacency
+
+        * Platform/spi/mac/AppKitSPI.h:
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView scrollViewFrame]):
+        (-[WKView hasScrolledContentsUnderTitlebar]):
+        * UIProcess/API/mac/WKWebViewMac.mm:
+        (-[WKWebView scrollViewFrame]):
+        (-[WKWebView hasScrolledContentsUnderTitlebar]):
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::updateWindowAndViewFrames):
+
+        If the WKWebView's frame changes, update the titlebar adjacency
+        state and notify observers of the change.
+
+        (WebKit::WebViewImpl::viewWillMoveToWindowImpl):
+
+        Unregister the WKWebView as an NSScrollViewSeparatorTrackingAdapter if
+        it is removed from the window.
+
+        (WebKit::WebViewImpl::viewDidHide):
+
+        Hidden views are not adjacent to the titlebar.
+
+        (WebKit::WebViewImpl::viewDidUnhide):
+
+        An unhidden view may be adjacent to the titlebar.
+
+        (WebKit::WebViewImpl::pageDidScroll):
+
+        Use the scroll position of the page to determine whether or not the
+        WKWebView is scrolled.
+
+        (WebKit::WebViewImpl::scrollViewFrame):
+
+        Needed to conform to NSScrollViewSeparatorTrackingAdapter.
+
+        (WebKit::WebViewImpl::hasScrolledContentsUnderTitlebar):
+
+        Needed to conform to NSScrollViewSeparatorTrackingAdapter. Returns true
+        if the view is registered as an NSScrollViewSeparatorTrackingAdapter
+        and is scrolled.
+
+        (WebKit::WebViewImpl::updateTitlebarAdjacencyState):
+
+        The WKWebView needs to be registered as an NSScrollViewSeparatorTrackingAdapter
+        if it's adjacent to the titlebar and unregistered otherwise.
+
+        * UIProcess/PageClient.h:
+        (WebKit::PageClient::pageDidScroll):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::pageDidScroll):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/PageClientImplMac.h:
+        * UIProcess/mac/PageClientImplMac.mm:
+        (WebKit::PageClientImpl::didCommitLoadForMainFrame):
+
+        Reset the scroll position upon navigation, as pageDidScroll does not get
+        called when navigating.
+
+        (WebKit::PageClientImpl::pageDidScroll):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::pageDidScroll):
+
+        Pass the current scroll position when the page is scrolled, so that the
+        UIProcess knows whether or not the page has a non-zero scroll position.
+
</ins><span class="cx"> 2021-05-18  Tim Horton  <timothy_horton@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r275013): Trying to navigate in a WKWebView from a command line tool crashes the Web Content process
</span></span></pre></div>
<a id="trunkSourceWebKitPlatformspimacAppKitSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Platform/spi/mac/AppKitSPI.h (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Platform/spi/mac/AppKitSPI.h 2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/Platform/spi/mac/AppKitSPI.h    2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -31,6 +31,10 @@
</span><span class="cx"> #import <AppKit/NSTextInputClient_Private.h>
</span><span class="cx"> #import <AppKit/NSWindow_Private.h>
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+#import <AppKit/NSScrollViewSeparatorTrackingAdapter_Private.h>
+#endif
+
</ins><span class="cx"> #else
</span><span class="cx"> 
</span><span class="cx"> @interface NSInspectorBar : NSObject
</span><span class="lines">@@ -37,6 +41,13 @@
</span><span class="cx"> @property (getter=isVisible) BOOL visible;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+@protocol NSScrollViewSeparatorTrackingAdapter
+@property (readonly) NSRect scrollViewFrame;
+@property (readonly) BOOL hasScrolledContentsUnderTitlebar;
+@end
+#endif
+
</ins><span class="cx"> @protocol NSTextInputClient_Async
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="lines">@@ -54,6 +65,11 @@
</span><span class="cx"> @property CGFloat titlebarAlphaValue;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+- (BOOL)registerScrollViewSeparatorTrackingAdapter:(NSObject<NSScrollViewSeparatorTrackingAdapter> *)adapter;
+- (void)unregisterScrollViewSeparatorTrackingAdapter:(NSObject<NSScrollViewSeparatorTrackingAdapter> *)adapter;
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/mac/WKView.mm (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/mac/WKView.mm  2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/API/mac/WKView.mm     2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #import "APIHitTestResult.h"
</span><span class="cx"> #import "APIIconLoadingClient.h"
</span><span class="cx"> #import "APIPageConfiguration.h"
</span><ins>+#import "AppKitSPI.h"
</ins><span class="cx"> #import "WKBrowsingContextGroupPrivate.h"
</span><span class="cx"> #import "WKNSData.h"
</span><span class="cx"> #import "WKProcessGroupPrivate.h"
</span><span class="lines">@@ -68,6 +69,11 @@
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+@interface WKView () <NSScrollViewSeparatorTrackingAdapter>
+@end
+#endif
+
</ins><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx"> 
</span><span class="cx"> @interface WKView () <NSFilePromiseProviderDelegate, NSDraggingSource>
</span><span class="lines">@@ -1131,6 +1137,24 @@
</span><span class="cx"> 
</span><span class="cx"> #endif // HAVE(TOUCH_BAR)
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+
+- (NSRect)scrollViewFrame
+{
+    if (!_data->_impl)
+        return NSZeroRect;
+    return _data->_impl->scrollViewFrame();
+}
+
+- (BOOL)hasScrolledContentsUnderTitlebar
+{
+    if (!_data->_impl)
+        return NO;
+    return _data->_impl->hasScrolledContentsUnderTitlebar();
+}
+
+#endif // HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+
</ins><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="cx"> 
</span><span class="cx"> - (NSString *)filePromiseProvider:(NSFilePromiseProvider *)filePromiseProvider fileNameForType:(NSString *)fileType
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPImacWKWebViewMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm    2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm       2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -84,6 +84,9 @@
</span><span class="cx">     , NSFilePromiseProviderDelegate
</span><span class="cx">     , NSDraggingSource
</span><span class="cx"> #endif
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    , NSScrollViewSeparatorTrackingAdapter
+#endif
</ins><span class="cx">     >
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="lines">@@ -994,6 +997,26 @@
</span><span class="cx"> 
</span><span class="cx"> #endif // HAVE(TOUCH_BAR)
</span><span class="cx"> 
</span><ins>+#pragma mark - NSScrollViewSeparatorTrackingAdapter
+
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+
+- (NSRect)scrollViewFrame
+{
+    if (!_impl)
+        return NSZeroRect;
+    return _impl->scrollViewFrame();
+}
+
+- (BOOL)hasScrolledContentsUnderTitlebar
+{
+    if (!_impl)
+        return NO;
+    return _impl->hasScrolledContentsUnderTitlebar();
+}
+
+#endif // HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #pragma mark -
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h        2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h   2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -94,6 +94,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+class IntPoint;
</ins><span class="cx"> struct ShareDataWithParsedURL;
</span><span class="cx"> 
</span><span class="cx"> #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS)
</span><span class="lines">@@ -302,6 +303,14 @@
</span><span class="cx">     void viewDidUnhide();
</span><span class="cx">     void activeSpaceDidChange();
</span><span class="cx"> 
</span><ins>+    void pageDidScroll(const WebCore::IntPoint&);
+
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    NSRect scrollViewFrame();
+    bool hasScrolledContentsUnderTitlebar();
+    void updateTitlebarAdjacencyState();
+#endif
+
</ins><span class="cx">     NSView *hitTest(CGPoint);
</span><span class="cx"> 
</span><span class="cx">     ColorSpaceData colorSpace();
</span><span class="lines">@@ -862,6 +871,12 @@
</span><span class="cx">     NSInteger m_initialNumberOfValidItemsForDrop { 0 };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    bool m_pageIsScrolledToTop { true };
+    bool m_isRegisteredScrollViewSeparatorTrackingAdapter { false };
+    NSRect m_lastScrollViewFrame { NSZeroRect };
+#endif
+
</ins><span class="cx">     RetainPtr<NSMenu> m_domPasteMenu;
</span><span class="cx">     RetainPtr<WKDOMPasteMenuDelegate> m_domPasteMenuDelegate;
</span><span class="cx">     CompletionHandler<void(WebCore::DOMPasteAccessResponse)> m_domPasteRequestHandler;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm       2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm  2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -120,6 +120,7 @@
</span><span class="cx"> #import <pal/spi/cocoa/NSTouchBarSPI.h>
</span><span class="cx"> #import <pal/spi/mac/DataDetectorsSPI.h>
</span><span class="cx"> #import <pal/spi/mac/LookupSPI.h>
</span><ins>+#import <pal/spi/mac/NSAppearanceSPI.h>
</ins><span class="cx"> #import <pal/spi/mac/NSApplicationSPI.h>
</span><span class="cx"> #import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
</span><span class="cx"> #import <pal/spi/mac/NSScrollerImpSPI.h>
</span><span class="lines">@@ -1463,6 +1464,10 @@
</span><span class="cx">     m_page->setFullscreenClient(makeUnique<WebKit::FullscreenClient>(view));
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    m_lastScrollViewFrame = scrollViewFrame();
+#endif
+
</ins><span class="cx">     WebProcessPool::statistics().wkViewCount++;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1820,6 +1825,16 @@
</span><span class="cx">     if (clipsToVisibleRect())
</span><span class="cx">         updateViewExposedRect();
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    NSRect scrollViewFrame = this->scrollViewFrame();
+    if (!NSEqualRects(m_lastScrollViewFrame, scrollViewFrame)) {
+        m_lastScrollViewFrame = scrollViewFrame;
+        [m_view didChangeValueForKey:@"scrollViewFrame"];
+    }
+
+    updateTitlebarAdjacencyState();
+#endif
+
</ins><span class="cx">     if (m_didScheduleWindowAndViewFrameUpdate)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -2317,6 +2332,13 @@
</span><span class="cx">     NSWindow *stopObservingWindow = m_targetWindowForMovePreparation ? m_targetWindowForMovePreparation.get() : [m_view window];
</span><span class="cx">     [m_windowVisibilityObserver stopObserving:stopObservingWindow];
</span><span class="cx">     [m_windowVisibilityObserver startObserving:window];
</span><ins>+
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    if (m_isRegisteredScrollViewSeparatorTrackingAdapter) {
+        [currentWindow unregisterScrollViewSeparatorTrackingAdapter:(NSObject<NSScrollViewSeparatorTrackingAdapter> *)m_view.get().get()];
+        m_isRegisteredScrollViewSeparatorTrackingAdapter = false;
+    }
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebViewImpl::viewWillMoveToWindow(NSWindow *window)
</span><span class="lines">@@ -2398,6 +2420,9 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(ActivityState, "WebViewImpl %p (page %llu) viewDidHide", this, m_page->identifier().toUInt64());
</span><span class="cx">     m_page->activityStateDidChange(WebCore::ActivityState::IsVisible);
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    updateTitlebarAdjacencyState();
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebViewImpl::viewDidUnhide()
</span><span class="lines">@@ -2404,6 +2429,9 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(ActivityState, "WebViewImpl %p (page %llu) viewDidUnhide", this, m_page->identifier().toUInt64());
</span><span class="cx">     m_page->activityStateDidChange(WebCore::ActivityState::IsVisible);
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    updateTitlebarAdjacencyState();
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebViewImpl::activeSpaceDidChange()
</span><span class="lines">@@ -2412,6 +2440,48 @@
</span><span class="cx">     m_page->activityStateDidChange(WebCore::ActivityState::IsVisible);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebViewImpl::pageDidScroll(const WebCore::IntPoint& scrollPosition)
+{
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+    if ((scrollPosition.y() <= 0) != m_pageIsScrolledToTop) {
+        [m_view willChangeValueForKey:@"hasScrolledContentsUnderTitlebar"];
+        m_pageIsScrolledToTop = !m_pageIsScrolledToTop;
+        [m_view didChangeValueForKey:@"hasScrolledContentsUnderTitlebar"];
+    }
+#endif
+}
+
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+
+NSRect WebViewImpl::scrollViewFrame()
+{
+    return [m_view convertRect:[m_view bounds] toView:nil];
+}
+
+bool WebViewImpl::hasScrolledContentsUnderTitlebar()
+{
+    return m_isRegisteredScrollViewSeparatorTrackingAdapter && !m_pageIsScrolledToTop;
+}
+
+void WebViewImpl::updateTitlebarAdjacencyState()
+{
+    NSWindow *window = [m_view window];
+    bool visible = ![m_view isHiddenOrHasHiddenAncestor];
+    CGFloat topOfWindowContentLayoutRectInSelf = NSMinY([m_view convertRect:[window contentLayoutRect] fromView:nil]);
+    bool topOfWindowContentLayoutRectAdjacent = NSMinY([m_view bounds]) <= topOfWindowContentLayoutRectInSelf;
+
+    bool shouldRegister = topOfWindowContentLayoutRectAdjacent && visible && [[m_view effectiveAppearance] _usesMetricsAppearance];
+
+    if (shouldRegister && !m_isRegisteredScrollViewSeparatorTrackingAdapter && [m_view conformsToProtocol:@protocol(NSScrollViewSeparatorTrackingAdapter)]) {
+        m_isRegisteredScrollViewSeparatorTrackingAdapter = [window registerScrollViewSeparatorTrackingAdapter:(NSObject<NSScrollViewSeparatorTrackingAdapter> *)m_view.get().get()];
+    } else if (!shouldRegister && m_isRegisteredScrollViewSeparatorTrackingAdapter) {
+        [window unregisterScrollViewSeparatorTrackingAdapter:(NSObject<NSScrollViewSeparatorTrackingAdapter> *)m_view.get().get()];
+        m_isRegisteredScrollViewSeparatorTrackingAdapter = false;
+    }
+}
+
+#endif // HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+
</ins><span class="cx"> NSView *WebViewImpl::hitTest(CGPoint point)
</span><span class="cx"> {
</span><span class="cx">     NSView *hitView = [m_view _web_superHitTest:NSPointFromCGPoint(point)];
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/PageClient.h (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/PageClient.h       2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/PageClient.h  2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -573,6 +573,8 @@
</span><span class="cx">     virtual bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) = 0;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    virtual void pageDidScroll(const WebCore::IntPoint&) { }
+
</ins><span class="cx">     virtual void didRestoreScrollPosition() = 0;
</span><span class="cx"> 
</span><span class="cx">     virtual bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) { return false; }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -6024,10 +6024,12 @@
</span><span class="cx">     pageClient().didChangeViewportProperties(attr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::pageDidScroll()
</del><ins>+void WebPageProxy::pageDidScroll(const WebCore::IntPoint& scrollPosition)
</ins><span class="cx"> {
</span><span class="cx">     m_uiClient->pageDidScroll(this);
</span><span class="cx"> 
</span><ins>+    pageClient().pageDidScroll(scrollPosition);
+
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     // Do not hide the validation message if the scrolling was caused by the keyboard showing up.
</span><span class="cx">     if (m_isKeyboardAnimatingIn)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -2072,7 +2072,7 @@
</span><span class="cx">     void rootViewToAccessibilityScreen(const WebCore::IntRect& viewRect, CompletionHandler<void(WebCore::IntRect)>&&);
</span><span class="cx">     void runBeforeUnloadConfirmPanel(WebCore::FrameIdentifier, FrameInfoData&&, const String& message, Messages::WebPageProxy::RunBeforeUnloadConfirmPanelDelayedReply&&);
</span><span class="cx">     void didChangeViewportProperties(const WebCore::ViewportAttributes&);
</span><del>-    void pageDidScroll();
</del><ins>+    void pageDidScroll(const WebCore::IntPoint&);
</ins><span class="cx">     void runOpenPanel(WebCore::FrameIdentifier, FrameInfoData&&, const WebCore::FileChooserSettings&);
</span><span class="cx">     bool didChooseFilesForOpenPanelWithImageTranscoding(const Vector<String>& fileURLs, const Vector<String>& allowedMIMETypes);
</span><span class="cx">     void showShareSheet(const WebCore::ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in   2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in      2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     RunBeforeUnloadConfirmPanel(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, String message) -> (bool shouldClose) Synchronous
</span><del>-    PageDidScroll()
</del><ins>+    PageDidScroll(WebCore::IntPoint scrollPosition)
</ins><span class="cx">     RunOpenPanel(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, struct WebCore::FileChooserSettings parameters)
</span><span class="cx">     ShowShareSheet(struct WebCore::ShareDataWithParsedURL shareData) -> (bool granted) Async
</span><span class="cx">     ShowContactPicker(struct WebCore::ContactsRequestData requestData) -> (Optional<Vector<WebCore::ContactInfo>> info) Async
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacPageClientImplMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h    2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h       2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -272,6 +272,7 @@
</span><span class="cx">     void refView() override;
</span><span class="cx">     void derefView() override;
</span><span class="cx"> 
</span><ins>+    void pageDidScroll(const WebCore::IntPoint&) override;
</ins><span class="cx">     void didRestoreScrollPosition() override;
</span><span class="cx">     bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacPageClientImplMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm   2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm      2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -286,6 +286,7 @@
</span><span class="cx">     m_impl->updateSupportsArbitraryLayoutModes();
</span><span class="cx">     m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
</span><span class="cx">     m_impl->clearPromisedDragImage();
</span><ins>+    m_impl->pageDidScroll({0, 0});
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
</span><span class="lines">@@ -965,6 +966,11 @@
</span><span class="cx">     return m_impl->remoteObjectRegistry();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::pageDidScroll(const WebCore::IntPoint& scrollPosition)
+{
+    m_impl->pageDidScroll(scrollPosition);
+}
+
</ins><span class="cx"> void PageClientImpl::didRestoreScrollPosition()
</span><span class="cx"> {
</span><span class="cx">     m_impl->didRestoreScrollPosition();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -2689,7 +2689,8 @@
</span><span class="cx"> 
</span><span class="cx">     m_pageScrolledHysteresis.impulse();
</span><span class="cx"> 
</span><del>-    send(Messages::WebPageProxy::PageDidScroll());
</del><ins>+    auto scrollPosition = m_page->mainFrame().view()->scrollPosition();
+    send(Messages::WebPageProxy::PageDidScroll(scrollPosition));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::pageStoppedScrolling()
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Tools/ChangeLog       2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2021-05-18  Aditya Keerthi  <akeerthi@apple.com>
+
+        [macOS] Titlebar separator doesn't show when WKWebView is scrolled
+        https://bugs.webkit.org/show_bug.cgi?id=220633
+        <rdar://problem/71094055>
+
+        Reviewed by Darin Adler.
+
+        Added API tests to verify that the delegate implementation returns the
+        correct value for `hasScrolledContentsUnderTitlebar` depending on
+        the view's scroll position, visibility, and frame.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h:
+        * TestWebKitAPI/Tests/mac/WKWebViewTitlebarSeparatorTests.mm: Added.
+        (-[TitlebarSeparatorTestWKWebView initWithFrame:configuration:]):
+        (-[TitlebarSeparatorTestWKWebView separatorTrackingAdapter]):
+        (BackForwardCache):
+        (ChangeTitlebarAdjacency):
+        (ChangeViewVisibility):
+        (NavigationResetsTitlebarAppearance):
+        (ParentWhileScrolled):
+        (ScrollWithTitlebarAdjacency):
+        (ScrollWithoutTitlebarAdjacency):
+
</ins><span class="cx"> 2021-05-18  Jonathan Bedard  <jbedard@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [webkitpy] Forward booted simulators to children processes
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -1144,6 +1144,7 @@
</span><span class="cx">          E3EFB02F25506503003C2F96 /* SystemBeep.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3EFB02E25506503003C2F96 /* SystemBeep.mm */; };
</span><span class="cx">          E3F8AB92241AB9CE003E2A7E /* AccessibilityRemoteUIApp.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3F8AB91241AB9CE003E2A7E /* AccessibilityRemoteUIApp.mm */; };
</span><span class="cx">          E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E5036F77211BC22800BFDBE2 /* color-drop.html */; };
</span><ins>+               E520A36B25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E520A36A25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm */; };
</ins><span class="cx">           E589183C252BC90A0041DED5 /* DateTimeInputsAccessoryViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E589183B252BC90A0041DED5 /* DateTimeInputsAccessoryViewTests.mm */; };
</span><span class="cx">          E5AA42F2259128AE00410A3D /* UserInterfaceIdiomUpdate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5AA42F1259128AE00410A3D /* UserInterfaceIdiomUpdate.mm */; };
</span><span class="cx">          E5AA8D1D25151CC60051CC45 /* DateInputTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5AA8D1C25151CC60051CC45 /* DateInputTests.mm */; };
</span><span class="lines">@@ -2961,6 +2962,7 @@
</span><span class="cx">          E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Deque.cpp; sourceTree = "<group>"; };
</span><span class="cx">          E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
</span><span class="cx">          E5036F77211BC22800BFDBE2 /* color-drop.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "color-drop.html"; sourceTree = "<group>"; };
</span><ins>+               E520A36A25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewTitlebarSeparatorTests.mm; sourceTree = "<group>"; };
</ins><span class="cx">           E589183B252BC90A0041DED5 /* DateTimeInputsAccessoryViewTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DateTimeInputsAccessoryViewTests.mm; sourceTree = "<group>"; };
</span><span class="cx">          E5AA42F1259128AE00410A3D /* UserInterfaceIdiomUpdate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UserInterfaceIdiomUpdate.mm; sourceTree = "<group>"; };
</span><span class="cx">          E5AA8D1C25151CC60051CC45 /* DateInputTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DateInputTests.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -4739,6 +4741,7 @@
</span><span class="cx">                          A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
</span><span class="cx">                          F425831524F07CA5006B985D /* WKWebViewCoders.mm */,
</span><span class="cx">                          F4FA917F1E61849B007B8C1D /* WKWebViewMacEditingTests.mm */,
</span><ins>+                               E520A36A25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm */,
</ins><span class="cx">                   );
</span><span class="cx">                  path = mac;
</span><span class="cx">                  sourceTree = "<group>";
</span><span class="lines">@@ -5880,6 +5883,7 @@
</span><span class="cx">                          CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */,
</span><span class="cx">                          9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
</span><span class="cx">                          95A524952581A10D00461FE9 /* WKWebViewThemeColor.mm in Sources */,
</span><ins>+                               E520A36B25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm in Sources */,
</ins><span class="cx">                           953ABB3525C0D682004C8B73 /* WKWebViewUnderPageBackgroundColor.mm in Sources */,
</span><span class="cx">                          7C74C8FA22DFBA9600DA2DAB /* WTFStringUtilities.cpp in Sources */,
</span><span class="cx">                          C14D304624B4C3BA00480387 /* XPCEndpoint.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsTestWebKitAPImacAppKitSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h (277687 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h    2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h       2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -33,6 +33,10 @@
</span><span class="cx"> #import <AppKit/NSTextInputClient_Private.h>
</span><span class="cx"> #import <AppKit/NSWindow_Private.h>
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+#import <AppKit/NSScrollViewSeparatorTrackingAdapter_Private.h>
+#endif
+
</ins><span class="cx"> #else
</span><span class="cx"> 
</span><span class="cx"> @protocol NSTextInputClient_Async
</span><span class="lines">@@ -79,8 +83,15 @@
</span><span class="cx"> - (void)setInspectorBar:(NSInspectorBar *)bar;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+@protocol NSScrollViewSeparatorTrackingAdapter
+@property (readonly) NSRect scrollViewFrame;
+@property (readonly) BOOL hasScrolledContentsUnderTitlebar;
+@end
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#endif
+
</ins><span class="cx"> @protocol NSTextInputClient_Async_Staging_44648564
</span><span class="cx"> @optional
</span><span class="cx"> - (void)typingAttributesWithCompletionHandler:(void(^)(NSDictionary<NSString *, id> *))completionHandler;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacWKWebViewTitlebarSeparatorTestsmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewTitlebarSeparatorTests.mm (0 => 277688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewTitlebarSeparatorTests.mm                           (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewTitlebarSeparatorTests.mm      2021-05-18 23:15:23 UTC (rev 277688)
</span><span class="lines">@@ -0,0 +1,193 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if PLATFORM(MAC)
+
+#import "AppKitSPI.h"
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <wtf/RetainPtr.h>
+
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+
+@interface TitlebarSeparatorTestWKWebView : TestWKWebView
+- (id<NSScrollViewSeparatorTrackingAdapter>)separatorTrackingAdapter;
+@end
+
+@implementation TitlebarSeparatorTestWKWebView {
+    RetainPtr<NSWindow> _hostWindow;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
+{
+    self = [super initWithFrame:frame configuration:configuration addToWindow:NO];
+    if (!self)
+        return nil;
+
+    [self synchronouslyLoadTestPageNamed:@"simple-tall"];
+
+    _hostWindow = adoptNS([[NSWindow alloc] initWithContentRect:self.frame styleMask:NSWindowStyleMaskTitled backing:NSBackingStoreBuffered defer:YES]);
+    [[_hostWindow contentView] addSubview:self];
+    [_hostWindow makeKeyAndOrderFront:nil];
+
+    return self;
+}
+
+- (id<NSScrollViewSeparatorTrackingAdapter>)separatorTrackingAdapter
+{
+    ASSERT([self conformsToProtocol:@protocol(NSScrollViewSeparatorTrackingAdapter)]);
+    return (id<NSScrollViewSeparatorTrackingAdapter>)self;
+}
+
+@end
+
+TEST(WKWebViewTitlebarSeparatorTests, ScrollWithTitlebarAdjacency)
+{
+    auto webView = adoptNS([[TitlebarSeparatorTestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto separatorTrackingAdapter = [webView separatorTrackingAdapter];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView stringByEvaluatingJavaScript:@"scrollTo(0, 1000)"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView stringByEvaluatingJavaScript:@"scrollTo(0, 0)"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+}
+
+TEST(WKWebViewTitlebarSeparatorTests, NavigationResetsTitlebarAppearance)
+{
+    auto webView = adoptNS([[TitlebarSeparatorTestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto separatorTrackingAdapter = [webView separatorTrackingAdapter];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView stringByEvaluatingJavaScript:@"scrollTo(0, 1000)"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView synchronouslyLoadTestPageNamed:@"simple-tall"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+}
+
+TEST(WKWebViewTitlebarSeparatorTests, ScrollWithoutTitlebarAdjacency)
+{
+    auto webView = adoptNS([[TitlebarSeparatorTestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+    [webView setFrameSize:NSMakeSize(800, 500)];
+
+    auto separatorTrackingAdapter = [webView separatorTrackingAdapter];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView stringByEvaluatingJavaScript:@"scrollTo(0, 1000)"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+}
+
+TEST(WKWebViewTitlebarSeparatorTests, ChangeTitlebarAdjacency)
+{
+    auto webView = adoptNS([[TitlebarSeparatorTestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto separatorTrackingAdapter = [webView separatorTrackingAdapter];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView stringByEvaluatingJavaScript:@"scrollTo(0, 1000)"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView setFrameSize:NSMakeSize(800, 500)];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView setFrameSize:NSMakeSize(800, 600)];
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+}
+
+TEST(WKWebViewTitlebarSeparatorTests, ChangeViewVisibility)
+{
+    auto webView = adoptNS([[TitlebarSeparatorTestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto separatorTrackingAdapter = [webView separatorTrackingAdapter];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView stringByEvaluatingJavaScript:@"scrollTo(0, 1000)"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView setHidden:YES];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView setHidden:NO];
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+}
+
+TEST(WKWebViewTitlebarSeparatorTests, BackForwardCache)
+{
+    auto webView = adoptNS([[TitlebarSeparatorTestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto separatorTrackingAdapter = [webView separatorTrackingAdapter];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView stringByEvaluatingJavaScript:@"scrollTo(0, 1000)"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView synchronouslyLoadTestPageNamed:@"simple"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView synchronouslyGoBack];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+
+    [webView synchronouslyGoForward];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+}
+
+TEST(WKWebViewTitlebarSeparatorTests, ParentWhileScrolled)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto rect = CGRectMake(0, 0, 800, 600);
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:rect configuration:configuration.get() addToWindow:NO]);
+    [webView synchronouslyLoadTestPageNamed:@"simple-tall"];
+    [webView stringByEvaluatingJavaScript:@"scrollTo(0, 1000)"];
+    [webView waitForNextPresentationUpdate];
+
+    auto window = adoptNS([[NSWindow alloc] initWithContentRect:rect styleMask:NSWindowStyleMaskTitled backing:NSBackingStoreBuffered defer:YES]);
+    [[window contentView] addSubview:webView.get()];
+    [window makeKeyAndOrderFront:nil];
+
+    auto separatorTrackingAdapter = (id<NSScrollViewSeparatorTrackingAdapter>)webView.get();
+    EXPECT_TRUE([separatorTrackingAdapter hasScrolledContentsUnderTitlebar]);
+}
+
+#endif // HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+
+#endif // PLATFORM(MAC)
</ins></span></pre>
</div>
</div>

</body>
</html>