Bug 454376 add -lCrun -lCstd for Solaris OS_LIBS, r=bsmedberg
[wine-gecko.git] / layout / style / nsStyleStruct.h
blob95f6fb849d5d78e6eefea42a2d95d13a50ba29f9
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 <mats.palmgren@bredband.net>
24 * Masayuki Nakano <masayuki@d-toybox.com>
25 * Rob Arnold <robarnold@mozilla.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
42 * structs that contain the data provided by nsStyleContext, the
43 * internal API for computed style data for an element
46 #ifndef nsStyleStruct_h___
47 #define nsStyleStruct_h___
49 #include "nsColor.h"
50 #include "nsCoord.h"
51 #include "nsMargin.h"
52 #include "nsRect.h"
53 #include "nsFont.h"
54 #include "nsVoidArray.h"
55 #include "nsStyleCoord.h"
56 #include "nsStyleConsts.h"
57 #include "nsChangeHint.h"
58 #include "nsPresContext.h"
59 #include "nsIPresShell.h"
60 #include "nsCOMPtr.h"
61 #include "nsCOMArray.h"
62 #include "nsIAtom.h"
63 #include "nsIURI.h"
64 #include "nsCSSValue.h"
65 #include "nsStyleTransformMatrix.h"
67 class nsIFrame;
68 class imgIRequest;
70 // Includes nsStyleStructID.
71 #include "nsStyleStructFwd.h"
73 // Bits for each struct.
74 // NS_STYLE_INHERIT_BIT defined in nsStyleStructFwd.h
75 #define NS_STYLE_INHERIT_MASK 0x00ffffff
77 // Additional bits for nsStyleContext's mBits:
78 // A bit to test whether or not we have any text decorations.
79 #define NS_STYLE_HAS_TEXT_DECORATIONS 0x01000000
81 // Additional bits for nsRuleNode's mDependentBits:
82 #define NS_RULE_NODE_GC_MARK 0x02000000
83 #define NS_RULE_NODE_IS_IMPORTANT 0x08000000
84 #define NS_RULE_NODE_LEVEL_MASK 0xf0000000
85 #define NS_RULE_NODE_LEVEL_SHIFT 28
87 // The lifetime of these objects is managed by the presshell's arena.
89 struct nsStyleFont {
90 nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext);
91 nsStyleFont(const nsStyleFont& aStyleFont);
92 nsStyleFont(nsPresContext *aPresContext);
93 ~nsStyleFont(void) {}
95 nsChangeHint CalcDifference(const nsStyleFont& aOther) const;
96 #ifdef DEBUG
97 static nsChangeHint MaxDifference();
98 #endif
99 static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
101 static nscoord ZoomText(nsPresContext* aPresContext, nscoord aSize);
102 static nscoord UnZoomText(nsPresContext* aPresContext, nscoord aSize);
104 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
105 void Destroy(nsPresContext* aContext);
107 nsFont mFont; // [inherited]
108 nscoord mSize; // [inherited] Our "computed size". Can be different from mFont.size
109 // which is our "actual size" and is enforced to be >= the user's
110 // preferred min-size. mFont.size should be used for display purposes
111 // while mSize is the value to return in getComputedStyle() for example.
112 PRUint8 mFlags; // [inherited] See nsStyleConsts.h
114 #ifdef MOZ_MATHML
115 // MathML scriptlevel support
116 PRInt8 mScriptLevel; // [inherited]
117 // The value mSize would have had if scriptminsize had never been applied
118 nscoord mScriptUnconstrainedSize;
119 nscoord mScriptMinSize; // [inherited] length
120 float mScriptSizeMultiplier; // [inherited]
121 #endif
124 struct nsStyleColor {
125 nsStyleColor(nsPresContext* aPresContext);
126 nsStyleColor(const nsStyleColor& aOther);
127 ~nsStyleColor(void) {}
129 nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
130 #ifdef DEBUG
131 static nsChangeHint MaxDifference();
132 #endif
134 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
135 return aContext->AllocateFromShell(sz);
137 void Destroy(nsPresContext* aContext) {
138 this->~nsStyleColor();
139 aContext->FreeToShell(sizeof(nsStyleColor), this);
142 // Don't add ANY members to this struct! We can achieve caching in the rule
143 // tree (rather than the style tree) by letting color stay by itself! -dwh
144 nscolor mColor; // [inherited]
147 struct nsStyleBackground {
148 nsStyleBackground();
149 nsStyleBackground(const nsStyleBackground& aOther);
150 ~nsStyleBackground();
152 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
153 return aContext->AllocateFromShell(sz);
155 void Destroy(nsPresContext* aContext) {
156 this->~nsStyleBackground();
157 aContext->FreeToShell(sizeof(nsStyleBackground), this);
160 nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
161 #ifdef DEBUG
162 static nsChangeHint MaxDifference();
163 #endif
165 PRUint8 mBackgroundFlags; // [reset] See nsStyleConsts.h
166 PRUint8 mBackgroundAttachment; // [reset] See nsStyleConsts.h
167 PRUint8 mBackgroundClip; // [reset] See nsStyleConsts.h
168 PRUint8 mBackgroundInlinePolicy; // [reset] See nsStyleConsts.h
169 PRUint8 mBackgroundOrigin; // [reset] See nsStyleConsts.h
170 PRUint8 mBackgroundRepeat; // [reset] See nsStyleConsts.h
172 // Note: a member of this union is valid IFF the appropriate bit flag
173 // is set in mBackgroundFlags.
174 union {
175 nscoord mCoord;
176 float mFloat;
177 } mBackgroundXPosition, // [reset]
178 mBackgroundYPosition; // [reset]
180 nscolor mBackgroundColor; // [reset]
181 nsCOMPtr<imgIRequest> mBackgroundImage; // [reset]
183 // True if this background is completely transparent.
184 PRBool IsTransparent() const
186 return (NS_GET_A(mBackgroundColor) == 0 &&
187 (mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE));
190 // We have to take slower codepaths for fixed background attachment,
191 // but we don't want to do that when there's no image.
192 // Not inline because it uses an nsCOMPtr<imgIRequest>
193 // FIXME: Should be in nsStyleStructInlines.h.
194 PRBool HasFixedBackground() const;
197 // See https://bugzilla.mozilla.org/show_bug.cgi?id=271586#c43 for why
198 // this is hard to replace with 'currentColor'.
199 #define BORDER_COLOR_FOREGROUND 0x20
200 #define OUTLINE_COLOR_INITIAL 0x80
201 // FOREGROUND | INITIAL(OUTLINE)
202 #define BORDER_COLOR_SPECIAL 0xA0
203 #define BORDER_STYLE_MASK 0x1F
205 #define NS_SPACING_MARGIN 0
206 #define NS_SPACING_PADDING 1
207 #define NS_SPACING_BORDER 2
210 struct nsStyleMargin {
211 nsStyleMargin(void);
212 nsStyleMargin(const nsStyleMargin& aMargin);
213 ~nsStyleMargin(void) {}
215 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
216 void Destroy(nsPresContext* aContext);
218 void RecalcData();
219 nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
220 #ifdef DEBUG
221 static nsChangeHint MaxDifference();
222 #endif
224 nsStyleSides mMargin; // [reset] coord, percent, auto
226 PRBool GetMargin(nsMargin& aMargin) const
228 if (mHasCachedMargin) {
229 aMargin = mCachedMargin;
230 return PR_TRUE;
232 return PR_FALSE;
235 protected:
236 PRPackedBool mHasCachedMargin;
237 nsMargin mCachedMargin;
241 struct nsStylePadding {
242 nsStylePadding(void);
243 nsStylePadding(const nsStylePadding& aPadding);
244 ~nsStylePadding(void) {}
246 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
247 void Destroy(nsPresContext* aContext);
249 void RecalcData();
250 nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
251 #ifdef DEBUG
252 static nsChangeHint MaxDifference();
253 #endif
255 nsStyleSides mPadding; // [reset] coord, percent
257 PRBool GetPadding(nsMargin& aPadding) const
259 if (mHasCachedPadding) {
260 aPadding = mCachedPadding;
261 return PR_TRUE;
263 return PR_FALSE;
266 protected:
267 PRPackedBool mHasCachedPadding;
268 nsMargin mCachedPadding;
271 struct nsBorderColors {
272 nsBorderColors* mNext;
273 nscolor mColor;
275 nsBorderColors* CopyColors() {
276 nsBorderColors* next = nsnull;
277 if (mNext)
278 next = mNext->CopyColors();
279 return new nsBorderColors(mColor, next);
282 nsBorderColors() :mNext(nsnull) { mColor = NS_RGB(0,0,0); }
284 nsBorderColors(const nscolor& aColor, nsBorderColors* aNext=nsnull) {
285 mColor = aColor;
286 mNext = aNext;
289 ~nsBorderColors() {
290 delete mNext;
293 static PRBool Equal(const nsBorderColors* c1,
294 const nsBorderColors* c2) {
295 if (c1 == c2)
296 return PR_TRUE;
297 while (c1 && c2) {
298 if (c1->mColor != c2->mColor)
299 return PR_FALSE;
300 c1 = c1->mNext;
301 c2 = c2->mNext;
303 // both should be NULL if these are equal, otherwise one
304 // has more colors than another
305 return !c1 && !c2;
309 struct nsCSSShadowItem {
310 nscoord mXOffset;
311 nscoord mYOffset;
312 nscoord mRadius;
313 nscoord mSpread;
315 nscolor mColor;
316 PRPackedBool mHasColor; // Whether mColor should be used
318 nsCSSShadowItem() : mHasColor(PR_FALSE) {
319 MOZ_COUNT_CTOR(nsCSSShadowItem);
321 ~nsCSSShadowItem() {
322 MOZ_COUNT_DTOR(nsCSSShadowItem);
325 PRBool operator==(const nsCSSShadowItem& aOther) {
326 return (mXOffset == aOther.mXOffset &&
327 mYOffset == aOther.mYOffset &&
328 mRadius == aOther.mRadius &&
329 mHasColor == aOther.mHasColor &&
330 mSpread == aOther.mSpread &&
331 (!mHasColor || mColor == aOther.mColor));
333 PRBool operator!=(const nsCSSShadowItem& aOther) {
334 return !(*this == aOther);
338 class nsCSSShadowArray {
339 public:
340 void* operator new(size_t aBaseSize, PRUint32 aArrayLen) {
341 // We can allocate both this nsCSSShadowArray and the
342 // actual array in one allocation. The amount of memory to
343 // allocate is equal to the class's size + the number of bytes for all
344 // but the first array item (because aBaseSize includes one
345 // item, see the private declarations)
346 return ::operator new(aBaseSize +
347 (aArrayLen - 1) * sizeof(nsCSSShadowItem));
350 nsCSSShadowArray(PRUint32 aArrayLen) :
351 mLength(aArrayLen), mRefCnt(0)
353 MOZ_COUNT_CTOR(nsCSSShadowArray);
354 for (PRUint32 i = 1; i < mLength; ++i) {
355 // Make sure we call the constructors of each nsCSSShadowItem
356 // (the first one is called for us because we declared it under private)
357 new (&mArray[i]) nsCSSShadowItem();
360 ~nsCSSShadowArray() {
361 MOZ_COUNT_DTOR(nsCSSShadowArray);
362 for (PRUint32 i = 1; i < mLength; ++i) {
363 mArray[i].~nsCSSShadowItem();
367 nsrefcnt AddRef() { return ++mRefCnt; }
368 nsrefcnt Release();
370 PRUint32 Length() const { return mLength; }
371 nsCSSShadowItem* ShadowAt(PRUint32 i) {
372 NS_ABORT_IF_FALSE(i < mLength, "Accessing too high an index in the text shadow array!");
373 return &mArray[i];
375 const nsCSSShadowItem* ShadowAt(PRUint32 i) const {
376 NS_ABORT_IF_FALSE(i < mLength, "Accessing too high an index in the text shadow array!");
377 return &mArray[i];
380 private:
381 PRUint32 mLength;
382 PRUint32 mRefCnt;
383 nsCSSShadowItem mArray[1]; // This MUST be the last item
386 // Border widths are rounded to the nearest-below integer number of pixels,
387 // but values between zero and one device pixels are always rounded up to
388 // one device pixel.
389 #define NS_ROUND_BORDER_TO_PIXELS(l,tpp) \
390 ((l) == 0) ? 0 : PR_MAX((tpp), (l) / (tpp) * (tpp))
391 // Outline offset is rounded to the nearest integer number of pixels, but values
392 // between zero and one device pixels are always rounded up to one device pixel.
393 // Note that the offset can be negative.
394 #define NS_ROUND_OFFSET_TO_PIXELS(l,tpp) \
395 (((l) == 0) ? 0 : \
396 ((l) > 0) ? PR_MAX( (tpp), ((l) + ((tpp) / 2)) / (tpp) * (tpp)) : \
397 PR_MIN(-(tpp), ((l) - ((tpp) / 2)) / (tpp) * (tpp)))
399 // Returns if the given border style type is visible or not
400 static PRBool IsVisibleBorderStyle(PRUint8 aStyle)
402 return (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
403 aStyle != NS_STYLE_BORDER_STYLE_HIDDEN);
406 struct nsStyleBorder {
407 nsStyleBorder(nsPresContext* aContext);
408 nsStyleBorder(const nsStyleBorder& aBorder);
409 ~nsStyleBorder();
411 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
412 void Destroy(nsPresContext* aContext);
414 nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
415 #ifdef DEBUG
416 static nsChangeHint MaxDifference();
417 #endif
418 PRBool ImageBorderDiffers() const;
420 nsStyleSides mBorderRadius; // [reset] coord, percent
421 nsStyleSides mBorderImageSplit; // [reset] integer, percent
422 PRUint8 mFloatEdge; // [reset] see nsStyleConsts.h
423 PRUint8 mBorderImageHFill; // [reset]
424 PRUint8 mBorderImageVFill; // [reset]
425 nsBorderColors** mBorderColors; // [reset] multiple levels of color for a border.
426 nsRefPtr<nsCSSShadowArray> mBoxShadow; // [reset] NULL for 'none'
427 PRBool mHaveBorderImageWidth; // [reset]
428 nsMargin mBorderImageWidth; // [reset]
430 void EnsureBorderColors() {
431 if (!mBorderColors) {
432 mBorderColors = new nsBorderColors*[4];
433 if (mBorderColors)
434 for (PRInt32 i = 0; i < 4; i++)
435 mBorderColors[i] = nsnull;
439 void ClearBorderColors(PRUint8 aSide) {
440 if (mBorderColors[aSide]) {
441 delete mBorderColors[aSide];
442 mBorderColors[aSide] = nsnull;
446 // Return whether aStyle is a visible style. Invisible styles cause
447 // the relevant computed border width to be 0.
448 // Note that this does *not* consider the effects of 'border-image':
449 // if border-style is none, but there is a loaded border image,
450 // HasVisibleStyle will be false even though there *is* a border.
451 PRBool HasVisibleStyle(PRUint8 aSide)
453 return IsVisibleBorderStyle(GetBorderStyle(aSide));
456 // aBorderWidth is in twips
457 void SetBorderWidth(PRUint8 aSide, nscoord aBorderWidth)
459 nscoord roundedWidth =
460 NS_ROUND_BORDER_TO_PIXELS(aBorderWidth, mTwipsPerPixel);
461 mBorder.side(aSide) = roundedWidth;
462 if (HasVisibleStyle(aSide))
463 mComputedBorder.side(aSide) = roundedWidth;
466 void SetBorderImageWidthOverride(PRUint8 aSide, nscoord aBorderWidth)
468 mBorderImageWidth.side(aSide) =
469 NS_ROUND_BORDER_TO_PIXELS(aBorderWidth, mTwipsPerPixel);
472 // Get the actual border, in twips. (If there is no border-image
473 // loaded, this is the same as GetComputedBorder. If there is a
474 // border-image loaded, it uses the border-image width overrides if
475 // present, and otherwise mBorder, which is GetComputedBorder without
476 // considering border-style: none.)
477 const nsMargin& GetActualBorder() const;
479 // Get the computed border (plus rounding). This does consider the
480 // effects of 'border-style: none', but does not consider
481 // 'border-image'.
482 const nsMargin& GetComputedBorder() const
484 return mComputedBorder;
487 // Get the actual border width for a particular side, in twips. Note that
488 // this is zero if and only if there is no border to be painted for this
489 // side. That is, this value takes into account the border style and the
490 // value is rounded to the nearest device pixel by NS_ROUND_BORDER_TO_PIXELS.
491 nscoord GetActualBorderWidth(PRUint8 aSide) const
493 return GetActualBorder().side(aSide);
496 PRUint8 GetBorderStyle(PRUint8 aSide) const
498 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
499 return (mBorderStyle[aSide] & BORDER_STYLE_MASK);
502 void SetBorderStyle(PRUint8 aSide, PRUint8 aStyle)
504 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
505 mBorderStyle[aSide] &= ~BORDER_STYLE_MASK;
506 mBorderStyle[aSide] |= (aStyle & BORDER_STYLE_MASK);
507 mComputedBorder.side(aSide) =
508 (HasVisibleStyle(aSide) ? mBorder.side(aSide) : 0);
511 // Defined in nsStyleStructInlines.h
512 inline PRBool IsBorderImageLoaded() const;
514 void GetBorderColor(PRUint8 aSide, nscolor& aColor,
515 PRBool& aForeground) const
517 aForeground = PR_FALSE;
518 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
519 if ((mBorderStyle[aSide] & BORDER_COLOR_SPECIAL) == 0)
520 aColor = mBorderColor[aSide];
521 else if (mBorderStyle[aSide] & BORDER_COLOR_FOREGROUND)
522 aForeground = PR_TRUE;
523 else
524 NS_NOTREACHED("OUTLINE_COLOR_INITIAL should not be set here");
527 void SetBorderColor(PRUint8 aSide, nscolor aColor)
529 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
530 mBorderColor[aSide] = aColor;
531 mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
534 // These are defined in nsStyleStructInlines.h
535 inline void SetBorderImage(imgIRequest* aImage);
536 inline imgIRequest* GetBorderImage() const;
538 void GetCompositeColors(PRInt32 aIndex, nsBorderColors** aColors) const
540 if (!mBorderColors)
541 *aColors = nsnull;
542 else
543 *aColors = mBorderColors[aIndex];
546 void AppendBorderColor(PRInt32 aIndex, nscolor aColor)
548 NS_ASSERTION(aIndex >= 0 && aIndex <= 3, "bad side for composite border color");
549 nsBorderColors* colorEntry = new nsBorderColors(aColor);
550 if (!mBorderColors[aIndex])
551 mBorderColors[aIndex] = colorEntry;
552 else {
553 nsBorderColors* last = mBorderColors[aIndex];
554 while (last->mNext)
555 last = last->mNext;
556 last->mNext = colorEntry;
558 mBorderStyle[aIndex] &= ~BORDER_COLOR_SPECIAL;
561 void SetBorderToForeground(PRUint8 aSide)
563 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
564 mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
565 mBorderStyle[aSide] |= BORDER_COLOR_FOREGROUND;
568 protected:
569 // mComputedBorder holds the CSS2.1 computed border-width values. In
570 // particular, these widths take into account the border-style for the
571 // relevant side and the values are rounded to the nearest device
572 // pixel. They are also rounded (which is not part of the definition
573 // of computed values). However, they do *not* take into account the
574 // presence of border-image. See GetActualBorder above for how to
575 // really get the actual border.
576 nsMargin mComputedBorder;
578 // mBorder holds the nscoord values for the border widths as they would be if
579 // all the border-style values were visible (not hidden or none). This
580 // member exists so that when we create structs using the copy
581 // constructor during style resolution the new structs will know what the
582 // specified values of the border were in case they have more specific rules
583 // setting the border style. Note that this isn't quite the CSS specified
584 // value, since this has had the enumerated border widths converted to
585 // lengths, and all lengths converted to twips. But it's not quite the
586 // computed value either. The values are rounded to the nearest device pixel
587 // We also use these values when we have a loaded border-image that
588 // does not have width overrides.
589 nsMargin mBorder;
591 PRUint8 mBorderStyle[4]; // [reset] See nsStyleConsts.h
592 nscolor mBorderColor[4]; // [reset] the colors to use for a simple border. not used
593 // if -moz-border-colors is specified
595 nsCOMPtr<imgIRequest> mBorderImage; // [reset]
597 nscoord mTwipsPerPixel;
601 struct nsStyleOutline {
602 nsStyleOutline(nsPresContext* aPresContext);
603 nsStyleOutline(const nsStyleOutline& aOutline);
604 ~nsStyleOutline(void) {}
606 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
607 return aContext->AllocateFromShell(sz);
609 void Destroy(nsPresContext* aContext) {
610 this->~nsStyleOutline();
611 aContext->FreeToShell(sizeof(nsStyleOutline), this);
614 void RecalcData(nsPresContext* aContext);
615 nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
616 #ifdef DEBUG
617 static nsChangeHint MaxDifference();
618 #endif
620 nsStyleSides mOutlineRadius; // [reset] coord, percent
621 // (top=topLeft, right=topRight, bottom=bottomRight, left=bottomLeft)
623 // Note that this is a specified value. You can get the actual values
624 // with GetOutlineWidth. You cannot get the computed value directly.
625 nsStyleCoord mOutlineWidth; // [reset] coord, enum (see nsStyleConsts.h)
626 nscoord mOutlineOffset; // [reset]
628 PRBool GetOutlineWidth(nscoord& aWidth) const
630 if (mHasCachedOutline) {
631 aWidth = mCachedOutlineWidth;
632 return PR_TRUE;
634 return PR_FALSE;
637 PRUint8 GetOutlineStyle(void) const
639 return (mOutlineStyle & BORDER_STYLE_MASK);
642 void SetOutlineStyle(PRUint8 aStyle)
644 mOutlineStyle &= ~BORDER_STYLE_MASK;
645 mOutlineStyle |= (aStyle & BORDER_STYLE_MASK);
648 // PR_FALSE means initial value
649 PRBool GetOutlineColor(nscolor& aColor) const
651 if ((mOutlineStyle & BORDER_COLOR_SPECIAL) == 0) {
652 aColor = mOutlineColor;
653 return PR_TRUE;
655 return PR_FALSE;
658 void SetOutlineColor(nscolor aColor)
660 mOutlineColor = aColor;
661 mOutlineStyle &= ~BORDER_COLOR_SPECIAL;
664 void SetOutlineInitialColor()
666 mOutlineStyle |= OUTLINE_COLOR_INITIAL;
669 PRBool GetOutlineInitialColor() const
671 return !!(mOutlineStyle & OUTLINE_COLOR_INITIAL);
674 protected:
675 // This value is the actual value, so it's rounded to the nearest device
676 // pixel.
677 nscoord mCachedOutlineWidth;
679 nscolor mOutlineColor; // [reset]
681 PRPackedBool mHasCachedOutline;
682 PRUint8 mOutlineStyle; // [reset] See nsStyleConsts.h
684 nscoord mTwipsPerPixel;
688 struct nsStyleList {
689 nsStyleList(void);
690 nsStyleList(const nsStyleList& aStyleList);
691 ~nsStyleList(void);
693 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
694 return aContext->AllocateFromShell(sz);
696 void Destroy(nsPresContext* aContext) {
697 this->~nsStyleList();
698 aContext->FreeToShell(sizeof(nsStyleList), this);
701 nsChangeHint CalcDifference(const nsStyleList& aOther) const;
702 #ifdef DEBUG
703 static nsChangeHint MaxDifference();
704 #endif
706 PRUint8 mListStyleType; // [inherited] See nsStyleConsts.h
707 PRUint8 mListStylePosition; // [inherited]
708 nsCOMPtr<imgIRequest> mListStyleImage; // [inherited]
709 nsRect mImageRegion; // [inherited] the rect to use within an image
712 struct nsStylePosition {
713 nsStylePosition(void);
714 nsStylePosition(const nsStylePosition& aOther);
715 ~nsStylePosition(void);
717 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
718 return aContext->AllocateFromShell(sz);
720 void Destroy(nsPresContext* aContext) {
721 this->~nsStylePosition();
722 aContext->FreeToShell(sizeof(nsStylePosition), this);
725 nsChangeHint CalcDifference(const nsStylePosition& aOther) const;
726 #ifdef DEBUG
727 static nsChangeHint MaxDifference();
728 #endif
730 nsStyleSides mOffset; // [reset] coord, percent, auto
731 nsStyleCoord mWidth; // [reset] coord, percent, auto, enum
732 nsStyleCoord mMinWidth; // [reset] coord, percent, enum
733 nsStyleCoord mMaxWidth; // [reset] coord, percent, null, enum
734 nsStyleCoord mHeight; // [reset] coord, percent, auto
735 nsStyleCoord mMinHeight; // [reset] coord, percent
736 nsStyleCoord mMaxHeight; // [reset] coord, percent, null
737 PRUint8 mBoxSizing; // [reset] see nsStyleConsts.h
738 nsStyleCoord mZIndex; // [reset] integer, auto
741 struct nsStyleTextReset {
742 nsStyleTextReset(void);
743 nsStyleTextReset(const nsStyleTextReset& aOther);
744 ~nsStyleTextReset(void);
746 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
747 return aContext->AllocateFromShell(sz);
749 void Destroy(nsPresContext* aContext) {
750 this->~nsStyleTextReset();
751 aContext->FreeToShell(sizeof(nsStyleTextReset), this);
754 nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
755 #ifdef DEBUG
756 static nsChangeHint MaxDifference();
757 #endif
759 PRUint8 mTextDecoration; // [reset] see nsStyleConsts.h
760 PRUint8 mUnicodeBidi; // [reset] see nsStyleConsts.h
762 nsStyleCoord mVerticalAlign; // [reset] coord, percent, enum (see nsStyleConsts.h)
765 struct nsStyleText {
766 nsStyleText(void);
767 nsStyleText(const nsStyleText& aOther);
768 ~nsStyleText(void);
770 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
771 return aContext->AllocateFromShell(sz);
773 void Destroy(nsPresContext* aContext) {
774 this->~nsStyleText();
775 aContext->FreeToShell(sizeof(nsStyleText), this);
778 nsChangeHint CalcDifference(const nsStyleText& aOther) const;
779 #ifdef DEBUG
780 static nsChangeHint MaxDifference();
781 #endif
783 PRUint8 mTextAlign; // [inherited] see nsStyleConsts.h
784 PRUint8 mTextTransform; // [inherited] see nsStyleConsts.h
785 PRUint8 mWhiteSpace; // [inherited] see nsStyleConsts.h
786 PRUint8 mWordWrap; // [inherited] see nsStyleConsts.h
788 nsStyleCoord mLetterSpacing; // [inherited] coord, normal
789 nsStyleCoord mLineHeight; // [inherited] coord, factor, normal
790 nsStyleCoord mTextIndent; // [inherited] coord, percent
791 nsStyleCoord mWordSpacing; // [inherited] coord, normal
793 nsRefPtr<nsCSSShadowArray> mTextShadow; // [inherited] NULL in case of a zero-length
795 PRBool WhiteSpaceIsSignificant() const {
796 return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
797 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP;
800 PRBool NewlineIsSignificant() const {
801 return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
802 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP ||
803 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE;
806 PRBool WhiteSpaceCanWrap() const {
807 return mWhiteSpace == NS_STYLE_WHITESPACE_NORMAL ||
808 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP ||
809 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE;
812 PRBool WordCanWrap() const {
813 return mWordWrap == NS_STYLE_WORDWRAP_BREAK_WORD;
817 struct nsStyleVisibility {
818 nsStyleVisibility(nsPresContext* aPresContext);
819 nsStyleVisibility(const nsStyleVisibility& aVisibility);
820 ~nsStyleVisibility() {}
822 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
823 return aContext->AllocateFromShell(sz);
825 void Destroy(nsPresContext* aContext) {
826 this->~nsStyleVisibility();
827 aContext->FreeToShell(sizeof(nsStyleVisibility), this);
830 nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
831 #ifdef DEBUG
832 static nsChangeHint MaxDifference();
833 #endif
835 PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
836 PRUint8 mVisible; // [inherited]
837 nsCOMPtr<nsIAtom> mLangGroup; // [inherited]
839 PRBool IsVisible() const {
840 return (mVisible == NS_STYLE_VISIBILITY_VISIBLE);
843 PRBool IsVisibleOrCollapsed() const {
844 return ((mVisible == NS_STYLE_VISIBILITY_VISIBLE) ||
845 (mVisible == NS_STYLE_VISIBILITY_COLLAPSE));
849 struct nsStyleDisplay {
850 nsStyleDisplay();
851 nsStyleDisplay(const nsStyleDisplay& aOther);
852 ~nsStyleDisplay() {}
854 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
855 return aContext->AllocateFromShell(sz);
857 void Destroy(nsPresContext* aContext) {
858 this->~nsStyleDisplay();
859 aContext->FreeToShell(sizeof(nsStyleDisplay), this);
862 nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
863 #ifdef DEBUG
864 static nsChangeHint MaxDifference();
865 #endif
867 // We guarantee that if mBinding is non-null, so are mBinding->mURI and
868 // mBinding->mOriginPrincipal.
869 nsRefPtr<nsCSSValue::URL> mBinding; // [reset]
870 #if 0
871 // XXX This is how it is defined in the CSS2 spec, but the errata
872 // changed it to be consistent with the positioning draft and how
873 // Nav and IE implement it
874 nsMargin mClip; // [reset] offsets from respective edge
875 #else
876 nsRect mClip; // [reset] offsets from upper-left border edge
877 #endif
878 float mOpacity; // [reset]
879 PRUint8 mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
880 PRUint8 mOriginalDisplay; // [reset] saved mDisplay for position:absolute/fixed
881 PRUint8 mAppearance; // [reset]
882 PRUint8 mPosition; // [reset] see nsStyleConsts.h
883 PRUint8 mFloats; // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
884 PRUint8 mBreakType; // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
885 PRPackedBool mBreakBefore; // [reset]
886 PRPackedBool mBreakAfter; // [reset]
887 PRUint8 mOverflowX; // [reset] see nsStyleConsts.h
888 PRUint8 mOverflowY; // [reset] see nsStyleConsts.h
889 PRUint8 mClipFlags; // [reset] see nsStyleConsts.h
890 PRPackedBool mTransformPresent; // [reset] Whether there is a -moz-transform.
891 nsStyleTransformMatrix mTransform; // [reset] The stored transform matrix
892 nsStyleCoord mTransformOrigin[2]; // [reset] percent, coord.
894 PRBool IsBlockInside() const {
895 return NS_STYLE_DISPLAY_BLOCK == mDisplay ||
896 NS_STYLE_DISPLAY_LIST_ITEM == mDisplay ||
897 NS_STYLE_DISPLAY_INLINE_BLOCK == mDisplay;
898 // Should TABLE_CELL and TABLE_CAPTION go here? They have
899 // block frames nested inside of them.
900 // (But please audit all callers before changing.)
903 PRBool IsBlockOutside() const {
904 return NS_STYLE_DISPLAY_BLOCK == mDisplay ||
905 NS_STYLE_DISPLAY_LIST_ITEM == mDisplay ||
906 NS_STYLE_DISPLAY_TABLE == mDisplay;
909 PRBool IsInlineOutside() const {
910 return NS_STYLE_DISPLAY_INLINE == mDisplay ||
911 NS_STYLE_DISPLAY_INLINE_BLOCK == mDisplay ||
912 NS_STYLE_DISPLAY_INLINE_TABLE == mDisplay ||
913 NS_STYLE_DISPLAY_INLINE_BOX == mDisplay ||
914 NS_STYLE_DISPLAY_INLINE_GRID == mDisplay ||
915 NS_STYLE_DISPLAY_INLINE_STACK == mDisplay;
918 PRBool IsFloating() const {
919 return NS_STYLE_FLOAT_NONE != mFloats;
922 PRBool IsAbsolutelyPositioned() const {return (NS_STYLE_POSITION_ABSOLUTE == mPosition) ||
923 (NS_STYLE_POSITION_FIXED == mPosition);}
925 /* Returns true if we're positioned or there's a transform in effect. */
926 PRBool IsPositioned() const {
927 return IsAbsolutelyPositioned() ||
928 NS_STYLE_POSITION_RELATIVE == mPosition || mTransformPresent;
931 PRBool IsScrollableOverflow() const {
932 // mOverflowX and mOverflowY always match when one of them is
933 // NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP.
934 return mOverflowX != NS_STYLE_OVERFLOW_VISIBLE &&
935 mOverflowX != NS_STYLE_OVERFLOW_CLIP;
938 // For table elements that don't support scroll frame creation, we
939 // support 'overflow: hidden' to mean 'overflow: -moz-hidden-unscrollable'.
940 PRBool IsTableClip() const {
941 return mOverflowX == NS_STYLE_OVERFLOW_CLIP ||
942 (mOverflowX == NS_STYLE_OVERFLOW_HIDDEN &&
943 mOverflowY == NS_STYLE_OVERFLOW_HIDDEN);
946 /* Returns whether the element has the -moz-transform property. */
947 PRBool HasTransform() const {
948 return mTransformPresent;
952 struct nsStyleTable {
953 nsStyleTable(void);
954 nsStyleTable(const nsStyleTable& aOther);
955 ~nsStyleTable(void);
957 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
958 return aContext->AllocateFromShell(sz);
960 void Destroy(nsPresContext* aContext) {
961 this->~nsStyleTable();
962 aContext->FreeToShell(sizeof(nsStyleTable), this);
965 nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
966 #ifdef DEBUG
967 static nsChangeHint MaxDifference();
968 #endif
970 PRUint8 mLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*
971 PRUint8 mFrame; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_FRAME_*
972 PRUint8 mRules; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_RULES_*
973 PRInt32 mCols; // [reset] an integer if set, or see nsStyleConsts.h NS_STYLE_TABLE_COLS_*
974 PRInt32 mSpan; // [reset] the number of columns spanned by a colgroup or col
977 struct nsStyleTableBorder {
978 nsStyleTableBorder(nsPresContext* aContext);
979 nsStyleTableBorder(const nsStyleTableBorder& aOther);
980 ~nsStyleTableBorder(void);
982 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
983 return aContext->AllocateFromShell(sz);
985 void Destroy(nsPresContext* aContext) {
986 this->~nsStyleTableBorder();
987 aContext->FreeToShell(sizeof(nsStyleTableBorder), this);
990 nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
991 #ifdef DEBUG
992 static nsChangeHint MaxDifference();
993 #endif
995 nscoord mBorderSpacingX;// [inherited]
996 nscoord mBorderSpacingY;// [inherited]
997 PRUint8 mBorderCollapse;// [inherited]
998 PRUint8 mCaptionSide; // [inherited]
999 PRUint8 mEmptyCells; // [inherited]
1002 enum nsStyleContentType {
1003 eStyleContentType_String = 1,
1004 eStyleContentType_Image = 10,
1005 eStyleContentType_Attr = 20,
1006 eStyleContentType_Counter = 30,
1007 eStyleContentType_Counters = 31,
1008 eStyleContentType_OpenQuote = 40,
1009 eStyleContentType_CloseQuote = 41,
1010 eStyleContentType_NoOpenQuote = 42,
1011 eStyleContentType_NoCloseQuote = 43,
1012 eStyleContentType_AltContent = 50
1015 struct nsStyleContentData {
1016 nsStyleContentType mType;
1017 union {
1018 PRUnichar *mString;
1019 imgIRequest *mImage;
1020 nsCSSValue::Array* mCounters;
1021 } mContent;
1023 nsStyleContentData() : mType(nsStyleContentType(0)) { mContent.mString = nsnull; }
1024 ~nsStyleContentData();
1025 nsStyleContentData& operator=(const nsStyleContentData& aOther);
1026 PRBool operator==(const nsStyleContentData& aOther) const;
1028 PRBool operator!=(const nsStyleContentData& aOther) const {
1029 return !(*this == aOther);
1031 private:
1032 nsStyleContentData(const nsStyleContentData&); // not to be implemented
1035 struct nsStyleCounterData {
1036 nsString mCounter;
1037 PRInt32 mValue;
1041 #define DELETE_ARRAY_IF(array) if (array) { delete[] array; array = nsnull; }
1043 struct nsStyleQuotes {
1044 nsStyleQuotes();
1045 nsStyleQuotes(const nsStyleQuotes& aQuotes);
1046 ~nsStyleQuotes();
1048 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1049 return aContext->AllocateFromShell(sz);
1051 void Destroy(nsPresContext* aContext) {
1052 this->~nsStyleQuotes();
1053 aContext->FreeToShell(sizeof(nsStyleQuotes), this);
1056 void SetInitial();
1057 void CopyFrom(const nsStyleQuotes& aSource);
1059 nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const;
1060 #ifdef DEBUG
1061 static nsChangeHint MaxDifference();
1062 #endif
1064 PRUint32 QuotesCount(void) const { return mQuotesCount; } // [inherited]
1066 const nsString* OpenQuoteAt(PRUint32 aIndex) const
1068 NS_ASSERTION(aIndex < mQuotesCount, "out of range");
1069 return mQuotes + (aIndex * 2);
1071 const nsString* CloseQuoteAt(PRUint32 aIndex) const
1073 NS_ASSERTION(aIndex < mQuotesCount, "out of range");
1074 return mQuotes + (aIndex * 2 + 1);
1076 nsresult GetQuotesAt(PRUint32 aIndex, nsString& aOpen, nsString& aClose) const {
1077 if (aIndex < mQuotesCount) {
1078 aIndex *= 2;
1079 aOpen = mQuotes[aIndex];
1080 aClose = mQuotes[++aIndex];
1081 return NS_OK;
1083 return NS_ERROR_ILLEGAL_VALUE;
1086 nsresult AllocateQuotes(PRUint32 aCount) {
1087 if (aCount != mQuotesCount) {
1088 DELETE_ARRAY_IF(mQuotes);
1089 if (aCount) {
1090 mQuotes = new nsString[aCount * 2];
1091 if (! mQuotes) {
1092 mQuotesCount = 0;
1093 return NS_ERROR_OUT_OF_MEMORY;
1096 mQuotesCount = aCount;
1098 return NS_OK;
1101 nsresult SetQuotesAt(PRUint32 aIndex, const nsString& aOpen, const nsString& aClose) {
1102 if (aIndex < mQuotesCount) {
1103 aIndex *= 2;
1104 mQuotes[aIndex] = aOpen;
1105 mQuotes[++aIndex] = aClose;
1106 return NS_OK;
1108 return NS_ERROR_ILLEGAL_VALUE;
1111 protected:
1112 PRUint32 mQuotesCount;
1113 nsString* mQuotes;
1116 struct nsStyleContent {
1117 nsStyleContent(void);
1118 nsStyleContent(const nsStyleContent& aContent);
1119 ~nsStyleContent(void);
1121 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1122 return aContext->AllocateFromShell(sz);
1124 void Destroy(nsPresContext* aContext) {
1125 this->~nsStyleContent();
1126 aContext->FreeToShell(sizeof(nsStyleContent), this);
1129 nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
1130 #ifdef DEBUG
1131 static nsChangeHint MaxDifference();
1132 #endif
1134 PRUint32 ContentCount(void) const { return mContentCount; } // [reset]
1136 const nsStyleContentData& ContentAt(PRUint32 aIndex) const {
1137 NS_ASSERTION(aIndex < mContentCount, "out of range");
1138 return mContents[aIndex];
1141 nsStyleContentData& ContentAt(PRUint32 aIndex) {
1142 NS_ASSERTION(aIndex < mContentCount, "out of range");
1143 return mContents[aIndex];
1146 nsresult AllocateContents(PRUint32 aCount);
1148 PRUint32 CounterIncrementCount(void) const { return mIncrementCount; } // [reset]
1149 const nsStyleCounterData* GetCounterIncrementAt(PRUint32 aIndex) const {
1150 NS_ASSERTION(aIndex < mIncrementCount, "out of range");
1151 return &mIncrements[aIndex];
1154 nsresult AllocateCounterIncrements(PRUint32 aCount) {
1155 if (aCount != mIncrementCount) {
1156 DELETE_ARRAY_IF(mIncrements);
1157 if (aCount) {
1158 mIncrements = new nsStyleCounterData[aCount];
1159 if (! mIncrements) {
1160 mIncrementCount = 0;
1161 return NS_ERROR_OUT_OF_MEMORY;
1164 mIncrementCount = aCount;
1166 return NS_OK;
1169 nsresult SetCounterIncrementAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aIncrement) {
1170 if (aIndex < mIncrementCount) {
1171 mIncrements[aIndex].mCounter = aCounter;
1172 mIncrements[aIndex].mValue = aIncrement;
1173 return NS_OK;
1175 return NS_ERROR_ILLEGAL_VALUE;
1178 PRUint32 CounterResetCount(void) const { return mResetCount; } // [reset]
1179 const nsStyleCounterData* GetCounterResetAt(PRUint32 aIndex) const {
1180 NS_ASSERTION(aIndex < mResetCount, "out of range");
1181 return &mResets[aIndex];
1184 nsresult AllocateCounterResets(PRUint32 aCount) {
1185 if (aCount != mResetCount) {
1186 DELETE_ARRAY_IF(mResets);
1187 if (aCount) {
1188 mResets = new nsStyleCounterData[aCount];
1189 if (! mResets) {
1190 mResetCount = 0;
1191 return NS_ERROR_OUT_OF_MEMORY;
1194 mResetCount = aCount;
1196 return NS_OK;
1199 nsresult SetCounterResetAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aValue) {
1200 if (aIndex < mResetCount) {
1201 mResets[aIndex].mCounter = aCounter;
1202 mResets[aIndex].mValue = aValue;
1203 return NS_OK;
1205 return NS_ERROR_ILLEGAL_VALUE;
1208 nsStyleCoord mMarkerOffset; // [reset] coord, auto
1210 protected:
1211 PRUint32 mContentCount;
1212 nsStyleContentData* mContents;
1214 PRUint32 mIncrementCount;
1215 nsStyleCounterData* mIncrements;
1217 PRUint32 mResetCount;
1218 nsStyleCounterData* mResets;
1221 struct nsStyleUIReset {
1222 nsStyleUIReset(void);
1223 nsStyleUIReset(const nsStyleUIReset& aOther);
1224 ~nsStyleUIReset(void);
1226 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1227 return aContext->AllocateFromShell(sz);
1229 void Destroy(nsPresContext* aContext) {
1230 this->~nsStyleUIReset();
1231 aContext->FreeToShell(sizeof(nsStyleUIReset), this);
1234 nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
1235 #ifdef DEBUG
1236 static nsChangeHint MaxDifference();
1237 #endif
1239 PRUint8 mUserSelect; // [reset] (selection-style)
1240 PRUint8 mForceBrokenImageIcon; // [reset] (0 if not forcing, otherwise forcing)
1241 PRUint8 mIMEMode; // [reset]
1244 struct nsCursorImage {
1245 nsCOMPtr<imgIRequest> mImage;
1246 PRBool mHaveHotspot;
1247 float mHotspotX, mHotspotY;
1249 nsCursorImage();
1252 struct nsStyleUserInterface {
1253 nsStyleUserInterface(void);
1254 nsStyleUserInterface(const nsStyleUserInterface& aOther);
1255 ~nsStyleUserInterface(void);
1257 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1258 return aContext->AllocateFromShell(sz);
1260 void Destroy(nsPresContext* aContext) {
1261 this->~nsStyleUserInterface();
1262 aContext->FreeToShell(sizeof(nsStyleUserInterface), this);
1265 nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
1266 #ifdef DEBUG
1267 static nsChangeHint MaxDifference();
1268 #endif
1270 PRUint8 mUserInput; // [inherited]
1271 PRUint8 mUserModify; // [inherited] (modify-content)
1272 PRUint8 mUserFocus; // [inherited] (auto-select)
1274 PRUint8 mCursor; // [inherited] See nsStyleConsts.h
1276 PRUint32 mCursorArrayLength;
1277 nsCursorImage *mCursorArray;// [inherited] The specified URL values
1278 // and coordinates. Takes precedence over
1279 // mCursor. Zero-length array is represented
1280 // by null pointer.
1282 // Does not free mCursorArray; the caller is responsible for calling
1283 // |delete [] mCursorArray| first if it is needed.
1284 void CopyCursorArrayFrom(const nsStyleUserInterface& aSource);
1287 struct nsStyleXUL {
1288 nsStyleXUL();
1289 nsStyleXUL(const nsStyleXUL& aSource);
1290 ~nsStyleXUL();
1292 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1293 return aContext->AllocateFromShell(sz);
1295 void Destroy(nsPresContext* aContext) {
1296 this->~nsStyleXUL();
1297 aContext->FreeToShell(sizeof(nsStyleXUL), this);
1300 nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
1301 #ifdef DEBUG
1302 static nsChangeHint MaxDifference();
1303 #endif
1305 float mBoxFlex; // [reset] see nsStyleConsts.h
1306 PRUint32 mBoxOrdinal; // [reset] see nsStyleConsts.h
1307 PRUint8 mBoxAlign; // [reset] see nsStyleConsts.h
1308 PRUint8 mBoxDirection; // [reset] see nsStyleConsts.h
1309 PRUint8 mBoxOrient; // [reset] see nsStyleConsts.h
1310 PRUint8 mBoxPack; // [reset] see nsStyleConsts.h
1311 PRPackedBool mStretchStack; // [reset] see nsStyleConsts.h
1314 struct nsStyleColumn {
1315 nsStyleColumn(nsPresContext* aPresContext);
1316 nsStyleColumn(const nsStyleColumn& aSource);
1317 ~nsStyleColumn();
1319 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1320 return aContext->AllocateFromShell(sz);
1322 void Destroy(nsPresContext* aContext) {
1323 this->~nsStyleColumn();
1324 aContext->FreeToShell(sizeof(nsStyleColumn), this);
1327 nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
1328 #ifdef DEBUG
1329 static nsChangeHint MaxDifference();
1330 #endif
1332 PRUint32 mColumnCount; // [reset] see nsStyleConsts.h
1333 nsStyleCoord mColumnWidth; // [reset] coord, auto
1334 nsStyleCoord mColumnGap; // [reset] coord, percent, normal
1336 nscolor mColumnRuleColor; // [reset]
1337 PRUint8 mColumnRuleStyle; // [reset]
1338 // See https://bugzilla.mozilla.org/show_bug.cgi?id=271586#c43 for why
1339 // this is hard to replace with 'currentColor'.
1340 PRPackedBool mColumnRuleColorIsForeground;
1342 void SetColumnRuleWidth(nscoord aWidth) {
1343 mColumnRuleWidth = NS_ROUND_BORDER_TO_PIXELS(aWidth, mTwipsPerPixel);
1346 nscoord GetComputedColumnRuleWidth() const {
1347 return (IsVisibleBorderStyle(mColumnRuleStyle) ? mColumnRuleWidth : 0);
1350 protected:
1351 nscoord mColumnRuleWidth; // [reset] coord
1352 nscoord mTwipsPerPixel;
1355 #ifdef MOZ_SVG
1356 enum nsStyleSVGPaintType {
1357 eStyleSVGPaintType_None = 1,
1358 eStyleSVGPaintType_Color,
1359 eStyleSVGPaintType_Server
1362 struct nsStyleSVGPaint
1364 nsStyleSVGPaintType mType;
1365 union {
1366 nscolor mColor;
1367 nsIURI *mPaintServer;
1368 } mPaint;
1369 nscolor mFallbackColor;
1371 nsStyleSVGPaint() : mType(nsStyleSVGPaintType(0)) { mPaint.mPaintServer = nsnull; }
1372 ~nsStyleSVGPaint();
1373 void SetType(nsStyleSVGPaintType aType);
1374 nsStyleSVGPaint& operator=(const nsStyleSVGPaint& aOther);
1375 PRBool operator==(const nsStyleSVGPaint& aOther) const;
1377 PRBool operator!=(const nsStyleSVGPaint& aOther) const {
1378 return !(*this == aOther);
1382 struct nsStyleSVG {
1383 nsStyleSVG();
1384 nsStyleSVG(const nsStyleSVG& aSource);
1385 ~nsStyleSVG();
1387 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1388 return aContext->AllocateFromShell(sz);
1390 void Destroy(nsPresContext* aContext) {
1391 this->~nsStyleSVG();
1392 aContext->FreeToShell(sizeof(nsStyleSVG), this);
1395 nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
1396 #ifdef DEBUG
1397 static nsChangeHint MaxDifference();
1398 #endif
1400 nsStyleSVGPaint mFill; // [inherited]
1401 nsStyleSVGPaint mStroke; // [inherited]
1402 nsCOMPtr<nsIURI> mMarkerEnd; // [inherited]
1403 nsCOMPtr<nsIURI> mMarkerMid; // [inherited]
1404 nsCOMPtr<nsIURI> mMarkerStart; // [inherited]
1405 nsStyleCoord *mStrokeDasharray; // [inherited] coord, percent, factor
1407 nsStyleCoord mStrokeDashoffset; // [inherited] coord, percent, factor
1408 nsStyleCoord mStrokeWidth; // [inherited] coord, percent, factor
1410 float mFillOpacity; // [inherited]
1411 float mStrokeMiterlimit; // [inherited]
1412 float mStrokeOpacity; // [inherited]
1414 PRUint32 mStrokeDasharrayLength;
1415 PRUint8 mClipRule; // [inherited]
1416 PRUint8 mColorInterpolation; // [inherited] see nsStyleConsts.h
1417 PRUint8 mColorInterpolationFilters; // [inherited] see nsStyleConsts.h
1418 PRUint8 mFillRule; // [inherited] see nsStyleConsts.h
1419 PRUint8 mPointerEvents; // [inherited] see nsStyleConsts.h
1420 PRUint8 mShapeRendering; // [inherited] see nsStyleConsts.h
1421 PRUint8 mStrokeLinecap; // [inherited] see nsStyleConsts.h
1422 PRUint8 mStrokeLinejoin; // [inherited] see nsStyleConsts.h
1423 PRUint8 mTextAnchor; // [inherited] see nsStyleConsts.h
1424 PRUint8 mTextRendering; // [inherited] see nsStyleConsts.h
1427 struct nsStyleSVGReset {
1428 nsStyleSVGReset();
1429 nsStyleSVGReset(const nsStyleSVGReset& aSource);
1430 ~nsStyleSVGReset();
1432 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1433 return aContext->AllocateFromShell(sz);
1435 void Destroy(nsPresContext* aContext) {
1436 this->~nsStyleSVGReset();
1437 aContext->FreeToShell(sizeof(nsStyleSVGReset), this);
1440 nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
1441 #ifdef DEBUG
1442 static nsChangeHint MaxDifference();
1443 #endif
1445 nscolor mStopColor; // [reset]
1446 nscolor mFloodColor; // [reset]
1447 nscolor mLightingColor; // [reset]
1448 nsCOMPtr<nsIURI> mClipPath; // [reset]
1449 nsCOMPtr<nsIURI> mFilter; // [reset]
1450 nsCOMPtr<nsIURI> mMask; // [reset]
1452 float mStopOpacity; // [reset]
1453 float mFloodOpacity; // [reset]
1455 PRUint8 mDominantBaseline; // [reset] see nsStyleConsts.h
1457 #endif
1459 #endif /* nsStyleStruct_h___ */