Skip to content
Permalink
Browse files
Simplify how PlatformWebViews are created when view options change
https://bugs.webkit.org/show_bug.cgi?id=148093

Reviewed by Sam Weinig.

Instead of letting each port dictate when the PlatformWebView should be recreated we now do the following:

TestController::ensureViewSupportsOptionsForTest gets the view options for a test by calling
TestController::viewOptionsForTest, which returns a filled in ViewOptions struct for a given test. It also allows
ports to add/override settings by calling TestController::updatePlatformSpecificViewOptionsForTest.

If the current PlatformWebView doesn't support the given view options, delete the web view and create a new one.

Also, get rid of the first call to TestController::createWebViewWithOptions in TestController::initialize and
always rely on TestController::ensureViewSupportsOptionsForTest creating a PlatformWebView for us.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::ensureViewSupportsOptionsForTest):
(WTR::shouldUseFixedLayout):
(WTR::TestController::viewOptionsForTest):
(WTR::TestController::updateWebViewSizeForTest):
(WTR::TestController::updateWindowScaleForTest):
(WTR::TestController::configureViewForTest):
(WTR::TestController::initialize): Deleted.
(WTR::TestController::ensureViewSupportsOptions): Deleted.
(WTR::TestController::updateLayoutTypeForTest): Deleted.
(WTR::TestController::platformConfigureViewForTest): Deleted.
(WTR::TestController::platformResetPreferencesToConsistentValues): Deleted.
(WTR::TestController::run): Deleted.
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/efl/TestControllerEfl.cpp:
(WTR::shouldUseFixedLayout):
(WTR::TestController::updatePlatformSpecificViewOptionsForTest):
(WTR::TestController::platformConfigureViewForTest):
(WTR::TestController::platformResetPreferencesToConsistentValues):
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::updatePlatformSpecificViewOptionsForTest):
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::updatePlatformSpecificViewOptionsForTest):
(WTR::TestController::platformConfigureViewForTest):

Canonical link: https://commits.webkit.org/166210@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188548 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Aug 17, 2015
1 parent d889524 commit 33fb7e3de1baa62dfeed586331cb7e35ae6c038e
Showing 6 changed files with 116 additions and 62 deletions.
@@ -1,3 +1,46 @@
2015-08-17 Anders Carlsson <andersca@apple.com>

Simplify how PlatformWebViews are created when view options change
https://bugs.webkit.org/show_bug.cgi?id=148093

Reviewed by Sam Weinig.

Instead of letting each port dictate when the PlatformWebView should be recreated we now do the following:

TestController::ensureViewSupportsOptionsForTest gets the view options for a test by calling
TestController::viewOptionsForTest, which returns a filled in ViewOptions struct for a given test. It also allows
ports to add/override settings by calling TestController::updatePlatformSpecificViewOptionsForTest.

If the current PlatformWebView doesn't support the given view options, delete the web view and create a new one.

Also, get rid of the first call to TestController::createWebViewWithOptions in TestController::initialize and
always rely on TestController::ensureViewSupportsOptionsForTest creating a PlatformWebView for us.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::ensureViewSupportsOptionsForTest):
(WTR::shouldUseFixedLayout):
(WTR::TestController::viewOptionsForTest):
(WTR::TestController::updateWebViewSizeForTest):
(WTR::TestController::updateWindowScaleForTest):
(WTR::TestController::configureViewForTest):
(WTR::TestController::initialize): Deleted.
(WTR::TestController::ensureViewSupportsOptions): Deleted.
(WTR::TestController::updateLayoutTypeForTest): Deleted.
(WTR::TestController::platformConfigureViewForTest): Deleted.
(WTR::TestController::platformResetPreferencesToConsistentValues): Deleted.
(WTR::TestController::run): Deleted.
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/efl/TestControllerEfl.cpp:
(WTR::shouldUseFixedLayout):
(WTR::TestController::updatePlatformSpecificViewOptionsForTest):
(WTR::TestController::platformConfigureViewForTest):
(WTR::TestController::platformResetPreferencesToConsistentValues):
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::updatePlatformSpecificViewOptionsForTest):
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::updatePlatformSpecificViewOptionsForTest):
(WTR::TestController::platformConfigureViewForTest):

2015-08-17 Sam Weinig <sam@webkit.org>

API::PageConfiguration's sessionID needs to be set whenever the API::WebsiteDataStore is set
@@ -432,12 +432,6 @@ void TestController::initialize(int argc, const char* argv[])

// Some preferences (notably mock scroll bars setting) currently cannot be re-applied to an existing view, so we need to set them now.
resetPreferencesToConsistentValues();

ViewOptions viewOptions;
viewOptions.useRemoteLayerTree = m_shouldUseRemoteLayerTree;
viewOptions.shouldShowWebView = m_shouldShowWebView;

createWebViewWithOptions(viewOptions);
}

void TestController::createWebViewWithOptions(const ViewOptions& options)
@@ -543,18 +537,25 @@ void TestController::createWebViewWithOptions(const ViewOptions& options)
m_mainWebView->changeWindowScaleIfNeeded(1);
}

void TestController::ensureViewSupportsOptions(const ViewOptions& options)
void TestController::ensureViewSupportsOptionsForTest(const TestInvocation& test)
{
if (m_mainWebView && !m_mainWebView->viewSupportsOptions(options)) {
WKPageSetPageUIClient(m_mainWebView->page(), 0);
WKPageSetPageNavigationClient(m_mainWebView->page(), 0);
auto viewOptions = viewOptionsForTest(test);

if (m_mainWebView) {
if (m_mainWebView->viewSupportsOptions(viewOptions))
return;

WKPageSetPageUIClient(m_mainWebView->page(), nullptr);
WKPageSetPageNavigationClient(m_mainWebView->page(), nullptr);
WKPageClose(m_mainWebView->page());

m_mainWebView = nullptr;

createWebViewWithOptions(options);
resetStateToConsistentValues();
m_mainWebView = nullptr;
}

createWebViewWithOptions(viewOptions);

if (!resetStateToConsistentValues())
TestInvocation::dumpWebProcessUnresponsiveness("<unknown> - TestController::run - Failed to reset state to consistent values\n");
}

void TestController::resetPreferencesToConsistentValues()
@@ -747,67 +748,54 @@ const char* TestController::networkProcessName()
#endif
}

void TestController::updateWebViewSizeForTest(const TestInvocation& test)
{
bool isSVGW3CTest = test.urlContains("svg/W3C-SVG-1.1") || test.urlContains("svg\\W3C-SVG-1.1");

unsigned width = viewWidth;
unsigned height = viewHeight;
if (isSVGW3CTest) {
width = w3cSVGViewWidth;
height = w3cSVGViewHeight;
}

mainWebView()->resizeTo(width, height);
}

void TestController::updateWindowScaleForTest(PlatformWebView* view, const TestInvocation& test)
{
bool needsHighDPIWindow = test.urlContains("/hidpi-");
view->changeWindowScaleIfNeeded(needsHighDPIWindow ? 2 : 1);
}

// FIXME: move into relevant platformConfigureViewForTest()?
static bool shouldUseFixedLayout(const TestInvocation& test)
{
#if ENABLE(CSS_DEVICE_ADAPTATION)
if (test.urlContains("device-adapt/") || test.urlContains("device-adapt\\"))
return true;
if (test.urlContains("device-adapt/") || test.urlContains("device-adapt\\"))
return true;
#endif

#if USE(COORDINATED_GRAPHICS) && PLATFORM(EFL)
if (test.urlContains("sticky/") || test.urlContains("sticky\\"))
return true;
#endif
return false;

UNUSED_PARAM(test);
}

void TestController::updateLayoutTypeForTest(const TestInvocation& test)
ViewOptions TestController::viewOptionsForTest(const TestInvocation& test) const
{
ViewOptions viewOptions;

viewOptions.useRemoteLayerTree = m_shouldUseRemoteLayerTree;
viewOptions.shouldShowWebView = m_shouldShowWebView;
viewOptions.useFixedLayout = shouldUseFixedLayout(test);

ensureViewSupportsOptions(viewOptions);
updatePlatformSpecificViewOptionsForTest(viewOptions, test);

return viewOptions;
}

#if !PLATFORM(COCOA) && !PLATFORM(GTK)
void TestController::platformConfigureViewForTest(const TestInvocation&)
void TestController::updateWebViewSizeForTest(const TestInvocation& test)
{
bool isSVGW3CTest = test.urlContains("svg/W3C-SVG-1.1") || test.urlContains("svg\\W3C-SVG-1.1");

unsigned width = viewWidth;
unsigned height = viewHeight;
if (isSVGW3CTest) {
width = w3cSVGViewWidth;
height = w3cSVGViewHeight;
}

mainWebView()->resizeTo(width, height);
}

void TestController::platformResetPreferencesToConsistentValues()
void TestController::updateWindowScaleForTest(PlatformWebView* view, const TestInvocation& test)
{
bool needsHighDPIWindow = test.urlContains("/hidpi-");
view->changeWindowScaleIfNeeded(needsHighDPIWindow ? 2 : 1);
}
#endif

void TestController::configureViewForTest(const TestInvocation& test)
{
ensureViewSupportsOptionsForTest(test);
updateWebViewSizeForTest(test);
updateWindowScaleForTest(mainWebView(), test);
updateLayoutTypeForTest(test);

platformConfigureViewForTest(test);
}
@@ -935,11 +923,6 @@ void TestController::runTestingServerLoop()

void TestController::run()
{
if (!resetStateToConsistentValues()) {
TestInvocation::dumpWebProcessUnresponsiveness("<unknown> - TestController::run - Failed to reset state to consistent values\n");
return;
}

if (m_usingServerMode)
runTestingServerLoop();
else {
@@ -68,7 +68,6 @@ class TestController {

EventSenderProxy* eventSenderProxy() { return m_eventSenderProxy.get(); }

void ensureViewSupportsOptions(const ViewOptions&);
bool shouldUseRemoteLayerTree() const { return m_shouldUseRemoteLayerTree; }

// Runs the run loop until `done` is true or the timeout elapses.
@@ -142,9 +141,12 @@ class TestController {
void initializeInjectedBundlePath();
void initializeTestPluginDirectory();

void ensureViewSupportsOptionsForTest(const TestInvocation&);
ViewOptions viewOptionsForTest(const TestInvocation&) const;
void updatePlatformSpecificViewOptionsForTest(ViewOptions&, const TestInvocation&) const;

void updateWebViewSizeForTest(const TestInvocation&);
void updateWindowScaleForTest(PlatformWebView*, const TestInvocation&);
void updateLayoutTypeForTest(const TestInvocation&);

void decidePolicyForGeolocationPermissionRequestIfPossible();
void decidePolicyForUserMediaPermissionRequestIfPossible();
@@ -21,6 +21,7 @@
#include "TestController.h"

#include "PlatformWebView.h"
#include "TestInvocation.h"
#include <Ecore.h>
#include <Evas.h>
#include <stdio.h>
@@ -132,4 +133,26 @@ const char* TestController::platformLibraryPathForTesting()
return 0;
}

static bool shouldUseFixedLayout(const TestInvocation& test)
{
#if USE(COORDINATED_GRAPHICS)
if (test.urlContains("sticky/") || test.urlContains("sticky\\"))
return true;
#endif
return false;
}

void TestController::updatePlatformSpecificViewOptionsForTest(ViewOptions& viewOptions, const TestInvocation& test) const
{
viewOptions.useFixedLayout = shouldUseFixedLayout(test);
}

void TestController::platformConfigureViewForTest(const TestInvocation&)
{
}

void TestController::platformResetPreferencesToConsistentValues()
{
}

} // namespace WTR
@@ -98,6 +98,10 @@ static bool shouldMakeViewportFlexible(const TestInvocation& test)
}
}

void TestController::updatePlatformSpecificViewOptionsForTest(ViewOptions&, const TestInvocation&) const
{
}

void TestController::platformRunUntil(bool& done, double timeout)
{
NSDate *endDate = (timeout > 0) ? [NSDate dateWithTimeIntervalSinceNow:timeout] : [NSDate distantFuture];
@@ -96,16 +96,15 @@ static bool shouldUseThreadedScrolling(const TestInvocation& test)
#endif
}

void TestController::platformConfigureViewForTest(const TestInvocation& test)
void TestController::updatePlatformSpecificViewOptionsForTest(ViewOptions& viewOptions, const TestInvocation& test) const
{
ViewOptions viewOptions;

viewOptions.useThreadedScrolling = shouldUseThreadedScrolling(test);
viewOptions.useRemoteLayerTree = shouldUseRemoteLayerTree();
viewOptions.shouldShowWebView = shouldShowWebView();
}

ensureViewSupportsOptions(viewOptions);

void TestController::platformConfigureViewForTest(const TestInvocation& test)
{
#if WK_API_ENABLED
if (!test.urlContains("contentextensions/"))
return;

0 comments on commit 33fb7e3

Please sign in to comment.