layout/style/nsMediaFeatures.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/nsMediaFeatures.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,686 @@
     1.4 +/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/* the features that media queries can test */
    1.10 +
    1.11 +#include "nsMediaFeatures.h"
    1.12 +#include "nsGkAtoms.h"
    1.13 +#include "nsCSSKeywords.h"
    1.14 +#include "nsStyleConsts.h"
    1.15 +#include "nsPresContext.h"
    1.16 +#include "nsCSSValue.h"
    1.17 +#ifdef XP_WIN
    1.18 +#include "mozilla/LookAndFeel.h"
    1.19 +#endif
    1.20 +#include "nsCSSRuleProcessor.h"
    1.21 +#include "nsDeviceContext.h"
    1.22 +#include "nsIDocument.h"
    1.23 +
    1.24 +using namespace mozilla;
    1.25 +
    1.26 +static const nsCSSProps::KTableValue kOrientationKeywords[] = {
    1.27 +  eCSSKeyword_portrait,                 NS_STYLE_ORIENTATION_PORTRAIT,
    1.28 +  eCSSKeyword_landscape,                NS_STYLE_ORIENTATION_LANDSCAPE,
    1.29 +  eCSSKeyword_UNKNOWN,                  -1
    1.30 +};
    1.31 +
    1.32 +static const nsCSSProps::KTableValue kScanKeywords[] = {
    1.33 +  eCSSKeyword_progressive,              NS_STYLE_SCAN_PROGRESSIVE,
    1.34 +  eCSSKeyword_interlace,                NS_STYLE_SCAN_INTERLACE,
    1.35 +  eCSSKeyword_UNKNOWN,                  -1
    1.36 +};
    1.37 +
    1.38 +#ifdef XP_WIN
    1.39 +struct WindowsThemeName {
    1.40 +    LookAndFeel::WindowsTheme id;
    1.41 +    const wchar_t* name;
    1.42 +};
    1.43 +
    1.44 +// Windows theme identities used in the -moz-windows-theme media query.
    1.45 +const WindowsThemeName themeStrings[] = {
    1.46 +    { LookAndFeel::eWindowsTheme_Aero,       L"aero" },
    1.47 +    { LookAndFeel::eWindowsTheme_AeroLite,   L"aero-lite" },
    1.48 +    { LookAndFeel::eWindowsTheme_LunaBlue,   L"luna-blue" },
    1.49 +    { LookAndFeel::eWindowsTheme_LunaOlive,  L"luna-olive" },
    1.50 +    { LookAndFeel::eWindowsTheme_LunaSilver, L"luna-silver" },
    1.51 +    { LookAndFeel::eWindowsTheme_Royale,     L"royale" },
    1.52 +    { LookAndFeel::eWindowsTheme_Zune,       L"zune" },
    1.53 +    { LookAndFeel::eWindowsTheme_Generic,    L"generic" }
    1.54 +};
    1.55 +
    1.56 +struct OperatingSystemVersionInfo {
    1.57 +    LookAndFeel::OperatingSystemVersion id;
    1.58 +    const wchar_t* name;
    1.59 +};
    1.60 +
    1.61 +// Os version identities used in the -moz-os-version media query.
    1.62 +const OperatingSystemVersionInfo osVersionStrings[] = {
    1.63 +    { LookAndFeel::eOperatingSystemVersion_WindowsXP,     L"windows-xp" },
    1.64 +    { LookAndFeel::eOperatingSystemVersion_WindowsVista,  L"windows-vista" },
    1.65 +    { LookAndFeel::eOperatingSystemVersion_Windows7,      L"windows-win7" },
    1.66 +    { LookAndFeel::eOperatingSystemVersion_Windows8,      L"windows-win8" },
    1.67 +};
    1.68 +#endif
    1.69 +
    1.70 +// A helper for four features below
    1.71 +static nsSize
    1.72 +GetSize(nsPresContext* aPresContext)
    1.73 +{
    1.74 +    nsSize size;
    1.75 +    if (aPresContext->IsRootPaginatedDocument())
    1.76 +        // We want the page size, including unprintable areas and margins.
    1.77 +        size = aPresContext->GetPageSize();
    1.78 +    else
    1.79 +        size = aPresContext->GetVisibleArea().Size();
    1.80 +    return size;
    1.81 +}
    1.82 +
    1.83 +static nsresult
    1.84 +GetWidth(nsPresContext* aPresContext, const nsMediaFeature*,
    1.85 +         nsCSSValue& aResult)
    1.86 +{
    1.87 +    nsSize size = GetSize(aPresContext);
    1.88 +    float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width);
    1.89 +    aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel);
    1.90 +    return NS_OK;
    1.91 +}
    1.92 +
    1.93 +static nsresult
    1.94 +GetHeight(nsPresContext* aPresContext, const nsMediaFeature*,
    1.95 +          nsCSSValue& aResult)
    1.96 +{
    1.97 +    nsSize size = GetSize(aPresContext);
    1.98 +    float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height);
    1.99 +    aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel);
   1.100 +    return NS_OK;
   1.101 +}
   1.102 +
   1.103 +inline static nsDeviceContext*
   1.104 +GetDeviceContextFor(nsPresContext* aPresContext)
   1.105 +{
   1.106 +  // It would be nice to call
   1.107 +  // nsLayoutUtils::GetDeviceContextForScreenInfo here, except for two
   1.108 +  // things:  (1) it can flush, and flushing is bad here, and (2) it
   1.109 +  // doesn't really get us consistency in multi-monitor situations
   1.110 +  // *anyway*.
   1.111 +  return aPresContext->DeviceContext();
   1.112 +}
   1.113 +
   1.114 +// A helper for three features below.
   1.115 +static nsSize
   1.116 +GetDeviceSize(nsPresContext* aPresContext)
   1.117 +{
   1.118 +    nsSize size;
   1.119 +
   1.120 +    if (!aPresContext->IsChrome() || aPresContext->IsDeviceSizePageSize()) {
   1.121 +        size = GetSize(aPresContext);
   1.122 +    } else if (aPresContext->IsRootPaginatedDocument()) {
   1.123 +        // We want the page size, including unprintable areas and margins.
   1.124 +        // XXX The spec actually says we want the "page sheet size", but
   1.125 +        // how is that different?
   1.126 +        size = aPresContext->GetPageSize();
   1.127 +    } else {
   1.128 +        GetDeviceContextFor(aPresContext)->
   1.129 +            GetDeviceSurfaceDimensions(size.width, size.height);
   1.130 +    }
   1.131 +    return size;
   1.132 +}
   1.133 +
   1.134 +static nsresult
   1.135 +GetDeviceWidth(nsPresContext* aPresContext, const nsMediaFeature*,
   1.136 +               nsCSSValue& aResult)
   1.137 +{
   1.138 +    nsSize size = GetDeviceSize(aPresContext);
   1.139 +    float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width);
   1.140 +    aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel);
   1.141 +    return NS_OK;
   1.142 +}
   1.143 +
   1.144 +static nsresult
   1.145 +GetDeviceHeight(nsPresContext* aPresContext, const nsMediaFeature*,
   1.146 +                nsCSSValue& aResult)
   1.147 +{
   1.148 +    nsSize size = GetDeviceSize(aPresContext);
   1.149 +    float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height);
   1.150 +    aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel);
   1.151 +    return NS_OK;
   1.152 +}
   1.153 +
   1.154 +static nsresult
   1.155 +GetOrientation(nsPresContext* aPresContext, const nsMediaFeature*,
   1.156 +               nsCSSValue& aResult)
   1.157 +{
   1.158 +    nsSize size = GetSize(aPresContext);
   1.159 +    int32_t orientation;
   1.160 +    if (size.width > size.height) {
   1.161 +        orientation = NS_STYLE_ORIENTATION_LANDSCAPE;
   1.162 +    } else {
   1.163 +        // Per spec, square viewports should be 'portrait'
   1.164 +        orientation = NS_STYLE_ORIENTATION_PORTRAIT;
   1.165 +    }
   1.166 +
   1.167 +    aResult.SetIntValue(orientation, eCSSUnit_Enumerated);
   1.168 +    return NS_OK;
   1.169 +}
   1.170 +
   1.171 +static nsresult
   1.172 +GetDeviceOrientation(nsPresContext* aPresContext, const nsMediaFeature*,
   1.173 +                     nsCSSValue& aResult)
   1.174 +{
   1.175 +    nsSize size = GetDeviceSize(aPresContext);
   1.176 +    int32_t orientation;
   1.177 +    if (size.width > size.height) {
   1.178 +        orientation = NS_STYLE_ORIENTATION_LANDSCAPE;
   1.179 +    } else {
   1.180 +        // Per spec, square viewports should be 'portrait'
   1.181 +        orientation = NS_STYLE_ORIENTATION_PORTRAIT;
   1.182 +    }
   1.183 +
   1.184 +    aResult.SetIntValue(orientation, eCSSUnit_Enumerated);
   1.185 +    return NS_OK;
   1.186 +}
   1.187 +
   1.188 +static nsresult
   1.189 +GetIsResourceDocument(nsPresContext* aPresContext, const nsMediaFeature*,
   1.190 +                      nsCSSValue& aResult)
   1.191 +{
   1.192 +  nsIDocument* doc = aPresContext->Document();
   1.193 +  aResult.SetIntValue(doc && doc->IsResourceDoc() ? 1 : 0, eCSSUnit_Integer);
   1.194 +  return NS_OK;
   1.195 +}
   1.196 +
   1.197 +// Helper for two features below
   1.198 +static nsresult
   1.199 +MakeArray(const nsSize& aSize, nsCSSValue& aResult)
   1.200 +{
   1.201 +    nsRefPtr<nsCSSValue::Array> a = nsCSSValue::Array::Create(2);
   1.202 +
   1.203 +    a->Item(0).SetIntValue(aSize.width, eCSSUnit_Integer);
   1.204 +    a->Item(1).SetIntValue(aSize.height, eCSSUnit_Integer);
   1.205 +
   1.206 +    aResult.SetArrayValue(a, eCSSUnit_Array);
   1.207 +    return NS_OK;
   1.208 +}
   1.209 +
   1.210 +static nsresult
   1.211 +GetAspectRatio(nsPresContext* aPresContext, const nsMediaFeature*,
   1.212 +               nsCSSValue& aResult)
   1.213 +{
   1.214 +    return MakeArray(GetSize(aPresContext), aResult);
   1.215 +}
   1.216 +
   1.217 +static nsresult
   1.218 +GetDeviceAspectRatio(nsPresContext* aPresContext, const nsMediaFeature*,
   1.219 +                     nsCSSValue& aResult)
   1.220 +{
   1.221 +    return MakeArray(GetDeviceSize(aPresContext), aResult);
   1.222 +}
   1.223 +
   1.224 +static nsresult
   1.225 +GetColor(nsPresContext* aPresContext, const nsMediaFeature*,
   1.226 +         nsCSSValue& aResult)
   1.227 +{
   1.228 +    uint32_t depth = 24; // Always assume 24-bit depth for non-chrome callers.
   1.229 +
   1.230 +    if (aPresContext->IsChrome()) {
   1.231 +        // FIXME:  This implementation is bogus.  nsDeviceContext
   1.232 +        // doesn't provide reliable information (should be fixed in bug
   1.233 +        // 424386).
   1.234 +        // FIXME: On a monochrome device, return 0!
   1.235 +        nsDeviceContext *dx = GetDeviceContextFor(aPresContext);
   1.236 +        dx->GetDepth(depth);
   1.237 +    }
   1.238 +
   1.239 +    // The spec says to use bits *per color component*, so divide by 3,
   1.240 +    // and round down, since the spec says to use the smallest when the
   1.241 +    // color components differ.
   1.242 +    depth /= 3;
   1.243 +    aResult.SetIntValue(int32_t(depth), eCSSUnit_Integer);
   1.244 +    return NS_OK;
   1.245 +}
   1.246 +
   1.247 +static nsresult
   1.248 +GetColorIndex(nsPresContext* aPresContext, const nsMediaFeature*,
   1.249 +              nsCSSValue& aResult)
   1.250 +{
   1.251 +    // We should return zero if the device does not use a color lookup
   1.252 +    // table.  Stuart says that our handling of displays with 8-bit
   1.253 +    // color is bad enough that we never change the lookup table to
   1.254 +    // match what we're trying to display, so perhaps we should always
   1.255 +    // return zero.  Given that there isn't any better information
   1.256 +    // exposed, we don't have much other choice.
   1.257 +    aResult.SetIntValue(0, eCSSUnit_Integer);
   1.258 +    return NS_OK;
   1.259 +}
   1.260 +
   1.261 +static nsresult
   1.262 +GetMonochrome(nsPresContext* aPresContext, const nsMediaFeature*,
   1.263 +              nsCSSValue& aResult)
   1.264 +{
   1.265 +    // For color devices we should return 0.
   1.266 +    // FIXME: On a monochrome device, return the actual color depth, not
   1.267 +    // 0!
   1.268 +    aResult.SetIntValue(0, eCSSUnit_Integer);
   1.269 +    return NS_OK;
   1.270 +}
   1.271 +
   1.272 +static nsresult
   1.273 +GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
   1.274 +              nsCSSValue& aResult)
   1.275 +{
   1.276 +    float dpi = 96; // Always return 96 to non-chrome callers.
   1.277 +
   1.278 +    if (aPresContext->IsChrome()) {
   1.279 +      // Resolution measures device pixels per CSS (inch/cm/pixel).  We
   1.280 +      // return it in device pixels per CSS inches.
   1.281 +      dpi = float(nsPresContext::AppUnitsPerCSSInch()) /
   1.282 +            float(aPresContext->AppUnitsPerDevPixel());
   1.283 +    }
   1.284 +
   1.285 +    aResult.SetFloatValue(dpi, eCSSUnit_Inch);
   1.286 +    return NS_OK;
   1.287 +}
   1.288 +
   1.289 +static nsresult
   1.290 +GetScan(nsPresContext* aPresContext, const nsMediaFeature*,
   1.291 +        nsCSSValue& aResult)
   1.292 +{
   1.293 +    // Since Gecko doesn't support the 'tv' media type, the 'scan'
   1.294 +    // feature is never present.
   1.295 +    aResult.Reset();
   1.296 +    return NS_OK;
   1.297 +}
   1.298 +
   1.299 +static nsresult
   1.300 +GetGrid(nsPresContext* aPresContext, const nsMediaFeature*,
   1.301 +        nsCSSValue& aResult)
   1.302 +{
   1.303 +    // Gecko doesn't support grid devices (e.g., ttys), so the 'grid'
   1.304 +    // feature is always 0.
   1.305 +    aResult.SetIntValue(0, eCSSUnit_Integer);
   1.306 +    return NS_OK;
   1.307 +}
   1.308 +
   1.309 +static nsresult
   1.310 +GetDevicePixelRatio(nsPresContext* aPresContext, const nsMediaFeature*,
   1.311 +                    nsCSSValue& aResult)
   1.312 +{
   1.313 +    if (aPresContext->IsChrome()) {
   1.314 +        float ratio = aPresContext->CSSPixelsToDevPixels(1.0f);
   1.315 +        aResult.SetFloatValue(ratio, eCSSUnit_Number);
   1.316 +    } else {
   1.317 +        aResult.SetFloatValue(1.0, eCSSUnit_Number);
   1.318 +    }
   1.319 +    return NS_OK;
   1.320 +}
   1.321 +
   1.322 +static nsresult
   1.323 +GetSystemMetric(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
   1.324 +                nsCSSValue& aResult)
   1.325 +{
   1.326 +    aResult.Reset();
   1.327 +    if (aPresContext->IsChrome()) {
   1.328 +        NS_ABORT_IF_FALSE(aFeature->mValueType == nsMediaFeature::eBoolInteger,
   1.329 +                          "unexpected type");
   1.330 +        nsIAtom *metricAtom = *aFeature->mData.mMetric;
   1.331 +        bool hasMetric = nsCSSRuleProcessor::HasSystemMetric(metricAtom);
   1.332 +        aResult.SetIntValue(hasMetric ? 1 : 0, eCSSUnit_Integer);
   1.333 +    }
   1.334 +    return NS_OK;
   1.335 +}
   1.336 +
   1.337 +static nsresult
   1.338 +GetWindowsTheme(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
   1.339 +                nsCSSValue& aResult)
   1.340 +{
   1.341 +    aResult.Reset();
   1.342 +#ifdef XP_WIN
   1.343 +    if (aPresContext->IsChrome()) {
   1.344 +        uint8_t windowsThemeId =
   1.345 +            nsCSSRuleProcessor::GetWindowsThemeIdentifier();
   1.346 +
   1.347 +        // Classic mode should fail to match.
   1.348 +        if (windowsThemeId == LookAndFeel::eWindowsTheme_Classic)
   1.349 +            return NS_OK;
   1.350 +
   1.351 +        // Look up the appropriate theme string
   1.352 +        for (size_t i = 0; i < ArrayLength(themeStrings); ++i) {
   1.353 +            if (windowsThemeId == themeStrings[i].id) {
   1.354 +                aResult.SetStringValue(nsDependentString(themeStrings[i].name),
   1.355 +                                       eCSSUnit_Ident);
   1.356 +                break;
   1.357 +            }
   1.358 +        }
   1.359 +    }
   1.360 +#endif
   1.361 +    return NS_OK;
   1.362 +}
   1.363 +
   1.364 +static nsresult
   1.365 +GetOperatinSystemVersion(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
   1.366 +                         nsCSSValue& aResult)
   1.367 +{
   1.368 +    aResult.Reset();
   1.369 +    if (!aPresContext->IsChrome()) return NS_OK;
   1.370 +
   1.371 +#ifdef XP_WIN
   1.372 +    int32_t metricResult;
   1.373 +    if (NS_SUCCEEDED(
   1.374 +          LookAndFeel::GetInt(LookAndFeel::eIntID_OperatingSystemVersionIdentifier,
   1.375 +                              &metricResult))) {
   1.376 +        for (size_t i = 0; i < ArrayLength(osVersionStrings); ++i) {
   1.377 +            if (metricResult == osVersionStrings[i].id) {
   1.378 +                aResult.SetStringValue(nsDependentString(osVersionStrings[i].name),
   1.379 +                                       eCSSUnit_Ident);
   1.380 +                break;
   1.381 +            }
   1.382 +        }
   1.383 +    }
   1.384 +#endif
   1.385 +    return NS_OK;
   1.386 +}
   1.387 +
   1.388 +static nsresult
   1.389 +GetIsGlyph(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
   1.390 +          nsCSSValue& aResult)
   1.391 +{
   1.392 +    aResult.SetIntValue(aPresContext->IsGlyph() ? 1 : 0, eCSSUnit_Integer);
   1.393 +    return NS_OK;
   1.394 +}
   1.395 +
   1.396 +/*
   1.397 + * Adding new media features requires (1) adding the new feature to this
   1.398 + * array, with appropriate entries (and potentially any new code needed
   1.399 + * to support new types in these entries and (2) ensuring that either
   1.400 + * nsPresContext::MediaFeatureValuesChanged or
   1.401 + * nsPresContext::PostMediaFeatureValuesChangedEvent is called when the
   1.402 + * value that would be returned by the entry's mGetter changes.
   1.403 + */
   1.404 +
   1.405 +/* static */ const nsMediaFeature
   1.406 +nsMediaFeatures::features[] = {
   1.407 +    {
   1.408 +        &nsGkAtoms::width,
   1.409 +        nsMediaFeature::eMinMaxAllowed,
   1.410 +        nsMediaFeature::eLength,
   1.411 +        { nullptr },
   1.412 +        GetWidth
   1.413 +    },
   1.414 +    {
   1.415 +        &nsGkAtoms::height,
   1.416 +        nsMediaFeature::eMinMaxAllowed,
   1.417 +        nsMediaFeature::eLength,
   1.418 +        { nullptr },
   1.419 +        GetHeight
   1.420 +    },
   1.421 +    {
   1.422 +        &nsGkAtoms::deviceWidth,
   1.423 +        nsMediaFeature::eMinMaxAllowed,
   1.424 +        nsMediaFeature::eLength,
   1.425 +        { nullptr },
   1.426 +        GetDeviceWidth
   1.427 +    },
   1.428 +    {
   1.429 +        &nsGkAtoms::deviceHeight,
   1.430 +        nsMediaFeature::eMinMaxAllowed,
   1.431 +        nsMediaFeature::eLength,
   1.432 +        { nullptr },
   1.433 +        GetDeviceHeight
   1.434 +    },
   1.435 +    {
   1.436 +        &nsGkAtoms::orientation,
   1.437 +        nsMediaFeature::eMinMaxNotAllowed,
   1.438 +        nsMediaFeature::eEnumerated,
   1.439 +        { kOrientationKeywords },
   1.440 +        GetOrientation
   1.441 +    },
   1.442 +    {
   1.443 +        &nsGkAtoms::aspectRatio,
   1.444 +        nsMediaFeature::eMinMaxAllowed,
   1.445 +        nsMediaFeature::eIntRatio,
   1.446 +        { nullptr },
   1.447 +        GetAspectRatio
   1.448 +    },
   1.449 +    {
   1.450 +        &nsGkAtoms::deviceAspectRatio,
   1.451 +        nsMediaFeature::eMinMaxAllowed,
   1.452 +        nsMediaFeature::eIntRatio,
   1.453 +        { nullptr },
   1.454 +        GetDeviceAspectRatio
   1.455 +    },
   1.456 +    {
   1.457 +        &nsGkAtoms::color,
   1.458 +        nsMediaFeature::eMinMaxAllowed,
   1.459 +        nsMediaFeature::eInteger,
   1.460 +        { nullptr },
   1.461 +        GetColor
   1.462 +    },
   1.463 +    {
   1.464 +        &nsGkAtoms::colorIndex,
   1.465 +        nsMediaFeature::eMinMaxAllowed,
   1.466 +        nsMediaFeature::eInteger,
   1.467 +        { nullptr },
   1.468 +        GetColorIndex
   1.469 +    },
   1.470 +    {
   1.471 +        &nsGkAtoms::monochrome,
   1.472 +        nsMediaFeature::eMinMaxAllowed,
   1.473 +        nsMediaFeature::eInteger,
   1.474 +        { nullptr },
   1.475 +        GetMonochrome
   1.476 +    },
   1.477 +    {
   1.478 +        &nsGkAtoms::resolution,
   1.479 +        nsMediaFeature::eMinMaxAllowed,
   1.480 +        nsMediaFeature::eResolution,
   1.481 +        { nullptr },
   1.482 +        GetResolution
   1.483 +    },
   1.484 +    {
   1.485 +        &nsGkAtoms::scan,
   1.486 +        nsMediaFeature::eMinMaxNotAllowed,
   1.487 +        nsMediaFeature::eEnumerated,
   1.488 +        { kScanKeywords },
   1.489 +        GetScan
   1.490 +    },
   1.491 +    {
   1.492 +        &nsGkAtoms::grid,
   1.493 +        nsMediaFeature::eMinMaxNotAllowed,
   1.494 +        nsMediaFeature::eBoolInteger,
   1.495 +        { nullptr },
   1.496 +        GetGrid
   1.497 +    },
   1.498 +
   1.499 +    // Mozilla extensions
   1.500 +    {
   1.501 +        &nsGkAtoms::_moz_device_pixel_ratio,
   1.502 +        nsMediaFeature::eMinMaxAllowed,
   1.503 +        nsMediaFeature::eFloat,
   1.504 +        { nullptr },
   1.505 +        GetDevicePixelRatio
   1.506 +    },
   1.507 +    {
   1.508 +        &nsGkAtoms::_moz_device_orientation,
   1.509 +        nsMediaFeature::eMinMaxNotAllowed,
   1.510 +        nsMediaFeature::eEnumerated,
   1.511 +        { kOrientationKeywords },
   1.512 +        GetDeviceOrientation
   1.513 +    },
   1.514 +    {
   1.515 +        &nsGkAtoms::_moz_is_resource_document,
   1.516 +        nsMediaFeature::eMinMaxNotAllowed,
   1.517 +        nsMediaFeature::eBoolInteger,
   1.518 +        { nullptr },
   1.519 +        GetIsResourceDocument
   1.520 +    },
   1.521 +    {
   1.522 +        &nsGkAtoms::_moz_color_picker_available,
   1.523 +        nsMediaFeature::eMinMaxNotAllowed,
   1.524 +        nsMediaFeature::eBoolInteger,
   1.525 +        { &nsGkAtoms::color_picker_available },
   1.526 +        GetSystemMetric
   1.527 +    },
   1.528 +    {
   1.529 +        &nsGkAtoms::_moz_scrollbar_start_backward,
   1.530 +        nsMediaFeature::eMinMaxNotAllowed,
   1.531 +        nsMediaFeature::eBoolInteger,
   1.532 +        { &nsGkAtoms::scrollbar_start_backward },
   1.533 +        GetSystemMetric
   1.534 +    },
   1.535 +    {
   1.536 +        &nsGkAtoms::_moz_scrollbar_start_forward,
   1.537 +        nsMediaFeature::eMinMaxNotAllowed,
   1.538 +        nsMediaFeature::eBoolInteger,
   1.539 +        { &nsGkAtoms::scrollbar_start_forward },
   1.540 +        GetSystemMetric
   1.541 +    },
   1.542 +    {
   1.543 +        &nsGkAtoms::_moz_scrollbar_end_backward,
   1.544 +        nsMediaFeature::eMinMaxNotAllowed,
   1.545 +        nsMediaFeature::eBoolInteger,
   1.546 +        { &nsGkAtoms::scrollbar_end_backward },
   1.547 +        GetSystemMetric
   1.548 +    },
   1.549 +    {
   1.550 +        &nsGkAtoms::_moz_scrollbar_end_forward,
   1.551 +        nsMediaFeature::eMinMaxNotAllowed,
   1.552 +        nsMediaFeature::eBoolInteger,
   1.553 +        { &nsGkAtoms::scrollbar_end_forward },
   1.554 +        GetSystemMetric
   1.555 +    },
   1.556 +    {
   1.557 +        &nsGkAtoms::_moz_scrollbar_thumb_proportional,
   1.558 +        nsMediaFeature::eMinMaxNotAllowed,
   1.559 +        nsMediaFeature::eBoolInteger,
   1.560 +        { &nsGkAtoms::scrollbar_thumb_proportional },
   1.561 +        GetSystemMetric
   1.562 +    },
   1.563 +    {
   1.564 +        &nsGkAtoms::_moz_images_in_menus,
   1.565 +        nsMediaFeature::eMinMaxNotAllowed,
   1.566 +        nsMediaFeature::eBoolInteger,
   1.567 +        { &nsGkAtoms::images_in_menus },
   1.568 +        GetSystemMetric
   1.569 +    },
   1.570 +    {
   1.571 +        &nsGkAtoms::_moz_images_in_buttons,
   1.572 +        nsMediaFeature::eMinMaxNotAllowed,
   1.573 +        nsMediaFeature::eBoolInteger,
   1.574 +        { &nsGkAtoms::images_in_buttons },
   1.575 +        GetSystemMetric
   1.576 +    },
   1.577 +    {
   1.578 +        &nsGkAtoms::_moz_overlay_scrollbars,
   1.579 +        nsMediaFeature::eMinMaxNotAllowed,
   1.580 +        nsMediaFeature::eBoolInteger,
   1.581 +        { &nsGkAtoms::overlay_scrollbars },
   1.582 +        GetSystemMetric
   1.583 +    },
   1.584 +    {
   1.585 +        &nsGkAtoms::_moz_windows_default_theme,
   1.586 +        nsMediaFeature::eMinMaxNotAllowed,
   1.587 +        nsMediaFeature::eBoolInteger,
   1.588 +        { &nsGkAtoms::windows_default_theme },
   1.589 +        GetSystemMetric
   1.590 +    },
   1.591 +    {
   1.592 +        &nsGkAtoms::_moz_mac_graphite_theme,
   1.593 +        nsMediaFeature::eMinMaxNotAllowed,
   1.594 +        nsMediaFeature::eBoolInteger,
   1.595 +        { &nsGkAtoms::mac_graphite_theme },
   1.596 +        GetSystemMetric
   1.597 +    },
   1.598 +    {
   1.599 +        &nsGkAtoms::_moz_mac_lion_theme,
   1.600 +        nsMediaFeature::eMinMaxNotAllowed,
   1.601 +        nsMediaFeature::eBoolInteger,
   1.602 +        { &nsGkAtoms::mac_lion_theme },
   1.603 +        GetSystemMetric
   1.604 +    },
   1.605 +    {
   1.606 +        &nsGkAtoms::_moz_windows_compositor,
   1.607 +        nsMediaFeature::eMinMaxNotAllowed,
   1.608 +        nsMediaFeature::eBoolInteger,
   1.609 +        { &nsGkAtoms::windows_compositor },
   1.610 +        GetSystemMetric
   1.611 +    },
   1.612 +    {
   1.613 +        &nsGkAtoms::_moz_windows_classic,
   1.614 +        nsMediaFeature::eMinMaxNotAllowed,
   1.615 +        nsMediaFeature::eBoolInteger,
   1.616 +        { &nsGkAtoms::windows_classic },
   1.617 +        GetSystemMetric
   1.618 +    },
   1.619 +    {
   1.620 +        &nsGkAtoms::_moz_windows_glass,
   1.621 +        nsMediaFeature::eMinMaxNotAllowed,
   1.622 +        nsMediaFeature::eBoolInteger,
   1.623 +        { &nsGkAtoms::windows_glass },
   1.624 +        GetSystemMetric
   1.625 +    },
   1.626 +    {
   1.627 +        &nsGkAtoms::_moz_touch_enabled,
   1.628 +        nsMediaFeature::eMinMaxNotAllowed,
   1.629 +        nsMediaFeature::eBoolInteger,
   1.630 +        { &nsGkAtoms::touch_enabled },
   1.631 +        GetSystemMetric
   1.632 +    },
   1.633 +    {
   1.634 +        &nsGkAtoms::_moz_menubar_drag,
   1.635 +        nsMediaFeature::eMinMaxNotAllowed,
   1.636 +        nsMediaFeature::eBoolInteger,
   1.637 +        { &nsGkAtoms::menubar_drag },
   1.638 +        GetSystemMetric
   1.639 +    },
   1.640 +    {
   1.641 +        &nsGkAtoms::_moz_windows_theme,
   1.642 +        nsMediaFeature::eMinMaxNotAllowed,
   1.643 +        nsMediaFeature::eIdent,
   1.644 +        { nullptr },
   1.645 +        GetWindowsTheme
   1.646 +    },
   1.647 +    {
   1.648 +        &nsGkAtoms::_moz_os_version,
   1.649 +        nsMediaFeature::eMinMaxNotAllowed,
   1.650 +        nsMediaFeature::eIdent,
   1.651 +        { nullptr },
   1.652 +        GetOperatinSystemVersion
   1.653 +    },
   1.654 +
   1.655 +    {
   1.656 +        &nsGkAtoms::_moz_swipe_animation_enabled,
   1.657 +        nsMediaFeature::eMinMaxNotAllowed,
   1.658 +        nsMediaFeature::eBoolInteger,
   1.659 +        { &nsGkAtoms::swipe_animation_enabled },
   1.660 +        GetSystemMetric
   1.661 +    },
   1.662 +
   1.663 +    {
   1.664 +        &nsGkAtoms::_moz_physical_home_button,
   1.665 +        nsMediaFeature::eMinMaxNotAllowed,
   1.666 +        nsMediaFeature::eBoolInteger,
   1.667 +        { &nsGkAtoms::physical_home_button },
   1.668 +        GetSystemMetric
   1.669 +    },
   1.670 +
   1.671 +    // Internal -moz-is-glyph media feature: applies only inside SVG glyphs.
   1.672 +    // Internal because it is really only useful in the user agent anyway
   1.673 +    //  and therefore not worth standardizing.
   1.674 +    {
   1.675 +        &nsGkAtoms::_moz_is_glyph,
   1.676 +        nsMediaFeature::eMinMaxNotAllowed,
   1.677 +        nsMediaFeature::eBoolInteger,
   1.678 +        { nullptr },
   1.679 +        GetIsGlyph
   1.680 +    },
   1.681 +    // Null-mName terminator:
   1.682 +    {
   1.683 +        nullptr,
   1.684 +        nsMediaFeature::eMinMaxAllowed,
   1.685 +        nsMediaFeature::eInteger,
   1.686 +        { nullptr },
   1.687 +        nullptr
   1.688 +    },
   1.689 +};

mercurial