2016-01-11 02:28:35 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-07-26 20:14:48 +04:00
|
|
|
|
|
|
|
/* the features that media queries can test */
|
|
|
|
|
|
|
|
#ifndef nsMediaFeatures_h_
|
|
|
|
#define nsMediaFeatures_h_
|
|
|
|
|
2014-02-05 15:10:44 +04:00
|
|
|
#include "nsCSSProps.h"
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
class nsAtom;
|
2018-01-15 17:33:25 +03:00
|
|
|
class nsIDocument;
|
2008-07-26 20:14:48 +04:00
|
|
|
class nsCSSValue;
|
2018-02-13 03:53:44 +03:00
|
|
|
class nsStaticAtom;
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2009-10-16 04:23:18 +04:00
|
|
|
struct nsMediaFeature;
|
2018-01-15 17:33:25 +03:00
|
|
|
typedef void (*nsMediaFeatureValueGetter)(nsIDocument* aDocument,
|
2017-01-18 16:33:24 +03:00
|
|
|
const nsMediaFeature* aFeature,
|
|
|
|
nsCSSValue& aResult);
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2016-01-11 02:28:35 +03:00
|
|
|
struct nsMediaFeature
|
|
|
|
{
|
2017-10-27 02:31:13 +03:00
|
|
|
nsStaticAtom** mName; // extra indirection to point to nsGkAtoms members
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2016-01-11 02:28:35 +03:00
|
|
|
enum RangeType { eMinMaxAllowed, eMinMaxNotAllowed };
|
|
|
|
RangeType mRangeType;
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2016-01-11 02:28:35 +03:00
|
|
|
enum ValueType {
|
|
|
|
// All value types allow eCSSUnit_Null to indicate that no value
|
|
|
|
// was given (in addition to the types listed below).
|
2017-01-15 23:18:35 +03:00
|
|
|
eLength, // values are eCSSUnit_Pixel
|
2016-01-11 02:28:35 +03:00
|
|
|
eInteger, // values are eCSSUnit_Integer
|
|
|
|
eFloat, // values are eCSSUnit_Number
|
|
|
|
eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only)
|
|
|
|
eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer
|
|
|
|
eResolution, // values are in eCSSUnit_Inch (for dpi),
|
|
|
|
// eCSSUnit_Pixel (for dppx), or
|
|
|
|
// eCSSUnit_Centimeter (for dpcm)
|
|
|
|
eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table)
|
|
|
|
eIdent // values are eCSSUnit_Ident
|
|
|
|
// Note that a number of pieces of code (both for parsing and
|
|
|
|
// for matching of valueless expressions) assume that all numeric
|
|
|
|
// value types cannot be negative. The parsing code also does
|
|
|
|
// not allow zeros in eIntRatio types.
|
|
|
|
};
|
|
|
|
ValueType mValueType;
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2016-01-11 02:28:35 +03:00
|
|
|
enum RequirementFlags : uint8_t {
|
|
|
|
// Bitfield of requirements that must be satisfied in order for this
|
|
|
|
// media feature to be active.
|
|
|
|
eNoRequirements = 0,
|
2016-01-18 20:24:16 +03:00
|
|
|
eHasWebkitPrefix = 1 << 0, // Feature name must start w/ "-webkit-", even
|
|
|
|
// before any "min-"/"max-" qualifier.
|
|
|
|
|
|
|
|
// Feature is only supported if the pref
|
|
|
|
// "layout.css.prefixes.device-pixel-ratio-webkit" is enabled.
|
|
|
|
// (Should only be used for -webkit-device-pixel-ratio.)
|
2017-10-07 14:25:58 +03:00
|
|
|
eWebkitDevicePixelRatioPrefEnabled = 1 << 1,
|
|
|
|
// Feature is only usable from UA sheets and chrome:// urls.
|
|
|
|
eUserAgentAndChromeOnly = 1 << 2,
|
2016-01-11 02:28:35 +03:00
|
|
|
};
|
|
|
|
uint8_t mReqFlags;
|
2015-11-10 05:09:40 +03:00
|
|
|
|
2016-01-11 02:28:35 +03:00
|
|
|
union {
|
|
|
|
// In static arrays, it's the first member that's initialized. We
|
|
|
|
// need that to be void* so we can initialize both other types.
|
|
|
|
// This member should never be accessed by name.
|
|
|
|
const void* mInitializer_;
|
|
|
|
// If mValueType == eEnumerated: const int32_t*: keyword table in
|
|
|
|
// the same format as the keyword tables in nsCSSProps.
|
|
|
|
const nsCSSProps::KTableEntry* mKeywordTable;
|
|
|
|
// If mGetter == GetSystemMetric (which implies mValueType ==
|
2017-10-03 01:05:19 +03:00
|
|
|
// eBoolInteger): nsAtom * const *, for the system metric.
|
|
|
|
nsAtom * const * mMetric;
|
2016-01-11 02:28:35 +03:00
|
|
|
} mData;
|
2008-07-26 20:14:48 +04:00
|
|
|
|
2016-01-11 02:28:35 +03:00
|
|
|
// A function that returns the current value for this feature for a
|
|
|
|
// given presentation. If it returns eCSSUnit_Null, the feature is
|
|
|
|
// not present.
|
|
|
|
nsMediaFeatureValueGetter mGetter;
|
2008-07-26 20:14:48 +04:00
|
|
|
};
|
|
|
|
|
2016-01-11 02:28:35 +03:00
|
|
|
class nsMediaFeatures
|
|
|
|
{
|
2008-07-26 20:14:48 +04:00
|
|
|
public:
|
2017-11-17 10:35:26 +03:00
|
|
|
static void InitSystemMetrics();
|
|
|
|
static void FreeSystemMetrics();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2016-01-11 02:28:35 +03:00
|
|
|
// Terminated with an entry whose mName is null.
|
|
|
|
static const nsMediaFeature features[];
|
2008-07-26 20:14:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsMediaFeatures_h_) */
|