Bug 686581 - Implement -moz-is-resource-document media query. r=roc
authorMats Palmgren <matspal@gmail.com>
Sat, 24 Sep 2011 10:28:54 +0200
changeset 77460 c764918036ab50a93c44c906597e4044ea7a553f
parent 77459 d5727cb7221b318d11d940daa5d67836ec8ca515
child 77461 8068ef5b4dcbd057b25457dafc8e0cf747006e8c
push id2128
push usermpalmgren@mozilla.com
push dateSat, 24 Sep 2011 08:28:34 +0000
treeherdermozilla-inbound@8068ef5b4dcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs686581
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 686581 - Implement -moz-is-resource-document media query. r=roc
content/base/src/nsGkAtomList.h
layout/style/nsMediaFeatures.cpp
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1897,16 +1897,17 @@ GK_ATOM(_moz_mac_lion_theme, "-moz-mac-l
 GK_ATOM(_moz_windows_compositor, "-moz-windows-compositor")
 GK_ATOM(_moz_windows_classic, "-moz-windows-classic")
 GK_ATOM(_moz_windows_theme, "-moz-windows-theme")
 GK_ATOM(_moz_touch_enabled, "-moz-touch-enabled")
 GK_ATOM(_moz_maemo_classic, "-moz-maemo-classic")
 GK_ATOM(_moz_menubar_drag, "-moz-menubar-drag")
 GK_ATOM(_moz_device_pixel_ratio, "-moz-device-pixel-ratio")
 GK_ATOM(_moz_device_orientation, "-moz-device-orientation")
+GK_ATOM(_moz_is_resource_document, "-moz-is-resource-document")
 
 #ifdef ACCESSIBILITY
 GK_ATOM(anonid, "anonid")
 GK_ATOM(aria_activedescendant, "aria-activedescendant")
 GK_ATOM(aria_atomic, "aria-atomic")
 GK_ATOM(aria_autocomplete, "aria-autocomplete")
 GK_ATOM(aria_busy, "aria-busy")
 GK_ATOM(aria_checked, "aria-checked")
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -189,16 +189,25 @@ GetDeviceOrientation(nsPresContext* aPre
         // Per spec, square viewports should be 'portrait'
         orientation = NS_STYLE_ORIENTATION_PORTRAIT;
     }
 
     aResult.SetIntValue(orientation, eCSSUnit_Enumerated);
     return NS_OK;
 }
 
+static nsresult
+GetIsResourceDocument(nsPresContext* aPresContext, const nsMediaFeature*,
+                      nsCSSValue& aResult)
+{
+  nsIDocument* doc = aPresContext->Document();
+  aResult.SetIntValue(doc && doc->IsResourceDoc() ? 1 : 0, eCSSUnit_Integer);
+  return NS_OK;
+}
+
 // Helper for two features below
 static nsresult
 MakeArray(const nsSize& aSize, nsCSSValue& aResult)
 {
     nsRefPtr<nsCSSValue::Array> a = nsCSSValue::Array::Create(2);
 
     a->Item(0).SetIntValue(aSize.width, eCSSUnit_Integer);
     a->Item(1).SetIntValue(aSize.height, eCSSUnit_Integer);
@@ -456,16 +465,23 @@ nsMediaFeatures::features[] = {
     {
         &nsGkAtoms::_moz_device_orientation,
         nsMediaFeature::eMinMaxNotAllowed,
         nsMediaFeature::eEnumerated,
         { kOrientationKeywords },
         GetDeviceOrientation
     },
     {
+        &nsGkAtoms::_moz_is_resource_document,
+        nsMediaFeature::eMinMaxNotAllowed,
+        nsMediaFeature::eBoolInteger,
+        { nsnull },
+        GetIsResourceDocument
+    },
+    {
         &nsGkAtoms::_moz_scrollbar_start_backward,
         nsMediaFeature::eMinMaxNotAllowed,
         nsMediaFeature::eBoolInteger,
         { &nsGkAtoms::scrollbar_start_backward },
         GetSystemMetric
     },
     {
         &nsGkAtoms::_moz_scrollbar_start_forward,