michael@0: /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* the features that media queries can test */ michael@0: michael@0: #ifndef nsMediaFeatures_h_ michael@0: #define nsMediaFeatures_h_ michael@0: michael@0: #include "nsError.h" michael@0: #include "nsCSSProps.h" michael@0: michael@0: class nsIAtom; michael@0: class nsPresContext; michael@0: class nsCSSValue; michael@0: michael@0: struct nsMediaFeature; michael@0: typedef nsresult michael@0: (* nsMediaFeatureValueGetter)(nsPresContext* aPresContext, michael@0: const nsMediaFeature* aFeature, michael@0: nsCSSValue& aResult); michael@0: michael@0: struct nsMediaFeature { michael@0: nsIAtom **mName; // extra indirection to point to nsGkAtoms members michael@0: michael@0: enum RangeType { eMinMaxAllowed, eMinMaxNotAllowed }; michael@0: RangeType mRangeType; michael@0: michael@0: enum ValueType { michael@0: // All value types allow eCSSUnit_Null to indicate that no value michael@0: // was given (in addition to the types listed below). michael@0: eLength, // values are such that nsCSSValue::IsLengthUnit() is true michael@0: eInteger, // values are eCSSUnit_Integer michael@0: eFloat, // values are eCSSUnit_Number michael@0: eBoolInteger,// values are eCSSUnit_Integer (0, -0, or 1 only) michael@0: eIntRatio, // values are eCSSUnit_Array of two eCSSUnit_Integer michael@0: eResolution, // values are in eCSSUnit_Inch (for dpi), michael@0: // eCSSUnit_Pixel (for dppx), or michael@0: // eCSSUnit_Centimeter (for dpcm) michael@0: eEnumerated, // values are eCSSUnit_Enumerated (uses keyword table) michael@0: eIdent // values are eCSSUnit_Ident michael@0: // Note that a number of pieces of code (both for parsing and michael@0: // for matching of valueless expressions) assume that all numeric michael@0: // value types cannot be negative. The parsing code also does michael@0: // not allow zeros in eIntRatio types. michael@0: }; michael@0: ValueType mValueType; michael@0: michael@0: union { michael@0: // In static arrays, it's the first member that's initialized. We michael@0: // need that to be void* so we can initialize both other types. michael@0: // This member should never be accessed by name. michael@0: const void* mInitializer_; michael@0: // If mValueType == eEnumerated: const int32_t*: keyword table in michael@0: // the same format as the keyword tables in nsCSSProps. michael@0: const nsCSSProps::KTableValue* mKeywordTable; michael@0: // If mGetter == GetSystemMetric (which implies mValueType == michael@0: // eBoolInteger): nsIAtom * const *, for the system metric. michael@0: nsIAtom * const * mMetric; michael@0: } mData; michael@0: michael@0: // A function that returns the current value for this feature for a michael@0: // given presentation. If it returns eCSSUnit_Null, the feature is michael@0: // not present. michael@0: nsMediaFeatureValueGetter mGetter; michael@0: }; michael@0: michael@0: class nsMediaFeatures { michael@0: public: michael@0: // Terminated with an entry whose mName is null. michael@0: static const nsMediaFeature features[]; michael@0: }; michael@0: michael@0: #endif /* !defined(nsMediaFeatures_h_) */