Skip to content
Permalink
Browse files
Expose a way for MiniBrowser to simulate header and footer banners
https://bugs.webkit.org/show_bug.cgi?id=166005

Reviewed by Wenson Hsieh.

Source/WebKit2:

Expose testing SPI that allows a client to simulate the presence of header
and footer banners. These are simply plumbed through to set FrameView's
m_headerHeight and m_footerHeight.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setHeaderBannerHeightForTesting:]):
(-[WKWebView _setFooterBannerHeightForTesting:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setHeaderBannerHeightForTesting):
(WebKit::WebPageProxy::setFooterBannerHeightForTesting):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setHeaderBannerHeightForTesting):
(WebKit::WebPage::setFooterBannerHeightForTesting):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

Add a MiniBrowser menu item and setting to toggle adding space for header and footer
banners. This only works in WebKit2.

We need to reset these on each navigation, since newly created FrameViews
don't re-fetch the header and footer height stored on Page.

Also fix the signature of webView:didFinishNavigation: to follow API changes,
as well as fixing webViewWebContentProcessDidTerminate:

* MiniBrowser/mac/SettingsController.h:
* MiniBrowser/mac/SettingsController.m:
(-[SettingsController _populateMenu]):
(-[SettingsController validateMenuItem:]):
(-[SettingsController toggleReserveSpaceForBanners:]):
(-[SettingsController isSpaceReservedForBanners]):
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController didChangeSettings]):
(-[WK2BrowserWindowController webView:didFinishNavigation:]):
(-[WK2BrowserWindowController webViewWebContentProcessDidTerminate:]):
(-[WK2BrowserWindowController webView:didFinishLoadingNavigation:]): Deleted.
(-[WK2BrowserWindowController _webViewWebProcessDidCrash:]): Deleted.


Canonical link: https://commits.webkit.org/183605@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209975 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
smfr committed Dec 18, 2016
1 parent cf173d5 commit 92673e1ac3694755617f9dcb4feb18a2c18cdc63
@@ -1,3 +1,28 @@
2016-12-18 Simon Fraser <simon.fraser@apple.com>

Expose a way for MiniBrowser to simulate header and footer banners
https://bugs.webkit.org/show_bug.cgi?id=166005

Reviewed by Wenson Hsieh.

Expose testing SPI that allows a client to simulate the presence of header
and footer banners. These are simply plumbed through to set FrameView's
m_headerHeight and m_footerHeight.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setHeaderBannerHeightForTesting:]):
(-[WKWebView _setFooterBannerHeightForTesting:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setHeaderBannerHeightForTesting):
(WebKit::WebPageProxy::setFooterBannerHeightForTesting):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setHeaderBannerHeightForTesting):
(WebKit::WebPage::setFooterBannerHeightForTesting):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

2016-12-16 Dave Hyatt <hyatt@apple.com>

[CSS Values] Make separate wrapper classes for the deprecated CSS Values OM
@@ -4863,6 +4863,17 @@ - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange
{
[self insertText:string replacementRange:replacementRange];
}

- (void)_setHeaderBannerHeight:(int)height
{
_page->setHeaderBannerHeightForTesting(height);
}

- (void)_setFooterBannerHeight:(int)height
{
_page->setFooterBannerHeightForTesting(height);
}

#endif // PLATFORM(MAC)

- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin
@@ -312,6 +312,9 @@ typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(WK_MAC_TBA));

- (void)_insertText:(id)string replacementRange:(NSRange)replacementRange WK_API_AVAILABLE(macosx(WK_MAC_TBA));

- (void)_setHeaderBannerHeight:(int)height WK_API_AVAILABLE(macosx(WK_MAC_TBA));
- (void)_setFooterBannerHeight:(int)height WK_API_AVAILABLE(macosx(WK_MAC_TBA));
#endif

- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin WK_API_AVAILABLE(ios(WK_IOS_TBA));
@@ -6574,6 +6574,17 @@ void WebPageProxy::didHandleAcceptedCandidate()
{
m_pageClient.didHandleAcceptedCandidate();
}

void WebPageProxy::setHeaderBannerHeightForTesting(int height)
{
m_process->send(Messages::WebPage::SetHeaderBannerHeightForTesting(height), m_pageID);
}

void WebPageProxy::setFooterBannerHeightForTesting(int height)
{
m_process->send(Messages::WebPage::SetFooterBannerHeightForTesting(height), m_pageID);
}

#endif

void WebPageProxy::imageOrMediaDocumentSizeChanged(const WebCore::IntSize& newSize)
@@ -1088,6 +1088,9 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>

void handleAcceptedCandidate(WebCore::TextCheckingResult);
void didHandleAcceptedCandidate();

void setHeaderBannerHeightForTesting(int);
void setFooterBannerHeightForTesting(int);
#endif

#if PLATFORM(EFL) && HAVE(ACCESSIBILITY) && defined(HAVE_ECORE_X)
@@ -1833,6 +1833,21 @@ void WebPage::showPageBanners()
if (m_footerBanner)
m_footerBanner->showIfHidden();
}

void WebPage::setHeaderBannerHeightForTesting(int height)
{
#if ENABLE(RUBBER_BANDING)
corePage()->addHeaderWithHeight(height);
#endif
}

void WebPage::setFooterBannerHeightForTesting(int height)
{
#if ENABLE(RUBBER_BANDING)
corePage()->addFooterWithHeight(height);
#endif
}

#endif // !PLATFORM(IOS)

void WebPage::takeSnapshot(IntRect snapshotRect, IntSize bitmapSize, uint32_t options, uint64_t callbackID)
@@ -475,6 +475,8 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP
void hidePageBanners();
void showPageBanners();

void setHeaderBannerHeightForTesting(int);
void setFooterBannerHeightForTesting(int);
#endif // !PLATFORM(IOS)

WebCore::IntPoint screenToRootView(const WebCore::IntPoint&);
@@ -416,11 +416,16 @@ messages -> WebPage LegacyReceiver {
ImmediateActionDidUpdate()
ImmediateActionDidCancel()
ImmediateActionDidComplete()

DataDetectorsDidPresentUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
DataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
DataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID pageOverlay)

HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate)
RequestActiveNowPlayingSessionInfo()

SetHeaderBannerHeightForTesting(int height);
SetFooterBannerHeightForTesting(int height);
#endif

SetShouldDispatchFakeMouseMoveEvents(bool shouldDispatchFakeMouseMoveEvents)
@@ -1,3 +1,32 @@
2016-12-18 Simon Fraser <simon.fraser@apple.com>

Expose a way for MiniBrowser to simulate header and footer banners
https://bugs.webkit.org/show_bug.cgi?id=166005

Reviewed by Wenson Hsieh.

Add a MiniBrowser menu item and setting to toggle adding space for header and footer
banners. This only works in WebKit2.

We need to reset these on each navigation, since newly created FrameViews
don't re-fetch the header and footer height stored on Page.

Also fix the signature of webView:didFinishNavigation: to follow API changes,
as well as fixing webViewWebContentProcessDidTerminate:

* MiniBrowser/mac/SettingsController.h:
* MiniBrowser/mac/SettingsController.m:
(-[SettingsController _populateMenu]):
(-[SettingsController validateMenuItem:]):
(-[SettingsController toggleReserveSpaceForBanners:]):
(-[SettingsController isSpaceReservedForBanners]):
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController didChangeSettings]):
(-[WK2BrowserWindowController webView:didFinishNavigation:]):
(-[WK2BrowserWindowController webViewWebContentProcessDidTerminate:]):
(-[WK2BrowserWindowController webView:didFinishLoadingNavigation:]): Deleted.
(-[WK2BrowserWindowController _webViewWebProcessDidCrash:]): Deleted.

2016-12-17 Simon Fraser <simon.fraser@apple.com>

Fix iOS test results after r209967.
@@ -40,6 +40,7 @@
@property (nonatomic, readonly) BOOL simpleLineLayoutDebugBordersEnabled;
@property (nonatomic, readonly) BOOL incrementalRenderingSuppressed;
@property (nonatomic, readonly) BOOL tiledScrollingIndicatorVisible;
@property (nonatomic, readonly, getter=isSpaceReservedForBanners) BOOL spaceReservedForBanners;
@property (nonatomic, readonly) BOOL resourceUsageOverlayVisible;
@property (nonatomic, readonly) BOOL nonFastScrollableRegionOverlayVisible;
@property (nonatomic, readonly) BOOL wheelEventHandlerRegionOverlayVisible;
@@ -40,6 +40,8 @@
static NSString * const LayerBordersVisiblePreferenceKey = @"LayerBordersVisible";
static NSString * const SimpleLineLayoutDebugBordersEnabledPreferenceKey = @"SimpleLineLayoutDebugBordersEnabled";
static NSString * const TiledScrollingIndicatorVisiblePreferenceKey = @"TiledScrollingIndicatorVisible";
static NSString * const ReserveSpaceForBannersPreferenceKey = @"ReserveSpaceForBanners";

static NSString * const ResourceUsageOverlayVisiblePreferenceKey = @"ResourceUsageOverlayVisible";
static NSString * const LoadsAllSiteIconsKey = @"LoadsAllSiteIcons";
static NSString * const UsesGameControllerFrameworkKey = @"UsesGameControllerFramework";
@@ -135,6 +137,7 @@ - (void)_populateMenu

[self _addHeaderWithTitle:@"WebKit2-only Settings"];

[self _addItemWithTitle:@"Reserve Space For Banners" action:@selector(toggleReserveSpaceForBanners:) indented:YES];
[self _addItemWithTitle:@"Show Tiled Scrolling Indicator" action:@selector(toggleShowTiledScrollingIndicator:) indented:YES];
[self _addItemWithTitle:@"Use UI-Side Compositing" action:@selector(toggleUseUISideCompositing:) indented:YES];
[self _addItemWithTitle:@"Disable Per-Window Web Processes" action:@selector(togglePerWindowWebProcessesDisabled:) indented:YES];
@@ -213,6 +216,8 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
[menuItem setState:[self animatedImageAsyncDecodingEnabled] ? NSOnState : NSOffState];
else if (action == @selector(toggleVisualViewportEnabled:))
[menuItem setState:[self visualViewportEnabled] ? NSOnState : NSOffState];
else if (action == @selector(toggleReserveSpaceForBanners:))
[menuItem setState:[self isSpaceReservedForBanners] ? NSOnState : NSOffState];
else if (action == @selector(toggleShowTiledScrollingIndicator:))
[menuItem setState:[self tiledScrollingIndicatorVisible] ? NSOnState : NSOffState];
else if (action == @selector(toggleShowResourceUsageOverlay:))
@@ -360,6 +365,11 @@ - (BOOL)displayListDrawingEnabled
return [[NSUserDefaults standardUserDefaults] boolForKey:DisplayListDrawingEnabledPreferenceKey];
}

- (void)toggleReserveSpaceForBanners:(id)sender
{
[self _toggleBooleanDefault:ReserveSpaceForBannersPreferenceKey];
}

- (void)toggleShowTiledScrollingIndicator:(id)sender
{
[self _toggleBooleanDefault:TiledScrollingIndicatorVisiblePreferenceKey];
@@ -400,6 +410,11 @@ - (void)toggleNetworkCacheSpeculativeRevalidationDisabled:(id)sender
[self _toggleBooleanDefault:NetworkCacheSpeculativeRevalidationDisabledKey];
}

- (BOOL)isSpaceReservedForBanners
{
return [[NSUserDefaults standardUserDefaults] boolForKey:ReserveSpaceForBannersPreferenceKey];
}

- (BOOL)tiledScrollingIndicatorVisible
{
return [[NSUserDefaults standardUserDefaults] boolForKey:TiledScrollingIndicatorVisiblePreferenceKey];
@@ -43,6 +43,8 @@
#import <WebKit/_WKUserInitiatedAction.h>

static void* keyValueObservingContext = &keyValueObservingContext;
static const int testHeaderBannerHeight = 42;
static const int testFooterBannerHeight = 58;

@interface WK2BrowserWindowController () <WKNavigationDelegate, WKUIDelegate, _WKIconLoadingDelegate>
@end
@@ -408,6 +410,9 @@ - (void)didChangeSettings
visibleOverlayRegions |= _WKWheelEventHandlerRegion;

preferences._visibleDebugOverlayRegions = visibleOverlayRegions;

[_webView _setHeaderBannerHeight:[settings isSpaceReservedForBanners] ? testHeaderBannerHeight : 0];
[_webView _setFooterBannerHeight:[settings isSpaceReservedForBanners] ? testFooterBannerHeight : 0];
}

- (void)updateTitle:(NSString *)title
@@ -617,9 +622,15 @@ - (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigat
[self updateTitle:nil];
}

- (void)webView:(WKWebView *)webView didFinishLoadingNavigation:(WKNavigation *)navigation
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
LOG(@"didFinishLoadingNavigation: %@", navigation);
LOG(@"didFinishNavigation: %@", navigation);

// Banner heights don't persist across page loads (oddly, since Page stores them), so reset on every page load.
if ([[SettingsController shared] isSpaceReservedForBanners]) {
[_webView _setHeaderBannerHeight:testHeaderBannerHeight];
[_webView _setFooterBannerHeight:testFooterBannerHeight];
}
}

- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *__nullable credential))completionHandler
@@ -633,7 +644,7 @@ - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigatio
LOG(@"didFailNavigation: %@, error %@", navigation, error);
}

- (void)_webViewWebProcessDidCrash:(WKWebView *)webView
- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView
{
NSLog(@"WebContent process crashed; reloading");
[self reload:nil];

0 comments on commit 92673e1

Please sign in to comment.