Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / layout / style / nsStyleStruct.h
blobfcfdf961475f481f519678f0650e6dc81ed8123d
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
109 // from mFont.size which is our "actual size" and is
110 // enforced to be >= the user's preferred min-size.
111 // mFont.size should be used for display purposes
112 // while mSize is the value to return in
113 // getComputedStyle() for example.
114 PRUint8 mGenericID; // [inherited] generic CSS font family, if any;
115 // value is a kGenericFont_* constant, see nsFont.h.
117 #ifdef MOZ_MATHML
118 // MathML scriptlevel support
119 PRInt8 mScriptLevel; // [inherited]
120 // The value mSize would have had if scriptminsize had never been applied
121 nscoord mScriptUnconstrainedSize;
122 nscoord mScriptMinSize; // [inherited] length
123 float mScriptSizeMultiplier; // [inherited]
124 #endif
127 struct nsStyleColor {
128 nsStyleColor(nsPresContext* aPresContext);
129 nsStyleColor(const nsStyleColor& aOther);
130 ~nsStyleColor(void) {}
132 nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
133 #ifdef DEBUG
134 static nsChangeHint MaxDifference();
135 #endif
137 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
138 return aContext->AllocateFromShell(sz);
140 void Destroy(nsPresContext* aContext) {
141 this->~nsStyleColor();
142 aContext->FreeToShell(sizeof(nsStyleColor), this);
145 // Don't add ANY members to this struct! We can achieve caching in the rule
146 // tree (rather than the style tree) by letting color stay by itself! -dwh
147 nscolor mColor; // [inherited]
150 struct nsStyleBackground {
151 nsStyleBackground();
152 nsStyleBackground(const nsStyleBackground& aOther);
153 ~nsStyleBackground();
155 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
156 return aContext->AllocateFromShell(sz);
158 void Destroy(nsPresContext* aContext) {
159 this->~nsStyleBackground();
160 aContext->FreeToShell(sizeof(nsStyleBackground), this);
163 nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
164 #ifdef DEBUG
165 static nsChangeHint MaxDifference();
166 #endif
168 PRUint8 mBackgroundFlags; // [reset] See nsStyleConsts.h
169 PRUint8 mBackgroundAttachment; // [reset] See nsStyleConsts.h
170 PRUint8 mBackgroundClip; // [reset] See nsStyleConsts.h
171 PRUint8 mBackgroundInlinePolicy; // [reset] See nsStyleConsts.h
172 PRUint8 mBackgroundOrigin; // [reset] See nsStyleConsts.h
173 PRUint8 mBackgroundRepeat; // [reset] See nsStyleConsts.h
175 // Note: a member of this union is valid IFF the appropriate bit flag
176 // is set in mBackgroundFlags.
177 union {
178 nscoord mCoord;
179 float mFloat;
180 } mBackgroundXPosition, // [reset]
181 mBackgroundYPosition; // [reset]
183 nscolor mBackgroundColor; // [reset]
184 nsCOMPtr<imgIRequest> mBackgroundImage; // [reset]
186 // True if this background is completely transparent.
187 PRBool IsTransparent() const
189 return (NS_GET_A(mBackgroundColor) == 0 &&
190 (mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE));
193 // We have to take slower codepaths for fixed background attachment,
194 // but we don't want to do that when there's no image.
195 // Not inline because it uses an nsCOMPtr<imgIRequest>
196 // FIXME: Should be in nsStyleStructInlines.h.
197 PRBool HasFixedBackground() const;
200 // See https://bugzilla.mozilla.org/show_bug.cgi?id=271586#c43 for why
201 // this is hard to replace with 'currentColor'.
202 #define BORDER_COLOR_FOREGROUND 0x20
203 #define OUTLINE_COLOR_INITIAL 0x80
204 // FOREGROUND | INITIAL(OUTLINE)
205 #define BORDER_COLOR_SPECIAL 0xA0
206 #define BORDER_STYLE_MASK 0x1F
208 #define NS_SPACING_MARGIN 0
209 #define NS_SPACING_PADDING 1
210 #define NS_SPACING_BORDER 2
213 struct nsStyleMargin {
214 nsStyleMargin(void);
215 nsStyleMargin(const nsStyleMargin& aMargin);
216 ~nsStyleMargin(void) {}
218 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
219 void Destroy(nsPresContext* aContext);
221 void RecalcData();
222 nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
223 #ifdef DEBUG
224 static nsChangeHint MaxDifference();
225 #endif
227 nsStyleSides mMargin; // [reset] coord, percent, auto
229 PRBool GetMargin(nsMargin& aMargin) const
231 if (mHasCachedMargin) {
232 aMargin = mCachedMargin;
233 return PR_TRUE;
235 return PR_FALSE;
238 protected:
239 PRPackedBool mHasCachedMargin;
240 nsMargin mCachedMargin;
244 struct nsStylePadding {
245 nsStylePadding(void);
246 nsStylePadding(const nsStylePadding& aPadding);
247 ~nsStylePadding(void) {}
249 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
250 void Destroy(nsPresContext* aContext);
252 void RecalcData();
253 nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
254 #ifdef DEBUG
255 static nsChangeHint MaxDifference();
256 #endif
258 nsStyleSides mPadding; // [reset] coord, percent
260 PRBool GetPadding(nsMargin& aPadding) const
262 if (mHasCachedPadding) {
263 aPadding = mCachedPadding;
264 return PR_TRUE;
266 return PR_FALSE;
269 protected:
270 PRPackedBool mHasCachedPadding;
271 nsMargin mCachedPadding;
274 struct nsBorderColors {
275 nsBorderColors* mNext;
276 nscolor mColor;
278 nsBorderColors() : mNext(nsnull), mColor(NS_RGB(0,0,0)) {}
279 nsBorderColors(const nscolor& aColor) : mNext(nsnull), mColor(aColor) {}
280 ~nsBorderColors();
282 nsBorderColors* Clone() const { return Clone(PR_TRUE); }
284 static PRBool Equal(const nsBorderColors* c1,
285 const nsBorderColors* c2) {
286 if (c1 == c2)
287 return PR_TRUE;
288 while (c1 && c2) {
289 if (c1->mColor != c2->mColor)
290 return PR_FALSE;
291 c1 = c1->mNext;
292 c2 = c2->mNext;
294 // both should be NULL if these are equal, otherwise one
295 // has more colors than another
296 return !c1 && !c2;
299 private:
300 nsBorderColors* Clone(PRBool aDeep) const;
303 struct nsCSSShadowItem {
304 nscoord mXOffset;
305 nscoord mYOffset;
306 nscoord mRadius;
307 nscoord mSpread;
309 nscolor mColor;
310 PRPackedBool mHasColor; // Whether mColor should be used
312 nsCSSShadowItem() : mHasColor(PR_FALSE) {
313 MOZ_COUNT_CTOR(nsCSSShadowItem);
315 ~nsCSSShadowItem() {
316 MOZ_COUNT_DTOR(nsCSSShadowItem);
319 PRBool operator==(const nsCSSShadowItem& aOther) {
320 return (mXOffset == aOther.mXOffset &&
321 mYOffset == aOther.mYOffset &&
322 mRadius == aOther.mRadius &&
323 mHasColor == aOther.mHasColor &&
324 mSpread == aOther.mSpread &&
325 (!mHasColor || mColor == aOther.mColor));
327 PRBool operator!=(const nsCSSShadowItem& aOther) {
328 return !(*this == aOther);
332 class nsCSSShadowArray {
333 public:
334 void* operator new(size_t aBaseSize, PRUint32 aArrayLen) {
335 // We can allocate both this nsCSSShadowArray and the
336 // actual array in one allocation. The amount of memory to
337 // allocate is equal to the class's size + the number of bytes for all
338 // but the first array item (because aBaseSize includes one
339 // item, see the private declarations)
340 return ::operator new(aBaseSize +
341 (aArrayLen - 1) * sizeof(nsCSSShadowItem));
344 nsCSSShadowArray(PRUint32 aArrayLen) :
345 mLength(aArrayLen), mRefCnt(0)
347 MOZ_COUNT_CTOR(nsCSSShadowArray);
348 for (PRUint32 i = 1; i < mLength; ++i) {
349 // Make sure we call the constructors of each nsCSSShadowItem
350 // (the first one is called for us because we declared it under private)
351 new (&mArray[i]) nsCSSShadowItem();
354 ~nsCSSShadowArray() {
355 MOZ_COUNT_DTOR(nsCSSShadowArray);
356 for (PRUint32 i = 1; i < mLength; ++i) {
357 mArray[i].~nsCSSShadowItem();
361 nsrefcnt AddRef() { return ++mRefCnt; }
362 nsrefcnt Release();
364 PRUint32 Length() const { return mLength; }
365 nsCSSShadowItem* ShadowAt(PRUint32 i) {
366 NS_ABORT_IF_FALSE(i < mLength, "Accessing too high an index in the text shadow array!");
367 return &mArray[i];
369 const nsCSSShadowItem* ShadowAt(PRUint32 i) const {
370 NS_ABORT_IF_FALSE(i < mLength, "Accessing too high an index in the text shadow array!");
371 return &mArray[i];
374 private:
375 PRUint32 mLength;
376 PRUint32 mRefCnt;
377 nsCSSShadowItem mArray[1]; // This MUST be the last item
380 // Border widths are rounded to the nearest-below integer number of pixels,
381 // but values between zero and one device pixels are always rounded up to
382 // one device pixel.
383 #define NS_ROUND_BORDER_TO_PIXELS(l,tpp) \
384 ((l) == 0) ? 0 : PR_MAX((tpp), (l) / (tpp) * (tpp))
385 // Outline offset is rounded to the nearest integer number of pixels, but values
386 // between zero and one device pixels are always rounded up to one device pixel.
387 // Note that the offset can be negative.
388 #define NS_ROUND_OFFSET_TO_PIXELS(l,tpp) \
389 (((l) == 0) ? 0 : \
390 ((l) > 0) ? PR_MAX( (tpp), ((l) + ((tpp) / 2)) / (tpp) * (tpp)) : \
391 PR_MIN(-(tpp), ((l) - ((tpp) / 2)) / (tpp) * (tpp)))
393 // Returns if the given border style type is visible or not
394 static PRBool IsVisibleBorderStyle(PRUint8 aStyle)
396 return (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
397 aStyle != NS_STYLE_BORDER_STYLE_HIDDEN);
400 struct nsStyleBorder {
401 nsStyleBorder(nsPresContext* aContext);
402 nsStyleBorder(const nsStyleBorder& aBorder);
403 ~nsStyleBorder();
405 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
406 void Destroy(nsPresContext* aContext);
408 nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
409 #ifdef DEBUG
410 static nsChangeHint MaxDifference();
411 #endif
412 PRBool ImageBorderDiffers() const;
414 nsStyleCorners mBorderRadius; // [reset] coord, percent
415 nsStyleSides mBorderImageSplit; // [reset] integer, percent
416 PRUint8 mFloatEdge; // [reset] see nsStyleConsts.h
417 PRUint8 mBorderImageHFill; // [reset]
418 PRUint8 mBorderImageVFill; // [reset]
419 nsBorderColors** mBorderColors; // [reset] multiple levels of color for a border.
420 nsRefPtr<nsCSSShadowArray> mBoxShadow; // [reset] NULL for 'none'
421 PRBool mHaveBorderImageWidth; // [reset]
422 nsMargin mBorderImageWidth; // [reset]
424 void EnsureBorderColors() {
425 if (!mBorderColors) {
426 mBorderColors = new nsBorderColors*[4];
427 if (mBorderColors)
428 for (PRInt32 i = 0; i < 4; i++)
429 mBorderColors[i] = nsnull;
433 void ClearBorderColors(PRUint8 aSide) {
434 if (mBorderColors[aSide]) {
435 delete mBorderColors[aSide];
436 mBorderColors[aSide] = nsnull;
440 // Return whether aStyle is a visible style. Invisible styles cause
441 // the relevant computed border width to be 0.
442 // Note that this does *not* consider the effects of 'border-image':
443 // if border-style is none, but there is a loaded border image,
444 // HasVisibleStyle will be false even though there *is* a border.
445 PRBool HasVisibleStyle(PRUint8 aSide)
447 return IsVisibleBorderStyle(GetBorderStyle(aSide));
450 // aBorderWidth is in twips
451 void SetBorderWidth(PRUint8 aSide, nscoord aBorderWidth)
453 nscoord roundedWidth =
454 NS_ROUND_BORDER_TO_PIXELS(aBorderWidth, mTwipsPerPixel);
455 mBorder.side(aSide) = roundedWidth;
456 if (HasVisibleStyle(aSide))
457 mComputedBorder.side(aSide) = roundedWidth;
460 void SetBorderImageWidthOverride(PRUint8 aSide, nscoord aBorderWidth)
462 mBorderImageWidth.side(aSide) =
463 NS_ROUND_BORDER_TO_PIXELS(aBorderWidth, mTwipsPerPixel);
466 // Get the actual border, in twips. (If there is no border-image
467 // loaded, this is the same as GetComputedBorder. If there is a
468 // border-image loaded, it uses the border-image width overrides if
469 // present, and otherwise mBorder, which is GetComputedBorder without
470 // considering border-style: none.)
471 const nsMargin& GetActualBorder() const;
473 // Get the computed border (plus rounding). This does consider the
474 // effects of 'border-style: none', but does not consider
475 // 'border-image'.
476 const nsMargin& GetComputedBorder() const
478 return mComputedBorder;
481 // Get the actual border width for a particular side, in twips. Note that
482 // this is zero if and only if there is no border to be painted for this
483 // side. That is, this value takes into account the border style and the
484 // value is rounded to the nearest device pixel by NS_ROUND_BORDER_TO_PIXELS.
485 nscoord GetActualBorderWidth(PRUint8 aSide) const
487 return GetActualBorder().side(aSide);
490 PRUint8 GetBorderStyle(PRUint8 aSide) const
492 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
493 return (mBorderStyle[aSide] & BORDER_STYLE_MASK);
496 void SetBorderStyle(PRUint8 aSide, PRUint8 aStyle)
498 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
499 mBorderStyle[aSide] &= ~BORDER_STYLE_MASK;
500 mBorderStyle[aSide] |= (aStyle & BORDER_STYLE_MASK);
501 mComputedBorder.side(aSide) =
502 (HasVisibleStyle(aSide) ? mBorder.side(aSide) : 0);
505 // Defined in nsStyleStructInlines.h
506 inline PRBool IsBorderImageLoaded() const;
508 void GetBorderColor(PRUint8 aSide, nscolor& aColor,
509 PRBool& aForeground) const
511 aForeground = PR_FALSE;
512 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
513 if ((mBorderStyle[aSide] & BORDER_COLOR_SPECIAL) == 0)
514 aColor = mBorderColor[aSide];
515 else if (mBorderStyle[aSide] & BORDER_COLOR_FOREGROUND)
516 aForeground = PR_TRUE;
517 else
518 NS_NOTREACHED("OUTLINE_COLOR_INITIAL should not be set here");
521 void SetBorderColor(PRUint8 aSide, nscolor aColor)
523 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
524 mBorderColor[aSide] = aColor;
525 mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
528 // These are defined in nsStyleStructInlines.h
529 inline void SetBorderImage(imgIRequest* aImage);
530 inline imgIRequest* GetBorderImage() const;
532 void GetCompositeColors(PRInt32 aIndex, nsBorderColors** aColors) const
534 if (!mBorderColors)
535 *aColors = nsnull;
536 else
537 *aColors = mBorderColors[aIndex];
540 void AppendBorderColor(PRInt32 aIndex, nscolor aColor)
542 NS_ASSERTION(aIndex >= 0 && aIndex <= 3, "bad side for composite border color");
543 nsBorderColors* colorEntry = new nsBorderColors(aColor);
544 if (!mBorderColors[aIndex])
545 mBorderColors[aIndex] = colorEntry;
546 else {
547 nsBorderColors* last = mBorderColors[aIndex];
548 while (last->mNext)
549 last = last->mNext;
550 last->mNext = colorEntry;
552 mBorderStyle[aIndex] &= ~BORDER_COLOR_SPECIAL;
555 void SetBorderToForeground(PRUint8 aSide)
557 NS_ASSERTION(aSide <= NS_SIDE_LEFT, "bad side");
558 mBorderStyle[aSide] &= ~BORDER_COLOR_SPECIAL;
559 mBorderStyle[aSide] |= BORDER_COLOR_FOREGROUND;
562 protected:
563 // mComputedBorder holds the CSS2.1 computed border-width values. In
564 // particular, these widths take into account the border-style for the
565 // relevant side and the values are rounded to the nearest device
566 // pixel. They are also rounded (which is not part of the definition
567 // of computed values). However, they do *not* take into account the
568 // presence of border-image. See GetActualBorder above for how to
569 // really get the actual border.
570 nsMargin mComputedBorder;
572 // mBorder holds the nscoord values for the border widths as they would be if
573 // all the border-style values were visible (not hidden or none). This
574 // member exists so that when we create structs using the copy
575 // constructor during style resolution the new structs will know what the
576 // specified values of the border were in case they have more specific rules
577 // setting the border style. Note that this isn't quite the CSS specified
578 // value, since this has had the enumerated border widths converted to
579 // lengths, and all lengths converted to twips. But it's not quite the
580 // computed value either. The values are rounded to the nearest device pixel
581 // We also use these values when we have a loaded border-image that
582 // does not have width overrides.
583 nsMargin mBorder;
585 PRUint8 mBorderStyle[4]; // [reset] See nsStyleConsts.h
586 nscolor mBorderColor[4]; // [reset] the colors to use for a simple border. not used
587 // if -moz-border-colors is specified
589 nsCOMPtr<imgIRequest> mBorderImage; // [reset]
591 nscoord mTwipsPerPixel;
595 struct nsStyleOutline {
596 nsStyleOutline(nsPresContext* aPresContext);
597 nsStyleOutline(const nsStyleOutline& aOutline);
598 ~nsStyleOutline(void) {}
600 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
601 return aContext->AllocateFromShell(sz);
603 void Destroy(nsPresContext* aContext) {
604 this->~nsStyleOutline();
605 aContext->FreeToShell(sizeof(nsStyleOutline), this);
608 void RecalcData(nsPresContext* aContext);
609 nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
610 #ifdef DEBUG
611 static nsChangeHint MaxDifference();
612 #endif
614 nsStyleCorners mOutlineRadius; // [reset] coord, percent
616 // Note that this is a specified value. You can get the actual values
617 // with GetOutlineWidth. You cannot get the computed value directly.
618 nsStyleCoord mOutlineWidth; // [reset] coord, enum (see nsStyleConsts.h)
619 nscoord mOutlineOffset; // [reset]
621 PRBool GetOutlineWidth(nscoord& aWidth) const
623 if (mHasCachedOutline) {
624 aWidth = mCachedOutlineWidth;
625 return PR_TRUE;
627 return PR_FALSE;
630 PRUint8 GetOutlineStyle(void) const
632 return (mOutlineStyle & BORDER_STYLE_MASK);
635 void SetOutlineStyle(PRUint8 aStyle)
637 mOutlineStyle &= ~BORDER_STYLE_MASK;
638 mOutlineStyle |= (aStyle & BORDER_STYLE_MASK);
641 // PR_FALSE means initial value
642 PRBool GetOutlineColor(nscolor& aColor) const
644 if ((mOutlineStyle & BORDER_COLOR_SPECIAL) == 0) {
645 aColor = mOutlineColor;
646 return PR_TRUE;
648 return PR_FALSE;
651 void SetOutlineColor(nscolor aColor)
653 mOutlineColor = aColor;
654 mOutlineStyle &= ~BORDER_COLOR_SPECIAL;
657 void SetOutlineInitialColor()
659 mOutlineStyle |= OUTLINE_COLOR_INITIAL;
662 PRBool GetOutlineInitialColor() const
664 return !!(mOutlineStyle & OUTLINE_COLOR_INITIAL);
667 protected:
668 // This value is the actual value, so it's rounded to the nearest device
669 // pixel.
670 nscoord mCachedOutlineWidth;
672 nscolor mOutlineColor; // [reset]
674 PRPackedBool mHasCachedOutline;
675 PRUint8 mOutlineStyle; // [reset] See nsStyleConsts.h
677 nscoord mTwipsPerPixel;
681 struct nsStyleList {
682 nsStyleList(void);
683 nsStyleList(const nsStyleList& aStyleList);
684 ~nsStyleList(void);
686 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
687 return aContext->AllocateFromShell(sz);
689 void Destroy(nsPresContext* aContext) {
690 this->~nsStyleList();
691 aContext->FreeToShell(sizeof(nsStyleList), this);
694 nsChangeHint CalcDifference(const nsStyleList& aOther) const;
695 #ifdef DEBUG
696 static nsChangeHint MaxDifference();
697 #endif
699 PRUint8 mListStyleType; // [inherited] See nsStyleConsts.h
700 PRUint8 mListStylePosition; // [inherited]
701 nsCOMPtr<imgIRequest> mListStyleImage; // [inherited]
702 nsRect mImageRegion; // [inherited] the rect to use within an image
705 struct nsStylePosition {
706 nsStylePosition(void);
707 nsStylePosition(const nsStylePosition& aOther);
708 ~nsStylePosition(void);
710 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
711 return aContext->AllocateFromShell(sz);
713 void Destroy(nsPresContext* aContext) {
714 this->~nsStylePosition();
715 aContext->FreeToShell(sizeof(nsStylePosition), this);
718 nsChangeHint CalcDifference(const nsStylePosition& aOther) const;
719 #ifdef DEBUG
720 static nsChangeHint MaxDifference();
721 #endif
723 nsStyleSides mOffset; // [reset] coord, percent, auto
724 nsStyleCoord mWidth; // [reset] coord, percent, auto, enum
725 nsStyleCoord mMinWidth; // [reset] coord, percent, enum
726 nsStyleCoord mMaxWidth; // [reset] coord, percent, null, enum
727 nsStyleCoord mHeight; // [reset] coord, percent, auto
728 nsStyleCoord mMinHeight; // [reset] coord, percent
729 nsStyleCoord mMaxHeight; // [reset] coord, percent, null
730 PRUint8 mBoxSizing; // [reset] see nsStyleConsts.h
731 nsStyleCoord mZIndex; // [reset] integer, auto
734 struct nsStyleTextReset {
735 nsStyleTextReset(void);
736 nsStyleTextReset(const nsStyleTextReset& aOther);
737 ~nsStyleTextReset(void);
739 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
740 return aContext->AllocateFromShell(sz);
742 void Destroy(nsPresContext* aContext) {
743 this->~nsStyleTextReset();
744 aContext->FreeToShell(sizeof(nsStyleTextReset), this);
747 nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
748 #ifdef DEBUG
749 static nsChangeHint MaxDifference();
750 #endif
752 PRUint8 mTextDecoration; // [reset] see nsStyleConsts.h
753 PRUint8 mUnicodeBidi; // [reset] see nsStyleConsts.h
755 nsStyleCoord mVerticalAlign; // [reset] coord, percent, enum (see nsStyleConsts.h)
758 struct nsStyleText {
759 nsStyleText(void);
760 nsStyleText(const nsStyleText& aOther);
761 ~nsStyleText(void);
763 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
764 return aContext->AllocateFromShell(sz);
766 void Destroy(nsPresContext* aContext) {
767 this->~nsStyleText();
768 aContext->FreeToShell(sizeof(nsStyleText), this);
771 nsChangeHint CalcDifference(const nsStyleText& aOther) const;
772 #ifdef DEBUG
773 static nsChangeHint MaxDifference();
774 #endif
776 PRUint8 mTextAlign; // [inherited] see nsStyleConsts.h
777 PRUint8 mTextTransform; // [inherited] see nsStyleConsts.h
778 PRUint8 mWhiteSpace; // [inherited] see nsStyleConsts.h
779 PRUint8 mWordWrap; // [inherited] see nsStyleConsts.h
781 nsStyleCoord mLetterSpacing; // [inherited] coord, normal
782 nsStyleCoord mLineHeight; // [inherited] coord, factor, normal
783 nsStyleCoord mTextIndent; // [inherited] coord, percent
784 nsStyleCoord mWordSpacing; // [inherited] coord, normal
786 nsRefPtr<nsCSSShadowArray> mTextShadow; // [inherited] NULL in case of a zero-length
788 PRBool WhiteSpaceIsSignificant() const {
789 return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
790 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP;
793 PRBool NewlineIsSignificant() const {
794 return mWhiteSpace == NS_STYLE_WHITESPACE_PRE ||
795 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP ||
796 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE;
799 PRBool WhiteSpaceCanWrap() const {
800 return mWhiteSpace == NS_STYLE_WHITESPACE_NORMAL ||
801 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP ||
802 mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE;
805 PRBool WordCanWrap() const {
806 return WhiteSpaceCanWrap() && mWordWrap == NS_STYLE_WORDWRAP_BREAK_WORD;
810 struct nsStyleVisibility {
811 nsStyleVisibility(nsPresContext* aPresContext);
812 nsStyleVisibility(const nsStyleVisibility& aVisibility);
813 ~nsStyleVisibility() {}
815 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
816 return aContext->AllocateFromShell(sz);
818 void Destroy(nsPresContext* aContext) {
819 this->~nsStyleVisibility();
820 aContext->FreeToShell(sizeof(nsStyleVisibility), this);
823 nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
824 #ifdef DEBUG
825 static nsChangeHint MaxDifference();
826 #endif
828 PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
829 PRUint8 mVisible; // [inherited]
830 nsCOMPtr<nsIAtom> mLangGroup; // [inherited]
832 PRBool IsVisible() const {
833 return (mVisible == NS_STYLE_VISIBILITY_VISIBLE);
836 PRBool IsVisibleOrCollapsed() const {
837 return ((mVisible == NS_STYLE_VISIBILITY_VISIBLE) ||
838 (mVisible == NS_STYLE_VISIBILITY_COLLAPSE));
842 struct nsStyleDisplay {
843 nsStyleDisplay();
844 nsStyleDisplay(const nsStyleDisplay& aOther);
845 ~nsStyleDisplay() {}
847 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
848 return aContext->AllocateFromShell(sz);
850 void Destroy(nsPresContext* aContext) {
851 this->~nsStyleDisplay();
852 aContext->FreeToShell(sizeof(nsStyleDisplay), this);
855 nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
856 #ifdef DEBUG
857 static nsChangeHint MaxDifference();
858 #endif
860 // We guarantee that if mBinding is non-null, so are mBinding->mURI and
861 // mBinding->mOriginPrincipal.
862 nsRefPtr<nsCSSValue::URL> mBinding; // [reset]
863 #if 0
864 // XXX This is how it is defined in the CSS2 spec, but the errata
865 // changed it to be consistent with the positioning draft and how
866 // Nav and IE implement it
867 nsMargin mClip; // [reset] offsets from respective edge
868 #else
869 nsRect mClip; // [reset] offsets from upper-left border edge
870 #endif
871 float mOpacity; // [reset]
872 PRUint8 mDisplay; // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
873 PRUint8 mOriginalDisplay; // [reset] saved mDisplay for position:absolute/fixed
874 PRUint8 mAppearance; // [reset]
875 PRUint8 mPosition; // [reset] see nsStyleConsts.h
876 PRUint8 mFloats; // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
877 PRUint8 mBreakType; // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
878 PRPackedBool mBreakBefore; // [reset]
879 PRPackedBool mBreakAfter; // [reset]
880 PRUint8 mOverflowX; // [reset] see nsStyleConsts.h
881 PRUint8 mOverflowY; // [reset] see nsStyleConsts.h
882 PRUint8 mClipFlags; // [reset] see nsStyleConsts.h
883 PRPackedBool mTransformPresent; // [reset] Whether there is a -moz-transform.
884 nsStyleTransformMatrix mTransform; // [reset] The stored transform matrix
885 nsStyleCoord mTransformOrigin[2]; // [reset] percent, coord.
887 PRBool IsBlockInside() const {
888 return NS_STYLE_DISPLAY_BLOCK == mDisplay ||
889 NS_STYLE_DISPLAY_LIST_ITEM == mDisplay ||
890 NS_STYLE_DISPLAY_INLINE_BLOCK == mDisplay;
891 // Should TABLE_CELL and TABLE_CAPTION go here? They have
892 // block frames nested inside of them.
893 // (But please audit all callers before changing.)
896 PRBool IsBlockOutside() const {
897 return NS_STYLE_DISPLAY_BLOCK == mDisplay ||
898 NS_STYLE_DISPLAY_LIST_ITEM == mDisplay ||
899 NS_STYLE_DISPLAY_TABLE == mDisplay;
902 PRBool IsInlineOutside() const {
903 return NS_STYLE_DISPLAY_INLINE == mDisplay ||
904 NS_STYLE_DISPLAY_INLINE_BLOCK == mDisplay ||
905 NS_STYLE_DISPLAY_INLINE_TABLE == mDisplay ||
906 NS_STYLE_DISPLAY_INLINE_BOX == mDisplay ||
907 NS_STYLE_DISPLAY_INLINE_GRID == mDisplay ||
908 NS_STYLE_DISPLAY_INLINE_STACK == mDisplay;
911 PRBool IsFloating() const {
912 return NS_STYLE_FLOAT_NONE != mFloats;
915 PRBool IsAbsolutelyPositioned() const {return (NS_STYLE_POSITION_ABSOLUTE == mPosition) ||
916 (NS_STYLE_POSITION_FIXED == mPosition);}
918 /* Returns true if we're positioned or there's a transform in effect. */
919 PRBool IsPositioned() const {
920 return IsAbsolutelyPositioned() ||
921 NS_STYLE_POSITION_RELATIVE == mPosition || mTransformPresent;
924 PRBool IsScrollableOverflow() const {
925 // mOverflowX and mOverflowY always match when one of them is
926 // NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP.
927 return mOverflowX != NS_STYLE_OVERFLOW_VISIBLE &&
928 mOverflowX != NS_STYLE_OVERFLOW_CLIP;
931 // For table elements that don't support scroll frame creation, we
932 // support 'overflow: hidden' to mean 'overflow: -moz-hidden-unscrollable'.
933 PRBool IsTableClip() const {
934 return mOverflowX == NS_STYLE_OVERFLOW_CLIP ||
935 (mOverflowX == NS_STYLE_OVERFLOW_HIDDEN &&
936 mOverflowY == NS_STYLE_OVERFLOW_HIDDEN);
939 /* Returns whether the element has the -moz-transform property. */
940 PRBool HasTransform() const {
941 return mTransformPresent;
945 struct nsStyleTable {
946 nsStyleTable(void);
947 nsStyleTable(const nsStyleTable& aOther);
948 ~nsStyleTable(void);
950 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
951 return aContext->AllocateFromShell(sz);
953 void Destroy(nsPresContext* aContext) {
954 this->~nsStyleTable();
955 aContext->FreeToShell(sizeof(nsStyleTable), this);
958 nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
959 #ifdef DEBUG
960 static nsChangeHint MaxDifference();
961 #endif
963 PRUint8 mLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*
964 PRUint8 mFrame; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_FRAME_*
965 PRUint8 mRules; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_RULES_*
966 PRInt32 mCols; // [reset] an integer if set, or see nsStyleConsts.h NS_STYLE_TABLE_COLS_*
967 PRInt32 mSpan; // [reset] the number of columns spanned by a colgroup or col
970 struct nsStyleTableBorder {
971 nsStyleTableBorder(nsPresContext* aContext);
972 nsStyleTableBorder(const nsStyleTableBorder& aOther);
973 ~nsStyleTableBorder(void);
975 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
976 return aContext->AllocateFromShell(sz);
978 void Destroy(nsPresContext* aContext) {
979 this->~nsStyleTableBorder();
980 aContext->FreeToShell(sizeof(nsStyleTableBorder), this);
983 nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
984 #ifdef DEBUG
985 static nsChangeHint MaxDifference();
986 #endif
988 nscoord mBorderSpacingX;// [inherited]
989 nscoord mBorderSpacingY;// [inherited]
990 PRUint8 mBorderCollapse;// [inherited]
991 PRUint8 mCaptionSide; // [inherited]
992 PRUint8 mEmptyCells; // [inherited]
995 enum nsStyleContentType {
996 eStyleContentType_String = 1,
997 eStyleContentType_Image = 10,
998 eStyleContentType_Attr = 20,
999 eStyleContentType_Counter = 30,
1000 eStyleContentType_Counters = 31,
1001 eStyleContentType_OpenQuote = 40,
1002 eStyleContentType_CloseQuote = 41,
1003 eStyleContentType_NoOpenQuote = 42,
1004 eStyleContentType_NoCloseQuote = 43,
1005 eStyleContentType_AltContent = 50
1008 struct nsStyleContentData {
1009 nsStyleContentType mType;
1010 union {
1011 PRUnichar *mString;
1012 imgIRequest *mImage;
1013 nsCSSValue::Array* mCounters;
1014 } mContent;
1016 nsStyleContentData() : mType(nsStyleContentType(0)) { mContent.mString = nsnull; }
1017 ~nsStyleContentData();
1018 nsStyleContentData& operator=(const nsStyleContentData& aOther);
1019 PRBool operator==(const nsStyleContentData& aOther) const;
1021 PRBool operator!=(const nsStyleContentData& aOther) const {
1022 return !(*this == aOther);
1024 private:
1025 nsStyleContentData(const nsStyleContentData&); // not to be implemented
1028 struct nsStyleCounterData {
1029 nsString mCounter;
1030 PRInt32 mValue;
1034 #define DELETE_ARRAY_IF(array) if (array) { delete[] array; array = nsnull; }
1036 struct nsStyleQuotes {
1037 nsStyleQuotes();
1038 nsStyleQuotes(const nsStyleQuotes& aQuotes);
1039 ~nsStyleQuotes();
1041 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1042 return aContext->AllocateFromShell(sz);
1044 void Destroy(nsPresContext* aContext) {
1045 this->~nsStyleQuotes();
1046 aContext->FreeToShell(sizeof(nsStyleQuotes), this);
1049 void SetInitial();
1050 void CopyFrom(const nsStyleQuotes& aSource);
1052 nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const;
1053 #ifdef DEBUG
1054 static nsChangeHint MaxDifference();
1055 #endif
1057 PRUint32 QuotesCount(void) const { return mQuotesCount; } // [inherited]
1059 const nsString* OpenQuoteAt(PRUint32 aIndex) const
1061 NS_ASSERTION(aIndex < mQuotesCount, "out of range");
1062 return mQuotes + (aIndex * 2);
1064 const nsString* CloseQuoteAt(PRUint32 aIndex) const
1066 NS_ASSERTION(aIndex < mQuotesCount, "out of range");
1067 return mQuotes + (aIndex * 2 + 1);
1069 nsresult GetQuotesAt(PRUint32 aIndex, nsString& aOpen, nsString& aClose) const {
1070 if (aIndex < mQuotesCount) {
1071 aIndex *= 2;
1072 aOpen = mQuotes[aIndex];
1073 aClose = mQuotes[++aIndex];
1074 return NS_OK;
1076 return NS_ERROR_ILLEGAL_VALUE;
1079 nsresult AllocateQuotes(PRUint32 aCount) {
1080 if (aCount != mQuotesCount) {
1081 DELETE_ARRAY_IF(mQuotes);
1082 if (aCount) {
1083 mQuotes = new nsString[aCount * 2];
1084 if (! mQuotes) {
1085 mQuotesCount = 0;
1086 return NS_ERROR_OUT_OF_MEMORY;
1089 mQuotesCount = aCount;
1091 return NS_OK;
1094 nsresult SetQuotesAt(PRUint32 aIndex, const nsString& aOpen, const nsString& aClose) {
1095 if (aIndex < mQuotesCount) {
1096 aIndex *= 2;
1097 mQuotes[aIndex] = aOpen;
1098 mQuotes[++aIndex] = aClose;
1099 return NS_OK;
1101 return NS_ERROR_ILLEGAL_VALUE;
1104 protected:
1105 PRUint32 mQuotesCount;
1106 nsString* mQuotes;
1109 struct nsStyleContent {
1110 nsStyleContent(void);
1111 nsStyleContent(const nsStyleContent& aContent);
1112 ~nsStyleContent(void);
1114 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1115 return aContext->AllocateFromShell(sz);
1117 void Destroy(nsPresContext* aContext) {
1118 this->~nsStyleContent();
1119 aContext->FreeToShell(sizeof(nsStyleContent), this);
1122 nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
1123 #ifdef DEBUG
1124 static nsChangeHint MaxDifference();
1125 #endif
1127 PRUint32 ContentCount(void) const { return mContentCount; } // [reset]
1129 const nsStyleContentData& ContentAt(PRUint32 aIndex) const {
1130 NS_ASSERTION(aIndex < mContentCount, "out of range");
1131 return mContents[aIndex];
1134 nsStyleContentData& ContentAt(PRUint32 aIndex) {
1135 NS_ASSERTION(aIndex < mContentCount, "out of range");
1136 return mContents[aIndex];
1139 nsresult AllocateContents(PRUint32 aCount);
1141 PRUint32 CounterIncrementCount(void) const { return mIncrementCount; } // [reset]
1142 const nsStyleCounterData* GetCounterIncrementAt(PRUint32 aIndex) const {
1143 NS_ASSERTION(aIndex < mIncrementCount, "out of range");
1144 return &mIncrements[aIndex];
1147 nsresult AllocateCounterIncrements(PRUint32 aCount) {
1148 if (aCount != mIncrementCount) {
1149 DELETE_ARRAY_IF(mIncrements);
1150 if (aCount) {
1151 mIncrements = new nsStyleCounterData[aCount];
1152 if (! mIncrements) {
1153 mIncrementCount = 0;
1154 return NS_ERROR_OUT_OF_MEMORY;
1157 mIncrementCount = aCount;
1159 return NS_OK;
1162 nsresult SetCounterIncrementAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aIncrement) {
1163 if (aIndex < mIncrementCount) {
1164 mIncrements[aIndex].mCounter = aCounter;
1165 mIncrements[aIndex].mValue = aIncrement;
1166 return NS_OK;
1168 return NS_ERROR_ILLEGAL_VALUE;
1171 PRUint32 CounterResetCount(void) const { return mResetCount; } // [reset]
1172 const nsStyleCounterData* GetCounterResetAt(PRUint32 aIndex) const {
1173 NS_ASSERTION(aIndex < mResetCount, "out of range");
1174 return &mResets[aIndex];
1177 nsresult AllocateCounterResets(PRUint32 aCount) {
1178 if (aCount != mResetCount) {
1179 DELETE_ARRAY_IF(mResets);
1180 if (aCount) {
1181 mResets = new nsStyleCounterData[aCount];
1182 if (! mResets) {
1183 mResetCount = 0;
1184 return NS_ERROR_OUT_OF_MEMORY;
1187 mResetCount = aCount;
1189 return NS_OK;
1192 nsresult SetCounterResetAt(PRUint32 aIndex, const nsString& aCounter, PRInt32 aValue) {
1193 if (aIndex < mResetCount) {
1194 mResets[aIndex].mCounter = aCounter;
1195 mResets[aIndex].mValue = aValue;
1196 return NS_OK;
1198 return NS_ERROR_ILLEGAL_VALUE;
1201 nsStyleCoord mMarkerOffset; // [reset] coord, auto
1203 protected:
1204 PRUint32 mContentCount;
1205 nsStyleContentData* mContents;
1207 PRUint32 mIncrementCount;
1208 nsStyleCounterData* mIncrements;
1210 PRUint32 mResetCount;
1211 nsStyleCounterData* mResets;
1214 struct nsStyleUIReset {
1215 nsStyleUIReset(void);
1216 nsStyleUIReset(const nsStyleUIReset& aOther);
1217 ~nsStyleUIReset(void);
1219 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1220 return aContext->AllocateFromShell(sz);
1222 void Destroy(nsPresContext* aContext) {
1223 this->~nsStyleUIReset();
1224 aContext->FreeToShell(sizeof(nsStyleUIReset), this);
1227 nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
1228 #ifdef DEBUG
1229 static nsChangeHint MaxDifference();
1230 #endif
1232 PRUint8 mUserSelect; // [reset] (selection-style)
1233 PRUint8 mForceBrokenImageIcon; // [reset] (0 if not forcing, otherwise forcing)
1234 PRUint8 mIMEMode; // [reset]
1235 PRUint8 mWindowShadow; // [reset]
1238 struct nsCursorImage {
1239 nsCOMPtr<imgIRequest> mImage;
1240 PRBool mHaveHotspot;
1241 float mHotspotX, mHotspotY;
1243 nsCursorImage();
1246 struct nsStyleUserInterface {
1247 nsStyleUserInterface(void);
1248 nsStyleUserInterface(const nsStyleUserInterface& aOther);
1249 ~nsStyleUserInterface(void);
1251 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1252 return aContext->AllocateFromShell(sz);
1254 void Destroy(nsPresContext* aContext) {
1255 this->~nsStyleUserInterface();
1256 aContext->FreeToShell(sizeof(nsStyleUserInterface), this);
1259 nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
1260 #ifdef DEBUG
1261 static nsChangeHint MaxDifference();
1262 #endif
1264 PRUint8 mUserInput; // [inherited]
1265 PRUint8 mUserModify; // [inherited] (modify-content)
1266 PRUint8 mUserFocus; // [inherited] (auto-select)
1268 PRUint8 mCursor; // [inherited] See nsStyleConsts.h
1270 PRUint32 mCursorArrayLength;
1271 nsCursorImage *mCursorArray;// [inherited] The specified URL values
1272 // and coordinates. Takes precedence over
1273 // mCursor. Zero-length array is represented
1274 // by null pointer.
1276 // Does not free mCursorArray; the caller is responsible for calling
1277 // |delete [] mCursorArray| first if it is needed.
1278 void CopyCursorArrayFrom(const nsStyleUserInterface& aSource);
1281 struct nsStyleXUL {
1282 nsStyleXUL();
1283 nsStyleXUL(const nsStyleXUL& aSource);
1284 ~nsStyleXUL();
1286 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1287 return aContext->AllocateFromShell(sz);
1289 void Destroy(nsPresContext* aContext) {
1290 this->~nsStyleXUL();
1291 aContext->FreeToShell(sizeof(nsStyleXUL), this);
1294 nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
1295 #ifdef DEBUG
1296 static nsChangeHint MaxDifference();
1297 #endif
1299 float mBoxFlex; // [reset] see nsStyleConsts.h
1300 PRUint32 mBoxOrdinal; // [reset] see nsStyleConsts.h
1301 PRUint8 mBoxAlign; // [reset] see nsStyleConsts.h
1302 PRUint8 mBoxDirection; // [reset] see nsStyleConsts.h
1303 PRUint8 mBoxOrient; // [reset] see nsStyleConsts.h
1304 PRUint8 mBoxPack; // [reset] see nsStyleConsts.h
1305 PRPackedBool mStretchStack; // [reset] see nsStyleConsts.h
1308 struct nsStyleColumn {
1309 nsStyleColumn(nsPresContext* aPresContext);
1310 nsStyleColumn(const nsStyleColumn& aSource);
1311 ~nsStyleColumn();
1313 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1314 return aContext->AllocateFromShell(sz);
1316 void Destroy(nsPresContext* aContext) {
1317 this->~nsStyleColumn();
1318 aContext->FreeToShell(sizeof(nsStyleColumn), this);
1321 nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
1322 #ifdef DEBUG
1323 static nsChangeHint MaxDifference();
1324 #endif
1326 PRUint32 mColumnCount; // [reset] see nsStyleConsts.h
1327 nsStyleCoord mColumnWidth; // [reset] coord, auto
1328 nsStyleCoord mColumnGap; // [reset] coord, percent, normal
1330 nscolor mColumnRuleColor; // [reset]
1331 PRUint8 mColumnRuleStyle; // [reset]
1332 // See https://bugzilla.mozilla.org/show_bug.cgi?id=271586#c43 for why
1333 // this is hard to replace with 'currentColor'.
1334 PRPackedBool mColumnRuleColorIsForeground;
1336 void SetColumnRuleWidth(nscoord aWidth) {
1337 mColumnRuleWidth = NS_ROUND_BORDER_TO_PIXELS(aWidth, mTwipsPerPixel);
1340 nscoord GetComputedColumnRuleWidth() const {
1341 return (IsVisibleBorderStyle(mColumnRuleStyle) ? mColumnRuleWidth : 0);
1344 protected:
1345 nscoord mColumnRuleWidth; // [reset] coord
1346 nscoord mTwipsPerPixel;
1349 #ifdef MOZ_SVG
1350 enum nsStyleSVGPaintType {
1351 eStyleSVGPaintType_None = 1,
1352 eStyleSVGPaintType_Color,
1353 eStyleSVGPaintType_Server
1356 struct nsStyleSVGPaint
1358 nsStyleSVGPaintType mType;
1359 union {
1360 nscolor mColor;
1361 nsIURI *mPaintServer;
1362 } mPaint;
1363 nscolor mFallbackColor;
1365 nsStyleSVGPaint() : mType(nsStyleSVGPaintType(0)) { mPaint.mPaintServer = nsnull; }
1366 ~nsStyleSVGPaint();
1367 void SetType(nsStyleSVGPaintType aType);
1368 nsStyleSVGPaint& operator=(const nsStyleSVGPaint& aOther);
1369 PRBool operator==(const nsStyleSVGPaint& aOther) const;
1371 PRBool operator!=(const nsStyleSVGPaint& aOther) const {
1372 return !(*this == aOther);
1376 struct nsStyleSVG {
1377 nsStyleSVG();
1378 nsStyleSVG(const nsStyleSVG& aSource);
1379 ~nsStyleSVG();
1381 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1382 return aContext->AllocateFromShell(sz);
1384 void Destroy(nsPresContext* aContext) {
1385 this->~nsStyleSVG();
1386 aContext->FreeToShell(sizeof(nsStyleSVG), this);
1389 nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
1390 #ifdef DEBUG
1391 static nsChangeHint MaxDifference();
1392 #endif
1394 nsStyleSVGPaint mFill; // [inherited]
1395 nsStyleSVGPaint mStroke; // [inherited]
1396 nsCOMPtr<nsIURI> mMarkerEnd; // [inherited]
1397 nsCOMPtr<nsIURI> mMarkerMid; // [inherited]
1398 nsCOMPtr<nsIURI> mMarkerStart; // [inherited]
1399 nsStyleCoord *mStrokeDasharray; // [inherited] coord, percent, factor
1401 nsStyleCoord mStrokeDashoffset; // [inherited] coord, percent, factor
1402 nsStyleCoord mStrokeWidth; // [inherited] coord, percent, factor
1404 float mFillOpacity; // [inherited]
1405 float mStrokeMiterlimit; // [inherited]
1406 float mStrokeOpacity; // [inherited]
1408 PRUint32 mStrokeDasharrayLength;
1409 PRUint8 mClipRule; // [inherited]
1410 PRUint8 mColorInterpolation; // [inherited] see nsStyleConsts.h
1411 PRUint8 mColorInterpolationFilters; // [inherited] see nsStyleConsts.h
1412 PRUint8 mFillRule; // [inherited] see nsStyleConsts.h
1413 PRUint8 mPointerEvents; // [inherited] see nsStyleConsts.h
1414 PRUint8 mShapeRendering; // [inherited] see nsStyleConsts.h
1415 PRUint8 mStrokeLinecap; // [inherited] see nsStyleConsts.h
1416 PRUint8 mStrokeLinejoin; // [inherited] see nsStyleConsts.h
1417 PRUint8 mTextAnchor; // [inherited] see nsStyleConsts.h
1418 PRUint8 mTextRendering; // [inherited] see nsStyleConsts.h
1421 struct nsStyleSVGReset {
1422 nsStyleSVGReset();
1423 nsStyleSVGReset(const nsStyleSVGReset& aSource);
1424 ~nsStyleSVGReset();
1426 void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
1427 return aContext->AllocateFromShell(sz);
1429 void Destroy(nsPresContext* aContext) {
1430 this->~nsStyleSVGReset();
1431 aContext->FreeToShell(sizeof(nsStyleSVGReset), this);
1434 nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
1435 #ifdef DEBUG
1436 static nsChangeHint MaxDifference();
1437 #endif
1439 nscolor mStopColor; // [reset]
1440 nscolor mFloodColor; // [reset]
1441 nscolor mLightingColor; // [reset]
1442 nsCOMPtr<nsIURI> mClipPath; // [reset]
1443 nsCOMPtr<nsIURI> mFilter; // [reset]
1444 nsCOMPtr<nsIURI> mMask; // [reset]
1446 float mStopOpacity; // [reset]
1447 float mFloodOpacity; // [reset]
1449 PRUint8 mDominantBaseline; // [reset] see nsStyleConsts.h
1451 #endif
1453 #endif /* nsStyleStruct_h___ */