2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 05:32:19 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
2002-05-21 12:16:42 +04:00
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
2005-03-27 15:36:08 +04:00
|
|
|
* Mats Palmgren <mats.palmgren@bredband.net>
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 05:32:19 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 05:32:19 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-25 08:47:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* representation of a declaration block (or style attribute) in a CSS
|
|
|
|
* stylesheet
|
|
|
|
*/
|
|
|
|
|
2001-08-14 11:59:59 +04:00
|
|
|
#include "nscore.h"
|
2008-01-10 23:13:24 +03:00
|
|
|
#include "prlog.h"
|
2002-01-16 01:43:37 +03:00
|
|
|
#include "nsCSSDeclaration.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsString.h"
|
2002-07-25 22:31:10 +04:00
|
|
|
#include "nsIAtom.h"
|
2001-10-26 06:38:29 +04:00
|
|
|
#include "nsUnicharUtils.h"
|
2004-09-10 07:26:58 +04:00
|
|
|
#include "nsReadableUtils.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsCSSProps.h"
|
2002-08-24 18:41:28 +04:00
|
|
|
#include "nsFont.h"
|
2003-11-01 13:57:41 +03:00
|
|
|
#include "nsReadableUtils.h"
|
2007-03-08 21:44:45 +03:00
|
|
|
#include "nsStyleUtil.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-15 02:34:27 +04:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2002-05-21 12:16:42 +04:00
|
|
|
#define B_BORDER_TOP_STYLE 0x001
|
|
|
|
#define B_BORDER_LEFT_STYLE 0x002
|
|
|
|
#define B_BORDER_RIGHT_STYLE 0x004
|
|
|
|
#define B_BORDER_BOTTOM_STYLE 0x008
|
|
|
|
#define B_BORDER_TOP_COLOR 0x010
|
|
|
|
#define B_BORDER_LEFT_COLOR 0x020
|
|
|
|
#define B_BORDER_RIGHT_COLOR 0x040
|
|
|
|
#define B_BORDER_BOTTOM_COLOR 0x080
|
|
|
|
#define B_BORDER_TOP_WIDTH 0x100
|
|
|
|
#define B_BORDER_LEFT_WIDTH 0x200
|
|
|
|
#define B_BORDER_RIGHT_WIDTH 0x400
|
|
|
|
#define B_BORDER_BOTTOM_WIDTH 0x800
|
|
|
|
|
|
|
|
#define B_BORDER_STYLE 0x00f
|
|
|
|
#define B_BORDER_COLOR 0x0f0
|
|
|
|
#define B_BORDER_WIDTH 0xf00
|
|
|
|
|
|
|
|
#define B_BORDER_TOP 0x111
|
|
|
|
#define B_BORDER_LEFT 0x222
|
|
|
|
#define B_BORDER_RIGHT 0x444
|
|
|
|
#define B_BORDER_BOTTOM 0x888
|
|
|
|
|
|
|
|
#define B_BORDER 0xfff
|
1998-04-22 10:38:31 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSDeclaration::nsCSSDeclaration()
|
2008-01-10 23:13:24 +03:00
|
|
|
: mData(nsnull),
|
2003-06-08 02:14:42 +04:00
|
|
|
mImportantData(nsnull)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2008-01-10 23:13:24 +03:00
|
|
|
// check that we can fit all the CSS properties into a PRUint8
|
|
|
|
// for the mOrder array - if not, might need to use PRUint16!
|
|
|
|
PR_STATIC_ASSERT(eCSSProperty_COUNT_no_shorthands - 1 <= PR_UINT8_MAX);
|
|
|
|
|
2003-04-15 07:07:34 +04:00
|
|
|
MOZ_COUNT_CTOR(nsCSSDeclaration);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration::nsCSSDeclaration(const nsCSSDeclaration& aCopy)
|
2008-01-10 23:13:24 +03:00
|
|
|
: mOrder(aCopy.mOrder),
|
2003-06-08 02:14:42 +04:00
|
|
|
mData(aCopy.mData ? aCopy.mData->Clone() : nsnull),
|
|
|
|
mImportantData(aCopy.mImportantData ? aCopy.mImportantData->Clone()
|
|
|
|
: nsnull)
|
1999-06-03 05:58:11 +04:00
|
|
|
{
|
2003-04-15 07:07:34 +04:00
|
|
|
MOZ_COUNT_CTOR(nsCSSDeclaration);
|
1999-06-03 05:58:11 +04:00
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration::~nsCSSDeclaration(void)
|
|
|
|
{
|
2003-06-08 02:14:42 +04:00
|
|
|
if (mData) {
|
|
|
|
mData->Destroy();
|
|
|
|
}
|
|
|
|
if (mImportantData) {
|
|
|
|
mImportantData->Destroy();
|
|
|
|
}
|
1998-06-26 09:51:55 +04:00
|
|
|
|
2003-04-15 07:07:34 +04:00
|
|
|
MOZ_COUNT_DTOR(nsCSSDeclaration);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
nsresult
|
|
|
|
nsCSSDeclaration::ValueAppended(nsCSSProperty aProperty)
|
2002-01-16 01:43:37 +03:00
|
|
|
{
|
2003-06-08 02:14:42 +04:00
|
|
|
// order IS important for CSS, so remove and add to the end
|
|
|
|
if (nsCSSProps::IsShorthand(aProperty)) {
|
|
|
|
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
|
2008-01-10 23:13:24 +03:00
|
|
|
mOrder.RemoveElement(*p);
|
|
|
|
mOrder.AppendElement(*p);
|
2003-06-08 02:14:42 +04:00
|
|
|
}
|
|
|
|
} else {
|
2008-01-10 23:13:24 +03:00
|
|
|
mOrder.RemoveElement(aProperty);
|
|
|
|
mOrder.AppendElement(aProperty);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
return NS_OK;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
nsresult
|
|
|
|
nsCSSDeclaration::RemoveProperty(nsCSSProperty aProperty)
|
2002-01-16 01:43:37 +03:00
|
|
|
{
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSExpandedDataBlock data;
|
|
|
|
data.Expand(&mData, &mImportantData);
|
|
|
|
NS_ASSERTION(!mData && !mImportantData, "Expand didn't null things out");
|
|
|
|
|
|
|
|
if (nsCSSProps::IsShorthand(aProperty)) {
|
|
|
|
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
|
|
|
|
data.ClearProperty(*p);
|
2008-01-10 23:13:24 +03:00
|
|
|
mOrder.RemoveElement(*p);
|
2003-06-08 02:14:42 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
data.ClearProperty(aProperty);
|
2008-01-10 23:13:24 +03:00
|
|
|
mOrder.RemoveElement(aProperty);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
data.Compress(&mData, &mImportantData);
|
|
|
|
return NS_OK;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSDeclaration::AppendComment(const nsAString& aComment)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2003-06-08 02:14:42 +04:00
|
|
|
return /* NS_ERROR_NOT_IMPLEMENTED, or not any longer that is */ NS_OK;
|
|
|
|
}
|
1998-10-08 05:31:58 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
nsresult
|
|
|
|
nsCSSDeclaration::GetValueOrImportantValue(nsCSSProperty aProperty, nsCSSValue& aValue) const
|
|
|
|
{
|
|
|
|
aValue.Reset();
|
1999-12-22 14:27:10 +03:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
NS_ASSERTION(aProperty >= 0, "out of range");
|
|
|
|
if (aProperty >= eCSSProperty_COUNT_no_shorthands ||
|
|
|
|
nsCSSProps::kTypeTable[aProperty] != eCSSType_Value) {
|
|
|
|
NS_ERROR("can't query for shorthand properties");
|
|
|
|
return NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
}
|
2000-01-24 14:19:55 +03:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSCompressedDataBlock *data = GetValueIsImportant(aProperty)
|
|
|
|
? mImportantData : mData;
|
|
|
|
const void *storage = data->StorageFor(aProperty);
|
|
|
|
if (!storage)
|
|
|
|
return NS_OK;
|
2007-07-08 11:08:04 +04:00
|
|
|
aValue = *static_cast<const nsCSSValue*>(storage);
|
2003-06-08 02:14:42 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
nsresult
|
|
|
|
nsCSSDeclaration::GetValue(const nsAString& aProperty,
|
|
|
|
nsAString& aValue) const
|
|
|
|
{
|
|
|
|
nsCSSProperty propID = nsCSSProps::LookupProperty(aProperty);
|
|
|
|
return GetValue(propID, aValue);
|
|
|
|
}
|
1998-10-08 05:31:58 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
PRBool nsCSSDeclaration::AppendValueToString(nsCSSProperty aProperty, nsAString& aResult) const
|
|
|
|
{
|
|
|
|
nsCSSCompressedDataBlock *data = GetValueIsImportant(aProperty)
|
|
|
|
? mImportantData : mData;
|
|
|
|
const void *storage = data->StorageFor(aProperty);
|
|
|
|
if (storage) {
|
|
|
|
switch (nsCSSProps::kTypeTable[aProperty]) {
|
|
|
|
case eCSSType_Value: {
|
2007-07-08 11:08:04 +04:00
|
|
|
const nsCSSValue *val = static_cast<const nsCSSValue*>(storage);
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendCSSValueToString(aProperty, *val, aResult);
|
|
|
|
} break;
|
|
|
|
case eCSSType_Rect: {
|
2007-07-08 11:08:04 +04:00
|
|
|
const nsCSSRect *rect = static_cast<const nsCSSRect*>(storage);
|
2003-11-16 05:06:38 +03:00
|
|
|
if (rect->mTop.GetUnit() == eCSSUnit_Inherit ||
|
|
|
|
rect->mTop.GetUnit() == eCSSUnit_Initial) {
|
|
|
|
NS_ASSERTION(rect->mRight.GetUnit() == rect->mTop.GetUnit(),
|
|
|
|
"Top inherit or initial, right isn't. Fix the parser!");
|
|
|
|
NS_ASSERTION(rect->mBottom.GetUnit() == rect->mTop.GetUnit(),
|
|
|
|
"Top inherit or initial, bottom isn't. Fix the parser!");
|
|
|
|
NS_ASSERTION(rect->mLeft.GetUnit() == rect->mTop.GetUnit(),
|
|
|
|
"Top inherit or initial, left isn't. Fix the parser!");
|
|
|
|
AppendCSSValueToString(aProperty, rect->mTop, aResult);
|
|
|
|
} else {
|
2004-06-17 04:13:25 +04:00
|
|
|
aResult.AppendLiteral("rect(");
|
2003-11-16 05:06:38 +03:00
|
|
|
AppendCSSValueToString(aProperty, rect->mTop, aResult);
|
|
|
|
NS_NAMED_LITERAL_STRING(comma, ", ");
|
|
|
|
aResult.Append(comma);
|
|
|
|
AppendCSSValueToString(aProperty, rect->mRight, aResult);
|
|
|
|
aResult.Append(comma);
|
|
|
|
AppendCSSValueToString(aProperty, rect->mBottom, aResult);
|
|
|
|
aResult.Append(comma);
|
|
|
|
AppendCSSValueToString(aProperty, rect->mLeft, aResult);
|
|
|
|
aResult.Append(PRUnichar(')'));
|
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
} break;
|
2004-09-10 07:26:58 +04:00
|
|
|
case eCSSType_ValuePair: {
|
2007-07-08 11:08:04 +04:00
|
|
|
const nsCSSValuePair *pair = static_cast<const nsCSSValuePair*>(storage);
|
2004-09-10 07:26:58 +04:00
|
|
|
AppendCSSValueToString(aProperty, pair->mXValue, aResult);
|
2007-04-16 02:25:20 +04:00
|
|
|
if (pair->mYValue != pair->mXValue ||
|
|
|
|
(aProperty == eCSSProperty_background_position &&
|
|
|
|
pair->mXValue.GetUnit() != eCSSUnit_Inherit &&
|
|
|
|
pair->mXValue.GetUnit() != eCSSUnit_Initial)) {
|
2004-09-10 07:26:58 +04:00
|
|
|
// Only output a Y value if it's different from the X value
|
2007-04-16 02:25:20 +04:00
|
|
|
// or if it's a background-position value other than 'initial'
|
|
|
|
// or 'inherit'.
|
2004-09-10 07:26:58 +04:00
|
|
|
aResult.Append(PRUnichar(' '));
|
|
|
|
AppendCSSValueToString(aProperty, pair->mYValue, aResult);
|
|
|
|
}
|
|
|
|
} break;
|
2003-06-08 02:14:42 +04:00
|
|
|
case eCSSType_ValueList: {
|
|
|
|
const nsCSSValueList* val =
|
2007-07-08 11:08:04 +04:00
|
|
|
*static_cast<nsCSSValueList*const*>(storage);
|
2003-06-08 02:14:42 +04:00
|
|
|
do {
|
|
|
|
AppendCSSValueToString(aProperty, val->mValue, aResult);
|
|
|
|
val = val->mNext;
|
|
|
|
if (val) {
|
2005-07-01 08:29:42 +04:00
|
|
|
if (aProperty == eCSSProperty_cursor
|
2005-09-20 16:04:45 +04:00
|
|
|
|| aProperty == eCSSProperty_text_shadow
|
2008-07-08 04:56:52 +04:00
|
|
|
|| aProperty == eCSSProperty_box_shadow
|
2005-07-01 08:29:42 +04:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
|| aProperty == eCSSProperty_stroke_dasharray
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
aResult.Append(PRUnichar(','));
|
2003-06-08 02:14:42 +04:00
|
|
|
aResult.Append(PRUnichar(' '));
|
|
|
|
}
|
|
|
|
} while (val);
|
|
|
|
} break;
|
2008-08-05 02:15:11 +04:00
|
|
|
case eCSSType_ValuePairList: {
|
|
|
|
const nsCSSValuePairList* item =
|
|
|
|
*static_cast<nsCSSValuePairList*const*>(storage);
|
2003-06-08 02:14:42 +04:00
|
|
|
do {
|
2008-08-05 02:15:11 +04:00
|
|
|
NS_ASSERTION(item->mXValue.GetUnit() != eCSSUnit_Null,
|
|
|
|
"unexpected null unit");
|
|
|
|
AppendCSSValueToString(aProperty, item->mXValue, aResult);
|
|
|
|
if (item->mYValue.GetUnit() != eCSSUnit_Null) {
|
2007-03-31 02:02:09 +04:00
|
|
|
aResult.Append(PRUnichar(' '));
|
2008-08-05 02:15:11 +04:00
|
|
|
AppendCSSValueToString(aProperty, item->mYValue, aResult);
|
2007-03-31 02:02:09 +04:00
|
|
|
}
|
2008-08-05 02:15:11 +04:00
|
|
|
item = item->mNext;
|
|
|
|
if (item) {
|
2003-06-08 02:14:42 +04:00
|
|
|
aResult.Append(PRUnichar(' '));
|
|
|
|
}
|
2008-08-05 02:15:11 +04:00
|
|
|
} while (item);
|
2003-06-08 02:14:42 +04:00
|
|
|
} break;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
return storage != nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2006-05-03 03:36:17 +04:00
|
|
|
/* static */ PRBool
|
|
|
|
nsCSSDeclaration::AppendCSSValueToString(nsCSSProperty aProperty,
|
|
|
|
const nsCSSValue& aValue,
|
|
|
|
nsAString& aResult)
|
1998-10-08 05:31:58 +04:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2005-04-02 03:07:00 +04:00
|
|
|
if (eCSSUnit_String <= unit && unit <= eCSSUnit_Attr) {
|
|
|
|
if (unit == eCSSUnit_Attr) {
|
|
|
|
aResult.AppendLiteral("attr(");
|
1998-10-27 02:22:40 +03:00
|
|
|
}
|
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
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
else if (eCSSUnit_Array <= unit && unit <= eCSSUnit_Counters) {
|
|
|
|
switch (unit) {
|
|
|
|
case eCSSUnit_Counter: aResult.AppendLiteral("counter("); break;
|
|
|
|
case eCSSUnit_Counters: aResult.AppendLiteral("counters("); break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSValue::Array *array = aValue.GetArrayValue();
|
|
|
|
PRBool mark = PR_FALSE;
|
|
|
|
for (PRUint16 i = 0, i_end = array->Count(); i < i_end; ++i) {
|
2008-07-17 10:30:25 +04:00
|
|
|
if (aProperty == eCSSProperty_border_image && i >= 5) {
|
|
|
|
if (array->Item(i).GetUnit() == eCSSUnit_Null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (i == 5) {
|
|
|
|
aResult.AppendLiteral(" /");
|
|
|
|
}
|
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
if (mark && array->Item(i).GetUnit() != eCSSUnit_Null) {
|
|
|
|
if (unit == eCSSUnit_Array)
|
|
|
|
aResult.AppendLiteral(" ");
|
|
|
|
else
|
|
|
|
aResult.AppendLiteral(", ");
|
|
|
|
}
|
|
|
|
nsCSSProperty prop =
|
|
|
|
((eCSSUnit_Counter <= unit && unit <= eCSSUnit_Counters) &&
|
|
|
|
i == array->Count() - 1)
|
|
|
|
? eCSSProperty_list_style_type : aProperty;
|
|
|
|
if (AppendCSSValueToString(prop, array->Item(i), aResult)) {
|
|
|
|
mark = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-09-30 05:08:59 +04:00
|
|
|
else if (eCSSUnit_Integer == unit) {
|
2008-02-08 22:51:41 +03:00
|
|
|
nsAutoString tmpStr;
|
|
|
|
tmpStr.AppendInt(aValue.GetIntValue(), 10);
|
|
|
|
aResult.Append(tmpStr);
|
1998-09-30 05:08:59 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Enumerated == unit) {
|
1999-07-18 04:25:28 +04:00
|
|
|
if (eCSSProperty_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;
|
2002-08-24 18:41:28 +04:00
|
|
|
for (mask = NS_STYLE_TEXT_DECORATION_UNDERLINE;
|
1998-09-30 05:08:59 +04:00
|
|
|
mask <= NS_STYLE_TEXT_DECORATION_BLINK;
|
|
|
|
mask <<= 1) {
|
|
|
|
if ((mask & intValue) == mask) {
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, mask), aResult);
|
1998-09-30 05:08:59 +04:00
|
|
|
intValue &= ~mask;
|
|
|
|
if (0 != intValue) { // more left
|
2000-08-23 21:27:06 +04:00
|
|
|
aResult.Append(PRUnichar(' '));
|
1998-09-30 05:08:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, NS_STYLE_TEXT_DECORATION_NONE), aResult);
|
1998-09-30 05:08:59 +04:00
|
|
|
}
|
|
|
|
}
|
1999-07-18 04:25:28 +04:00
|
|
|
else if (eCSSProperty_azimuth == aProperty) {
|
1998-10-27 02:22:40 +03:00
|
|
|
PRInt32 intValue = aValue.GetIntValue();
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, (intValue & ~NS_STYLE_AZIMUTH_BEHIND)), aResult);
|
1998-10-27 02:22:40 +03:00
|
|
|
if ((NS_STYLE_AZIMUTH_BEHIND & intValue) != 0) {
|
2000-08-23 21:27:06 +04:00
|
|
|
aResult.Append(PRUnichar(' '));
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, NS_STYLE_AZIMUTH_BEHIND), aResult);
|
1998-10-27 02:22:40 +03:00
|
|
|
}
|
|
|
|
}
|
1999-07-18 04:25:28 +04:00
|
|
|
else if (eCSSProperty_marks == aProperty) {
|
1999-02-10 11:37:28 +03:00
|
|
|
PRInt32 intValue = aValue.GetIntValue();
|
|
|
|
if ((NS_STYLE_PAGE_MARKS_CROP & intValue) != 0) {
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, NS_STYLE_PAGE_MARKS_CROP), aResult);
|
1999-02-10 11:37:28 +03:00
|
|
|
}
|
|
|
|
if ((NS_STYLE_PAGE_MARKS_REGISTER & intValue) != 0) {
|
|
|
|
if ((NS_STYLE_PAGE_MARKS_CROP & intValue) != 0) {
|
2000-08-23 21:27:06 +04:00
|
|
|
aResult.Append(PRUnichar(' '));
|
1999-02-10 11:37:28 +03:00
|
|
|
}
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, NS_STYLE_PAGE_MARKS_REGISTER), aResult);
|
1999-02-10 11:37:28 +03:00
|
|
|
}
|
|
|
|
}
|
1998-09-30 05:08:59 +04:00
|
|
|
else {
|
2001-11-28 00:13:53 +03:00
|
|
|
const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, aValue.GetIntValue());
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(name, aResult);
|
1998-09-30 05:08:59 +04:00
|
|
|
}
|
|
|
|
}
|
2008-02-08 22:51:41 +03:00
|
|
|
else if (eCSSUnit_EnumColor == unit) {
|
|
|
|
// we can lookup the property in the ColorTable and then
|
|
|
|
// get a string mapping the name
|
|
|
|
nsCAutoString str;
|
|
|
|
if (nsCSSProps::GetColorName(aValue.GetIntValue(), str)){
|
|
|
|
AppendASCIItoUTF16(str, aResult);
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("bad color value");
|
|
|
|
}
|
|
|
|
}
|
2003-10-02 02:53:56 +04:00
|
|
|
else if (eCSSUnit_Color == unit) {
|
1998-10-08 05:31:58 +04:00
|
|
|
nscolor color = aValue.GetColorValue();
|
2007-03-06 07:35:56 +03:00
|
|
|
if (color == NS_RGBA(0, 0, 0, 0)) {
|
|
|
|
// Use the strictest match for 'transparent' so we do correct
|
|
|
|
// round-tripping of all other rgba() values.
|
2007-03-09 12:43:55 +03:00
|
|
|
aResult.AppendLiteral("transparent");
|
2007-03-06 07:35:56 +03:00
|
|
|
} else {
|
|
|
|
nsAutoString tmpStr;
|
|
|
|
PRUint8 a = NS_GET_A(color);
|
|
|
|
if (a < 255) {
|
|
|
|
tmpStr.AppendLiteral("rgba(");
|
|
|
|
} else {
|
|
|
|
tmpStr.AppendLiteral("rgb(");
|
|
|
|
}
|
2000-08-23 21:27:06 +04:00
|
|
|
|
2007-03-06 07:35:56 +03:00
|
|
|
NS_NAMED_LITERAL_STRING(comma, ", ");
|
|
|
|
|
|
|
|
tmpStr.AppendInt(NS_GET_R(color), 10);
|
|
|
|
tmpStr.Append(comma);
|
|
|
|
tmpStr.AppendInt(NS_GET_G(color), 10);
|
|
|
|
tmpStr.Append(comma);
|
|
|
|
tmpStr.AppendInt(NS_GET_B(color), 10);
|
|
|
|
if (a < 255) {
|
|
|
|
tmpStr.Append(comma);
|
2007-03-08 21:44:45 +03:00
|
|
|
tmpStr.AppendFloat(nsStyleUtil::ColorComponentToFloat(a));
|
2007-03-06 07:35:56 +03:00
|
|
|
}
|
|
|
|
tmpStr.Append(PRUnichar(')'));
|
2000-08-23 21:27:06 +04:00
|
|
|
|
2007-03-06 07:35:56 +03:00
|
|
|
aResult.Append(tmpStr);
|
|
|
|
}
|
1998-09-30 05:08:59 +04:00
|
|
|
}
|
2004-03-09 06:57:51 +03:00
|
|
|
else if (eCSSUnit_URL == unit || eCSSUnit_Image == unit) {
|
2003-10-02 02:53:56 +04:00
|
|
|
aResult.Append(NS_LITERAL_STRING("url(") +
|
2003-10-30 04:45:37 +03:00
|
|
|
nsDependentString(aValue.GetOriginalURLValue()) +
|
2003-10-02 02:53:56 +04:00
|
|
|
NS_LITERAL_STRING(")"));
|
|
|
|
}
|
1998-09-30 05:08:59 +04:00
|
|
|
else if (eCSSUnit_Percent == unit) {
|
2000-08-23 21:27:06 +04:00
|
|
|
nsAutoString tmpStr;
|
|
|
|
tmpStr.AppendFloat(aValue.GetPercentValue() * 100.0f);
|
|
|
|
aResult.Append(tmpStr);
|
1998-09-30 05:08:59 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Percent < unit) { // length unit
|
2000-08-23 21:27:06 +04:00
|
|
|
nsAutoString tmpStr;
|
|
|
|
tmpStr.AppendFloat(aValue.GetFloatValue());
|
|
|
|
aResult.Append(tmpStr);
|
1998-09-30 05:08:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (unit) {
|
1998-10-27 02:22:40 +03:00
|
|
|
case eCSSUnit_Null: break;
|
2004-06-17 04:13:25 +04:00
|
|
|
case eCSSUnit_Auto: aResult.AppendLiteral("auto"); break;
|
|
|
|
case eCSSUnit_Inherit: aResult.AppendLiteral("inherit"); break;
|
2004-12-05 01:10:07 +03:00
|
|
|
case eCSSUnit_Initial: aResult.AppendLiteral("-moz-initial"); break;
|
2004-06-17 04:13:25 +04:00
|
|
|
case eCSSUnit_None: aResult.AppendLiteral("none"); break;
|
|
|
|
case eCSSUnit_Normal: aResult.AppendLiteral("normal"); break;
|
2007-06-12 22:28:56 +04:00
|
|
|
case eCSSUnit_System_Font: aResult.AppendLiteral("-moz-use-system-font"); break;
|
1998-10-27 02:22:40 +03:00
|
|
|
|
|
|
|
case eCSSUnit_String: break;
|
2003-10-02 02:53:56 +04:00
|
|
|
case eCSSUnit_URL: break;
|
2004-03-09 06:57:51 +03:00
|
|
|
case eCSSUnit_Image: break;
|
2005-04-02 03:07:00 +04:00
|
|
|
case eCSSUnit_Array: break;
|
1998-10-27 02:22:40 +03:00
|
|
|
case eCSSUnit_Attr:
|
|
|
|
case eCSSUnit_Counter:
|
2000-08-23 21:27:06 +04:00
|
|
|
case eCSSUnit_Counters: aResult.Append(PRUnichar(')')); break;
|
1998-10-27 02:22:40 +03:00
|
|
|
case eCSSUnit_Integer: break;
|
|
|
|
case eCSSUnit_Enumerated: break;
|
2008-02-08 22:51:41 +03:00
|
|
|
case eCSSUnit_EnumColor: break;
|
1998-10-27 02:22:40 +03:00
|
|
|
case eCSSUnit_Color: break;
|
2000-08-23 21:27:06 +04:00
|
|
|
case eCSSUnit_Percent: aResult.Append(PRUnichar('%')); break;
|
1998-10-27 02:22:40 +03:00
|
|
|
case eCSSUnit_Number: break;
|
|
|
|
|
2004-06-17 04:13:25 +04:00
|
|
|
case eCSSUnit_Inch: aResult.AppendLiteral("in"); break;
|
|
|
|
case eCSSUnit_Foot: aResult.AppendLiteral("ft"); break;
|
|
|
|
case eCSSUnit_Mile: aResult.AppendLiteral("mi"); break;
|
|
|
|
case eCSSUnit_Millimeter: aResult.AppendLiteral("mm"); break;
|
|
|
|
case eCSSUnit_Centimeter: aResult.AppendLiteral("cm"); break;
|
|
|
|
case eCSSUnit_Meter: aResult.AppendLiteral("m"); break;
|
|
|
|
case eCSSUnit_Kilometer: aResult.AppendLiteral("km"); break;
|
|
|
|
case eCSSUnit_Point: aResult.AppendLiteral("pt"); break;
|
|
|
|
case eCSSUnit_Pica: aResult.AppendLiteral("pc"); break;
|
|
|
|
case eCSSUnit_Didot: aResult.AppendLiteral("dt"); break;
|
|
|
|
case eCSSUnit_Cicero: aResult.AppendLiteral("cc"); break;
|
2000-08-23 21:27:06 +04:00
|
|
|
|
2004-06-17 04:13:25 +04:00
|
|
|
case eCSSUnit_EM: aResult.AppendLiteral("em"); break;
|
|
|
|
case eCSSUnit_EN: aResult.AppendLiteral("en"); break;
|
|
|
|
case eCSSUnit_XHeight: aResult.AppendLiteral("ex"); break;
|
|
|
|
case eCSSUnit_CapHeight: aResult.AppendLiteral("cap"); break;
|
|
|
|
case eCSSUnit_Char: aResult.AppendLiteral("ch"); break;
|
2000-08-23 21:27:06 +04:00
|
|
|
|
2004-06-17 04:13:25 +04:00
|
|
|
case eCSSUnit_Pixel: aResult.AppendLiteral("px"); break;
|
2000-08-23 21:27:06 +04:00
|
|
|
|
2004-06-17 04:13:25 +04:00
|
|
|
case eCSSUnit_Degree: aResult.AppendLiteral("deg"); break;
|
|
|
|
case eCSSUnit_Grad: aResult.AppendLiteral("grad"); break;
|
|
|
|
case eCSSUnit_Radian: aResult.AppendLiteral("rad"); break;
|
2000-08-23 21:27:06 +04:00
|
|
|
|
2004-06-17 04:13:25 +04:00
|
|
|
case eCSSUnit_Hertz: aResult.AppendLiteral("Hz"); break;
|
|
|
|
case eCSSUnit_Kilohertz: aResult.AppendLiteral("kHz"); break;
|
2000-08-23 21:27:06 +04:00
|
|
|
|
|
|
|
case eCSSUnit_Seconds: aResult.Append(PRUnichar('s')); break;
|
2004-06-17 04:13:25 +04:00
|
|
|
case eCSSUnit_Milliseconds: aResult.AppendLiteral("ms"); break;
|
1998-10-08 05:31:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsresult
|
|
|
|
nsCSSDeclaration::GetValue(nsCSSProperty aProperty,
|
2003-06-08 02:14:42 +04:00
|
|
|
nsAString& aValue) const
|
1998-10-08 05:31:58 +04:00
|
|
|
{
|
|
|
|
aValue.Truncate(0);
|
1998-09-30 05:08:59 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
// simple properties are easy.
|
2004-10-01 02:32:28 +04:00
|
|
|
if (!nsCSSProps::IsShorthand(aProperty)) {
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(aProperty, aValue);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-08 05:31:58 +04:00
|
|
|
// shorthands
|
2007-06-12 22:28:56 +04:00
|
|
|
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(p, aProperty) {
|
|
|
|
if (!mData->StorageFor(*p) &&
|
|
|
|
(!mImportantData || !mImportantData->StorageFor(*p)))
|
|
|
|
// We don't have all the properties in the shorthand.
|
|
|
|
if (*p != eCSSProperty__x_system_font)
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
// XXX What about checking the consistency of '!important'?
|
2007-06-12 22:28:56 +04:00
|
|
|
// XXX What about checking that we don't serialize inherit,
|
|
|
|
// -moz-initial, or other illegal values?
|
2004-08-26 21:11:20 +04:00
|
|
|
// XXXldb Can we share shorthand logic with ToString?
|
1998-10-08 05:31:58 +04:00
|
|
|
switch (aProperty) {
|
2003-06-08 02:14:42 +04:00
|
|
|
case eCSSProperty_margin:
|
|
|
|
case eCSSProperty_padding:
|
|
|
|
case eCSSProperty_border_color:
|
|
|
|
case eCSSProperty_border_style:
|
|
|
|
case eCSSProperty__moz_border_radius:
|
|
|
|
case eCSSProperty__moz_outline_radius:
|
|
|
|
case eCSSProperty_border_width: {
|
|
|
|
const nsCSSProperty* subprops =
|
|
|
|
nsCSSProps::SubpropertyEntryFor(aProperty);
|
|
|
|
NS_ASSERTION(nsCSSProps::kTypeTable[subprops[0]] == eCSSType_Value &&
|
|
|
|
nsCSSProps::kTypeTable[subprops[1]] == eCSSType_Value &&
|
|
|
|
nsCSSProps::kTypeTable[subprops[2]] == eCSSType_Value &&
|
|
|
|
nsCSSProps::kTypeTable[subprops[3]] == eCSSType_Value,
|
|
|
|
"type mismatch");
|
|
|
|
if (!AppendValueToString(subprops[0], aValue) ||
|
|
|
|
!(aValue.Append(PRUnichar(' ')),
|
|
|
|
AppendValueToString(subprops[1], aValue)) ||
|
|
|
|
!(aValue.Append(PRUnichar(' ')),
|
|
|
|
AppendValueToString(subprops[2], aValue)) ||
|
|
|
|
!(aValue.Append(PRUnichar(' ')),
|
|
|
|
AppendValueToString(subprops[3], aValue))) {
|
|
|
|
aValue.Truncate();
|
1998-10-08 05:31:58 +04:00
|
|
|
}
|
|
|
|
break;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
1999-07-18 04:25:28 +04:00
|
|
|
case eCSSProperty_border:
|
2003-06-08 02:14:42 +04:00
|
|
|
// XXX More consistency checking needed before falling through.
|
|
|
|
aProperty = eCSSProperty_border_top;
|
|
|
|
case eCSSProperty_border_top:
|
|
|
|
case eCSSProperty_border_right:
|
|
|
|
case eCSSProperty_border_bottom:
|
|
|
|
case eCSSProperty_border_left:
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_start:
|
|
|
|
case eCSSProperty_border_end:
|
2008-07-19 14:38:25 +04:00
|
|
|
case eCSSProperty__moz_column_rule:
|
2005-03-27 15:36:08 +04:00
|
|
|
case eCSSProperty_outline: {
|
2003-06-08 02:14:42 +04:00
|
|
|
const nsCSSProperty* subprops =
|
|
|
|
nsCSSProps::SubpropertyEntryFor(aProperty);
|
|
|
|
NS_ASSERTION(nsCSSProps::kTypeTable[subprops[0]] == eCSSType_Value &&
|
|
|
|
nsCSSProps::kTypeTable[subprops[1]] == eCSSType_Value &&
|
|
|
|
nsCSSProps::kTypeTable[subprops[2]] == eCSSType_Value,
|
|
|
|
"type mismatch");
|
|
|
|
if (!AppendValueToString(subprops[0], aValue) ||
|
|
|
|
!(aValue.Append(PRUnichar(' ')),
|
|
|
|
AppendValueToString(subprops[1], aValue)) ||
|
|
|
|
!(aValue.Append(PRUnichar(' ')),
|
|
|
|
AppendValueToString(subprops[2], aValue))) {
|
|
|
|
aValue.Truncate();
|
1998-10-08 05:31:58 +04:00
|
|
|
}
|
|
|
|
break;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
2004-02-04 09:10:56 +03:00
|
|
|
case eCSSProperty_margin_left:
|
|
|
|
case eCSSProperty_margin_right:
|
|
|
|
case eCSSProperty_margin_start:
|
|
|
|
case eCSSProperty_margin_end:
|
|
|
|
case eCSSProperty_padding_left:
|
|
|
|
case eCSSProperty_padding_right:
|
|
|
|
case eCSSProperty_padding_start:
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_padding_end:
|
|
|
|
case eCSSProperty_border_left_color:
|
|
|
|
case eCSSProperty_border_left_style:
|
|
|
|
case eCSSProperty_border_left_width:
|
|
|
|
case eCSSProperty_border_right_color:
|
|
|
|
case eCSSProperty_border_right_style:
|
|
|
|
case eCSSProperty_border_right_width:
|
|
|
|
case eCSSProperty_border_start_color:
|
|
|
|
case eCSSProperty_border_start_style:
|
|
|
|
case eCSSProperty_border_start_width:
|
|
|
|
case eCSSProperty_border_end_color:
|
|
|
|
case eCSSProperty_border_end_style:
|
|
|
|
case eCSSProperty_border_end_width: {
|
2004-02-04 09:10:56 +03:00
|
|
|
const nsCSSProperty* subprops =
|
|
|
|
nsCSSProps::SubpropertyEntryFor(aProperty);
|
|
|
|
NS_ASSERTION(subprops[3] == eCSSProperty_UNKNOWN,
|
|
|
|
"not box property with physical vs. logical cascading");
|
|
|
|
AppendValueToString(subprops[0], aValue);
|
|
|
|
break;
|
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
case eCSSProperty_background: {
|
2007-03-06 09:59:39 +03:00
|
|
|
PRBool appendedSomething = PR_FALSE;
|
|
|
|
if (AppendValueToString(eCSSProperty_background_color, aValue)) {
|
|
|
|
appendedSomething = PR_TRUE;
|
2003-06-08 02:14:42 +04:00
|
|
|
aValue.Append(PRUnichar(' '));
|
2007-03-06 09:59:39 +03:00
|
|
|
}
|
|
|
|
if (AppendValueToString(eCSSProperty_background_image, aValue)) {
|
2003-06-08 02:14:42 +04:00
|
|
|
aValue.Append(PRUnichar(' '));
|
2007-03-06 09:59:39 +03:00
|
|
|
appendedSomething = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (AppendValueToString(eCSSProperty_background_repeat, aValue)) {
|
2000-08-23 21:27:06 +04:00
|
|
|
aValue.Append(PRUnichar(' '));
|
2007-03-06 09:59:39 +03:00
|
|
|
appendedSomething = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (AppendValueToString(eCSSProperty_background_attachment, aValue)) {
|
2003-06-08 02:14:42 +04:00
|
|
|
aValue.Append(PRUnichar(' '));
|
2007-03-06 09:59:39 +03:00
|
|
|
appendedSomething = PR_TRUE;
|
|
|
|
}
|
2007-04-16 02:25:20 +04:00
|
|
|
if (!AppendValueToString(eCSSProperty_background_position, aValue) &&
|
|
|
|
appendedSomething) {
|
2007-03-06 09:59:39 +03:00
|
|
|
NS_ASSERTION(!aValue.IsEmpty() && aValue.Last() == PRUnichar(' '),
|
|
|
|
"We appended a space before!");
|
|
|
|
// We appended an extra space. Let's get rid of it
|
|
|
|
aValue.Truncate(aValue.Length() - 1);
|
1998-10-08 05:31:58 +04:00
|
|
|
}
|
|
|
|
break;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
case eCSSProperty_cue: {
|
2007-04-21 04:16:52 +04:00
|
|
|
if (AppendValueToString(eCSSProperty_cue_before, aValue)) {
|
2000-08-23 21:27:06 +04:00
|
|
|
aValue.Append(PRUnichar(' '));
|
2007-04-21 04:16:52 +04:00
|
|
|
if (!AppendValueToString(eCSSProperty_cue_after, aValue))
|
2003-06-08 02:14:42 +04:00
|
|
|
aValue.Truncate();
|
1998-10-08 05:31:58 +04:00
|
|
|
}
|
|
|
|
break;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
case eCSSProperty_font: {
|
2007-06-12 22:28:56 +04:00
|
|
|
nsCSSValue style, variant, weight, size, lh, family, systemFont;
|
|
|
|
GetValueOrImportantValue(eCSSProperty__x_system_font, systemFont);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_font_style, style);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_font_variant, variant);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_font_weight, weight);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_font_size, size);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_line_height, lh);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_font_family, family);
|
|
|
|
|
|
|
|
if (systemFont.GetUnit() != eCSSUnit_None &&
|
|
|
|
systemFont.GetUnit() != eCSSUnit_Null) {
|
|
|
|
AppendCSSValueToString(eCSSProperty__x_system_font, systemFont, aValue);
|
2007-03-23 02:01:14 +03:00
|
|
|
} else {
|
2007-06-12 22:28:56 +04:00
|
|
|
if (style.GetUnit() != eCSSUnit_Normal) {
|
|
|
|
AppendCSSValueToString(eCSSProperty_font_style, style, aValue);
|
|
|
|
aValue.Append(PRUnichar(' '));
|
|
|
|
}
|
|
|
|
if (variant.GetUnit() != eCSSUnit_Normal) {
|
|
|
|
AppendCSSValueToString(eCSSProperty_font_variant, variant, aValue);
|
|
|
|
aValue.Append(PRUnichar(' '));
|
|
|
|
}
|
|
|
|
if (weight.GetUnit() != eCSSUnit_Normal) {
|
|
|
|
AppendCSSValueToString(eCSSProperty_font_weight, weight, aValue);
|
|
|
|
aValue.Append(PRUnichar(' '));
|
|
|
|
}
|
|
|
|
AppendCSSValueToString(eCSSProperty_font_size, size, aValue);
|
|
|
|
if (lh.GetUnit() != eCSSUnit_Normal) {
|
|
|
|
aValue.Append(PRUnichar('/'));
|
|
|
|
AppendCSSValueToString(eCSSProperty_line_height, lh, aValue);
|
|
|
|
}
|
|
|
|
aValue.Append(PRUnichar(' '));
|
|
|
|
AppendCSSValueToString(eCSSProperty_font_family, family, aValue);
|
2001-12-05 11:35:05 +03:00
|
|
|
}
|
|
|
|
break;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
1999-07-18 04:25:28 +04:00
|
|
|
case eCSSProperty_list_style:
|
2003-06-08 02:14:42 +04:00
|
|
|
if (AppendValueToString(eCSSProperty_list_style_type, aValue))
|
|
|
|
aValue.Append(PRUnichar(' '));
|
|
|
|
if (AppendValueToString(eCSSProperty_list_style_position, aValue))
|
|
|
|
aValue.Append(PRUnichar(' '));
|
1999-07-18 04:25:28 +04:00
|
|
|
AppendValueToString(eCSSProperty_list_style_image, aValue);
|
1998-10-08 05:31:58 +04:00
|
|
|
break;
|
2004-09-05 04:04:04 +04:00
|
|
|
case eCSSProperty_overflow: {
|
|
|
|
nsCSSValue xValue, yValue;
|
|
|
|
GetValueOrImportantValue(eCSSProperty_overflow_x, xValue);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_overflow_y, yValue);
|
|
|
|
if (xValue == yValue)
|
|
|
|
AppendValueToString(eCSSProperty_overflow_x, aValue);
|
|
|
|
break;
|
|
|
|
}
|
2002-01-16 01:43:37 +03:00
|
|
|
case eCSSProperty_pause: {
|
2007-04-21 04:16:52 +04:00
|
|
|
if (AppendValueToString(eCSSProperty_pause_before, aValue)) {
|
2000-08-23 21:27:06 +04:00
|
|
|
aValue.Append(PRUnichar(' '));
|
2007-04-21 04:16:52 +04:00
|
|
|
if (!AppendValueToString(eCSSProperty_pause_after, aValue))
|
2003-06-08 02:14:42 +04:00
|
|
|
aValue.Truncate();
|
1998-10-08 05:31:58 +04:00
|
|
|
}
|
|
|
|
break;
|
2002-01-16 01:43:37 +03:00
|
|
|
}
|
2004-12-09 06:16:15 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
case eCSSProperty_marker: {
|
|
|
|
nsCSSValue endValue, midValue, startValue;
|
|
|
|
GetValueOrImportantValue(eCSSProperty_marker_end, endValue);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_marker_mid, midValue);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_marker_start, startValue);
|
|
|
|
if (endValue == midValue && midValue == startValue)
|
|
|
|
AppendValueToString(eCSSProperty_marker_end, aValue);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
1998-10-08 05:31:58 +04:00
|
|
|
default:
|
2003-06-08 02:14:42 +04:00
|
|
|
NS_NOTREACHED("no other shorthands");
|
1998-10-08 05:31:58 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-09-30 05:08:59 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
PRBool
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSDeclaration::GetValueIsImportant(const nsAString& aProperty) const
|
1998-11-06 03:56:28 +03:00
|
|
|
{
|
1999-07-18 04:25:28 +04:00
|
|
|
nsCSSProperty propID = nsCSSProps::LookupProperty(aProperty);
|
2002-01-16 01:43:37 +03:00
|
|
|
return GetValueIsImportant(propID);
|
1998-11-06 03:56:28 +03:00
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
PRBool
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSDeclaration::GetValueIsImportant(nsCSSProperty aProperty) const
|
1998-07-15 02:34:27 +04:00
|
|
|
{
|
2003-06-08 02:14:42 +04:00
|
|
|
if (!mImportantData)
|
|
|
|
return PR_FALSE;
|
1998-07-15 02:34:27 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
// Inefficient, but we can assume '!important' is rare.
|
|
|
|
return mImportantData->StorageFor(aProperty) != nsnull;
|
1998-07-15 02:34:27 +04:00
|
|
|
}
|
|
|
|
|
2007-04-16 02:25:20 +04:00
|
|
|
// XXXldb Bug 376075 All callers of AllPropertiesSameImportance also
|
|
|
|
// need to check for 'inherit' and 'initial' values, since you can't
|
|
|
|
// output a mix of either mixed with other values in the same shorthand!
|
2002-05-21 12:16:42 +04:00
|
|
|
PRBool
|
|
|
|
nsCSSDeclaration::AllPropertiesSameImportance(PRInt32 aFirst, PRInt32 aSecond,
|
|
|
|
PRInt32 aThird, PRInt32 aFourth,
|
2007-04-16 02:25:20 +04:00
|
|
|
PRInt32 aFifth,
|
2003-06-08 02:14:42 +04:00
|
|
|
PRBool & aImportance) const
|
2002-05-21 12:16:42 +04:00
|
|
|
{
|
2003-06-08 02:14:42 +04:00
|
|
|
aImportance = GetValueIsImportant(OrderValueAt(aFirst-1));
|
|
|
|
if ((aSecond && aImportance != GetValueIsImportant(OrderValueAt(aSecond-1))) ||
|
|
|
|
(aThird && aImportance != GetValueIsImportant(OrderValueAt(aThird-1))) ||
|
|
|
|
(aFourth && aImportance != GetValueIsImportant(OrderValueAt(aFourth-1))) ||
|
2007-04-16 02:25:20 +04:00
|
|
|
(aFifth && aImportance != GetValueIsImportant(OrderValueAt(aFifth-1)))) {
|
2002-05-21 12:16:42 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
2001-10-24 12:08:30 +04:00
|
|
|
|
|
|
|
PRBool
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration::AllPropertiesSameValue(PRInt32 aFirst, PRInt32 aSecond,
|
2003-06-08 02:14:42 +04:00
|
|
|
PRInt32 aThird, PRInt32 aFourth) const
|
2001-10-24 12:08:30 +04:00
|
|
|
{
|
|
|
|
nsCSSValue firstValue, otherValue;
|
2001-12-21 04:10:07 +03:00
|
|
|
// TryBorderShorthand does the bounds-checking for us; valid values there
|
|
|
|
// are > 0; 0 is a flag for "not set". We here are passed the actual
|
|
|
|
// index, which comes from finding the value in the mOrder property array.
|
|
|
|
// Of course, re-getting the mOrder value here is pretty silly.
|
2003-06-08 02:14:42 +04:00
|
|
|
GetValueOrImportantValue(OrderValueAt(aFirst-1), firstValue);
|
|
|
|
GetValueOrImportantValue(OrderValueAt(aSecond-1), otherValue);
|
2001-10-24 12:08:30 +04:00
|
|
|
if (firstValue != otherValue) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
GetValueOrImportantValue(OrderValueAt(aThird-1), otherValue);
|
2001-10-24 12:08:30 +04:00
|
|
|
if (firstValue != otherValue) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2003-06-08 02:14:42 +04:00
|
|
|
GetValueOrImportantValue(OrderValueAt(aFourth-1), otherValue);
|
2001-10-24 12:08:30 +04:00
|
|
|
if (firstValue != otherValue) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2006-05-03 03:36:17 +04:00
|
|
|
/* static */ void
|
|
|
|
nsCSSDeclaration::AppendImportanceToString(PRBool aIsImportant,
|
|
|
|
nsAString& aString)
|
2002-05-21 12:16:42 +04:00
|
|
|
{
|
|
|
|
if (aIsImportant) {
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral(" ! important");
|
2002-05-21 12:16:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-24 12:08:30 +04:00
|
|
|
void
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration::AppendPropertyAndValueToString(nsCSSProperty aProperty,
|
2004-02-05 03:19:19 +03:00
|
|
|
nsCSSProperty aPropertyName,
|
|
|
|
nsAString& aResult) const
|
2001-10-24 12:08:30 +04:00
|
|
|
{
|
2004-03-09 03:52:54 +03:00
|
|
|
NS_ASSERTION(0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands,
|
|
|
|
"property enum out of range");
|
2004-02-05 03:19:19 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(aPropertyName), aResult);
|
2004-06-17 04:13:25 +04:00
|
|
|
aResult.AppendLiteral(": ");
|
2004-02-05 03:19:19 +03:00
|
|
|
AppendValueToString(aProperty, aResult);
|
2002-05-21 12:16:42 +04:00
|
|
|
PRBool isImportant = GetValueIsImportant(aProperty);
|
2004-02-05 03:19:19 +03:00
|
|
|
AppendImportanceToString(isImportant, aResult);
|
2004-06-17 04:13:25 +04:00
|
|
|
aResult.AppendLiteral("; ");
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
|
|
|
|
2002-05-21 12:16:42 +04:00
|
|
|
PRBool
|
|
|
|
nsCSSDeclaration::TryBorderShorthand(nsAString & aString, PRUint32 aPropertiesSet,
|
|
|
|
PRInt32 aBorderTopWidth,
|
|
|
|
PRInt32 aBorderTopStyle,
|
|
|
|
PRInt32 aBorderTopColor,
|
|
|
|
PRInt32 aBorderBottomWidth,
|
|
|
|
PRInt32 aBorderBottomStyle,
|
|
|
|
PRInt32 aBorderBottomColor,
|
|
|
|
PRInt32 aBorderLeftWidth,
|
|
|
|
PRInt32 aBorderLeftStyle,
|
|
|
|
PRInt32 aBorderLeftColor,
|
|
|
|
PRInt32 aBorderRightWidth,
|
|
|
|
PRInt32 aBorderRightStyle,
|
2003-06-08 02:14:42 +04:00
|
|
|
PRInt32 aBorderRightColor) const
|
2001-10-24 12:08:30 +04:00
|
|
|
{
|
2002-05-21 17:33:25 +04:00
|
|
|
PRBool border = PR_FALSE, isImportant = PR_FALSE;
|
2001-12-21 04:10:07 +03:00
|
|
|
// 0 means not in the mOrder array; otherwise it's index+1
|
2002-05-21 12:16:42 +04:00
|
|
|
if (B_BORDER == aPropertiesSet
|
|
|
|
&& AllPropertiesSameValue(aBorderTopWidth, aBorderBottomWidth,
|
|
|
|
aBorderLeftWidth, aBorderRightWidth)
|
|
|
|
&& AllPropertiesSameValue(aBorderTopStyle, aBorderBottomStyle,
|
|
|
|
aBorderLeftStyle, aBorderRightStyle)
|
|
|
|
&& AllPropertiesSameValue(aBorderTopColor, aBorderBottomColor,
|
|
|
|
aBorderLeftColor, aBorderRightColor)) {
|
|
|
|
border = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (border) {
|
|
|
|
border = PR_FALSE;
|
|
|
|
PRBool isWidthImportant, isStyleImportant, isColorImportant;
|
|
|
|
if (AllPropertiesSameImportance(aBorderTopWidth, aBorderBottomWidth,
|
|
|
|
aBorderLeftWidth, aBorderRightWidth,
|
2007-04-16 02:25:20 +04:00
|
|
|
0,
|
2002-05-21 12:16:42 +04:00
|
|
|
isWidthImportant) &&
|
|
|
|
AllPropertiesSameImportance(aBorderTopStyle, aBorderBottomStyle,
|
|
|
|
aBorderLeftStyle, aBorderRightStyle,
|
2007-04-16 02:25:20 +04:00
|
|
|
0,
|
2002-05-21 12:16:42 +04:00
|
|
|
isStyleImportant) &&
|
|
|
|
AllPropertiesSameImportance(aBorderTopColor, aBorderBottomColor,
|
|
|
|
aBorderLeftColor, aBorderRightColor,
|
2007-04-16 02:25:20 +04:00
|
|
|
0,
|
2002-05-21 12:16:42 +04:00
|
|
|
isColorImportant)) {
|
|
|
|
if (isWidthImportant == isStyleImportant && isWidthImportant == isColorImportant) {
|
|
|
|
border = PR_TRUE;
|
|
|
|
isImportant = isWidthImportant;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-10-24 12:08:30 +04:00
|
|
|
if (border) {
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(eCSSProperty_border), aString);
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral(": ");
|
2002-05-21 12:16:42 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(eCSSProperty_border_top_width, aString);
|
2002-05-21 12:16:42 +04:00
|
|
|
aString.Append(PRUnichar(' '));
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(eCSSProperty_border_top_style, aString);
|
2002-05-21 12:16:42 +04:00
|
|
|
aString.Append(PRUnichar(' '));
|
|
|
|
|
|
|
|
nsAutoString valueString;
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(eCSSProperty_border_top_color, valueString);
|
2004-05-23 02:15:22 +04:00
|
|
|
if (!valueString.EqualsLiteral("-moz-use-text-color")) {
|
2002-05-21 12:16:42 +04:00
|
|
|
/* don't output this value, it's proprietary Mozilla and */
|
|
|
|
/* not intended to be exposed ; we can remove it from the */
|
|
|
|
/* values of the shorthand since this value represents the */
|
|
|
|
/* initial value of border-*-color */
|
|
|
|
aString.Append(valueString);
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
2002-05-21 12:16:42 +04:00
|
|
|
AppendImportanceToString(isImportant, aString);
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral("; ");
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
2002-05-21 12:16:42 +04:00
|
|
|
return border;
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
|
|
|
|
2002-05-21 12:16:42 +04:00
|
|
|
PRBool
|
2002-03-24 01:56:05 +03:00
|
|
|
nsCSSDeclaration::TryBorderSideShorthand(nsAString & aString,
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSProperty aShorthand,
|
2002-05-21 12:16:42 +04:00
|
|
|
PRInt32 aBorderWidth,
|
|
|
|
PRInt32 aBorderStyle,
|
2003-06-08 02:14:42 +04:00
|
|
|
PRInt32 aBorderColor) const
|
2001-10-24 12:08:30 +04:00
|
|
|
{
|
2002-05-21 12:16:42 +04:00
|
|
|
PRBool isImportant;
|
|
|
|
if (AllPropertiesSameImportance(aBorderWidth, aBorderStyle, aBorderColor,
|
2007-04-16 02:25:20 +04:00
|
|
|
0, 0,
|
2002-05-21 12:16:42 +04:00
|
|
|
isImportant)) {
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(aShorthand), aString);
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral(": ");
|
2003-11-01 13:57:41 +03:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(OrderValueAt(aBorderWidth-1), aString);
|
2002-05-21 12:16:42 +04:00
|
|
|
|
|
|
|
aString.Append(PRUnichar(' '));
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(OrderValueAt(aBorderStyle-1), aString);
|
2002-05-21 12:16:42 +04:00
|
|
|
|
|
|
|
nsAutoString valueString;
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(OrderValueAt(aBorderColor-1), valueString);
|
2004-05-23 02:15:22 +04:00
|
|
|
if (!valueString.EqualsLiteral("-moz-use-text-color")) {
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral(" ");
|
2002-05-21 12:16:42 +04:00
|
|
|
aString.Append(valueString);
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
2002-05-21 12:16:42 +04:00
|
|
|
AppendImportanceToString(isImportant, aString);
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral("; ");
|
2002-05-21 12:16:42 +04:00
|
|
|
return PR_TRUE;
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
2002-05-21 12:16:42 +04:00
|
|
|
return PR_FALSE;
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
|
|
|
|
2002-05-21 12:16:42 +04:00
|
|
|
PRBool
|
|
|
|
nsCSSDeclaration::TryFourSidesShorthand(nsAString & aString,
|
|
|
|
nsCSSProperty aShorthand,
|
|
|
|
PRInt32 & aTop,
|
|
|
|
PRInt32 & aBottom,
|
|
|
|
PRInt32 & aLeft,
|
|
|
|
PRInt32 & aRight,
|
2003-06-08 02:14:42 +04:00
|
|
|
PRBool aClearIndexes) const
|
2001-10-24 12:08:30 +04:00
|
|
|
{
|
2001-12-21 04:10:07 +03:00
|
|
|
// 0 means not in the mOrder array; otherwise it's index+1
|
2002-05-21 12:16:42 +04:00
|
|
|
PRBool isImportant;
|
|
|
|
if (aTop && aBottom && aLeft && aRight &&
|
|
|
|
AllPropertiesSameImportance(aTop, aBottom, aLeft, aRight,
|
2007-04-16 02:25:20 +04:00
|
|
|
0,
|
2002-05-21 12:16:42 +04:00
|
|
|
isImportant)) {
|
2001-10-24 12:08:30 +04:00
|
|
|
// all 4 properties are set, we can output a shorthand
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(aShorthand), aString);
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral(": ");
|
2001-10-24 12:08:30 +04:00
|
|
|
nsCSSValue topValue, bottomValue, leftValue, rightValue;
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSProperty topProp = OrderValueAt(aTop-1);
|
|
|
|
nsCSSProperty bottomProp = OrderValueAt(aBottom-1);
|
|
|
|
nsCSSProperty leftProp = OrderValueAt(aLeft-1);
|
|
|
|
nsCSSProperty rightProp = OrderValueAt(aRight-1);
|
2002-06-14 16:36:43 +04:00
|
|
|
GetValueOrImportantValue(topProp, topValue);
|
|
|
|
GetValueOrImportantValue(bottomProp, bottomValue);
|
|
|
|
GetValueOrImportantValue(leftProp, leftValue);
|
|
|
|
GetValueOrImportantValue(rightProp, rightValue);
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendCSSValueToString(topProp, topValue, aString);
|
2001-10-24 12:08:30 +04:00
|
|
|
if (topValue != rightValue || topValue != leftValue || topValue != bottomValue) {
|
|
|
|
aString.Append(PRUnichar(' '));
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendCSSValueToString(rightProp, rightValue, aString);
|
2001-10-24 12:08:30 +04:00
|
|
|
if (topValue != bottomValue || rightValue != leftValue) {
|
|
|
|
aString.Append(PRUnichar(' '));
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendCSSValueToString(bottomProp, bottomValue, aString);
|
2001-10-24 12:08:30 +04:00
|
|
|
if (rightValue != leftValue) {
|
|
|
|
aString.Append(PRUnichar(' '));
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendCSSValueToString(leftProp, leftValue, aString);
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-05-21 12:16:42 +04:00
|
|
|
if (aClearIndexes) {
|
|
|
|
aTop = 0; aBottom = 0; aLeft = 0; aRight = 0;
|
|
|
|
}
|
|
|
|
AppendImportanceToString(isImportant, aString);
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral("; ");
|
2002-05-21 12:16:42 +04:00
|
|
|
return PR_TRUE;
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
2002-05-21 12:16:42 +04:00
|
|
|
return PR_FALSE;
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-24 01:56:05 +03:00
|
|
|
nsCSSDeclaration::TryBackgroundShorthand(nsAString & aString,
|
2002-01-16 01:43:37 +03:00
|
|
|
PRInt32 & aBgColor,
|
|
|
|
PRInt32 & aBgImage,
|
|
|
|
PRInt32 & aBgRepeat,
|
|
|
|
PRInt32 & aBgAttachment,
|
2007-04-16 02:25:20 +04:00
|
|
|
PRInt32 & aBgPosition) const
|
2001-10-24 12:08:30 +04:00
|
|
|
{
|
2001-12-21 04:10:07 +03:00
|
|
|
// 0 means not in the mOrder array; otherwise it's index+1
|
2001-10-24 12:08:30 +04:00
|
|
|
// check if we have at least two properties set; otherwise, no need to
|
|
|
|
// use a shorthand
|
2002-05-21 12:16:42 +04:00
|
|
|
PRBool isImportant;
|
2007-04-16 02:25:20 +04:00
|
|
|
if (aBgColor && aBgImage && aBgRepeat && aBgAttachment && aBgPosition &&
|
2002-05-21 12:16:42 +04:00
|
|
|
AllPropertiesSameImportance(aBgColor, aBgImage, aBgRepeat, aBgAttachment,
|
2007-04-16 02:25:20 +04:00
|
|
|
aBgPosition, isImportant)) {
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(eCSSProperty_background), aString);
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral(": ");
|
2002-05-21 12:16:42 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(eCSSProperty_background_color, aString);
|
2002-05-21 12:16:42 +04:00
|
|
|
aBgColor = 0;
|
|
|
|
|
|
|
|
aString.Append(PRUnichar(' '));
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(eCSSProperty_background_image, aString);
|
2002-05-21 12:16:42 +04:00
|
|
|
aBgImage = 0;
|
|
|
|
|
|
|
|
aString.Append(PRUnichar(' '));
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(eCSSProperty_background_repeat, aString);
|
2002-05-21 12:16:42 +04:00
|
|
|
aBgRepeat = 0;
|
|
|
|
|
|
|
|
aString.Append(PRUnichar(' '));
|
2003-06-08 02:14:42 +04:00
|
|
|
AppendValueToString(eCSSProperty_background_attachment, aString);
|
2002-05-21 12:16:42 +04:00
|
|
|
aBgAttachment = 0;
|
|
|
|
|
|
|
|
aString.Append(PRUnichar(' '));
|
2007-04-16 02:25:20 +04:00
|
|
|
AppendValueToString(eCSSProperty_background_position, aString);
|
|
|
|
aBgPosition = 0;
|
|
|
|
|
2002-05-21 12:16:42 +04:00
|
|
|
AppendImportanceToString(isImportant, aString);
|
2004-06-17 04:13:25 +04:00
|
|
|
aString.AppendLiteral("; ");
|
2001-10-24 12:08:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-05 04:04:04 +04:00
|
|
|
void
|
|
|
|
nsCSSDeclaration::TryOverflowShorthand(nsAString & aString,
|
|
|
|
PRInt32 & aOverflowX,
|
|
|
|
PRInt32 & aOverflowY) const
|
|
|
|
{
|
|
|
|
PRBool isImportant;
|
|
|
|
if (aOverflowX && aOverflowY &&
|
|
|
|
AllPropertiesSameImportance(aOverflowX, aOverflowY,
|
2007-04-16 02:25:20 +04:00
|
|
|
0, 0, 0, isImportant)) {
|
2004-09-05 04:04:04 +04:00
|
|
|
nsCSSValue xValue, yValue;
|
|
|
|
GetValueOrImportantValue(eCSSProperty_overflow_x, xValue);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_overflow_y, yValue);
|
|
|
|
if (xValue == yValue) {
|
2004-09-08 09:42:03 +04:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(eCSSProperty_overflow),
|
|
|
|
aString);
|
|
|
|
aString.AppendLiteral(": ");
|
|
|
|
|
2004-09-05 04:04:04 +04:00
|
|
|
AppendCSSValueToString(eCSSProperty_overflow_x, xValue, aString);
|
|
|
|
AppendImportanceToString(isImportant, aString);
|
|
|
|
aString.AppendLiteral("; ");
|
|
|
|
aOverflowX = aOverflowY = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-09 06:16:15 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
void
|
|
|
|
nsCSSDeclaration::TryMarkerShorthand(nsAString & aString,
|
|
|
|
PRInt32 & aMarkerEnd,
|
|
|
|
PRInt32 & aMarkerMid,
|
|
|
|
PRInt32 & aMarkerStart) const
|
|
|
|
{
|
|
|
|
PRBool isImportant;
|
|
|
|
if (aMarkerEnd && aMarkerMid && aMarkerEnd &&
|
|
|
|
AllPropertiesSameImportance(aMarkerEnd, aMarkerMid, aMarkerStart,
|
2007-04-16 02:25:20 +04:00
|
|
|
0, 0, isImportant)) {
|
2004-12-09 06:16:15 +03:00
|
|
|
nsCSSValue endValue, midValue, startValue;
|
|
|
|
GetValueOrImportantValue(eCSSProperty_marker_end, endValue);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_marker_mid, midValue);
|
|
|
|
GetValueOrImportantValue(eCSSProperty_marker_start, startValue);
|
|
|
|
if (endValue == midValue && midValue == startValue) {
|
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(eCSSProperty_marker),
|
|
|
|
aString);
|
|
|
|
aString.AppendLiteral(": ");
|
|
|
|
|
|
|
|
AppendCSSValueToString(eCSSProperty_marker_end, endValue, aString);
|
|
|
|
AppendImportanceToString(isImportant, aString);
|
|
|
|
aString.AppendLiteral("; ");
|
|
|
|
aMarkerEnd = aMarkerMid = aMarkerStart = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-10-24 12:08:30 +04:00
|
|
|
#define NS_CASE_OUTPUT_PROPERTY_VALUE(_prop, _index) \
|
|
|
|
case _prop: \
|
|
|
|
if (_index) { \
|
|
|
|
AppendPropertyAndValueToString(property, aString); \
|
|
|
|
_index = 0; \
|
|
|
|
} \
|
|
|
|
break;
|
|
|
|
|
2004-02-05 03:19:19 +03:00
|
|
|
#define NS_CASE_OUTPUT_PROPERTY_VALUE_AS(_prop, _propas, _index) \
|
|
|
|
case _prop: \
|
|
|
|
if (_index) { \
|
|
|
|
AppendPropertyAndValueToString(property, _propas, aString); \
|
|
|
|
_index = 0; \
|
|
|
|
} \
|
|
|
|
break;
|
|
|
|
|
2002-05-21 12:16:42 +04:00
|
|
|
#define NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE(_condition, _prop, _index) \
|
|
|
|
case _prop: \
|
|
|
|
if ((_condition) && _index) { \
|
|
|
|
AppendPropertyAndValueToString(property, aString); \
|
|
|
|
_index = 0; \
|
|
|
|
} \
|
|
|
|
break;
|
|
|
|
|
2007-07-04 22:51:16 +04:00
|
|
|
#define NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE_AS(_condition, _prop, _propas, _index) \
|
|
|
|
case _prop: \
|
|
|
|
if ((_condition) && _index) { \
|
|
|
|
AppendPropertyAndValueToString(property, _propas, aString); \
|
|
|
|
_index = 0; \
|
|
|
|
} \
|
|
|
|
break;
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
void nsCSSDeclaration::PropertyIsSet(PRInt32 & aPropertyIndex, PRInt32 aIndex, PRUint32 & aSet, PRUint32 aValue) const
|
2002-05-21 12:16:42 +04:00
|
|
|
{
|
|
|
|
aPropertyIndex = aIndex + 1;
|
|
|
|
aSet |= aValue;
|
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsresult
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSDeclaration::ToString(nsAString& aString) const
|
1998-07-15 02:34:27 +04:00
|
|
|
{
|
2008-01-10 23:13:24 +03:00
|
|
|
PRInt32 count = mOrder.Length();
|
2003-06-08 02:14:42 +04:00
|
|
|
PRInt32 index;
|
|
|
|
// 0 means not in the mOrder array; otherwise it's index+1
|
|
|
|
PRInt32 borderTopWidth = 0, borderTopStyle = 0, borderTopColor = 0;
|
|
|
|
PRInt32 borderBottomWidth = 0, borderBottomStyle = 0, borderBottomColor = 0;
|
|
|
|
PRInt32 borderLeftWidth = 0, borderLeftStyle = 0, borderLeftColor = 0;
|
|
|
|
PRInt32 borderRightWidth = 0, borderRightStyle = 0, borderRightColor = 0;
|
2007-07-04 22:51:16 +04:00
|
|
|
PRInt32 borderStartWidth = 0, borderStartStyle = 0, borderStartColor = 0;
|
|
|
|
PRInt32 borderEndWidth = 0, borderEndStyle = 0, borderEndColor = 0;
|
2003-06-08 02:14:42 +04:00
|
|
|
PRInt32 marginTop = 0, marginBottom = 0, marginLeft = 0, marginRight = 0;
|
|
|
|
PRInt32 paddingTop = 0, paddingBottom = 0, paddingLeft = 0, paddingRight = 0;
|
|
|
|
PRInt32 bgColor = 0, bgImage = 0, bgRepeat = 0, bgAttachment = 0;
|
2007-04-16 02:25:20 +04:00
|
|
|
PRInt32 bgPosition = 0;
|
2004-09-05 04:04:04 +04:00
|
|
|
PRInt32 overflowX = 0, overflowY = 0;
|
2008-07-19 14:38:25 +04:00
|
|
|
PRInt32 columnRuleWidth = 0, columnRuleStyle = 0, columnRuleColor = 0;
|
2003-06-08 02:14:42 +04:00
|
|
|
PRUint32 borderPropertiesSet = 0, finalBorderPropertiesToSet = 0;
|
2004-12-09 06:16:15 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
PRInt32 markerEnd = 0, markerMid = 0, markerStart = 0;
|
|
|
|
#endif
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
nsCSSProperty property = OrderValueAt(index);
|
|
|
|
switch (property) {
|
|
|
|
case eCSSProperty_border_top_width:
|
|
|
|
PropertyIsSet(borderTopWidth, index, borderPropertiesSet, B_BORDER_TOP_WIDTH);
|
|
|
|
break;
|
|
|
|
case eCSSProperty_border_bottom_width:
|
|
|
|
PropertyIsSet(borderBottomWidth, index, borderPropertiesSet, B_BORDER_BOTTOM_WIDTH);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_left_width_value:
|
2003-06-08 02:14:42 +04:00
|
|
|
PropertyIsSet(borderLeftWidth, index, borderPropertiesSet, B_BORDER_LEFT_WIDTH);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_right_width_value:
|
2003-06-08 02:14:42 +04:00
|
|
|
PropertyIsSet(borderRightWidth, index, borderPropertiesSet, B_BORDER_RIGHT_WIDTH);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_start_width_value:
|
|
|
|
borderStartWidth = index+1;
|
|
|
|
break;
|
|
|
|
case eCSSProperty_border_end_width_value:
|
|
|
|
borderEndWidth = index+1;
|
|
|
|
break;
|
2001-10-24 12:08:30 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
case eCSSProperty_border_top_style:
|
|
|
|
PropertyIsSet(borderTopStyle, index, borderPropertiesSet, B_BORDER_TOP_STYLE);
|
|
|
|
break;
|
|
|
|
case eCSSProperty_border_bottom_style:
|
|
|
|
PropertyIsSet(borderBottomStyle, index, borderPropertiesSet, B_BORDER_BOTTOM_STYLE);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_left_style_value:
|
2003-06-08 02:14:42 +04:00
|
|
|
PropertyIsSet(borderLeftStyle, index, borderPropertiesSet, B_BORDER_LEFT_STYLE);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_right_style_value:
|
2003-06-08 02:14:42 +04:00
|
|
|
PropertyIsSet(borderRightStyle, index, borderPropertiesSet, B_BORDER_RIGHT_STYLE);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_start_style_value:
|
|
|
|
borderStartStyle = index+1;
|
|
|
|
break;
|
|
|
|
case eCSSProperty_border_end_style_value:
|
|
|
|
borderEndStyle = index+1;
|
|
|
|
break;
|
2001-10-24 12:08:30 +04:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
case eCSSProperty_border_top_color:
|
|
|
|
PropertyIsSet(borderTopColor, index, borderPropertiesSet, B_BORDER_TOP_COLOR);
|
|
|
|
break;
|
|
|
|
case eCSSProperty_border_bottom_color:
|
|
|
|
PropertyIsSet(borderBottomColor, index, borderPropertiesSet, B_BORDER_BOTTOM_COLOR);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_left_color_value:
|
2003-06-08 02:14:42 +04:00
|
|
|
PropertyIsSet(borderLeftColor, index, borderPropertiesSet, B_BORDER_LEFT_COLOR);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_right_color_value:
|
2003-06-08 02:14:42 +04:00
|
|
|
PropertyIsSet(borderRightColor, index, borderPropertiesSet, B_BORDER_RIGHT_COLOR);
|
|
|
|
break;
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_start_color_value:
|
|
|
|
borderStartColor = index+1;
|
|
|
|
break;
|
|
|
|
case eCSSProperty_border_end_color_value:
|
|
|
|
borderEndColor = index+1;
|
|
|
|
break;
|
2003-06-08 02:14:42 +04:00
|
|
|
|
2004-08-26 21:11:20 +04:00
|
|
|
case eCSSProperty_margin_top: marginTop = index+1; break;
|
|
|
|
case eCSSProperty_margin_bottom: marginBottom = index+1; break;
|
|
|
|
case eCSSProperty_margin_left_value: marginLeft = index+1; break;
|
|
|
|
case eCSSProperty_margin_right_value: marginRight = index+1; break;
|
|
|
|
|
|
|
|
case eCSSProperty_padding_top: paddingTop = index+1; break;
|
|
|
|
case eCSSProperty_padding_bottom: paddingBottom = index+1; break;
|
|
|
|
case eCSSProperty_padding_left_value: paddingLeft = index+1; break;
|
|
|
|
case eCSSProperty_padding_right_value: paddingRight = index+1; break;
|
|
|
|
|
|
|
|
case eCSSProperty_background_color: bgColor = index+1; break;
|
|
|
|
case eCSSProperty_background_image: bgImage = index+1; break;
|
|
|
|
case eCSSProperty_background_repeat: bgRepeat = index+1; break;
|
|
|
|
case eCSSProperty_background_attachment: bgAttachment = index+1; break;
|
2007-04-16 02:25:20 +04:00
|
|
|
case eCSSProperty_background_position: bgPosition = index+1; break;
|
2004-08-26 21:11:20 +04:00
|
|
|
|
2004-09-05 04:04:04 +04:00
|
|
|
case eCSSProperty_overflow_x: overflowX = index+1; break;
|
|
|
|
case eCSSProperty_overflow_y: overflowY = index+1; break;
|
|
|
|
|
2008-07-19 14:38:25 +04:00
|
|
|
case eCSSProperty__moz_column_rule_width: columnRuleWidth = index+1; break;
|
|
|
|
case eCSSProperty__moz_column_rule_style: columnRuleStyle = index+1; break;
|
|
|
|
case eCSSProperty__moz_column_rule_color: columnRuleColor = index+1; break;
|
|
|
|
|
2004-12-09 06:16:15 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
case eCSSProperty_marker_end: markerEnd = index+1; break;
|
|
|
|
case eCSSProperty_marker_mid: markerMid = index+1; break;
|
|
|
|
case eCSSProperty_marker_start: markerStart = index+1; break;
|
|
|
|
#endif
|
|
|
|
|
2004-08-26 21:11:20 +04:00
|
|
|
default: break;
|
2003-06-08 02:14:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!TryBorderShorthand(aString, borderPropertiesSet,
|
|
|
|
borderTopWidth, borderTopStyle, borderTopColor,
|
|
|
|
borderBottomWidth, borderBottomStyle, borderBottomColor,
|
|
|
|
borderLeftWidth, borderLeftStyle, borderLeftColor,
|
|
|
|
borderRightWidth, borderRightStyle, borderRightColor)) {
|
|
|
|
PRUint32 borderPropertiesToSet = 0;
|
|
|
|
if ((borderPropertiesSet & B_BORDER_STYLE) != B_BORDER_STYLE ||
|
|
|
|
!TryFourSidesShorthand(aString, eCSSProperty_border_style,
|
|
|
|
borderTopStyle, borderBottomStyle,
|
|
|
|
borderLeftStyle, borderRightStyle,
|
|
|
|
PR_FALSE)) {
|
|
|
|
borderPropertiesToSet |= B_BORDER_STYLE;
|
|
|
|
}
|
|
|
|
if ((borderPropertiesSet & B_BORDER_COLOR) != B_BORDER_COLOR ||
|
|
|
|
!TryFourSidesShorthand(aString, eCSSProperty_border_color,
|
|
|
|
borderTopColor, borderBottomColor,
|
|
|
|
borderLeftColor, borderRightColor,
|
|
|
|
PR_FALSE)) {
|
|
|
|
borderPropertiesToSet |= B_BORDER_COLOR;
|
|
|
|
}
|
|
|
|
if ((borderPropertiesSet & B_BORDER_WIDTH) != B_BORDER_WIDTH ||
|
|
|
|
!TryFourSidesShorthand(aString, eCSSProperty_border_width,
|
|
|
|
borderTopWidth, borderBottomWidth,
|
|
|
|
borderLeftWidth, borderRightWidth,
|
|
|
|
PR_FALSE)) {
|
|
|
|
borderPropertiesToSet |= B_BORDER_WIDTH;
|
|
|
|
}
|
|
|
|
borderPropertiesToSet &= borderPropertiesSet;
|
|
|
|
if (borderPropertiesToSet) {
|
|
|
|
if ((borderPropertiesSet & B_BORDER_TOP) != B_BORDER_TOP ||
|
|
|
|
!TryBorderSideShorthand(aString, eCSSProperty_border_top,
|
|
|
|
borderTopWidth, borderTopStyle, borderTopColor)) {
|
|
|
|
finalBorderPropertiesToSet |= B_BORDER_TOP;
|
|
|
|
}
|
|
|
|
if ((borderPropertiesSet & B_BORDER_LEFT) != B_BORDER_LEFT ||
|
|
|
|
!TryBorderSideShorthand(aString, eCSSProperty_border_left,
|
|
|
|
borderLeftWidth, borderLeftStyle, borderLeftColor)) {
|
|
|
|
finalBorderPropertiesToSet |= B_BORDER_LEFT;
|
|
|
|
}
|
|
|
|
if ((borderPropertiesSet & B_BORDER_RIGHT) != B_BORDER_RIGHT ||
|
|
|
|
!TryBorderSideShorthand(aString, eCSSProperty_border_right,
|
|
|
|
borderRightWidth, borderRightStyle, borderRightColor)) {
|
|
|
|
finalBorderPropertiesToSet |= B_BORDER_RIGHT;
|
|
|
|
}
|
|
|
|
if ((borderPropertiesSet & B_BORDER_BOTTOM) != B_BORDER_BOTTOM ||
|
|
|
|
!TryBorderSideShorthand(aString, eCSSProperty_border_bottom,
|
|
|
|
borderBottomWidth, borderBottomStyle, borderBottomColor)) {
|
|
|
|
finalBorderPropertiesToSet |= B_BORDER_BOTTOM;
|
|
|
|
}
|
|
|
|
finalBorderPropertiesToSet &= borderPropertiesToSet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TryFourSidesShorthand(aString, eCSSProperty_margin,
|
|
|
|
marginTop, marginBottom,
|
|
|
|
marginLeft, marginRight,
|
|
|
|
PR_TRUE);
|
|
|
|
TryFourSidesShorthand(aString, eCSSProperty_padding,
|
|
|
|
paddingTop, paddingBottom,
|
|
|
|
paddingLeft, paddingRight,
|
|
|
|
PR_TRUE);
|
|
|
|
TryBackgroundShorthand(aString,
|
|
|
|
bgColor, bgImage, bgRepeat, bgAttachment,
|
2007-04-16 02:25:20 +04:00
|
|
|
bgPosition);
|
2004-09-05 04:04:04 +04:00
|
|
|
TryOverflowShorthand(aString, overflowX, overflowY);
|
2004-12-09 06:16:15 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
TryMarkerShorthand(aString, markerEnd, markerMid, markerStart);
|
|
|
|
#endif
|
2008-07-19 14:38:25 +04:00
|
|
|
|
|
|
|
if (columnRuleColor && columnRuleStyle && columnRuleWidth) {
|
|
|
|
TryBorderSideShorthand(aString, eCSSProperty__moz_column_rule,
|
|
|
|
columnRuleWidth, columnRuleStyle, columnRuleColor);
|
|
|
|
columnRuleWidth = columnRuleStyle = columnRuleColor = 0;
|
|
|
|
}
|
|
|
|
|
2007-07-04 22:51:16 +04:00
|
|
|
// FIXME The order of the declarations should depend on the *-source
|
|
|
|
// properties.
|
|
|
|
if (borderStartWidth && borderStartStyle && borderStartColor &&
|
|
|
|
TryBorderSideShorthand(aString, eCSSProperty_border_start,
|
|
|
|
borderStartWidth, borderStartStyle, borderStartColor))
|
|
|
|
borderStartWidth = borderStartStyle = borderStartColor = 0;
|
|
|
|
if (borderEndWidth && borderEndStyle && borderEndColor &&
|
|
|
|
TryBorderSideShorthand(aString, eCSSProperty_border_end,
|
|
|
|
borderEndWidth, borderEndStyle, borderEndColor))
|
|
|
|
borderEndWidth = borderEndStyle = borderEndColor = 0;
|
2003-06-08 02:14:42 +04:00
|
|
|
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
nsCSSProperty property = OrderValueAt(index);
|
|
|
|
switch (property) {
|
|
|
|
|
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE(finalBorderPropertiesToSet & B_BORDER_TOP_STYLE,
|
|
|
|
eCSSProperty_border_top_style, borderTopStyle)
|
2007-07-04 22:51:16 +04:00
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE_AS(finalBorderPropertiesToSet & B_BORDER_LEFT_STYLE,
|
|
|
|
eCSSProperty_border_left_style_value,
|
|
|
|
eCSSProperty_border_left_style, borderLeftStyle)
|
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE_AS(finalBorderPropertiesToSet & B_BORDER_RIGHT_STYLE,
|
|
|
|
eCSSProperty_border_right_style_value,
|
|
|
|
eCSSProperty_border_right_style, borderRightStyle)
|
2003-06-08 02:14:42 +04:00
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE(finalBorderPropertiesToSet & B_BORDER_BOTTOM_STYLE,
|
|
|
|
eCSSProperty_border_bottom_style, borderBottomStyle)
|
2007-07-04 22:51:16 +04:00
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_border_start_style_value,
|
|
|
|
eCSSProperty_border_start_style, borderStartStyle)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_border_end_style_value,
|
|
|
|
eCSSProperty_border_end_style, borderEndStyle)
|
2003-06-08 02:14:42 +04:00
|
|
|
|
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE(finalBorderPropertiesToSet & B_BORDER_TOP_COLOR,
|
|
|
|
eCSSProperty_border_top_color, borderTopColor)
|
2007-07-04 22:51:16 +04:00
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE_AS(finalBorderPropertiesToSet & B_BORDER_LEFT_COLOR,
|
|
|
|
eCSSProperty_border_left_color_value,
|
|
|
|
eCSSProperty_border_left_color, borderLeftColor)
|
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE_AS(finalBorderPropertiesToSet & B_BORDER_RIGHT_COLOR,
|
|
|
|
eCSSProperty_border_right_color_value,
|
|
|
|
eCSSProperty_border_right_color, borderRightColor)
|
2003-06-08 02:14:42 +04:00
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE(finalBorderPropertiesToSet & B_BORDER_BOTTOM_COLOR,
|
|
|
|
eCSSProperty_border_bottom_color, borderBottomColor)
|
2007-07-04 22:51:16 +04:00
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_border_start_color_value,
|
|
|
|
eCSSProperty_border_start_color, borderStartColor)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_border_end_color_value,
|
|
|
|
eCSSProperty_border_end_color, borderEndColor)
|
2003-06-08 02:14:42 +04:00
|
|
|
|
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE(finalBorderPropertiesToSet & B_BORDER_TOP_WIDTH,
|
|
|
|
eCSSProperty_border_top_width, borderTopWidth)
|
2007-07-04 22:51:16 +04:00
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE_AS(finalBorderPropertiesToSet & B_BORDER_LEFT_WIDTH,
|
|
|
|
eCSSProperty_border_left_width_value,
|
|
|
|
eCSSProperty_border_left_width, borderLeftWidth)
|
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE_AS(finalBorderPropertiesToSet & B_BORDER_RIGHT_WIDTH,
|
|
|
|
eCSSProperty_border_right_width_value,
|
|
|
|
eCSSProperty_border_right_width, borderRightWidth)
|
2003-06-08 02:14:42 +04:00
|
|
|
NS_CASE_CONDITIONAL_OUTPUT_PROPERTY_VALUE(finalBorderPropertiesToSet & B_BORDER_BOTTOM_WIDTH,
|
|
|
|
eCSSProperty_border_bottom_width, borderBottomWidth)
|
2007-07-04 22:51:16 +04:00
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_border_start_width_value,
|
|
|
|
eCSSProperty_border_start_width, borderStartWidth)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_border_end_width_value,
|
|
|
|
eCSSProperty_border_end_width, borderEndWidth)
|
2003-06-08 02:14:42 +04:00
|
|
|
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_margin_top, marginTop)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_margin_bottom, marginBottom)
|
2004-02-05 03:19:19 +03:00
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_margin_left_value,
|
|
|
|
eCSSProperty_margin_left, marginLeft)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_margin_right_value,
|
|
|
|
eCSSProperty_margin_right, marginRight)
|
2003-06-08 02:14:42 +04:00
|
|
|
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_padding_top, paddingTop)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_padding_bottom, paddingBottom)
|
2004-02-05 03:19:19 +03:00
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_padding_left_value,
|
|
|
|
eCSSProperty_padding_left, paddingLeft)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE_AS(eCSSProperty_padding_right_value,
|
|
|
|
eCSSProperty_padding_right, paddingRight)
|
2003-06-08 02:14:42 +04:00
|
|
|
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_background_color, bgColor)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_background_image, bgImage)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_background_repeat, bgRepeat)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_background_attachment, bgAttachment)
|
2007-04-16 02:25:20 +04:00
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_background_position, bgPosition)
|
2002-05-21 12:16:42 +04:00
|
|
|
|
2004-09-05 04:04:04 +04:00
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_overflow_x, overflowX)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_overflow_y, overflowY)
|
|
|
|
|
2004-12-09 06:16:15 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_marker_end, markerEnd)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_marker_mid, markerMid)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty_marker_start, markerStart)
|
|
|
|
#endif
|
|
|
|
|
2008-07-19 14:38:25 +04:00
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty__moz_column_rule_width, columnRuleWidth)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty__moz_column_rule_style, columnRuleStyle)
|
|
|
|
NS_CASE_OUTPUT_PROPERTY_VALUE(eCSSProperty__moz_column_rule_color, columnRuleColor)
|
|
|
|
|
2004-02-05 03:19:19 +03:00
|
|
|
case eCSSProperty_margin_left_ltr_source:
|
|
|
|
case eCSSProperty_margin_left_rtl_source:
|
|
|
|
case eCSSProperty_margin_right_ltr_source:
|
|
|
|
case eCSSProperty_margin_right_rtl_source:
|
|
|
|
case eCSSProperty_padding_left_ltr_source:
|
|
|
|
case eCSSProperty_padding_left_rtl_source:
|
|
|
|
case eCSSProperty_padding_right_ltr_source:
|
|
|
|
case eCSSProperty_padding_right_rtl_source:
|
2007-07-04 22:51:16 +04:00
|
|
|
case eCSSProperty_border_left_color_ltr_source:
|
|
|
|
case eCSSProperty_border_left_color_rtl_source:
|
|
|
|
case eCSSProperty_border_left_style_ltr_source:
|
|
|
|
case eCSSProperty_border_left_style_rtl_source:
|
|
|
|
case eCSSProperty_border_left_width_ltr_source:
|
|
|
|
case eCSSProperty_border_left_width_rtl_source:
|
|
|
|
case eCSSProperty_border_right_color_ltr_source:
|
|
|
|
case eCSSProperty_border_right_color_rtl_source:
|
|
|
|
case eCSSProperty_border_right_style_ltr_source:
|
|
|
|
case eCSSProperty_border_right_style_rtl_source:
|
|
|
|
case eCSSProperty_border_right_width_ltr_source:
|
|
|
|
case eCSSProperty_border_right_width_rtl_source:
|
2004-02-05 03:19:19 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eCSSProperty_margin_start_value:
|
|
|
|
AppendPropertyAndValueToString(property, eCSSProperty_margin_start,
|
|
|
|
aString);
|
|
|
|
break;
|
|
|
|
case eCSSProperty_margin_end_value:
|
|
|
|
AppendPropertyAndValueToString(property, eCSSProperty_margin_end,
|
|
|
|
aString);
|
|
|
|
break;
|
|
|
|
case eCSSProperty_padding_start_value:
|
|
|
|
AppendPropertyAndValueToString(property, eCSSProperty_padding_start,
|
|
|
|
aString);
|
|
|
|
break;
|
|
|
|
case eCSSProperty_padding_end_value:
|
|
|
|
AppendPropertyAndValueToString(property, eCSSProperty_padding_end,
|
|
|
|
aString);
|
|
|
|
break;
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
default:
|
|
|
|
if (0 <= property) {
|
|
|
|
AppendPropertyAndValueToString(property, aString);
|
|
|
|
}
|
|
|
|
break;
|
1998-09-10 05:19:26 +04:00
|
|
|
}
|
|
|
|
}
|
2001-10-24 12:08:30 +04:00
|
|
|
if (! aString.IsEmpty()) {
|
|
|
|
// if the string is not empty, we have a trailing whitespace we should remove
|
|
|
|
aString.Truncate(aString.Length() - 1);
|
|
|
|
}
|
1998-09-10 05:19:26 +04:00
|
|
|
return NS_OK;
|
1998-07-15 02:34:27 +04:00
|
|
|
}
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
2002-01-16 01:43:37 +03:00
|
|
|
void nsCSSDeclaration::List(FILE* out, PRInt32 aIndent) const
|
1998-09-10 05:19:26 +04:00
|
|
|
{
|
|
|
|
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
fputs("{ ", out);
|
2007-05-17 01:17:45 +04:00
|
|
|
nsAutoString s;
|
|
|
|
ToString(s);
|
|
|
|
fputs(NS_ConvertUTF16toUTF8(s).get(), out);
|
1998-09-10 05:19:26 +04:00
|
|
|
fputs("}", out);
|
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsresult
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSDeclaration::GetNthProperty(PRUint32 aIndex, nsAString& aReturn) const
|
1998-09-25 04:51:45 +04:00
|
|
|
{
|
2000-08-23 21:27:06 +04:00
|
|
|
aReturn.Truncate();
|
2008-01-10 23:13:24 +03:00
|
|
|
if (aIndex < mOrder.Length()) {
|
2003-06-08 02:14:42 +04:00
|
|
|
nsCSSProperty property = OrderValueAt(aIndex);
|
1998-09-25 04:51:45 +04:00
|
|
|
if (0 <= property) {
|
2003-11-01 13:57:41 +03:00
|
|
|
AppendASCIItoUTF16(nsCSSProps::GetStringValue(property), aReturn);
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration*
|
|
|
|
nsCSSDeclaration::Clone() const
|
1999-06-03 05:58:11 +04:00
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
return new nsCSSDeclaration(*this);
|
1999-06-03 05:58:11 +04:00
|
|
|
}
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
PRBool
|
|
|
|
nsCSSDeclaration::InitializeEmpty()
|
1998-09-10 05:19:26 +04:00
|
|
|
{
|
2003-06-08 02:14:42 +04:00
|
|
|
NS_ASSERTION(!mData && !mImportantData, "already initialized");
|
|
|
|
mData = nsCSSCompressedDataBlock::CreateEmptyBlock();
|
|
|
|
return mData != nsnull;
|
1998-09-10 05:19:26 +04:00
|
|
|
}
|