[chromium] Add the ability to turn off autoresize.
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Mar 2012 01:29:56 +0000 (01:29 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Mar 2012 01:29:56 +0000 (01:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77452

Reviewed by Darin Fisher.

Source/WebCore:

Test: fast/autoresize/turn-off-autoresize.html

* page/FrameView.cpp:
(WebCore::FrameView::enableAutoSizeMode): Fix the code
path for turning off autoresize to set the scrollbars to auto.

Source/WebKit/chromium:

* public/WebView.h:
(WebKit::WebViewImpl::enableAutoResizeMode): Cleaned up the api.
(WebKit::WebViewImpl::disableAutoResizeMode): Added the ability to disable auto-resize.
(WebKit::WebViewImpl::enableAutoResizeMode): Deprecated it.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::enableAutoResizeMode): Adjust for new api.
(WebKit::WebViewImpl::disableAutoResizeMode): Allow turning off autoresize.
(WebKit::WebViewImpl::enableAutoResizeMode): Call the other two apis, but
this api will be deleted shortly.
(WebKit::WebViewImpl::configureAutoResizeMode): Common code.
* src/WebViewImpl.h:
(WebViewImpl): Adjust to new public api.

Tools:

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController): Expose a way to turn off auto-resize.
(LayoutTestController::enableAutoResizeMode): Ditto and adjust to new WebKit api.
(LayoutTestController::disableAutoResizeMode):  Ditto.
* DumpRenderTree/chromium/LayoutTestController.h: Ditto.

LayoutTests:

* fast/autoresize/turn-off-autoresize-expected.txt: Added.
* fast/autoresize/turn-off-autoresize.html: Added.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/autoresize/turn-off-autoresize-expected.txt [new file with mode: 0644]
LayoutTests/fast/autoresize/turn-off-autoresize.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebView.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h

index a68e005..c563992 100644 (file)
@@ -1,3 +1,13 @@
+2012-02-29  David Levin  <levin@chromium.org>
+
+        [chromium] Add the ability to turn off autoresize.
+        https://bugs.webkit.org/show_bug.cgi?id=77452
+
+        Reviewed by Darin Fisher.
+
+        * fast/autoresize/turn-off-autoresize-expected.txt: Added.
+        * fast/autoresize/turn-off-autoresize.html: Added.
+
 2012-02-29  Adam Klein  <adamk@chromium.org>
 
         Rebaseline line-grid tests for Chromium after r109267.
diff --git a/LayoutTests/fast/autoresize/turn-off-autoresize-expected.txt b/LayoutTests/fast/autoresize/turn-off-autoresize-expected.txt
new file mode 100644 (file)
index 0000000..33d71a7
--- /dev/null
@@ -0,0 +1,15 @@
+This test verifies that turning off auto resize functions correctly. It only works when run in dumprendertree as it relies on having auto-resize function available. 
+
+When it succeeds, there should be a series of PASS messages followed by a DONE message. 
+
+PASS: document.body.clientWidth equaled window.innerWidth
+PASS: document.body.clientHeight equaled window.innerHeight
+PASS: document.body.scrollWidth equaled window.innerWidth
+PASS: document.body.scrollHeight equaled window.innerHeight
+PASS: window.innerWidth equaled window.outerWidth
+PASS: window.innerHeight equaled window.outerHeight
+PASS: window.outerWidth equaled 200
+PASS: window.outerHeight equaled 200
+PASS: window.outerWidth equaled 200
+DONE
+
diff --git a/LayoutTests/fast/autoresize/turn-off-autoresize.html b/LayoutTests/fast/autoresize/turn-off-autoresize.html
new file mode 100644 (file)
index 0000000..c8708c0
--- /dev/null
@@ -0,0 +1,38 @@
+<!doctype html>
+<html>
+<script src='resources/autoresize-util.js'></script>
+<script>
+function runTest()
+{
+    if (window.layoutTestController) {
+        layoutTestController.enableAutoResizeMode(10, 10, 1000, 1000);
+        layoutTestController.dumpAsText();
+    }
+    shouldBe('document.body.clientWidth', 'window.innerWidth');
+    shouldBe('document.body.clientHeight', 'window.innerHeight');
+    shouldBe('document.body.scrollWidth', 'window.innerWidth');
+    shouldBe('document.body.scrollHeight', 'window.innerHeight');
+    shouldBe('window.innerWidth', 'window.outerWidth');
+    shouldBe('window.innerHeight', 'window.outerHeight');
+    if (window.layoutTestController)
+        layoutTestController.disableAutoResizeMode(200, 200);
+
+    shouldBe('window.outerWidth', 200);
+    shouldBe('window.outerHeight', 200);
+    document.body.style.width = '100px';
+    shouldBe('window.outerWidth', 200);
+
+    log('DONE');
+}
+</script>
+<body onload="runTest()" style="margin:0; width:900px">
+This test verifies that turning off auto resize functions correctly. It only works when run in dumprendertree as it relies on having auto-resize function available.
+<br>
+<br>
+When it succeeds, there should be a series of PASS messages followed by a DONE message.
+<br>
+<br>
+<div id='result'>
+</div>
+</body>
+</html>
index 7c4a164..9757d56 100644 (file)
@@ -1,3 +1,16 @@
+2012-02-29  David Levin  <levin@chromium.org>
+
+        [chromium] Add the ability to turn off autoresize.
+        https://bugs.webkit.org/show_bug.cgi?id=77452
+
+        Reviewed by Darin Fisher.
+
+        Test: fast/autoresize/turn-off-autoresize.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::enableAutoSizeMode): Fix the code
+        path for turning off autoresize to set the scrollbars to auto.
+
 2012-02-29  David Barton  <dbarton@mathscribe.com>
 
         <msubsup> setNeedsLayout() correction
index 024c484..42cf9d6 100644 (file)
@@ -3024,11 +3024,15 @@ void FrameView::enableAutoSizeMode(bool enable, const IntSize& minSize, const In
     m_minAutoSize = minSize;
     m_maxAutoSize = maxSize;
 
-    if (!m_shouldAutoSize)
-        return;
-
     setNeedsLayout();
     scheduleRelayout();
+    if (m_shouldAutoSize)
+        return;
+
+    // Since autosize mode forces the scrollbar mode, change them to being auto.
+    setVerticalScrollbarLock(false);
+    setHorizontalScrollbarLock(false);
+    setScrollbarModes(ScrollbarAuto, ScrollbarAuto);
 }
 
 void FrameView::forceLayout(bool allowSubtree)
index 7771d0f..cfacec5 100644 (file)
@@ -1,3 +1,23 @@
+2012-02-29  David Levin  <levin@chromium.org>
+
+        [chromium] Add the ability to turn off autoresize.
+        https://bugs.webkit.org/show_bug.cgi?id=77452
+
+        Reviewed by Darin Fisher.
+
+        * public/WebView.h:
+        (WebKit::WebViewImpl::enableAutoResizeMode): Cleaned up the api.
+        (WebKit::WebViewImpl::disableAutoResizeMode): Added the ability to disable auto-resize.
+        (WebKit::WebViewImpl::enableAutoResizeMode): Deprecated it.
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::enableAutoResizeMode): Adjust for new api.
+        (WebKit::WebViewImpl::disableAutoResizeMode): Allow turning off autoresize.
+        (WebKit::WebViewImpl::enableAutoResizeMode): Call the other two apis, but
+        this api will be deleted shortly.
+        (WebKit::WebViewImpl::configureAutoResizeMode): Common code.
+        * src/WebViewImpl.h:
+        (WebViewImpl): Adjust to new public api.
+
 2012-02-29  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed.  Rolled DEPS.
index ed853e2..9d5ca89 100644 (file)
@@ -260,10 +260,17 @@ public:
     // In auto-resize mode, the view is automatically adjusted to fit the html
     // content within the given bounds.
     virtual void enableAutoResizeMode(
-        bool enable,
         const WebSize& minSize,
         const WebSize& maxSize) = 0;
 
+    // Turn off auto-resize.
+    virtual void disableAutoResizeMode() = 0;
+
+    // DEPRECATED
+    virtual void enableAutoResizeMode(
+        bool enable,
+        const WebSize& minSize,
+        const WebSize& maxSize) = 0;
 
     // Media ---------------------------------------------------------------
 
index f153022..c6b2d99 100644 (file)
@@ -2264,15 +2264,27 @@ void WebViewImpl::enableFixedLayoutMode(bool enable)
 #endif
 }
 
-void WebViewImpl::enableAutoResizeMode(bool enable, const WebSize& minSize, const WebSize& maxSize)
+
+void WebViewImpl::enableAutoResizeMode(const WebSize& minSize, const WebSize& maxSize)
 {
-    m_shouldAutoResize = enable;
+    m_shouldAutoResize = true;
     m_minAutoSize = minSize;
     m_maxAutoSize = maxSize;
-    if (!mainFrameImpl() || !mainFrameImpl()->frame() || !mainFrameImpl()->frame()->view())
-        return;
+    configureAutoResizeMode();
+}
 
-    mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_shouldAutoResize, m_minAutoSize, m_maxAutoSize);
+void WebViewImpl::disableAutoResizeMode()
+{
+    m_shouldAutoResize = false;
+    configureAutoResizeMode();
+}
+
+void WebViewImpl::enableAutoResizeMode(bool enable, const WebSize& minSize, const WebSize& maxSize)
+{
+    if (enable)
+        enableAutoResizeMode(enable, minSize, maxSize);
+    else
+        disableAutoResizeMode();
 }
 
 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScale)
@@ -2585,6 +2597,14 @@ void WebViewImpl::sendResizeEventAndRepaint()
     }
 }
 
+void WebViewImpl::configureAutoResizeMode()
+{
+    if (!mainFrameImpl() || !mainFrameImpl()->frame() || !mainFrameImpl()->frame()->view())
+        return;
+
+    mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_shouldAutoResize, m_minAutoSize, m_maxAutoSize);
+}
+
 unsigned long WebViewImpl::createUniqueIdentifierForRequest()
 {
     if (m_page)
index cac6d48..cbf1a53 100644 (file)
@@ -188,6 +188,10 @@ public:
     virtual WebSize fixedLayoutSize() const;
     virtual void setFixedLayoutSize(const WebSize&);
     virtual void enableAutoResizeMode(
+        const WebSize& minSize,
+        const WebSize& maxSize);
+    virtual void disableAutoResizeMode();
+    virtual void enableAutoResizeMode(
         bool enable,
         const WebSize& minSize,
         const WebSize& maxSize);
@@ -534,6 +538,7 @@ private:
                                                DragAction);
 
     void sendResizeEventAndRepaint();
+    void configureAutoResizeMode();
 
 #if USE(ACCELERATED_COMPOSITING)
     void setIsAcceleratedCompositingActive(bool);
index 51d8cd6..566fb35 100644 (file)
@@ -1,3 +1,16 @@
+2012-02-29  David Levin  <levin@chromium.org>
+
+        [chromium] Add the ability to turn off autoresize.
+        https://bugs.webkit.org/show_bug.cgi?id=77452
+
+        Reviewed by Darin Fisher.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController): Expose a way to turn off auto-resize.
+        (LayoutTestController::enableAutoResizeMode): Ditto and adjust to new WebKit api.
+        (LayoutTestController::disableAutoResizeMode):  Ditto.
+        * DumpRenderTree/chromium/LayoutTestController.h: Ditto.
+
 2012-02-29  Dirk Pranke  <dpranke@chromium.org>
 
         nrwt: make --print trace work with virtual tests
index 74c97c4..9c68dff 100644 (file)
@@ -104,6 +104,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
 #if ENABLE(POINTER_LOCK)
     bindMethod("didLosePointerLock", &LayoutTestController::didLosePointerLock);
 #endif
+    bindMethod("disableAutoResizeMode", &LayoutTestController::disableAutoResizeMode);
     bindMethod("disableImageLoading", &LayoutTestController::disableImageLoading);
     bindMethod("display", &LayoutTestController::display);
     bindMethod("displayInvalidatedRegion", &LayoutTestController::displayInvalidatedRegion);
@@ -1129,7 +1130,23 @@ void LayoutTestController::enableAutoResizeMode(const CppArgumentList& arguments
     int maxHeight = cppVariantToInt32(arguments[3]);
     WebKit::WebSize maxSize(maxWidth, maxHeight);
 
-    m_shell->webView()->enableAutoResizeMode(true, minSize, maxSize);
+    m_shell->webView()->enableAutoResizeMode(minSize, maxSize);
+    result->set(true);
+}
+
+void LayoutTestController::disableAutoResizeMode(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() !=2) {
+        result->set(false);
+        return;
+    }
+    int newWidth = cppVariantToInt32(arguments[0]);
+    int newHeight = cppVariantToInt32(arguments[1]);
+    WebKit::WebSize newSize(newWidth, newHeight);
+
+    m_shell->webViewHost()->setWindowRect(WebRect(0, 0, newSize.width, newSize.height));
+    m_shell->webView()->disableAutoResizeMode();
+    m_shell->webView()->resize(newSize);
     result->set(true);
 }
 
index 526bca0..0f5059b 100644 (file)
@@ -241,6 +241,7 @@ public:
     void pauseTransitionAtTimeOnElementWithId(const CppArgumentList&, CppVariant*);
     void elementDoesAutoCompleteForElementWithId(const CppArgumentList&, CppVariant*);
     void enableAutoResizeMode(const CppArgumentList&, CppVariant*);
+    void disableAutoResizeMode(const CppArgumentList&, CppVariant*);
     void numberOfActiveAnimations(const CppArgumentList&, CppVariant*);
     void suspendAnimations(const CppArgumentList&, CppVariant*);
     void resumeAnimations(const CppArgumentList&, CppVariant*);