Diff
Modified: trunk/Source/WTF/ChangeLog (277687 => 277688)
--- 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)
@@ -1,3 +1,13 @@
+2021-05-18 Aditya Keerthi <akeer...@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.
+
2021-05-18 Yoshiaki Jitsukawa <yoshiaki.jitsuk...@sony.com>
[PlayStation] Fix PlayStation port
Modified: trunk/Source/WTF/wtf/PlatformHave.h (277687 => 277688)
--- 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)
@@ -921,6 +921,7 @@
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
#define HAVE_STATIC_FONT_REGISTRY 1
#define HAVE_DATA_DETECTORS_MAC_ACTION 1
+#define HAVE_NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER 1
#endif
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000) \
Modified: trunk/Source/WebKit/ChangeLog (277687 => 277688)
--- 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)
@@ -1,3 +1,99 @@
+2021-05-18 Aditya Keerthi <akeer...@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.
+
2021-05-18 Tim Horton <timothy_hor...@apple.com>
REGRESSION (r275013): Trying to navigate in a WKWebView from a command line tool crashes the Web Content process
Modified: trunk/Source/WebKit/Platform/spi/mac/AppKitSPI.h (277687 => 277688)
--- 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)
@@ -31,6 +31,10 @@
#import <AppKit/NSTextInputClient_Private.h>
#import <AppKit/NSWindow_Private.h>
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+#import <AppKit/NSScrollViewSeparatorTrackingAdapter_Private.h>
+#endif
+
#else
@interface NSInspectorBar : NSObject
@@ -37,6 +41,13 @@
@property (getter=isVisible) BOOL visible;
@end
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+@protocol NSScrollViewSeparatorTrackingAdapter
+@property (readonly) NSRect scrollViewFrame;
+@property (readonly) BOOL hasScrolledContentsUnderTitlebar;
+@end
+#endif
+
@protocol NSTextInputClient_Async
@end
@@ -54,6 +65,11 @@
@property CGFloat titlebarAlphaValue;
#endif
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+- (BOOL)registerScrollViewSeparatorTrackingAdapter:(NSObject<NSScrollViewSeparatorTrackingAdapter> *)adapter;
+- (void)unregisterScrollViewSeparatorTrackingAdapter:(NSObject<NSScrollViewSeparatorTrackingAdapter> *)adapter;
+#endif
+
@end
#endif
Modified: trunk/Source/WebKit/UIProcess/API/mac/WKView.mm (277687 => 277688)
--- 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)
@@ -31,6 +31,7 @@
#import "APIHitTestResult.h"
#import "APIIconLoadingClient.h"
#import "APIPageConfiguration.h"
+#import "AppKitSPI.h"
#import "WKBrowsingContextGroupPrivate.h"
#import "WKNSData.h"
#import "WKProcessGroupPrivate.h"
@@ -68,6 +69,11 @@
@end
#endif
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+@interface WKView () <NSScrollViewSeparatorTrackingAdapter>
+@end
+#endif
+
#if ENABLE(DRAG_SUPPORT)
@interface WKView () <NSFilePromiseProviderDelegate, NSDraggingSource>
@@ -1131,6 +1137,24 @@
#endif // HAVE(TOUCH_BAR)
+#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)
+
#if ENABLE(DRAG_SUPPORT)
- (NSString *)filePromiseProvider:(NSFilePromiseProvider *)filePromiseProvider fileNameForType:(NSString *)fileType
Modified: trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm (277687 => 277688)
--- 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)
@@ -84,6 +84,9 @@
, NSFilePromiseProviderDelegate
, NSDraggingSource
#endif
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+ , NSScrollViewSeparatorTrackingAdapter
+#endif
>
@end
@@ -994,6 +997,26 @@
#endif // HAVE(TOUCH_BAR)
+#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)
+
@end
#pragma mark -
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (277687 => 277688)
--- 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)
@@ -94,6 +94,7 @@
}
namespace WebCore {
+class IntPoint;
struct ShareDataWithParsedURL;
#if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS)
@@ -302,6 +303,14 @@
void viewDidUnhide();
void activeSpaceDidChange();
+ void pageDidScroll(const WebCore::IntPoint&);
+
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+ NSRect scrollViewFrame();
+ bool hasScrolledContentsUnderTitlebar();
+ void updateTitlebarAdjacencyState();
+#endif
+
NSView *hitTest(CGPoint);
ColorSpaceData colorSpace();
@@ -862,6 +871,12 @@
NSInteger m_initialNumberOfValidItemsForDrop { 0 };
#endif
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+ bool m_pageIsScrolledToTop { true };
+ bool m_isRegisteredScrollViewSeparatorTrackingAdapter { false };
+ NSRect m_lastScrollViewFrame { NSZeroRect };
+#endif
+
RetainPtr<NSMenu> m_domPasteMenu;
RetainPtr<WKDOMPasteMenuDelegate> m_domPasteMenuDelegate;
CompletionHandler<void(WebCore::DOMPasteAccessResponse)> m_domPasteRequestHandler;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (277687 => 277688)
--- 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)
@@ -120,6 +120,7 @@
#import <pal/spi/cocoa/NSTouchBarSPI.h>
#import <pal/spi/mac/DataDetectorsSPI.h>
#import <pal/spi/mac/LookupSPI.h>
+#import <pal/spi/mac/NSAppearanceSPI.h>
#import <pal/spi/mac/NSApplicationSPI.h>
#import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
#import <pal/spi/mac/NSScrollerImpSPI.h>
@@ -1463,6 +1464,10 @@
m_page->setFullscreenClient(makeUnique<WebKit::FullscreenClient>(view));
#endif
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+ m_lastScrollViewFrame = scrollViewFrame();
+#endif
+
WebProcessPool::statistics().wkViewCount++;
}
@@ -1820,6 +1825,16 @@
if (clipsToVisibleRect())
updateViewExposedRect();
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+ NSRect scrollViewFrame = this->scrollViewFrame();
+ if (!NSEqualRects(m_lastScrollViewFrame, scrollViewFrame)) {
+ m_lastScrollViewFrame = scrollViewFrame;
+ [m_view didChangeValueForKey:@"scrollViewFrame"];
+ }
+
+ updateTitlebarAdjacencyState();
+#endif
+
if (m_didScheduleWindowAndViewFrameUpdate)
return;
@@ -2317,6 +2332,13 @@
NSWindow *stopObservingWindow = m_targetWindowForMovePreparation ? m_targetWindowForMovePreparation.get() : [m_view window];
[m_windowVisibilityObserver stopObserving:stopObservingWindow];
[m_windowVisibilityObserver startObserving:window];
+
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+ if (m_isRegisteredScrollViewSeparatorTrackingAdapter) {
+ [currentWindow unregisterScrollViewSeparatorTrackingAdapter:(NSObject<NSScrollViewSeparatorTrackingAdapter> *)m_view.get().get()];
+ m_isRegisteredScrollViewSeparatorTrackingAdapter = false;
+ }
+#endif
}
void WebViewImpl::viewWillMoveToWindow(NSWindow *window)
@@ -2398,6 +2420,9 @@
{
LOG(ActivityState, "WebViewImpl %p (page %llu) viewDidHide", this, m_page->identifier().toUInt64());
m_page->activityStateDidChange(WebCore::ActivityState::IsVisible);
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+ updateTitlebarAdjacencyState();
+#endif
}
void WebViewImpl::viewDidUnhide()
@@ -2404,6 +2429,9 @@
{
LOG(ActivityState, "WebViewImpl %p (page %llu) viewDidUnhide", this, m_page->identifier().toUInt64());
m_page->activityStateDidChange(WebCore::ActivityState::IsVisible);
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+ updateTitlebarAdjacencyState();
+#endif
}
void WebViewImpl::activeSpaceDidChange()
@@ -2412,6 +2440,48 @@
m_page->activityStateDidChange(WebCore::ActivityState::IsVisible);
}
+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)
+
NSView *WebViewImpl::hitTest(CGPoint point)
{
NSView *hitView = [m_view _web_superHitTest:NSPointFromCGPoint(point)];
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (277687 => 277688)
--- 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)
@@ -573,6 +573,8 @@
virtual bool decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&) = 0;
#endif
+ virtual void pageDidScroll(const WebCore::IntPoint&) { }
+
virtual void didRestoreScrollPosition() = 0;
virtual bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) { return false; }
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (277687 => 277688)
--- 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)
@@ -6024,10 +6024,12 @@
pageClient().didChangeViewportProperties(attr);
}
-void WebPageProxy::pageDidScroll()
+void WebPageProxy::pageDidScroll(const WebCore::IntPoint& scrollPosition)
{
m_uiClient->pageDidScroll(this);
+ pageClient().pageDidScroll(scrollPosition);
+
#if PLATFORM(IOS_FAMILY)
// Do not hide the validation message if the scrolling was caused by the keyboard showing up.
if (m_isKeyboardAnimatingIn)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (277687 => 277688)
--- 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)
@@ -2072,7 +2072,7 @@
void rootViewToAccessibilityScreen(const WebCore::IntRect& viewRect, CompletionHandler<void(WebCore::IntRect)>&&);
void runBeforeUnloadConfirmPanel(WebCore::FrameIdentifier, FrameInfoData&&, const String& message, Messages::WebPageProxy::RunBeforeUnloadConfirmPanelDelayedReply&&);
void didChangeViewportProperties(const WebCore::ViewportAttributes&);
- void pageDidScroll();
+ void pageDidScroll(const WebCore::IntPoint&);
void runOpenPanel(WebCore::FrameIdentifier, FrameInfoData&&, const WebCore::FileChooserSettings&);
bool didChooseFilesForOpenPanelWithImageTranscoding(const Vector<String>& fileURLs, const Vector<String>& allowedMIMETypes);
void showShareSheet(const WebCore::ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (277687 => 277688)
--- 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)
@@ -66,7 +66,7 @@
#endif
RunBeforeUnloadConfirmPanel(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, String message) -> (bool shouldClose) Synchronous
- PageDidScroll()
+ PageDidScroll(WebCore::IntPoint scrollPosition)
RunOpenPanel(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, struct WebCore::FileChooserSettings parameters)
ShowShareSheet(struct WebCore::ShareDataWithParsedURL shareData) -> (bool granted) Async
ShowContactPicker(struct WebCore::ContactsRequestData requestData) -> (Optional<Vector<WebCore::ContactInfo>> info) Async
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (277687 => 277688)
--- 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)
@@ -272,6 +272,7 @@
void refView() override;
void derefView() override;
+ void pageDidScroll(const WebCore::IntPoint&) override;
void didRestoreScrollPosition() override;
bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) override;
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (277687 => 277688)
--- 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)
@@ -286,6 +286,7 @@
m_impl->updateSupportsArbitraryLayoutModes();
m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
m_impl->clearPromisedDragImage();
+ m_impl->pageDidScroll({0, 0});
}
void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
@@ -965,6 +966,11 @@
return m_impl->remoteObjectRegistry();
}
+void PageClientImpl::pageDidScroll(const WebCore::IntPoint& scrollPosition)
+{
+ m_impl->pageDidScroll(scrollPosition);
+}
+
void PageClientImpl::didRestoreScrollPosition()
{
m_impl->didRestoreScrollPosition();
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (277687 => 277688)
--- 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)
@@ -2689,7 +2689,8 @@
m_pageScrolledHysteresis.impulse();
- send(Messages::WebPageProxy::PageDidScroll());
+ auto scrollPosition = m_page->mainFrame().view()->scrollPosition();
+ send(Messages::WebPageProxy::PageDidScroll(scrollPosition));
}
void WebPage::pageStoppedScrolling()
Modified: trunk/Tools/ChangeLog (277687 => 277688)
--- trunk/Tools/ChangeLog 2021-05-18 23:08:58 UTC (rev 277687)
+++ trunk/Tools/ChangeLog 2021-05-18 23:15:23 UTC (rev 277688)
@@ -1,3 +1,28 @@
+2021-05-18 Aditya Keerthi <akeer...@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):
+
2021-05-18 Jonathan Bedard <jbed...@apple.com>
[webkitpy] Forward booted simulators to children processes
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (277687 => 277688)
--- 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)
@@ -1144,6 +1144,7 @@
E3EFB02F25506503003C2F96 /* SystemBeep.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3EFB02E25506503003C2F96 /* SystemBeep.mm */; };
E3F8AB92241AB9CE003E2A7E /* AccessibilityRemoteUIApp.mm in Sources */ = {isa = PBXBuildFile; fileRef = E3F8AB91241AB9CE003E2A7E /* AccessibilityRemoteUIApp.mm */; };
E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E5036F77211BC22800BFDBE2 /* color-drop.html */; };
+ E520A36B25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E520A36A25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm */; };
E589183C252BC90A0041DED5 /* DateTimeInputsAccessoryViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E589183B252BC90A0041DED5 /* DateTimeInputsAccessoryViewTests.mm */; };
E5AA42F2259128AE00410A3D /* UserInterfaceIdiomUpdate.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5AA42F1259128AE00410A3D /* UserInterfaceIdiomUpdate.mm */; };
E5AA8D1D25151CC60051CC45 /* DateInputTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5AA8D1C25151CC60051CC45 /* DateInputTests.mm */; };
@@ -2961,6 +2962,7 @@
E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Deque.cpp; sourceTree = "<group>"; };
E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
E5036F77211BC22800BFDBE2 /* color-drop.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "color-drop.html"; sourceTree = "<group>"; };
+ E520A36A25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewTitlebarSeparatorTests.mm; sourceTree = "<group>"; };
E589183B252BC90A0041DED5 /* DateTimeInputsAccessoryViewTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DateTimeInputsAccessoryViewTests.mm; sourceTree = "<group>"; };
E5AA42F1259128AE00410A3D /* UserInterfaceIdiomUpdate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UserInterfaceIdiomUpdate.mm; sourceTree = "<group>"; };
E5AA8D1C25151CC60051CC45 /* DateInputTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DateInputTests.mm; sourceTree = "<group>"; };
@@ -4739,6 +4741,7 @@
A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
F425831524F07CA5006B985D /* WKWebViewCoders.mm */,
F4FA917F1E61849B007B8C1D /* WKWebViewMacEditingTests.mm */,
+ E520A36A25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm */,
);
path = mac;
sourceTree = "<group>";
@@ -5880,6 +5883,7 @@
CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */,
9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
95A524952581A10D00461FE9 /* WKWebViewThemeColor.mm in Sources */,
+ E520A36B25AFB76C00526CB9 /* WKWebViewTitlebarSeparatorTests.mm in Sources */,
953ABB3525C0D682004C8B73 /* WKWebViewUnderPageBackgroundColor.mm in Sources */,
7C74C8FA22DFBA9600DA2DAB /* WTFStringUtilities.cpp in Sources */,
C14D304624B4C3BA00480387 /* XPCEndpoint.mm in Sources */,
Modified: trunk/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac/AppKitSPI.h (277687 => 277688)
--- 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)
@@ -33,6 +33,10 @@
#import <AppKit/NSTextInputClient_Private.h>
#import <AppKit/NSWindow_Private.h>
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+#import <AppKit/NSScrollViewSeparatorTrackingAdapter_Private.h>
+#endif
+
#else
@protocol NSTextInputClient_Async
@@ -79,8 +83,15 @@
- (void)setInspectorBar:(NSInspectorBar *)bar;
@end
+#if HAVE(NSSCROLLVIEW_SEPARATOR_TRACKING_ADAPTER)
+@protocol NSScrollViewSeparatorTrackingAdapter
+@property (readonly) NSRect scrollViewFrame;
+@property (readonly) BOOL hasScrolledContentsUnderTitlebar;
+@end
#endif
+#endif
+
@protocol NSTextInputClient_Async_Staging_44648564
@optional
- (void)typingAttributesWithCompletionHandler:(void(^)(NSDictionary<NSString *, id> *))completionHandler;
Added: trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewTitlebarSeparatorTests.mm (0 => 277688)
--- 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)
@@ -0,0 +1,193 @@
+/*
+ * 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)