Allow tests to run with a tile cache, and optionally dump the tile cache via layerTre...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Oct 2012 22:22:11 +0000 (22:22 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Oct 2012 22:22:11 +0000 (22:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=100159

Reviewed by Tim Horton.

Source/WebCore:

Add a LAYER_TREE_INCLUDES_PAGE_TILE_CACHE flag for layerTreeAsText(), and plumb it
through to GraphicsLayerCA, which dumps the TiledBacking tile coverage rect.

Test: platform/mac/tiled-drawing/use-tiled-drawing.html

* page/Frame.h:
* platform/graphics/GraphicsLayer.cpp:
(showGraphicsLayerTree):
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::tiledBacking):
* platform/graphics/TiledBacking.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::tiledBacking):
(WebCore::GraphicsLayerCA::dumpAdditionalProperties):
* platform/graphics/ca/GraphicsLayerCA.h:
(GraphicsLayerCA):
* platform/graphics/ca/mac/TileCache.h:
(WebCore::TileCache::tileCoverageRect):
(TileCache):
* platform/graphics/ca/mac/TileCache.mm:
(WebCore::TileCache::computeTileCoverageRect):
(WebCore::TileCache::revalidateTiles):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::layerTreeAsText):
* testing/Internals.cpp:
(WebCore::Internals::layerTreeAsText):
* testing/Internals.h:
* testing/Internals.idl:

Tools:

Make WebKitTestRunner use a WKView with a tile cache for tests run in a directory
whose path includes "tiled-drawing". It does this by passing around a WKDictionary
of options, and if the current PlatformWebView doesn't support those options, it will
create a new one.

* WebKitTestRunner/PlatformWebView.h:
(PlatformWebView): Add a WKDictionaryRef options dictionary argument.
(WTR::PlatformWebView::viewSupportsOptions): Returns true if the view
supports the options in the WKDictionaryRef.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize): Call createWebViewWithOptions() with
no options in the normal case.
(WTR::TestController::createWebViewWithOptions): Moved code into this fuction
so we can call it in two places.
(WTR::TestController::ensureViewSupportsOptions): If the current view
doesn't support the given options, throw it away and makea  new one that does.
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::shouldUseTiledDrawing): Return true if the directory contains "tiled-drawing".
(WTR::updateTiledDrawingForCurrentTest): Tell the TestController to check whether
the view supports the given options. No-op for non-Mac platforms.
(WTR::TestInvocation::invoke): Call updateTiledDrawingForCurrentTest().
* WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
(WTR::PlatformWebView::PlatformWebView): New constructor parameter.
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
(WTR::PlatformWebView::PlatformWebView):  New constructor parameter.
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(-[TestRunnerWKView initWithFrame:contextRef:pageGroupRef:useTiledDrawing:]):
(-[TestRunnerWKView _shouldUseTiledDrawingArea]): Subclass the WKView so we can return
a custom value from this method.
(WTR::PlatformWebView::PlatformWebView):
(WTR::PlatformWebView::viewSupportsOptions):
* WebKitTestRunner/qt/PlatformWebViewQt.cpp:
(WTR::PlatformWebView::PlatformWebView): New constructor parameter.
* WebKitTestRunner/win/PlatformWebViewWin.cpp:
(WTR::PlatformWebView::PlatformWebView): New constructor parameter.

LayoutTests:

A new test that dumps tile cache data for a large page.

* platform/mac/tiled-drawing/use-tiled-drawing-expected.txt: Added.
* platform/mac/tiled-drawing/use-tiled-drawing.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@132276 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/tiled-drawing/use-tiled-drawing-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/use-tiled-drawing.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/Frame.h
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/TiledBacking.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/mac/TileCache.h
Source/WebCore/platform/graphics/ca/mac/TileCache.mm
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Tools/ChangeLog
Tools/WebKitTestRunner/PlatformWebView.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp
Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp
Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm
Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp
Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp

index 3f35812..280277a 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Allow tests to run with a tile cache, and optionally dump the tile cache via layerTreeAsText()
+        https://bugs.webkit.org/show_bug.cgi?id=100159
+
+        Reviewed by Tim Horton.
+
+        A new test that dumps tile cache data for a large page.
+
+        * platform/mac/tiled-drawing/use-tiled-drawing-expected.txt: Added.
+        * platform/mac/tiled-drawing/use-tiled-drawing.html: Added.
+
 2012-10-23  Chris Rogers  <crogers@google.com>
 
         Change setTargetValueAtTime() to setTargetAtTime()
diff --git a/LayoutTests/platform/mac/tiled-drawing/use-tiled-drawing-expected.txt b/LayoutTests/platform/mac/tiled-drawing/use-tiled-drawing-expected.txt
new file mode 100644 (file)
index 0000000..5476e8f
--- /dev/null
@@ -0,0 +1,19 @@
+(GraphicsLayer
+  (bounds 1208.00 2021.00)
+  (visible rect 0.00, 0.00 785.00 x 585.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 1208.00 2021.00)
+      (drawsContent 1)
+      (backgroundColor #FFFFFF)
+      (visible rect 0.00, 0.00 785.00 x 585.00)
+      (tile cache coverage 0, 0 1208 x 1536)
+      (children 1
+        (GraphicsLayer
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/platform/mac/tiled-drawing/use-tiled-drawing.html b/LayoutTests/platform/mac/tiled-drawing/use-tiled-drawing.html
new file mode 100644 (file)
index 0000000..4d1d9f9
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            width: 1200px;
+            height: 2000px;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function doTest()
+        {
+            if (window.internals) {
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document,
+                    internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+            }
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+<pre id="layers">Layer tree goes here</p>
+</body>
+</html>
index 7d2fa64..414193d 100644 (file)
@@ -1,3 +1,39 @@
+2012-10-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Allow tests to run with a tile cache, and optionally dump the tile cache via layerTreeAsText()
+        https://bugs.webkit.org/show_bug.cgi?id=100159
+
+        Reviewed by Tim Horton.
+
+        Add a LAYER_TREE_INCLUDES_PAGE_TILE_CACHE flag for layerTreeAsText(), and plumb it
+        through to GraphicsLayerCA, which dumps the TiledBacking tile coverage rect.
+
+        Test: platform/mac/tiled-drawing/use-tiled-drawing.html
+
+        * page/Frame.h:
+        * platform/graphics/GraphicsLayer.cpp:
+        (showGraphicsLayerTree):
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::tiledBacking):
+        * platform/graphics/TiledBacking.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::tiledBacking):
+        (WebCore::GraphicsLayerCA::dumpAdditionalProperties):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        (GraphicsLayerCA):
+        * platform/graphics/ca/mac/TileCache.h:
+        (WebCore::TileCache::tileCoverageRect):
+        (TileCache):
+        * platform/graphics/ca/mac/TileCache.mm:
+        (WebCore::TileCache::computeTileCoverageRect):
+        (WebCore::TileCache::revalidateTiles):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::layerTreeAsText):
+        * testing/Internals.cpp:
+        (WebCore::Internals::layerTreeAsText):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2012-10-23  No'am Rosenthal  <noam.rosenthal@nokia.com>
 
         Coordinated Graphics: Enable threaded/IPC animations
index 23a59eb..b1a1316 100644 (file)
@@ -78,7 +78,8 @@ namespace WebCore {
 
     enum {
         LayerTreeFlagsIncludeDebugInfo = 1 << 0,
-        LayerTreeFlagsIncludeVisibleRects = 1 << 2
+        LayerTreeFlagsIncludeVisibleRects = 1 << 1,
+        LayerTreeFlagsIncludeTileCaches = 1 << 2
     };
     typedef unsigned LayerTreeFlags;
 
index 3a32b51..c4cc085 100644 (file)
@@ -692,7 +692,7 @@ void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
     if (!layer)
         return;
 
-    String output = layer->layerTreeAsText(LayerTreeAsTextDebug | LayerTreeAsTextIncludeVisibleRects);
+    String output = layer->layerTreeAsText(LayerTreeAsTextDebug | LayerTreeAsTextIncludeVisibleRects | LayerTreeAsTextIncludeTileCaches);
     fprintf(stderr, "%s\n", output.utf8().data());
 }
 #endif
index e67a17e..50893cd 100644 (file)
@@ -48,6 +48,7 @@ enum LayerTreeAsTextBehaviorFlags {
     LayerTreeAsTextBehaviorNormal = 0,
     LayerTreeAsTextDebug = 1 << 0, // Dump extra debugging info like layer addresses.
     LayerTreeAsTextIncludeVisibleRects = 1 << 1,
+    LayerTreeAsTextIncludeTileCaches = 1 << 2
 };
 typedef unsigned LayerTreeAsTextBehavior;
 
@@ -401,7 +402,7 @@ public:
 
     bool usingTiledLayer() const { return m_usingTiledLayer; }
 
-    virtual TiledBacking* tiledBacking() { return 0; }
+    virtual TiledBacking* tiledBacking() const { return 0; }
 
 #if PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
     // This allows several alternative GraphicsLayer implementations in the same port,
index 4108f12..8c81cc9 100644 (file)
@@ -54,6 +54,10 @@ public:
 
     virtual void setScrollingPerformanceLoggingEnabled(bool) = 0;
     virtual bool scrollingPerformanceLoggingEnabled() const = 0;
+    
+    // Exposed for testing
+    virtual IntRect tileCoverageRect() const = 0;
+
 };
 
 } // namespace WebCore
index a74bb1c..6ee9c02 100644 (file)
@@ -910,7 +910,7 @@ void GraphicsLayerCA::flushCompositingStateForThisLayerOnly()
     commitLayerChangesAfterSublayers();
 }
 
-TiledBacking* GraphicsLayerCA::tiledBacking()
+TiledBacking* GraphicsLayerCA::tiledBacking() const
 {
     return m_layer->tiledBacking();
 }
@@ -2522,6 +2522,12 @@ void GraphicsLayerCA::dumpAdditionalProperties(TextStream& textStream, int inden
         writeIndent(textStream, indent + 1);
         textStream << "(visible rect " << m_visibleRect.x() << ", " << m_visibleRect.y() << " " << m_visibleRect.width() << " x " << m_visibleRect.height() << ")\n";
     }
+
+    if (tiledBacking() && (behavior & LayerTreeAsTextIncludeTileCaches)) {
+        writeIndent(textStream, indent + 1);
+        IntRect tileCoverageRect = tiledBacking()->tileCoverageRect();
+        textStream << "(tile cache coverage " << tileCoverageRect.x() << ", " << tileCoverageRect.y() << " " << tileCoverageRect.width() << " x " << tileCoverageRect.height() << ")\n";
+    }
 }
 
 void GraphicsLayerCA::setDebugBorder(const Color& color, float borderWidth)
index c6b210e..00ca62e 100644 (file)
@@ -134,7 +134,7 @@ public:
     virtual void flushCompositingState(const FloatRect&);
     virtual void flushCompositingStateForThisLayerOnly();
 
-    virtual TiledBacking* tiledBacking() OVERRIDE;
+    virtual TiledBacking* tiledBacking() const OVERRIDE;
 
     bool allowTiledLayer() const { return m_allowTiledLayer; }
     virtual void setAllowTiledLayer(bool b);
index 17e98ee..a03d6d8 100644 (file)
@@ -89,6 +89,8 @@ private:
     virtual void forceRepaint() OVERRIDE;
     virtual void setScrollingPerformanceLoggingEnabled(bool flag) OVERRIDE { m_scrollingPerformanceLoggingEnabled = flag; }
     virtual bool scrollingPerformanceLoggingEnabled() const OVERRIDE { return m_scrollingPerformanceLoggingEnabled; }
+
+    virtual IntRect tileCoverageRect() const { return m_tileCoverageRect; }
     
     IntRect bounds() const;
 
@@ -96,7 +98,7 @@ private:
     IntRect rectForTileIndex(const TileIndex&) const;
     void getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight);
 
-    IntRect tileCoverageRect() const;
+    IntRect computeTileCoverageRect() const;
 
     void scheduleTileRevalidation(double interval);
     void tileRevalidationTimerFired(Timer<TileCache>*);
index 619244d..8aaf87d 100644 (file)
@@ -304,7 +304,7 @@ void TileCache::getTileIndexRangeForRect(const IntRect& rect, TileIndex& topLeft
     bottomRight.setY(max(clampedRect.maxY() / m_tileSize.height(), 0));
 }
 
-IntRect TileCache::tileCoverageRect() const
+IntRect TileCache::computeTileCoverageRect() const
 {
     IntRect tileCoverageRect = m_visibleRect;
 
@@ -377,7 +377,7 @@ void TileCache::revalidateTiles()
     if (m_visibleRect.isEmpty() || bounds().isEmpty())
         return;
 
-    IntRect tileCoverageRect = this->tileCoverageRect();
+    IntRect tileCoverageRect = computeTileCoverageRect();
 
     Vector<TileIndex> tilesToRemove;
 
index 55664c2..eef1ef4 100644 (file)
@@ -1137,7 +1137,9 @@ String RenderLayerCompositor::layerTreeAsText(LayerTreeFlags flags)
         layerTreeBehavior |= LayerTreeAsTextDebug;
     if (flags & LayerTreeFlagsIncludeVisibleRects)
         layerTreeBehavior |= LayerTreeAsTextIncludeVisibleRects;
-    
+    if (flags & LayerTreeFlagsIncludeTileCaches)
+        layerTreeBehavior |= LayerTreeAsTextIncludeTileCaches;
+
     // We skip dumping the scroll and clip layers to keep layerTreeAsText output
     // similar between platforms.
     return m_rootContentLayer->layerTreeAsText(layerTreeBehavior);
index c26d6ea..9496c22 100644 (file)
@@ -1237,6 +1237,8 @@ String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionC
     LayerTreeFlags layerTreeFlags = 0;
     if (flags & LAYER_TREE_INCLUDES_VISIBLE_RECTS)
         layerTreeFlags |= LayerTreeFlagsIncludeVisibleRects;
+    if (flags & LAYER_TREE_INCLUDES_TILE_CACHES)
+        layerTreeFlags |= LayerTreeFlagsIncludeTileCaches;
 
     return document->frame()->layerTreeAsText(layerTreeFlags);
 }
index bbc5c5b..569ce29 100644 (file)
@@ -188,7 +188,10 @@ public:
     void resumeAnimations(Document*, ExceptionCode&) const;
 
     enum {
-        LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1 // Values need to kept in sync with Internals.idl.
+        // Values need to be kept in sync with Internals.idl.
+        LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
+        LAYER_TREE_INCLUDES_TILE_CACHES = 2
+        
     };
     String layerTreeAsText(Document*, unsigned flags, ExceptionCode&) const;
     String layerTreeAsText(Document*, ExceptionCode&) const;
index 77ba660..2e09375 100644 (file)
 
     // Flags for layerTreeAsText.
     const unsigned short LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1;
+    const unsigned short LAYER_TREE_INCLUDES_TILE_CACHES = 2;
     DOMString layerTreeAsText(in Document document, in [Optional] unsigned short flags) raises (DOMException);
 
     void garbageCollectDocumentResources(in Document document) raises (DOMException);
index 7b33f2d..a98e206 100644 (file)
@@ -1,3 +1,47 @@
+2012-10-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Allow tests to run with a tile cache, and optionally dump the tile cache via layerTreeAsText()
+        https://bugs.webkit.org/show_bug.cgi?id=100159
+
+        Reviewed by Tim Horton.
+
+        Make WebKitTestRunner use a WKView with a tile cache for tests run in a directory
+        whose path includes "tiled-drawing". It does this by passing around a WKDictionary 
+        of options, and if the current PlatformWebView doesn't support those options, it will
+        create a new one.
+
+        * WebKitTestRunner/PlatformWebView.h:
+        (PlatformWebView): Add a WKDictionaryRef options dictionary argument.
+        (WTR::PlatformWebView::viewSupportsOptions): Returns true if the view
+        supports the options in the WKDictionaryRef.
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::initialize): Call createWebViewWithOptions() with
+        no options in the normal case.
+        (WTR::TestController::createWebViewWithOptions): Moved code into this fuction
+        so we can call it in two places.
+        (WTR::TestController::ensureViewSupportsOptions): If the current view
+        doesn't support the given options, throw it away and makea  new one that does.
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::shouldUseTiledDrawing): Return true if the directory contains "tiled-drawing".
+        (WTR::updateTiledDrawingForCurrentTest): Tell the TestController to check whether
+        the view supports the given options. No-op for non-Mac platforms.
+        (WTR::TestInvocation::invoke): Call updateTiledDrawingForCurrentTest().
+        * WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
+        (WTR::PlatformWebView::PlatformWebView): New constructor parameter.
+        * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
+        (WTR::PlatformWebView::PlatformWebView):  New constructor parameter.
+        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+        (-[TestRunnerWKView initWithFrame:contextRef:pageGroupRef:useTiledDrawing:]):
+        (-[TestRunnerWKView _shouldUseTiledDrawingArea]): Subclass the WKView so we can return
+        a custom value from this method.
+        (WTR::PlatformWebView::PlatformWebView):
+        (WTR::PlatformWebView::viewSupportsOptions):
+        * WebKitTestRunner/qt/PlatformWebViewQt.cpp:
+        (WTR::PlatformWebView::PlatformWebView): New constructor parameter.
+        * WebKitTestRunner/win/PlatformWebViewWin.cpp:
+        (WTR::PlatformWebView::PlatformWebView): New constructor parameter.
+
 2012-10-23  David Barton  <dbarton@mathscribe.com>
 
         [MathML] Symbol font uses greek letters for roman ones on linux and Windows
index 13859e1..60d2fc1 100644 (file)
@@ -64,7 +64,7 @@ namespace WTR {
 
 class PlatformWebView {
 public:
-    PlatformWebView(WKContextRef, WKPageGroupRef);
+    PlatformWebView(WKContextRef, WKPageGroupRef, WKDictionaryRef options = 0);
     ~PlatformWebView();
 
     WKPageRef page();
@@ -88,7 +88,13 @@ public:
     void makeWebViewFirstResponder();
     void setWindowIsKey(bool isKey) { m_windowIsKey = isKey; }
     bool windowIsKey() const { return m_windowIsKey; }
-    
+
+#if PLATFORM(MAC)
+    bool viewSupportsOptions(WKDictionaryRef) const;
+#else
+    bool viewSupportsOptions(WKDictionaryRef) const { return true; }
+#endif
+
     WKRetainPtr<WKImageRef> windowSnapshotImage();
 
 private:
index e9ef047..047f5a1 100644 (file)
@@ -343,8 +343,12 @@ void TestController::initialize(int argc, const char* argv[])
     if (testPluginDirectory())
         WKContextSetAdditionalPluginsDirectory(m_context.get(), testPluginDirectory());
 
-    m_mainWebView = adoptPtr(new PlatformWebView(m_context.get(), m_pageGroup.get()));
+    createWebViewWithOptions(0);
+}
 
+void TestController::createWebViewWithOptions(WKDictionaryRef options)
+{
+    m_mainWebView = adoptPtr(new PlatformWebView(m_context.get(), m_pageGroup.get(), options));
     WKPageUIClient pageUIClient = {
         kWKPageUIClientCurrentVersion,
         m_mainWebView.get(),
@@ -446,6 +450,21 @@ void TestController::initialize(int argc, const char* argv[])
     WKPageSetPagePolicyClient(m_mainWebView->page(), &pagePolicyClient);
 }
 
+void TestController::ensureViewSupportsOptions(WKDictionaryRef options)
+{
+    if (m_mainWebView && !m_mainWebView->viewSupportsOptions(options)) {
+        WKPageSetPageUIClient(m_mainWebView->page(), 0);
+        WKPageSetPageLoaderClient(m_mainWebView->page(), 0);
+        WKPageSetPagePolicyClient(m_mainWebView->page(), 0);
+        WKPageClose(m_mainWebView->page());
+        
+        m_mainWebView = nullptr;
+
+        createWebViewWithOptions(options);
+        resetStateToConsistentValues();
+    }
+}
+
 bool TestController::resetStateToConsistentValues()
 {
     m_state = Resetting;
index 7081acd..6a994a4 100644 (file)
@@ -57,6 +57,8 @@ public:
     PlatformWebView* mainWebView() { return m_mainWebView.get(); }
     WKContextRef context() { return m_context.get(); }
 
+    void ensureViewSupportsOptions(WKDictionaryRef options);
+    
     // Runs the run loop until `done` is true or the timeout elapses.
     enum TimeoutDuration { ShortTimeout, LongTimeout, NoTimeout };
     bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; }
@@ -83,6 +85,7 @@ public:
 
 private:
     void initialize(int argc, const char* argv[]);
+    void createWebViewWithOptions(WKDictionaryRef);
     void run();
 
     void runTestingServerLoop();
index 7b43f7b..9861d8b 100644 (file)
@@ -143,9 +143,31 @@ static bool shouldOpenWebInspector(const char* pathOrURL)
 }
 #endif
 
+#if PLATFORM(MAC)
+static bool shouldUseTiledDrawing(const char* pathOrURL)
+{
+    return strstr(pathOrURL, "tiled-drawing/") || strstr(pathOrURL, "tiled-drawing\\");
+}
+#endif
+
+static void updateTiledDrawingForCurrentTest(const char* pathOrURL)
+{
+#if PLATFORM(MAC)
+    WKRetainPtr<WKMutableDictionaryRef> viewOptions = adoptWK(WKMutableDictionaryCreate());
+    WKRetainPtr<WKStringRef> useTiledDrawingKey = adoptWK(WKStringCreateWithUTF8CString("TiledDrawing"));
+    WKRetainPtr<WKBooleanRef> useTiledDrawingValue = adoptWK(WKBooleanCreate(shouldUseTiledDrawing(pathOrURL)));
+    WKDictionaryAddItem(viewOptions.get(), useTiledDrawingKey.get(), useTiledDrawingValue.get());
+
+    TestController::shared().ensureViewSupportsOptions(viewOptions.get());
+#else
+    UNUSED_PARAM(pathOrURL);
+#endif
+}
+
 void TestInvocation::invoke()
 {
     sizeWebViewForCurrentTest(m_pathOrURL.c_str());
+    updateTiledDrawingForCurrentTest(m_pathOrURL.c_str());
 
     WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest"));
     WKRetainPtr<WKMutableDictionaryRef> beginTestMessageBody = adoptWK(WKMutableDictionaryCreate());
index 06187a0..d64be5e 100644 (file)
@@ -40,7 +40,7 @@ static Ecore_Evas* initEcoreEvas()
     return ecoreEvas;
 }
 
-PlatformWebView::PlatformWebView(WKContextRef context, WKPageGroupRef pageGroup)
+PlatformWebView::PlatformWebView(WKContextRef context, WKPageGroupRef pageGroup, WKDictionaryRef /*options*/)
 {
     m_window = initEcoreEvas();
     Evas* evas = ecore_evas_get(m_window);
index f1615d4..bbef04e 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace WTR {
 
-PlatformWebView::PlatformWebView(WKContextRef context, WKPageGroupRef pageGroup)
+PlatformWebView::PlatformWebView(WKContextRef context, WKPageGroupRef pageGroup, WKDictionaryRef /*options*/)
     : m_view(WKViewCreate(context, pageGroup))
     , m_window(gtk_window_new(GTK_WINDOW_POPUP))
     , m_windowIsKey(true)
index db5d119..4c7b15f 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "PlatformWebView.h"
+#include "TestController.h"
 
 #import <WebKit2/WKImageCG.h>
 #import <WebKit2/WKViewPrivate.h>
 @property (nonatomic, assign) WTR::PlatformWebView* platformWebView;
 @end
 
+@interface TestRunnerWKView : WKView {
+    BOOL _useTiledDrawing;
+}
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)context pageGroupRef:(WKPageGroupRef)pageGroup useTiledDrawing:(BOOL)useTiledDrawing;
+
+@property (nonatomic, assign) BOOL useTiledDrawing;
+@end
+
+@implementation TestRunnerWKView
+
+@synthesize useTiledDrawing = _useTiledDrawing;
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)context pageGroupRef:(WKPageGroupRef)pageGroup useTiledDrawing:(BOOL)useTiledDrawing
+{
+    _useTiledDrawing = useTiledDrawing;
+    return [super initWithFrame:frame contextRef:context pageGroupRef:pageGroup];
+}
+
+- (BOOL)_shouldUseTiledDrawingArea
+{
+    return _useTiledDrawing;
+}
+
+@end
+
 @implementation WebKitTestRunnerWindow
 @synthesize platformWebView = _platformWebView;
 
 
 namespace WTR {
 
-PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, WKDictionaryRef options)
     : m_windowIsKey(true)
 {
+    WKRetainPtr<WKStringRef> useTiledDrawingKey(AdoptWK, WKStringCreateWithUTF8CString("TiledDrawing"));
+    bool useTiledDrawing = options ? WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(options, useTiledDrawingKey.get()))) : false;
+
     NSRect rect = NSMakeRect(0, 0, 800, 600);
-    m_view = [[WKView alloc] initWithFrame:rect contextRef:contextRef pageGroupRef:pageGroupRef];
+    m_view = [[TestRunnerWKView alloc] initWithFrame:rect contextRef:contextRef pageGroupRef:pageGroupRef useTiledDrawing:useTiledDrawing];
 
     NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
     m_window = [[WebKitTestRunnerWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
@@ -168,4 +198,12 @@ WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
     return adoptWK(WKImageCreateFromCGImage(windowSnapshotImage.get(), 0));
 }
 
+bool PlatformWebView::viewSupportsOptions(WKDictionaryRef options) const
+{
+    WKRetainPtr<WKStringRef> useTiledDrawingKey(AdoptWK, WKStringCreateWithUTF8CString("TiledDrawing"));
+    bool useTiledDrawing = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(options, useTiledDrawingKey.get())));
+
+    return useTiledDrawing == [(TestRunnerWKView *)m_view useTiledDrawing];
+}
+
 } // namespace WTR
index 00177db..58c06cc 100644 (file)
@@ -79,7 +79,7 @@ private:
     QQuickWebView* m_view;
 };
 
-PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, WKDictionaryRef /*options*/)
     : m_view(new QQuickWebView(contextRef, pageGroupRef))
     , m_window(new WrapperWindow(m_view))
     , m_windowIsKey(true)
index 2fbcef9..91a03d2 100644 (file)
@@ -48,7 +48,7 @@ static void registerWindowClass()
     RegisterClassExW(&wndClass);
 }
 
-PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, WKDictionaryRef /*options*/)
     : m_windowIsKey(true)
 {
     registerWindowClass();