Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : /* the features that media queries can test */
8 :
9 : #include "nsMediaFeatures.h"
10 : #include "nsGkAtoms.h"
11 : #include "nsCSSKeywords.h"
12 : #include "nsStyleConsts.h"
13 : #include "nsPresContext.h"
14 : #include "nsCSSValue.h"
15 : #ifdef XP_WIN
16 : #include "mozilla/LookAndFeel.h"
17 : #endif
18 : #include "nsCSSRuleProcessor.h"
19 : #include "nsDeviceContext.h"
20 : #include "nsIBaseWindow.h"
21 : #include "nsIDocument.h"
22 : #include "nsIWidget.h"
23 : #include "nsContentUtils.h"
24 : #include "mozilla/StyleSheet.h"
25 : #include "mozilla/StyleSheetInlines.h"
26 :
27 : using namespace mozilla;
28 :
29 : static const nsCSSProps::KTableEntry kOrientationKeywords[] = {
30 : { eCSSKeyword_portrait, NS_STYLE_ORIENTATION_PORTRAIT },
31 : { eCSSKeyword_landscape, NS_STYLE_ORIENTATION_LANDSCAPE },
32 : { eCSSKeyword_UNKNOWN, -1 }
33 : };
34 :
35 : static const nsCSSProps::KTableEntry kScanKeywords[] = {
36 : { eCSSKeyword_progressive, NS_STYLE_SCAN_PROGRESSIVE },
37 : { eCSSKeyword_interlace, NS_STYLE_SCAN_INTERLACE },
38 : { eCSSKeyword_UNKNOWN, -1 }
39 : };
40 :
41 : static const nsCSSProps::KTableEntry kDisplayModeKeywords[] = {
42 : { eCSSKeyword_browser, NS_STYLE_DISPLAY_MODE_BROWSER },
43 : { eCSSKeyword_minimal_ui, NS_STYLE_DISPLAY_MODE_MINIMAL_UI },
44 : { eCSSKeyword_standalone, NS_STYLE_DISPLAY_MODE_STANDALONE },
45 : { eCSSKeyword_fullscreen, NS_STYLE_DISPLAY_MODE_FULLSCREEN },
46 : { eCSSKeyword_UNKNOWN, -1 }
47 : };
48 :
49 : #ifdef XP_WIN
50 : struct WindowsThemeName {
51 : LookAndFeel::WindowsTheme id;
52 : const wchar_t* name;
53 : };
54 :
55 : // Windows theme identities used in the -moz-windows-theme media query.
56 : const WindowsThemeName themeStrings[] = {
57 : { LookAndFeel::eWindowsTheme_Aero, L"aero" },
58 : { LookAndFeel::eWindowsTheme_AeroLite, L"aero-lite" },
59 : { LookAndFeel::eWindowsTheme_LunaBlue, L"luna-blue" },
60 : { LookAndFeel::eWindowsTheme_LunaOlive, L"luna-olive" },
61 : { LookAndFeel::eWindowsTheme_LunaSilver, L"luna-silver" },
62 : { LookAndFeel::eWindowsTheme_Royale, L"royale" },
63 : { LookAndFeel::eWindowsTheme_Zune, L"zune" },
64 : { LookAndFeel::eWindowsTheme_Generic, L"generic" }
65 : };
66 :
67 : struct OperatingSystemVersionInfo {
68 : LookAndFeel::OperatingSystemVersion id;
69 : const wchar_t* name;
70 : };
71 :
72 : // Os version identities used in the -moz-os-version media query.
73 : const OperatingSystemVersionInfo osVersionStrings[] = {
74 : { LookAndFeel::eOperatingSystemVersion_Windows7, L"windows-win7" },
75 : { LookAndFeel::eOperatingSystemVersion_Windows8, L"windows-win8" },
76 : { LookAndFeel::eOperatingSystemVersion_Windows10, L"windows-win10" }
77 : };
78 : #endif
79 :
80 : // A helper for four features below
81 : static nsSize
82 21 : GetSize(nsPresContext* aPresContext)
83 : {
84 21 : nsSize size;
85 21 : if (aPresContext->IsRootPaginatedDocument())
86 : // We want the page size, including unprintable areas and margins.
87 0 : size = aPresContext->GetPageSize();
88 : else
89 21 : size = aPresContext->GetVisibleArea().Size();
90 21 : return size;
91 : }
92 :
93 : static void
94 21 : GetWidth(nsPresContext* aPresContext, const nsMediaFeature*,
95 : nsCSSValue& aResult)
96 : {
97 21 : nsSize size = GetSize(aPresContext);
98 21 : float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width);
99 21 : aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel);
100 21 : }
101 :
102 : static void
103 0 : GetHeight(nsPresContext* aPresContext, const nsMediaFeature*,
104 : nsCSSValue& aResult)
105 : {
106 0 : nsSize size = GetSize(aPresContext);
107 0 : float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height);
108 0 : aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel);
109 0 : }
110 :
111 : inline static nsDeviceContext*
112 0 : GetDeviceContextFor(nsPresContext* aPresContext)
113 : {
114 : // It would be nice to call
115 : // nsLayoutUtils::GetDeviceContextForScreenInfo here, except for two
116 : // things: (1) it can flush, and flushing is bad here, and (2) it
117 : // doesn't really get us consistency in multi-monitor situations
118 : // *anyway*.
119 0 : return aPresContext->DeviceContext();
120 : }
121 :
122 : static bool
123 142 : ShouldResistFingerprinting(nsPresContext* aPresContext)
124 : {
125 142 : return nsContentUtils::ShouldResistFingerprinting(aPresContext->GetDocShell());
126 : }
127 :
128 : // A helper for three features below.
129 : static nsSize
130 0 : GetDeviceSize(nsPresContext* aPresContext)
131 : {
132 0 : nsSize size;
133 :
134 0 : if (ShouldResistFingerprinting(aPresContext) || aPresContext->IsDeviceSizePageSize()) {
135 0 : size = GetSize(aPresContext);
136 0 : } else if (aPresContext->IsRootPaginatedDocument()) {
137 : // We want the page size, including unprintable areas and margins.
138 : // XXX The spec actually says we want the "page sheet size", but
139 : // how is that different?
140 0 : size = aPresContext->GetPageSize();
141 : } else {
142 : GetDeviceContextFor(aPresContext)->
143 0 : GetDeviceSurfaceDimensions(size.width, size.height);
144 : }
145 0 : return size;
146 : }
147 :
148 : static void
149 0 : GetDeviceWidth(nsPresContext* aPresContext, const nsMediaFeature*,
150 : nsCSSValue& aResult)
151 : {
152 0 : nsSize size = GetDeviceSize(aPresContext);
153 0 : float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width);
154 0 : aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel);
155 0 : }
156 :
157 : static void
158 0 : GetDeviceHeight(nsPresContext* aPresContext, const nsMediaFeature*,
159 : nsCSSValue& aResult)
160 : {
161 0 : nsSize size = GetDeviceSize(aPresContext);
162 0 : float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height);
163 0 : aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel);
164 0 : }
165 :
166 : static void
167 0 : GetOrientation(nsPresContext* aPresContext, const nsMediaFeature*,
168 : nsCSSValue& aResult)
169 : {
170 0 : nsSize size = GetSize(aPresContext);
171 : int32_t orientation;
172 0 : if (size.width > size.height) {
173 0 : orientation = NS_STYLE_ORIENTATION_LANDSCAPE;
174 : } else {
175 : // Per spec, square viewports should be 'portrait'
176 0 : orientation = NS_STYLE_ORIENTATION_PORTRAIT;
177 : }
178 :
179 0 : aResult.SetIntValue(orientation, eCSSUnit_Enumerated);
180 0 : }
181 :
182 : static void
183 0 : GetDeviceOrientation(nsPresContext* aPresContext, const nsMediaFeature*,
184 : nsCSSValue& aResult)
185 : {
186 0 : nsSize size = GetDeviceSize(aPresContext);
187 : int32_t orientation;
188 0 : if (size.width > size.height) {
189 0 : orientation = NS_STYLE_ORIENTATION_LANDSCAPE;
190 : } else {
191 : // Per spec, square viewports should be 'portrait'
192 0 : orientation = NS_STYLE_ORIENTATION_PORTRAIT;
193 : }
194 :
195 0 : aResult.SetIntValue(orientation, eCSSUnit_Enumerated);
196 0 : }
197 :
198 : static void
199 62 : GetIsResourceDocument(nsPresContext* aPresContext, const nsMediaFeature*,
200 : nsCSSValue& aResult)
201 : {
202 62 : nsIDocument* doc = aPresContext->Document();
203 62 : aResult.SetIntValue(doc && doc->IsResourceDoc() ? 1 : 0, eCSSUnit_Integer);
204 62 : }
205 :
206 : // Helper for two features below
207 : static void
208 0 : MakeArray(const nsSize& aSize, nsCSSValue& aResult)
209 : {
210 0 : RefPtr<nsCSSValue::Array> a = nsCSSValue::Array::Create(2);
211 :
212 0 : a->Item(0).SetIntValue(aSize.width, eCSSUnit_Integer);
213 0 : a->Item(1).SetIntValue(aSize.height, eCSSUnit_Integer);
214 :
215 0 : aResult.SetArrayValue(a, eCSSUnit_Array);
216 0 : }
217 :
218 : static void
219 0 : GetAspectRatio(nsPresContext* aPresContext, const nsMediaFeature*,
220 : nsCSSValue& aResult)
221 : {
222 0 : MakeArray(GetSize(aPresContext), aResult);
223 0 : }
224 :
225 : static void
226 0 : GetDeviceAspectRatio(nsPresContext* aPresContext, const nsMediaFeature*,
227 : nsCSSValue& aResult)
228 : {
229 0 : MakeArray(GetDeviceSize(aPresContext), aResult);
230 0 : }
231 :
232 : static void
233 0 : GetColor(nsPresContext* aPresContext, const nsMediaFeature*,
234 : nsCSSValue& aResult)
235 : {
236 0 : uint32_t depth = 24; // Use depth of 24 when resisting fingerprinting.
237 :
238 0 : if (!ShouldResistFingerprinting(aPresContext)) {
239 : // FIXME: This implementation is bogus. nsDeviceContext
240 : // doesn't provide reliable information (should be fixed in bug
241 : // 424386).
242 : // FIXME: On a monochrome device, return 0!
243 0 : nsDeviceContext *dx = GetDeviceContextFor(aPresContext);
244 0 : dx->GetDepth(depth);
245 : }
246 :
247 : // The spec says to use bits *per color component*, so divide by 3,
248 : // and round down, since the spec says to use the smallest when the
249 : // color components differ.
250 0 : depth /= 3;
251 0 : aResult.SetIntValue(int32_t(depth), eCSSUnit_Integer);
252 0 : }
253 :
254 : static void
255 0 : GetColorIndex(nsPresContext* aPresContext, const nsMediaFeature*,
256 : nsCSSValue& aResult)
257 : {
258 : // We should return zero if the device does not use a color lookup
259 : // table. Stuart says that our handling of displays with 8-bit
260 : // color is bad enough that we never change the lookup table to
261 : // match what we're trying to display, so perhaps we should always
262 : // return zero. Given that there isn't any better information
263 : // exposed, we don't have much other choice.
264 0 : aResult.SetIntValue(0, eCSSUnit_Integer);
265 0 : }
266 :
267 : static void
268 0 : GetMonochrome(nsPresContext* aPresContext, const nsMediaFeature*,
269 : nsCSSValue& aResult)
270 : {
271 : // For color devices we should return 0.
272 : // FIXME: On a monochrome device, return the actual color depth, not
273 : // 0!
274 0 : aResult.SetIntValue(0, eCSSUnit_Integer);
275 0 : }
276 :
277 : static void
278 129 : GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
279 : nsCSSValue& aResult)
280 : {
281 129 : float dpi = 96; // Use 96 when resisting fingerprinting.
282 :
283 129 : if (!ShouldResistFingerprinting(aPresContext)) {
284 : // Resolution measures device pixels per CSS (inch/cm/pixel). We
285 : // return it in device pixels per CSS inches.
286 258 : dpi = float(nsPresContext::AppUnitsPerCSSInch()) /
287 129 : float(aPresContext->AppUnitsPerDevPixel());
288 : }
289 :
290 129 : aResult.SetFloatValue(dpi, eCSSUnit_Inch);
291 129 : }
292 :
293 : static void
294 0 : GetScan(nsPresContext* aPresContext, const nsMediaFeature*,
295 : nsCSSValue& aResult)
296 : {
297 : // Since Gecko doesn't support the 'tv' media type, the 'scan'
298 : // feature is never present.
299 0 : aResult.Reset();
300 0 : }
301 :
302 : static void
303 0 : GetDisplayMode(nsPresContext* aPresContext, const nsMediaFeature*,
304 : nsCSSValue& aResult)
305 : {
306 0 : nsCOMPtr<nsISupports> container;
307 0 : if (aPresContext) {
308 : // Calling GetRootPresContext() can be slow, so make sure to call it
309 : // just once.
310 0 : nsRootPresContext* root = aPresContext->GetRootPresContext();
311 0 : if (root && root->Document()) {
312 0 : container = root->Document()->GetContainer();
313 : }
314 : }
315 0 : nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
316 0 : if (!baseWindow) {
317 0 : aResult.SetIntValue(NS_STYLE_DISPLAY_MODE_BROWSER, eCSSUnit_Enumerated);
318 0 : return;
319 : }
320 0 : nsCOMPtr<nsIWidget> mainWidget;
321 0 : baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
322 : int32_t displayMode;
323 0 : nsSizeMode mode = mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
324 : // Background tabs are always in 'browser' mode for now.
325 : // If new modes are supported, please ensure not cause the regression in
326 : // Bug 1259641.
327 0 : switch (mode) {
328 : case nsSizeMode_Fullscreen:
329 0 : displayMode = NS_STYLE_DISPLAY_MODE_FULLSCREEN;
330 0 : break;
331 : default:
332 0 : displayMode = NS_STYLE_DISPLAY_MODE_BROWSER;
333 0 : break;
334 : }
335 :
336 0 : aResult.SetIntValue(displayMode, eCSSUnit_Enumerated);
337 : }
338 :
339 : static void
340 0 : GetGrid(nsPresContext* aPresContext, const nsMediaFeature*,
341 : nsCSSValue& aResult)
342 : {
343 : // Gecko doesn't support grid devices (e.g., ttys), so the 'grid'
344 : // feature is always 0.
345 0 : aResult.SetIntValue(0, eCSSUnit_Integer);
346 0 : }
347 :
348 : static void
349 0 : GetDevicePixelRatio(nsPresContext* aPresContext, const nsMediaFeature*,
350 : nsCSSValue& aResult)
351 : {
352 0 : if (!ShouldResistFingerprinting(aPresContext)) {
353 0 : float ratio = aPresContext->CSSPixelsToDevPixels(1.0f);
354 0 : aResult.SetFloatValue(ratio, eCSSUnit_Number);
355 : } else {
356 0 : aResult.SetFloatValue(1.0, eCSSUnit_Number);
357 : }
358 0 : }
359 :
360 : static void
361 0 : GetTransform3d(nsPresContext* aPresContext, const nsMediaFeature*,
362 : nsCSSValue& aResult)
363 : {
364 : // Gecko supports 3d transforms, so this feature is always 1.
365 0 : aResult.SetIntValue(1, eCSSUnit_Integer);
366 0 : }
367 :
368 : static void
369 12 : GetSystemMetric(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
370 : nsCSSValue& aResult)
371 : {
372 12 : aResult.Reset();
373 12 : if (ShouldResistFingerprinting(aPresContext)) {
374 : // If "privacy.resistFingerprinting" is enabled, then we simply don't
375 : // return any system-backed media feature values. (No spoofed values returned.)
376 0 : return;
377 : }
378 :
379 12 : MOZ_ASSERT(aFeature->mValueType == nsMediaFeature::eBoolInteger,
380 : "unexpected type");
381 12 : nsIAtom *metricAtom = *aFeature->mData.mMetric;
382 12 : bool hasMetric = nsCSSRuleProcessor::HasSystemMetric(metricAtom);
383 12 : aResult.SetIntValue(hasMetric ? 1 : 0, eCSSUnit_Integer);
384 : }
385 :
386 : static void
387 0 : GetWindowsTheme(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
388 : nsCSSValue& aResult)
389 : {
390 0 : aResult.Reset();
391 0 : if (ShouldResistFingerprinting(aPresContext)) {
392 0 : return;
393 : }
394 :
395 : #ifdef XP_WIN
396 : uint8_t windowsThemeId =
397 : nsCSSRuleProcessor::GetWindowsThemeIdentifier();
398 :
399 : // Classic mode should fail to match.
400 : if (windowsThemeId == LookAndFeel::eWindowsTheme_Classic)
401 : return;
402 :
403 : // Look up the appropriate theme string
404 : for (size_t i = 0; i < ArrayLength(themeStrings); ++i) {
405 : if (windowsThemeId == themeStrings[i].id) {
406 : aResult.SetStringValue(nsDependentString(themeStrings[i].name),
407 : eCSSUnit_Ident);
408 : break;
409 : }
410 : }
411 : #endif
412 : }
413 :
414 : static void
415 1 : GetOperatingSystemVersion(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
416 : nsCSSValue& aResult)
417 : {
418 1 : aResult.Reset();
419 1 : if (ShouldResistFingerprinting(aPresContext)) {
420 0 : return;
421 : }
422 :
423 : #ifdef XP_WIN
424 : int32_t metricResult;
425 : if (NS_SUCCEEDED(
426 : LookAndFeel::GetInt(LookAndFeel::eIntID_OperatingSystemVersionIdentifier,
427 : &metricResult))) {
428 : for (size_t i = 0; i < ArrayLength(osVersionStrings); ++i) {
429 : if (metricResult == osVersionStrings[i].id) {
430 : aResult.SetStringValue(nsDependentString(osVersionStrings[i].name),
431 : eCSSUnit_Ident);
432 : break;
433 : }
434 : }
435 : }
436 : #endif
437 : }
438 :
439 : static void
440 62 : GetIsGlyph(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
441 : nsCSSValue& aResult)
442 : {
443 62 : aResult.SetIntValue(aPresContext->IsGlyph() ? 1 : 0, eCSSUnit_Integer);
444 62 : }
445 :
446 : /*
447 : * Adding new media features requires (1) adding the new feature to this
448 : * array, with appropriate entries (and potentially any new code needed
449 : * to support new types in these entries and (2) ensuring that either
450 : * nsPresContext::MediaFeatureValuesChanged or
451 : * nsPresContext::PostMediaFeatureValuesChangedEvent is called when the
452 : * value that would be returned by the entry's mGetter changes.
453 : */
454 :
455 : /* static */ const nsMediaFeature
456 : nsMediaFeatures::features[] = {
457 : {
458 : &nsGkAtoms::width,
459 : nsMediaFeature::eMinMaxAllowed,
460 : nsMediaFeature::eLength,
461 : nsMediaFeature::eNoRequirements,
462 : { nullptr },
463 : GetWidth
464 : },
465 : {
466 : &nsGkAtoms::height,
467 : nsMediaFeature::eMinMaxAllowed,
468 : nsMediaFeature::eLength,
469 : nsMediaFeature::eNoRequirements,
470 : { nullptr },
471 : GetHeight
472 : },
473 : {
474 : &nsGkAtoms::deviceWidth,
475 : nsMediaFeature::eMinMaxAllowed,
476 : nsMediaFeature::eLength,
477 : nsMediaFeature::eNoRequirements,
478 : { nullptr },
479 : GetDeviceWidth
480 : },
481 : {
482 : &nsGkAtoms::deviceHeight,
483 : nsMediaFeature::eMinMaxAllowed,
484 : nsMediaFeature::eLength,
485 : nsMediaFeature::eNoRequirements,
486 : { nullptr },
487 : GetDeviceHeight
488 : },
489 : {
490 : &nsGkAtoms::orientation,
491 : nsMediaFeature::eMinMaxNotAllowed,
492 : nsMediaFeature::eEnumerated,
493 : nsMediaFeature::eNoRequirements,
494 : { kOrientationKeywords },
495 : GetOrientation
496 : },
497 : {
498 : &nsGkAtoms::aspectRatio,
499 : nsMediaFeature::eMinMaxAllowed,
500 : nsMediaFeature::eIntRatio,
501 : nsMediaFeature::eNoRequirements,
502 : { nullptr },
503 : GetAspectRatio
504 : },
505 : {
506 : &nsGkAtoms::deviceAspectRatio,
507 : nsMediaFeature::eMinMaxAllowed,
508 : nsMediaFeature::eIntRatio,
509 : nsMediaFeature::eNoRequirements,
510 : { nullptr },
511 : GetDeviceAspectRatio
512 : },
513 : {
514 : &nsGkAtoms::color,
515 : nsMediaFeature::eMinMaxAllowed,
516 : nsMediaFeature::eInteger,
517 : nsMediaFeature::eNoRequirements,
518 : { nullptr },
519 : GetColor
520 : },
521 : {
522 : &nsGkAtoms::colorIndex,
523 : nsMediaFeature::eMinMaxAllowed,
524 : nsMediaFeature::eInteger,
525 : nsMediaFeature::eNoRequirements,
526 : { nullptr },
527 : GetColorIndex
528 : },
529 : {
530 : &nsGkAtoms::monochrome,
531 : nsMediaFeature::eMinMaxAllowed,
532 : nsMediaFeature::eInteger,
533 : nsMediaFeature::eNoRequirements,
534 : { nullptr },
535 : GetMonochrome
536 : },
537 : {
538 : &nsGkAtoms::resolution,
539 : nsMediaFeature::eMinMaxAllowed,
540 : nsMediaFeature::eResolution,
541 : nsMediaFeature::eNoRequirements,
542 : { nullptr },
543 : GetResolution
544 : },
545 : {
546 : &nsGkAtoms::scan,
547 : nsMediaFeature::eMinMaxNotAllowed,
548 : nsMediaFeature::eEnumerated,
549 : nsMediaFeature::eNoRequirements,
550 : { kScanKeywords },
551 : GetScan
552 : },
553 : {
554 : &nsGkAtoms::grid,
555 : nsMediaFeature::eMinMaxNotAllowed,
556 : nsMediaFeature::eBoolInteger,
557 : nsMediaFeature::eNoRequirements,
558 : { nullptr },
559 : GetGrid
560 : },
561 : {
562 : &nsGkAtoms::displayMode,
563 : nsMediaFeature::eMinMaxNotAllowed,
564 : nsMediaFeature::eEnumerated,
565 : nsMediaFeature::eNoRequirements,
566 : { kDisplayModeKeywords },
567 : GetDisplayMode
568 : },
569 :
570 : // Webkit extensions that we support for de-facto web compatibility
571 : // -webkit-{min|max}-device-pixel-ratio (controlled with its own pref):
572 : {
573 : &nsGkAtoms::devicePixelRatio,
574 : nsMediaFeature::eMinMaxAllowed,
575 : nsMediaFeature::eFloat,
576 : nsMediaFeature::eHasWebkitPrefix |
577 : nsMediaFeature::eWebkitDevicePixelRatioPrefEnabled,
578 : { nullptr },
579 : GetDevicePixelRatio
580 : },
581 : // -webkit-transform-3d:
582 : {
583 : &nsGkAtoms::transform_3d,
584 : nsMediaFeature::eMinMaxNotAllowed,
585 : nsMediaFeature::eBoolInteger,
586 : nsMediaFeature::eHasWebkitPrefix,
587 : { nullptr },
588 : GetTransform3d
589 : },
590 :
591 : // Mozilla extensions
592 : {
593 : &nsGkAtoms::_moz_device_pixel_ratio,
594 : nsMediaFeature::eMinMaxAllowed,
595 : nsMediaFeature::eFloat,
596 : nsMediaFeature::eNoRequirements,
597 : { nullptr },
598 : GetDevicePixelRatio
599 : },
600 : {
601 : &nsGkAtoms::_moz_device_orientation,
602 : nsMediaFeature::eMinMaxNotAllowed,
603 : nsMediaFeature::eEnumerated,
604 : nsMediaFeature::eNoRequirements,
605 : { kOrientationKeywords },
606 : GetDeviceOrientation
607 : },
608 : {
609 : &nsGkAtoms::_moz_is_resource_document,
610 : nsMediaFeature::eMinMaxNotAllowed,
611 : nsMediaFeature::eBoolInteger,
612 : nsMediaFeature::eNoRequirements,
613 : { nullptr },
614 : GetIsResourceDocument
615 : },
616 : {
617 : &nsGkAtoms::_moz_color_picker_available,
618 : nsMediaFeature::eMinMaxNotAllowed,
619 : nsMediaFeature::eBoolInteger,
620 : nsMediaFeature::eNoRequirements,
621 : { &nsGkAtoms::color_picker_available },
622 : GetSystemMetric
623 : },
624 : {
625 : &nsGkAtoms::_moz_scrollbar_start_backward,
626 : nsMediaFeature::eMinMaxNotAllowed,
627 : nsMediaFeature::eBoolInteger,
628 : nsMediaFeature::eNoRequirements,
629 : { &nsGkAtoms::scrollbar_start_backward },
630 : GetSystemMetric
631 : },
632 : {
633 : &nsGkAtoms::_moz_scrollbar_start_forward,
634 : nsMediaFeature::eMinMaxNotAllowed,
635 : nsMediaFeature::eBoolInteger,
636 : nsMediaFeature::eNoRequirements,
637 : { &nsGkAtoms::scrollbar_start_forward },
638 : GetSystemMetric
639 : },
640 : {
641 : &nsGkAtoms::_moz_scrollbar_end_backward,
642 : nsMediaFeature::eMinMaxNotAllowed,
643 : nsMediaFeature::eBoolInteger,
644 : nsMediaFeature::eNoRequirements,
645 : { &nsGkAtoms::scrollbar_end_backward },
646 : GetSystemMetric
647 : },
648 : {
649 : &nsGkAtoms::_moz_scrollbar_end_forward,
650 : nsMediaFeature::eMinMaxNotAllowed,
651 : nsMediaFeature::eBoolInteger,
652 : nsMediaFeature::eNoRequirements,
653 : { &nsGkAtoms::scrollbar_end_forward },
654 : GetSystemMetric
655 : },
656 : {
657 : &nsGkAtoms::_moz_scrollbar_thumb_proportional,
658 : nsMediaFeature::eMinMaxNotAllowed,
659 : nsMediaFeature::eBoolInteger,
660 : nsMediaFeature::eNoRequirements,
661 : { &nsGkAtoms::scrollbar_thumb_proportional },
662 : GetSystemMetric
663 : },
664 : {
665 : &nsGkAtoms::_moz_overlay_scrollbars,
666 : nsMediaFeature::eMinMaxNotAllowed,
667 : nsMediaFeature::eBoolInteger,
668 : nsMediaFeature::eNoRequirements,
669 : { &nsGkAtoms::overlay_scrollbars },
670 : GetSystemMetric
671 : },
672 : {
673 : &nsGkAtoms::_moz_windows_default_theme,
674 : nsMediaFeature::eMinMaxNotAllowed,
675 : nsMediaFeature::eBoolInteger,
676 : nsMediaFeature::eNoRequirements,
677 : { &nsGkAtoms::windows_default_theme },
678 : GetSystemMetric
679 : },
680 : {
681 : &nsGkAtoms::_moz_mac_graphite_theme,
682 : nsMediaFeature::eMinMaxNotAllowed,
683 : nsMediaFeature::eBoolInteger,
684 : nsMediaFeature::eNoRequirements,
685 : { &nsGkAtoms::mac_graphite_theme },
686 : GetSystemMetric
687 : },
688 : {
689 : &nsGkAtoms::_moz_mac_yosemite_theme,
690 : nsMediaFeature::eMinMaxNotAllowed,
691 : nsMediaFeature::eBoolInteger,
692 : nsMediaFeature::eNoRequirements,
693 : { &nsGkAtoms::mac_yosemite_theme },
694 : GetSystemMetric
695 : },
696 : {
697 : &nsGkAtoms::_moz_windows_accent_color_applies,
698 : nsMediaFeature::eMinMaxNotAllowed,
699 : nsMediaFeature::eBoolInteger,
700 : nsMediaFeature::eNoRequirements,
701 : { &nsGkAtoms::windows_accent_color_applies },
702 : GetSystemMetric
703 : },
704 : {
705 : &nsGkAtoms::_moz_windows_compositor,
706 : nsMediaFeature::eMinMaxNotAllowed,
707 : nsMediaFeature::eBoolInteger,
708 : nsMediaFeature::eNoRequirements,
709 : { &nsGkAtoms::windows_compositor },
710 : GetSystemMetric
711 : },
712 : {
713 : &nsGkAtoms::_moz_windows_classic,
714 : nsMediaFeature::eMinMaxNotAllowed,
715 : nsMediaFeature::eBoolInteger,
716 : nsMediaFeature::eNoRequirements,
717 : { &nsGkAtoms::windows_classic },
718 : GetSystemMetric
719 : },
720 : {
721 : &nsGkAtoms::_moz_windows_glass,
722 : nsMediaFeature::eMinMaxNotAllowed,
723 : nsMediaFeature::eBoolInteger,
724 : nsMediaFeature::eNoRequirements,
725 : { &nsGkAtoms::windows_glass },
726 : GetSystemMetric
727 : },
728 : {
729 : &nsGkAtoms::_moz_touch_enabled,
730 : nsMediaFeature::eMinMaxNotAllowed,
731 : nsMediaFeature::eBoolInteger,
732 : nsMediaFeature::eNoRequirements,
733 : { &nsGkAtoms::touch_enabled },
734 : GetSystemMetric
735 : },
736 : {
737 : &nsGkAtoms::_moz_menubar_drag,
738 : nsMediaFeature::eMinMaxNotAllowed,
739 : nsMediaFeature::eBoolInteger,
740 : nsMediaFeature::eNoRequirements,
741 : { &nsGkAtoms::menubar_drag },
742 : GetSystemMetric
743 : },
744 : {
745 : &nsGkAtoms::_moz_windows_theme,
746 : nsMediaFeature::eMinMaxNotAllowed,
747 : nsMediaFeature::eIdent,
748 : nsMediaFeature::eNoRequirements,
749 : { nullptr },
750 : GetWindowsTheme
751 : },
752 : {
753 : &nsGkAtoms::_moz_os_version,
754 : nsMediaFeature::eMinMaxNotAllowed,
755 : nsMediaFeature::eIdent,
756 : nsMediaFeature::eNoRequirements,
757 : { nullptr },
758 : GetOperatingSystemVersion
759 : },
760 :
761 : {
762 : &nsGkAtoms::_moz_swipe_animation_enabled,
763 : nsMediaFeature::eMinMaxNotAllowed,
764 : nsMediaFeature::eBoolInteger,
765 : nsMediaFeature::eNoRequirements,
766 : { &nsGkAtoms::swipe_animation_enabled },
767 : GetSystemMetric
768 : },
769 :
770 : {
771 : &nsGkAtoms::_moz_physical_home_button,
772 : nsMediaFeature::eMinMaxNotAllowed,
773 : nsMediaFeature::eBoolInteger,
774 : nsMediaFeature::eNoRequirements,
775 : { &nsGkAtoms::physical_home_button },
776 : GetSystemMetric
777 : },
778 :
779 : // Internal -moz-is-glyph media feature: applies only inside SVG glyphs.
780 : // Internal because it is really only useful in the user agent anyway
781 : // and therefore not worth standardizing.
782 : {
783 : &nsGkAtoms::_moz_is_glyph,
784 : nsMediaFeature::eMinMaxNotAllowed,
785 : nsMediaFeature::eBoolInteger,
786 : nsMediaFeature::eNoRequirements,
787 : { nullptr },
788 : GetIsGlyph
789 : },
790 : // Null-mName terminator:
791 : {
792 : nullptr,
793 : nsMediaFeature::eMinMaxAllowed,
794 : nsMediaFeature::eInteger,
795 : nsMediaFeature::eNoRequirements,
796 : { nullptr },
797 : nullptr
798 : },
799 : };
|