/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Mats Palmgren * Masayuki Nakano * Rob Arnold * Jonathon Jongsma , Collabora Ltd. * L. David Baron , Mozilla Corporation * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ /* * structs that contain the data provided by nsStyleContext, the * internal API for computed style data for an element */ #ifndef nsStyleStruct_h___ #define nsStyleStruct_h___ #include "nsColor.h" #include "nsCoord.h" #include "nsMargin.h" #include "nsRect.h" #include "nsFont.h" #include "nsStyleCoord.h" #include "nsStyleConsts.h" #include "nsChangeHint.h" #include "nsPresContext.h" #include "nsCOMPtr.h" #include "nsCOMArray.h" #include "nsTArray.h" #include "nsIAtom.h" #include "nsIURI.h" #include "nsCSSValue.h" #include "nsStyleTransformMatrix.h" #include "nsAlgorithm.h" #include "imgIRequest.h" #include "gfxRect.h" class nsIFrame; class imgIRequest; class imgIContainer; struct nsCSSValueList; // Includes nsStyleStructID. #include "nsStyleStructFwd.h" // Bits for each struct. // NS_STYLE_INHERIT_BIT defined in nsStyleStructFwd.h #define NS_STYLE_INHERIT_MASK 0x00ffffff // Additional bits for nsStyleContext's mBits: // See nsStyleContext::HasTextDecorations #define NS_STYLE_HAS_TEXT_DECORATIONS 0x01000000 // See nsStyleContext::HasPseudoElementData. #define NS_STYLE_HAS_PSEUDO_ELEMENT_DATA 0x02000000 // See nsStyleContext::RelevantLinkIsVisited #define NS_STYLE_RELEVANT_LINK_VISITED 0x04000000 // See nsStyleContext::IsStyleIfVisited #define NS_STYLE_IS_STYLE_IF_VISITED 0x08000000 // See nsStyleContext::GetPseudoEnum #define NS_STYLE_CONTEXT_TYPE_MASK 0xf0000000 #define NS_STYLE_CONTEXT_TYPE_SHIFT 28 // Additional bits for nsRuleNode's mDependentBits: #define NS_RULE_NODE_GC_MARK 0x02000000 #define NS_RULE_NODE_IS_IMPORTANT 0x08000000 #define NS_RULE_NODE_LEVEL_MASK 0xf0000000 #define NS_RULE_NODE_LEVEL_SHIFT 28 // The lifetime of these objects is managed by the presshell's arena. // Each struct must implement a static ForceCompare() function returning a // boolean. Structs that can return a hint that doesn't guarantee that the // change will be applied to all descendants must return true from // ForceCompare(), so that we will make sure to compare those structs in // nsStyleContext::CalcStyleDifference. struct nsStyleFont { nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext); nsStyleFont(const nsStyleFont& aStyleFont); nsStyleFont(nsPresContext *aPresContext); ~nsStyleFont(void) { MOZ_COUNT_DTOR(nsStyleFont); } nsChangeHint CalcDifference(const nsStyleFont& aOther) const; #ifdef DEBUG static nsChangeHint MaxDifference(); #endif static PRBool ForceCompare() { return PR_FALSE; } static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2); static nscoord ZoomText(nsPresContext* aPresContext, nscoord aSize); static nscoord UnZoomText(nsPresContext* aPresContext, nscoord aSize); void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW; void Destroy(nsPresContext* aContext); nsFont mFont; // [inherited] nscoord mSize; // [inherited] Our "computed size". Can be different // from mFont.size which is our "actual size" and is // enforced to be >= the user's preferred min-size. // mFont.size should be used for display purposes // while mSize is the value to return in // getComputedStyle() for example. PRUint8 mGenericID; // [inherited] generic CSS font family, if any; // value is a kGenericFont_* constant, see nsFont.h. #ifdef MOZ_MATHML // MathML scriptlevel support PRInt8 mScriptLevel; // [inherited] // The value mSize would have had if scriptminsize had never been applied nscoord mScriptUnconstrainedSize; nscoord mScriptMinSize; // [inherited] length float mScriptSizeMultiplier; // [inherited] #endif }; struct nsStyleGradientStop { nsStyleCoord mLocation; // percent, coord, none nscolor mColor; }; class nsStyleGradient { public: nsStyleGradient(); PRUint8 mShape; // NS_STYLE_GRADIENT_SHAPE_* PRUint8 mSize; // NS_STYLE_GRADIENT_SIZE_*; // not used (must be FARTHEST_CORNER) for linear shape PRPackedBool mRepeating; nsStyleCoord mBgPosX; // percent, coord, calc, none nsStyleCoord mBgPosY; // percent, coord, calc, none nsStyleCoord mAngle; // none, angle // stops are in the order specified in the stylesheet nsTArray mStops; PRBool operator==(const nsStyleGradient& aOther) const; PRBool operator!=(const nsStyleGradient& aOther) const { return !(*this == aOther); }; PRBool IsOpaque(); NS_INLINE_DECL_REFCOUNTING(nsStyleGradient) private: ~nsStyleGradient() {} // Not to be implemented nsStyleGradient(const nsStyleGradient& aOther); nsStyleGradient& operator=(const nsStyleGradient& aOther); }; enum nsStyleImageType { eStyleImageType_Null, eStyleImageType_Image, eStyleImageType_Gradient, eStyleImageType_Element }; /** * Represents a paintable image of one of the following types. * (1) A real image loaded from an external source. * (2) A CSS linear or radial gradient. * (3) An element within a document, or an ,