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