Log Message
Various autoresize fixes. https://bugs.webkit.org/show_bug.cgi?id=81199 Reviewed by Darin Fisher.
Source/WebCore: Tested by WebViewTest additions. * page/FrameView.cpp: (WebCore::FrameView::autoSizeIfEnabled): Fixed a bug that caused a horizontal scrollbar to appear when the size was width was fixed and height overflowed which is one of the tests that was added. Source/WebKit/chromium: * public/WebView.h: (WebView): Remove a deprecated api. * src/WebViewImpl.cpp: Ditto. * src/WebViewImpl.h: Ditto. * tests/FrameTestHelpers.cpp: (WebKit::FrameTestHelpers::registerMockedURLLoad): Added an overload with more flexibility. The previous api didn't allow one to request a url with a search string. (FrameTestHelpers): * tests/FrameTestHelpers.h: (FrameTestHelpers): Ditto. * tests/WebViewTest.cpp: Fix the test because calling _javascript_: was working. Make the test generic and added a lot more tests to cover various possibilities. I avoided using a layout test because there wasn't a way to get the scrollbar state, so I just generalized a test that was already there. * tests/data/specify_size.html: Allow the test to take its size from the search string. Tools: * DumpRenderTree/chromium/LayoutTestController.cpp: (LayoutTestController::reset): Stop using the deprecated api that was removed.
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/page/FrameView.cpp
- trunk/Source/WebKit/chromium/ChangeLog
- trunk/Source/WebKit/chromium/public/WebView.h
- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
- trunk/Source/WebKit/chromium/src/WebViewImpl.h
- trunk/Source/WebKit/chromium/tests/FrameTestHelpers.cpp
- trunk/Source/WebKit/chromium/tests/FrameTestHelpers.h
- trunk/Source/WebKit/chromium/tests/WebViewTest.cpp
- trunk/Source/WebKit/chromium/tests/data/specify_size.html
- trunk/Tools/ChangeLog
- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Diff
Modified: trunk/Source/WebCore/ChangeLog (110874 => 110875)
--- trunk/Source/WebCore/ChangeLog 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebCore/ChangeLog 2012-03-15 19:54:27 UTC (rev 110875)
@@ -1,3 +1,17 @@
+2012-03-15 David Levin <le...@chromium.org>
+
+ Various autoresize fixes.
+ https://bugs.webkit.org/show_bug.cgi?id=81199
+
+ Reviewed by Darin Fisher.
+
+ Tested by WebViewTest additions.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::autoSizeIfEnabled): Fixed a bug that caused a horizontal
+ scrollbar to appear when the size was width was fixed and height overflowed which
+ is one of the tests that was added.
+
2012-03-15 Andrey Kosyakov <ca...@chromium.org>
Web Inspector: normalize vertical overview bars by longest bar, not by longest frame
Modified: trunk/Source/WebCore/page/FrameView.cpp (110874 => 110875)
--- trunk/Source/WebCore/page/FrameView.cpp 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebCore/page/FrameView.cpp 2012-03-15 19:54:27 UTC (rev 110875)
@@ -2367,9 +2367,6 @@
int height = documentRenderBox->scrollHeight();
IntSize newSize(width, height);
- // Ensure the size is at least the min bounds.
- newSize = newSize.expandedTo(m_minAutoSize);
-
// Check to see if a scrollbar is needed for a given dimension and
// if so, increase the other dimension to account for the scrollbar.
// Since the dimensions are only for the view rectangle, once a
@@ -2394,6 +2391,9 @@
// already greater the maximum.
}
+ // Ensure the size is at least the min bounds.
+ newSize = newSize.expandedTo(m_minAutoSize);
+
// Bound the dimensions by the max bounds and determine what scrollbars to show.
ScrollbarMode horizonalScrollbarMode = ScrollbarAlwaysOff;
if (newSize.width() > m_maxAutoSize.width()) {
Modified: trunk/Source/WebKit/chromium/ChangeLog (110874 => 110875)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-03-15 19:54:27 UTC (rev 110875)
@@ -1,3 +1,26 @@
+2012-03-15 David Levin <le...@chromium.org>
+
+ Various autoresize fixes.
+ https://bugs.webkit.org/show_bug.cgi?id=81199
+
+ Reviewed by Darin Fisher.
+
+ * public/WebView.h:
+ (WebView): Remove a deprecated api.
+ * src/WebViewImpl.cpp: Ditto.
+ * src/WebViewImpl.h: Ditto.
+ * tests/FrameTestHelpers.cpp:
+ (WebKit::FrameTestHelpers::registerMockedURLLoad): Added an overload with more flexibility.
+ The previous api didn't allow one to request a url with a search string.
+ (FrameTestHelpers):
+ * tests/FrameTestHelpers.h:
+ (FrameTestHelpers): Ditto.
+ * tests/WebViewTest.cpp: Fix the test because calling _javascript_:
+ was working. Make the test generic and added a lot more tests to cover
+ various possibilities. I avoided using a layout test because there wasn't
+ a way to get the scrollbar state, so I just generalized a test that was already there.
+ * tests/data/specify_size.html: Allow the test to take its size from the search string.
+
2012-03-15 Peter Beverloo <pe...@chromium.org>
Unreviewed. Rolled DEPS.
Modified: trunk/Source/WebKit/chromium/public/WebView.h (110874 => 110875)
--- trunk/Source/WebKit/chromium/public/WebView.h 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebKit/chromium/public/WebView.h 2012-03-15 19:54:27 UTC (rev 110875)
@@ -266,12 +266,6 @@
// Turn off auto-resize.
virtual void disableAutoResizeMode() = 0;
- // DEPRECATED
- virtual void enableAutoResizeMode(
- bool enable,
- const WebSize& minSize,
- const WebSize& maxSize) = 0;
-
// Media ---------------------------------------------------------------
// Performs the specified media player action on the node at the given location.
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (110874 => 110875)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-03-15 19:54:27 UTC (rev 110875)
@@ -2268,14 +2268,6 @@
configureAutoResizeMode();
}
-void WebViewImpl::enableAutoResizeMode(bool enable, const WebSize& minSize, const WebSize& maxSize)
-{
- if (enable)
- enableAutoResizeMode(minSize, maxSize);
- else
- disableAutoResizeMode();
-}
-
void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScale)
{
m_pageDefinedMinimumPageScaleFactor = minPageScale;
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (110874 => 110875)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-03-15 19:54:27 UTC (rev 110875)
@@ -193,10 +193,6 @@
const WebSize& minSize,
const WebSize& maxSize);
virtual void disableAutoResizeMode();
- virtual void enableAutoResizeMode(
- bool enable,
- const WebSize& minSize,
- const WebSize& maxSize);
virtual void performMediaPlayerAction(
const WebMediaPlayerAction& action,
const WebPoint& location);
Modified: trunk/Source/WebKit/chromium/tests/FrameTestHelpers.cpp (110874 => 110875)
--- trunk/Source/WebKit/chromium/tests/FrameTestHelpers.cpp 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebKit/chromium/tests/FrameTestHelpers.cpp 2012-03-15 19:54:27 UTC (rev 110875)
@@ -48,6 +48,11 @@
void registerMockedURLLoad(const std::string& base, const std::string& fileName)
{
+ registerMockedURLLoad(GURL(base + fileName), fileName);
+}
+
+void registerMockedURLLoad(GURL url, const std::string& fileName)
+{
WebURLResponse response;
response.initialize();
response.setMIMEType("text/html");
@@ -56,7 +61,7 @@
filePath += "/Source/WebKit/chromium/tests/data/";
filePath += fileName;
- webkit_support::RegisterMockedURL(GURL(base + fileName), response, WebString::fromUTF8(filePath));
+ webkit_support::RegisterMockedURL(url, response, WebString::fromUTF8(filePath));
}
void loadFrame(WebFrame* frame, const std::string& url)
Modified: trunk/Source/WebKit/chromium/tests/FrameTestHelpers.h (110874 => 110875)
--- trunk/Source/WebKit/chromium/tests/FrameTestHelpers.h 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebKit/chromium/tests/FrameTestHelpers.h 2012-03-15 19:54:27 UTC (rev 110875)
@@ -33,6 +33,8 @@
#include <string>
+class GURL;
+
namespace WebKit {
class WebFrame;
@@ -43,6 +45,8 @@
namespace FrameTestHelpers {
void registerMockedURLLoad(const std::string& base, const std::string& fileName);
+// Like the previous overload, but it allows more flexibility in the url since it is given by the caller.
+void registerMockedURLLoad(GURL, const std::string& fileName);
void loadFrame(WebFrame*, const std::string& url);
Modified: trunk/Source/WebKit/chromium/tests/WebViewTest.cpp (110874 => 110875)
--- trunk/Source/WebKit/chromium/tests/WebViewTest.cpp 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebKit/chromium/tests/WebViewTest.cpp 2012-03-15 19:54:27 UTC (rev 110875)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -42,6 +42,7 @@
#include "platform/WebSize.h"
#include "WebViewClient.h"
#include "WebViewImpl.h"
+#include <googleurl/src/gurl.h>
#include <gtest/gtest.h>
#include <webkit/support/webkit_support.h>
@@ -49,12 +50,28 @@
namespace {
+enum HorizontalScrollbarState {
+ NoHorizontalScrollbar,
+ VisibleHorizontalScrollbar,
+};
+
+enum VerticalScrollbarState {
+ NoVerticalScrollbar,
+ VisibleVerticalScrollbar,
+};
+
class TestData {
public:
void setWebView(WebView* webView) { m_webView = static_cast<WebViewImpl*>(webView); }
void setSize(const WebSize& newSize) { m_size = newSize; }
- bool hasHorizontalScrollbar() const { return m_webView->hasHorizontalScrollbar(); }
- bool hasVerticalScrollbar() const { return m_webView->hasVerticalScrollbar(); }
+ HorizontalScrollbarState horizontalScrollbarState() const
+ {
+ return m_webView->hasHorizontalScrollbar() ? VisibleHorizontalScrollbar: NoHorizontalScrollbar;
+ }
+ VerticalScrollbarState verticalScrollbarState() const
+ {
+ return m_webView->hasVerticalScrollbar() ? VisibleVerticalScrollbar : NoVerticalScrollbar;
+ }
int width() const { return m_size.width; }
int height() const { return m_size.height; }
@@ -88,6 +105,11 @@
}
protected:
+ void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResize,
+ const std::string& pageWidth, const std::string& pageHeight,
+ int expectedWidth, int expectedHeight,
+ HorizontalScrollbarState expectedHorizontalState, VerticalScrollbarState expectedVerticalState);
+
std::string m_baseURL;
};
@@ -119,35 +141,108 @@
webView->close();
}
-TEST_F(WebViewTest, AutoResizeMinimumSize)
+void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResize,
+ const std::string& pageWidth, const std::string& pageHeight,
+ int expectedWidth, int expectedHeight,
+ HorizontalScrollbarState expectedHorizontalState, VerticalScrollbarState expectedVerticalState)
{
AutoResizeWebViewClient client;
- FrameTestHelpers::registerMockedURLLoad(m_baseURL, "specify_size.html");
- WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "specify_size.html", true, 0, &client);
+ std::string url = "" + "specify_size.html?" + pageWidth + ":" + pageHeight;
+ FrameTestHelpers::registerMockedURLLoad(GURL(url), "specify_size.html");
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(url, true, 0, &client);
client.testData().setWebView(webView);
- FrameTestHelpers::loadFrame(webView->mainFrame(), "_javascript_:document.getElementById('sizer').style.height = '56px';");
- FrameTestHelpers::loadFrame(webView->mainFrame(), "_javascript_:document.getElementById('sizer').style.width = '91px';");
WebFrameImpl* frame = static_cast<WebFrameImpl*>(webView->mainFrame());
WebCore::FrameView* frameView = frame->frame()->view();
+ frameView->layout();
EXPECT_FALSE(frameView->layoutPending());
EXPECT_FALSE(frameView->needsLayout());
- WebSize minSize(91, 56);
- WebSize maxSize(403, 302);
- webView->enableAutoResizeMode(true, minSize, maxSize);
+ webView->enableAutoResizeMode(minAutoResize, maxAutoResize);
EXPECT_TRUE(frameView->layoutPending());
EXPECT_TRUE(frameView->needsLayout());
frameView->layout();
EXPECT_TRUE(frame->frame()->document()->isHTMLDocument());
- EXPECT_EQ(91, client.testData().width());
- EXPECT_EQ(56, client.testData().height());
- EXPECT_FALSE(client.testData().hasHorizontalScrollbar());
- EXPECT_FALSE(client.testData().hasVerticalScrollbar());
+ EXPECT_EQ(expectedWidth, client.testData().width());
+ EXPECT_EQ(expectedHeight, client.testData().height());
+ EXPECT_EQ(expectedHorizontalState, client.testData().horizontalScrollbarState());
+ EXPECT_EQ(expectedVerticalState, client.testData().verticalScrollbarState());
webView->close();
}
+TEST_F(WebViewTest, AutoResizeMinimumSize)
+{
+ WebSize minAutoResize(91, 56);
+ WebSize maxAutoResize(403, 302);
+ std::string pageWidth = "91px";
+ std::string pageHeight = "56px";
+ int expectedWidth = 91;
+ int expectedHeight = 56;
+ testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight,
+ expectedWidth, expectedHeight, NoHorizontalScrollbar, NoVerticalScrollbar);
}
+
+TEST_F(WebViewTest, AutoResizeHeightOverflowAndFixedWidth)
+{
+ WebSize minAutoResize(90, 95);
+ WebSize maxAutoResize(90, 100);
+ std::string pageWidth = "60px";
+ std::string pageHeight = "200px";
+ int expectedWidth = 90;
+ int expectedHeight = 100;
+ testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight,
+ expectedWidth, expectedHeight, NoHorizontalScrollbar, VisibleVerticalScrollbar);
+}
+
+TEST_F(WebViewTest, AutoResizeFixedHeightAndWidthOverflow)
+{
+ WebSize minAutoResize(90, 100);
+ WebSize maxAutoResize(200, 100);
+ std::string pageWidth = "300px";
+ std::string pageHeight = "80px";
+ int expectedWidth = 200;
+ int expectedHeight = 100;
+ testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight,
+ expectedWidth, expectedHeight, VisibleHorizontalScrollbar, NoVerticalScrollbar);
+}
+
+TEST_F(WebViewTest, AutoResizeInBetweenSizes)
+{
+ WebSize minAutoResize(90, 95);
+ WebSize maxAutoResize(200, 300);
+ std::string pageWidth = "100px";
+ std::string pageHeight = "200px";
+ int expectedWidth = 100;
+ int expectedHeight = 200;
+ testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight,
+ expectedWidth, expectedHeight, NoHorizontalScrollbar, NoVerticalScrollbar);
+}
+
+TEST_F(WebViewTest, AutoResizeOverflowSizes)
+{
+ WebSize minAutoResize(90, 95);
+ WebSize maxAutoResize(200, 300);
+ std::string pageWidth = "300px";
+ std::string pageHeight = "400px";
+ int expectedWidth = 200;
+ int expectedHeight = 300;
+ testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight,
+ expectedWidth, expectedHeight, VisibleHorizontalScrollbar, VisibleVerticalScrollbar);
+}
+
+TEST_F(WebViewTest, AutoResizeMaxSize)
+{
+ WebSize minAutoResize(90, 95);
+ WebSize maxAutoResize(200, 300);
+ std::string pageWidth = "200px";
+ std::string pageHeight = "300px";
+ int expectedWidth = 200;
+ int expectedHeight = 300;
+ testAutoResize(minAutoResize, maxAutoResize, pageWidth, pageHeight,
+ expectedWidth, expectedHeight, NoHorizontalScrollbar, NoVerticalScrollbar);
+}
+
+}
Modified: trunk/Source/WebKit/chromium/tests/data/specify_size.html (110874 => 110875)
--- trunk/Source/WebKit/chromium/tests/data/specify_size.html 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Source/WebKit/chromium/tests/data/specify_size.html 2012-03-15 19:54:27 UTC (rev 110875)
@@ -1,6 +1,20 @@
<!doctype html>
<html>
<body style='margin:0px'>
-<img id='sizer' src=''/>
+<img id='sizer'/>
+<script>
+// The desired size should be specified in the url in the search portion
+// like this ?widthDimension:heightDimension.
+var unitMatch = '([0-9]+[a-zA-Z]+)';
+var searchParser = new RegExp('\\?' + unitMatch + '(?:\\:' + unitMatch + ')');
+var parsedParameters = searchParser.exec(window.location.search);
+
+// Set the sizes.
+var elementToSize = document.getElementById('sizer');
+var width = parsedParameters[1];
+elementToSize.style.width = width;
+var height = parsedParameters[2];
+elementToSize.style.height = height;
+</script>
</body>
</html>
Modified: trunk/Tools/ChangeLog (110874 => 110875)
--- trunk/Tools/ChangeLog 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Tools/ChangeLog 2012-03-15 19:54:27 UTC (rev 110875)
@@ -1,3 +1,13 @@
+2012-03-15 David Levin <le...@chromium.org>
+
+ Various autoresize fixes.
+ https://bugs.webkit.org/show_bug.cgi?id=81199
+
+ Reviewed by Darin Fisher.
+
+ * DumpRenderTree/chromium/LayoutTestController.cpp:
+ (LayoutTestController::reset): Stop using the deprecated api that was removed.
+
2012-03-15 Carlos Garcia Campos <cgar...@igalia.com>
[GTK] Actually use --release and --debug command line options in run-gtk-test
Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (110874 => 110875)
--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp 2012-03-15 19:54:15 UTC (rev 110874)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp 2012-03-15 19:54:27 UTC (rev 110875)
@@ -625,7 +625,7 @@
#endif
m_shell->webView()->removeAllUserContent();
WebKit::WebSize empty;
- m_shell->webView()->enableAutoResizeMode(false, empty, empty);
+ m_shell->webView()->disableAutoResizeMode();
}
m_dumpAsText = false;
m_dumpAsAudio = false;
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes