Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c2abdb76db274ba599d89d60075d88eb268e80c0
      
https://github.com/WebKit/WebKit/commit/c2abdb76db274ba599d89d60075d88eb268e80c0
  Author: Wenson Hsieh <[email protected]>
  Date:   2025-03-31 (Mon, 31 Mar 2025)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
    M Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm
    M Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h
    M Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm
    M Source/WebKit/UIProcess/ViewGestureController.h
    M Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm
    M Source/WebKit/UIProcess/mac/WebViewImpl.h
    M Source/WebKit/UIProcess/mac/WebViewImpl.mm
    M Tools/TestWebKitAPI/SourcesCocoa.txt
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/mac/CustomSwipeViewTests.mm

  Log Message:
  -----------
  [macOS] Add a version of `-_setCustomSwipeViewsTopContentInset:` that 
supports all 4 rect edges
https://bugs.webkit.org/show_bug.cgi?id=290731
rdar://144614910

Reviewed by Abrar Rahman Protyasha.

Add an alternate version of `-_setCustomSwipeViewsTopContentInset:` that takes 
an `NSEdgeInsets`
struct instead of just a single value denoting the top content inset, and 
reimplement the existing
method in terms of the new method.

See below for more details.

* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm:
(coreBoxExtentsFromEdgeInsets):
(-[WKWebView _setObscuredContentInsets:immediate:]):

Pull logic to convert `NSEdgeInsets` into a `WebCore::FloatBoxExtent` out into 
a separate static
helper, so that I can reuse it below.

(-[WKWebView _setCustomSwipeViewsTopContentInset:]):

Reimplement this in terms of `-_setCustomSwipeViewsObscuredContentInsets:`.

(-[WKWebView _setCustomSwipeViewsObscuredContentInsets:]):
* Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h:
* Source/WebKit/UIProcess/API/mac/WKWebViewTestingMac.mm:
(-[WKWebView _windowRelativeBoundsForCustomSwipeViewsForTesting]):

Add a simple testing hook to ask for the window-relative bounds for custom 
swipe views. This isn't
really exposed in any other sensible way for API tests, so I fell back to 
adding a new testing hook
instead.

* Source/WebKit/UIProcess/ViewGestureController.h:
* Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::windowRelativeBoundsForCustomSwipeViews const):

Add support for all 4 rect edges here. Instead of just shrinking `swipeArea` by 
the top inset, we
now shrink `swipeArea` by all 4 sides (note that this is in AppKit window 
coordinates, so the origin
is in the bottom left corner).

(WebKit::ViewGestureController::beginSwipeGesture):

This previously re-expanded the `windowRelativeBoundsForCustomSwipeViews` by 
the top content inset;
we adjust this to do the same for all 4 rect edges, by unapplying the shrinking 
by obscured insets
above.

* Source/WebKit/UIProcess/mac/WebViewImpl.h:
* Source/WebKit/UIProcess/mac/WebViewImpl.mm:
(WebKit::WebViewImpl::windowRelativeBoundsForCustomSwipeViews const):
(WebKit::WebViewImpl::customSwipeViewsObscuredContentInsets const):
(WebKit::WebViewImpl::protectedGestureController const):

Add a `protectedGestureController` const getter that returns a `RefPtr`.

(WebKit::WebViewImpl::setCustomSwipeViewsObscuredContentInsets):
(WebKit::WebViewImpl::setCustomSwipeViewsTopContentInset): Deleted.
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/mac/CustomSwipeViewTests.mm: Copied from 
Source/WebKit/UIProcess/API/mac/WKWebViewPrivateForTestingMac.h.
(TestWebKitAPI::TEST(CustomSwipeViewTests, 
WindowRelativeBoundsForCustomSwipeViews)):

Add a new simple API test to exercise this SPI, using the new test helper 
property.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to