Skip to content
Permalink
Browse files
[iOS] Add SPI for internal clients to consult whether or not viewport…
… quirks should be enabled

https://bugs.webkit.org/show_bug.cgi?id=228123
rdar://80397679

Reviewed by Tim Horton.

Add support for an SPI property on WKWebView that indicates whether site-specific quirks should be enabled.
For now, this flag is only updated whenever we commit a mainframe load, which is sufficient for the purposes of
Safari to determine whether or not to use quirked viewport behaviors for tab pill behavior.

If needed in the future, this property should probably:
1. Support KVO, and...
2. Change eagerly when the option is toggled via Web Inspector.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _needsSiteSpecificQuirks]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetStateAfterProcessTermination):

Maintain a corresponding flag on the WebPageProxy in the UI process, which starts out as `true` and is reset
if the web process terminates.

* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebPage.cpp:

Add plumbing to propagate changes in the boolean flag to the UI process.

(WebKit::WebPage::didCommitLoad):

Update the flag on WebPage.

* WebProcess/WebPage/WebPage.h:


Canonical link: https://commits.webkit.org/239833@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280119 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
whsieh committed Jul 21, 2021
1 parent 6f197bb commit 95ac13f3bc02b3c6a9353013a14b13808023dc11
Showing 8 changed files with 61 additions and 0 deletions.
@@ -1,3 +1,40 @@
2021-07-20 Wenson Hsieh <wenson_hsieh@apple.com>

[iOS] Add SPI for internal clients to consult whether or not viewport quirks should be enabled
https://bugs.webkit.org/show_bug.cgi?id=228123
rdar://80397679

Reviewed by Tim Horton.

Add support for an SPI property on WKWebView that indicates whether site-specific quirks should be enabled.
For now, this flag is only updated whenever we commit a mainframe load, which is sufficient for the purposes of
Safari to determine whether or not to use quirked viewport behaviors for tab pill behavior.

If needed in the future, this property should probably:
1. Support KVO, and...
2. Change eagerly when the option is toggled via Web Inspector.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _needsSiteSpecificQuirks]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetStateAfterProcessTermination):

Maintain a corresponding flag on the WebPageProxy in the UI process, which starts out as `true` and is reset
if the web process terminates.

* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebPage.cpp:

Add plumbing to propagate changes in the boolean flag to the UI process.

(WebKit::WebPage::didCommitLoad):

Update the flag on WebPage.

* WebProcess/WebPage/WebPage.h:

2021-07-20 Kyle Piddington <kpiddington@apple.com>

REGRESSION(ANGLE+METAL): WebGL2 content low frame rate
@@ -2518,6 +2518,11 @@ - (BOOL)_userContentExtensionsEnabled
return true;
}

- (BOOL)_needsSiteSpecificQuirks
{
return _page && _page->needsSiteSpecificQuirks();
}

- (pid_t)_webProcessIdentifier
{
if (![self _isValid])
@@ -412,6 +412,8 @@ for this property.
- (void)_suspendPage:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
- (void)_resumePage:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));

@property (nonatomic, readonly) BOOL _needsSiteSpecificQuirks WK_API_AVAILABLE(macos(12.0), ios(15.0));

@end

#if TARGET_OS_IPHONE
@@ -7639,6 +7639,8 @@ void WebPageProxy::resetStateAfterProcessTermination(ProcessTerminationReason re
if (auto* automationSession = process().processPool().automationSession())
automationSession->terminate();
}

m_needsSiteSpecificQuirks = true;
}

void WebPageProxy::provisionalProcessDidTerminate()
@@ -1960,6 +1960,9 @@ class WebPageProxy final : public API::ObjectImpl<API::Object::Type::Page>
WKQuickLookPreviewController *quickLookPreviewController() const { return m_quickLookPreviewController.get(); }
#endif

bool needsSiteSpecificQuirks() const { return m_needsSiteSpecificQuirks; }
void setNeedsSiteSpecificQuirks(bool value) { m_needsSiteSpecificQuirks = value; }

private:
WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&);
void platformInitialize();
@@ -3076,6 +3079,8 @@ class WebPageProxy final : public API::ObjectImpl<API::Object::Type::Page>
#if ENABLE(IMAGE_ANALYSIS) && PLATFORM(MAC)
RetainPtr<WKQuickLookPreviewController> m_quickLookPreviewController;
#endif

bool m_needsSiteSpecificQuirks { true };
};

#ifdef __OBJC__
@@ -413,6 +413,8 @@ messages -> WebPageProxy {
ShowDataDetectorsUIForPositionInformation(struct WebKit::InteractionInformationAtPosition information)
#endif

SetNeedsSiteSpecificQuirks(bool needsSiteSpecificQuirks)

DidChangeInspectorFrontendCount(uint64_t count)

CreateInspectorTarget(String targetId, enum:uint8_t Inspector::InspectorTargetType type)
@@ -6273,6 +6273,12 @@ void WebPage::didCommitLoad(WebFrame* frame)
if (!frame->isMainFrame())
return;

bool needsSiteSpecificQuirks = frame->coreFrame()->settings().needsSiteSpecificQuirks();
if (m_needsSiteSpecificQuirks != needsSiteSpecificQuirks) {
m_needsSiteSpecificQuirks = needsSiteSpecificQuirks;
send(Messages::WebPageProxy::SetNeedsSiteSpecificQuirks(needsSiteSpecificQuirks));
}

if (m_drawingArea)
m_drawingArea->sendEnterAcceleratedCompositingModeIfNeeded();

@@ -2378,6 +2378,8 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP
#if ENABLE(APP_HIGHLIGHTS)
WebCore::HighlightVisibility m_appHighlightsVisible { false };
#endif

bool m_needsSiteSpecificQuirks { true };
};

#if !PLATFORM(IOS_FAMILY)

0 comments on commit 95ac13f

Please sign in to comment.