|
1 /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* the features that media queries can test */ |
|
7 |
|
8 #ifndef nsMediaFeatures_h_ |
|
9 #define nsMediaFeatures_h_ |
|
10 |
|
11 #include "nsError.h" |
|
12 #include "nsCSSProps.h" |
|
13 |
|
14 class nsIAtom; |
|
15 class nsPresContext; |
|
16 class nsCSSValue; |
|
17 |
|
18 struct nsMediaFeature; |
|
19 typedef nsresult |
|
20 (* nsMediaFeatureValueGetter)(nsPresContext* aPresContext, |
|
21 const nsMediaFeature* aFeature, |
|
22 nsCSSValue& aResult); |
|
23 |
|
24 struct nsMediaFeature { |
|
25 nsIAtom **mName; // extra indirection to point to nsGkAtoms members |
|
26 |
|
27 enum RangeType { eMinMaxAllowed, eMinMaxNotAllowed }; |
|
28 RangeType mRangeType; |
|
29 |
|
30 enum ValueType { |
|
31 // All value types allow eCSSUnit_Null to indicate that no value |
|
32 // was given (in addition to the types listed below). |
|
33 eLength, // values are such that nsCSSValue::IsLengthUnit() is true |
|
34 eInteger, // values are eCSSUnit_Integer |
|
35 eFloat, // values are eCSSUnit_Number |
|
36 eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only) |
|
37 eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer |
|
38 eResolution, // values are in eCSSUnit_Inch (for dpi), |
|
39 // eCSSUnit_Pixel (for dppx), or |
|
40 // eCSSUnit_Centimeter (for dpcm) |
|
41 eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table) |
|
42 eIdent // values are eCSSUnit_Ident |
|
43 // Note that a number of pieces of code (both for parsing and |
|
44 // for matching of valueless expressions) assume that all numeric |
|
45 // value types cannot be negative. The parsing code also does |
|
46 // not allow zeros in eIntRatio types. |
|
47 }; |
|
48 ValueType mValueType; |
|
49 |
|
50 union { |
|
51 // In static arrays, it's the first member that's initialized. We |
|
52 // need that to be void* so we can initialize both other types. |
|
53 // This member should never be accessed by name. |
|
54 const void* mInitializer_; |
|
55 // If mValueType == eEnumerated: const int32_t*: keyword table in |
|
56 // the same format as the keyword tables in nsCSSProps. |
|
57 const nsCSSProps::KTableValue* mKeywordTable; |
|
58 // If mGetter == GetSystemMetric (which implies mValueType == |
|
59 // eBoolInteger): nsIAtom * const *, for the system metric. |
|
60 nsIAtom * const * mMetric; |
|
61 } mData; |
|
62 |
|
63 // A function that returns the current value for this feature for a |
|
64 // given presentation. If it returns eCSSUnit_Null, the feature is |
|
65 // not present. |
|
66 nsMediaFeatureValueGetter mGetter; |
|
67 }; |
|
68 |
|
69 class nsMediaFeatures { |
|
70 public: |
|
71 // Terminated with an entry whose mName is null. |
|
72 static const nsMediaFeature features[]; |
|
73 }; |
|
74 |
|
75 #endif /* !defined(nsMediaFeatures_h_) */ |