@media queries do not take zooming into account
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 17:19:58 +0000 (17:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Mar 2013 17:19:58 +0000 (17:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=53186

Patch by John Mellor <johnme@chromium.org> on 2013-03-08
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Fixes @media width and height to take into account full page zoom, by
adding code to MediaQueryEvaluator's width/heightMediaFeatureEval,
corresponding to the existing code in Element::clientWidth which makes
document.documentElement.clientWidth take into account page zoom.

Test: fast/media/mq-width-pagezoom.html

* css/MediaQueryEvaluator.cpp:
(WebCore::heightMediaFeatureEval):
(WebCore::widthMediaFeatureEval):

LayoutTests:

* fast/media/mq-width-pagezoom-expected.html: Added.
* fast/media/mq-width-pagezoom.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/media/mq-width-pagezoom-expected.html [new file with mode: 0644]
LayoutTests/fast/media/mq-width-pagezoom.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/MediaQueryEvaluator.cpp

index ec2cdf1..832c13a 100644 (file)
@@ -1,3 +1,13 @@
+2013-03-08  John Mellor  <johnme@chromium.org>
+
+        @media queries do not take zooming into account
+        https://bugs.webkit.org/show_bug.cgi?id=53186
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * fast/media/mq-width-pagezoom-expected.html: Added.
+        * fast/media/mq-width-pagezoom.html: Added.
+
 2013-03-08  Chris Fleizach  <cfleizach@apple.com>
 
         [Mac] [WK2] platform/mac/accessibility/press-action-is-first.html fails
diff --git a/LayoutTests/fast/media/mq-width-pagezoom-expected.html b/LayoutTests/fast/media/mq-width-pagezoom-expected.html
new file mode 100644 (file)
index 0000000..1c49cd6
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<script>
+    eventSender.zoomPageIn();
+    eventSender.zoomPageIn();
+</script>
+<style>
+    body {
+        background: green;
+    }
+</style>
+<p>
+    This page should have 144% full page zoom, hence the viewport width should
+    be 800 / 1.44 = 555.6px, which is less than 700 so the background should
+    go green.
+</p> 
\ No newline at end of file
diff --git a/LayoutTests/fast/media/mq-width-pagezoom.html b/LayoutTests/fast/media/mq-width-pagezoom.html
new file mode 100644 (file)
index 0000000..e817388
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<script>
+    eventSender.zoomPageIn();
+    eventSender.zoomPageIn();
+</script>
+<style>
+    body {
+        background: red;
+    }
+    @media (max-width: 700px) {
+        body {
+            background: green;
+        }
+    }
+</style>
+<p>
+    This page should have 144% full page zoom, hence the viewport width should
+    be 800 / 1.44 = 555.6px, which is less than 700 so the background should
+    go green.
+</p> 
\ No newline at end of file
index 65ea6bb..a55907e 100644 (file)
@@ -1,3 +1,21 @@
+2013-03-08  John Mellor  <johnme@chromium.org>
+
+        @media queries do not take zooming into account
+        https://bugs.webkit.org/show_bug.cgi?id=53186
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Fixes @media width and height to take into account full page zoom, by
+        adding code to MediaQueryEvaluator's width/heightMediaFeatureEval,
+        corresponding to the existing code in Element::clientWidth which makes
+        document.documentElement.clientWidth take into account page zoom.
+
+        Test: fast/media/mq-width-pagezoom.html
+
+        * css/MediaQueryEvaluator.cpp:
+        (WebCore::heightMediaFeatureEval):
+        (WebCore::widthMediaFeatureEval):
+
 2013-03-08  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [BlackBerry] Add stubs for DNSResolveQueue platform specific methods
index 2cf6999..b6ae623 100644 (file)
@@ -478,9 +478,12 @@ static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* f
     FrameView* view = frame->view();
 
     if (value) {
+        int height = view->layoutHeight();
+        if (RenderView* renderView = frame->document()->renderView())
+            height = adjustForAbsoluteZoom(height, renderView);
         RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
         int length;
-        return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(view->layoutHeight(), length, op);
+        return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(height, length, op);
     }
 
     return view->layoutHeight() != 0;
@@ -491,9 +494,12 @@ static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* fr
     FrameView* view = frame->view();
 
     if (value) {
+        int width = view->layoutWidth();
+        if (RenderView* renderView = frame->document()->renderView())
+            width = adjustForAbsoluteZoom(width, renderView);
         RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
         int length;
-        return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(view->layoutWidth(), length, op);
+        return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(width, length, op);
     }
 
     return view->layoutWidth() != 0;