2011-03-01 Joseph Pecoraro <joepeck@webkit.org>
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Mar 2011 00:59:59 +0000 (00:59 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Mar 2011 00:59:59 +0000 (00:59 +0000)
        Reviewed by Kenneth Rohde Christiansen.

        Viewport Warning/Error Messages Are Now Inaccurate
        https://bugs.webkit.org/show_bug.cgi?id=53707

        Added tests specifically to test Console warnings.

        * fast/viewport/viewport-warnings-1.html: Added.
        * fast/viewport/viewport-warnings-2.html: Added.
        * fast/viewport/viewport-warnings-3.html: Added.
        * fast/viewport/viewport-warnings-4.html: Added.
        * fast/viewport/viewport-warnings-5.html: Added.
        * fast/viewport/viewport-warnings-6.html: Added.
        * fast/viewport/viewport-warnings-7.html: Added.

2011-03-01  Joseph Pecoraro  <joepeck@webkit.org>

        Reviewed by Kenneth Rohde Christiansen.

        Viewport Warning/Error Messages Are Now Inaccurate
        https://bugs.webkit.org/show_bug.cgi?id=53707

        Correct and improve the error messages for viewport
        parsing. Clarify the difference between incorrect
        keys, values, and when to use the device-width or
        device-height constants.

        * dom/ViewportArguments.cpp:
        (WebCore::computeViewportAttributes): suggest using keywords if fixed input matches device width or height.
        (WebCore::numericPrefix):
        (WebCore::findSizeValue): remove incorrect warnings about fixed numbers because we don't know the device width or height.
        (WebCore::setViewportFeature): report a warning for an unrecognized key.
        (WebCore::viewportErrorMessageTemplate): added template for unrecognized key.
        (WebCore::viewportErrorMessageLevel):
        * dom/ViewportArguments.h:

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/viewport/viewport-warnings-1.html [new file with mode: 0644]
LayoutTests/fast/viewport/viewport-warnings-2.html [new file with mode: 0644]
LayoutTests/fast/viewport/viewport-warnings-3.html [new file with mode: 0644]
LayoutTests/fast/viewport/viewport-warnings-4.html [new file with mode: 0644]
LayoutTests/fast/viewport/viewport-warnings-5.html [new file with mode: 0644]
LayoutTests/fast/viewport/viewport-warnings-6.html [new file with mode: 0644]
LayoutTests/fast/viewport/viewport-warnings-7.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/ViewportArguments.cpp
Source/WebCore/dom/ViewportArguments.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_view.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/gtk/webkit/webkitviewportattributes.cpp
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp

index b05cd85..b039b2e 100644 (file)
@@ -1,3 +1,20 @@
+2011-03-01  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Viewport Warning/Error Messages Are Now Inaccurate
+        https://bugs.webkit.org/show_bug.cgi?id=53707
+
+        Added tests specifically to test Console warnings.
+
+        * fast/viewport/viewport-warnings-1.html: Added.
+        * fast/viewport/viewport-warnings-2.html: Added.
+        * fast/viewport/viewport-warnings-3.html: Added.
+        * fast/viewport/viewport-warnings-4.html: Added.
+        * fast/viewport/viewport-warnings-5.html: Added.
+        * fast/viewport/viewport-warnings-6.html: Added.
+        * fast/viewport/viewport-warnings-7.html: Added.
+
 2011-03-01  Tony Gentilcore  <tonyg@chromium.org>
 
         Unreviewed baseline
diff --git a/LayoutTests/fast/viewport/viewport-warnings-1.html b/LayoutTests/fast/viewport/viewport-warnings-1.html
new file mode 100644 (file)
index 0000000..f697975
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+    <title>No warnings or errors.</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
+    <script>
+        function test() {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpConfigurationForViewport(160, 320, 480, 320, 352);
+            }
+        }
+    </script>
+</head>
+<body onload="test();">
diff --git a/LayoutTests/fast/viewport/viewport-warnings-2.html b/LayoutTests/fast/viewport/viewport-warnings-2.html
new file mode 100644 (file)
index 0000000..c875ae4
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+    <title>Unrecognized key.</title>
+    <meta name="viewport" content="wwidth=100">
+    <script>
+        function test() {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpConfigurationForViewport(160, 320, 480, 320, 352);
+            }
+        }
+    </script>
+</head>
+<body onload="test();">
diff --git a/LayoutTests/fast/viewport/viewport-warnings-3.html b/LayoutTests/fast/viewport/viewport-warnings-3.html
new file mode 100644 (file)
index 0000000..9f58398
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+    <title>Unrecognized value.</title>
+    <meta name="viewport" content="width=unrecognized-width">
+    <script>
+        function test() {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpConfigurationForViewport(160, 320, 480, 320, 352);
+            }
+        }
+    </script>
+</head>
+<body onload="test();">
diff --git a/LayoutTests/fast/viewport/viewport-warnings-4.html b/LayoutTests/fast/viewport/viewport-warnings-4.html
new file mode 100644 (file)
index 0000000..bb15d7c
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+    <title>Truncated value.</title>
+    <meta name="viewport" content="width=123x456">
+    <script>
+        function test() {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpConfigurationForViewport(160, 320, 480, 320, 352);
+            }
+        }
+    </script>
+</head>
+<body onload="test();">
diff --git a/LayoutTests/fast/viewport/viewport-warnings-5.html b/LayoutTests/fast/viewport/viewport-warnings-5.html
new file mode 100644 (file)
index 0000000..f9a984b
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+    <title>Suggest using keywords when fixed number matches device width or height.</title>
+    <meta name="viewport" content="width=320, height=352">
+    <script>
+        function test() {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpConfigurationForViewport(160, 320, 480, 320, 352);
+            }
+        }
+    </script>
+</head>
+<body onload="test();">
diff --git a/LayoutTests/fast/viewport/viewport-warnings-6.html b/LayoutTests/fast/viewport/viewport-warnings-6.html
new file mode 100644 (file)
index 0000000..829508c
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+    <title>Multiple warnings and errors due to incorrect semicolon separators.</title>
+    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
+    <script>
+        function test() {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpConfigurationForViewport(160, 320, 480, 320, 352);
+            }
+        }
+    </script>
+</head>
+<body onload="test();">
diff --git a/LayoutTests/fast/viewport/viewport-warnings-7.html b/LayoutTests/fast/viewport/viewport-warnings-7.html
new file mode 100644 (file)
index 0000000..96eeebd
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+    <title>Missing value should produce an error.</title>
+    <meta name="viewport" content="width=">
+    <script>
+        function test() {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.dumpConfigurationForViewport(160, 320, 480, 320, 352);
+            }
+        }
+    </script>
+</head>
+<body onload="test();">
index 005ef71..4f47af6 100644 (file)
@@ -1,3 +1,24 @@
+2011-03-01  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Viewport Warning/Error Messages Are Now Inaccurate
+        https://bugs.webkit.org/show_bug.cgi?id=53707
+
+        Correct and improve the error messages for viewport
+        parsing. Clarify the difference between incorrect
+        keys, values, and when to use the device-width or
+        device-height constants.
+
+        * dom/ViewportArguments.cpp:
+        (WebCore::computeViewportAttributes): suggest using keywords if fixed input matches device width or height.
+        (WebCore::numericPrefix):
+        (WebCore::findSizeValue): remove incorrect warnings about fixed numbers because we don't know the device width or height.
+        (WebCore::setViewportFeature): report a warning for an unrecognized key.
+        (WebCore::viewportErrorMessageTemplate): added template for unrecognized key.
+        (WebCore::viewportErrorMessageLevel):
+        * dom/ViewportArguments.h:
+
 2011-03-01  Ryosuke Niwa  <rniwa@webkit.org>
 
         Reviewed by Darin Adler.
index 06c5ea2..0097433 100644 (file)
@@ -41,7 +41,7 @@ using namespace std;
 
 namespace WebCore {
 
-ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, int deviceDPI, IntSize visibleViewport)
+ViewportAttributes computeViewportAttributes(Document* document, ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, int deviceDPI, IntSize visibleViewport)
 {
     ViewportAttributes result;
 
@@ -50,6 +50,11 @@ ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktop
 
     ASSERT(availableWidth > 0 && availableHeight > 0);
 
+    if (args.width == deviceWidth || args.height == deviceWidth)
+        reportViewportWarning(document, DeviceWidthShouldBeUsedWarning, String(), String());
+    if (args.width == deviceHeight || args.height == deviceHeight)
+        reportViewportWarning(document, DeviceHeightShouldBeUsedWarning, String(), String());
+
     switch (int(args.targetDensityDpi)) {
     case ViewportArguments::ValueDeviceDPI:
         args.targetDensityDpi = deviceDPI;
@@ -190,7 +195,7 @@ static float numericPrefix(const String& keyString, const String& valueString, D
     if (!*ok) {
         if (!didReadNumber) {
             ASSERT(!value);
-            reportViewportWarning(document, UnrecognizedViewportArgumentError, valueString, keyString);
+            reportViewportWarning(document, UnrecognizedViewportArgumentValueError, valueString, keyString);
             return value;
         }
         *ok = true;
@@ -221,11 +226,6 @@ static float findSizeValue(const String& keyString, const String& valueString, D
     if (value < 0)
         return ViewportArguments::ValueAuto;
 
-    if (keyString == "width")
-        reportViewportWarning(document, DeviceWidthShouldBeUsedWarning, String(), String());
-    else if (keyString == "height")
-        reportViewportWarning(document, DeviceHeightShouldBeUsedWarning, String(), String());
-
     return value;
 }
 
@@ -332,6 +332,8 @@ void setViewportFeature(const String& keyString, const String& valueString, Docu
         arguments->userScalable = findUserScalableValue(keyString, valueString, document);
     else if (keyString == "target-densitydpi")
         arguments->targetDensityDpi = findTargetDensityDPIValue(keyString, valueString, document);
+    else
+        reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, keyString, String());
 }
 
 static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode)
@@ -339,6 +341,7 @@ static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode)
     static const char* const errors[] = {
         "Viewport width or height set to physical device width, try using \"device-width\" constant instead for future compatibility.",
         "Viewport height or height set to physical device height, try using \"device-height\" constant instead for future compatibility.",
+        "Viewport argument key \"%replacement1\" not recognized and ignored.",
         "Viewport argument value \"%replacement1\" for key \"%replacement2\" not recognized. Content ignored.",
         "Viewport argument value \"%replacement1\" for key \"%replacement2\" was truncated to its numeric prefix.",
         "Viewport maximum-scale cannot be larger than 10.0. The maximum-scale will be set to 10.0.",
@@ -356,7 +359,8 @@ static MessageLevel viewportErrorMessageLevel(ViewportErrorCode errorCode)
     case TruncatedViewportArgumentValueError:
     case TargetDensityDpiTooSmallOrLargeError:
         return TipMessageLevel;
-    case UnrecognizedViewportArgumentError:
+    case UnrecognizedViewportArgumentKeyError:
+    case UnrecognizedViewportArgumentValueError:
     case MaximumScaleTooLargeError:
         return ErrorMessageLevel;
     }
index 339345c..5697096 100644 (file)
@@ -37,7 +37,8 @@ class Document;
 enum ViewportErrorCode {
     DeviceWidthShouldBeUsedWarning,
     DeviceHeightShouldBeUsedWarning,
-    UnrecognizedViewportArgumentError,
+    UnrecognizedViewportArgumentKeyError,
+    UnrecognizedViewportArgumentValueError,
     TruncatedViewportArgumentValueError,
     MaximumScaleTooLargeError,
     TargetDensityDpiTooSmallOrLargeError
@@ -100,7 +101,7 @@ struct ViewportArguments {
     }
 };
 
-ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, int deviceDPI, IntSize visibleViewport);
+ViewportAttributes computeViewportAttributes(Document*, ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, int deviceDPI, IntSize visibleViewport);
 
 void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data);
 void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2);
index 3e76be1..f7a7ffc 100644 (file)
@@ -1,3 +1,13 @@
+2011-03-01  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Viewport Warning/Error Messages Are Now Inaccurate
+        https://bugs.webkit.org/show_bug.cgi?id=53707
+
+        * ewk/ewk_view.cpp:
+        (_ewk_view_viewport_attributes_compute): pass a Document into computeViewportAttributes for warnings to be reported to.
+
 2011-02-28  Chang Shu  <cshu@webkit.org>
 
         Reviewed by Ryosuke Niwa.
index ab0629a..a3b6dd6 100644 (file)
@@ -1023,8 +1023,10 @@ static WebCore::ViewportAttributes _ewk_view_viewport_attributes_compute(Evas_Ob
     int device_width = (int) priv->page->chrome()->client()->windowRect().width();
     int device_height = (int) priv->page->chrome()->client()->windowRect().height();
 
+    WebCore::Document* document = priv->page->mainFrame()->document();
+
     WebCore::IntSize available_size = WebCore::IntSize(available_width, available_height);
-    WebCore::ViewportAttributes attributes = WebCore::computeViewportAttributes(priv->viewport_arguments, desktop_width, device_width, device_height, device_dpi, available_size);
+    WebCore::ViewportAttributes attributes = WebCore::computeViewportAttributes(document, priv->viewport_arguments, desktop_width, device_width, device_height, device_dpi, available_size);
 
     return attributes;
 }
index 39fbfdd..8901702 100644 (file)
@@ -1,3 +1,15 @@
+2011-03-01  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Viewport Warning/Error Messages Are Now Inaccurate
+        https://bugs.webkit.org/show_bug.cgi?id=53707
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::dumpConfigurationForViewport): pass a Document into computeViewportAttributes for warnings to be reported to.
+        * webkit/webkitviewportattributes.cpp:
+        (webkitViewportAttributesRecompute): pass a Document into computeViewportAttributes for warnings to be reported to.
+
 2011-03-01  Kamil Blank  <k.blank@samsung.com>
 
         Reviewed by Martin Robinson.
index 6db2c81..c637976 100644 (file)
@@ -626,8 +626,9 @@ void DumpRenderTreeSupportGtk::dumpConfigurationForViewport(WebKitWebView* webVi
 {
     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
 
-    ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments();
-    ViewportAttributes attrs = computeViewportAttributes(arguments, /* default layout width for non-mobile pages */ 980, deviceWidth, deviceHeight, deviceDPI, IntSize(availableWidth, availableHeight));
+    Document* document = webView->priv->corePage->mainFrame()->document();
+    ViewportArguments arguments = document->viewportArguments();
+    ViewportAttributes attrs = computeViewportAttributes(document, arguments, /* default layout width for non-mobile pages */ 980, deviceWidth, deviceHeight, deviceDPI, IntSize(availableWidth, availableHeight));
 
     fprintf(stdout, "viewport size %dx%d scale %f with limits [%f, %f]\n", attrs.layoutSize.width(), attrs.layoutSize.height(), attrs.initialScale, attrs.minimumScale, attrs.maximumScale);
 }
index 9a98e44..fb65881 100644 (file)
@@ -532,9 +532,10 @@ void webkitViewportAttributesRecompute(WebKitViewportAttributes* viewportAttribu
     // First of all, we give the application an opportunity to override some of the values.
     g_signal_emit_by_name(webView, "viewport-attributes-recompute-requested", viewportAttributes);
 
-    ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments();
+    Document* document = webView->priv->corePage->mainFrame()->document();
+    ViewportArguments arguments = document->viewportArguments();
 
-    ViewportAttributes attributes = computeViewportAttributes(arguments, priv->desktopWidth, priv->deviceWidth, priv->deviceHeight, priv->deviceDPI, IntSize(priv->availableWidth, priv->availableHeight));
+    ViewportAttributes attributes = computeViewportAttributes(document, arguments, priv->desktopWidth, priv->deviceWidth, priv->deviceHeight, priv->deviceDPI, IntSize(priv->availableWidth, priv->availableHeight));
 
     priv->width = attributes.layoutSize.width();
     priv->height = attributes.layoutSize.height();
index f4d2631..64d41f3 100644 (file)
@@ -2523,7 +2523,8 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av
         deviceHeight = size.height();
     }
 
-    WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, qt_defaultDpi(), availableSize);
+    WebCore::Document* document = d->page->mainFrame()->document();
+    WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(document, d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, qt_defaultDpi(), availableSize);
 
     result.m_isValid = true;
     result.m_size = conf.layoutSize;
index f767c73..b0efe42 100644 (file)
@@ -1,3 +1,15 @@
+2011-03-01  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Viewport Warning/Error Messages Are Now Inaccurate
+        https://bugs.webkit.org/show_bug.cgi?id=53707
+
+        * Api/qwebpage.cpp:
+        (QWebPage::viewportAttributesForSize): pass a Document into computeViewportAttributes for warnings to be reported to.
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+        (DumpRenderTreeSupportQt::viewportAsText): pass a Document into computeViewportAttributes for warnings to be reported to.
+
 2011-03-01  Andras Becsi  <abecsi@webkit.org>
 
         Reviewed by Csaba Osztrogon√°c.
index 22bb567..e65abc5 100644 (file)
@@ -722,9 +722,10 @@ void DumpRenderTreeSupportQt::dumpNotification(bool b)
 
 QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, int deviceDPI, const QSize& deviceSize, const QSize& availableSize)
 {
+    WebCore::Document* document = page->d->page->mainFrame()->document();
     WebCore::ViewportArguments args = page->d->viewportArguments();
 
-    WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(args,
+    WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(document, args,
         /* desktop-width */ 980,
         /* device-width  */ deviceSize.width(),
         /* device-height */ deviceSize.height(),