Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / layout / style / nsStyleStruct.h
bloba050c5e7c30503352cf749f1745869c96e12f242
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Mats Palmgren <matspal@gmail.com>
24 * Masayuki Nakano <masayuki@d-toybox.com>
25 * Rob Arnold <robarnold@mozilla.com>
26 * Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>, Collabora Ltd.
27 * L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
29 * Alternatively, the contents of this file may be used under the terms of
30 * either of the GNU General Public License Version 2 or later (the "GPL"),
31 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32 * in which case the provisions of the GPL or the LGPL are applicable instead
33 * of those above. If you wish to allow use of your version of this file only
34 * under the terms of either the GPL or the LGPL, and not to allow others to
35 * use your version of this file under the terms of the MPL, indicate your
36 * decision by deleting the provisions above and replace them with the notice
37 * and other provisions required by the GPL or the LGPL. If you do not delete
38 * the provisions above, a recipient may use your version of this file under
39 * the terms of any one of the MPL, the GPL or the LGPL.
41 * ***** END LICENSE BLOCK ***** */
44 * structs that contain the data provided by nsStyleContext, the
45 * internal API for computed style data for an element
48 #ifndef nsStyleStruct_h___
49 #define nsStyleStruct_h___
51 #include "nsColor.h"
52 #include "nsCoord.h"
53 #include "nsMargin.h"
54 #include "nsRect.h"
55 #include "nsFont.h"
56 #include "nsStyleCoord.h"
57 #include "nsStyleConsts.h"
58 #include "nsChangeHint.h"
59 #include "nsPresContext.h"
60 #include "nsCOMPtr.h"
61 #include "nsCOMArray.h"
62 #include "nsTArray.h"
63 #include "nsIAtom.h"
64 #include "nsIURI.h"
65 #include "nsCSSValue.h"
66 #include "nsStyleTransformMatrix.h"
67 #include "nsAlgorithm.h"
68 #include "imgIRequest.h"
69 #include "gfxRect.h"
71 class nsIFrame;
72 class imgIRequest;
73 class imgIContainer;
74 struct nsCSSValueList;
76 // Includes nsStyleStructID.
77 #include "nsStyleStructFwd.h"
79 // Bits for each struct.
80 // NS_STYLE_INHERIT_BIT defined in nsStyleStructFwd.h
81 #define NS_STYLE_INHERIT_MASK 0x00ffffff
83 // Additional bits for nsStyleContext's mBits:
84 // See nsStyleContext::HasTextDecorations
85 #define NS_STYLE_HAS_TEXT_DECORATIONS 0x01000000
86 // See nsStyleContext::HasPseudoElementData.
87 #define NS_STYLE_HAS_PSEUDO_ELEMENT_DATA 0x02000000
88 // See nsStyleContext::RelevantLinkIsVisited
89 #define NS_STYLE_RELEVANT_LINK_VISITED 0x04000000
90 // See nsStyleContext::IsStyleIfVisited
91 #define NS_STYLE_IS_STYLE_IF_VISITED 0x08000000
92 // See nsStyleContext::GetPseudoEnum
93 #define NS_STYLE_CONTEXT_TYPE_MASK 0xf0000000
94 #define NS_STYLE_CONTEXT_TYPE_SHIFT 28
96 // Additional bits for nsRuleNode's mDependentBits:
97 #define NS_RULE_NODE_GC_MARK 0x02000000
98 #define NS_RULE_NODE_IS_IMPORTANT 0x08000000
99 #define NS_RULE_NODE_LEVEL_MASK 0xf0000000
100 #define NS_RULE_NODE_LEVEL_SHIFT 28
102 // The lifetime of these objects is managed by the presshell's arena.
104 // Each struct must implement a static ForceCompare() function returning a
105 // boolean. Structs that can return a hint that doesn't guarantee that the
106 // change will be applied to all descendants must return true from
107 // ForceCompare(), so that we will make sure to compare those structs in
108 // nsStyleContext::CalcStyleDifference.
110 struct nsStyleFont {
111 nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext);
112 nsStyleFont(const nsStyleFont& aStyleFont);
113 nsStyleFont(nsPresContext *aPresContext);
114 ~nsStyleFont(void) {
115 MOZ_COUNT_DTOR(nsStyleFont);
118 nsChangeHint CalcDifference(const nsStyleFont& aOther) const;
119 #ifdef DEBUG
120 static nsChangeHint MaxDifference();
121 #endif
122 static PRBool ForceCompare() { return PR_FALSE; }
123 static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
125 static nscoord ZoomText(nsPresContext* aPresContext, nscoord aSize);
126 static nscoord UnZoomText(nsPresContext* aPresContext, nscoord aSize);
128 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
129 void Destroy(nsPresContext* aContext);
131 nsFont mFont; // [inherited]
132 nscoord mSize; // [inherited] Our "computed size". Can be different
133 // from mFont.size which is our "actual size" and is
134 // enforced to be >= the user's preferred min-size.
135 // mFont.size should be used for display purposes
136 // while mSize is the value to return in
137 // getComputedStyle() for example.
138 PRUint8 mGenericID; // [inherited] generic CSS font family, if any;
139 // value is a kGenericFont_* constant, see nsFont.h.
141 #ifdef MOZ_MATHML
142 // MathML scriptlevel support
143 PRInt8 mScriptLevel; // [inherited]
144 // The value mSize would have had if scriptminsize had never been applied
145 nscoord mScriptUnconstrainedSize;
146 nscoord mScriptMinSize; // [inherited] length
147 float mScriptSizeMultiplier; // [inherited]
148 #endif
151 struct nsStyleGradientStop {
152 nsStyleCoord mLocation; // percent, coord, none
153 nscolor mColor;
156 class nsStyleGradient {
157 public:
158 nsStyleGradient();
159 PRUint8 mShape; // NS_STYLE_GRADIENT_SHAPE_*
160 PRUint8 mSize; // NS_STYLE_GRADIENT_SIZE_*;
161 // not used (must be FARTHEST_CORNER) for linear shape
162 PRPackedBool mRepeating;
164 nsStyleCoord mBgPosX; // percent, coord, calc, none
165 nsStyleCoord mBgPosY; // percent, coord, calc, none
166 nsStyleCoord mAngle; // none, angle
168 // stops are in the order specified in the stylesheet
169 nsTArray<nsStyleGradientStop> mStops;
171 PRBool operator==(const nsStyleGradient& aOther) const;
172 PRBool operator!=(const nsStyleGradient& aOther) const {
173 return !(*this == aOther);
176 PRBool IsOpaque();
178 NS_INLINE_DECL_REFCOUNTING(nsStyleGradient)
180 private:
181 ~nsStyleGradient() {}
183 // Not to be implemented
184 nsStyleGradient(const nsStyleGradient& aOther);
185 nsStyleGradient& operator=(const nsStyleGradient& aOther);
188 enum nsStyleImageType {
189 eStyleImageType_Null,
190 eStyleImageType_Image,
191 eStyleImageType_Gradient,
192 eStyleImageType_Element
196 * Represents a paintable image of one of the following types.
197 * (1) A real image loaded from an external source.
198 * (2) A CSS linear or radial gradient.
199 * (3) An element within a document, or an <img>, <video>, or <canvas> element
200 * not in a document.
201 * (*) Optionally a crop rect can be set to paint a partial (rectangular)
202 * region of an image. (Currently, this feature is only supported with an
203 * image of type (1)).
205 * This struct is currently used only for 'background-image', but it may be
206 * used by other CSS properties such as 'border-image', 'list-style-image', and
207 * 'content' in the future (bug 507052).
209 struct nsStyleImage {
210 nsStyleImage();
211 ~nsStyleImage();
212 nsStyleImage(const nsStyleImage& aOther);
213 nsStyleImage& operator=(const nsStyleImage& aOther);
215 void SetNull();
216 void SetImageData(imgIRequest* aImage);
217 void TrackImage(nsPresContext* aContext);
218 void UntrackImage(nsPresContext* aContext);
219 void SetGradientData(nsStyleGradient* aGradient);
220 void SetElementId(const PRUnichar* aElementId);
221 void SetCropRect(nsStyleSides* aCropRect);
223 nsStyleImageType GetType() const {
224 return mType;
226 imgIRequest* GetImageData() const {
227 NS_ABORT_IF_FALSE(mType == eStyleImageType_Image, "Data is not an image!");
228 NS_ABORT_IF_FALSE(mImageTracked,
229 "Should be tracking any image we're going to use!");
230 return mImage;
232 nsStyleGradient* GetGradientData() const {
233 NS_ASSERTION(mType == eStyleImageType_Gradient, "Data is not a gradient!");
234 return mGradient;
236 const PRUnichar* GetElementId() const {
237 NS_ASSERTION(mType == eStyleImageType_Element, "Data is not an element!");
238 return mElementId;
240 nsStyleSides* GetCropRect() const {
241 NS_ASSERTION(mType == eStyleImageType_Image,
242 "Only image data can have a crop rect");
243 return mCropRect;
247 * Compute the actual crop rect in pixels, using the source image bounds.
248 * The computation involves converting percentage unit to pixel unit and
249 * clamping each side value to fit in the source image bounds.
250 * @param aActualCropRect the computed actual crop rect.
251 * @param aIsEntireImage PR_TRUE iff |aActualCropRect| is identical to the
252 * source image bounds.
253 * @return PR_TRUE iff |aActualCropRect| holds a meaningful value.
255 PRBool ComputeActualCropRect(nsIntRect& aActualCropRect,
256 PRBool* aIsEntireImage = nsnull) const;
259 * Requests a decode on the image.
261 nsresult RequestDecode() const;
263 * @return PR_TRUE if the item is definitely opaque --- i.e., paints every
264 * pixel within its bounds opaquely, and the bounds contains at least a pixel.
266 PRBool IsOpaque() const;
268 * @return PR_TRUE if this image is fully loaded, and its size is calculated;
269 * always returns PR_TRUE if |mType| is |eStyleImageType_Gradient| or
270 * |eStyleImageType_Element|.
272 PRBool IsComplete() const;
274 * @return PR_TRUE if it is 100% confident that this image contains no pixel
275 * to draw.
277 PRBool IsEmpty() const {
278 // There are some other cases when the image will be empty, for example
279 // when the crop rect is empty. However, checking the emptiness of crop
280 // rect is non-trivial since each side value can be specified with
281 // percentage unit, which can not be evaluated until the source image size
282 // is available. Therefore, we currently postpone the evaluation of crop
283 // rect until the actual rendering time --- alternatively until GetOpaqueRegion()
284 // is called.
285 return mType == eStyleImageType_Null;
288 PRBool operator==(const nsStyleImage& aOther) const;
289 PRBool operator!=(const nsStyleImage& aOther) const {
290 return !(*this == aOther);
293 private:
294 void DoCopy(const nsStyleImage& aOther);
296 nsStyleImageType mType;
297 union {
298 imgIRequest* mImage;
299 nsStyleGradient* mGradient;
300 PRUnichar* mElementId;
302 // This is _currently_ used only in conjunction with eStyleImageType_Image.
303 nsAutoPtr<nsStyleSides> mCropRect;
304 #ifdef DEBUG
305 bool mImageTracked;
306 #endif
309 struct nsStyleColor {
310 nsStyleColor(nsPresContext* aPresContext);
311 nsStyleColor(const nsStyleColor& aOther);
312 ~nsStyleColor(void) {
313 MOZ_COUNT_DTOR(nsStyleColor);
316 nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
317 #ifdef DEBUG
318 static nsChangeHint MaxDifference();
319 #endif
320 static PRBool ForceCompare() { return PR_FALSE; }
322 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
323 return aContext->AllocateFromShell(sz);
325 void Destroy(nsPresContext* aContext) {
326 this->~nsStyleColor();
327 aContext->FreeToShell(sizeof(nsStyleColor), this);
330 // Don't add ANY members to this struct! We can achieve caching in the rule
331 // tree (rather than the style tree) by letting color stay by itself! -dwh
332 nscolor mColor; // [inherited]
335 struct nsStyleBackground {
336 nsStyleBackground();
337 nsStyleBackground(const nsStyleBackground& aOther);
338 ~nsStyleBackground();
340 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
341 return aContext->AllocateFromShell(sz);
343 void Destroy(nsPresContext* aContext);
345 nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
346 #ifdef DEBUG
347 static nsChangeHint MaxDifference();
348 #endif
349 static PRBool ForceCompare() { return PR_FALSE; }
351 struct Position;
352 friend struct Position;
353 struct Position {
354 struct PositionCoord {
355 // A 'background-position' can be a linear combination of length
356 // and percent (thanks to calc(), which can combine them).
357 nscoord mLength;
358 float mPercent;
360 bool operator==(const PositionCoord& aOther) const
361 { return mLength == aOther.mLength && mPercent == aOther.mPercent; }
362 bool operator!=(const PositionCoord& aOther) const
363 { return !(*this == aOther); }
365 PositionCoord mXPosition, mYPosition;
367 // Initialize nothing
368 Position() {}
370 // Initialize to initial values
371 void SetInitialValues();
373 // True if the effective background image position described by this depends
374 // on the size of the corresponding frame.
375 PRBool DependsOnFrameSize() const {
376 return mXPosition.mPercent != 0.0f || mYPosition.mPercent != 0.0f;
379 bool operator==(const Position& aOther) const {
380 return mXPosition == aOther.mXPosition &&
381 mYPosition == aOther.mYPosition;
383 bool operator!=(const Position& aOther) const {
384 return !(*this == aOther);
388 struct Size;
389 friend struct Size;
390 struct Size {
391 struct Dimension {
392 // A 'background-size' can be a linear combination of length
393 // and percent (thanks to calc(), which can combine them).
394 nscoord mLength;
395 float mPercent;
397 bool operator==(const Dimension& aOther) const
398 { return mLength == aOther.mLength && mPercent == aOther.mPercent; }
399 bool operator!=(const Dimension& aOther) const
400 { return !(*this == aOther); }
402 Dimension mWidth, mHeight;
404 // Except for eLengthPercentage, Dimension types which might change
405 // how a layer is painted when the corresponding frame's dimensions
406 // change *must* precede all dimension types which are agnostic to
407 // frame size; see DependsOnFrameSize below.
408 enum DimensionType {
409 // If one of mWidth and mHeight is eContain or eCover, then both are.
410 // Also, these two values must equal the corresponding values in
411 // kBackgroundSizeKTable.
412 eContain, eCover,
414 eAuto,
415 eLengthPercentage,
416 eDimensionType_COUNT
418 PRUint8 mWidthType, mHeightType;
420 // True if the effective image size described by this depends on
421 // the size of the corresponding frame. Gradients depend on the
422 // frame size when their dimensions are 'auto', images don't; both
423 // types depend on the frame size when their dimensions are
424 // 'contain', 'cover', or a percentage.
425 // -moz-element also depends on the frame size when the dimensions
426 // are 'auto' since it could be an SVG gradient or pattern which
427 // behaves exactly like a CSS gradient.
428 bool DependsOnFrameSize(nsStyleImageType aType) const {
429 if ((mWidthType == eLengthPercentage && mWidth.mPercent != 0.0f) ||
430 (mHeightType == eLengthPercentage && mHeight.mPercent != 0.0f)) {
431 return true;
433 if (aType == eStyleImageType_Image) {
434 return mWidthType <= eCover || mHeightType <= eCover;
435 } else {
436 NS_ABORT_IF_FALSE(aType == eStyleImageType_Gradient ||
437 aType == eStyleImageType_Element,
438 "unrecognized image type");
439 return mWidthType <= eAuto || mHeightType <= eAuto;
443 // Initialize nothing
444 Size() {}
446 // Initialize to initial values
447 void SetInitialValues();
449 bool operator==(const Size& aOther) const;
450 bool operator!=(const Size& aOther) const {
451 return !(*this == aOther);
455 struct Layer;
456 friend struct Layer;
457 struct Layer {
458 PRUint8 mAttachment; // [reset] See nsStyleConsts.h
459 PRUint8 mClip; // [reset] See nsStyleConsts.h
460 PRUint8 mOrigin; // [reset] See nsStyleConsts.h
461 PRUint8 mRepeat; // [reset] See nsStyleConsts.h
462 Position mPosition; // [reset]
463 nsStyleImage mImage; // [reset]
464 Size mSize; // [reset]
466 // Initializes only mImage
467 Layer();
468 ~Layer();
470 // Register/unregister images with the document. We do this only
471 // after the dust has settled in ComputeBackgroundData.
472 void TrackImages(nsPresContext* aContext) {
473 if (mImage.GetType() == eStyleImageType_Image)
474 mImage.TrackImage(aContext);
476 void UntrackImages(nsPresContext* aContext) {
477 if (mImage.GetType() == eStyleImageType_Image)
478 mImage.UntrackImage(aContext);
481 void SetInitialValues();
483 // True if the rendering of this layer might change when the size
484 // of the corresponding frame changes. This is true for any
485 // non-solid-color background whose position or size depends on
486 // the frame size. It's also true for SVG images whose root <svg>
487 // node has a viewBox.
488 PRBool RenderingMightDependOnFrameSize() const;
490 // An equality operator that compares the images using URL-equality
491 // rather than pointer-equality.
492 PRBool operator==(const Layer& aOther) const;
493 PRBool operator!=(const Layer& aOther) const {
494 return !(*this == aOther);
498 // The (positive) number of computed values of each property, since
499 // the lengths of the lists are independent.
500 PRUint32 mAttachmentCount,
501 mClipCount,
502 mOriginCount,
503 mRepeatCount,
504 mPositionCount,
505 mImageCount,
506 mSizeCount;
507 // Layers are stored in an array, matching the top-to-bottom order in
508 // which they are specified in CSS. The number of layers to be used
509 // should come from the background-image property. We create
510 // additional |Layer| objects for *any* property, not just
511 // background-image. This means that the bottommost layer that
512 // callers in layout care about (which is also the one whose
513 // background-clip applies to the background-color) may not be last
514 // layer. In layers below the bottom layer, properties will be
515 // uninitialized unless their count, above, indicates that they are
516 // present.
517 nsAutoTArray<Layer, 1> mLayers;
519 const Layer& BottomLayer() const { return mLayers[mImageCount - 1]; }
521 #define NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(var_, stylebg_) \
522 for (PRUint32 var_ = (stylebg_)->mImageCount; var_-- != 0; )
524 nscolor mBackgroundColor; // [reset]
526 // FIXME: This (now background-break in css3-background) should
527 // probably move into a different struct so that everything in
528 // nsStyleBackground is set by the background shorthand.
529 PRUint8 mBackgroundInlinePolicy; // [reset] See nsStyleConsts.h
531 // True if this background is completely transparent.
532 PRBool IsTransparent() const;
534 // We have to take slower codepaths for fixed background attachment,
535 // but we don't want to do that when there's no image.
536 // Not inline because it uses an nsCOMPtr<imgIRequest>
537 // FIXME: Should be in nsStyleStructInlines.h.
538 PRBool HasFixedBackground() const;
541 // See https://bugzilla.mozilla.org/show_bug.cgi?id=271586#c43 for why
542 // this is hard to replace with 'currentColor'.
543 #define BORDER_COLOR_FOREGROUND 0x20
544 #define OUTLINE_COLOR_INITIAL 0x80
545 // FOREGROUND | INITIAL(OUTLINE)
546 #define BORDER_COLOR_SPECIAL 0xA0
547 #define BORDER_STYLE_MASK 0x1F
549 #define NS_SPACING_MARGIN 0
550 #define NS_SPACING_PADDING 1
551 #define NS_SPACING_BORDER 2
554 struct nsStyleMargin {
555 nsStyleMargin(void);
556 nsStyleMargin(const nsStyleMargin& aMargin);
557 ~nsStyleMargin(void) {
558 MOZ_COUNT_DTOR(nsStyleMargin);
561 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
562 void Destroy(nsPresContext* aContext);
564 void RecalcData();
565 nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
566 #ifdef DEBUG
567 static nsChangeHint MaxDifference();
568 #endif
569 static PRBool ForceCompare() { return PR_TRUE; }
571 nsStyleSides mMargin; // [reset] coord, percent, calc, auto
573 PRBool IsWidthDependent() const { return !mHasCachedMargin; }
574 PRBool GetMargin(nsMargin& aMargin) const
576 if (mHasCachedMargin) {
577 aMargin = mCachedMargin;
578 return PR_TRUE;
580 return PR_FALSE;
583 protected:
584 PRPackedBool mHasCachedMargin;
585 nsMargin mCachedMargin;
589 struct nsStylePadding {
590 nsStylePadding(void);
591 nsStylePadding(const nsStylePadding& aPadding);
592 ~nsStylePadding(void) {
593 MOZ_COUNT_DTOR(nsStylePadding);
596 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
597 void Destroy(nsPresContext* aContext);
599 void RecalcData();
600 nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
601 #ifdef DEBUG
602 static nsChangeHint MaxDifference();
603 #endif
604 static PRBool ForceCompare() { return PR_TRUE; }
606 nsStyleSides mPadding; // [reset] coord, percent, calc
608 PRBool IsWidthDependent() const { return !mHasCachedPadding; }
609 PRBool GetPadding(nsMargin& aPadding) const
611 if (mHasCachedPadding) {
612 aPadding = mCachedPadding;
613 return PR_TRUE;
615 return PR_FALSE;
618 protected:
619 PRPackedBool mHasCachedPadding;
620 nsMargin mCachedPadding;
623 struct nsBorderColors {
624 nsBorderColors* mNext;
625 nscolor mColor;
627 nsBorderColors() : mNext(nsnull), mColor(NS_RGB(0,0,0)) {}
628 nsBorderColors(const nscolor& aColor) : mNext(nsnull), mColor(aColor) {}
629 ~nsBorderColors();
631 nsBorderColors* Clone() const { return Clone(PR_TRUE); }
633 static PRBool Equal(const nsBorderColors* c1,
634 const nsBorderColors* c2) {
635 if (c1 == c2)
636 return PR_TRUE;
637 while (c1 && c2) {
638 if (c1->mColor != c2->mColor)
639 return PR_FALSE;
640 c1 = c1->mNext;
641 c2 = c2->mNext;
643 // both should be NULL if these are equal, otherwise one
644 // has more colors than another
645 return !c1 && !c2;
648 private:
649 nsBorderColors* Clone(PRBool aDeep) const;
652 struct nsCSSShadowItem {
653 nscoord mXOffset;
654 nscoord mYOffset;
655 nscoord mRadius;
656 nscoord mSpread;
658 nscolor mColor;
659 PRPackedBool mHasColor; // Whether mColor should be used
660 PRPackedBool mInset;
662 nsCSSShadowItem() : mHasColor(PR_FALSE) {
663 MOZ_COUNT_CTOR(nsCSSShadowItem);
665 ~nsCSSShadowItem() {
666 MOZ_COUNT_DTOR(nsCSSShadowItem);
669 PRBool operator==(const nsCSSShadowItem& aOther) {
670 return (mXOffset == aOther.mXOffset &&
671 mYOffset == aOther.mYOffset &&
672 mRadius == aOther.mRadius &&
673 mHasColor == aOther.mHasColor &&
674 mSpread == aOther.mSpread &&
675 mInset == aOther.mInset &&
676 (!mHasColor || mColor == aOther.mColor));
678 PRBool operator!=(const nsCSSShadowItem& aOther) {
679 return !(*this == aOther);
683 class nsCSSShadowArray {
684 public:
685 void* operator new(size_t aBaseSize, PRUint32 aArrayLen) {
686 // We can allocate both this nsCSSShadowArray and the
687 // actual array in one allocation. The amount of memory to
688 // allocate is equal to the class's size + the number of bytes for all
689 // but the first array item (because aBaseSize includes one
690 // item, see the private declarations)
691 return ::operator new(aBaseSize +
692 (aArrayLen - 1) * sizeof(nsCSSShadowItem));
695 nsCSSShadowArray(PRUint32 aArrayLen) :
696 mLength(aArrayLen)
698 MOZ_COUNT_CTOR(nsCSSShadowArray);
699 for (PRUint32 i = 1; i < mLength; ++i) {
700 // Make sure we call the constructors of each nsCSSShadowItem
701 // (the first one is called for us because we declared it under private)
702 new (&mArray[i]) nsCSSShadowItem();
705 ~nsCSSShadowArray() {
706 MOZ_COUNT_DTOR(nsCSSShadowArray);
707 for (PRUint32 i = 1; i < mLength; ++i) {
708 mArray[i].~nsCSSShadowItem();
712 PRUint32 Length() const { return mLength; }
713 nsCSSShadowItem* ShadowAt(PRUint32 i) {
714 NS_ABORT_IF_FALSE(i < mLength, "Accessing too high an index in the text shadow array!");
715 return &mArray[i];
717 const nsCSSShadowItem* ShadowAt(PRUint32 i) const {
718 NS_ABORT_IF_FALSE(i < mLength, "Accessing too high an index in the text shadow array!");
719 return &mArray[i];
722 NS_INLINE_DECL_REFCOUNTING(nsCSSShadowArray)
724 private:
725 PRUint32 mLength;
726 nsCSSShadowItem mArray[1]; // This MUST be the last item
729 // Border widths are rounded to the nearest-below integer number of pixels,
730 // but values between zero and one device pixels are always rounded up to
731 // one device pixel.
732 #define NS_ROUND_BORDER_TO_PIXELS(l,tpp) \
733 ((l) == 0) ? 0 : NS_MAX((tpp), (l) / (tpp) * (tpp))
734 // Outline offset is rounded to the nearest integer number of pixels, but values
735 // between zero and one device pixels are always rounded up to one device pixel.
736 // Note that the offset can be negative.
737 #define NS_ROUND_OFFSET_TO_PIXELS(l,tpp) \
738 (((l) == 0) ? 0 : \
739 ((l) > 0) ? NS_MAX( (tpp), ((l) + ((tpp) / 2)) / (tpp) * (tpp)) : \
740 NS_MIN(-(tpp), ((l) - ((tpp) / 2)) / (tpp) * (tpp)))
742 // Returns if the given border style type is visible or not
743 static PRBool IsVisibleBorderStyle(PRUint8 aStyle)
745 return (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
746 aStyle != NS_STYLE_BORDER_STYLE_HIDDEN);
749 struct nsStyleBorder {
750 nsStyleBorder(nsPresContext* aContext);
751 nsStyleBorder(const nsStyleBorder& aBorder);
752 ~nsStyleBorder();
754 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
755 void Destroy(nsPresContext* aContext);
757 nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
758 #ifdef DEBUG
759 static nsChangeHint MaxDifference();
760 #endif
761 static PRBool ForceCompare() { return PR_FALSE; }
762 PRBool ImageBorderDiffers() const;
764 nsStyleCorners mBorderRadius; // [reset] coord, percent, calc
765 nsStyleSides mBorderImageSplit; // [reset] integer, percent
766 PRUint8 mFloatEdge; // [reset] see nsStyleConsts.h
767 PRUint8 mBorderImageHFill; // [reset]
768 PRUint8 mBorderImageVFill; // [reset]
769 nsBorderColors** mBorderColors; // [reset] multiple levels of color for a border.
770 nsRefPtr<nsCSSShadowArray> mBoxShadow; // [reset] NULL for 'none'
771 PRBool mHaveBorderImageWidth; // [reset]
772 nsMargin mBorderImageWidth; // [reset]
774 void EnsureBorderColors() {
775 if (!mBorderColors) {
776 mBorderColors = new nsBorderColors*[4];
777 if (mBorderColors)
778 for (PRInt32 i = 0; i < 4; i++)
779 mBorderColors[i] = nsnull;
783 void ClearBorderColors(mozilla::css::Side aSide) {
784 if (mBorderColors && mBorderColors[aSide]) {
785 delete mBorderColors[aSide];
786 mBorderColors[aSide] = nsnull;
790 // Return whether aStyle is a visible style. Invisible styles cause
791 // the relevant computed border width to be 0.
792 // Note that this does *not* consider the effects of 'border-image':
793 // if border-style is none, but there is a loaded border image,
794 // HasVisibleStyle will be false even though there *is* a border.
795 PRBool HasVisibleStyle(mozilla::css::Side aSide)
797 return IsVisibleBorderStyle(GetBorderStyle(aSide));
800 // aBorderWidth is in twips
801 void SetBorderWidth(mozilla::css::Side aSide, nscoord aBorderWidth)
803 nscoord roundedWidth =
804 NS_ROUND_BORDER_TO_PIXELS(aBorderWidth, mTwipsPerPixel);
805 mBorder.side(aSide) = roundedWidth;
806 if (HasVisibleStyle(aSide))
807 mComputedBorder.side(aSide) = roundedWidth;
810 void SetBorderImageWidthOverride(mozilla::css::Side aSide, nscoord aBorderWidth)
812 mBorderImageWidth.side(aSide) =
813 NS_ROUND_BORDER_TO_PIXELS(aBorderWidth, mTwipsPerPixel);
816 // Get the actual border, in twips. (If there is no border-image
817 // loaded, this is the same as GetComputedBorder. If there is a
818 // border-image loaded, it uses the border-image width overrides if
819 // present, and otherwise mBorder, which is GetComputedBorder without
820 // considering border-style: none.)
821 const nsMargin& GetActualBorder() const;
823 // Get the computed border (plus rounding). This does consider the
824 // effects of 'border-style: none', but does not consider
825 // 'border-image'.
826 const nsMargin& GetComputedBorder() const
828 return mComputedBorder;
831 // Get the actual border width for a particular side, in appunits. Note that
832 // this is zero if and only if there is no border to be painted for this
833 // side. That is, this value takes into account the border style and the
834 // value is rounded to the nearest device pixel by NS_ROUND_BORDER_TO_PIXELS.
835 nscoord GetActualBorderWidth(mozilla::css::Side aSide) const
837 return GetActualBorder().side(aSide);
840 PRUint8 GetBorderStyle(mozilla::css::Side aSide) const
842 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
843 return (mBorderStyle[aSide] & BORDER_STYLE_MASK);
846 void SetBorderStyle(mozilla::css::Side aSide, PRUint8 aStyle)
848 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
849 mBorderStyle[aSide] &= ~BORDER_STYLE_MASK;
850 mBorderStyle[aSide] |= (aStyle & BORDER_STYLE_MASK);
851 mComputedBorder.side(aSide) =
852 (HasVisibleStyle(aSide) ? mBorder.side(aSide) : 0);
855 // Defined in nsStyleStructInlines.h
856 inline PRBool IsBorderImageLoaded() const;
857 inline nsresult RequestDecode();
859 void GetBorderColor(mozilla::css::Side aSide, nscolor& aColor,
860 PRBool& aForeground) const
862 aForeground = PR_FALSE;
863 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
864 if ((mBorderStyle[aSide] & BORDER_COLOR_SPECIAL) == 0)
865 aColor = mBorderColor[aSide];
866 else if (mBorderStyle[aSide] & BORDER_COLOR_FOREGROUND)
867 aForeground = PR_TRUE;
868 else
869 NS_NOTREACHED("OUTLINE_COLOR_INITIAL should not be set here");
872 void SetBorderColor(mozilla::css::Side aSide, nscolor aColor)
874 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
875 mBorderColor[aSide] = aColor;
876 mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
879 // These are defined in nsStyleStructInlines.h
880 inline void SetBorderImage(imgIRequest* aImage);
881 inline imgIRequest* GetBorderImage() const;
883 bool HasBorderImage() {return !!mBorderImage;}
885 void TrackImage(nsPresContext* aContext);
886 void UntrackImage(nsPresContext* aContext);
888 // These methods are used for the caller to caches the sub images created during
889 // a border-image paint operation
890 inline void SetSubImage(PRUint8 aIndex, imgIContainer* aSubImage) const;
891 inline imgIContainer* GetSubImage(PRUint8 aIndex) const;
893 void GetCompositeColors(PRInt32 aIndex, nsBorderColors** aColors) const
895 if (!mBorderColors)
896 *aColors = nsnull;
897 else
898 *aColors = mBorderColors[aIndex];
901 void AppendBorderColor(PRInt32 aIndex, nscolor aColor)
903 NS_ASSERTION(aIndex >= 0 && aIndex <= 3, "bad side for composite border color");
904 nsBorderColors* colorEntry = new nsBorderColors(aColor);
905 if (!mBorderColors[aIndex])
906 mBorderColors[aIndex] = colorEntry;
907 else {
908 nsBorderColors* last = mBorderColors[aIndex];
909 while (last->mNext)
910 last = last->mNext;
911 last->mNext = colorEntry;
913 mBorderStyle[aIndex] &= ~BORDER_COLOR_SPECIAL;
916 void SetBorderToForeground(mozilla::css::Side aSide)
918 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
919 mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
920 mBorderStyle[aSide] |= BORDER_COLOR_FOREGROUND;
923 #ifdef DEBUG
924 bool mImageTracked;
925 #endif
927 protected:
928 // mComputedBorder holds the CSS2.1 computed border-width values. In
929 // particular, these widths take into account the border-style for the
930 // relevant side and the values are rounded to the nearest device
931 // pixel. They are also rounded (which is not part of the definition
932 // of computed values). However, they do *not* take into account the
933 // presence of border-image. See GetActualBorder above for how to
934 // really get the actual border.
935 nsMargin mComputedBorder;
937 // mBorder holds the nscoord values for the border widths as they would be if
938 // all the border-style values were visible (not hidden or none). This
939 // member exists so that when we create structs using the copy
940 // constructor during style resolution the new structs will know what the
941 // specified values of the border were in case they have more specific rules
942 // setting the border style. Note that this isn't quite the CSS specified
943 // value, since this has had the enumerated border widths converted to
944 // lengths, and all lengths converted to twips. But it's not quite the
945 // computed value either. The values are rounded to the nearest device pixel
946 // We also use these values when we have a loaded border-image that
947 // does not have width overrides.
948 nsMargin mBorder;
950 PRUint8 mBorderStyle[4]; // [reset] See nsStyleConsts.h
951 nscolor mBorderColor[4]; // [reset] the colors to use for a simple border. not used
952 // if -moz-border-colors is specified
953 private:
954 nsCOMPtr<imgIRequest> mBorderImage; // [reset]
956 // Cache used by callers for border-image painting
957 nsCOMArray<imgIContainer> mSubImages;
959 nscoord mTwipsPerPixel;
961 nsStyleBorder& operator=(const nsStyleBorder& aOther); // Not to be implemented
965 struct nsStyleOutline {
966 nsStyleOutline(nsPresContext* aPresContext);
967 nsStyleOutline(const nsStyleOutline& aOutline);
968 ~nsStyleOutline(void) {
969 MOZ_COUNT_DTOR(nsStyleOutline);
972 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
973 return aContext->AllocateFromShell(sz);
975 void Destroy(nsPresContext* aContext) {
976 this->~nsStyleOutline();
977 aContext->FreeToShell(sizeof(nsStyleOutline), this);
980 void RecalcData(nsPresContext* aContext);
981 nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
982 #ifdef DEBUG
983 static nsChangeHint MaxDifference();
984 #endif
985 static PRBool ForceCompare() { return PR_FALSE; }
987 nsStyleCorners mOutlineRadius; // [reset] coord, percent, calc
989 // Note that this is a specified value. You can get the actual values
990 // with GetOutlineWidth. You cannot get the computed value directly.
991 nsStyleCoord mOutlineWidth; // [reset] coord, enum (see nsStyleConsts.h)
992 nscoord mOutlineOffset; // [reset]
994 PRBool GetOutlineWidth(nscoord& aWidth) const
996 if (mHasCachedOutline) {
997 aWidth = mCachedOutlineWidth;
998 return PR_TRUE;
1000 return PR_FALSE;
1003 PRUint8 GetOutlineStyle(void) const
1005 return (mOutlineStyle & BORDER_STYLE_MASK);
1008 void SetOutlineStyle(PRUint8 aStyle)
1010 mOutlineStyle &= ~BORDER_STYLE_MASK;
1011 mOutlineStyle |= (aStyle & BORDER_STYLE_MASK);
1014 // PR_FALSE means initial value
1015 PRBool GetOutlineColor(nscolor& aColor) const
1017 if ((mOutlineStyle & BORDER_COLOR_SPECIAL) == 0) {
1018 aColor = mOutlineColor;
1019 return PR_TRUE;
1021 return PR_FALSE;
1024 void SetOutlineColor(nscolor aColor)
1026 mOutlineColor = aColor;
1027 mOutlineStyle &= ~BORDER_COLOR_SPECIAL;
1030 void SetOutlineInitialColor()
1032 mOutlineStyle |= OUTLINE_COLOR_INITIAL;
1035 PRBool GetOutlineInitialColor() const
1037 return !!(mOutlineStyle & OUTLINE_COLOR_INITIAL);
1040 protected:
1041 // This value is the actual value, so it's rounded to the nearest device
1042 // pixel.
1043 nscoord mCachedOutlineWidth;
1045 nscolor mOutlineColor; // [reset]
1047 PRPackedBool mHasCachedOutline;
1048 PRUint8 mOutlineStyle; // [reset] See nsStyleConsts.h
1050 nscoord mTwipsPerPixel;
1054 struct nsStyleList {
1055 nsStyleList(void);
1056 nsStyleList(const nsStyleList& aStyleList);
1057 ~nsStyleList(void);
1059 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1060 return aContext->AllocateFromShell(sz);
1062 void Destroy(nsPresContext* aContext) {
1063 this->~nsStyleList();
1064 aContext->FreeToShell(sizeof(nsStyleList), this);
1067 nsChangeHint CalcDifference(const nsStyleList& aOther) const;
1068 #ifdef DEBUG
1069 static nsChangeHint MaxDifference();
1070 #endif
1071 static PRBool ForceCompare() { return PR_FALSE; }
1073 imgIRequest* GetListStyleImage() const { return mListStyleImage; }
1074 void SetListStyleImage(imgIRequest* aReq)
1076 if (mListStyleImage)
1077 mListStyleImage->UnlockImage();
1078 mListStyleImage = aReq;
1079 if (mListStyleImage)
1080 mListStyleImage->LockImage();
1083 PRUint8 mListStyleType; // [inherited] See nsStyleConsts.h
1084 PRUint8 mListStylePosition; // [inherited]
1085 private:
1086 nsCOMPtr<imgIRequest> mListStyleImage; // [inherited]
1087 nsStyleList& operator=(const nsStyleList& aOther); // Not to be implemented
1088 public:
1089 nsRect mImageRegion; // [inherited] the rect to use within an image
1092 struct nsStylePosition {
1093 nsStylePosition(void);
1094 nsStylePosition(const nsStylePosition& aOther);
1095 ~nsStylePosition(void);
1097 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1098 return aContext->AllocateFromShell(sz);
1100 void Destroy(nsPresContext* aContext) {
1101 this->~nsStylePosition();
1102 aContext->FreeToShell(sizeof(nsStylePosition), this);
1105 nsChangeHint CalcDifference(const nsStylePosition& aOther) const;
1106 #ifdef DEBUG
1107 static nsChangeHint MaxDifference();
1108 #endif
1109 static PRBool ForceCompare() { return PR_TRUE; }
1111 nsStyleSides mOffset; // [reset] coord, percent, calc, auto
1112 nsStyleCoord mWidth; // [reset] coord, percent, enum, calc, auto
1113 nsStyleCoord mMinWidth; // [reset] coord, percent, enum, calc
1114 nsStyleCoord mMaxWidth; // [reset] coord, percent, enum, calc, none
1115 nsStyleCoord mHeight; // [reset] coord, percent, calc, auto
1116 nsStyleCoord mMinHeight; // [reset] coord, percent, calc
1117 nsStyleCoord mMaxHeight; // [reset] coord, percent, calc, none
1118 PRUint8 mBoxSizing; // [reset] see nsStyleConsts.h
1119 nsStyleCoord mZIndex; // [reset] integer, auto
1121 PRBool WidthDependsOnContainer() const
1122 { return WidthCoordDependsOnContainer(mWidth); }
1123 PRBool MinWidthDependsOnContainer() const
1124 { return WidthCoordDependsOnContainer(mMinWidth); }
1125 PRBool MaxWidthDependsOnContainer() const
1126 { return WidthCoordDependsOnContainer(mMaxWidth); }
1128 // Note that these functions count 'auto' as depending on the
1129 // container since that's the case for absolutely positioned elements.
1130 // However, some callers do not care about this case and should check
1131 // for it, since it is the most common case.
1132 // FIXME: We should probably change the assumption to be the other way
1133 // around.
1134 PRBool HeightDependsOnContainer() const
1135 { return HeightCoordDependsOnContainer(mHeight); }
1136 PRBool MinHeightDependsOnContainer() const
1137 { return HeightCoordDependsOnContainer(mMinHeight); }
1138 PRBool MaxHeightDependsOnContainer() const
1139 { return HeightCoordDependsOnContainer(mMaxHeight); }
1141 PRBool OffsetHasPercent(mozilla::css::Side aSide) const
1143 return mOffset.Get(aSide).HasPercent();
1146 private:
1147 static PRBool WidthCoordDependsOnContainer(const nsStyleCoord &aCoord);
1148 static PRBool HeightCoordDependsOnContainer(const nsStyleCoord &aCoord)
1150 return aCoord.GetUnit() == eStyleUnit_Auto || // CSS 2.1, 10.6.4, item (5)
1151 aCoord.HasPercent();
1155 struct nsStyleTextReset {
1156 nsStyleTextReset(void);
1157 nsStyleTextReset(const nsStyleTextReset& aOther);
1158 ~nsStyleTextReset(void);
1160 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1161 return aContext->AllocateFromShell(sz);
1163 void Destroy(nsPresContext* aContext) {
1164 this->~nsStyleTextReset();
1165 aContext->FreeToShell(sizeof(nsStyleTextReset), this);
1168 nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
1169 #ifdef DEBUG
1170 static nsChangeHint MaxDifference();
1171 #endif
1172 static PRBool ForceCompare() { return PR_FALSE; }
1174 PRUint8 mTextDecoration; // [reset] see nsStyleConsts.h
1175 PRUint8 mUnicodeBidi; // [reset] see nsStyleConsts.h
1177 nsStyleCoord mVerticalAlign; // [reset] coord, percent, calc, enum (see nsStyleConsts.h)
1180 struct nsStyleText {
1181 nsStyleText(void);
1182 nsStyleText(const nsStyleText& aOther);
1183 ~nsStyleText(void);
1185 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1186 return aContext->AllocateFromShell(sz);
1188 void Destroy(nsPresContext* aContext) {
1189 this->~nsStyleText();
1190 aContext->FreeToShell(sizeof(nsStyleText), this);
1193 nsChangeHint CalcDifference(const nsStyleText& aOther) const;
1194 #ifdef DEBUG
1195 static nsChangeHint MaxDifference();
1196 #endif
1197 static PRBool ForceCompare() { return PR_FALSE; }
1199 PRUint8 mTextAlign; // [inherited] see nsStyleConsts.h
1200 PRUint8 mTextTransform; // [inherited] see nsStyleConsts.h
1201 PRUint8 mWhiteSpace; // [inherited] see nsStyleConsts.h
1202 PRUint8 mWordWrap; // [inherited] see nsStyleConsts.h
1203 PRInt32 mTabSize; // [inherited] see nsStyleConsts.h
1205 nsStyleCoord mLetterSpacing; // [inherited] coord, normal
1206 nsStyleCoord mLineHeight; // [inherited] coord, factor, normal
1207 nsStyleCoord mTextIndent; // [inherited] coord, percent, calc
1208 nscoord mWordSpacing; // [inherited]
1210 nsRefPtr<nsCSSShadowArray> mTextShadow; // [inherited] NULL in case of a zero-length
1212 PRBool WhiteSpaceIsSignificant() const {
1213 return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
1214 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP;
1217 PRBool NewlineIsSignificant() const {
1218 return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
1219 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP ||
1220 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE;
1223 PRBool WhiteSpaceCanWrap() const {
1224 return mWhiteSpace == NS_STYLE_WHITESPACE_NORMAL ||
1225 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP ||
1226 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE;
1229 PRBool WordCanWrap() const {
1230 return WhiteSpaceCanWrap() && mWordWrap == NS_STYLE_WORDWRAP_BREAK_WORD;
1234 struct nsStyleVisibility {
1235 nsStyleVisibility(nsPresContext* aPresContext);
1236 nsStyleVisibility(const nsStyleVisibility& aVisibility);
1237 ~nsStyleVisibility() {
1238 MOZ_COUNT_DTOR(nsStyleVisibility);
1241 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1242 return aContext->AllocateFromShell(sz);
1244 void Destroy(nsPresContext* aContext) {
1245 this->~nsStyleVisibility();
1246 aContext->FreeToShell(sizeof(nsStyleVisibility), this);
1249 nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
1250 #ifdef DEBUG
1251 static nsChangeHint MaxDifference();
1252 #endif
1253 static PRBool ForceCompare() { return PR_FALSE; }
1255 PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
1256 PRUint8 mVisible; // [inherited]
1257 nsCOMPtr<nsIAtom> mLanguage; // [inherited]
1258 PRUint8 mPointerEvents; // [inherited] see nsStyleConsts.h
1260 PRBool IsVisible() const {
1261 return (mVisible == NS_STYLE_VISIBILITY_VISIBLE);
1264 PRBool IsVisibleOrCollapsed() const {
1265 return ((mVisible == NS_STYLE_VISIBILITY_VISIBLE) ||
1266 (mVisible == NS_STYLE_VISIBILITY_COLLAPSE));
1270 struct nsTimingFunction {
1271 explicit nsTimingFunction(PRInt32 aTimingFunctionType
1272 = NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE)
1274 AssignFromKeyword(aTimingFunctionType);
1277 nsTimingFunction(float x1, float y1, float x2, float y2)
1278 : mX1(x1)
1279 , mY1(y1)
1280 , mX2(x2)
1281 , mY2(y2)
1284 float mX1;
1285 float mY1;
1286 float mX2;
1287 float mY2;
1289 PRBool operator==(const nsTimingFunction& aOther) const
1291 return !(*this != aOther);
1294 PRBool operator!=(const nsTimingFunction& aOther) const
1296 return mX1 != aOther.mX1 || mY1 != aOther.mY1 ||
1297 mX2 != aOther.mX2 || mY2 != aOther.mY2;
1300 private:
1301 void AssignFromKeyword(PRInt32 aTimingFunctionType);
1304 struct nsTransition {
1305 nsTransition() { /* leaves uninitialized; see also SetInitialValues */ }
1306 explicit nsTransition(const nsTransition& aCopy);
1308 void SetInitialValues();
1310 // Delay and Duration are in milliseconds
1312 nsTimingFunction& GetTimingFunction() { return mTimingFunction; }
1313 const nsTimingFunction& GetTimingFunction() const { return mTimingFunction; }
1314 float GetDelay() const { return mDelay; }
1315 float GetDuration() const { return mDuration; }
1316 nsCSSProperty GetProperty() const { return mProperty; }
1317 nsIAtom* GetUnknownProperty() const { return mUnknownProperty; }
1319 void SetTimingFunction(const nsTimingFunction& aTimingFunction)
1320 { mTimingFunction = aTimingFunction; }
1321 void SetDelay(float aDelay) { mDelay = aDelay; }
1322 void SetDuration(float aDuration) { mDuration = aDuration; }
1323 void SetProperty(nsCSSProperty aProperty)
1325 NS_ASSERTION(aProperty != eCSSProperty_UNKNOWN, "invalid property");
1326 mProperty = aProperty;
1328 void SetUnknownProperty(const nsAString& aUnknownProperty);
1329 void CopyPropertyFrom(const nsTransition& aOther)
1331 mProperty = aOther.mProperty;
1332 mUnknownProperty = aOther.mUnknownProperty;
1335 private:
1336 nsTimingFunction mTimingFunction;
1337 float mDuration;
1338 float mDelay;
1339 nsCSSProperty mProperty;
1340 nsCOMPtr<nsIAtom> mUnknownProperty; // used when mProperty is
1341 // eCSSProperty_UNKNOWN
1344 struct nsStyleDisplay {
1345 nsStyleDisplay();
1346 nsStyleDisplay(const nsStyleDisplay& aOther);
1347 ~nsStyleDisplay() {
1348 MOZ_COUNT_DTOR(nsStyleDisplay);
1351 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1352 return aContext->AllocateFromShell(sz);
1354 void Destroy(nsPresContext* aContext) {
1355 this->~nsStyleDisplay();
1356 aContext->FreeToShell(sizeof(nsStyleDisplay), this);
1359 nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
1360 #ifdef DEBUG
1361 static nsChangeHint MaxDifference();
1362 #endif
1363 static PRBool ForceCompare() { return PR_TRUE; }
1365 // We guarantee that if mBinding is non-null, so are mBinding->mURI and
1366 // mBinding->mOriginPrincipal.
1367 nsRefPtr<nsCSSValue::URL> mBinding; // [reset]
1368 nsRect mClip; // [reset] offsets from upper-left border edge
1369 float mOpacity; // [reset]
1370 PRUint8 mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
1371 PRUint8 mOriginalDisplay; // [reset] saved mDisplay for position:absolute/fixed
1372 PRUint8 mAppearance; // [reset]
1373 PRUint8 mPosition; // [reset] see nsStyleConsts.h
1374 PRUint8 mFloats; // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
1375 PRUint8 mBreakType; // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
1376 PRPackedBool mBreakBefore; // [reset]
1377 PRPackedBool mBreakAfter; // [reset]
1378 PRUint8 mOverflowX; // [reset] see nsStyleConsts.h
1379 PRUint8 mOverflowY; // [reset] see nsStyleConsts.h
1380 PRUint8 mResize; // [reset] see nsStyleConsts.h
1381 PRUint8 mClipFlags; // [reset] see nsStyleConsts.h
1383 // mSpecifiedTransform is the list of transform functions as
1384 // specified, or null to indicate there is no transform. (inherit or
1385 // initial are replaced by an actual list of transform functions, or
1386 // null, as appropriate.) (owned by the style rule)
1387 const nsCSSValueList *mSpecifiedTransform; // [reset]
1388 nsStyleTransformMatrix mTransform; // [reset] The stored transform matrix
1389 nsStyleCoord mTransformOrigin[2]; // [reset] percent, coord, calc
1391 nsAutoTArray<nsTransition, 1> mTransitions; // [reset]
1392 // The number of elements in mTransitions that are not from repeating
1393 // a list due to another property being longer.
1394 PRUint32 mTransitionTimingFunctionCount,
1395 mTransitionDurationCount,
1396 mTransitionDelayCount,
1397 mTransitionPropertyCount;
1399 PRBool IsBlockInside() const {
1400 return NS_STYLE_DISPLAY_BLOCK == mDisplay ||
1401 NS_STYLE_DISPLAY_LIST_ITEM == mDisplay ||
1402 NS_STYLE_DISPLAY_INLINE_BLOCK == mDisplay;
1403 // Should TABLE_CELL and TABLE_CAPTION go here? They have
1404 // block frames nested inside of them.
1405 // (But please audit all callers before changing.)
1408 PRBool IsBlockOutside() const {
1409 return NS_STYLE_DISPLAY_BLOCK == mDisplay ||
1410 NS_STYLE_DISPLAY_LIST_ITEM == mDisplay ||
1411 NS_STYLE_DISPLAY_TABLE == mDisplay;
1414 PRBool IsInlineOutside() const {
1415 return NS_STYLE_DISPLAY_INLINE == mDisplay ||
1416 NS_STYLE_DISPLAY_INLINE_BLOCK == mDisplay ||
1417 NS_STYLE_DISPLAY_INLINE_TABLE == mDisplay ||
1418 NS_STYLE_DISPLAY_INLINE_BOX == mDisplay ||
1419 NS_STYLE_DISPLAY_INLINE_GRID == mDisplay ||
1420 NS_STYLE_DISPLAY_INLINE_STACK == mDisplay;
1423 PRBool IsFloating() const {
1424 return NS_STYLE_FLOAT_NONE != mFloats;
1427 PRBool IsAbsolutelyPositioned() const {return (NS_STYLE_POSITION_ABSOLUTE == mPosition) ||
1428 (NS_STYLE_POSITION_FIXED == mPosition);}
1430 /* Returns true if we're positioned or there's a transform in effect. */
1431 PRBool IsPositioned() const {
1432 return IsAbsolutelyPositioned() ||
1433 NS_STYLE_POSITION_RELATIVE == mPosition || HasTransform();
1436 PRBool IsScrollableOverflow() const {
1437 // mOverflowX and mOverflowY always match when one of them is
1438 // NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP.
1439 return mOverflowX != NS_STYLE_OVERFLOW_VISIBLE &&
1440 mOverflowX != NS_STYLE_OVERFLOW_CLIP;
1443 // For table elements that don't support scroll frame creation, we
1444 // support 'overflow: hidden' to mean 'overflow: -moz-hidden-unscrollable'.
1445 PRBool IsTableClip() const {
1446 return mOverflowX == NS_STYLE_OVERFLOW_CLIP ||
1447 (mOverflowX == NS_STYLE_OVERFLOW_HIDDEN &&
1448 mOverflowY == NS_STYLE_OVERFLOW_HIDDEN);
1451 /* Returns whether the element has the -moz-transform property. */
1452 PRBool HasTransform() const {
1453 return mSpecifiedTransform != nsnull;
1457 struct nsStyleTable {
1458 nsStyleTable(void);
1459 nsStyleTable(const nsStyleTable& aOther);
1460 ~nsStyleTable(void);
1462 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1463 return aContext->AllocateFromShell(sz);
1465 void Destroy(nsPresContext* aContext) {
1466 this->~nsStyleTable();
1467 aContext->FreeToShell(sizeof(nsStyleTable), this);
1470 nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
1471 #ifdef DEBUG
1472 static nsChangeHint MaxDifference();
1473 #endif
1474 static PRBool ForceCompare() { return PR_FALSE; }
1476 PRUint8 mLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*
1477 PRUint8 mFrame; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_FRAME_*
1478 PRUint8 mRules; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_RULES_*
1479 PRInt32 mCols; // [reset] an integer if set, or see nsStyleConsts.h NS_STYLE_TABLE_COLS_*
1480 PRInt32 mSpan; // [reset] the number of columns spanned by a colgroup or col
1483 struct nsStyleTableBorder {
1484 nsStyleTableBorder(nsPresContext* aContext);
1485 nsStyleTableBorder(const nsStyleTableBorder& aOther);
1486 ~nsStyleTableBorder(void);
1488 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1489 return aContext->AllocateFromShell(sz);
1491 void Destroy(nsPresContext* aContext) {
1492 this->~nsStyleTableBorder();
1493 aContext->FreeToShell(sizeof(nsStyleTableBorder), this);
1496 nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
1497 #ifdef DEBUG
1498 static nsChangeHint MaxDifference();
1499 #endif
1500 static PRBool ForceCompare() { return PR_FALSE; }
1502 nscoord mBorderSpacingX;// [inherited]
1503 nscoord mBorderSpacingY;// [inherited]
1504 PRUint8 mBorderCollapse;// [inherited]
1505 PRUint8 mCaptionSide; // [inherited]
1506 PRUint8 mEmptyCells; // [inherited]
1509 enum nsStyleContentType {
1510 eStyleContentType_String = 1,
1511 eStyleContentType_Image = 10,
1512 eStyleContentType_Attr = 20,
1513 eStyleContentType_Counter = 30,
1514 eStyleContentType_Counters = 31,
1515 eStyleContentType_OpenQuote = 40,
1516 eStyleContentType_CloseQuote = 41,
1517 eStyleContentType_NoOpenQuote = 42,
1518 eStyleContentType_NoCloseQuote = 43,
1519 eStyleContentType_AltContent = 50
1522 struct nsStyleContentData {
1523 nsStyleContentType mType;
1524 union {
1525 PRUnichar *mString;
1526 imgIRequest *mImage;
1527 nsCSSValue::Array* mCounters;
1528 } mContent;
1529 #ifdef DEBUG
1530 bool mImageTracked;
1531 #endif
1533 nsStyleContentData()
1534 : mType(nsStyleContentType(0))
1535 #ifdef DEBUG
1536 , mImageTracked(false)
1537 #endif
1538 { mContent.mString = nsnull; }
1540 ~nsStyleContentData();
1541 nsStyleContentData& operator=(const nsStyleContentData& aOther);
1542 PRBool operator==(const nsStyleContentData& aOther) const;
1544 PRBool operator!=(const nsStyleContentData& aOther) const {
1545 return !(*this == aOther);
1548 void TrackImage(nsPresContext* aContext);
1549 void UntrackImage(nsPresContext* aContext);
1551 void SetImage(imgIRequest* aRequest)
1553 NS_ABORT_IF_FALSE(!mImageTracked,
1554 "Setting a new image without untracking the old one!");
1555 NS_ABORT_IF_FALSE(mType == eStyleContentType_Image, "Wrong type!");
1556 NS_IF_ADDREF(mContent.mImage = aRequest);
1558 private:
1559 nsStyleContentData(const nsStyleContentData&); // not to be implemented
1562 struct nsStyleCounterData {
1563 nsString mCounter;
1564 PRInt32 mValue;
1568 #define DELETE_ARRAY_IF(array) if (array) { delete[] array; array = nsnull; }
1570 struct nsStyleQuotes {
1571 nsStyleQuotes();
1572 nsStyleQuotes(const nsStyleQuotes& aQuotes);
1573 ~nsStyleQuotes();
1575 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1576 return aContext->AllocateFromShell(sz);
1578 void Destroy(nsPresContext* aContext) {
1579 this->~nsStyleQuotes();
1580 aContext->FreeToShell(sizeof(nsStyleQuotes), this);
1583 void SetInitial();
1584 void CopyFrom(const nsStyleQuotes& aSource);
1586 nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const;
1587 #ifdef DEBUG
1588 static nsChangeHint MaxDifference();
1589 #endif
1590 static PRBool ForceCompare() { return PR_FALSE; }
1592 PRUint32 QuotesCount(void) const { return mQuotesCount; } // [inherited]
1594 const nsString* OpenQuoteAt(PRUint32 aIndex) const
1596 NS_ASSERTION(aIndex < mQuotesCount, "out of range");
1597 return mQuotes + (aIndex * 2);
1599 const nsString* CloseQuoteAt(PRUint32 aIndex) const
1601 NS_ASSERTION(aIndex < mQuotesCount, "out of range");
1602 return mQuotes + (aIndex * 2 + 1);
1604 nsresult GetQuotesAt(PRUint32 aIndex, nsString& aOpen, nsString& aClose) const {
1605 if (aIndex < mQuotesCount) {
1606 aIndex *= 2;
1607 aOpen = mQuotes[aIndex];
1608 aClose = mQuotes[++aIndex];
1609 return NS_OK;
1611 return NS_ERROR_ILLEGAL_VALUE;
1614 nsresult AllocateQuotes(PRUint32 aCount) {
1615 if (aCount != mQuotesCount) {
1616 DELETE_ARRAY_IF(mQuotes);
1617 if (aCount) {
1618 mQuotes = new nsString[aCount * 2];
1619 if (! mQuotes) {
1620 mQuotesCount = 0;
1621 return NS_ERROR_OUT_OF_MEMORY;
1624 mQuotesCount = aCount;
1626 return NS_OK;
1629 nsresult SetQuotesAt(PRUint32 aIndex, const nsString& aOpen, const nsString& aClose) {
1630 if (aIndex < mQuotesCount) {
1631 aIndex *= 2;
1632 mQuotes[aIndex] = aOpen;
1633 mQuotes[++aIndex] = aClose;
1634 return NS_OK;
1636 return NS_ERROR_ILLEGAL_VALUE;
1639 protected:
1640 PRUint32 mQuotesCount;
1641 nsString* mQuotes;
1644 struct nsStyleContent {
1645 nsStyleContent(void);
1646 nsStyleContent(const nsStyleContent& aContent);
1647 ~nsStyleContent(void);
1649 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1650 return aContext->AllocateFromShell(sz);
1652 void Destroy(nsPresContext* aContext);
1654 nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
1655 #ifdef DEBUG
1656 static nsChangeHint MaxDifference();
1657 #endif
1658 static PRBool ForceCompare() { return PR_FALSE; }
1660 PRUint32 ContentCount(void) const { return mContentCount; } // [reset]
1662 const nsStyleContentData& ContentAt(PRUint32 aIndex) const {
1663 NS_ASSERTION(aIndex < mContentCount, "out of range");
1664 return mContents[aIndex];
1667 nsStyleContentData& ContentAt(PRUint32 aIndex) {
1668 NS_ASSERTION(aIndex < mContentCount, "out of range");
1669 return mContents[aIndex];
1672 nsresult AllocateContents(PRUint32 aCount);
1674 PRUint32 CounterIncrementCount(void) const { return mIncrementCount; } // [reset]
1675 const nsStyleCounterData* GetCounterIncrementAt(PRUint32 aIndex) const {
1676 NS_ASSERTION(aIndex < mIncrementCount, "out of range");
1677 return &mIncrements[aIndex];
1680 nsresult AllocateCounterIncrements(PRUint32 aCount) {
1681 if (aCount != mIncrementCount) {
1682 DELETE_ARRAY_IF(mIncrements);
1683 if (aCount) {
1684 mIncrements = new nsStyleCounterData[aCount];
1685 if (! mIncrements) {
1686 mIncrementCount = 0;
1687 return NS_ERROR_OUT_OF_MEMORY;
1690 mIncrementCount = aCount;
1692 return NS_OK;
1695 nsresult SetCounterIncrementAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aIncrement) {
1696 if (aIndex < mIncrementCount) {
1697 mIncrements[aIndex].mCounter = aCounter;
1698 mIncrements[aIndex].mValue = aIncrement;
1699 return NS_OK;
1701 return NS_ERROR_ILLEGAL_VALUE;
1704 PRUint32 CounterResetCount(void) const { return mResetCount; } // [reset]
1705 const nsStyleCounterData* GetCounterResetAt(PRUint32 aIndex) const {
1706 NS_ASSERTION(aIndex < mResetCount, "out of range");
1707 return &mResets[aIndex];
1710 nsresult AllocateCounterResets(PRUint32 aCount) {
1711 if (aCount != mResetCount) {
1712 DELETE_ARRAY_IF(mResets);
1713 if (aCount) {
1714 mResets = new nsStyleCounterData[aCount];
1715 if (! mResets) {
1716 mResetCount = 0;
1717 return NS_ERROR_OUT_OF_MEMORY;
1720 mResetCount = aCount;
1722 return NS_OK;
1725 nsresult SetCounterResetAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aValue) {
1726 if (aIndex < mResetCount) {
1727 mResets[aIndex].mCounter = aCounter;
1728 mResets[aIndex].mValue = aValue;
1729 return NS_OK;
1731 return NS_ERROR_ILLEGAL_VALUE;
1734 nsStyleCoord mMarkerOffset; // [reset] coord, auto
1736 protected:
1737 nsStyleContentData* mContents;
1738 nsStyleCounterData* mIncrements;
1739 nsStyleCounterData* mResets;
1741 PRUint32 mContentCount;
1742 PRUint32 mIncrementCount;
1743 PRUint32 mResetCount;
1746 struct nsStyleUIReset {
1747 nsStyleUIReset(void);
1748 nsStyleUIReset(const nsStyleUIReset& aOther);
1749 ~nsStyleUIReset(void);
1751 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1752 return aContext->AllocateFromShell(sz);
1754 void Destroy(nsPresContext* aContext) {
1755 this->~nsStyleUIReset();
1756 aContext->FreeToShell(sizeof(nsStyleUIReset), this);
1759 nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
1760 #ifdef DEBUG
1761 static nsChangeHint MaxDifference();
1762 #endif
1763 static PRBool ForceCompare() { return PR_FALSE; }
1765 PRUint8 mUserSelect; // [reset] (selection-style)
1766 PRUint8 mForceBrokenImageIcon; // [reset] (0 if not forcing, otherwise forcing)
1767 PRUint8 mIMEMode; // [reset]
1768 PRUint8 mWindowShadow; // [reset]
1771 struct nsCursorImage {
1772 PRBool mHaveHotspot;
1773 float mHotspotX, mHotspotY;
1775 nsCursorImage();
1776 nsCursorImage(const nsCursorImage& aOther);
1777 ~nsCursorImage();
1779 nsCursorImage& operator=(const nsCursorImage& aOther);
1781 * We hide mImage and force access through the getter and setter so that we
1782 * can lock the images we use. Cursor images are likely to be small, so we
1783 * don't care about discarding them. See bug 512260.
1784 * */
1785 void SetImage(imgIRequest *aImage) {
1786 if (mImage)
1787 mImage->UnlockImage();
1788 mImage = aImage;
1789 if (mImage)
1790 mImage->LockImage();
1792 imgIRequest* GetImage() const {
1793 return mImage;
1796 private:
1797 nsCOMPtr<imgIRequest> mImage;
1800 struct nsStyleUserInterface {
1801 nsStyleUserInterface(void);
1802 nsStyleUserInterface(const nsStyleUserInterface& aOther);
1803 ~nsStyleUserInterface(void);
1805 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1806 return aContext->AllocateFromShell(sz);
1808 void Destroy(nsPresContext* aContext) {
1809 this->~nsStyleUserInterface();
1810 aContext->FreeToShell(sizeof(nsStyleUserInterface), this);
1813 nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
1814 #ifdef DEBUG
1815 static nsChangeHint MaxDifference();
1816 #endif
1817 static PRBool ForceCompare() { return PR_FALSE; }
1819 PRUint8 mUserInput; // [inherited]
1820 PRUint8 mUserModify; // [inherited] (modify-content)
1821 PRUint8 mUserFocus; // [inherited] (auto-select)
1823 PRUint8 mCursor; // [inherited] See nsStyleConsts.h
1825 PRUint32 mCursorArrayLength;
1826 nsCursorImage *mCursorArray;// [inherited] The specified URL values
1827 // and coordinates. Takes precedence over
1828 // mCursor. Zero-length array is represented
1829 // by null pointer.
1831 // Does not free mCursorArray; the caller is responsible for calling
1832 // |delete [] mCursorArray| first if it is needed.
1833 void CopyCursorArrayFrom(const nsStyleUserInterface& aSource);
1836 struct nsStyleXUL {
1837 nsStyleXUL();
1838 nsStyleXUL(const nsStyleXUL& aSource);
1839 ~nsStyleXUL();
1841 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1842 return aContext->AllocateFromShell(sz);
1844 void Destroy(nsPresContext* aContext) {
1845 this->~nsStyleXUL();
1846 aContext->FreeToShell(sizeof(nsStyleXUL), this);
1849 nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
1850 #ifdef DEBUG
1851 static nsChangeHint MaxDifference();
1852 #endif
1853 static PRBool ForceCompare() { return PR_FALSE; }
1855 float mBoxFlex; // [reset] see nsStyleConsts.h
1856 PRUint32 mBoxOrdinal; // [reset] see nsStyleConsts.h
1857 PRUint8 mBoxAlign; // [reset] see nsStyleConsts.h
1858 PRUint8 mBoxDirection; // [reset] see nsStyleConsts.h
1859 PRUint8 mBoxOrient; // [reset] see nsStyleConsts.h
1860 PRUint8 mBoxPack; // [reset] see nsStyleConsts.h
1861 PRPackedBool mStretchStack; // [reset] see nsStyleConsts.h
1864 struct nsStyleColumn {
1865 nsStyleColumn(nsPresContext* aPresContext);
1866 nsStyleColumn(const nsStyleColumn& aSource);
1867 ~nsStyleColumn();
1869 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1870 return aContext->AllocateFromShell(sz);
1872 void Destroy(nsPresContext* aContext) {
1873 this->~nsStyleColumn();
1874 aContext->FreeToShell(sizeof(nsStyleColumn), this);
1877 nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
1878 #ifdef DEBUG
1879 static nsChangeHint MaxDifference();
1880 #endif
1881 static PRBool ForceCompare() { return PR_FALSE; }
1883 PRUint32 mColumnCount; // [reset] see nsStyleConsts.h
1884 nsStyleCoord mColumnWidth; // [reset] coord, auto
1885 nsStyleCoord mColumnGap; // [reset] coord, normal
1887 nscolor mColumnRuleColor; // [reset]
1888 PRUint8 mColumnRuleStyle; // [reset]
1889 // See https://bugzilla.mozilla.org/show_bug.cgi?id=271586#c43 for why
1890 // this is hard to replace with 'currentColor'.
1891 PRPackedBool mColumnRuleColorIsForeground;
1893 void SetColumnRuleWidth(nscoord aWidth) {
1894 mColumnRuleWidth = NS_ROUND_BORDER_TO_PIXELS(aWidth, mTwipsPerPixel);
1897 nscoord GetComputedColumnRuleWidth() const {
1898 return (IsVisibleBorderStyle(mColumnRuleStyle) ? mColumnRuleWidth : 0);
1901 protected:
1902 nscoord mColumnRuleWidth; // [reset] coord
1903 nscoord mTwipsPerPixel;
1906 enum nsStyleSVGPaintType {
1907 eStyleSVGPaintType_None = 1,
1908 eStyleSVGPaintType_Color,
1909 eStyleSVGPaintType_Server
1912 struct nsStyleSVGPaint
1914 union {
1915 nscolor mColor;
1916 nsIURI *mPaintServer;
1917 } mPaint;
1918 nsStyleSVGPaintType mType;
1919 nscolor mFallbackColor;
1921 nsStyleSVGPaint() : mType(nsStyleSVGPaintType(0)) { mPaint.mPaintServer = nsnull; }
1922 ~nsStyleSVGPaint();
1923 void SetType(nsStyleSVGPaintType aType);
1924 nsStyleSVGPaint& operator=(const nsStyleSVGPaint& aOther);
1925 PRBool operator==(const nsStyleSVGPaint& aOther) const;
1927 PRBool operator!=(const nsStyleSVGPaint& aOther) const {
1928 return !(*this == aOther);
1932 struct nsStyleSVG {
1933 nsStyleSVG();
1934 nsStyleSVG(const nsStyleSVG& aSource);
1935 ~nsStyleSVG();
1937 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1938 return aContext->AllocateFromShell(sz);
1940 void Destroy(nsPresContext* aContext) {
1941 this->~nsStyleSVG();
1942 aContext->FreeToShell(sizeof(nsStyleSVG), this);
1945 nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
1946 #ifdef DEBUG
1947 static nsChangeHint MaxDifference();
1948 #endif
1949 static PRBool ForceCompare() { return PR_FALSE; }
1951 nsStyleSVGPaint mFill; // [inherited]
1952 nsStyleSVGPaint mStroke; // [inherited]
1953 nsCOMPtr<nsIURI> mMarkerEnd; // [inherited]
1954 nsCOMPtr<nsIURI> mMarkerMid; // [inherited]
1955 nsCOMPtr<nsIURI> mMarkerStart; // [inherited]
1956 nsStyleCoord *mStrokeDasharray; // [inherited] coord, percent, factor
1958 nsStyleCoord mStrokeDashoffset; // [inherited] coord, percent, factor
1959 nsStyleCoord mStrokeWidth; // [inherited] coord, percent, factor
1961 float mFillOpacity; // [inherited]
1962 float mStrokeMiterlimit; // [inherited]
1963 float mStrokeOpacity; // [inherited]
1965 PRUint32 mStrokeDasharrayLength;
1966 PRUint8 mClipRule; // [inherited]
1967 PRUint8 mColorInterpolation; // [inherited] see nsStyleConsts.h
1968 PRUint8 mColorInterpolationFilters; // [inherited] see nsStyleConsts.h
1969 PRUint8 mFillRule; // [inherited] see nsStyleConsts.h
1970 PRUint8 mImageRendering; // [inherited] see nsStyleConsts.h
1971 PRUint8 mShapeRendering; // [inherited] see nsStyleConsts.h
1972 PRUint8 mStrokeLinecap; // [inherited] see nsStyleConsts.h
1973 PRUint8 mStrokeLinejoin; // [inherited] see nsStyleConsts.h
1974 PRUint8 mTextAnchor; // [inherited] see nsStyleConsts.h
1975 PRUint8 mTextRendering; // [inherited] see nsStyleConsts.h
1978 struct nsStyleSVGReset {
1979 nsStyleSVGReset();
1980 nsStyleSVGReset(const nsStyleSVGReset& aSource);
1981 ~nsStyleSVGReset();
1983 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1984 return aContext->AllocateFromShell(sz);
1986 void Destroy(nsPresContext* aContext) {
1987 this->~nsStyleSVGReset();
1988 aContext->FreeToShell(sizeof(nsStyleSVGReset), this);
1991 nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
1992 #ifdef DEBUG
1993 static nsChangeHint MaxDifference();
1994 #endif
1995 static PRBool ForceCompare() { return PR_FALSE; }
1997 nsCOMPtr<nsIURI> mClipPath; // [reset]
1998 nsCOMPtr<nsIURI> mFilter; // [reset]
1999 nsCOMPtr<nsIURI> mMask; // [reset]
2000 nscolor mStopColor; // [reset]
2001 nscolor mFloodColor; // [reset]
2002 nscolor mLightingColor; // [reset]
2004 float mStopOpacity; // [reset]
2005 float mFloodOpacity; // [reset]
2007 PRUint8 mDominantBaseline; // [reset] see nsStyleConsts.h
2010 #endif /* nsStyleStruct_h___ */