1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/style/nsMediaFeatures.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 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 +#ifndef nsMediaFeatures_h_ 1.12 +#define nsMediaFeatures_h_ 1.13 + 1.14 +#include "nsError.h" 1.15 +#include "nsCSSProps.h" 1.16 + 1.17 +class nsIAtom; 1.18 +class nsPresContext; 1.19 +class nsCSSValue; 1.20 + 1.21 +struct nsMediaFeature; 1.22 +typedef nsresult 1.23 +(* nsMediaFeatureValueGetter)(nsPresContext* aPresContext, 1.24 + const nsMediaFeature* aFeature, 1.25 + nsCSSValue& aResult); 1.26 + 1.27 +struct nsMediaFeature { 1.28 + nsIAtom **mName; // extra indirection to point to nsGkAtoms members 1.29 + 1.30 + enum RangeType { eMinMaxAllowed, eMinMaxNotAllowed }; 1.31 + RangeType mRangeType; 1.32 + 1.33 + enum ValueType { 1.34 + // All value types allow eCSSUnit_Null to indicate that no value 1.35 + // was given (in addition to the types listed below). 1.36 + eLength, // values are such that nsCSSValue::IsLengthUnit() is true 1.37 + eInteger, // values are eCSSUnit_Integer 1.38 + eFloat, // values are eCSSUnit_Number 1.39 + eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only) 1.40 + eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer 1.41 + eResolution, // values are in eCSSUnit_Inch (for dpi), 1.42 + // eCSSUnit_Pixel (for dppx), or 1.43 + // eCSSUnit_Centimeter (for dpcm) 1.44 + eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table) 1.45 + eIdent // values are eCSSUnit_Ident 1.46 + // Note that a number of pieces of code (both for parsing and 1.47 + // for matching of valueless expressions) assume that all numeric 1.48 + // value types cannot be negative. The parsing code also does 1.49 + // not allow zeros in eIntRatio types. 1.50 + }; 1.51 + ValueType mValueType; 1.52 + 1.53 + union { 1.54 + // In static arrays, it's the first member that's initialized. We 1.55 + // need that to be void* so we can initialize both other types. 1.56 + // This member should never be accessed by name. 1.57 + const void* mInitializer_; 1.58 + // If mValueType == eEnumerated: const int32_t*: keyword table in 1.59 + // the same format as the keyword tables in nsCSSProps. 1.60 + const nsCSSProps::KTableValue* mKeywordTable; 1.61 + // If mGetter == GetSystemMetric (which implies mValueType == 1.62 + // eBoolInteger): nsIAtom * const *, for the system metric. 1.63 + nsIAtom * const * mMetric; 1.64 + } mData; 1.65 + 1.66 + // A function that returns the current value for this feature for a 1.67 + // given presentation. If it returns eCSSUnit_Null, the feature is 1.68 + // not present. 1.69 + nsMediaFeatureValueGetter mGetter; 1.70 +}; 1.71 + 1.72 +class nsMediaFeatures { 1.73 +public: 1.74 + // Terminated with an entry whose mName is null. 1.75 + static const nsMediaFeature features[]; 1.76 +}; 1.77 + 1.78 +#endif /* !defined(nsMediaFeatures_h_) */