Title: [134392] trunk/Tools
Revision
134392
Author
[email protected]
Date
2012-11-13 02:53:50 -0800 (Tue, 13 Nov 2012)

Log Message

[chromium] move tracking of damaged regions from WebViewHost to WebTestProxy
https://bugs.webkit.org/show_bug.cgi?id=101927

Reviewed by Adam Barth.

This will allow for sharing the code with content_shell

* DumpRenderTree/chromium/DRTTestRunner.cpp:
(DRTTestRunner::display):
* DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
(WebKit):
(WebTestProxyBase):
(WebTestRunner::WebTestProxy::didInvalidateRect):
(WebTestRunner::WebTestProxy::didScrollRect):
(WebTestRunner::WebTestProxy::scheduleComposite):
(WebTestRunner::WebTestProxy::scheduleAnimation):
(WebTestRunner::WebTestProxy::setWindowRect):
(WebTestRunner::WebTestProxy::show):
(WebTestRunner::WebTestProxy::didAutoResize):
(WebTestRunner::WebTestProxy::postAccessibilityNotification):
* DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
(WebTestRunner::WebTestProxyBase::setPaintRect):
(WebTestRunner):
(WebTestRunner::WebTestProxyBase::paintRect):
(WebTestRunner::WebTestProxyBase::didInvalidateRect):
(WebTestRunner::WebTestProxyBase::didScrollRect):
(WebTestRunner::WebTestProxyBase::scheduleComposite):
(WebTestRunner::WebTestProxyBase::scheduleAnimation):
(WebTestRunner::WebTestProxyBase::show):
(WebTestRunner::WebTestProxyBase::setWindowRect):
(WebTestRunner::WebTestProxyBase::didAutoResize):
(WebTestRunner::WebTestProxyBase::postAccessibilityNotification):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::createNewWindow):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::scheduleAnimation):
(WebViewHost::show):
(WebViewHost::setWindowRect):
(WebViewHost::WebViewHost):
(WebViewHost::proxy):
(WebViewHost::setProxy):
(WebViewHost::reset):
(WebViewHost::paintInvalidatedRegion):
* DumpRenderTree/chromium/WebViewHost.h:
(WebViewHost):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (134391 => 134392)


--- trunk/Tools/ChangeLog	2012-11-13 10:25:21 UTC (rev 134391)
+++ trunk/Tools/ChangeLog	2012-11-13 10:53:50 UTC (rev 134392)
@@ -1,3 +1,51 @@
+2012-11-13  Jochen Eisinger  <[email protected]>
+
+        [chromium] move tracking of damaged regions from WebViewHost to WebTestProxy
+        https://bugs.webkit.org/show_bug.cgi?id=101927
+
+        Reviewed by Adam Barth.
+
+        This will allow for sharing the code with content_shell
+
+        * DumpRenderTree/chromium/DRTTestRunner.cpp:
+        (DRTTestRunner::display):
+        * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
+        (WebKit):
+        (WebTestProxyBase):
+        (WebTestRunner::WebTestProxy::didInvalidateRect):
+        (WebTestRunner::WebTestProxy::didScrollRect):
+        (WebTestRunner::WebTestProxy::scheduleComposite):
+        (WebTestRunner::WebTestProxy::scheduleAnimation):
+        (WebTestRunner::WebTestProxy::setWindowRect):
+        (WebTestRunner::WebTestProxy::show):
+        (WebTestRunner::WebTestProxy::didAutoResize):
+        (WebTestRunner::WebTestProxy::postAccessibilityNotification):
+        * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
+        (WebTestRunner::WebTestProxyBase::setPaintRect):
+        (WebTestRunner):
+        (WebTestRunner::WebTestProxyBase::paintRect):
+        (WebTestRunner::WebTestProxyBase::didInvalidateRect):
+        (WebTestRunner::WebTestProxyBase::didScrollRect):
+        (WebTestRunner::WebTestProxyBase::scheduleComposite):
+        (WebTestRunner::WebTestProxyBase::scheduleAnimation):
+        (WebTestRunner::WebTestProxyBase::show):
+        (WebTestRunner::WebTestProxyBase::setWindowRect):
+        (WebTestRunner::WebTestProxyBase::didAutoResize):
+        (WebTestRunner::WebTestProxyBase::postAccessibilityNotification):
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::createNewWindow):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::scheduleAnimation):
+        (WebViewHost::show):
+        (WebViewHost::setWindowRect):
+        (WebViewHost::WebViewHost):
+        (WebViewHost::proxy):
+        (WebViewHost::setProxy):
+        (WebViewHost::reset):
+        (WebViewHost::paintInvalidatedRegion):
+        * DumpRenderTree/chromium/WebViewHost.h:
+        (WebViewHost):
+
 2012-11-12  Dirk Pranke  <[email protected]>
 
         webkitpy: clean up lint errors, part 1

Modified: trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp (134391 => 134392)


--- trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp	2012-11-13 10:25:21 UTC (rev 134391)
+++ trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp	2012-11-13 10:53:50 UTC (rev 134392)
@@ -1266,7 +1266,7 @@
     WebViewHost* host = m_shell->webViewHost();
     const WebKit::WebSize& size = m_shell->webView()->size();
     WebRect rect(0, 0, size.width, size.height);
-    host->updatePaintRect(rect);
+    host->proxy()->setPaintRect(rect);
     host->paintInvalidatedRegion();
     host->displayRepaintMask();
     result->setNull();

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h (134391 => 134392)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h	2012-11-13 10:25:21 UTC (rev 134391)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h	2012-11-13 10:53:50 UTC (rev 134392)
@@ -31,10 +31,13 @@
 #ifndef WebTestProxy_h
 #define WebTestProxy_h
 
+#include "Platform/chromium/public/WebRect.h"
 #include "WebKit/chromium/public/WebAccessibilityNotification.h"
+#include "WebKit/chromium/public/WebNavigationPolicy.h"
 
 namespace WebKit {
 class WebAccessibilityObject;
+struct WebSize;
 }
 
 namespace WebTestRunner {
@@ -47,15 +50,27 @@
     void setInterfaces(WebTestInterfaces*);
     void setDelegate(WebTestDelegate*);
 
+    void setPaintRect(const WebKit::WebRect&);
+    WebKit::WebRect paintRect() const;
+
 protected:
     WebTestProxyBase();
     ~WebTestProxyBase();
 
-    void doPostAccessibilityNotification(const WebKit::WebAccessibilityObject&, WebKit::WebAccessibilityNotification);
+    void didInvalidateRect(const WebKit::WebRect&);
+    void didScrollRect(int, int, const WebKit::WebRect&);
+    void scheduleComposite();
+    void scheduleAnimation();
+    void setWindowRect(const WebKit::WebRect&);
+    void show(WebKit::WebNavigationPolicy);
+    void didAutoResize(const WebKit::WebSize&);
+    void postAccessibilityNotification(const WebKit::WebAccessibilityObject&, WebKit::WebAccessibilityNotification);
 
 private:
     WebTestInterfaces* m_testInterfaces;
     WebTestDelegate* m_delegate;
+
+    WebKit::WebRect m_paintRect;
 };
 
 // Use this template to inject methods into your WebViewClient implementation
@@ -70,9 +85,44 @@
 
     virtual ~WebTestProxy() { }
 
+    virtual void didInvalidateRect(const WebKit::WebRect& rect)
+    {
+        WebTestProxyBase::didInvalidateRect(rect);
+        WebViewClientImpl::didInvalidateRect(rect);
+    }
+    virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect)
+    {
+        WebTestProxyBase::didScrollRect(dx, dy, clipRect);
+        WebViewClientImpl::didScrollRect(dx, dy, clipRect);
+    }
+    virtual void scheduleComposite()
+    {
+        WebTestProxyBase::scheduleComposite();
+        WebViewClientImpl::scheduleComposite();
+    }
+    virtual void scheduleAnimation()
+    {
+        WebTestProxyBase::scheduleAnimation();
+        WebViewClientImpl::scheduleAnimation();
+    }
+    virtual void setWindowRect(const WebKit::WebRect& rect)
+    {
+        WebTestProxyBase::setWindowRect(rect);
+        WebViewClientImpl::setWindowRect(rect);
+    }
+    virtual void show(WebKit::WebNavigationPolicy policy)
+    {
+        WebTestProxyBase::show(policy);
+        WebViewClientImpl::show(policy);
+    }
+    virtual void didAutoResize(const WebKit::WebSize& newSize)
+    {
+        WebTestProxyBase::didAutoResize(newSize);
+        WebViewClientImpl::didAutoResize(newSize);
+    }
     virtual void postAccessibilityNotification(const WebKit::WebAccessibilityObject& object, WebKit::WebAccessibilityNotification notification)
     {
-        WebTestProxyBase::doPostAccessibilityNotification(object, notification);
+        WebTestProxyBase::postAccessibilityNotification(object, notification);
         WebViewClientImpl::postAccessibilityNotification(object, notification);
     }
 };

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp (134391 => 134392)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp	2012-11-13 10:25:21 UTC (rev 134391)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp	2012-11-13 10:53:50 UTC (rev 134392)
@@ -41,6 +41,7 @@
 #include "platform/WebCString.h"
 
 using namespace WebKit;
+using namespace std;
 
 namespace WebTestRunner {
 
@@ -64,8 +65,64 @@
     m_delegate = delegate;
 }
 
-void WebTestProxyBase::doPostAccessibilityNotification(const WebKit::WebAccessibilityObject& obj, WebKit::WebAccessibilityNotification notification)
+void WebTestProxyBase::setPaintRect(const WebRect& rect)
 {
+    m_paintRect = rect;
+}
+
+WebRect WebTestProxyBase::paintRect() const
+{
+    return m_paintRect;
+}
+
+void WebTestProxyBase::didInvalidateRect(const WebRect& rect)
+{
+    // m_paintRect = m_paintRect U rect
+    if (rect.isEmpty())
+        return;
+    if (m_paintRect.isEmpty()) {
+        m_paintRect = rect;
+        return;
+    }
+    int left = min(m_paintRect.x, rect.x);
+    int top = min(m_paintRect.y, rect.y);
+    int right = max(m_paintRect.x + m_paintRect.width, rect.x + rect.width);
+    int bottom = max(m_paintRect.y + m_paintRect.height, rect.y + rect.height);
+    m_paintRect = WebRect(left, top, right - left, bottom - top);
+}
+
+void WebTestProxyBase::didScrollRect(int, int, const WebRect& clipRect)
+{
+    didInvalidateRect(clipRect);
+}
+
+void WebTestProxyBase::scheduleComposite()
+{
+    m_paintRect = WebRect(0, 0, INT_MAX, INT_MAX);
+}
+
+void WebTestProxyBase::scheduleAnimation()
+{
+    scheduleComposite();
+}
+
+void WebTestProxyBase::show(WebNavigationPolicy)
+{
+    scheduleComposite();
+}
+
+void WebTestProxyBase::setWindowRect(const WebRect& rect)
+{
+    scheduleComposite();
+}
+
+void WebTestProxyBase::didAutoResize(const WebSize&)
+{
+    scheduleComposite();
+}
+
+void WebTestProxyBase::postAccessibilityNotification(const WebKit::WebAccessibilityObject& obj, WebKit::WebAccessibilityNotification notification)
+{
     if (notification == WebKit::WebAccessibilityNotificationFocusedUIElementChanged)
         m_testInterfaces->accessibilityController()->setFocusedElement(obj);
 

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (134391 => 134392)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2012-11-13 10:25:21 UTC (rev 134391)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2012-11-13 10:53:50 UTC (rev 134392)
@@ -757,6 +757,7 @@
         host->setDelegate(m_webViewHost.get());
     else
         host->setDelegate(host);
+    host->setProxy(host);
     WebView* view = WebView::create(host);
     view->setPermissionClient(webPermissions());
     view->setDevToolsAgentClient(devToolsAgent);

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (134391 => 134392)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-11-13 10:25:21 UTC (rev 134391)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-11-13 10:53:50 UTC (rev 134392)
@@ -703,18 +703,6 @@
 
 // WebWidgetClient -----------------------------------------------------------
 
-void WebViewHost::didInvalidateRect(const WebRect& rect)
-{
-    updatePaintRect(rect);
-}
-
-void WebViewHost::didScrollRect(int, int, const WebRect& clipRect)
-{
-    // This is used for optimizing painting when the renderer is scrolled. We're
-    // currently not doing any optimizations so just invalidate the region.
-    didInvalidateRect(clipRect);
-}
-
 void WebViewHost::didAutoResize(const WebSize& newSize)
 {
     // Purposely don't include the virtualWindowBorder in this case so that
@@ -722,27 +710,12 @@
     setWindowRect(WebRect(0, 0, newSize.width, newSize.height));
 }
 
-void WebViewHost::scheduleComposite()
+void WebViewHost::scheduleAnimation()
 {
-    WebSize widgetSize = webWidget()->size();
-    WebRect clientRect(0, 0, widgetSize.width, widgetSize.height);
-    didInvalidateRect(clientRect);
-}
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-void WebViewHost::serviceAnimation()
-{
     if (webView()->settings()->scrollAnimatorEnabled())
         webView()->animate(0.0);
-    scheduleComposite();
 }
 
-void WebViewHost::scheduleAnimation()
-{
-    postDelayedTask(new HostMethodTask(this, &WebViewHost::serviceAnimation), 0);
-}
-#endif
-
 void WebViewHost::didFocus()
 {
     m_shell->setFocus(webWidget(), true);
@@ -828,8 +801,6 @@
 void WebViewHost::show(WebNavigationPolicy)
 {
     m_hasWindow = true;
-    WebSize size = webWidget()->size();
-    updatePaintRect(WebRect(0, 0, size.width, size.height));
 }
 
 
@@ -870,7 +841,6 @@
     int height = m_windowRect.height - border2;
     discardBackingStore();
     webWidget()->resize(WebSize(width, height));
-    updatePaintRect(WebRect(0, 0, width, height));
 }
 
 WebRect WebViewHost::rootWindowRect()
@@ -1430,6 +1400,7 @@
 
 WebViewHost::WebViewHost(TestShell* shell)
     : m_shell(shell)
+    , m_proxy(0)
     , m_webWidget(0)
     , m_lastRequestedTextCheckingCompletion(0)
 {
@@ -1476,6 +1447,19 @@
     return m_webWidget;
 }
 
+WebTestProxyBase* WebViewHost::proxy() const
+{
+    ASSERT(m_proxy);
+    return m_proxy;
+}
+
+void WebViewHost::setProxy(WebTestProxyBase* proxy)
+{
+    ASSERT(!m_proxy);
+    ASSERT(proxy);
+    m_proxy = proxy;
+}
+
 void WebViewHost::reset()
 {
     m_policyDelegateEnabled = false;
@@ -1520,7 +1504,9 @@
 
     m_currentCursor = WebCursorInfo();
     m_windowRect = WebRect();
-    m_paintRect = WebRect();
+    // m_proxy is not set when reset() is invoked from the constructor.
+    if (m_proxy)
+        proxy()->setPaintRect(WebRect());
 
     if (m_webWidget) {
         webView()->mainFrame()->setName(WebString());
@@ -1784,22 +1770,6 @@
 
 // Painting functions ---------------------------------------------------------
 
-void WebViewHost::updatePaintRect(const WebRect& rect)
-{
-    // m_paintRect = m_paintRect U rect
-    if (rect.isEmpty())
-        return;
-    if (m_paintRect.isEmpty()) {
-        m_paintRect = rect;
-        return;
-    }
-    int left = min(m_paintRect.x, rect.x);
-    int top = min(m_paintRect.y, rect.y);
-    int right = max(m_paintRect.x + m_paintRect.width, rect.x + rect.width);
-    int bottom = max(m_paintRect.y + m_paintRect.height, rect.y + rect.height);
-    m_paintRect = WebRect(left, top, right - left, bottom - top);
-}
-
 void WebViewHost::paintRect(const WebRect& rect)
 {
     ASSERT(!m_isPainting);
@@ -1830,23 +1800,22 @@
     // Store the total area painted in total_paint. Then tell the gdk window
     // to update that area after we're done painting it.
     for (int i = 0; i < 3; ++i) {
-        // m_paintRect = intersect(m_paintRect , clientRect)
-        int left = max(m_paintRect.x, clientRect.x);
-        int top = max(m_paintRect.y, clientRect.y);
-        int right = min(m_paintRect.x + m_paintRect.width, clientRect.x + clientRect.width);
-        int bottom = min(m_paintRect.y + m_paintRect.height, clientRect.y + clientRect.height);
-        if (left >= right || top >= bottom)
-            m_paintRect = WebRect();
-        else
-            m_paintRect = WebRect(left, top, right - left, bottom - top);
+        // rect = intersect(proxy()->paintRect() , clientRect)
+        WebRect damageRect = proxy()->paintRect();
+        int left = max(damageRect.x, clientRect.x);
+        int top = max(damageRect.y, clientRect.y);
+        int right = min(damageRect.x + damageRect.width, clientRect.x + clientRect.width);
+        int bottom = min(damageRect.y + damageRect.height, clientRect.y + clientRect.height);
+        WebRect rect;
+        if (left < right && top < bottom)
+            rect = WebRect(left, top, right - left, bottom - top);
 
-        if (m_paintRect.isEmpty())
+        proxy()->setPaintRect(WebRect());
+        if (rect.isEmpty())
             continue;
-        WebRect rect(m_paintRect);
-        m_paintRect = WebRect();
         paintRect(rect);
     }
-    ASSERT(m_paintRect.isEmpty());
+    ASSERT(proxy()->paintRect().isEmpty());
 }
 
 void WebViewHost::paintPagesWithBoundaries()

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (134391 => 134392)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-11-13 10:25:21 UTC (rev 134391)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-11-13 10:53:50 UTC (rev 134392)
@@ -41,6 +41,7 @@
 #include "WebSpellCheckClient.h"
 #include "WebTask.h"
 #include "WebTestDelegate.h"
+#include "WebTestProxy.h"
 #include "WebViewClient.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
@@ -86,6 +87,8 @@
     void setWebWidget(WebKit::WebWidget*);
     WebKit::WebView* webView() const;
     WebKit::WebWidget* webWidget() const;
+    WebTestRunner::WebTestProxyBase* proxy() const;
+    void setProxy(WebTestRunner::WebTestProxyBase*);
     void reset();
     void setSelectTrailingWhitespaceEnabled(bool);
     void setSmartInsertDeleteEnabled(bool);
@@ -99,7 +102,6 @@
     void setDeviceScaleFactor(float);
 
     void paintRect(const WebKit::WebRect&);
-    void updatePaintRect(const WebKit::WebRect&);
     void paintInvalidatedRegion();
     void paintPagesWithBoundaries();
     SkCanvas* canvas();
@@ -205,14 +207,8 @@
     virtual void printPage(WebKit::WebFrame*);
 
     // WebKit::WebWidgetClient
-    virtual void didInvalidateRect(const WebKit::WebRect&);
-    virtual void didScrollRect(int dx, int dy, const WebKit::WebRect&);
     virtual void didAutoResize(const WebKit::WebSize& newSize);
-    virtual void scheduleComposite();
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-    virtual void serviceAnimation();
     virtual void scheduleAnimation();
-#endif
     virtual void didFocus();
     virtual void didBlur();
     virtual void didChangeCursor(const WebKit::WebCursorInfo&);
@@ -369,6 +365,9 @@
     // Non-owning pointer. The WebViewHost instance is owned by this TestShell instance.
     TestShell* m_shell;
 
+    // Non-owning pointer. This class needs to be wrapped in a WebTestProxy. This is the pointer to the WebTestProxyBase.
+    WebTestRunner::WebTestProxyBase* m_proxy;
+
     // This delegate works for the following widget.
     WebKit::WebWidget* m_webWidget;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to