pjs/layout/style/nsCSSDeclaration.cpp

3160 строки
103 KiB
C++
Исходник Обычный вид История

1998-04-14 00:24:54 +04:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsICSSDeclaration.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsCSSProps.h"
#include "nsCSSPropIDs.h"
#include "nsUnitConversion.h"
1998-07-17 09:50:35 +04:00
#include "nsVoidArray.h"
1998-04-14 00:24:54 +04:00
#include "nsStyleConsts.h"
1998-04-22 10:38:31 +04:00
//#define DEBUG_REFS
1998-04-14 00:24:54 +04:00
static NS_DEFINE_IID(kCSSFontSID, NS_CSS_FONT_SID);
static NS_DEFINE_IID(kCSSColorSID, NS_CSS_COLOR_SID);
1998-04-25 22:43:42 +04:00
static NS_DEFINE_IID(kCSSDisplaySID, NS_CSS_DISPLAY_SID);
1998-04-14 00:24:54 +04:00
static NS_DEFINE_IID(kCSSTextSID, NS_CSS_TEXT_SID);
static NS_DEFINE_IID(kCSSMarginSID, NS_CSS_MARGIN_SID);
static NS_DEFINE_IID(kCSSPositionSID, NS_CSS_POSITION_SID);
static NS_DEFINE_IID(kCSSListSID, NS_CSS_LIST_SID);
1998-10-08 05:31:58 +04:00
static NS_DEFINE_IID(kCSSTableSID, NS_CSS_TABLE_SID);
static NS_DEFINE_IID(kCSSBreaksSID, NS_CSS_BREAKS_SID);
static NS_DEFINE_IID(kCSSPageSID, NS_CSS_PAGE_SID);
static NS_DEFINE_IID(kCSSContentSID, NS_CSS_CONTENT_SID);
static NS_DEFINE_IID(kCSSAuralSID, NS_CSS_AURAL_SID);
1998-04-14 00:24:54 +04:00
static NS_DEFINE_IID(kICSSDeclarationIID, NS_ICSS_DECLARATION_IID);
1998-10-27 02:22:40 +03:00
#define CSS_IF_DELETE(ptr) if (nsnull != ptr) { delete ptr; ptr = nsnull; }
nsCSSStruct::~nsCSSStruct()
{
}
1998-10-08 05:31:58 +04:00
// --- nsCSSFont -----------------
1998-04-14 00:24:54 +04:00
nsCSSFont::~nsCSSFont()
{
}
1998-04-14 00:24:54 +04:00
const nsID& nsCSSFont::GetID(void)
{
return kCSSFontSID;
}
void nsCSSFont::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mFamily.AppendToString(buffer, PROP_FONT_FAMILY);
mStyle.AppendToString(buffer, PROP_FONT_STYLE);
mVariant.AppendToString(buffer, PROP_FONT_VARIANT);
mWeight.AppendToString(buffer, PROP_FONT_WEIGHT);
mSize.AppendToString(buffer, PROP_FONT_SIZE);
1998-10-08 05:31:58 +04:00
mSizeAdjust.AppendToString(buffer, PROP_FONT_SIZE_ADJUST);
mStretch.AppendToString(buffer, PROP_FONT_STRETCH);
1998-04-14 00:24:54 +04:00
fputs(buffer, out);
}
1998-10-27 02:22:40 +03:00
// --- support -----------------
nsCSSValueList::nsCSSValueList(void)
: mValue(),
mNext(nsnull)
{
}
nsCSSValueList::~nsCSSValueList(void)
{
CSS_IF_DELETE(mNext);
}
1998-04-14 00:24:54 +04:00
1998-10-08 05:31:58 +04:00
// --- nsCSSColor -----------------
1998-10-27 02:22:40 +03:00
nsCSSColor::nsCSSColor(void)
: mCursor(nsnull)
{
}
nsCSSColor::~nsCSSColor(void)
{
CSS_IF_DELETE(mCursor);
}
1998-04-14 00:24:54 +04:00
const nsID& nsCSSColor::GetID(void)
{
return kCSSColorSID;
}
void nsCSSColor::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mColor.AppendToString(buffer, PROP_COLOR);
mBackColor.AppendToString(buffer, PROP_BACKGROUND_COLOR);
mBackImage.AppendToString(buffer, PROP_BACKGROUND_IMAGE);
mBackRepeat.AppendToString(buffer, PROP_BACKGROUND_REPEAT);
mBackAttachment.AppendToString(buffer, PROP_BACKGROUND_ATTACHMENT);
mBackPositionX.AppendToString(buffer, PROP_BACKGROUND_X_POSITION);
mBackPositionY.AppendToString(buffer, PROP_BACKGROUND_Y_POSITION);
mBackFilter.AppendToString(buffer, PROP_BACKGROUND_FILTER);
1998-10-27 02:22:40 +03:00
nsCSSValueList* cursor = mCursor;
while (nsnull != cursor) {
cursor->mValue.AppendToString(buffer, PROP_CURSOR);
cursor = cursor->mNext;
}
mOpacity.AppendToString(buffer, PROP_OPACITY);
1998-04-14 00:24:54 +04:00
fputs(buffer, out);
}
1998-10-27 02:22:40 +03:00
// --- nsCSSText support -----------------
1998-10-08 05:31:58 +04:00
nsCSSShadow::nsCSSShadow(void)
: mNext(nsnull)
{
}
nsCSSShadow::~nsCSSShadow(void)
{
1998-10-27 02:22:40 +03:00
CSS_IF_DELETE(mNext);
1998-10-08 05:31:58 +04:00
}
// --- nsCSSText -----------------
nsCSSText::nsCSSText(void)
: mTextShadow(nsnull)
{
}
nsCSSText::~nsCSSText(void)
{
1998-10-27 02:22:40 +03:00
CSS_IF_DELETE(mTextShadow);
1998-10-08 05:31:58 +04:00
}
1998-04-14 00:24:54 +04:00
const nsID& nsCSSText::GetID(void)
{
return kCSSTextSID;
}
void nsCSSText::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mWordSpacing.AppendToString(buffer, PROP_WORD_SPACING);
mLetterSpacing.AppendToString(buffer, PROP_LETTER_SPACING);
mDecoration.AppendToString(buffer, PROP_TEXT_DECORATION);
1998-04-28 01:24:06 +04:00
mVerticalAlign.AppendToString(buffer, PROP_VERTICAL_ALIGN);
mTextTransform.AppendToString(buffer, PROP_TEXT_TRANSFORM);
1998-04-25 22:43:42 +04:00
mTextAlign.AppendToString(buffer, PROP_TEXT_ALIGN);
1998-04-28 01:24:06 +04:00
mTextIndent.AppendToString(buffer, PROP_TEXT_INDENT);
1998-10-08 05:31:58 +04:00
if (nsnull != mTextShadow) {
1998-10-27 02:22:40 +03:00
if (mTextShadow->mXOffset.IsLengthUnit()) {
1998-10-08 05:31:58 +04:00
nsCSSShadow* shadow = mTextShadow;
while (nsnull != shadow) {
shadow->mColor.AppendToString(buffer, PROP_TEXT_SHADOW_COLOR);
shadow->mXOffset.AppendToString(buffer, PROP_TEXT_SHADOW_X);
shadow->mYOffset.AppendToString(buffer, PROP_TEXT_SHADOW_Y);
shadow->mRadius.AppendToString(buffer, PROP_TEXT_SHADOW_RADIUS);
shadow = shadow->mNext;
}
}
else {
1998-10-27 02:22:40 +03:00
mTextShadow->mXOffset.AppendToString(buffer, PROP_TEXT_SHADOW);
1998-10-08 05:31:58 +04:00
}
}
mUnicodeBidi.AppendToString(buffer, PROP_UNICODE_BIDI);
1998-04-14 00:24:54 +04:00
mLineHeight.AppendToString(buffer, PROP_LINE_HEIGHT);
mWhiteSpace.AppendToString(buffer, PROP_WHITE_SPACE);
fputs(buffer, out);
}
1998-10-08 05:31:58 +04:00
// --- nsCSSRect -----------------
1998-05-27 03:16:55 +04:00
void nsCSSRect::List(FILE* out, PRInt32 aPropID, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
if (-1 < aPropID) {
buffer.Append(nsCSSProps::kNameTable[aPropID].name);
buffer.Append(": ");
}
mTop.AppendToString(buffer);
mRight.AppendToString(buffer);
mBottom.AppendToString(buffer);
mLeft.AppendToString(buffer);
fputs(buffer, out);
}
void nsCSSRect::List(FILE* out, PRInt32 aIndent, PRIntn aTRBL[]) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
if (eCSSUnit_Null != mTop.GetUnit()) {
buffer.Append(nsCSSProps::kNameTable[aTRBL[0]].name);
buffer.Append(": ");
mTop.AppendToString(buffer);
}
if (eCSSUnit_Null != mRight.GetUnit()) {
buffer.Append(nsCSSProps::kNameTable[aTRBL[1]].name);
buffer.Append(": ");
mRight.AppendToString(buffer);
}
if (eCSSUnit_Null != mBottom.GetUnit()) {
buffer.Append(nsCSSProps::kNameTable[aTRBL[2]].name);
buffer.Append(": ");
mBottom.AppendToString(buffer);
}
if (eCSSUnit_Null != mLeft.GetUnit()) {
buffer.Append(nsCSSProps::kNameTable[aTRBL[3]].name);
buffer.Append(": ");
mLeft.AppendToString(buffer);
}
fputs(buffer, out);
}
1998-10-08 05:31:58 +04:00
// --- nsCSSDisplay -----------------
1998-05-27 03:16:55 +04:00
nsCSSDisplay::nsCSSDisplay(void)
: mClip(nsnull)
{
}
nsCSSDisplay::~nsCSSDisplay(void)
{
1998-10-27 02:22:40 +03:00
CSS_IF_DELETE(mClip);
1998-05-27 03:16:55 +04:00
}
1998-04-25 22:43:42 +04:00
const nsID& nsCSSDisplay::GetID(void)
{
return kCSSDisplaySID;
}
void nsCSSDisplay::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mDirection.AppendToString(buffer, PROP_DIRECTION);
mDisplay.AppendToString(buffer, PROP_DISPLAY);
mFloat.AppendToString(buffer, PROP_FLOAT);
mClear.AppendToString(buffer, PROP_CLEAR);
1998-05-27 03:16:55 +04:00
mVisibility.AppendToString(buffer, PROP_VISIBILITY);
mFilter.AppendToString(buffer, PROP_FILTER);
1998-04-25 22:43:42 +04:00
fputs(buffer, out);
1998-05-27 03:16:55 +04:00
if (nsnull != mClip) {
mClip->List(out, PROP_CLIP);
1998-04-14 00:24:54 +04:00
}
1998-05-27 03:16:55 +04:00
buffer.SetLength(0);
mOverflow.AppendToString(buffer, PROP_OVERFLOW);
1998-04-14 00:24:54 +04:00
fputs(buffer, out);
}
1998-10-08 05:31:58 +04:00
// --- nsCSSMargin -----------------
1998-04-14 00:24:54 +04:00
nsCSSMargin::nsCSSMargin(void)
1998-10-08 05:31:58 +04:00
: mMargin(nsnull), mPadding(nsnull),
mBorderWidth(nsnull), mBorderColor(nsnull), mBorderStyle(nsnull)
1998-04-14 00:24:54 +04:00
{
}
nsCSSMargin::~nsCSSMargin(void)
{
1998-10-27 02:22:40 +03:00
CSS_IF_DELETE(mMargin);
CSS_IF_DELETE(mPadding);
CSS_IF_DELETE(mBorderWidth);
CSS_IF_DELETE(mBorderColor);
CSS_IF_DELETE(mBorderStyle);
1998-04-14 00:24:54 +04:00
}
const nsID& nsCSSMargin::GetID(void)
{
return kCSSMarginSID;
}
void nsCSSMargin::List(FILE* out, PRInt32 aIndent) const
{
if (nsnull != mMargin) {
static PRIntn trbl[] = {
PROP_MARGIN_TOP,
PROP_MARGIN_RIGHT,
PROP_MARGIN_BOTTOM,
PROP_MARGIN_LEFT
};
mMargin->List(out, aIndent, trbl);
1998-04-14 00:24:54 +04:00
}
if (nsnull != mPadding) {
static PRIntn trbl[] = {
PROP_PADDING_TOP,
PROP_PADDING_RIGHT,
PROP_PADDING_BOTTOM,
PROP_PADDING_LEFT
};
mPadding->List(out, aIndent, trbl);
1998-04-14 00:24:54 +04:00
}
1998-10-08 05:31:58 +04:00
if (nsnull != mBorderWidth) {
static PRIntn trbl[] = {
PROP_BORDER_TOP_WIDTH,
PROP_BORDER_RIGHT_WIDTH,
PROP_BORDER_BOTTOM_WIDTH,
PROP_BORDER_LEFT_WIDTH
};
1998-10-08 05:31:58 +04:00
mBorderWidth->List(out, aIndent, trbl);
1998-04-14 00:24:54 +04:00
}
1998-10-08 05:31:58 +04:00
if (nsnull != mBorderColor) {
mBorderColor->List(out, PROP_BORDER_COLOR, aIndent);
1998-04-14 00:24:54 +04:00
}
1998-10-08 05:31:58 +04:00
if (nsnull != mBorderStyle) {
mBorderStyle->List(out, PROP_BORDER_STYLE, aIndent);
}
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mOutlineWidth.AppendToString(buffer, PROP_OUTLINE_WIDTH);
mOutlineColor.AppendToString(buffer, PROP_OUTLINE_COLOR);
mOutlineStyle.AppendToString(buffer, PROP_OUTLINE_STYLE);
fputs(buffer, out);
}
// --- nsCSSPosition -----------------
nsCSSPosition::nsCSSPosition(void)
: mOffset(nsnull)
{
}
nsCSSPosition::~nsCSSPosition(void)
{
1998-10-27 02:22:40 +03:00
CSS_IF_DELETE(mOffset);
1998-04-14 00:24:54 +04:00
}
const nsID& nsCSSPosition::GetID(void)
{
return kCSSPositionSID;
}
void nsCSSPosition::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mPosition.AppendToString(buffer, PROP_POSITION);
mWidth.AppendToString(buffer, PROP_WIDTH);
1998-10-08 05:31:58 +04:00
mMinWidth.AppendToString(buffer, PROP_MIN_WIDTH);
mMaxWidth.AppendToString(buffer, PROP_MAX_WIDTH);
1998-04-14 00:24:54 +04:00
mHeight.AppendToString(buffer, PROP_HEIGHT);
1998-10-08 05:31:58 +04:00
mMinHeight.AppendToString(buffer, PROP_MIN_HEIGHT);
mMaxHeight.AppendToString(buffer, PROP_MAX_HEIGHT);
1998-04-30 23:56:39 +04:00
mZIndex.AppendToString(buffer, PROP_Z_INDEX);
1998-04-14 00:24:54 +04:00
fputs(buffer, out);
1998-10-08 05:31:58 +04:00
if (nsnull != mOffset) {
static PRIntn trbl[] = {
PROP_TOP,
PROP_RIGHT,
PROP_BOTTOM,
PROP_LEFT
};
mOffset->List(out, aIndent, trbl);
}
1998-04-14 00:24:54 +04:00
}
1998-10-08 05:31:58 +04:00
// --- nsCSSList -----------------
nsCSSList::~nsCSSList()
{
}
1998-04-14 00:24:54 +04:00
const nsID& nsCSSList::GetID(void)
{
return kCSSListSID;
}
void nsCSSList::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mType.AppendToString(buffer, PROP_LIST_STYLE_TYPE);
mImage.AppendToString(buffer, PROP_LIST_STYLE_IMAGE);
mPosition.AppendToString(buffer, PROP_LIST_STYLE_POSITION);
fputs(buffer, out);
}
1998-10-08 05:31:58 +04:00
// --- nsCSSTable -----------------
nsCSSTable::~nsCSSTable()
{
}
1998-10-08 05:31:58 +04:00
const nsID& nsCSSTable::GetID(void)
{
return kCSSTableSID;
}
void nsCSSTable::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mBorderCollapse.AppendToString(buffer, PROP_BORDER_COLLAPSE);
1998-10-27 02:22:40 +03:00
mBorderSpacingX.AppendToString(buffer, PROP_BORDER_X_SPACING);
mBorderSpacingY.AppendToString(buffer, PROP_BORDER_Y_SPACING);
1998-10-08 05:31:58 +04:00
mCaptionSide.AppendToString(buffer, PROP_CAPTION_SIDE);
mEmptyCells.AppendToString(buffer, PROP_EMPTY_CELLS);
mLayout.AppendToString(buffer, PROP_TABLE_LAYOUT);
fputs(buffer, out);
}
// --- nsCSSBreaks -----------------
nsCSSBreaks::~nsCSSBreaks()
{
}
1998-10-08 05:31:58 +04:00
const nsID& nsCSSBreaks::GetID(void)
{
return kCSSBreaksSID;
}
void nsCSSBreaks::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mOrphans.AppendToString(buffer, PROP_ORPHANS);
mWidows.AppendToString(buffer, PROP_WIDOWS);
mPage.AppendToString(buffer, PROP_PAGE);
mPageBreakAfter.AppendToString(buffer, PROP_PAGE_BREAK_AFTER);
mPageBreakBefore.AppendToString(buffer, PROP_PAGE_BREAK_BEFORE);
mPageBreakInside.AppendToString(buffer, PROP_PAGE_BREAK_INSIDE);
fputs(buffer, out);
}
// --- nsCSSPage -----------------
nsCSSPage::~nsCSSPage()
{
}
1998-10-08 05:31:58 +04:00
const nsID& nsCSSPage::GetID(void)
{
return kCSSPageSID;
}
void nsCSSPage::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mMarks.AppendToString(buffer, PROP_MARKS);
1998-10-27 02:22:40 +03:00
mSizeWidth.AppendToString(buffer, PROP_SIZE_WIDTH);
mSizeHeight.AppendToString(buffer, PROP_SIZE_HEIGHT);
1998-10-08 05:31:58 +04:00
fputs(buffer, out);
}
1998-10-27 02:22:40 +03:00
// --- nsCSSContent support -----------------
nsCSSCounterData::nsCSSCounterData(void)
: mNext(nsnull)
{
}
nsCSSCounterData::~nsCSSCounterData(void)
{
CSS_IF_DELETE(mNext);
}
nsCSSQuotes::nsCSSQuotes(void)
: mNext(nsnull)
{
}
nsCSSQuotes::~nsCSSQuotes(void)
{
CSS_IF_DELETE(mNext);
}
1998-10-08 05:31:58 +04:00
// --- nsCSSContent -----------------
1998-10-27 02:22:40 +03:00
nsCSSContent::nsCSSContent(void)
: mContent(nsnull),
mCounterIncrement(nsnull),
mCounterReset(nsnull),
mQuotes(nsnull)
{
}
nsCSSContent::~nsCSSContent(void)
{
CSS_IF_DELETE(mContent);
CSS_IF_DELETE(mCounterIncrement);
CSS_IF_DELETE(mCounterReset);
CSS_IF_DELETE(mQuotes);
}
1998-10-08 05:31:58 +04:00
const nsID& nsCSSContent::GetID(void)
{
return kCSSContentSID;
}
void nsCSSContent::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
1998-10-27 02:22:40 +03:00
nsCSSValueList* content = mContent;
while (nsnull != content) {
content->mValue.AppendToString(buffer, PROP_CONTENT);
content = content->mNext;
}
nsCSSCounterData* counter = mCounterIncrement;
while (nsnull != counter) {
counter->mCounter.AppendToString(buffer, PROP_COUNTER_INCREMENT);
counter->mValue.AppendToString(buffer, -1);
counter = counter->mNext;
}
counter = mCounterReset;
while (nsnull != counter) {
counter->mCounter.AppendToString(buffer, PROP_COUNTER_RESET);
counter->mValue.AppendToString(buffer, -1);
counter = counter->mNext;
}
1998-10-08 05:31:58 +04:00
mMarkerOffset.AppendToString(buffer, PROP_MARKER_OFFSET);
1998-10-27 02:22:40 +03:00
nsCSSQuotes* quotes = mQuotes;
while (nsnull != quotes) {
quotes->mOpen.AppendToString(buffer, PROP_QUOTES_OPEN);
quotes->mClose.AppendToString(buffer, PROP_QUOTES_CLOSE);
quotes = quotes->mNext;
}
1998-10-08 05:31:58 +04:00
fputs(buffer, out);
}
// --- nsCSSAural -----------------
nsCSSAural::~nsCSSAural()
{
}
1998-10-08 05:31:58 +04:00
const nsID& nsCSSAural::GetID(void)
{
return kCSSAuralSID;
}
void nsCSSAural::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buffer;
mAzimuth.AppendToString(buffer, PROP_AZIMUTH);
mElevation.AppendToString(buffer, PROP_ELEVATION);
mCueAfter.AppendToString(buffer, PROP_CUE_AFTER);
mCueBefore.AppendToString(buffer, PROP_CUE_BEFORE);
mPauseAfter.AppendToString(buffer, PROP_PAUSE_AFTER);
mPauseBefore.AppendToString(buffer, PROP_PAUSE_BEFORE);
mPitch.AppendToString(buffer, PROP_PITCH);
mPitchRange.AppendToString(buffer, PROP_PITCH_RANGE);
mPlayDuring.AppendToString(buffer, PROP_PLAY_DURING);
1998-10-27 02:22:40 +03:00
mPlayDuringFlags.AppendToString(buffer, PROP_PLAY_DURING_FLAGS);
1998-10-08 05:31:58 +04:00
mRichness.AppendToString(buffer, PROP_RICHNESS);
mSpeak.AppendToString(buffer, PROP_SPEAK);
mSpeakHeader.AppendToString(buffer, PROP_SPEAK_HEADER);
mSpeakNumeral.AppendToString(buffer, PROP_SPEAK_NUMERAL);
mSpeakPunctuation.AppendToString(buffer, PROP_SPEAK_PUNCTUATION);
mSpeechRate.AppendToString(buffer, PROP_SPEECH_RATE);
mStress.AppendToString(buffer, PROP_STRESS);
mVoiceFamily.AppendToString(buffer, PROP_VOICE_FAMILY);
mVolume.AppendToString(buffer, PROP_VOLUME);
fputs(buffer, out);
}
// --- nsCSSDeclaration -----------------
1998-04-14 00:24:54 +04:00
class CSSDeclarationImpl : public nsICSSDeclaration {
public:
void* operator new(size_t size);
1998-04-14 00:24:54 +04:00
CSSDeclarationImpl(void);
virtual ~CSSDeclarationImpl(void);
1998-04-14 00:24:54 +04:00
NS_DECL_ISUPPORTS
1999-01-06 04:25:39 +03:00
NS_IMETHOD GetData(const nsID& aSID, nsCSSStruct** aData);
NS_IMETHOD EnsureData(const nsID& aSID, nsCSSStruct** aData);
1998-04-14 00:24:54 +04:00
1999-01-06 04:25:39 +03:00
NS_IMETHOD AppendValue(PRInt32 aProperty, const nsCSSValue& aValue);
1999-02-10 11:37:28 +03:00
NS_IMETHOD AppendStructValue(PRInt32 aProperty, void* aStruct);
1999-01-06 04:25:39 +03:00
NS_IMETHOD SetValueImportant(PRInt32 aProperty);
NS_IMETHOD AppendComment(const nsString& aComment);
1998-07-17 09:50:35 +04:00
1999-01-06 04:25:39 +03:00
NS_IMETHOD GetValue(PRInt32 aProperty, nsCSSValue& aValue);
NS_IMETHOD GetValue(PRInt32 aProperty, nsString& aValue);
NS_IMETHOD GetValue(const nsString& aProperty, nsString& aValue);
1998-04-14 00:24:54 +04:00
1999-01-06 04:25:39 +03:00
NS_IMETHOD GetImportantValues(nsICSSDeclaration*& aResult);
NS_IMETHOD GetValueIsImportant(PRInt32 aProperty, PRBool& aIsImportant);
NS_IMETHOD GetValueIsImportant(const nsString& aProperty, PRBool& aIsImportant);
1998-10-08 05:31:58 +04:00
PRBool AppendValueToString(PRInt32 aProperty, nsString& aResult);
PRBool AppendValueToString(PRInt32 aProperty, const nsCSSValue& aValue, nsString& aResult);
1999-01-06 04:25:39 +03:00
NS_IMETHOD ToString(nsString& aString);
1998-09-10 05:19:26 +04:00
1998-04-14 00:24:54 +04:00
void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
1999-01-06 04:25:39 +03:00
NS_IMETHOD Count(PRUint32* aCount);
NS_IMETHOD GetNthProperty(PRUint32 aIndex, nsString& aReturn);
NS_IMETHOD GetStyleImpact(PRInt32* aHint) const;
1998-04-14 00:24:54 +04:00
private:
CSSDeclarationImpl(const CSSDeclarationImpl& aCopy);
CSSDeclarationImpl& operator=(const CSSDeclarationImpl& aCopy);
PRBool operator==(const CSSDeclarationImpl& aCopy) const;
protected:
nsCSSFont* mFont;
nsCSSColor* mColor;
nsCSSText* mText;
nsCSSMargin* mMargin;
nsCSSPosition* mPosition;
nsCSSList* mList;
1998-04-25 22:43:42 +04:00
nsCSSDisplay* mDisplay;
1998-10-08 05:31:58 +04:00
nsCSSTable* mTable;
nsCSSBreaks* mBreaks;
nsCSSPage* mPage;
nsCSSContent* mContent;
nsCSSAural* mAural;
1998-06-26 09:51:55 +04:00
CSSDeclarationImpl* mImportant;
1998-07-17 09:50:35 +04:00
nsVoidArray* mOrder;
nsVoidArray* mComments;
1998-04-14 00:24:54 +04:00
};
1998-04-22 10:38:31 +04:00
#ifdef DEBUG_REFS
static PRInt32 gInstanceCount;
#endif
1998-04-14 00:24:54 +04:00
void* CSSDeclarationImpl::operator new(size_t size)
{
void* result = new char[size];
nsCRT::zero(result, size);
return result;
}
CSSDeclarationImpl::CSSDeclarationImpl(void)
{
NS_INIT_REFCNT();
1998-04-22 10:38:31 +04:00
#ifdef DEBUG_REFS
++gInstanceCount;
fprintf(stdout, "%d + CSSDeclaration\n", gInstanceCount);
#endif
1998-04-14 00:24:54 +04:00
}
CSSDeclarationImpl::~CSSDeclarationImpl(void)
{
1998-10-08 05:31:58 +04:00
CSS_IF_DELETE(mFont);
CSS_IF_DELETE(mColor);
CSS_IF_DELETE(mText);
CSS_IF_DELETE(mMargin);
CSS_IF_DELETE(mPosition);
CSS_IF_DELETE(mList);
CSS_IF_DELETE(mDisplay);
CSS_IF_DELETE(mTable);
CSS_IF_DELETE(mBreaks);
CSS_IF_DELETE(mPage);
CSS_IF_DELETE(mContent);
CSS_IF_DELETE(mAural);
1998-06-26 09:51:55 +04:00
NS_IF_RELEASE(mImportant);
1998-10-27 02:22:40 +03:00
CSS_IF_DELETE(mOrder);
1998-07-17 09:50:35 +04:00
if (nsnull != mComments) {
PRInt32 index = mComments->Count();
while (0 < --index) {
nsString* comment = (nsString*)mComments->ElementAt(index);
delete comment;
}
delete mComments;
}
1998-06-26 09:51:55 +04:00
1998-04-22 10:38:31 +04:00
#ifdef DEBUG_REFS
--gInstanceCount;
fprintf(stdout, "%d - CSSDeclaration\n", gInstanceCount);
#endif
1998-04-14 00:24:54 +04:00
}
NS_IMPL_ISUPPORTS(CSSDeclarationImpl, kICSSDeclarationIID);
1998-10-08 05:31:58 +04:00
#define CSS_IF_GET_ELSE(sid,ptr,result) \
if (sid.Equals(kCSS##ptr##SID)) { *result = m##ptr; } else
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetData(const nsID& aSID, nsCSSStruct** aDataPtr)
1998-04-14 00:24:54 +04:00
{
if (nsnull == aDataPtr) {
return NS_ERROR_NULL_POINTER;
}
1998-10-08 05:31:58 +04:00
CSS_IF_GET_ELSE(aSID, Font, aDataPtr)
CSS_IF_GET_ELSE(aSID, Color, aDataPtr)
CSS_IF_GET_ELSE(aSID, Display, aDataPtr)
CSS_IF_GET_ELSE(aSID, Text, aDataPtr)
CSS_IF_GET_ELSE(aSID, Margin, aDataPtr)
CSS_IF_GET_ELSE(aSID, Position, aDataPtr)
CSS_IF_GET_ELSE(aSID, List, aDataPtr)
CSS_IF_GET_ELSE(aSID, Table, aDataPtr)
CSS_IF_GET_ELSE(aSID, Breaks, aDataPtr)
CSS_IF_GET_ELSE(aSID, Page, aDataPtr)
CSS_IF_GET_ELSE(aSID, Content, aDataPtr)
CSS_IF_GET_ELSE(aSID, Aural, aDataPtr) {
1998-04-14 00:24:54 +04:00
return NS_NOINTERFACE;
}
return NS_OK;
}
1998-10-08 05:31:58 +04:00
#define CSS_IF_ENSURE_ELSE(sid,ptr,result) \
if (sid.Equals(kCSS##ptr##SID)) { \
if (nsnull == m##ptr) { m##ptr = new nsCSS##ptr(); } \
*result = m##ptr; \
} else
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::EnsureData(const nsID& aSID, nsCSSStruct** aDataPtr)
1998-04-14 00:24:54 +04:00
{
if (nsnull == aDataPtr) {
return NS_ERROR_NULL_POINTER;
}
1998-10-08 05:31:58 +04:00
CSS_IF_ENSURE_ELSE(aSID, Font, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Color, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Display, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Text, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Margin, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Position, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, List, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Table, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Breaks, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Page, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Content, aDataPtr)
CSS_IF_ENSURE_ELSE(aSID, Aural, aDataPtr) {
1998-04-14 00:24:54 +04:00
return NS_NOINTERFACE;
}
if (nsnull == *aDataPtr) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
1998-10-08 05:31:58 +04:00
#define CSS_ENSURE(data) \
if (nsnull == m##data) { \
m##data = new nsCSS##data(); \
} \
if (nsnull == m##data) { \
result = NS_ERROR_OUT_OF_MEMORY; \
} \
else
#define CSS_ENSURE_RECT(data) \
if (nsnull == data) { \
data = new nsCSSRect(); \
} \
if (nsnull == data) { \
result = NS_ERROR_OUT_OF_MEMORY; \
} \
else
1998-10-27 02:22:40 +03:00
#define CSS_ENSURE_DATA(data,type) \
if (nsnull == data) { \
data = new type(); \
} \
if (nsnull == data) { \
result = NS_ERROR_OUT_OF_MEMORY; \
} \
else
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::AppendValue(PRInt32 aProperty, const nsCSSValue& aValue)
1998-04-14 00:24:54 +04:00
{
nsresult result = NS_OK;
switch (aProperty) {
// nsCSSFont
case PROP_FONT_FAMILY:
case PROP_FONT_STYLE:
case PROP_FONT_VARIANT:
case PROP_FONT_WEIGHT:
case PROP_FONT_SIZE:
1998-10-08 05:31:58 +04:00
case PROP_FONT_SIZE_ADJUST:
case PROP_FONT_STRETCH:
CSS_ENSURE(Font) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_FONT_FAMILY: mFont->mFamily = aValue; break;
case PROP_FONT_STYLE: mFont->mStyle = aValue; break;
case PROP_FONT_VARIANT: mFont->mVariant = aValue; break;
case PROP_FONT_WEIGHT: mFont->mWeight = aValue; break;
case PROP_FONT_SIZE: mFont->mSize = aValue; break;
case PROP_FONT_SIZE_ADJUST: mFont->mSizeAdjust = aValue; break;
case PROP_FONT_STRETCH: mFont->mStretch = aValue; break;
1998-04-14 00:24:54 +04:00
}
}
break;
// nsCSSColor
case PROP_COLOR:
case PROP_BACKGROUND_COLOR:
case PROP_BACKGROUND_IMAGE:
case PROP_BACKGROUND_REPEAT:
case PROP_BACKGROUND_ATTACHMENT:
case PROP_BACKGROUND_X_POSITION:
case PROP_BACKGROUND_Y_POSITION:
case PROP_BACKGROUND_FILTER:
1998-04-25 22:43:42 +04:00
case PROP_CURSOR:
case PROP_OPACITY:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Color) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
case PROP_COLOR: mColor->mColor = aValue; break;
case PROP_BACKGROUND_COLOR: mColor->mBackColor = aValue; break;
case PROP_BACKGROUND_IMAGE: mColor->mBackImage = aValue; break;
case PROP_BACKGROUND_REPEAT: mColor->mBackRepeat = aValue; break;
case PROP_BACKGROUND_ATTACHMENT: mColor->mBackAttachment = aValue; break;
case PROP_BACKGROUND_X_POSITION: mColor->mBackPositionX = aValue; break;
case PROP_BACKGROUND_Y_POSITION: mColor->mBackPositionY = aValue; break;
case PROP_BACKGROUND_FILTER: mColor->mBackFilter = aValue; break;
1998-10-27 02:22:40 +03:00
case PROP_CURSOR:
CSS_ENSURE_DATA(mColor->mCursor, nsCSSValueList) {
mColor->mCursor->mValue = aValue;
CSS_IF_DELETE(mColor->mCursor->mNext);
}
break;
case PROP_OPACITY: mColor->mOpacity = aValue; break;
1998-04-14 00:24:54 +04:00
}
}
break;
// nsCSSText
case PROP_WORD_SPACING:
case PROP_LETTER_SPACING:
case PROP_TEXT_DECORATION:
case PROP_VERTICAL_ALIGN:
case PROP_TEXT_TRANSFORM:
case PROP_TEXT_ALIGN:
case PROP_TEXT_INDENT:
1998-10-08 05:31:58 +04:00
case PROP_UNICODE_BIDI:
1998-04-14 00:24:54 +04:00
case PROP_LINE_HEIGHT:
case PROP_WHITE_SPACE:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Text) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
case PROP_WORD_SPACING: mText->mWordSpacing = aValue; break;
case PROP_LETTER_SPACING: mText->mLetterSpacing = aValue; break;
case PROP_TEXT_DECORATION: mText->mDecoration = aValue; break;
1998-04-28 01:24:06 +04:00
case PROP_VERTICAL_ALIGN: mText->mVerticalAlign = aValue; break;
case PROP_TEXT_TRANSFORM: mText->mTextTransform = aValue; break;
1998-04-25 22:43:42 +04:00
case PROP_TEXT_ALIGN: mText->mTextAlign = aValue; break;
1998-04-28 01:24:06 +04:00
case PROP_TEXT_INDENT: mText->mTextIndent = aValue; break;
1998-10-08 05:31:58 +04:00
case PROP_UNICODE_BIDI: mText->mUnicodeBidi = aValue; break;
1998-04-14 00:24:54 +04:00
case PROP_LINE_HEIGHT: mText->mLineHeight = aValue; break;
case PROP_WHITE_SPACE: mText->mWhiteSpace = aValue; break;
}
}
1998-10-08 05:31:58 +04:00
break;
1998-10-27 02:22:40 +03:00
case PROP_TEXT_SHADOW_COLOR:
case PROP_TEXT_SHADOW_RADIUS:
case PROP_TEXT_SHADOW_X:
case PROP_TEXT_SHADOW_Y:
CSS_ENSURE(Text) {
CSS_ENSURE_DATA(mText->mTextShadow, nsCSSShadow) {
switch (aProperty) {
case PROP_TEXT_SHADOW_COLOR: mText->mTextShadow->mColor = aValue; break;
case PROP_TEXT_SHADOW_RADIUS: mText->mTextShadow->mRadius = aValue; break;
case PROP_TEXT_SHADOW_X: mText->mTextShadow->mXOffset = aValue; break;
case PROP_TEXT_SHADOW_Y: mText->mTextShadow->mYOffset = aValue; break;
}
CSS_IF_DELETE(mText->mTextShadow->mNext);
}
}
break;
1998-10-08 05:31:58 +04:00
// nsCSSDisplay
case PROP_FLOAT:
case PROP_CLEAR:
case PROP_DISPLAY:
case PROP_DIRECTION:
case PROP_VISIBILITY:
case PROP_OVERFLOW:
case PROP_FILTER:
CSS_ENSURE(Display) {
switch (aProperty) {
case PROP_FLOAT: mDisplay->mFloat = aValue; break;
case PROP_CLEAR: mDisplay->mClear = aValue; break;
case PROP_DISPLAY: mDisplay->mDisplay = aValue; break;
case PROP_DIRECTION: mDisplay->mDirection = aValue; break;
case PROP_VISIBILITY: mDisplay->mVisibility = aValue; break;
case PROP_OVERFLOW: mDisplay->mOverflow = aValue; break;
case PROP_FILTER: mDisplay->mFilter = aValue; break;
}
}
break;
case PROP_CLIP_TOP:
case PROP_CLIP_RIGHT:
case PROP_CLIP_BOTTOM:
case PROP_CLIP_LEFT:
CSS_ENSURE(Display) {
CSS_ENSURE_RECT(mDisplay->mClip) {
switch(aProperty) {
case PROP_CLIP_TOP: mDisplay->mClip->mTop = aValue; break;
case PROP_CLIP_RIGHT: mDisplay->mClip->mRight = aValue; break;
case PROP_CLIP_BOTTOM: mDisplay->mClip->mBottom = aValue; break;
case PROP_CLIP_LEFT: mDisplay->mClip->mLeft = aValue; break;
}
}
1998-04-14 00:24:54 +04:00
}
break;
// nsCSSMargin
case PROP_MARGIN_TOP:
case PROP_MARGIN_RIGHT:
case PROP_MARGIN_BOTTOM:
case PROP_MARGIN_LEFT:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Margin) {
CSS_ENSURE_RECT(mMargin->mMargin) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
case PROP_MARGIN_TOP: mMargin->mMargin->mTop = aValue; break;
case PROP_MARGIN_RIGHT: mMargin->mMargin->mRight = aValue; break;
case PROP_MARGIN_BOTTOM: mMargin->mMargin->mBottom = aValue; break;
case PROP_MARGIN_LEFT: mMargin->mMargin->mLeft = aValue; break;
}
}
}
break;
case PROP_PADDING_TOP:
case PROP_PADDING_RIGHT:
case PROP_PADDING_BOTTOM:
case PROP_PADDING_LEFT:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Margin) {
CSS_ENSURE_RECT(mMargin->mPadding) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
case PROP_PADDING_TOP: mMargin->mPadding->mTop = aValue; break;
case PROP_PADDING_RIGHT: mMargin->mPadding->mRight = aValue; break;
case PROP_PADDING_BOTTOM: mMargin->mPadding->mBottom = aValue; break;
case PROP_PADDING_LEFT: mMargin->mPadding->mLeft = aValue; break;
}
}
}
break;
case PROP_BORDER_TOP_WIDTH:
case PROP_BORDER_RIGHT_WIDTH:
case PROP_BORDER_BOTTOM_WIDTH:
case PROP_BORDER_LEFT_WIDTH:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Margin) {
CSS_ENSURE_RECT(mMargin->mBorderWidth) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_BORDER_TOP_WIDTH: mMargin->mBorderWidth->mTop = aValue; break;
case PROP_BORDER_RIGHT_WIDTH: mMargin->mBorderWidth->mRight = aValue; break;
case PROP_BORDER_BOTTOM_WIDTH: mMargin->mBorderWidth->mBottom = aValue; break;
case PROP_BORDER_LEFT_WIDTH: mMargin->mBorderWidth->mLeft = aValue; break;
1998-04-14 00:24:54 +04:00
}
}
}
break;
case PROP_BORDER_TOP_COLOR:
case PROP_BORDER_RIGHT_COLOR:
case PROP_BORDER_BOTTOM_COLOR:
case PROP_BORDER_LEFT_COLOR:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Margin) {
CSS_ENSURE_RECT(mMargin->mBorderColor) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_BORDER_TOP_COLOR: mMargin->mBorderColor->mTop = aValue; break;
case PROP_BORDER_RIGHT_COLOR: mMargin->mBorderColor->mRight = aValue; break;
case PROP_BORDER_BOTTOM_COLOR: mMargin->mBorderColor->mBottom = aValue; break;
case PROP_BORDER_LEFT_COLOR: mMargin->mBorderColor->mLeft = aValue; break;
1998-04-14 00:24:54 +04:00
}
}
}
break;
case PROP_BORDER_TOP_STYLE:
case PROP_BORDER_RIGHT_STYLE:
case PROP_BORDER_BOTTOM_STYLE:
case PROP_BORDER_LEFT_STYLE:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Margin) {
CSS_ENSURE_RECT(mMargin->mBorderStyle) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_BORDER_TOP_STYLE: mMargin->mBorderStyle->mTop = aValue; break;
case PROP_BORDER_RIGHT_STYLE: mMargin->mBorderStyle->mRight = aValue; break;
case PROP_BORDER_BOTTOM_STYLE: mMargin->mBorderStyle->mBottom = aValue; break;
case PROP_BORDER_LEFT_STYLE: mMargin->mBorderStyle->mLeft = aValue; break;
1998-04-14 00:24:54 +04:00
}
}
}
1998-10-08 05:31:58 +04:00
break;
case PROP_OUTLINE_WIDTH:
case PROP_OUTLINE_COLOR:
case PROP_OUTLINE_STYLE:
CSS_ENSURE(Margin) {
switch (aProperty) {
case PROP_OUTLINE_WIDTH: mMargin->mOutlineWidth = aValue; break;
case PROP_OUTLINE_COLOR: mMargin->mOutlineColor = aValue; break;
case PROP_OUTLINE_STYLE: mMargin->mOutlineStyle = aValue; break;
}
1998-04-14 00:24:54 +04:00
}
break;
// nsCSSPosition
case PROP_POSITION:
case PROP_WIDTH:
1998-10-08 05:31:58 +04:00
case PROP_MIN_WIDTH:
case PROP_MAX_WIDTH:
1998-04-14 00:24:54 +04:00
case PROP_HEIGHT:
1998-10-08 05:31:58 +04:00
case PROP_MIN_HEIGHT:
case PROP_MAX_HEIGHT:
1998-04-14 00:24:54 +04:00
case PROP_Z_INDEX:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Position) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
case PROP_POSITION: mPosition->mPosition = aValue; break;
case PROP_WIDTH: mPosition->mWidth = aValue; break;
1998-10-08 05:31:58 +04:00
case PROP_MIN_WIDTH: mPosition->mMinWidth = aValue; break;
case PROP_MAX_WIDTH: mPosition->mMaxWidth = aValue; break;
1998-04-14 00:24:54 +04:00
case PROP_HEIGHT: mPosition->mHeight = aValue; break;
1998-10-08 05:31:58 +04:00
case PROP_MIN_HEIGHT: mPosition->mMinHeight = aValue; break;
case PROP_MAX_HEIGHT: mPosition->mMaxHeight = aValue; break;
1998-04-14 00:24:54 +04:00
case PROP_Z_INDEX: mPosition->mZIndex = aValue; break;
}
}
1998-10-08 05:31:58 +04:00
break;
case PROP_TOP:
case PROP_RIGHT:
case PROP_BOTTOM:
case PROP_LEFT:
CSS_ENSURE(Position) {
CSS_ENSURE_RECT(mPosition->mOffset) {
switch (aProperty) {
case PROP_TOP: mPosition->mOffset->mTop = aValue; break;
case PROP_RIGHT: mPosition->mOffset->mRight= aValue; break;
case PROP_BOTTOM: mPosition->mOffset->mBottom = aValue; break;
case PROP_LEFT: mPosition->mOffset->mLeft = aValue; break;
}
}
1998-04-14 00:24:54 +04:00
}
break;
// nsCSSList
case PROP_LIST_STYLE_TYPE:
case PROP_LIST_STYLE_IMAGE:
case PROP_LIST_STYLE_POSITION:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(List) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
case PROP_LIST_STYLE_TYPE: mList->mType = aValue; break;
case PROP_LIST_STYLE_IMAGE: mList->mImage = aValue; break;
case PROP_LIST_STYLE_POSITION: mList->mPosition = aValue; break;
}
}
break;
1998-10-08 05:31:58 +04:00
// nsCSSTable
case PROP_BORDER_COLLAPSE:
1998-10-27 02:22:40 +03:00
case PROP_BORDER_X_SPACING:
case PROP_BORDER_Y_SPACING:
1998-10-08 05:31:58 +04:00
case PROP_CAPTION_SIDE:
case PROP_EMPTY_CELLS:
case PROP_TABLE_LAYOUT:
CSS_ENSURE(Table) {
1998-04-25 22:43:42 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_BORDER_COLLAPSE: mTable->mBorderCollapse = aValue; break;
1998-10-27 02:22:40 +03:00
case PROP_BORDER_X_SPACING: mTable->mBorderSpacingX = aValue; break;
case PROP_BORDER_Y_SPACING: mTable->mBorderSpacingY = aValue; break;
1998-10-08 05:31:58 +04:00
case PROP_CAPTION_SIDE: mTable->mCaptionSide = aValue; break;
case PROP_EMPTY_CELLS: mTable->mEmptyCells = aValue; break;
case PROP_TABLE_LAYOUT: mTable->mLayout = aValue; break;
1998-05-27 03:16:55 +04:00
}
}
break;
1998-10-08 05:31:58 +04:00
// nsCSSBreaks
case PROP_ORPHANS:
case PROP_WIDOWS:
case PROP_PAGE:
case PROP_PAGE_BREAK_AFTER:
case PROP_PAGE_BREAK_BEFORE:
case PROP_PAGE_BREAK_INSIDE:
CSS_ENSURE(Breaks) {
switch (aProperty) {
case PROP_ORPHANS: mBreaks->mOrphans = aValue; break;
case PROP_WIDOWS: mBreaks->mWidows = aValue; break;
case PROP_PAGE: mBreaks->mPage = aValue; break;
case PROP_PAGE_BREAK_AFTER: mBreaks->mPageBreakAfter = aValue; break;
case PROP_PAGE_BREAK_BEFORE: mBreaks->mPageBreakBefore = aValue; break;
case PROP_PAGE_BREAK_INSIDE: mBreaks->mPageBreakInside = aValue; break;
1998-05-27 03:16:55 +04:00
}
1998-10-08 05:31:58 +04:00
}
break;
// nsCSSPage
case PROP_MARKS:
1998-10-27 02:22:40 +03:00
case PROP_SIZE_WIDTH:
case PROP_SIZE_HEIGHT:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Page) {
switch (aProperty) {
1998-10-27 02:22:40 +03:00
case PROP_MARKS: mPage->mMarks = aValue; break;
case PROP_SIZE_WIDTH: mPage->mSizeWidth = aValue; break;
case PROP_SIZE_HEIGHT: mPage->mSizeHeight = aValue; break;
1998-05-27 03:16:55 +04:00
}
1998-10-08 05:31:58 +04:00
}
break;
// nsCSSContent
case PROP_CONTENT:
case PROP_COUNTER_INCREMENT:
case PROP_COUNTER_RESET:
case PROP_MARKER_OFFSET:
1998-10-27 02:22:40 +03:00
case PROP_QUOTES_OPEN:
case PROP_QUOTES_CLOSE:
1998-10-08 05:31:58 +04:00
CSS_ENSURE(Content) {
switch (aProperty) {
1998-10-27 02:22:40 +03:00
case PROP_CONTENT:
CSS_ENSURE_DATA(mContent->mContent, nsCSSValueList) {
mContent->mContent->mValue = aValue;
CSS_IF_DELETE(mContent->mContent->mNext);
}
break;
case PROP_COUNTER_INCREMENT:
CSS_ENSURE_DATA(mContent->mCounterIncrement, nsCSSCounterData) {
mContent->mCounterIncrement->mCounter = aValue;
CSS_IF_DELETE(mContent->mCounterIncrement->mNext);
}
break;
case PROP_COUNTER_RESET:
CSS_ENSURE_DATA(mContent->mCounterReset, nsCSSCounterData) {
mContent->mCounterReset->mCounter = aValue;
CSS_IF_DELETE(mContent->mCounterReset->mNext);
}
break;
1998-10-08 05:31:58 +04:00
case PROP_MARKER_OFFSET: mContent->mMarkerOffset = aValue; break;
1998-10-27 02:22:40 +03:00
case PROP_QUOTES_OPEN:
CSS_ENSURE_DATA(mContent->mQuotes, nsCSSQuotes) {
mContent->mQuotes->mOpen = aValue;
CSS_IF_DELETE(mContent->mQuotes->mNext);
}
break;
case PROP_QUOTES_CLOSE:
CSS_ENSURE_DATA(mContent->mQuotes, nsCSSQuotes) {
mContent->mQuotes->mClose = aValue;
CSS_IF_DELETE(mContent->mQuotes->mNext);
}
break;
1998-04-25 22:43:42 +04:00
}
}
1998-10-08 05:31:58 +04:00
break;
// nsCSSAural
case PROP_AZIMUTH:
case PROP_ELEVATION:
case PROP_CUE_AFTER:
case PROP_CUE_BEFORE:
case PROP_PAUSE_AFTER:
case PROP_PAUSE_BEFORE:
case PROP_PITCH:
case PROP_PITCH_RANGE:
case PROP_PLAY_DURING:
1998-10-27 02:22:40 +03:00
case PROP_PLAY_DURING_FLAGS:
1998-10-08 05:31:58 +04:00
case PROP_RICHNESS:
case PROP_SPEAK:
case PROP_SPEAK_HEADER:
case PROP_SPEAK_NUMERAL:
case PROP_SPEAK_PUNCTUATION:
case PROP_SPEECH_RATE:
case PROP_STRESS:
case PROP_VOICE_FAMILY:
case PROP_VOLUME:
CSS_ENSURE(Aural) {
switch (aProperty) {
case PROP_AZIMUTH: mAural->mAzimuth = aValue; break;
case PROP_ELEVATION: mAural->mElevation = aValue; break;
case PROP_CUE_AFTER: mAural->mCueAfter = aValue; break;
case PROP_CUE_BEFORE: mAural->mCueBefore = aValue; break;
case PROP_PAUSE_AFTER: mAural->mPauseAfter = aValue; break;
case PROP_PAUSE_BEFORE: mAural->mPauseBefore = aValue; break;
case PROP_PITCH: mAural->mPitch = aValue; break;
case PROP_PITCH_RANGE: mAural->mPitchRange = aValue; break;
case PROP_PLAY_DURING: mAural->mPlayDuring = aValue; break;
1998-10-27 02:22:40 +03:00
case PROP_PLAY_DURING_FLAGS: mAural->mPlayDuringFlags = aValue; break;
1998-10-08 05:31:58 +04:00
case PROP_RICHNESS: mAural->mRichness = aValue; break;
case PROP_SPEAK: mAural->mSpeak = aValue; break;
case PROP_SPEAK_HEADER: mAural->mSpeakHeader = aValue; break;
case PROP_SPEAK_NUMERAL: mAural->mSpeakNumeral = aValue; break;
case PROP_SPEAK_PUNCTUATION: mAural->mSpeakPunctuation = aValue; break;
case PROP_SPEECH_RATE: mAural->mSpeechRate = aValue; break;
case PROP_STRESS: mAural->mStress = aValue; break;
case PROP_VOICE_FAMILY: mAural->mVoiceFamily = aValue; break;
case PROP_VOLUME: mAural->mVolume = aValue; break;
}
1998-04-25 22:43:42 +04:00
}
break;
1998-10-08 05:31:58 +04:00
// Shorthands
1998-04-14 00:24:54 +04:00
case PROP_BACKGROUND:
case PROP_BORDER:
1998-10-27 02:22:40 +03:00
case PROP_BORDER_SPACING:
1998-04-14 00:24:54 +04:00
case PROP_CLIP:
1998-10-08 05:31:58 +04:00
case PROP_CUE:
1998-04-14 00:24:54 +04:00
case PROP_FONT:
case PROP_LIST_STYLE:
case PROP_MARGIN:
1998-10-08 05:31:58 +04:00
case PROP_OUTLINE:
1998-04-14 00:24:54 +04:00
case PROP_PADDING:
1998-10-08 05:31:58 +04:00
case PROP_PAUSE:
1998-10-27 02:22:40 +03:00
case PROP_QUOTES:
case PROP_SIZE:
1998-10-08 05:31:58 +04:00
case PROP_TEXT_SHADOW:
1998-04-14 00:24:54 +04:00
case PROP_BACKGROUND_POSITION:
case PROP_BORDER_TOP:
case PROP_BORDER_RIGHT:
case PROP_BORDER_BOTTOM:
case PROP_BORDER_LEFT:
case PROP_BORDER_COLOR:
case PROP_BORDER_STYLE:
case PROP_BORDER_WIDTH:
1999-02-10 11:37:28 +03:00
NS_ERROR("can't append shorthand properties");
1998-04-14 00:24:54 +04:00
default:
result = NS_ERROR_ILLEGAL_VALUE;
break;
}
1998-07-17 09:50:35 +04:00
if (NS_OK == result) {
if (nsnull == mOrder) {
mOrder = new nsVoidArray();
}
if (nsnull != mOrder) {
PRInt32 index = mOrder->IndexOf((void*)aProperty);
if (-1 != index) {
mOrder->RemoveElementAt(index);
}
if (eCSSUnit_Null != aValue.GetUnit()) {
mOrder->AppendElement((void*)aProperty);
}
}
}
1998-04-14 00:24:54 +04:00
return result;
}
1999-02-10 11:37:28 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::AppendStructValue(PRInt32 aProperty, void* aStruct)
{
NS_ASSERTION(nsnull != aStruct, "must have struct");
if (nsnull == aStruct) {
return NS_ERROR_NULL_POINTER;
}
nsresult result = NS_OK;
switch (aProperty) {
case PROP_CURSOR:
CSS_ENSURE(Color) {
CSS_IF_DELETE(mColor->mCursor);
mColor->mCursor = (nsCSSValueList*)aStruct;
}
break;
case PROP_TEXT_SHADOW:
CSS_ENSURE(Text) {
CSS_IF_DELETE(mText->mTextShadow);
mText->mTextShadow = (nsCSSShadow*)aStruct;
}
break;
case PROP_CONTENT:
CSS_ENSURE(Content) {
CSS_IF_DELETE(mContent->mContent);
mContent->mContent = (nsCSSValueList*)aStruct;
}
break;
case PROP_COUNTER_INCREMENT:
CSS_ENSURE(Content) {
CSS_IF_DELETE(mContent->mCounterIncrement);
mContent->mCounterIncrement = (nsCSSCounterData*)aStruct;
}
break;
case PROP_COUNTER_RESET:
CSS_ENSURE(Content) {
CSS_IF_DELETE(mContent->mCounterReset);
mContent->mCounterReset = (nsCSSCounterData*)aStruct;
}
break;
case PROP_QUOTES:
CSS_ENSURE(Content) {
CSS_IF_DELETE(mContent->mQuotes);
mContent->mQuotes = (nsCSSQuotes*)aStruct;
}
break;
default:
NS_ERROR("not a struct property");
result = NS_ERROR_ILLEGAL_VALUE;
break;
}
if (NS_OK == result) {
if (nsnull == mOrder) {
mOrder = new nsVoidArray();
}
if (nsnull != mOrder) {
PRInt32 index = mOrder->IndexOf((void*)aProperty);
if (-1 != index) {
mOrder->RemoveElementAt(index);
}
mOrder->AppendElement((void*)aProperty);
}
}
return result;
}
1998-10-08 05:31:58 +04:00
#define CSS_ENSURE_IMPORTANT(data) \
if (nsnull == mImportant->m##data) { \
mImportant->m##data = new nsCSS##data(); \
} \
if (nsnull == mImportant->m##data) { \
result = NS_ERROR_OUT_OF_MEMORY; \
} \
else
#define CSS_CASE_IMPORTANT(prop,data) \
case prop: mImportant->data = data; data.Reset(); break
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::SetValueImportant(PRInt32 aProperty)
1998-06-26 09:51:55 +04:00
{
nsresult result = NS_OK;
if (nsnull == mImportant) {
mImportant = new CSSDeclarationImpl();
if (nsnull != mImportant) {
NS_ADDREF(mImportant);
}
else {
result = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_OK == result) {
switch (aProperty) {
// nsCSSFont
case PROP_FONT_FAMILY:
case PROP_FONT_STYLE:
case PROP_FONT_VARIANT:
case PROP_FONT_WEIGHT:
case PROP_FONT_SIZE:
1998-10-08 05:31:58 +04:00
case PROP_FONT_SIZE_ADJUST:
case PROP_FONT_STRETCH:
1998-06-26 09:51:55 +04:00
if (nsnull != mFont) {
1998-10-08 05:31:58 +04:00
CSS_ENSURE_IMPORTANT(Font) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_FONT_FAMILY, mFont->mFamily);
CSS_CASE_IMPORTANT(PROP_FONT_STYLE, mFont->mStyle);
CSS_CASE_IMPORTANT(PROP_FONT_VARIANT, mFont->mVariant);
CSS_CASE_IMPORTANT(PROP_FONT_WEIGHT, mFont->mWeight);
CSS_CASE_IMPORTANT(PROP_FONT_SIZE, mFont->mSize);
CSS_CASE_IMPORTANT(PROP_FONT_SIZE_ADJUST, mFont->mSizeAdjust);
CSS_CASE_IMPORTANT(PROP_FONT_STRETCH, mFont->mStretch);
1998-06-26 09:51:55 +04:00
}
}
}
break;
// nsCSSColor
case PROP_COLOR:
case PROP_BACKGROUND_COLOR:
case PROP_BACKGROUND_IMAGE:
case PROP_BACKGROUND_REPEAT:
case PROP_BACKGROUND_ATTACHMENT:
case PROP_BACKGROUND_X_POSITION:
case PROP_BACKGROUND_Y_POSITION:
case PROP_BACKGROUND_FILTER:
case PROP_OPACITY:
if (nsnull != mColor) {
1998-10-08 05:31:58 +04:00
CSS_ENSURE_IMPORTANT(Color) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_COLOR, mColor->mColor);
CSS_CASE_IMPORTANT(PROP_BACKGROUND_COLOR, mColor->mBackColor);
CSS_CASE_IMPORTANT(PROP_BACKGROUND_IMAGE, mColor->mBackImage);
CSS_CASE_IMPORTANT(PROP_BACKGROUND_REPEAT, mColor->mBackRepeat);
CSS_CASE_IMPORTANT(PROP_BACKGROUND_ATTACHMENT, mColor->mBackAttachment);
CSS_CASE_IMPORTANT(PROP_BACKGROUND_X_POSITION, mColor->mBackPositionX);
CSS_CASE_IMPORTANT(PROP_BACKGROUND_Y_POSITION, mColor->mBackPositionY);
CSS_CASE_IMPORTANT(PROP_BACKGROUND_FILTER, mColor->mBackFilter);
CSS_CASE_IMPORTANT(PROP_OPACITY, mColor->mOpacity);
1998-06-26 09:51:55 +04:00
}
}
}
break;
1998-10-27 02:22:40 +03:00
case PROP_CURSOR:
if (nsnull != mColor) {
if (nsnull != mColor->mCursor) {
CSS_ENSURE_IMPORTANT(Color) {
CSS_IF_DELETE(mImportant->mColor->mCursor);
mImportant->mColor->mCursor = mColor->mCursor;
mColor->mCursor = nsnull;
}
}
}
break;
1998-06-26 09:51:55 +04:00
// nsCSSText
case PROP_WORD_SPACING:
case PROP_LETTER_SPACING:
case PROP_TEXT_DECORATION:
case PROP_VERTICAL_ALIGN:
case PROP_TEXT_TRANSFORM:
case PROP_TEXT_ALIGN:
case PROP_TEXT_INDENT:
1998-10-08 05:31:58 +04:00
case PROP_UNICODE_BIDI:
1998-06-26 09:51:55 +04:00
case PROP_LINE_HEIGHT:
case PROP_WHITE_SPACE:
if (nsnull != mText) {
1998-10-08 05:31:58 +04:00
CSS_ENSURE_IMPORTANT(Text) {
switch (aProperty) {
CSS_CASE_IMPORTANT(PROP_WORD_SPACING, mText->mWordSpacing);
CSS_CASE_IMPORTANT(PROP_LETTER_SPACING, mText->mLetterSpacing);
CSS_CASE_IMPORTANT(PROP_TEXT_DECORATION, mText->mDecoration);
CSS_CASE_IMPORTANT(PROP_VERTICAL_ALIGN, mText->mVerticalAlign);
CSS_CASE_IMPORTANT(PROP_TEXT_TRANSFORM, mText->mTextTransform);
CSS_CASE_IMPORTANT(PROP_TEXT_ALIGN, mText->mTextAlign);
CSS_CASE_IMPORTANT(PROP_TEXT_INDENT, mText->mTextIndent);
CSS_CASE_IMPORTANT(PROP_UNICODE_BIDI, mText->mUnicodeBidi);
CSS_CASE_IMPORTANT(PROP_LINE_HEIGHT, mText->mLineHeight);
CSS_CASE_IMPORTANT(PROP_WHITE_SPACE, mText->mWhiteSpace);
}
1998-06-26 09:51:55 +04:00
}
1998-10-08 05:31:58 +04:00
}
break;
case PROP_TEXT_SHADOW:
if (nsnull != mText) {
if (nsnull != mText->mTextShadow) {
CSS_ENSURE_IMPORTANT(Text) {
1998-10-27 02:22:40 +03:00
CSS_IF_DELETE(mImportant->mText->mTextShadow);
1998-10-08 05:31:58 +04:00
mImportant->mText->mTextShadow = mText->mTextShadow;
mText->mTextShadow = nsnull;
}
}
}
break;
// nsCSSDisplay
case PROP_DIRECTION:
case PROP_DISPLAY:
case PROP_FLOAT:
case PROP_CLEAR:
case PROP_OVERFLOW:
case PROP_VISIBILITY:
case PROP_FILTER:
if (nsnull != mDisplay) {
CSS_ENSURE_IMPORTANT(Display) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_DIRECTION, mDisplay->mDirection);
CSS_CASE_IMPORTANT(PROP_DISPLAY, mDisplay->mDisplay);
CSS_CASE_IMPORTANT(PROP_FLOAT, mDisplay->mFloat);
CSS_CASE_IMPORTANT(PROP_CLEAR, mDisplay->mClear);
CSS_CASE_IMPORTANT(PROP_OVERFLOW, mDisplay->mOverflow);
CSS_CASE_IMPORTANT(PROP_VISIBILITY, mDisplay->mVisibility);
CSS_CASE_IMPORTANT(PROP_FILTER, mDisplay->mFilter);
1998-06-26 09:51:55 +04:00
}
}
1998-10-08 05:31:58 +04:00
}
break;
case PROP_CLIP_TOP:
case PROP_CLIP_RIGHT:
case PROP_CLIP_BOTTOM:
case PROP_CLIP_LEFT:
if (nsnull != mDisplay) {
if (nsnull != mDisplay->mClip) {
CSS_ENSURE_IMPORTANT(Display) {
CSS_ENSURE_RECT(mImportant->mDisplay->mClip) {
switch(aProperty) {
CSS_CASE_IMPORTANT(PROP_CLIP_TOP, mDisplay->mClip->mTop);
CSS_CASE_IMPORTANT(PROP_CLIP_RIGHT, mDisplay->mClip->mRight);
CSS_CASE_IMPORTANT(PROP_CLIP_BOTTOM, mDisplay->mClip->mBottom);
CSS_CASE_IMPORTANT(PROP_CLIP_LEFT, mDisplay->mClip->mLeft);
}
}
}
1998-06-26 09:51:55 +04:00
}
}
break;
// nsCSSMargin
case PROP_MARGIN_TOP:
case PROP_MARGIN_RIGHT:
case PROP_MARGIN_BOTTOM:
case PROP_MARGIN_LEFT:
if (nsnull != mMargin) {
if (nsnull != mMargin->mMargin) {
1998-10-08 05:31:58 +04:00
CSS_ENSURE_IMPORTANT(Margin) {
CSS_ENSURE_RECT(mImportant->mMargin->mMargin) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_MARGIN_TOP, mMargin->mMargin->mTop);
CSS_CASE_IMPORTANT(PROP_MARGIN_RIGHT, mMargin->mMargin->mRight);
CSS_CASE_IMPORTANT(PROP_MARGIN_BOTTOM, mMargin->mMargin->mBottom);
CSS_CASE_IMPORTANT(PROP_MARGIN_LEFT, mMargin->mMargin->mLeft);
1998-06-26 09:51:55 +04:00
}
}
}
}
}
break;
case PROP_PADDING_TOP:
case PROP_PADDING_RIGHT:
case PROP_PADDING_BOTTOM:
case PROP_PADDING_LEFT:
if (nsnull != mMargin) {
if (nsnull != mMargin->mPadding) {
1998-10-08 05:31:58 +04:00
CSS_ENSURE_IMPORTANT(Margin) {
CSS_ENSURE_RECT(mImportant->mMargin->mPadding) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_PADDING_TOP, mMargin->mPadding->mTop);
CSS_CASE_IMPORTANT(PROP_PADDING_RIGHT, mMargin->mPadding->mRight);
CSS_CASE_IMPORTANT(PROP_PADDING_BOTTOM, mMargin->mPadding->mBottom);
CSS_CASE_IMPORTANT(PROP_PADDING_LEFT, mMargin->mPadding->mLeft);
1998-06-26 09:51:55 +04:00
}
}
}
}
}
break;
case PROP_BORDER_TOP_WIDTH:
case PROP_BORDER_RIGHT_WIDTH:
case PROP_BORDER_BOTTOM_WIDTH:
case PROP_BORDER_LEFT_WIDTH:
if (nsnull != mMargin) {
1998-10-08 05:31:58 +04:00
if (nsnull != mMargin->mBorderWidth) {
CSS_ENSURE_IMPORTANT(Margin) {
CSS_ENSURE_RECT(mImportant->mMargin->mBorderWidth) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_BORDER_TOP_WIDTH, mMargin->mBorderWidth->mTop);
CSS_CASE_IMPORTANT(PROP_BORDER_RIGHT_WIDTH, mMargin->mBorderWidth->mRight);
CSS_CASE_IMPORTANT(PROP_BORDER_BOTTOM_WIDTH, mMargin->mBorderWidth->mBottom);
CSS_CASE_IMPORTANT(PROP_BORDER_LEFT_WIDTH, mMargin->mBorderWidth->mLeft);
1998-06-26 09:51:55 +04:00
}
}
}
}
}
break;
case PROP_BORDER_TOP_COLOR:
case PROP_BORDER_RIGHT_COLOR:
case PROP_BORDER_BOTTOM_COLOR:
case PROP_BORDER_LEFT_COLOR:
if (nsnull != mMargin) {
1998-10-08 05:31:58 +04:00
if (nsnull != mMargin->mBorderColor) {
CSS_ENSURE_IMPORTANT(Margin) {
CSS_ENSURE_RECT(mImportant->mMargin->mBorderColor) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_BORDER_TOP_COLOR, mMargin->mBorderColor->mTop);
CSS_CASE_IMPORTANT(PROP_BORDER_RIGHT_COLOR, mMargin->mBorderColor->mRight);
CSS_CASE_IMPORTANT(PROP_BORDER_BOTTOM_COLOR, mMargin->mBorderColor->mBottom);
CSS_CASE_IMPORTANT(PROP_BORDER_LEFT_COLOR, mMargin->mBorderColor->mLeft);
1998-06-26 09:51:55 +04:00
}
}
}
}
}
break;
case PROP_BORDER_TOP_STYLE:
case PROP_BORDER_RIGHT_STYLE:
case PROP_BORDER_BOTTOM_STYLE:
case PROP_BORDER_LEFT_STYLE:
if (nsnull != mMargin) {
1998-10-08 05:31:58 +04:00
if (nsnull != mMargin->mBorderStyle) {
CSS_ENSURE_IMPORTANT(Margin) {
CSS_ENSURE_RECT(mImportant->mMargin->mBorderStyle) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_BORDER_TOP_STYLE, mMargin->mBorderStyle->mTop);
CSS_CASE_IMPORTANT(PROP_BORDER_RIGHT_STYLE, mMargin->mBorderStyle->mRight);
CSS_CASE_IMPORTANT(PROP_BORDER_BOTTOM_STYLE, mMargin->mBorderStyle->mBottom);
CSS_CASE_IMPORTANT(PROP_BORDER_LEFT_STYLE, mMargin->mBorderStyle->mLeft);
1998-06-26 09:51:55 +04:00
}
}
}
1998-10-08 05:31:58 +04:00
}
}
break;
case PROP_OUTLINE_WIDTH:
case PROP_OUTLINE_COLOR:
case PROP_OUTLINE_STYLE:
if (nsnull != mMargin) {
CSS_ENSURE_IMPORTANT(Margin) {
switch (aProperty) {
CSS_CASE_IMPORTANT(PROP_OUTLINE_WIDTH, mMargin->mOutlineWidth);
CSS_CASE_IMPORTANT(PROP_OUTLINE_COLOR, mMargin->mOutlineColor);
CSS_CASE_IMPORTANT(PROP_OUTLINE_STYLE, mMargin->mOutlineStyle);
1998-06-26 09:51:55 +04:00
}
}
}
break;
// nsCSSPosition
case PROP_POSITION:
case PROP_WIDTH:
1998-10-08 05:31:58 +04:00
case PROP_MIN_WIDTH:
case PROP_MAX_WIDTH:
1998-06-26 09:51:55 +04:00
case PROP_HEIGHT:
1998-10-08 05:31:58 +04:00
case PROP_MIN_HEIGHT:
case PROP_MAX_HEIGHT:
1998-06-26 09:51:55 +04:00
case PROP_Z_INDEX:
if (nsnull != mPosition) {
1998-10-08 05:31:58 +04:00
CSS_ENSURE_IMPORTANT(Position) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_POSITION, mPosition->mPosition);
CSS_CASE_IMPORTANT(PROP_WIDTH, mPosition->mWidth);
CSS_CASE_IMPORTANT(PROP_MIN_WIDTH, mPosition->mMinWidth);
CSS_CASE_IMPORTANT(PROP_MAX_WIDTH, mPosition->mMaxWidth);
CSS_CASE_IMPORTANT(PROP_HEIGHT, mPosition->mHeight);
CSS_CASE_IMPORTANT(PROP_MIN_HEIGHT, mPosition->mMinHeight);
CSS_CASE_IMPORTANT(PROP_MAX_HEIGHT, mPosition->mMaxHeight);
CSS_CASE_IMPORTANT(PROP_Z_INDEX, mPosition->mZIndex);
1998-06-26 09:51:55 +04:00
}
}
1998-10-08 05:31:58 +04:00
}
break;
case PROP_TOP:
case PROP_RIGHT:
case PROP_BOTTOM:
case PROP_LEFT:
if (nsnull != mPosition) {
if (nsnull != mPosition->mOffset) {
CSS_ENSURE_IMPORTANT(Position) {
CSS_ENSURE_RECT(mImportant->mPosition->mOffset) {
switch (aProperty) {
CSS_CASE_IMPORTANT(PROP_TOP, mPosition->mOffset->mTop);
CSS_CASE_IMPORTANT(PROP_RIGHT, mPosition->mOffset->mRight);
CSS_CASE_IMPORTANT(PROP_BOTTOM, mPosition->mOffset->mBottom);
CSS_CASE_IMPORTANT(PROP_LEFT, mPosition->mOffset->mLeft);
}
}
}
1998-06-26 09:51:55 +04:00
}
}
break;
// nsCSSList
case PROP_LIST_STYLE_TYPE:
case PROP_LIST_STYLE_IMAGE:
case PROP_LIST_STYLE_POSITION:
if (nsnull != mList) {
1998-10-08 05:31:58 +04:00
CSS_ENSURE_IMPORTANT(List) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_LIST_STYLE_TYPE, mList->mType);
CSS_CASE_IMPORTANT(PROP_LIST_STYLE_IMAGE, mList->mImage);
CSS_CASE_IMPORTANT(PROP_LIST_STYLE_POSITION, mList->mPosition);
1998-06-26 09:51:55 +04:00
}
}
}
break;
1998-10-08 05:31:58 +04:00
// nsCSSTable
case PROP_BORDER_COLLAPSE:
1998-10-27 02:22:40 +03:00
case PROP_BORDER_X_SPACING:
case PROP_BORDER_Y_SPACING:
1998-10-08 05:31:58 +04:00
case PROP_CAPTION_SIDE:
case PROP_EMPTY_CELLS:
case PROP_TABLE_LAYOUT:
if (nsnull != mTable) {
CSS_ENSURE_IMPORTANT(Table) {
1998-06-26 09:51:55 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_BORDER_COLLAPSE, mTable->mBorderCollapse);
1998-10-27 02:22:40 +03:00
CSS_CASE_IMPORTANT(PROP_BORDER_X_SPACING, mTable->mBorderSpacingX);
CSS_CASE_IMPORTANT(PROP_BORDER_Y_SPACING, mTable->mBorderSpacingY);
1998-10-08 05:31:58 +04:00
CSS_CASE_IMPORTANT(PROP_CAPTION_SIDE, mTable->mCaptionSide);
CSS_CASE_IMPORTANT(PROP_EMPTY_CELLS, mTable->mEmptyCells);
CSS_CASE_IMPORTANT(PROP_TABLE_LAYOUT, mTable->mLayout);
1998-06-26 09:51:55 +04:00
}
}
1998-10-08 05:31:58 +04:00
}
break;
// nsCSSBreaks
case PROP_ORPHANS:
case PROP_WIDOWS:
case PROP_PAGE:
case PROP_PAGE_BREAK_AFTER:
case PROP_PAGE_BREAK_BEFORE:
case PROP_PAGE_BREAK_INSIDE:
if (nsnull != mBreaks) {
CSS_ENSURE_IMPORTANT(Breaks) {
switch (aProperty) {
CSS_CASE_IMPORTANT(PROP_ORPHANS, mBreaks->mOrphans);
CSS_CASE_IMPORTANT(PROP_WIDOWS, mBreaks->mWidows);
CSS_CASE_IMPORTANT(PROP_PAGE, mBreaks->mPage);
CSS_CASE_IMPORTANT(PROP_PAGE_BREAK_AFTER, mBreaks->mPageBreakAfter);
CSS_CASE_IMPORTANT(PROP_PAGE_BREAK_BEFORE, mBreaks->mPageBreakBefore);
CSS_CASE_IMPORTANT(PROP_PAGE_BREAK_INSIDE, mBreaks->mPageBreakInside);
}
1998-06-26 09:51:55 +04:00
}
}
break;
1998-10-08 05:31:58 +04:00
// nsCSSPage
case PROP_MARKS:
1998-10-27 02:22:40 +03:00
case PROP_SIZE_WIDTH:
case PROP_SIZE_HEIGHT:
1998-10-08 05:31:58 +04:00
if (nsnull != mPage) {
CSS_ENSURE_IMPORTANT(Page) {
switch (aProperty) {
1998-10-27 02:22:40 +03:00
CSS_CASE_IMPORTANT(PROP_MARKS, mPage->mMarks);
CSS_CASE_IMPORTANT(PROP_SIZE_WIDTH, mPage->mSizeWidth);
CSS_CASE_IMPORTANT(PROP_SIZE_HEIGHT, mPage->mSizeHeight);
1998-06-26 09:51:55 +04:00
}
1998-10-08 05:31:58 +04:00
}
}
break;
// nsCSSContent
case PROP_CONTENT:
1998-10-27 02:22:40 +03:00
if (nsnull != mContent) {
if (nsnull != mContent->mContent) {
CSS_ENSURE_IMPORTANT(Content) {
CSS_IF_DELETE(mImportant->mContent->mContent);
mImportant->mContent->mContent = mContent->mContent;
mContent->mContent = nsnull;
}
}
}
break;
1998-10-08 05:31:58 +04:00
case PROP_COUNTER_INCREMENT:
1998-10-27 02:22:40 +03:00
if (nsnull != mContent) {
if (nsnull != mContent->mCounterIncrement) {
CSS_ENSURE_IMPORTANT(Content) {
CSS_IF_DELETE(mImportant->mContent->mCounterIncrement);
mImportant->mContent->mCounterIncrement = mContent->mCounterIncrement;
mContent->mCounterIncrement = nsnull;
}
}
}
break;
1998-10-08 05:31:58 +04:00
case PROP_COUNTER_RESET:
1998-10-27 02:22:40 +03:00
if (nsnull != mContent) {
if (nsnull != mContent->mCounterReset) {
CSS_ENSURE_IMPORTANT(Content) {
CSS_IF_DELETE(mImportant->mContent->mCounterReset);
mImportant->mContent->mCounterReset = mContent->mCounterReset;
mContent->mCounterReset = nsnull;
}
}
}
break;
1998-10-08 05:31:58 +04:00
case PROP_MARKER_OFFSET:
if (nsnull != mContent) {
CSS_ENSURE_IMPORTANT(Content) {
switch (aProperty) {
1998-10-27 02:22:40 +03:00
CSS_CASE_IMPORTANT(PROP_MARKER_OFFSET, mContent->mMarkerOffset);
}
}
}
break;
case PROP_QUOTES:
if (nsnull != mContent) {
if (nsnull != mContent->mQuotes) {
CSS_ENSURE_IMPORTANT(Content) {
CSS_IF_DELETE(mImportant->mContent->mQuotes);
mImportant->mContent->mQuotes = mContent->mQuotes;
mContent->mQuotes = nsnull;
1998-06-26 09:51:55 +04:00
}
1998-10-08 05:31:58 +04:00
}
}
break;
// nsCSSAural
case PROP_AZIMUTH:
case PROP_ELEVATION:
case PROP_CUE_AFTER:
case PROP_CUE_BEFORE:
case PROP_PAUSE_AFTER:
case PROP_PAUSE_BEFORE:
case PROP_PITCH:
case PROP_PITCH_RANGE:
case PROP_RICHNESS:
case PROP_SPEAK:
case PROP_SPEAK_HEADER:
case PROP_SPEAK_NUMERAL:
case PROP_SPEAK_PUNCTUATION:
case PROP_SPEECH_RATE:
case PROP_STRESS:
case PROP_VOICE_FAMILY:
case PROP_VOLUME:
if (nsnull != mAural) {
CSS_ENSURE_IMPORTANT(Aural) {
switch (aProperty) {
CSS_CASE_IMPORTANT(PROP_AZIMUTH, mAural->mAzimuth);
CSS_CASE_IMPORTANT(PROP_ELEVATION, mAural->mElevation);
CSS_CASE_IMPORTANT(PROP_CUE_AFTER, mAural->mCueAfter);
CSS_CASE_IMPORTANT(PROP_CUE_BEFORE, mAural->mCueBefore);
CSS_CASE_IMPORTANT(PROP_PAUSE_AFTER, mAural->mPauseAfter);
CSS_CASE_IMPORTANT(PROP_PAUSE_BEFORE, mAural->mPauseBefore);
CSS_CASE_IMPORTANT(PROP_PITCH, mAural->mPitch);
CSS_CASE_IMPORTANT(PROP_PITCH_RANGE, mAural->mPitchRange);
CSS_CASE_IMPORTANT(PROP_RICHNESS, mAural->mRichness);
CSS_CASE_IMPORTANT(PROP_SPEAK, mAural->mSpeak);
CSS_CASE_IMPORTANT(PROP_SPEAK_HEADER, mAural->mSpeakHeader);
CSS_CASE_IMPORTANT(PROP_SPEAK_NUMERAL, mAural->mSpeakNumeral);
CSS_CASE_IMPORTANT(PROP_SPEAK_PUNCTUATION, mAural->mSpeakPunctuation);
CSS_CASE_IMPORTANT(PROP_SPEECH_RATE, mAural->mSpeechRate);
CSS_CASE_IMPORTANT(PROP_STRESS, mAural->mStress);
CSS_CASE_IMPORTANT(PROP_VOICE_FAMILY, mAural->mVoiceFamily);
CSS_CASE_IMPORTANT(PROP_VOLUME, mAural->mVolume);
1998-06-26 09:51:55 +04:00
}
}
}
break;
1998-10-27 02:22:40 +03:00
case PROP_PLAY_DURING:
if (nsnull != mAural) {
CSS_ENSURE_IMPORTANT(Aural) {
mImportant->mAural->mPlayDuring = mAural->mPlayDuring;
mAural->mPlayDuring.Reset();
mImportant->mAural->mPlayDuringFlags = mAural->mPlayDuringFlags;
mAural->mPlayDuringFlags.Reset();
}
}
break;
1998-10-08 05:31:58 +04:00
// Shorthands
1998-06-26 09:51:55 +04:00
case PROP_BACKGROUND:
SetValueImportant(PROP_BACKGROUND_COLOR);
SetValueImportant(PROP_BACKGROUND_IMAGE);
SetValueImportant(PROP_BACKGROUND_REPEAT);
SetValueImportant(PROP_BACKGROUND_ATTACHMENT);
SetValueImportant(PROP_BACKGROUND_X_POSITION);
SetValueImportant(PROP_BACKGROUND_Y_POSITION);
SetValueImportant(PROP_BACKGROUND_FILTER);
break;
case PROP_BORDER:
SetValueImportant(PROP_BORDER_TOP_WIDTH);
SetValueImportant(PROP_BORDER_RIGHT_WIDTH);
SetValueImportant(PROP_BORDER_BOTTOM_WIDTH);
SetValueImportant(PROP_BORDER_LEFT_WIDTH);
SetValueImportant(PROP_BORDER_TOP_STYLE);
SetValueImportant(PROP_BORDER_RIGHT_STYLE);
SetValueImportant(PROP_BORDER_BOTTOM_STYLE);
SetValueImportant(PROP_BORDER_LEFT_STYLE);
SetValueImportant(PROP_BORDER_TOP_COLOR);
SetValueImportant(PROP_BORDER_RIGHT_COLOR);
SetValueImportant(PROP_BORDER_BOTTOM_COLOR);
SetValueImportant(PROP_BORDER_LEFT_COLOR);
break;
1998-10-27 02:22:40 +03:00
case PROP_BORDER_SPACING:
SetValueImportant(PROP_BORDER_X_SPACING);
SetValueImportant(PROP_BORDER_Y_SPACING);
1998-06-26 09:51:55 +04:00
case PROP_CLIP:
SetValueImportant(PROP_CLIP_TOP);
SetValueImportant(PROP_CLIP_RIGHT);
SetValueImportant(PROP_CLIP_BOTTOM);
SetValueImportant(PROP_CLIP_LEFT);
break;
1998-10-08 05:31:58 +04:00
case PROP_CUE:
SetValueImportant(PROP_CUE_AFTER);
SetValueImportant(PROP_CUE_BEFORE);
break;
1998-06-26 09:51:55 +04:00
case PROP_FONT:
SetValueImportant(PROP_FONT_FAMILY);
SetValueImportant(PROP_FONT_STYLE);
SetValueImportant(PROP_FONT_VARIANT);
SetValueImportant(PROP_FONT_WEIGHT);
SetValueImportant(PROP_FONT_SIZE);
SetValueImportant(PROP_LINE_HEIGHT);
break;
case PROP_LIST_STYLE:
SetValueImportant(PROP_LIST_STYLE_TYPE);
SetValueImportant(PROP_LIST_STYLE_IMAGE);
SetValueImportant(PROP_LIST_STYLE_POSITION);
break;
case PROP_MARGIN:
SetValueImportant(PROP_MARGIN_TOP);
SetValueImportant(PROP_MARGIN_RIGHT);
SetValueImportant(PROP_MARGIN_BOTTOM);
SetValueImportant(PROP_MARGIN_LEFT);
break;
1998-10-08 05:31:58 +04:00
case PROP_OUTLINE:
SetValueImportant(PROP_OUTLINE_COLOR);
SetValueImportant(PROP_OUTLINE_STYLE);
SetValueImportant(PROP_OUTLINE_WIDTH);
break;
1998-06-26 09:51:55 +04:00
case PROP_PADDING:
SetValueImportant(PROP_PADDING_TOP);
SetValueImportant(PROP_PADDING_RIGHT);
SetValueImportant(PROP_PADDING_BOTTOM);
SetValueImportant(PROP_PADDING_LEFT);
break;
1998-10-08 05:31:58 +04:00
case PROP_PAUSE:
SetValueImportant(PROP_PAUSE_AFTER);
SetValueImportant(PROP_PAUSE_BEFORE);
break;
1998-10-27 02:22:40 +03:00
case PROP_SIZE:
SetValueImportant(PROP_SIZE_WIDTH);
SetValueImportant(PROP_SIZE_HEIGHT);
break;
1998-06-26 09:51:55 +04:00
case PROP_BACKGROUND_POSITION:
SetValueImportant(PROP_BACKGROUND_X_POSITION);
SetValueImportant(PROP_BACKGROUND_Y_POSITION);
break;
case PROP_BORDER_TOP:
SetValueImportant(PROP_BORDER_TOP_WIDTH);
SetValueImportant(PROP_BORDER_TOP_STYLE);
SetValueImportant(PROP_BORDER_TOP_COLOR);
break;
case PROP_BORDER_RIGHT:
SetValueImportant(PROP_BORDER_RIGHT_WIDTH);
SetValueImportant(PROP_BORDER_RIGHT_STYLE);
SetValueImportant(PROP_BORDER_RIGHT_COLOR);
break;
case PROP_BORDER_BOTTOM:
SetValueImportant(PROP_BORDER_BOTTOM_WIDTH);
SetValueImportant(PROP_BORDER_BOTTOM_STYLE);
SetValueImportant(PROP_BORDER_BOTTOM_COLOR);
break;
case PROP_BORDER_LEFT:
SetValueImportant(PROP_BORDER_LEFT_WIDTH);
SetValueImportant(PROP_BORDER_LEFT_STYLE);
SetValueImportant(PROP_BORDER_LEFT_COLOR);
break;
case PROP_BORDER_COLOR:
SetValueImportant(PROP_BORDER_TOP_COLOR);
SetValueImportant(PROP_BORDER_RIGHT_COLOR);
SetValueImportant(PROP_BORDER_BOTTOM_COLOR);
SetValueImportant(PROP_BORDER_LEFT_COLOR);
break;
case PROP_BORDER_STYLE:
SetValueImportant(PROP_BORDER_TOP_STYLE);
SetValueImportant(PROP_BORDER_RIGHT_STYLE);
SetValueImportant(PROP_BORDER_BOTTOM_STYLE);
SetValueImportant(PROP_BORDER_LEFT_STYLE);
break;
case PROP_BORDER_WIDTH:
SetValueImportant(PROP_BORDER_TOP_WIDTH);
SetValueImportant(PROP_BORDER_RIGHT_WIDTH);
SetValueImportant(PROP_BORDER_BOTTOM_WIDTH);
SetValueImportant(PROP_BORDER_LEFT_WIDTH);
break;
default:
result = NS_ERROR_ILLEGAL_VALUE;
break;
}
}
return result;
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::AppendComment(const nsString& aComment)
1998-07-17 09:50:35 +04:00
{
nsresult result = NS_ERROR_OUT_OF_MEMORY;
if (nsnull == mOrder) {
mOrder = new nsVoidArray();
}
if (nsnull == mComments) {
mComments = new nsVoidArray();
}
if ((nsnull != mComments) && (nsnull != mOrder)) {
mComments->AppendElement(new nsString(aComment));
mOrder->AppendElement((void*)-mComments->Count());
result = NS_OK;
}
return result;
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetValue(PRInt32 aProperty, nsCSSValue& aValue)
1998-04-14 00:24:54 +04:00
{
nsresult result = NS_OK;
switch (aProperty) {
// nsCSSFont
case PROP_FONT_FAMILY:
case PROP_FONT_STYLE:
case PROP_FONT_VARIANT:
case PROP_FONT_WEIGHT:
case PROP_FONT_SIZE:
1998-10-08 05:31:58 +04:00
case PROP_FONT_SIZE_ADJUST:
case PROP_FONT_STRETCH:
1998-04-14 00:24:54 +04:00
if (nsnull != mFont) {
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_FONT_FAMILY: aValue = mFont->mFamily; break;
case PROP_FONT_STYLE: aValue = mFont->mStyle; break;
case PROP_FONT_VARIANT: aValue = mFont->mVariant; break;
case PROP_FONT_WEIGHT: aValue = mFont->mWeight; break;
case PROP_FONT_SIZE: aValue = mFont->mSize; break;
case PROP_FONT_SIZE_ADJUST: aValue = mFont->mSizeAdjust; break;
case PROP_FONT_STRETCH: aValue = mFont->mStretch; break;
1998-04-14 00:24:54 +04:00
}
}
else {
aValue.Reset();
}
break;
// nsCSSColor
case PROP_COLOR:
case PROP_BACKGROUND_COLOR:
case PROP_BACKGROUND_IMAGE:
case PROP_BACKGROUND_REPEAT:
case PROP_BACKGROUND_ATTACHMENT:
case PROP_BACKGROUND_X_POSITION:
case PROP_BACKGROUND_Y_POSITION:
case PROP_BACKGROUND_FILTER:
1998-04-25 22:43:42 +04:00
case PROP_CURSOR:
case PROP_OPACITY:
1998-04-14 00:24:54 +04:00
if (nsnull != mColor) {
switch (aProperty) {
case PROP_COLOR: aValue = mColor->mColor; break;
case PROP_BACKGROUND_COLOR: aValue = mColor->mBackColor; break;
case PROP_BACKGROUND_IMAGE: aValue = mColor->mBackImage; break;
case PROP_BACKGROUND_REPEAT: aValue = mColor->mBackRepeat; break;
case PROP_BACKGROUND_ATTACHMENT: aValue = mColor->mBackAttachment; break;
case PROP_BACKGROUND_X_POSITION: aValue = mColor->mBackPositionX; break;
case PROP_BACKGROUND_Y_POSITION: aValue = mColor->mBackPositionY; break;
case PROP_BACKGROUND_FILTER: aValue = mColor->mBackFilter; break;
1998-10-27 02:22:40 +03:00
case PROP_CURSOR:
if (nsnull != mColor->mCursor) {
aValue = mColor->mCursor->mValue;
}
break;
case PROP_OPACITY: aValue = mColor->mOpacity; break;
1998-04-14 00:24:54 +04:00
}
}
else {
aValue.Reset();
}
break;
// nsCSSText
case PROP_WORD_SPACING:
case PROP_LETTER_SPACING:
case PROP_TEXT_DECORATION:
case PROP_VERTICAL_ALIGN:
case PROP_TEXT_TRANSFORM:
case PROP_TEXT_ALIGN:
case PROP_TEXT_INDENT:
1998-10-08 05:31:58 +04:00
case PROP_UNICODE_BIDI:
1998-04-14 00:24:54 +04:00
case PROP_LINE_HEIGHT:
case PROP_WHITE_SPACE:
if (nsnull != mText) {
switch (aProperty) {
case PROP_WORD_SPACING: aValue = mText->mWordSpacing; break;
case PROP_LETTER_SPACING: aValue = mText->mLetterSpacing; break;
case PROP_TEXT_DECORATION: aValue = mText->mDecoration; break;
1998-04-28 01:24:06 +04:00
case PROP_VERTICAL_ALIGN: aValue = mText->mVerticalAlign; break;
case PROP_TEXT_TRANSFORM: aValue = mText->mTextTransform; break;
1998-04-25 22:43:42 +04:00
case PROP_TEXT_ALIGN: aValue = mText->mTextAlign; break;
1998-04-28 01:24:06 +04:00
case PROP_TEXT_INDENT: aValue = mText->mTextIndent; break;
1998-10-08 05:31:58 +04:00
case PROP_UNICODE_BIDI: aValue = mText->mUnicodeBidi; break;
1998-04-14 00:24:54 +04:00
case PROP_LINE_HEIGHT: aValue = mText->mLineHeight; break;
case PROP_WHITE_SPACE: aValue = mText->mWhiteSpace; break;
}
}
else {
aValue.Reset();
}
break;
1998-10-08 05:31:58 +04:00
case PROP_TEXT_SHADOW_COLOR:
case PROP_TEXT_SHADOW_X:
case PROP_TEXT_SHADOW_Y:
case PROP_TEXT_SHADOW_RADIUS:
if ((nsnull != mText) && (nsnull != mText->mTextShadow)) {
switch (aProperty) {
case PROP_TEXT_SHADOW_COLOR: aValue = mText->mTextShadow->mColor; break;
case PROP_TEXT_SHADOW_X: aValue = mText->mTextShadow->mXOffset; break;
case PROP_TEXT_SHADOW_Y: aValue = mText->mTextShadow->mYOffset; break;
case PROP_TEXT_SHADOW_RADIUS: aValue = mText->mTextShadow->mRadius; break;
}
}
break;
// nsCSSDisplay
case PROP_FLOAT:
case PROP_CLEAR:
case PROP_DISPLAY:
case PROP_DIRECTION:
case PROP_VISIBILITY:
case PROP_OVERFLOW:
case PROP_FILTER:
if (nsnull != mDisplay) {
switch (aProperty) {
case PROP_FLOAT: aValue = mDisplay->mFloat; break;
case PROP_CLEAR: aValue = mDisplay->mClear; break;
case PROP_DISPLAY: aValue = mDisplay->mDisplay; break;
case PROP_DIRECTION: aValue = mDisplay->mDirection; break;
case PROP_VISIBILITY: aValue = mDisplay->mVisibility; break;
case PROP_OVERFLOW: aValue = mDisplay->mOverflow; break;
case PROP_FILTER: aValue = mDisplay->mFilter; break;
}
}
else {
aValue.Reset();
}
break;
case PROP_CLIP_TOP:
case PROP_CLIP_RIGHT:
case PROP_CLIP_BOTTOM:
case PROP_CLIP_LEFT:
if ((nsnull != mDisplay) && (nsnull != mDisplay->mClip)) {
switch(aProperty) {
case PROP_CLIP_TOP: aValue = mDisplay->mClip->mTop; break;
case PROP_CLIP_RIGHT: aValue = mDisplay->mClip->mRight; break;
case PROP_CLIP_BOTTOM: aValue = mDisplay->mClip->mBottom; break;
case PROP_CLIP_LEFT: aValue = mDisplay->mClip->mLeft; break;
}
}
else {
aValue.Reset();
}
break;
1998-04-14 00:24:54 +04:00
// nsCSSMargin
case PROP_MARGIN_TOP:
case PROP_MARGIN_RIGHT:
case PROP_MARGIN_BOTTOM:
case PROP_MARGIN_LEFT:
if ((nsnull != mMargin) && (nsnull != mMargin->mMargin)) {
switch (aProperty) {
case PROP_MARGIN_TOP: aValue = mMargin->mMargin->mTop; break;
case PROP_MARGIN_RIGHT: aValue = mMargin->mMargin->mRight; break;
case PROP_MARGIN_BOTTOM: aValue = mMargin->mMargin->mBottom; break;
case PROP_MARGIN_LEFT: aValue = mMargin->mMargin->mLeft; break;
}
}
else {
aValue.Reset();
}
break;
case PROP_PADDING_TOP:
case PROP_PADDING_RIGHT:
case PROP_PADDING_BOTTOM:
case PROP_PADDING_LEFT:
if ((nsnull != mMargin) && (nsnull != mMargin->mPadding)) {
switch (aProperty) {
case PROP_PADDING_TOP: aValue = mMargin->mPadding->mTop; break;
case PROP_PADDING_RIGHT: aValue = mMargin->mPadding->mRight; break;
case PROP_PADDING_BOTTOM: aValue = mMargin->mPadding->mBottom; break;
case PROP_PADDING_LEFT: aValue = mMargin->mPadding->mLeft; break;
}
}
else {
aValue.Reset();
}
break;
case PROP_BORDER_TOP_WIDTH:
case PROP_BORDER_RIGHT_WIDTH:
case PROP_BORDER_BOTTOM_WIDTH:
case PROP_BORDER_LEFT_WIDTH:
1998-10-08 05:31:58 +04:00
if ((nsnull != mMargin) && (nsnull != mMargin->mBorderWidth)) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_BORDER_TOP_WIDTH: aValue = mMargin->mBorderWidth->mTop; break;
case PROP_BORDER_RIGHT_WIDTH: aValue = mMargin->mBorderWidth->mRight; break;
case PROP_BORDER_BOTTOM_WIDTH: aValue = mMargin->mBorderWidth->mBottom; break;
case PROP_BORDER_LEFT_WIDTH: aValue = mMargin->mBorderWidth->mLeft; break;
1998-04-14 00:24:54 +04:00
}
}
else {
aValue.Reset();
}
break;
case PROP_BORDER_TOP_COLOR:
case PROP_BORDER_RIGHT_COLOR:
case PROP_BORDER_BOTTOM_COLOR:
case PROP_BORDER_LEFT_COLOR:
1998-10-08 05:31:58 +04:00
if ((nsnull != mMargin) && (nsnull != mMargin->mBorderColor)) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_BORDER_TOP_COLOR: aValue = mMargin->mBorderColor->mTop; break;
case PROP_BORDER_RIGHT_COLOR: aValue = mMargin->mBorderColor->mRight; break;
case PROP_BORDER_BOTTOM_COLOR: aValue = mMargin->mBorderColor->mBottom; break;
case PROP_BORDER_LEFT_COLOR: aValue = mMargin->mBorderColor->mLeft; break;
1998-04-14 00:24:54 +04:00
}
}
else {
aValue.Reset();
}
break;
case PROP_BORDER_TOP_STYLE:
case PROP_BORDER_RIGHT_STYLE:
case PROP_BORDER_BOTTOM_STYLE:
case PROP_BORDER_LEFT_STYLE:
1998-10-08 05:31:58 +04:00
if ((nsnull != mMargin) && (nsnull != mMargin->mBorderStyle)) {
switch (aProperty) {
case PROP_BORDER_TOP_STYLE: aValue = mMargin->mBorderStyle->mTop; break;
case PROP_BORDER_RIGHT_STYLE: aValue = mMargin->mBorderStyle->mRight; break;
case PROP_BORDER_BOTTOM_STYLE: aValue = mMargin->mBorderStyle->mBottom; break;
case PROP_BORDER_LEFT_STYLE: aValue = mMargin->mBorderStyle->mLeft; break;
}
}
else {
aValue.Reset();
}
break;
case PROP_OUTLINE_WIDTH:
case PROP_OUTLINE_COLOR:
case PROP_OUTLINE_STYLE:
if (nsnull != mMargin) {
1998-04-14 00:24:54 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_OUTLINE_WIDTH: aValue = mMargin->mOutlineWidth; break;
case PROP_OUTLINE_COLOR: aValue = mMargin->mOutlineColor; break;
case PROP_OUTLINE_STYLE: aValue = mMargin->mOutlineStyle; break;
1998-04-14 00:24:54 +04:00
}
}
else {
aValue.Reset();
}
break;
// nsCSSPosition
case PROP_POSITION:
case PROP_WIDTH:
1998-10-08 05:31:58 +04:00
case PROP_MIN_WIDTH:
case PROP_MAX_WIDTH:
1998-04-14 00:24:54 +04:00
case PROP_HEIGHT:
1998-10-08 05:31:58 +04:00
case PROP_MIN_HEIGHT:
case PROP_MAX_HEIGHT:
1998-04-14 00:24:54 +04:00
case PROP_Z_INDEX:
if (nsnull != mPosition) {
switch (aProperty) {
case PROP_POSITION: aValue = mPosition->mPosition; break;
case PROP_WIDTH: aValue = mPosition->mWidth; break;
1998-10-08 05:31:58 +04:00
case PROP_MIN_WIDTH: aValue = mPosition->mMinWidth; break;
case PROP_MAX_WIDTH: aValue = mPosition->mMaxWidth; break;
1998-04-14 00:24:54 +04:00
case PROP_HEIGHT: aValue = mPosition->mHeight; break;
1998-10-08 05:31:58 +04:00
case PROP_MIN_HEIGHT: aValue = mPosition->mMinHeight; break;
case PROP_MAX_HEIGHT: aValue = mPosition->mMaxHeight; break;
1998-04-14 00:24:54 +04:00
case PROP_Z_INDEX: aValue = mPosition->mZIndex; break;
}
}
else {
aValue.Reset();
}
break;
1998-10-08 05:31:58 +04:00
case PROP_TOP:
case PROP_RIGHT:
case PROP_BOTTOM:
case PROP_LEFT:
if ((nsnull != mPosition) && (nsnull != mPosition->mOffset)) {
switch (aProperty) {
case PROP_TOP: aValue = mPosition->mOffset->mTop; break;
case PROP_RIGHT: aValue = mPosition->mOffset->mRight; break;
case PROP_BOTTOM: aValue = mPosition->mOffset->mBottom; break;
case PROP_LEFT: aValue = mPosition->mOffset->mLeft; break;
}
}
else {
aValue.Reset();
}
break;
1998-04-14 00:24:54 +04:00
// nsCSSList
case PROP_LIST_STYLE_TYPE:
case PROP_LIST_STYLE_IMAGE:
case PROP_LIST_STYLE_POSITION:
if (nsnull != mList) {
switch (aProperty) {
case PROP_LIST_STYLE_TYPE: aValue = mList->mType; break;
case PROP_LIST_STYLE_IMAGE: aValue = mList->mImage; break;
case PROP_LIST_STYLE_POSITION: aValue = mList->mPosition; break;
}
}
else {
aValue.Reset();
}
break;
1998-10-08 05:31:58 +04:00
// nsCSSTable
case PROP_BORDER_COLLAPSE:
1998-10-27 02:22:40 +03:00
case PROP_BORDER_X_SPACING:
case PROP_BORDER_Y_SPACING:
1998-10-08 05:31:58 +04:00
case PROP_CAPTION_SIDE:
case PROP_EMPTY_CELLS:
case PROP_TABLE_LAYOUT:
if (nsnull != mTable) {
1998-04-25 22:43:42 +04:00
switch (aProperty) {
1998-10-08 05:31:58 +04:00
case PROP_BORDER_COLLAPSE: aValue = mTable->mBorderCollapse; break;
1998-10-27 02:22:40 +03:00
case PROP_BORDER_X_SPACING: aValue = mTable->mBorderSpacingX; break;
case PROP_BORDER_Y_SPACING: aValue = mTable->mBorderSpacingY; break;
1998-10-08 05:31:58 +04:00
case PROP_CAPTION_SIDE: aValue = mTable->mCaptionSide; break;
case PROP_EMPTY_CELLS: aValue = mTable->mEmptyCells; break;
case PROP_TABLE_LAYOUT: aValue = mTable->mLayout; break;
1998-05-27 03:16:55 +04:00
}
}
else {
aValue.Reset();
}
break;
1998-10-08 05:31:58 +04:00
// nsCSSBreaks
case PROP_ORPHANS:
case PROP_WIDOWS:
case PROP_PAGE:
case PROP_PAGE_BREAK_AFTER:
case PROP_PAGE_BREAK_BEFORE:
case PROP_PAGE_BREAK_INSIDE:
if (nsnull != mBreaks) {
switch (aProperty) {
case PROP_ORPHANS: aValue = mBreaks->mOrphans; break;
case PROP_WIDOWS: aValue = mBreaks->mWidows; break;
case PROP_PAGE: aValue = mBreaks->mPage; break;
case PROP_PAGE_BREAK_AFTER: aValue = mBreaks->mPageBreakAfter; break;
case PROP_PAGE_BREAK_BEFORE: aValue = mBreaks->mPageBreakBefore; break;
case PROP_PAGE_BREAK_INSIDE: aValue = mBreaks->mPageBreakInside; break;
}
}
else {
aValue.Reset();
}
break;
// nsCSSPage
case PROP_MARKS:
1998-10-27 02:22:40 +03:00
case PROP_SIZE_WIDTH:
case PROP_SIZE_HEIGHT:
1998-10-08 05:31:58 +04:00
if (nsnull != mPage) {
switch (aProperty) {
1998-10-27 02:22:40 +03:00
case PROP_MARKS: aValue = mPage->mMarks; break;
case PROP_SIZE_WIDTH: aValue = mPage->mSizeWidth; break;
case PROP_SIZE_HEIGHT: aValue = mPage->mSizeHeight; break;
1998-10-08 05:31:58 +04:00
}
}
else {
aValue.Reset();
}
break;
// nsCSSContent
case PROP_CONTENT:
case PROP_COUNTER_INCREMENT:
case PROP_COUNTER_RESET:
case PROP_MARKER_OFFSET:
1998-10-27 02:22:40 +03:00
case PROP_QUOTES_OPEN:
case PROP_QUOTES_CLOSE:
1998-10-08 05:31:58 +04:00
if (nsnull != mContent) {
switch (aProperty) {
1998-10-27 02:22:40 +03:00
case PROP_CONTENT:
if (nsnull != mContent->mContent) {
aValue = mContent->mContent->mValue;
}
break;
case PROP_COUNTER_INCREMENT:
if (nsnull != mContent->mCounterIncrement) {
aValue = mContent->mCounterIncrement->mCounter;
}
break;
case PROP_COUNTER_RESET:
if (nsnull != mContent->mCounterReset) {
aValue = mContent->mCounterReset->mCounter;
}
break;
1998-10-08 05:31:58 +04:00
case PROP_MARKER_OFFSET: aValue = mContent->mMarkerOffset; break;
1998-10-27 02:22:40 +03:00
case PROP_QUOTES_OPEN:
if (nsnull != mContent->mQuotes) {
aValue = mContent->mQuotes->mOpen;
}
break;
case PROP_QUOTES_CLOSE:
if (nsnull != mContent->mQuotes) {
aValue = mContent->mQuotes->mClose;
}
break;
1998-10-08 05:31:58 +04:00
}
}
else {
aValue.Reset();
}
break;
// nsCSSAural
case PROP_AZIMUTH:
case PROP_ELEVATION:
case PROP_CUE_AFTER:
case PROP_CUE_BEFORE:
case PROP_PAUSE_AFTER:
case PROP_PAUSE_BEFORE:
case PROP_PITCH:
case PROP_PITCH_RANGE:
case PROP_PLAY_DURING:
1998-10-27 02:22:40 +03:00
case PROP_PLAY_DURING_FLAGS:
1998-10-08 05:31:58 +04:00
case PROP_RICHNESS:
case PROP_SPEAK:
case PROP_SPEAK_HEADER:
case PROP_SPEAK_NUMERAL:
case PROP_SPEAK_PUNCTUATION:
case PROP_SPEECH_RATE:
case PROP_STRESS:
case PROP_VOICE_FAMILY:
case PROP_VOLUME:
if (nsnull != mAural) {
switch (aProperty) {
case PROP_AZIMUTH: aValue = mAural->mAzimuth; break;
case PROP_ELEVATION: aValue = mAural->mElevation; break;
case PROP_CUE_AFTER: aValue = mAural->mCueAfter; break;
case PROP_CUE_BEFORE: aValue = mAural->mCueBefore; break;
case PROP_PAUSE_AFTER: aValue = mAural->mPauseAfter; break;
case PROP_PAUSE_BEFORE: aValue = mAural->mPauseBefore; break;
case PROP_PITCH: aValue = mAural->mPitch; break;
case PROP_PITCH_RANGE: aValue = mAural->mPitchRange; break;
case PROP_PLAY_DURING: aValue = mAural->mPlayDuring; break;
1998-10-27 02:22:40 +03:00
case PROP_PLAY_DURING_FLAGS: aValue = mAural->mPlayDuringFlags; break;
1998-10-08 05:31:58 +04:00
case PROP_RICHNESS: aValue = mAural->mRichness; break;
case PROP_SPEAK: aValue = mAural->mSpeak; break;
case PROP_SPEAK_HEADER: aValue = mAural->mSpeakHeader; break;
case PROP_SPEAK_NUMERAL: aValue = mAural->mSpeakNumeral; break;
case PROP_SPEAK_PUNCTUATION: aValue = mAural->mSpeakPunctuation; break;
case PROP_SPEECH_RATE: aValue = mAural->mSpeechRate; break;
case PROP_STRESS: aValue = mAural->mStress; break;
case PROP_VOICE_FAMILY: aValue = mAural->mVoiceFamily; break;
case PROP_VOLUME: aValue = mAural->mVolume; break;
1998-04-25 22:43:42 +04:00
}
}
else {
aValue.Reset();
}
break;
1998-10-08 05:31:58 +04:00
// Shorthands
1998-04-14 00:24:54 +04:00
case PROP_BACKGROUND:
case PROP_BORDER:
1998-10-27 02:22:40 +03:00
case PROP_BORDER_SPACING:
1998-04-14 00:24:54 +04:00
case PROP_CLIP:
1998-10-08 05:31:58 +04:00
case PROP_CUE:
1998-04-14 00:24:54 +04:00
case PROP_FONT:
case PROP_LIST_STYLE:
case PROP_MARGIN:
1998-10-08 05:31:58 +04:00
case PROP_OUTLINE:
1998-04-14 00:24:54 +04:00
case PROP_PADDING:
1998-10-08 05:31:58 +04:00
case PROP_PAUSE:
1998-10-27 02:22:40 +03:00
case PROP_QUOTES:
case PROP_SIZE:
1998-10-08 05:31:58 +04:00
case PROP_TEXT_SHADOW:
1998-04-14 00:24:54 +04:00
case PROP_BACKGROUND_POSITION:
case PROP_BORDER_TOP:
case PROP_BORDER_RIGHT:
case PROP_BORDER_BOTTOM:
case PROP_BORDER_LEFT:
case PROP_BORDER_COLOR:
case PROP_BORDER_STYLE:
case PROP_BORDER_WIDTH:
NS_ERROR("can't query for shorthand properties");
default:
result = NS_ERROR_ILLEGAL_VALUE;
break;
}
return result;
}
1998-09-30 05:08:59 +04:00
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetValue(const nsString& aProperty, nsString& aValue)
1998-09-30 05:08:59 +04:00
{
char prop[50];
aProperty.ToCString(prop, sizeof(prop));
PRInt32 propID = nsCSSProps::LookupName(prop);
return GetValue(propID, aValue);
}
1998-10-08 05:31:58 +04:00
PRBool CSSDeclarationImpl::AppendValueToString(PRInt32 aProperty, nsString& aResult)
1998-09-30 05:08:59 +04:00
{
nsCSSValue value;
GetValue(aProperty, value);
1998-10-08 05:31:58 +04:00
return AppendValueToString(aProperty, value, aResult);
}
1998-09-30 05:08:59 +04:00
1998-10-08 05:31:58 +04:00
PRBool CSSDeclarationImpl::AppendValueToString(PRInt32 aProperty, const nsCSSValue& aValue, nsString& aResult)
{
nsCSSUnit unit = aValue.GetUnit();
1998-09-30 05:08:59 +04:00
if (eCSSUnit_Null == unit) {
1998-10-08 05:31:58 +04:00
return PR_FALSE;
1998-09-30 05:08:59 +04:00
}
1998-10-27 02:22:40 +03:00
if ((eCSSUnit_String <= unit) && (unit <= eCSSUnit_Counters)) {
switch (unit) {
case eCSSUnit_URL: aResult.Append("url("); break;
case eCSSUnit_Attr: aResult.Append("attr("); break;
case eCSSUnit_Counter: aResult.Append("counter("); break;
case eCSSUnit_Counters: aResult.Append("counters("); break;
default: break;
}
1998-09-30 05:08:59 +04:00
nsAutoString buffer;
1998-10-08 05:31:58 +04:00
aValue.GetStringValue(buffer);
aResult.Append(buffer);
1998-09-30 05:08:59 +04:00
}
else if (eCSSUnit_Integer == unit) {
1998-10-08 05:31:58 +04:00
aResult.Append(aValue.GetIntValue(), 10);
1998-09-30 05:08:59 +04:00
}
else if (eCSSUnit_Enumerated == unit) {
if (PROP_TEXT_DECORATION == aProperty) {
1998-10-08 05:31:58 +04:00
PRInt32 intValue = aValue.GetIntValue();
1998-09-30 05:08:59 +04:00
if (NS_STYLE_TEXT_DECORATION_NONE != intValue) {
PRInt32 mask;
for (mask = NS_STYLE_TEXT_DECORATION_UNDERLINE;
mask <= NS_STYLE_TEXT_DECORATION_BLINK;
mask <<= 1) {
if ((mask & intValue) == mask) {
1998-10-08 05:31:58 +04:00
aResult.Append(nsCSSProps::LookupProperty(aProperty, mask));
1998-09-30 05:08:59 +04:00
intValue &= ~mask;
if (0 != intValue) { // more left
1998-10-08 05:31:58 +04:00
aResult.Append(' ');
1998-09-30 05:08:59 +04:00
}
}
}
}
else {
1998-10-08 05:31:58 +04:00
aResult.Append(nsCSSProps::LookupProperty(aProperty, NS_STYLE_TEXT_DECORATION_NONE));
1998-09-30 05:08:59 +04:00
}
}
1998-10-27 02:22:40 +03:00
else if (PROP_AZIMUTH == aProperty) {
PRInt32 intValue = aValue.GetIntValue();
aResult.Append(nsCSSProps::LookupProperty(aProperty, (intValue & ~NS_STYLE_AZIMUTH_BEHIND)));
if ((NS_STYLE_AZIMUTH_BEHIND & intValue) != 0) {
aResult.Append(' ');
aResult.Append(nsCSSProps::LookupProperty(aProperty, NS_STYLE_AZIMUTH_BEHIND));
}
}
else if (PROP_PLAY_DURING_FLAGS == aProperty) {
PRInt32 intValue = aValue.GetIntValue();
if ((NS_STYLE_PLAY_DURING_MIX & intValue) != 0) {
aResult.Append(nsCSSProps::LookupProperty(aProperty, NS_STYLE_PLAY_DURING_MIX));
}
if ((NS_STYLE_PLAY_DURING_REPEAT & intValue) != 0) {
if (NS_STYLE_PLAY_DURING_REPEAT != intValue) {
aResult.Append(' ');
}
aResult.Append(nsCSSProps::LookupProperty(aProperty, NS_STYLE_PLAY_DURING_REPEAT));
}
}
1999-02-10 11:37:28 +03:00
else if (PROP_MARKS == aProperty) {
PRInt32 intValue = aValue.GetIntValue();
if ((NS_STYLE_PAGE_MARKS_CROP & intValue) != 0) {
aResult.Append(nsCSSProps::LookupProperty(aProperty, NS_STYLE_PAGE_MARKS_CROP));
}
if ((NS_STYLE_PAGE_MARKS_REGISTER & intValue) != 0) {
if ((NS_STYLE_PAGE_MARKS_CROP & intValue) != 0) {
aResult.Append(' ');
}
aResult.Append(nsCSSProps::LookupProperty(aProperty, NS_STYLE_PAGE_MARKS_REGISTER));
}
}
1998-09-30 05:08:59 +04:00
else {
1998-10-08 05:31:58 +04:00
const char* name = nsCSSProps::LookupProperty(aProperty, aValue.GetIntValue());
1998-09-30 05:08:59 +04:00
if (name != nsnull) {
1998-10-08 05:31:58 +04:00
aResult.Append(name);
1998-09-30 05:08:59 +04:00
}
}
}
else if (eCSSUnit_Color == unit){
1998-10-08 05:31:58 +04:00
nscolor color = aValue.GetColorValue();
1998-10-27 02:22:40 +03:00
aResult.Append("rgb(");
aResult.Append(NS_GET_R(color), 10);
aResult.Append(",");
aResult.Append(NS_GET_G(color), 10);
aResult.Append(",");
aResult.Append(NS_GET_B(color), 10);
aResult.Append(')');
1998-09-30 05:08:59 +04:00
}
else if (eCSSUnit_Percent == unit) {
1998-10-08 05:31:58 +04:00
aResult.Append(aValue.GetPercentValue() * 100.0f);
1998-09-30 05:08:59 +04:00
}
else if (eCSSUnit_Percent < unit) { // length unit
1998-10-08 05:31:58 +04:00
aResult.Append(aValue.GetFloatValue());
1998-09-30 05:08:59 +04:00
}
switch (unit) {
1998-10-27 02:22:40 +03:00
case eCSSUnit_Null: break;
case eCSSUnit_Auto: aResult.Append("auto"); break;
case eCSSUnit_Inherit: aResult.Append("inherit"); break;
case eCSSUnit_None: aResult.Append("none"); break;
case eCSSUnit_Normal: aResult.Append("normal"); break;
case eCSSUnit_String: break;
case eCSSUnit_URL:
case eCSSUnit_Attr:
case eCSSUnit_Counter:
case eCSSUnit_Counters: aResult.Append(')'); break;
case eCSSUnit_Integer: break;
case eCSSUnit_Enumerated: break;
case eCSSUnit_Color: break;
case eCSSUnit_Percent: aResult.Append("%"); break;
case eCSSUnit_Number: break;
case eCSSUnit_Inch: aResult.Append("in"); break;
case eCSSUnit_Foot: aResult.Append("ft"); break;
case eCSSUnit_Mile: aResult.Append("mi"); break;
case eCSSUnit_Millimeter: aResult.Append("mm"); break;
case eCSSUnit_Centimeter: aResult.Append("cm"); break;
case eCSSUnit_Meter: aResult.Append("m"); break;
case eCSSUnit_Kilometer: aResult.Append("km"); break;
case eCSSUnit_Point: aResult.Append("pt"); break;
case eCSSUnit_Pica: aResult.Append("pc"); break;
case eCSSUnit_Didot: aResult.Append("dt"); break;
case eCSSUnit_Cicero: aResult.Append("cc"); break;
case eCSSUnit_EM: aResult.Append("em"); break;
case eCSSUnit_EN: aResult.Append("en"); break;
case eCSSUnit_XHeight: aResult.Append("ex"); break;
case eCSSUnit_CapHeight: aResult.Append("cap"); break;
case eCSSUnit_Pixel: aResult.Append("px"); break;
case eCSSUnit_Degree: aResult.Append("deg"); break;
case eCSSUnit_Grad: aResult.Append("grad"); break;
case eCSSUnit_Radian: aResult.Append("rad"); break;
case eCSSUnit_Hertz: aResult.Append("Hz"); break;
case eCSSUnit_Kilohertz: aResult.Append("kHz"); break;
case eCSSUnit_Seconds: aResult.Append("s"); break;
case eCSSUnit_Milliseconds: aResult.Append("ms"); break;
1998-10-08 05:31:58 +04:00
}
return PR_TRUE;
}
#define HAS_VALUE(strct,data) \
((nsnull != strct) && (eCSSUnit_Null != strct->data.GetUnit()))
#define HAS_RECT(strct,rect) \
((nsnull != strct) && (nsnull != strct->rect) && \
(eCSSUnit_Null != strct->rect->mTop.GetUnit()) && \
(eCSSUnit_Null != strct->rect->mRight.GetUnit()) && \
(eCSSUnit_Null != strct->rect->mBottom.GetUnit()) && \
(eCSSUnit_Null != strct->rect->mLeft.GetUnit()))
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetValue(PRInt32 aProperty, nsString& aValue)
1998-10-08 05:31:58 +04:00
{
PRBool isImportant = PR_FALSE;
GetValueIsImportant(aProperty, isImportant);
if (PR_TRUE == isImportant) {
return mImportant->GetValue(aProperty, aValue);
}
1998-10-08 05:31:58 +04:00
aValue.Truncate(0);
1998-09-30 05:08:59 +04:00
1998-10-08 05:31:58 +04:00
// shorthands
switch (aProperty) {
case PROP_BACKGROUND:
if (AppendValueToString(PROP_BACKGROUND_COLOR, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_BACKGROUND_IMAGE, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_BACKGROUND_REPEAT, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_BACKGROUND_ATTACHMENT, aValue)) aValue.Append(' ');
if (HAS_VALUE(mColor,mBackPositionX) && HAS_VALUE(mColor,mBackPositionY)) {
AppendValueToString(PROP_BACKGROUND_X_POSITION, aValue);
aValue.Append(' ');
AppendValueToString(PROP_BACKGROUND_Y_POSITION, aValue);
}
break;
case PROP_BORDER:
if (AppendValueToString(PROP_BORDER_TOP_WIDTH, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_BORDER_TOP_STYLE, aValue)) aValue.Append(' ');
AppendValueToString(PROP_BORDER_TOP_COLOR, aValue);
break;
1998-10-27 02:22:40 +03:00
case PROP_BORDER_SPACING:
if (AppendValueToString(PROP_BORDER_X_SPACING, aValue)) {
aValue.Append(' ');
AppendValueToString(PROP_BORDER_Y_SPACING, aValue);
}
break;
1998-10-08 05:31:58 +04:00
case PROP_CLIP:
if (HAS_RECT(mDisplay,mClip)) {
aValue.Append("rect(");
AppendValueToString(PROP_CLIP_TOP, aValue); aValue.Append(' ');
AppendValueToString(PROP_CLIP_RIGHT, aValue); aValue.Append(' ');
AppendValueToString(PROP_CLIP_BOTTOM, aValue); aValue.Append(' ');
AppendValueToString(PROP_CLIP_LEFT, aValue);
aValue.Append(")");
}
break;
case PROP_CUE:
if (HAS_VALUE(mAural,mCueAfter) && HAS_VALUE(mAural,mCueBefore)) {
AppendValueToString(PROP_CUE_AFTER, aValue);
aValue.Append(' ');
AppendValueToString(PROP_CUE_BEFORE, aValue);
}
break;
1998-10-27 02:22:40 +03:00
case PROP_CURSOR:
if ((nsnull != mColor) && (nsnull != mColor->mCursor)) {
nsCSSValueList* cursor = mColor->mCursor;
do {
AppendValueToString(PROP_CURSOR, cursor->mValue, aValue);
cursor = cursor->mNext;
if (nsnull != cursor) {
aValue.Append(' ');
}
} while (nsnull != cursor);
}
break;
1998-10-08 05:31:58 +04:00
case PROP_FONT:
if (HAS_VALUE(mFont,mSize)) {
if (AppendValueToString(PROP_FONT_STYLE, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_FONT_VARIANT, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_FONT_WEIGHT, aValue)) aValue.Append(' ');
AppendValueToString(PROP_FONT_SIZE, aValue);
if (HAS_VALUE(mText,mLineHeight)) {
aValue.Append('/');
AppendValueToString(PROP_LINE_HEIGHT, aValue);
}
aValue.Append(' ');
AppendValueToString(PROP_FONT_FAMILY, aValue);
}
break;
case PROP_LIST_STYLE:
if (AppendValueToString(PROP_LIST_STYLE_TYPE, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_LIST_STYLE_POSITION, aValue)) aValue.Append(' ');
AppendValueToString(PROP_LIST_STYLE_IMAGE, aValue);
break;
case PROP_MARGIN:
if (HAS_RECT(mMargin,mMargin)) {
AppendValueToString(PROP_MARGIN_TOP, aValue); aValue.Append(' ');
AppendValueToString(PROP_MARGIN_RIGHT, aValue); aValue.Append(' ');
AppendValueToString(PROP_MARGIN_BOTTOM, aValue); aValue.Append(' ');
AppendValueToString(PROP_MARGIN_LEFT, aValue);
}
break;
case PROP_OUTLINE:
if (AppendValueToString(PROP_OUTLINE_COLOR, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_OUTLINE_STYLE, aValue)) aValue.Append(' ');
AppendValueToString(PROP_OUTLINE_WIDTH, aValue);
break;
case PROP_PADDING:
if (HAS_RECT(mMargin,mPadding)) {
AppendValueToString(PROP_PADDING_TOP, aValue); aValue.Append(' ');
AppendValueToString(PROP_PADDING_RIGHT, aValue); aValue.Append(' ');
AppendValueToString(PROP_PADDING_BOTTOM, aValue); aValue.Append(' ');
AppendValueToString(PROP_PADDING_LEFT, aValue);
}
break;
case PROP_PAUSE:
if (HAS_VALUE(mAural,mPauseAfter) && HAS_VALUE(mAural,mPauseBefore)) {
AppendValueToString(PROP_PAUSE_AFTER, aValue);
aValue.Append(' ');
AppendValueToString(PROP_PAUSE_BEFORE, aValue);
}
break;
1998-10-27 02:22:40 +03:00
case PROP_SIZE:
if (HAS_VALUE(mPage,mSizeWidth) && HAS_VALUE(mPage,mSizeHeight)) {
AppendValueToString(PROP_SIZE_WIDTH, aValue);
aValue.Append(' ');
AppendValueToString(PROP_SIZE_HEIGHT, aValue);
}
break;
1998-10-08 05:31:58 +04:00
case PROP_TEXT_SHADOW:
if ((nsnull != mText) && (nsnull != mText->mTextShadow)) {
1998-10-27 02:22:40 +03:00
if (mText->mTextShadow->mXOffset.IsLengthUnit()) {
1998-10-08 05:31:58 +04:00
nsCSSShadow* shadow = mText->mTextShadow;
while (nsnull != shadow) {
if (AppendValueToString(PROP_TEXT_SHADOW_COLOR, shadow->mColor, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_TEXT_SHADOW_X, shadow->mXOffset, aValue)) {
aValue.Append(' ');
AppendValueToString(PROP_TEXT_SHADOW_Y, shadow->mYOffset, aValue);
aValue.Append(' ');
}
if (AppendValueToString(PROP_TEXT_SHADOW_RADIUS, shadow->mRadius, aValue)) aValue.Append(' ');
shadow = shadow->mNext;
}
}
else { // none or inherit
1998-10-27 02:22:40 +03:00
AppendValueToString(PROP_TEXT_SHADOW_X, aValue);
1998-10-08 05:31:58 +04:00
}
}
break;
case PROP_BACKGROUND_POSITION:
if (HAS_VALUE(mColor,mBackPositionX) && HAS_VALUE(mColor,mBackPositionY)) {
AppendValueToString(PROP_BACKGROUND_X_POSITION, aValue);
aValue.Append(' ');
AppendValueToString(PROP_BACKGROUND_Y_POSITION, aValue);
}
break;
case PROP_BORDER_TOP:
if (AppendValueToString(PROP_BORDER_TOP_WIDTH, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_BORDER_TOP_STYLE, aValue)) aValue.Append(' ');
AppendValueToString(PROP_BORDER_TOP_COLOR, aValue);
break;
case PROP_BORDER_RIGHT:
if (AppendValueToString(PROP_BORDER_RIGHT_WIDTH, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_BORDER_RIGHT_STYLE, aValue)) aValue.Append(' ');
AppendValueToString(PROP_BORDER_RIGHT_COLOR, aValue);
break;
case PROP_BORDER_BOTTOM:
if (AppendValueToString(PROP_BORDER_BOTTOM_WIDTH, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_BORDER_BOTTOM_STYLE, aValue)) aValue.Append(' ');
AppendValueToString(PROP_BORDER_BOTTOM_COLOR, aValue);
break;
case PROP_BORDER_LEFT:
if (AppendValueToString(PROP_BORDER_LEFT_WIDTH, aValue)) aValue.Append(' ');
if (AppendValueToString(PROP_BORDER_LEFT_STYLE, aValue)) aValue.Append(' ');
AppendValueToString(PROP_BORDER_LEFT_COLOR, aValue);
break;
case PROP_BORDER_COLOR:
if (HAS_RECT(mMargin,mBorderColor)) {
AppendValueToString(PROP_BORDER_TOP_COLOR, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_RIGHT_COLOR, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_BOTTOM_COLOR, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_LEFT_COLOR, aValue);
}
break;
case PROP_BORDER_STYLE:
if (HAS_RECT(mMargin,mBorderStyle)) {
AppendValueToString(PROP_BORDER_TOP_STYLE, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_RIGHT_STYLE, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_BOTTOM_STYLE, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_LEFT_STYLE, aValue);
}
break;
case PROP_BORDER_WIDTH:
if (HAS_RECT(mMargin,mBorderWidth)) {
AppendValueToString(PROP_BORDER_TOP_WIDTH, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_RIGHT_WIDTH, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_BOTTOM_WIDTH, aValue); aValue.Append(' ');
AppendValueToString(PROP_BORDER_LEFT_WIDTH, aValue);
}
break;
1998-10-27 02:22:40 +03:00
case PROP_CONTENT:
if ((nsnull != mContent) && (nsnull != mContent->mContent)) {
nsCSSValueList* content = mContent->mContent;
do {
AppendValueToString(PROP_CONTENT, content->mValue, aValue);
content = content->mNext;
if (nsnull != content) {
aValue.Append(' ');
}
} while (nsnull != content);
}
break;
case PROP_COUNTER_INCREMENT:
if ((nsnull != mContent) && (nsnull != mContent->mCounterIncrement)) {
nsCSSCounterData* data = mContent->mCounterIncrement;
do {
if (AppendValueToString(PROP_COUNTER_INCREMENT, data->mCounter, aValue)) {
if (HAS_VALUE(data, mValue)) {
aValue.Append(' ');
AppendValueToString(PROP_COUNTER_INCREMENT, data->mValue, aValue);
}
}
data = data->mNext;
if (nsnull != data) {
aValue.Append(' ');
}
} while (nsnull != data);
}
break;
case PROP_COUNTER_RESET:
if ((nsnull != mContent) && (nsnull != mContent->mCounterReset)) {
nsCSSCounterData* data = mContent->mCounterReset;
do {
if (AppendValueToString(PROP_COUNTER_RESET, data->mCounter, aValue)) {
if (HAS_VALUE(data, mValue)) {
aValue.Append(' ');
AppendValueToString(PROP_COUNTER_RESET, data->mValue, aValue);
}
}
data = data->mNext;
if (nsnull != data) {
aValue.Append(' ');
}
} while (nsnull != data);
}
break;
case PROP_PLAY_DURING:
if (HAS_VALUE(mAural, mPlayDuring)) {
AppendValueToString(PROP_PLAY_DURING, aValue);
if (HAS_VALUE(mAural, mPlayDuringFlags)) {
aValue.Append(' ');
AppendValueToString(PROP_PLAY_DURING_FLAGS, aValue);
}
}
break;
case PROP_QUOTES:
if ((nsnull != mContent) && (nsnull != mContent->mQuotes)) {
nsCSSQuotes* quotes = mContent->mQuotes;
do {
AppendValueToString(PROP_QUOTES_OPEN, quotes->mOpen, aValue);
aValue.Append(' ');
AppendValueToString(PROP_QUOTES_CLOSE, quotes->mClose, aValue);
quotes = quotes->mNext;
if (nsnull != quotes) {
aValue.Append(' ');
}
} while (nsnull != quotes);
}
break;
1998-10-08 05:31:58 +04:00
default:
AppendValueToString(aProperty, aValue);
break;
}
1998-09-30 05:08:59 +04:00
return NS_OK;
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetImportantValues(nsICSSDeclaration*& aResult)
1998-06-26 09:51:55 +04:00
{
if (nsnull != mImportant) {
aResult = mImportant;
NS_ADDREF(aResult);
}
else {
aResult = nsnull;
}
return NS_OK;
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetValueIsImportant(const nsString& aProperty,
PRBool& aIsImportant)
{
char prop[50];
aProperty.ToCString(prop, sizeof(prop));
PRInt32 propID = nsCSSProps::LookupName(prop);
return GetValueIsImportant(propID, aIsImportant);
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetValueIsImportant(PRInt32 aProperty,
PRBool& aIsImportant)
{
nsCSSValue val;
1998-09-10 05:19:26 +04:00
if (nsnull != mImportant) {
mImportant->GetValue(aProperty, val);
if (eCSSUnit_Null != val.GetUnit()) {
aIsImportant = PR_TRUE;
1998-09-10 05:19:26 +04:00
}
else {
aIsImportant = PR_FALSE;
}
}
else {
aIsImportant = PR_FALSE;
}
return NS_OK;
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::ToString(nsString& aString)
{
1998-09-10 05:19:26 +04:00
if (nsnull != mOrder) {
PRInt32 count = mOrder->Count();
PRInt32 index;
for (index = 0; index < count; index++) {
PRInt32 property = (PRInt32)mOrder->ElementAt(index);
if (0 <= property) {
aString.Append(nsCSSProps::kNameTable[property].name);
aString.Append(": ");
1998-09-30 05:08:59 +04:00
nsAutoString value;
GetValue(property, value);
aString.Append(value);
if (index < count) {
aString.Append("; ");
1998-09-10 05:19:26 +04:00
}
}
else { // is comment
aString.Append("/* ");
nsString* comment = (nsString*)mComments->ElementAt((-1) - property);
aString.Append(*comment);
aString.Append(" */ ");
}
}
}
return NS_OK;
}
1998-09-10 05:19:26 +04:00
void CSSDeclarationImpl::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
fputs("{ ", out);
if (nsnull != mFont) {
mFont->List(out);
}
if (nsnull != mColor) {
mColor->List(out);
}
if (nsnull != mText) {
mText->List(out);
}
1998-10-08 05:31:58 +04:00
if (nsnull != mDisplay) {
mDisplay->List(out);
}
1998-09-10 05:19:26 +04:00
if (nsnull != mMargin) {
mMargin->List(out);
}
if (nsnull != mPosition) {
mPosition->List(out);
}
if (nsnull != mList) {
mList->List(out);
}
1998-10-08 05:31:58 +04:00
if (nsnull != mTable) {
mTable->List(out);
}
if (nsnull != mBreaks) {
mBreaks->List(out);
}
if (nsnull != mPage) {
mPage->List(out);
}
if (nsnull != mContent) {
mContent->List(out);
}
if (nsnull != mAural) {
mAural->List(out);
1998-09-10 05:19:26 +04:00
}
fputs("}", out);
if (nsnull != mImportant) {
fputs(" ! important ", out);
mImportant->List(out, 0);
}
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::Count(PRUint32* aCount)
{
if (nsnull != mOrder) {
*aCount = (PRUint32)mOrder->Count();
}
else {
*aCount = 0;
}
return NS_OK;
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetNthProperty(PRUint32 aIndex, nsString& aReturn)
{
aReturn.SetLength(0);
if (nsnull != mOrder) {
PRInt32 property = (PRInt32)mOrder->ElementAt(aIndex);
if (0 <= property) {
aReturn.Append(nsCSSProps::kNameTable[property].name);
}
}
return NS_OK;
}
1999-01-06 04:25:39 +03:00
NS_IMETHODIMP
CSSDeclarationImpl::GetStyleImpact(PRInt32* aHint) const
{
NS_ASSERTION(nsnull != aHint, "null pointer");
if (nsnull == aHint) {
return NS_ERROR_NULL_POINTER;
}
PRInt32 hint = NS_STYLE_HINT_NONE;
1999-01-06 04:25:39 +03:00
if (nsnull != mOrder) {
PRInt32 count = mOrder->Count();
PRInt32 index;
for (index = 0; index < count; index++) {
PRInt32 property = (PRInt32)mOrder->ElementAt(index);
if (0 <= property) {
if (hint < nsCSSProps::kHintTable[property]) {
hint = nsCSSProps::kHintTable[property];
}
}
}
}
*aHint = hint;
return NS_OK;
}
1998-09-10 05:19:26 +04:00
NS_HTML nsresult
NS_NewCSSDeclaration(nsICSSDeclaration** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
CSSDeclarationImpl *it;
NS_NEWXPCOM(it, CSSDeclarationImpl);
1998-09-10 05:19:26 +04:00
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kICSSDeclarationIID, (void **) aInstancePtrResult);
}