Changeset 254360 in webkit


Ignore:
Timestamp:
Jan 10, 2020 11:56:50 AM (4 years ago)
Author:
Simon Fraser
Message:

[macOS UI-side compositing] Introduce WKScrollView and WKContentView for macOS
https://bugs.webkit.org/show_bug.cgi?id=206042

Reviewed by Tim Horton.

Add WKScrollViewMac and WKWebViewMac, with bare-bones implementations. WKScrollViewMac
has a WKScrollViewDelegate to make it more iOS-like, to avoid clients having to register
boundsDidChange notifications, and WKWebView on macOS becomes the delegate.

These views are only created when UI-side compositing is enabled.

  • SourcesCocoa.txt:
  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):

  • UIProcess/API/Cocoa/WKWebViewInternal.h:
  • UIProcess/API/mac/WKContentViewMac.h: Added.
  • UIProcess/API/mac/WKContentViewMac.mm: Added.

(-[WKContentView initWithFrame:page:]):
(-[WKContentView isFlipped]):
(-[WKContentView _setAcceleratedCompositingRootLayer:]):

  • UIProcess/API/mac/WKScrollViewMac.h: Added.
  • UIProcess/API/mac/WKScrollViewMac.mm: Added.

(+[WKScrollView isCompatibleWithResponsiveScrolling]):
(-[WKScrollView initWithFrame:]):
(-[WKScrollView dealloc]):
(-[WKScrollView delegate]):
(-[WKScrollView setDelegate:]):
(-[WKScrollView contentOffset]):
(-[WKScrollView boundsDidChange:]):
(-[WKScrollView setContentInsets:]):

  • UIProcess/API/mac/WKWebViewMac.h:
  • UIProcess/API/mac/WKWebViewMac.mm:

(-[WKWebView scrollViewDidScroll:]):
(-[WKWebView scrollViewContentInsetsDidChange:]):
(-[WKWebView _setupScrollAndContentViews]):

  • UIProcess/ios/WebPageProxyIOS.mm:
  • WebKit.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebKit
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r254356 r254360  
     12020-01-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [macOS UI-side compositing] Introduce WKScrollView and WKContentView for macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=206042
     5
     6        Reviewed by Tim Horton.
     7
     8        Add WKScrollViewMac and WKWebViewMac, with bare-bones implementations. WKScrollViewMac
     9        has a WKScrollViewDelegate to make it more iOS-like, to avoid clients having to register
     10        boundsDidChange notifications, and WKWebView on macOS becomes the delegate.
     11
     12        These views are only created when UI-side compositing is enabled.
     13
     14        * SourcesCocoa.txt:
     15        * UIProcess/API/Cocoa/WKWebView.mm:
     16        (-[WKWebView _initializeWithConfiguration:]):
     17        * UIProcess/API/Cocoa/WKWebViewInternal.h:
     18        * UIProcess/API/mac/WKContentViewMac.h: Added.
     19        * UIProcess/API/mac/WKContentViewMac.mm: Added.
     20        (-[WKContentView initWithFrame:page:]):
     21        (-[WKContentView isFlipped]):
     22        (-[WKContentView _setAcceleratedCompositingRootLayer:]):
     23        * UIProcess/API/mac/WKScrollViewMac.h: Added.
     24        * UIProcess/API/mac/WKScrollViewMac.mm: Added.
     25        (+[WKScrollView isCompatibleWithResponsiveScrolling]):
     26        (-[WKScrollView initWithFrame:]):
     27        (-[WKScrollView dealloc]):
     28        (-[WKScrollView delegate]):
     29        (-[WKScrollView setDelegate:]):
     30        (-[WKScrollView contentOffset]):
     31        (-[WKScrollView boundsDidChange:]):
     32        (-[WKScrollView setContentInsets:]):
     33        * UIProcess/API/mac/WKWebViewMac.h:
     34        * UIProcess/API/mac/WKWebViewMac.mm:
     35        (-[WKWebView scrollViewDidScroll:]):
     36        (-[WKWebView scrollViewContentInsetsDidChange:]):
     37        (-[WKWebView _setupScrollAndContentViews]):
     38        * UIProcess/ios/WebPageProxyIOS.mm:
     39        * WebKit.xcodeproj/project.pbxproj:
     40
    1412020-01-10  Jiewen Tan  <jiewen_tan@apple.com>
    242
  • trunk/Source/WebKit/SourcesCocoa.txt

    r254345 r254360  
    335335UIProcess/API/ios/WKWebViewTestingIOS.mm
    336336
     337UIProcess/API/mac/WKContentViewMac.mm
     338UIProcess/API/mac/WKScrollViewMac.mm
    337339UIProcess/API/mac/WKView.mm
    338340UIProcess/API/mac/WKWebViewMac.mm
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r254315 r254360  
    162162#if PLATFORM(MAC)
    163163#import "AppKitSPI.h"
     164#import "WKContentViewMac.h"
    164165#import "WKTextFinderClient.h"
    165166#import "WKViewInternal.h"
     
    315316
    316317    _usePlatformFindUI = YES;
     318
    317319#if PLATFORM(IOS_FAMILY)
    318320    _avoidsUnsafeArea = YES;
     
    357359    _page = &_impl->page();
    358360
     361    if (_impl->isUsingUISideCompositing())
     362        _contentView = adoptNS([[WKContentView alloc] initWithFrame:self.bounds page:_page.copyRef()]);
     363
    359364    _impl->setAutomaticallyAdjustsContentInsets(true);
    360365    _impl->setRequiresUserActionForEditingControlsManager([configuration _requiresUserActionForEditingControlsManager]);
     366
     367    [self _setupScrollAndContentViews];
    361368#endif
    362369
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h

    r254241 r254360  
    8484}
    8585
     86@class WKContentView;
     87@class WKPasswordView;
     88@class WKSafeBrowsingWarning;
     89@class WKScrollView;
    8690@class WKWebViewContentProviderRegistry;
    87 @class WKPasswordView;
    8891@class _WKFrameHandle;
    89 @class WKSafeBrowsingWarning;
    90 
    91 #if PLATFORM(IOS_FAMILY)
    92 @class WKScrollView;
     92
     93#if PLATFORM(IOS_FAMILY)
    9394@class WKFullScreenWindowController;
    9495@protocol WKWebViewContentProvider;
     
    127128    std::unique_ptr<WebKit::WebViewImpl> _impl;
    128129    RetainPtr<WKTextFinderClient> _textFinderClient;
     130
     131    // Only used with UI-side compositing.
     132    RetainPtr<WKScrollView> _scrollView;
     133    RetainPtr<WKContentView> _contentView;
    129134#endif
    130135
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.h

    r253527 r254360  
    2828#if PLATFORM(MAC)
    2929
     30#import "WKScrollViewMac.h"
    3031#import "WebViewImpl.h"
    3132#import "_WKOverlayScrollbarStyle.h"
    3233#import <WebCore/ScrollTypes.h>
    3334
    34 @protocol WebViewImplDelegate;
    35 
    3635_WKOverlayScrollbarStyle toAPIScrollbarStyle(Optional<WebCore::ScrollbarOverlayStyle>);
    3736Optional<WebCore::ScrollbarOverlayStyle> toCoreScrollbarStyle(_WKOverlayScrollbarStyle);
    3837
    39 @interface WKWebView (WKInternalMac) <WebViewImplDelegate>
     38@interface WKWebView (WKInternalMac) <WebViewImplDelegate, WKScrollViewDelegate>
     39
     40- (void)_setupScrollAndContentViews;
    4041
    4142- (void)_takeFindStringFromSelectionInternal:(id)sender;
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm

    r253527 r254360  
    3131#import "AppKitSPI.h"
    3232#import "VersionChecks.h"
     33#import "WKContentViewMac.h"
    3334#import "WKSafeBrowsingWarning.h"
     35#import "WKScrollViewMac.h"
    3436#import "WKTextFinderClient.h"
    3537#import "WKUIDelegatePrivate.h"
     
    12081210}
    12091211
     1212#pragma mark - WKScrollViewDelegate
     1213
     1214- (void)scrollViewDidScroll:(NSScrollView *)scrollView
     1215{
     1216    // Only called with UI-side compositing.
     1217}
     1218
     1219- (void)scrollViewContentInsetsDidChange:(NSScrollView *)scrollView
     1220{
     1221    // Only called with UI-side compositing.
     1222}
     1223
     1224#pragma mark -
     1225
     1226- (void)_setupScrollAndContentViews
     1227{
     1228    if (!_impl->isUsingUISideCompositing())
     1229        return;
     1230
     1231    _scrollView = adoptNS([[WKScrollView alloc] initWithFrame:[self bounds]]);
     1232    [_scrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
     1233    [self addSubview:_scrollView.get() positioned:NSWindowBelow relativeTo:nil];
     1234
     1235    // The content view will get resized to fit the content.
     1236    [_scrollView setDocumentView:_contentView.get()];
     1237    [_scrollView setDelegate:self];
     1238}
     1239
    12101240@end
    12111241
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r254345 r254360  
    102102                0E97D74D200E900400BF6643 /* SafeBrowsingSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */; };
    103103                0EDE85032004E75D00030560 /* WebsitePopUpPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 0EDE85022004E74900030560 /* WebsitePopUpPolicy.h */; };
     104                0F04159C23C7CC730060A3E2 /* WKScrollViewMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F04159823C7CC720060A3E2 /* WKScrollViewMac.h */; };
     105                0F04159E23C7CC730060A3E2 /* WKContentViewMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F04159A23C7CC730060A3E2 /* WKContentViewMac.h */; };
    104106                0F08CF521D63C13A00B48DF1 /* WKFormSelectPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F08CF511D63C13A00B48DF1 /* WKFormSelectPicker.h */; };
    105107                0F08CF541D63C14000B48DF1 /* WKFormSelectPopover.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F08CF531D63C14000B48DF1 /* WKFormSelectPopover.h */; };
     
    20902092                0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SafeBrowsingSPI.h; sourceTree = "<group>"; };
    20912093                0EDE85022004E74900030560 /* WebsitePopUpPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsitePopUpPolicy.h; sourceTree = "<group>"; };
     2094                0F04159823C7CC720060A3E2 /* WKScrollViewMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKScrollViewMac.h; sourceTree = "<group>"; };
     2095                0F04159923C7CC730060A3E2 /* WKContentViewMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentViewMac.mm; sourceTree = "<group>"; };
     2096                0F04159A23C7CC730060A3E2 /* WKContentViewMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContentViewMac.h; sourceTree = "<group>"; };
     2097                0F04159B23C7CC730060A3E2 /* WKScrollViewMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKScrollViewMac.mm; sourceTree = "<group>"; };
    20922098                0F08CF511D63C13A00B48DF1 /* WKFormSelectPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFormSelectPicker.h; path = ios/forms/WKFormSelectPicker.h; sourceTree = "<group>"; };
    20932099                0F08CF531D63C14000B48DF1 /* WKFormSelectPopover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFormSelectPopover.h; path = ios/forms/WKFormSelectPopover.h; sourceTree = "<group>"; };
     
    87348740                        isa = PBXGroup;
    87358741                        children = (
     8742                                0F04159A23C7CC730060A3E2 /* WKContentViewMac.h */,
     8743                                0F04159923C7CC730060A3E2 /* WKContentViewMac.mm */,
     8744                                0F04159823C7CC720060A3E2 /* WKScrollViewMac.h */,
     8745                                0F04159B23C7CC730060A3E2 /* WKScrollViewMac.mm */,
    87368746                                BC8699B3116AADAA002A925B /* WKView.mm */,
    87378747                                BC8699B4116AADAA002A925B /* WKViewInternal.h */,
     
    1072710737                                0FCB4E4C18BBE044000FCFC9 /* WKContentView.h in Headers */,
    1072810738                                0FCB4E6C18BBF26A000FCFC9 /* WKContentViewInteraction.h in Headers */,
     10739                                0F04159E23C7CC730060A3E2 /* WKContentViewMac.h in Headers */,
    1072910740                                BCB9E24B1120E15C00A137E0 /* WKContext.h in Headers */,
    1073010741                                1AE52F981920267200A1FA37 /* WKContextConfigurationRef.h in Headers */,
     
    1094310954                                7CC99A3618EF7CBC0048C8B4 /* WKScriptMessageInternal.h in Headers */,
    1094410955                                0FCB4E5418BBE044000FCFC9 /* WKScrollView.h in Headers */,
     10956                                0F04159C23C7CC730060A3E2 /* WKScrollViewMac.h in Headers */,
    1094510957                                51CD1C651B34B9D400142CA5 /* WKSecurityOrigin.h in Headers */,
    1094610958                                51CD1C671B34B9DF00142CA5 /* WKSecurityOriginInternal.h in Headers */,
Note: See TracChangeset for help on using the changeset viewer.