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
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.
23 * Daniel Glazman <glazman@netscape.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
40 * temporary (expanded) representation of the property-value pairs
41 * within a CSS declaration using during parsing and mutation, and
42 * representation of complex values for CSS properties
45 #ifndef nsCSSStruct_h___
46 #define nsCSSStruct_h___
48 #include "nsCSSValue.h"
49 #include "nsStyleConsts.h"
51 // Prefer nsCSSValue::Array for lists of fixed size.
52 struct nsCSSValueList
{
53 nsCSSValueList() : mNext(nsnull
) { MOZ_COUNT_CTOR(nsCSSValueList
); }
56 nsCSSValueList
* Clone() const { return Clone(PR_TRUE
); }
58 static PRBool
Equal(nsCSSValueList
* aList1
, nsCSSValueList
* aList2
);
61 nsCSSValueList
* mNext
;
64 nsCSSValueList(const nsCSSValueList
& aCopy
) // makes a shallow copy
65 : mValue(aCopy
.mValue
), mNext(nsnull
)
67 MOZ_COUNT_CTOR(nsCSSValueList
);
69 nsCSSValueList
* Clone(PRBool aDeep
) const;
74 nsCSSRect(const nsCSSRect
& aCopy
);
77 PRBool
operator==(const nsCSSRect
& aOther
) const {
78 return mTop
== aOther
.mTop
&&
79 mRight
== aOther
.mRight
&&
80 mBottom
== aOther
.mBottom
&&
81 mLeft
== aOther
.mLeft
;
84 PRBool
operator!=(const nsCSSRect
& aOther
) const {
85 return mTop
!= aOther
.mTop
||
86 mRight
!= aOther
.mRight
||
87 mBottom
!= aOther
.mBottom
||
88 mLeft
!= aOther
.mLeft
;
91 void SetAllSidesTo(const nsCSSValue
& aValue
);
100 PRBool
HasValue() const {
102 mTop
.GetUnit() != eCSSUnit_Null
||
103 mRight
.GetUnit() != eCSSUnit_Null
||
104 mBottom
.GetUnit() != eCSSUnit_Null
||
105 mLeft
.GetUnit() != eCSSUnit_Null
;
113 typedef nsCSSValue
nsCSSRect::*side_type
;
114 static const side_type sides
[4];
117 struct nsCSSValuePair
{
120 MOZ_COUNT_CTOR(nsCSSValuePair
);
122 nsCSSValuePair(const nsCSSValuePair
& aCopy
)
123 : mXValue(aCopy
.mXValue
),
124 mYValue(aCopy
.mYValue
)
126 MOZ_COUNT_CTOR(nsCSSValuePair
);
130 MOZ_COUNT_DTOR(nsCSSValuePair
);
133 PRBool
operator==(const nsCSSValuePair
& aOther
) const {
134 return mXValue
== aOther
.mXValue
&&
135 mYValue
== aOther
.mYValue
;
138 PRBool
operator!=(const nsCSSValuePair
& aOther
) const {
139 return mXValue
!= aOther
.mXValue
||
140 mYValue
!= aOther
.mYValue
;
143 void SetBothValuesTo(const nsCSSValue
& aValue
) {
153 PRBool
HasValue() const {
154 return mXValue
.GetUnit() != eCSSUnit_Null
||
155 mYValue
.GetUnit() != eCSSUnit_Null
;
162 struct nsCSSCornerSizes
{
163 nsCSSCornerSizes(void);
164 nsCSSCornerSizes(const nsCSSCornerSizes
& aCopy
);
167 // argument is a "full corner" constant from nsStyleConsts.h
168 nsCSSValuePair
const & GetFullCorner(PRUint32 aCorner
) const {
169 return (this->*corners
[aCorner
]);
171 nsCSSValuePair
& GetFullCorner(PRUint32 aCorner
) {
172 return (this->*corners
[aCorner
]);
175 // argument is a "half corner" constant from nsStyleConsts.h
176 const nsCSSValue
& GetHalfCorner(PRUint32 hc
) const {
177 nsCSSValuePair
const & fc
= this->*corners
[NS_HALF_TO_FULL_CORNER(hc
)];
178 return NS_HALF_CORNER_IS_X(hc
) ? fc
.mXValue
: fc
.mYValue
;
180 nsCSSValue
& GetHalfCorner(PRUint32 hc
) {
181 nsCSSValuePair
& fc
= this->*corners
[NS_HALF_TO_FULL_CORNER(hc
)];
182 return NS_HALF_CORNER_IS_X(hc
) ? fc
.mXValue
: fc
.mYValue
;
185 PRBool
operator==(const nsCSSCornerSizes
& aOther
) const {
186 NS_FOR_CSS_FULL_CORNERS(corner
) {
187 if (this->GetFullCorner(corner
) != aOther
.GetFullCorner(corner
))
193 PRBool
operator!=(const nsCSSCornerSizes
& aOther
) const {
194 NS_FOR_CSS_FULL_CORNERS(corner
) {
195 if (this->GetFullCorner(corner
) != aOther
.GetFullCorner(corner
))
201 PRBool
HasValue() const {
202 NS_FOR_CSS_FULL_CORNERS(corner
) {
203 if (this->GetFullCorner(corner
).HasValue())
209 void SetAllCornersTo(const nsCSSValue
& aValue
);
212 nsCSSValuePair mTopLeft
;
213 nsCSSValuePair mTopRight
;
214 nsCSSValuePair mBottomRight
;
215 nsCSSValuePair mBottomLeft
;
218 typedef nsCSSValuePair
nsCSSCornerSizes::*corner_type
;
219 static const corner_type corners
[4];
222 struct nsCSSValueListRect
{
223 nsCSSValueListRect(void);
224 nsCSSValueListRect(const nsCSSValueListRect
& aCopy
);
225 ~nsCSSValueListRect();
227 nsCSSValueList
* mTop
;
228 nsCSSValueList
* mRight
;
229 nsCSSValueList
* mBottom
;
230 nsCSSValueList
* mLeft
;
232 typedef nsCSSValueList
* nsCSSValueListRect::*side_type
;
233 static const side_type sides
[4];
236 // Maybe should be replaced with nsCSSValueList and nsCSSValue::Array?
237 struct nsCSSValuePairList
{
238 nsCSSValuePairList() : mNext(nsnull
) { MOZ_COUNT_CTOR(nsCSSValuePairList
); }
239 ~nsCSSValuePairList();
241 nsCSSValuePairList
* Clone() const { return Clone(PR_TRUE
); }
243 static PRBool
Equal(nsCSSValuePairList
* aList1
, nsCSSValuePairList
* aList2
);
247 nsCSSValuePairList
* mNext
;
250 nsCSSValuePairList(const nsCSSValuePairList
& aCopy
) // makes a shallow copy
251 : mXValue(aCopy
.mXValue
), mYValue(aCopy
.mYValue
), mNext(nsnull
)
253 MOZ_COUNT_CTOR(nsCSSValuePairList
);
255 nsCSSValuePairList
* Clone(PRBool aDeep
) const;
258 /****************************************************************************/
261 // EMPTY on purpose. ABSTRACT with no virtuals (typedef void nsCSSStruct?)
264 // We use the nsCSS* structures for storing nsCSSDeclaration's
265 // *temporary* data during parsing and modification. (They are too big
266 // for permanent storage.) We also use them for nsRuleData, with some
267 // additions of things that the style system must cascade, but that
268 // aren't CSS properties. Thus we use typedefs and inheritance
269 // (forwards, when the rule data needs extra data) to make the rule data
270 // structs from the declaration structs.
271 // NOTE: For compilation speed, this typedef also appears in nsRuleNode.h
272 typedef nsCSSStruct nsRuleDataStruct
;
275 struct nsCSSFont
: public nsCSSStruct
{
279 nsCSSValue mSystemFont
;
285 nsCSSValue mSizeAdjust
; // NEW
286 nsCSSValue mStretch
; // NEW
289 nsCSSValue mScriptLevel
; // Integer values mean "relative", Number values mean "absolute"
290 nsCSSValue mScriptSizeMultiplier
;
291 nsCSSValue mScriptMinSize
;
295 nsCSSFont(const nsCSSFont
& aOther
); // NOT IMPLEMENTED
298 struct nsRuleDataFont
: public nsCSSFont
{
299 PRBool mFamilyFromHTML
; // Is the family from an HTML FONT element
302 nsRuleDataFont(const nsRuleDataFont
& aOther
); // NOT IMPLEMENTED
305 struct nsCSSColor
: public nsCSSStruct
{
310 nsCSSValue mBackColor
;
311 nsCSSValue mBackImage
;
312 nsCSSValue mBackRepeat
;
313 nsCSSValue mBackAttachment
;
314 nsCSSValuePair mBackPosition
;
315 nsCSSValue mBackClip
;
316 nsCSSValue mBackOrigin
;
317 nsCSSValue mBackInlinePolicy
;
319 nsCSSColor(const nsCSSColor
& aOther
); // NOT IMPLEMENTED
322 struct nsRuleDataColor
: public nsCSSColor
{
325 nsRuleDataColor(const nsRuleDataColor
& aOther
); // NOT IMPLEMENTED
328 struct nsCSSText
: public nsCSSStruct
{
332 nsCSSValue mWordSpacing
;
333 nsCSSValue mLetterSpacing
;
334 nsCSSValue mVerticalAlign
;
335 nsCSSValue mTextTransform
;
336 nsCSSValue mTextAlign
;
337 nsCSSValue mTextIndent
;
338 nsCSSValue mDecoration
;
339 nsCSSValueList
* mTextShadow
; // NEW
340 nsCSSValue mUnicodeBidi
; // NEW
341 nsCSSValue mLineHeight
;
342 nsCSSValue mWhiteSpace
;
343 nsCSSValue mWordWrap
;
345 nsCSSText(const nsCSSText
& aOther
); // NOT IMPLEMENTED
348 struct nsRuleDataText
: public nsCSSText
{
351 nsRuleDataText(const nsRuleDataText
& aOther
); // NOT IMPLEMENTED
354 struct nsCSSDisplay
: public nsCSSStruct
{
358 nsCSSValue mDirection
;
361 nsCSSValue mAppearance
;
362 nsCSSValue mPosition
;
366 nsCSSValue mOverflowX
;
367 nsCSSValue mOverflowY
;
368 nsCSSValue mVisibility
;
370 nsCSSValueList
*mTransform
; // List of Arrays containing transform information
371 nsCSSValuePair mTransformOrigin
;
373 // temp fix for bug 24000
374 nsCSSValue mBreakBefore
;
375 nsCSSValue mBreakAfter
;
378 nsCSSDisplay(const nsCSSDisplay
& aOther
); // NOT IMPLEMENTED
381 struct nsRuleDataDisplay
: public nsCSSDisplay
{
383 nsRuleDataDisplay() {}
385 nsRuleDataDisplay(const nsRuleDataDisplay
& aOther
); // NOT IMPLEMENTED
388 struct nsCSSMargin
: public nsCSSStruct
{
393 nsCSSValue mMarginStart
;
394 nsCSSValue mMarginEnd
;
395 nsCSSValue mMarginLeftLTRSource
;
396 nsCSSValue mMarginLeftRTLSource
;
397 nsCSSValue mMarginRightLTRSource
;
398 nsCSSValue mMarginRightRTLSource
;
400 nsCSSValue mPaddingStart
;
401 nsCSSValue mPaddingEnd
;
402 nsCSSValue mPaddingLeftLTRSource
;
403 nsCSSValue mPaddingLeftRTLSource
;
404 nsCSSValue mPaddingRightLTRSource
;
405 nsCSSValue mPaddingRightRTLSource
;
406 nsCSSRect mBorderWidth
;
407 nsCSSValue mBorderStartWidth
;
408 nsCSSValue mBorderEndWidth
;
409 nsCSSValue mBorderLeftWidthLTRSource
;
410 nsCSSValue mBorderLeftWidthRTLSource
;
411 nsCSSValue mBorderRightWidthLTRSource
;
412 nsCSSValue mBorderRightWidthRTLSource
;
413 nsCSSRect mBorderColor
;
414 nsCSSValue mBorderStartColor
;
415 nsCSSValue mBorderEndColor
;
416 nsCSSValue mBorderLeftColorLTRSource
;
417 nsCSSValue mBorderLeftColorRTLSource
;
418 nsCSSValue mBorderRightColorLTRSource
;
419 nsCSSValue mBorderRightColorRTLSource
;
420 nsCSSValueListRect mBorderColors
;
421 nsCSSRect mBorderStyle
;
422 nsCSSValue mBorderStartStyle
;
423 nsCSSValue mBorderEndStyle
;
424 nsCSSValue mBorderLeftStyleLTRSource
;
425 nsCSSValue mBorderLeftStyleRTLSource
;
426 nsCSSValue mBorderRightStyleLTRSource
;
427 nsCSSValue mBorderRightStyleRTLSource
;
428 nsCSSCornerSizes mBorderRadius
;
429 nsCSSValue mOutlineWidth
;
430 nsCSSValue mOutlineColor
;
431 nsCSSValue mOutlineStyle
;
432 nsCSSValue mOutlineOffset
;
433 nsCSSCornerSizes mOutlineRadius
;
434 nsCSSValue mFloatEdge
; // NEW
435 nsCSSValue mBorderImage
;
436 nsCSSValueList
* mBoxShadow
;
438 nsCSSMargin(const nsCSSMargin
& aOther
); // NOT IMPLEMENTED
441 struct nsRuleDataMargin
: public nsCSSMargin
{
442 nsRuleDataMargin() {}
444 nsRuleDataMargin(const nsRuleDataMargin
& aOther
); // NOT IMPLEMENTED
447 struct nsCSSPosition
: public nsCSSStruct
{
449 ~nsCSSPosition(void);
452 nsCSSValue mMinWidth
;
453 nsCSSValue mMaxWidth
;
455 nsCSSValue mMinHeight
;
456 nsCSSValue mMaxHeight
;
457 nsCSSValue mBoxSizing
; // NEW
461 nsCSSPosition(const nsCSSPosition
& aOther
); // NOT IMPLEMENTED
464 struct nsRuleDataPosition
: public nsCSSPosition
{
465 nsRuleDataPosition() {}
467 nsRuleDataPosition(const nsRuleDataPosition
& aOther
); // NOT IMPLEMENTED
470 struct nsCSSList
: public nsCSSStruct
{
476 nsCSSValue mPosition
;
477 nsCSSRect mImageRegion
;
479 nsCSSList(const nsCSSList
& aOther
); // NOT IMPLEMENTED
482 struct nsRuleDataList
: public nsCSSList
{
485 nsRuleDataList(const nsRuleDataList
& aOther
); // NOT IMPLEMENTED
488 struct nsCSSTable
: public nsCSSStruct
{ // NEW
492 nsCSSValue mBorderCollapse
;
493 nsCSSValuePair mBorderSpacing
;
494 nsCSSValue mCaptionSide
;
495 nsCSSValue mEmptyCells
;
498 nsCSSValue mFrame
; // Not mappable via CSS, only using HTML4 table attrs.
499 nsCSSValue mRules
; // Not mappable via CSS, only using HTML4 table attrs.
500 nsCSSValue mSpan
; // Not mappable via CSS, only using HTML4 table attrs.
501 nsCSSValue mCols
; // Not mappable via CSS, only using HTML4 table attrs.
503 nsCSSTable(const nsCSSTable
& aOther
); // NOT IMPLEMENTED
506 struct nsRuleDataTable
: public nsCSSTable
{
509 nsRuleDataTable(const nsRuleDataTable
& aOther
); // NOT IMPLEMENTED
512 struct nsCSSBreaks
: public nsCSSStruct
{ // NEW
519 // temp fix for bug 24000
520 //nsCSSValue mPageBreakAfter;
521 //nsCSSValue mPageBreakBefore;
522 nsCSSValue mPageBreakInside
;
524 nsCSSBreaks(const nsCSSBreaks
& aOther
); // NOT IMPLEMENTED
527 struct nsRuleDataBreaks
: public nsCSSBreaks
{
528 nsRuleDataBreaks() {}
530 nsRuleDataBreaks(const nsRuleDataBreaks
& aOther
); // NOT IMPLEMENTED
533 struct nsCSSPage
: public nsCSSStruct
{ // NEW
538 nsCSSValuePair mSize
;
540 nsCSSPage(const nsCSSPage
& aOther
); // NOT IMPLEMENTED
543 struct nsRuleDataPage
: public nsCSSPage
{
546 nsRuleDataPage(const nsRuleDataPage
& aOther
); // NOT IMPLEMENTED
549 struct nsCSSContent
: public nsCSSStruct
{
553 nsCSSValueList
* mContent
;
554 nsCSSValuePairList
* mCounterIncrement
;
555 nsCSSValuePairList
* mCounterReset
;
556 nsCSSValue mMarkerOffset
;
557 nsCSSValuePairList
* mQuotes
;
559 nsCSSContent(const nsCSSContent
& aOther
); // NOT IMPLEMENTED
562 struct nsRuleDataContent
: public nsCSSContent
{
563 nsRuleDataContent() {}
565 nsRuleDataContent(const nsRuleDataContent
& aOther
); // NOT IMPLEMENTED
568 struct nsCSSUserInterface
: public nsCSSStruct
{ // NEW
569 nsCSSUserInterface(void);
570 ~nsCSSUserInterface(void);
572 nsCSSValue mUserInput
;
573 nsCSSValue mUserModify
;
574 nsCSSValue mUserSelect
;
575 nsCSSValue mUserFocus
;
577 nsCSSValueList
* mCursor
;
578 nsCSSValue mForceBrokenImageIcon
;
580 nsCSSValue mWindowShadow
;
582 nsCSSUserInterface(const nsCSSUserInterface
& aOther
); // NOT IMPLEMENTED
585 struct nsRuleDataUserInterface
: public nsCSSUserInterface
{
586 nsRuleDataUserInterface() {}
588 nsRuleDataUserInterface(const nsRuleDataUserInterface
& aOther
); // NOT IMPLEMENTED
591 struct nsCSSAural
: public nsCSSStruct
{ // NEW
596 nsCSSValue mElevation
;
597 nsCSSValue mCueAfter
;
598 nsCSSValue mCueBefore
;
599 nsCSSValue mPauseAfter
;
600 nsCSSValue mPauseBefore
;
602 nsCSSValue mPitchRange
;
603 nsCSSValue mRichness
;
605 nsCSSValue mSpeakHeader
;
606 nsCSSValue mSpeakNumeral
;
607 nsCSSValue mSpeakPunctuation
;
608 nsCSSValue mSpeechRate
;
610 nsCSSValue mVoiceFamily
;
613 nsCSSAural(const nsCSSAural
& aOther
); // NOT IMPLEMENTED
616 struct nsRuleDataAural
: public nsCSSAural
{
619 nsRuleDataAural(const nsRuleDataAural
& aOther
); // NOT IMPLEMENTED
622 struct nsCSSXUL
: public nsCSSStruct
{
626 nsCSSValue mBoxAlign
;
627 nsCSSValue mBoxDirection
;
629 nsCSSValue mBoxOrient
;
631 nsCSSValue mBoxOrdinal
;
632 nsCSSValue mStackSizing
;
634 nsCSSXUL(const nsCSSXUL
& aOther
); // NOT IMPLEMENTED
637 struct nsRuleDataXUL
: public nsCSSXUL
{
640 nsRuleDataXUL(const nsRuleDataXUL
& aOther
); // NOT IMPLEMENTED
643 struct nsCSSColumn
: public nsCSSStruct
{
647 nsCSSValue mColumnCount
;
648 nsCSSValue mColumnWidth
;
649 nsCSSValue mColumnGap
;
650 nsCSSValue mColumnRuleColor
;
651 nsCSSValue mColumnRuleWidth
;
652 nsCSSValue mColumnRuleStyle
;
654 nsCSSColumn(const nsCSSColumn
& aOther
); // NOT IMPLEMENTED
657 struct nsRuleDataColumn
: public nsCSSColumn
{
658 nsRuleDataColumn() {}
660 nsRuleDataColumn(const nsRuleDataColumn
& aOther
); // NOT IMPLEMENTED
664 struct nsCSSSVG
: public nsCSSStruct
{
668 nsCSSValue mClipPath
;
669 nsCSSValue mClipRule
;
670 nsCSSValue mColorInterpolation
;
671 nsCSSValue mColorInterpolationFilters
;
672 nsCSSValue mDominantBaseline
;
673 nsCSSValuePair mFill
;
674 nsCSSValue mFillOpacity
;
675 nsCSSValue mFillRule
;
677 nsCSSValue mFloodColor
;
678 nsCSSValue mFloodOpacity
;
679 nsCSSValue mLightingColor
;
680 nsCSSValue mMarkerEnd
;
681 nsCSSValue mMarkerMid
;
682 nsCSSValue mMarkerStart
;
684 nsCSSValue mPointerEvents
;
685 nsCSSValue mShapeRendering
;
686 nsCSSValue mStopColor
;
687 nsCSSValue mStopOpacity
;
688 nsCSSValuePair mStroke
;
689 nsCSSValueList
*mStrokeDasharray
;
690 nsCSSValue mStrokeDashoffset
;
691 nsCSSValue mStrokeLinecap
;
692 nsCSSValue mStrokeLinejoin
;
693 nsCSSValue mStrokeMiterlimit
;
694 nsCSSValue mStrokeOpacity
;
695 nsCSSValue mStrokeWidth
;
696 nsCSSValue mTextAnchor
;
697 nsCSSValue mTextRendering
;
699 nsCSSSVG(const nsCSSSVG
& aOther
); // NOT IMPLEMENTED
702 struct nsRuleDataSVG
: public nsCSSSVG
{
705 nsRuleDataSVG(const nsRuleDataSVG
& aOther
); // NOT IMPLEMENTED
709 #endif /* nsCSSStruct_h___ */