Fix handling of 'orienation' feature in print-preview. (Bug 468645) r+sr=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Mon, 29 Dec 2008 10:07:36 -0500
changeset 23165 ffd1fe854d954e840ba4670d885664f9825d0d6d
parent 23164 efbec418c3a14069a320d32adfec232b0aa97de9
child 23166 e09da908f8b4b045f7704173b903f22427bbc482
push id4370
push userdbaron@mozilla.com
push dateMon, 29 Dec 2008 15:14:13 +0000
treeherdermozilla-central@fb2f301f6d0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs468645
milestone1.9.2a1pre
Fix handling of 'orienation' feature in print-preview. (Bug 468645) r+sr=bzbarsky
layout/reftests/css-mediaqueries/mq_print_orientation.xhtml
layout/style/nsMediaFeatures.cpp
--- a/layout/reftests/css-mediaqueries/mq_print_orientation.xhtml
+++ b/layout/reftests/css-mediaqueries/mq_print_orientation.xhtml
@@ -1,32 +1,32 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD landscapeHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" class="reftest-print">
 <head>
   <title>Media Query - Print mode test - orientation</title>
   <style type="text/css"><![CDATA[
     p {height: 10px; width: 100px; color: yellow; }
     @media print { .a { color: aqua; } }
     @media screen { .b { color: aqua; } }
 
-    /* using orientation portrait works.  we are a 5/3 which is landscape though */
-    @media (orientation: portrait) { .c { color: aqua; } }    /* y */
-    @media print and (orientation: portrait) { .d {color: aqua; } }  /* y */
-    @media all and (orientation: portrait) { .e { color: aqua; } } /* y */
+    /* Print reftests are 5/3, which is landscape. */
+    @media (orientation: landscape) { .c { color: aqua; } }    /* y */
+    @media print and (orientation: landscape) { .d {color: aqua; } }  /* y */
+    @media all and (orientation: landscape) { .e { color: aqua; } } /* y */
 
 
     /* negative cases */
-    @media all and (orientation: landscape) { .f { color: aqua; } } /* n */
+    @media all and (orientation: portrait) { .f { color: aqua; } } /* n */
 
-    @media (orientation: landscape) { .g { color: aqua; } } /* n */
-    @media print and (orientation: landscape) { .h { color: aqua; } }  /* n */
+    @media (orientation: portrait) { .g { color: aqua; } } /* n */
+    @media print and (orientation: portrait) { .h { color: aqua; } }  /* n */
 
-    @media screen and (orientation: portrait) { .i {color: aqua; } }   /* n */
-    @media screen and (orientation: landscape) { .j {color: aqua; } } /* n */
+    @media screen and (orientation: landscape) { .i {color: aqua; } }   /* n */
+    @media screen and (orientation: portrait) { .j {color: aqua; } } /* n */
 
   ]]></style>
 </head>
 
 <body>
   <p class="a">a</p>
   <p class="b">b</p>
   <p class="c">c</p>
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -54,17 +54,17 @@ static const PRInt32 kOrientationKeyword
 };
 
 static const PRInt32 kScanKeywords[] = {
   eCSSKeyword_progressive,              NS_STYLE_SCAN_PROGRESSIVE,
   eCSSKeyword_interlace,                NS_STYLE_SCAN_INTERLACE,
   eCSSKeyword_UNKNOWN,                  -1
 };
 
-// A helper for three features below
+// A helper for four features below
 static nsSize
 GetSize(nsPresContext* aPresContext)
 {
     nsSize size;
     if (aPresContext->IsRootPaginatedDocument())
         // We want the page size, including unprintable areas and margins.
         size = aPresContext->GetPageSize();
     else
@@ -138,17 +138,17 @@ GetDeviceHeight(nsPresContext* aPresCont
     float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height);
     aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel);
     return NS_OK;
 }
 
 static nsresult
 GetOrientation(nsPresContext* aPresContext, nsCSSValue& aResult)
 {
-    nsSize size = aPresContext->GetVisibleArea().Size();
+    nsSize size = GetSize(aPresContext);
     PRInt32 orientation;
     if (size.width > size.height) {
         orientation = NS_STYLE_ORIENTATION_LANDSCAPE;
     } else {
         // Per spec, square viewports should be 'portrait'
         orientation = NS_STYLE_ORIENTATION_PORTRAIT;
     }