michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: /* michael@0: * structs that contain the data provided by nsStyleContext, the michael@0: * internal API for computed style data for an element michael@0: */ michael@0: michael@0: #ifndef nsStyleStruct_h___ michael@0: #define nsStyleStruct_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/CSSVariableValues.h" michael@0: #include "nsColor.h" michael@0: #include "nsCoord.h" michael@0: #include "nsMargin.h" michael@0: #include "nsRect.h" michael@0: #include "nsFont.h" michael@0: #include "nsStyleCoord.h" michael@0: #include "nsStyleConsts.h" michael@0: #include "nsChangeHint.h" michael@0: #include "nsPresContext.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsCOMArray.h" michael@0: #include "nsTArray.h" michael@0: #include "nsIAtom.h" michael@0: #include "nsCSSValue.h" michael@0: #include "imgRequestProxy.h" michael@0: #include "Orientation.h" michael@0: #include michael@0: michael@0: class nsIFrame; michael@0: class nsIURI; michael@0: class imgIContainer; michael@0: michael@0: // Includes nsStyleStructID. michael@0: #include "nsStyleStructFwd.h" michael@0: michael@0: // Bits for each struct. michael@0: // NS_STYLE_INHERIT_BIT defined in nsStyleStructFwd.h michael@0: #define NS_STYLE_INHERIT_MASK 0x000ffffff michael@0: michael@0: // Additional bits for nsStyleContext's mBits: michael@0: // See nsStyleContext::HasTextDecorationLines michael@0: #define NS_STYLE_HAS_TEXT_DECORATION_LINES 0x001000000 michael@0: // See nsStyleContext::HasPseudoElementData. michael@0: #define NS_STYLE_HAS_PSEUDO_ELEMENT_DATA 0x002000000 michael@0: // See nsStyleContext::RelevantLinkIsVisited michael@0: #define NS_STYLE_RELEVANT_LINK_VISITED 0x004000000 michael@0: // See nsStyleContext::IsStyleIfVisited michael@0: #define NS_STYLE_IS_STYLE_IF_VISITED 0x008000000 michael@0: // See nsStyleContext::GetPseudoEnum michael@0: #define NS_STYLE_CONTEXT_TYPE_MASK 0x1f0000000 michael@0: #define NS_STYLE_CONTEXT_TYPE_SHIFT 28 michael@0: michael@0: // Additional bits for nsRuleNode's mDependentBits: michael@0: #define NS_RULE_NODE_GC_MARK 0x02000000 michael@0: #define NS_RULE_NODE_USED_DIRECTLY 0x04000000 michael@0: #define NS_RULE_NODE_IS_IMPORTANT 0x08000000 michael@0: #define NS_RULE_NODE_LEVEL_MASK 0xf0000000 michael@0: #define NS_RULE_NODE_LEVEL_SHIFT 28 michael@0: michael@0: // The lifetime of these objects is managed by the presshell's arena. michael@0: michael@0: struct nsStyleFont { michael@0: nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext); michael@0: nsStyleFont(const nsStyleFont& aStyleFont); michael@0: nsStyleFont(nsPresContext *aPresContext); michael@0: private: michael@0: void Init(nsPresContext *aPresContext); michael@0: public: michael@0: ~nsStyleFont(void) { michael@0: MOZ_COUNT_DTOR(nsStyleFont); michael@0: } michael@0: michael@0: nsChangeHint CalcDifference(const nsStyleFont& aOther) const; michael@0: static nsChangeHint MaxDifference() { michael@0: return NS_STYLE_HINT_REFLOW; michael@0: } michael@0: static nsChangeHint MaxDifferenceNeverInherited() { michael@0: // CalcDifference never returns nsChangeHint_NeedReflow or michael@0: // nsChangeHint_ClearAncestorIntrinsics as inherited hints. michael@0: return NS_CombineHint(nsChangeHint_NeedReflow, michael@0: nsChangeHint_ClearAncestorIntrinsics); michael@0: } michael@0: static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2); michael@0: michael@0: static nscoord ZoomText(nsPresContext* aPresContext, nscoord aSize); michael@0: static nscoord UnZoomText(nsPresContext* aPresContext, nscoord aSize); michael@0: michael@0: void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW; michael@0: void Destroy(nsPresContext* aContext); michael@0: michael@0: void EnableZoom(nsPresContext* aContext, bool aEnable); michael@0: michael@0: nsFont mFont; // [inherited] michael@0: nscoord mSize; // [inherited] Our "computed size". Can be different michael@0: // from mFont.size which is our "actual size" and is michael@0: // enforced to be >= the user's preferred min-size. michael@0: // mFont.size should be used for display purposes michael@0: // while mSize is the value to return in michael@0: // getComputedStyle() for example. michael@0: uint8_t mGenericID; // [inherited] generic CSS font family, if any; michael@0: // value is a kGenericFont_* constant, see nsFont.h. michael@0: michael@0: // MathML scriptlevel support michael@0: int8_t mScriptLevel; // [inherited] michael@0: // MathML mathvariant support michael@0: uint8_t mMathVariant; // [inherited] michael@0: // MathML displaystyle support michael@0: uint8_t mMathDisplay; // [inherited] michael@0: michael@0: // was mLanguage set based on a lang attribute in the document? michael@0: bool mExplicitLanguage; // [inherited] michael@0: michael@0: // should calls to ZoomText() and UnZoomText() be made to the font michael@0: // size on this nsStyleFont? michael@0: bool mAllowZoom; // [inherited] michael@0: michael@0: // The value mSize would have had if scriptminsize had never been applied michael@0: nscoord mScriptUnconstrainedSize; michael@0: nscoord mScriptMinSize; // [inherited] length michael@0: float mScriptSizeMultiplier; // [inherited] michael@0: nsCOMPtr mLanguage; // [inherited] michael@0: }; michael@0: michael@0: struct nsStyleGradientStop { michael@0: nsStyleCoord mLocation; // percent, coord, calc, none michael@0: nscolor mColor; michael@0: }; michael@0: michael@0: class nsStyleGradient MOZ_FINAL { michael@0: public: michael@0: nsStyleGradient(); michael@0: uint8_t mShape; // NS_STYLE_GRADIENT_SHAPE_* michael@0: uint8_t mSize; // NS_STYLE_GRADIENT_SIZE_*; michael@0: // not used (must be FARTHEST_CORNER) for linear shape michael@0: bool mRepeating; michael@0: bool mLegacySyntax; michael@0: michael@0: nsStyleCoord mBgPosX; // percent, coord, calc, none michael@0: nsStyleCoord mBgPosY; // percent, coord, calc, none michael@0: nsStyleCoord mAngle; // none, angle michael@0: michael@0: nsStyleCoord mRadiusX; // percent, coord, calc, none michael@0: nsStyleCoord mRadiusY; // percent, coord, calc, none michael@0: michael@0: // stops are in the order specified in the stylesheet michael@0: nsTArray mStops; michael@0: michael@0: bool operator==(const nsStyleGradient& aOther) const; michael@0: bool operator!=(const nsStyleGradient& aOther) const { michael@0: return !(*this == aOther); michael@0: } michael@0: michael@0: bool IsOpaque(); michael@0: bool HasCalc(); michael@0: uint32_t Hash(PLDHashNumber aHash); michael@0: michael@0: NS_INLINE_DECL_REFCOUNTING(nsStyleGradient) michael@0: michael@0: private: michael@0: // Private destructor, to discourage deletion outside of Release(): michael@0: ~nsStyleGradient() {} michael@0: michael@0: nsStyleGradient(const nsStyleGradient& aOther) MOZ_DELETE; michael@0: nsStyleGradient& operator=(const nsStyleGradient& aOther) MOZ_DELETE; michael@0: }; michael@0: michael@0: enum nsStyleImageType { michael@0: eStyleImageType_Null, michael@0: eStyleImageType_Image, michael@0: eStyleImageType_Gradient, michael@0: eStyleImageType_Element michael@0: }; michael@0: michael@0: /** michael@0: * Represents a paintable image of one of the following types. michael@0: * (1) A real image loaded from an external source. michael@0: * (2) A CSS linear or radial gradient. michael@0: * (3) An element within a document, or an ,