2010-04-28 Luiz Agostini <luiz.agostini@openbossa.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Apr 2010 07:05:32 +0000 (07:05 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Apr 2010 07:05:32 +0000 (07:05 +0000)
        Reviewed by Simon Fraser.

        Media queries empty values
        https://bugs.webkit.org/show_bug.cgi?id=38116

        Adding isValid() method to MediaQueryExp to make it possible to differentiate
        between queries with empty values and queries with invalid values.

        * fast/media/media-query-invalid-value-expected.txt: Added.
        * fast/media/media-query-invalid-value.html: Added.
2010-04-28  Luiz Agostini  <luiz.agostini@openbossa.org>

        Reviewed by Simon Fraser.

        Media queries empty values
        https://bugs.webkit.org/show_bug.cgi?id=38116

        Adding isValid() method to MediaQueryExp to make it possible to differentiate
        between queries with empty values and queries with invalid values.

        Test: fast/media/media-query-invalid-value.html

        * css/MediaQueryEvaluator.cpp:
        (WebCore::MediaQueryEvaluator::eval):
        * css/MediaQueryExp.cpp:
        (WebCore::MediaQueryExp::MediaQueryExp):
        * css/MediaQueryExp.h:
        (WebCore::MediaQueryExp::isValid):

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

LayoutTests/ChangeLog
LayoutTests/fast/media/media-query-invalid-value-expected.txt [new file with mode: 0644]
LayoutTests/fast/media/media-query-invalid-value.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/MediaQueryEvaluator.cpp
WebCore/css/MediaQueryExp.cpp
WebCore/css/MediaQueryExp.h

index d197ba4..b626124 100644 (file)
@@ -1,3 +1,16 @@
+2010-04-28  Luiz Agostini  <luiz.agostini@openbossa.org>
+
+        Reviewed by Simon Fraser.
+
+        Media queries empty values
+        https://bugs.webkit.org/show_bug.cgi?id=38116
+
+        Adding isValid() method to MediaQueryExp to make it possible to differentiate
+        between queries with empty values and queries with invalid values.
+
+        * fast/media/media-query-invalid-value-expected.txt: Added.
+        * fast/media/media-query-invalid-value.html: Added.
+
 2010-04-25  Antonio Gomes  <tonikitoo@webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/media/media-query-invalid-value-expected.txt b/LayoutTests/fast/media/media-query-invalid-value-expected.txt
new file mode 100644 (file)
index 0000000..8889ba4
--- /dev/null
@@ -0,0 +1,6 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 200x200 [bgcolor=#008000]
diff --git a/LayoutTests/fast/media/media-query-invalid-value.html b/LayoutTests/fast/media/media-query-invalid-value.html
new file mode 100644 (file)
index 0000000..5613afa
--- /dev/null
@@ -0,0 +1,13 @@
+<head>
+    <style type="text/css">
+        @media (min-width) {
+            div { background-color: green; }
+        }
+        @media (min-width: blah) {
+            div { background-color: blue; }
+        }
+    </style>
+</head>
+<body>
+    <div style="width: 200; height: 200;"\>
+</body>
index f8b1b74..36bb57a 100644 (file)
@@ -1,3 +1,22 @@
+2010-04-28  Luiz Agostini  <luiz.agostini@openbossa.org>
+
+        Reviewed by Simon Fraser.
+
+        Media queries empty values
+        https://bugs.webkit.org/show_bug.cgi?id=38116
+
+        Adding isValid() method to MediaQueryExp to make it possible to differentiate
+        between queries with empty values and queries with invalid values.
+
+        Test: fast/media/media-query-invalid-value.html
+
+        * css/MediaQueryEvaluator.cpp:
+        (WebCore::MediaQueryEvaluator::eval):
+        * css/MediaQueryExp.cpp:
+        (WebCore::MediaQueryExp::MediaQueryExp):
+        * css/MediaQueryExp.h:
+        (WebCore::MediaQueryExp::isValid):
+
 2010-04-28  Pavel Feldman  <pfeldman@chromium.org>
 
         Reviewed by Yury Semikhatsky.
index ded40b5..20c7bb9 100644 (file)
@@ -533,6 +533,9 @@ bool MediaQueryEvaluator::eval(const MediaQueryExp* expr) const
     if (!m_frame || !m_style)
         return m_expResult;
 
+    if (!expr->isValid())
+        return false;
+
     if (!gFunctionMap)
         createFunctionMap();
 
index 7ba6d84..53c0b73 100644 (file)
@@ -37,6 +37,7 @@ namespace WebCore {
 MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueList* valueList)
     : m_mediaFeature(mediaFeature)
     , m_value(0)
+    , m_isValid(true)
 {
     if (valueList) {
         if (valueList->size() == 1) {
@@ -73,6 +74,7 @@ MediaQueryExp::MediaQueryExp(const AtomicString& mediaFeature, CSSParserValueLis
             if (isValid)
                 m_value = list.release();
         }
+        m_isValid = m_value;
     }
 }
 
index fd55cf6..9272402 100644 (file)
@@ -52,6 +52,8 @@ public:
                 || (other.m_value && m_value && other.m_value->cssText() == m_value->cssText()));
     }
 
+    bool isValid() const { return m_isValid; }
+
     bool isViewportDependent() const { return m_mediaFeature == MediaFeatureNames::widthMediaFeature || 
                                               m_mediaFeature == MediaFeatureNames::heightMediaFeature ||
                                               m_mediaFeature == MediaFeatureNames::min_widthMediaFeature ||
@@ -65,6 +67,7 @@ public:
 private:
     AtomicString m_mediaFeature;
     RefPtr<CSSValue> m_value;
+    bool m_isValid;
 };
 
 } // namespace