2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
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.
|
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* 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):
|
2001-06-01 02:19:43 +04:00
|
|
|
* David Hyatt <hyatt@netscape.com>
|
2001-02-13 17:06:29 +03:00
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-06-10 09:28:32 +04:00
|
|
|
#include "nsCSSRule.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsICSSStyleRule.h"
|
2001-09-19 18:16:34 +04:00
|
|
|
#include "nsICSSGroupRule.h"
|
2002-01-16 01:43:37 +03:00
|
|
|
#include "nsCSSDeclaration.h"
|
1998-11-26 04:34:53 +03:00
|
|
|
#include "nsICSSStyleSheet.h"
|
1999-08-04 09:07:10 +04:00
|
|
|
#include "nsICSSParser.h"
|
|
|
|
#include "nsICSSLoader.h"
|
|
|
|
#include "nsIHTMLContentContainer.h"
|
|
|
|
#include "nsIURL.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
1998-11-26 04:34:53 +03:00
|
|
|
#include "nsIDocument.h"
|
1998-08-07 06:16:38 +04:00
|
|
|
#include "nsIDeviceContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIArena.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsStyleConsts.h"
|
1998-05-19 01:09:43 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsUnitConversion.h"
|
1998-07-23 22:03:55 +04:00
|
|
|
#include "nsStyleUtil.h"
|
1998-09-17 04:19:47 +04:00
|
|
|
#include "nsIFontMetrics.h"
|
1998-10-06 05:39:33 +04:00
|
|
|
#include "nsIDOMCSSStyleSheet.h"
|
1998-11-26 04:34:53 +03:00
|
|
|
#include "nsIDOMCSSRule.h"
|
1998-10-06 05:39:33 +04:00
|
|
|
#include "nsIDOMCSSStyleRule.h"
|
|
|
|
#include "nsIDOMCSSStyleDeclaration.h"
|
|
|
|
#include "nsDOMCSSDeclaration.h"
|
1998-12-11 05:50:43 +03:00
|
|
|
#include "nsINameSpaceManager.h"
|
2001-01-22 07:03:48 +03:00
|
|
|
#include "nsINameSpace.h"
|
1999-09-10 09:56:19 +04:00
|
|
|
#include "nsILookAndFeel.h"
|
2001-04-18 03:23:09 +04:00
|
|
|
#include "xp_core.h"
|
2001-10-24 04:01:09 +04:00
|
|
|
#include "nsRuleNode.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
#include "nsISizeOfHandler.h"
|
2000-10-29 02:17:53 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
// #define DEBUG_REFS
|
2001-10-19 18:02:36 +04:00
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
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);
|
|
|
|
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-04-25 22:44:55 +04:00
|
|
|
static NS_DEFINE_IID(kCSSDisplaySID, NS_CSS_DISPLAY_SID);
|
1998-11-06 03:58:23 +03:00
|
|
|
static NS_DEFINE_IID(kCSSTableSID, NS_CSS_TABLE_SID);
|
1999-04-02 22:49:40 +04:00
|
|
|
static NS_DEFINE_IID(kCSSContentSID, NS_CSS_CONTENT_SID);
|
1999-07-24 23:04:42 +04:00
|
|
|
static NS_DEFINE_IID(kCSSUserInterfaceSID, NS_CSS_USER_INTERFACE_SID);
|
2001-03-06 05:30:30 +03:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
static NS_DEFINE_IID(kCSSXULSID, NS_CSS_XUL_SID);
|
|
|
|
#endif
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
static NS_DEFINE_IID(kCSSSVGSID, NS_CSS_SVG_SID);
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// -- nsCSSSelector -------------------------------
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
#define NS_IF_COPY(dest,source,type) \
|
|
|
|
if (nsnull != source) dest = new type(*(source))
|
|
|
|
|
|
|
|
#define NS_IF_DELETE(ptr) \
|
|
|
|
if (nsnull != ptr) { delete ptr; ptr = nsnull; }
|
|
|
|
|
2001-03-20 14:49:20 +03:00
|
|
|
#define NS_IF_NEGATED_START(bool,str) \
|
|
|
|
if (bool) { str.Append(NS_LITERAL_STRING(":not(")); }
|
|
|
|
|
|
|
|
#define NS_IF_NEGATED_END(bool,str) \
|
|
|
|
if (bool) { str.Append(PRUnichar(')')); }
|
|
|
|
|
2001-01-28 02:06:33 +03:00
|
|
|
MOZ_DECL_CTOR_COUNTER(nsAtomList)
|
1999-10-09 00:41:19 +04:00
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
nsAtomList::nsAtomList(nsIAtom* aAtom)
|
|
|
|
: mAtom(aAtom),
|
1998-04-14 00:24:54 +04:00
|
|
|
mNext(nsnull)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsAtomList);
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_ADDREF(mAtom);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
nsAtomList::nsAtomList(const nsString& aAtomValue)
|
|
|
|
: mAtom(nsnull),
|
|
|
|
mNext(nsnull)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsAtomList);
|
1998-12-11 05:50:43 +03:00
|
|
|
mAtom = NS_NewAtom(aAtomValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAtomList::nsAtomList(const nsAtomList& aCopy)
|
|
|
|
: mAtom(aCopy.mAtom),
|
|
|
|
mNext(nsnull)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsAtomList);
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_ADDREF(mAtom);
|
|
|
|
NS_IF_COPY(mNext, aCopy.mNext, nsAtomList);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAtomList::~nsAtomList(void)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_DTOR(nsAtomList);
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_RELEASE(mAtom);
|
|
|
|
NS_IF_DELETE(mNext);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsAtomList::Equals(const nsAtomList* aOther) const
|
|
|
|
{
|
|
|
|
if (this == aOther) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
if (nsnull != aOther) {
|
|
|
|
if (mAtom == aOther->mAtom) {
|
|
|
|
if (nsnull != mNext) {
|
|
|
|
return mNext->Equals(aOther->mNext);
|
|
|
|
}
|
|
|
|
return PRBool(nsnull == aOther->mNext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2001-01-28 02:06:33 +03:00
|
|
|
MOZ_DECL_CTOR_COUNTER(nsAttrSelector)
|
1999-10-09 00:41:19 +04:00
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
PRUint32 gAttrSelectorCount=0;
|
|
|
|
#endif
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
nsAttrSelector::nsAttrSelector(PRInt32 aNameSpace, const nsString& aAttr)
|
|
|
|
: mNameSpace(aNameSpace),
|
|
|
|
mAttr(nsnull),
|
1998-12-11 05:50:43 +03:00
|
|
|
mFunction(NS_ATTR_FUNC_SET),
|
1998-12-21 08:58:58 +03:00
|
|
|
mCaseSensitive(1),
|
1998-12-11 05:50:43 +03:00
|
|
|
mValue(),
|
|
|
|
mNext(nsnull)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsAttrSelector);
|
2000-03-31 11:08:36 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gAttrSelectorCount++;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "nsAttrSelector Instances (ctor): %ld\n", (long)gAttrSelectorCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
mAttr = NS_NewAtom(aAttr);
|
|
|
|
}
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
nsAttrSelector::nsAttrSelector(PRInt32 aNameSpace, const nsString& aAttr, PRUint8 aFunction,
|
|
|
|
const nsString& aValue, PRBool aCaseSensitive)
|
|
|
|
: mNameSpace(aNameSpace),
|
|
|
|
mAttr(nsnull),
|
1998-12-11 05:50:43 +03:00
|
|
|
mFunction(aFunction),
|
1998-12-21 08:58:58 +03:00
|
|
|
mCaseSensitive(aCaseSensitive),
|
1998-12-11 05:50:43 +03:00
|
|
|
mValue(aValue),
|
|
|
|
mNext(nsnull)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsAttrSelector);
|
2000-03-31 11:08:36 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gAttrSelectorCount++;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "nsAttrSelector Instances (ctor): %ld\n", (long)gAttrSelectorCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
mAttr = NS_NewAtom(aAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAttrSelector::nsAttrSelector(const nsAttrSelector& aCopy)
|
1999-06-10 09:28:32 +04:00
|
|
|
: mNameSpace(aCopy.mNameSpace),
|
|
|
|
mAttr(aCopy.mAttr),
|
1998-12-11 05:50:43 +03:00
|
|
|
mFunction(aCopy.mFunction),
|
1998-12-21 08:58:58 +03:00
|
|
|
mCaseSensitive(aCopy.mCaseSensitive),
|
1998-12-11 05:50:43 +03:00
|
|
|
mValue(aCopy.mValue),
|
|
|
|
mNext(nsnull)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsAttrSelector);
|
2000-03-31 11:08:36 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gAttrSelectorCount++;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "nsAttrSelector Instances (cp-ctor): %ld\n", (long)gAttrSelectorCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_ADDREF(mAttr);
|
|
|
|
NS_IF_COPY(mNext, aCopy.mNext, nsAttrSelector);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAttrSelector::~nsAttrSelector(void)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_DTOR(nsAttrSelector);
|
2000-03-31 11:08:36 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gAttrSelectorCount--;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "nsAttrSelector Instances (dtor): %ld\n", (long)gAttrSelectorCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_RELEASE(mAttr);
|
|
|
|
NS_IF_DELETE(mNext);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsAttrSelector::Equals(const nsAttrSelector* aOther) const
|
|
|
|
{
|
|
|
|
if (this == aOther) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
if (nsnull != aOther) {
|
1999-06-10 09:28:32 +04:00
|
|
|
if ((mNameSpace == aOther->mNameSpace) &&
|
|
|
|
(mAttr == aOther->mAttr) &&
|
1998-12-11 05:50:43 +03:00
|
|
|
(mFunction == aOther->mFunction) &&
|
1998-12-21 08:58:58 +03:00
|
|
|
(mCaseSensitive == aOther->mCaseSensitive) &&
|
1998-12-11 05:50:43 +03:00
|
|
|
mValue.Equals(aOther->mValue)) {
|
|
|
|
if (nsnull != mNext) {
|
|
|
|
return mNext->Equals(aOther->mNext);
|
|
|
|
}
|
|
|
|
return PRBool(nsnull == aOther->mNext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
2000-03-31 11:08:36 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* SizeOf method:
|
|
|
|
*
|
|
|
|
* Self (reported as nsAttrSelector's size):
|
|
|
|
* 1) sizeof(*this) + the size of mAttr atom (if it exists and is unique)
|
|
|
|
*
|
|
|
|
* Contained / Aggregated data (not reported as nsAttrSelector's size):
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Children / siblings / parents:
|
|
|
|
* 1) Recurses to the mMext instance which is reported as a seperate instance
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
void nsAttrSelector::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null");
|
|
|
|
|
|
|
|
// first get the unique items collection
|
|
|
|
UNIQUE_STYLE_ITEMS(uniqueItems);
|
|
|
|
if(! uniqueItems->AddItem((void*)this)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 localSize=0;
|
|
|
|
|
|
|
|
// create a tag for this instance
|
|
|
|
nsCOMPtr<nsIAtom> tag;
|
|
|
|
tag = getter_AddRefs(NS_NewAtom("nsAttrSelector"));
|
|
|
|
// get the size of an empty instance and add to the sizeof handler
|
|
|
|
aSize = sizeof(*this);
|
|
|
|
|
|
|
|
// add in the mAttr atom
|
|
|
|
if (mAttr && uniqueItems->AddItem(mAttr)){
|
|
|
|
mAttr->SizeOf(aSizeOfHandler, &localSize);
|
|
|
|
aSize += localSize;
|
|
|
|
}
|
|
|
|
aSizeOfHandler->AddSize(tag,aSize);
|
|
|
|
|
|
|
|
// recurse to the next one...
|
|
|
|
if(mNext){
|
|
|
|
mNext->SizeOf(aSizeOfHandler, localSize);
|
|
|
|
}
|
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
2001-01-28 02:06:33 +03:00
|
|
|
MOZ_DECL_CTOR_COUNTER(nsCSSSelector)
|
1999-10-09 00:41:19 +04:00
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
PRUint32 gSelectorCount=0;
|
|
|
|
#endif
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
nsCSSSelector::nsCSSSelector(void)
|
|
|
|
: mNameSpace(kNameSpaceID_Unknown), mTag(nsnull),
|
2001-02-13 17:06:29 +03:00
|
|
|
mIDList(nsnull),
|
1998-12-11 05:50:43 +03:00
|
|
|
mClassList(nsnull),
|
|
|
|
mPseudoClassList(nsnull),
|
|
|
|
mAttrList(nsnull),
|
|
|
|
mOperator(0),
|
2001-03-20 14:49:20 +03:00
|
|
|
mNegations(nsnull),
|
1998-04-14 00:24:54 +04:00
|
|
|
mNext(nsnull)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsCSSSelector);
|
2000-03-31 11:08:36 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gSelectorCount++;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "nsCSSSelector Instances (ctor): %ld\n", (long)gSelectorCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSSelector::nsCSSSelector(const nsCSSSelector& aCopy)
|
1998-12-11 05:50:43 +03:00
|
|
|
: mNameSpace(aCopy.mNameSpace), mTag(aCopy.mTag),
|
2001-02-13 17:06:29 +03:00
|
|
|
mIDList(nsnull),
|
1998-12-11 05:50:43 +03:00
|
|
|
mClassList(nsnull),
|
|
|
|
mPseudoClassList(nsnull),
|
|
|
|
mAttrList(nsnull),
|
|
|
|
mOperator(aCopy.mOperator),
|
2001-03-20 14:49:20 +03:00
|
|
|
mNegations(nsnull),
|
1998-04-14 00:24:54 +04:00
|
|
|
mNext(nsnull)
|
1998-12-11 05:50:43 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsCSSSelector);
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IF_ADDREF(mTag);
|
2001-02-13 17:06:29 +03:00
|
|
|
NS_IF_COPY(mIDList, aCopy.mIDList, nsAtomList);
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_COPY(mClassList, aCopy.mClassList, nsAtomList);
|
|
|
|
NS_IF_COPY(mPseudoClassList, aCopy.mPseudoClassList, nsAtomList);
|
|
|
|
NS_IF_COPY(mAttrList, aCopy.mAttrList, nsAttrSelector);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_COPY(mNegations, aCopy.mNegations, nsCSSSelector);
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gSelectorCount++;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "nsCSSSelector Instances (cp-ctor): %ld\n", (long)gSelectorCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
nsCSSSelector::~nsCSSSelector(void)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_DTOR(nsCSSSelector);
|
1998-12-11 05:50:43 +03:00
|
|
|
Reset();
|
2000-03-31 11:08:36 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gSelectorCount--;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "nsCSSSelector Instances (dtor): %ld\n", (long)gSelectorCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSSelector& nsCSSSelector::operator=(const nsCSSSelector& aCopy)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mTag);
|
2001-02-13 17:06:29 +03:00
|
|
|
NS_IF_DELETE(mIDList);
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_DELETE(mClassList);
|
|
|
|
NS_IF_DELETE(mPseudoClassList);
|
|
|
|
NS_IF_DELETE(mAttrList);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_DELETE(mNegations);
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
mNameSpace = aCopy.mNameSpace;
|
1998-04-14 00:24:54 +04:00
|
|
|
mTag = aCopy.mTag;
|
2001-02-13 17:06:29 +03:00
|
|
|
NS_IF_COPY(mIDList, aCopy.mIDList, nsAtomList);
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_COPY(mClassList, aCopy.mClassList, nsAtomList);
|
|
|
|
NS_IF_COPY(mPseudoClassList, aCopy.mPseudoClassList, nsAtomList);
|
|
|
|
NS_IF_COPY(mAttrList, aCopy.mAttrList, nsAttrSelector);
|
|
|
|
mOperator = aCopy.mOperator;
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_COPY(mNegations, aCopy.mNegations, nsCSSSelector);
|
1998-12-11 05:50:43 +03:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IF_ADDREF(mTag);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsCSSSelector::Equals(const nsCSSSelector* aOther) const
|
|
|
|
{
|
1998-12-11 05:50:43 +03:00
|
|
|
if (this == aOther) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != aOther) {
|
1998-12-11 05:50:43 +03:00
|
|
|
if ((aOther->mNameSpace == mNameSpace) &&
|
|
|
|
(aOther->mTag == mTag) &&
|
|
|
|
(aOther->mOperator == mOperator)) {
|
2001-02-13 17:06:29 +03:00
|
|
|
if (nsnull != mIDList) {
|
|
|
|
if (PR_FALSE == mIDList->Equals(aOther->mIDList)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (nsnull != aOther->mIDList) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
if (nsnull != mClassList) {
|
|
|
|
if (PR_FALSE == mClassList->Equals(aOther->mClassList)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (nsnull != aOther->mClassList) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nsnull != mPseudoClassList) {
|
|
|
|
if (PR_FALSE == mPseudoClassList->Equals(aOther->mPseudoClassList)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (nsnull != aOther->mPseudoClassList) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nsnull != mAttrList) {
|
|
|
|
if (PR_FALSE == mAttrList->Equals(aOther->mAttrList)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (nsnull != aOther->mAttrList) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2001-03-20 14:49:20 +03:00
|
|
|
if (nsnull != mNegations) {
|
|
|
|
if (PR_FALSE == mNegations->Equals(aOther->mNegations)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
void nsCSSSelector::Reset(void)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-12-11 05:50:43 +03:00
|
|
|
mNameSpace = kNameSpaceID_Unknown;
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IF_RELEASE(mTag);
|
2001-02-13 17:06:29 +03:00
|
|
|
NS_IF_DELETE(mIDList);
|
1998-12-11 05:50:43 +03:00
|
|
|
NS_IF_DELETE(mClassList);
|
|
|
|
NS_IF_DELETE(mPseudoClassList);
|
|
|
|
NS_IF_DELETE(mAttrList);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_DELETE(mNegations);
|
1999-02-27 10:16:57 +03:00
|
|
|
mOperator = PRUnichar(0);
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsCSSSelector::SetNameSpace(PRInt32 aNameSpace)
|
|
|
|
{
|
|
|
|
mNameSpace = aNameSpace;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsCSSSelector::SetTag(const nsString& aTag)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mTag);
|
2002-01-24 05:03:19 +03:00
|
|
|
if (!aTag.IsEmpty()) {
|
1998-12-11 05:50:43 +03:00
|
|
|
mTag = NS_NewAtom(aTag);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
|
|
|
|
2001-02-13 17:06:29 +03:00
|
|
|
void nsCSSSelector::AddID(const nsString& aID)
|
1998-12-11 05:50:43 +03:00
|
|
|
{
|
2002-01-24 05:03:19 +03:00
|
|
|
if (!aID.IsEmpty()) {
|
2001-02-13 17:06:29 +03:00
|
|
|
nsAtomList** list = &mIDList;
|
|
|
|
while (nsnull != *list) {
|
|
|
|
list = &((*list)->mNext);
|
|
|
|
}
|
|
|
|
*list = new nsAtomList(aID);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsCSSSelector::AddClass(const nsString& aClass)
|
|
|
|
{
|
2002-01-24 05:03:19 +03:00
|
|
|
if (!aClass.IsEmpty()) {
|
1998-12-11 05:50:43 +03:00
|
|
|
nsAtomList** list = &mClassList;
|
|
|
|
while (nsnull != *list) {
|
|
|
|
list = &((*list)->mNext);
|
|
|
|
}
|
|
|
|
*list = new nsAtomList(aClass);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsCSSSelector::AddPseudoClass(const nsString& aPseudoClass)
|
|
|
|
{
|
2002-01-24 05:03:19 +03:00
|
|
|
if (!aPseudoClass.IsEmpty()) {
|
1998-12-11 05:50:43 +03:00
|
|
|
nsAtomList** list = &mPseudoClassList;
|
|
|
|
while (nsnull != *list) {
|
|
|
|
list = &((*list)->mNext);
|
|
|
|
}
|
|
|
|
*list = new nsAtomList(aPseudoClass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsCSSSelector::AddPseudoClass(nsIAtom* aPseudoClass)
|
|
|
|
{
|
|
|
|
if (nsnull != aPseudoClass) {
|
|
|
|
nsAtomList** list = &mPseudoClassList;
|
|
|
|
while (nsnull != *list) {
|
|
|
|
list = &((*list)->mNext);
|
1998-05-19 01:09:43 +04:00
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
*list = new nsAtomList(aPseudoClass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
void nsCSSSelector::AddAttribute(PRInt32 aNameSpace, const nsString& aAttr)
|
1998-12-11 05:50:43 +03:00
|
|
|
{
|
2002-01-24 05:03:19 +03:00
|
|
|
if (!aAttr.IsEmpty()) {
|
1998-12-11 05:50:43 +03:00
|
|
|
nsAttrSelector** list = &mAttrList;
|
|
|
|
while (nsnull != *list) {
|
|
|
|
list = &((*list)->mNext);
|
|
|
|
}
|
1999-06-10 09:28:32 +04:00
|
|
|
*list = new nsAttrSelector(aNameSpace, aAttr);
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
void nsCSSSelector::AddAttribute(PRInt32 aNameSpace, const nsString& aAttr, PRUint8 aFunc,
|
|
|
|
const nsString& aValue, PRBool aCaseSensitive)
|
1998-12-11 05:50:43 +03:00
|
|
|
{
|
2002-01-24 05:03:19 +03:00
|
|
|
if (!aAttr.IsEmpty()) {
|
1998-12-11 05:50:43 +03:00
|
|
|
nsAttrSelector** list = &mAttrList;
|
|
|
|
while (nsnull != *list) {
|
|
|
|
list = &((*list)->mNext);
|
|
|
|
}
|
1999-06-10 09:28:32 +04:00
|
|
|
*list = new nsAttrSelector(aNameSpace, aAttr, aFunc, aValue, aCaseSensitive);
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsCSSSelector::SetOperator(PRUnichar aOperator)
|
|
|
|
{
|
|
|
|
mOperator = aOperator;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsCSSSelector::CalcWeight(void) const
|
|
|
|
{
|
|
|
|
PRInt32 weight = 0;
|
|
|
|
|
|
|
|
if (nsnull != mTag) {
|
|
|
|
weight += 0x000001;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2001-02-13 17:06:29 +03:00
|
|
|
nsAtomList* list = mIDList;
|
|
|
|
while (nsnull != list) {
|
1998-12-11 05:50:43 +03:00
|
|
|
weight += 0x010000;
|
2001-02-13 17:06:29 +03:00
|
|
|
list = list->mNext;
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
2001-02-13 17:06:29 +03:00
|
|
|
list = mClassList;
|
1998-12-11 05:50:43 +03:00
|
|
|
while (nsnull != list) {
|
|
|
|
weight += 0x000100;
|
|
|
|
list = list->mNext;
|
|
|
|
}
|
|
|
|
list = mPseudoClassList;
|
|
|
|
while (nsnull != list) {
|
|
|
|
weight += 0x000100;
|
|
|
|
list = list->mNext;
|
|
|
|
}
|
|
|
|
nsAttrSelector* attr = mAttrList;
|
|
|
|
while (nsnull != attr) {
|
|
|
|
weight += 0x000100;
|
|
|
|
attr = attr->mNext;
|
|
|
|
}
|
2001-03-20 14:49:20 +03:00
|
|
|
if (nsnull != mNegations) {
|
|
|
|
weight += mNegations->CalcWeight();
|
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
return weight;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
2000-03-31 11:08:36 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* SizeOf method:
|
|
|
|
*
|
|
|
|
* Self (reported as nsCSSSelector's size):
|
2001-02-13 17:06:29 +03:00
|
|
|
* 1) sizeof(*this) + the size of the mTag
|
|
|
|
* + the size of the mIDList unique items
|
2000-03-31 11:08:36 +04:00
|
|
|
* + the size of the mClassList and mPseudoClassList unique items
|
|
|
|
*
|
|
|
|
* Contained / Aggregated data (not reported as nsCSSSelector's size):
|
|
|
|
* 1) AttributeList is called out to seperately if it exists
|
|
|
|
*
|
|
|
|
* Children / siblings / parents:
|
|
|
|
* 1) Recurses to mNext which is counted as it's own instance
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
void nsCSSSelector::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null");
|
|
|
|
|
|
|
|
// first get the unique items collection
|
|
|
|
UNIQUE_STYLE_ITEMS(uniqueItems);
|
|
|
|
if(! uniqueItems->AddItem((void*)this)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 localSize=0;
|
|
|
|
|
|
|
|
// create a tag for this instance
|
|
|
|
nsCOMPtr<nsIAtom> tag;
|
|
|
|
tag = getter_AddRefs(NS_NewAtom("nsCSSSelector"));
|
|
|
|
// get the size of an empty instance and add to the sizeof handler
|
|
|
|
aSize = sizeof(*this);
|
|
|
|
|
|
|
|
// now get the member-atoms and add them in
|
|
|
|
if(mTag && uniqueItems->AddItem(mTag)){
|
|
|
|
localSize = 0;
|
|
|
|
mTag->SizeOf(aSizeOfHandler, &localSize);
|
|
|
|
aSize += localSize;
|
|
|
|
}
|
2001-02-13 17:06:29 +03:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
|
|
|
// XXX ????
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
// a couple of simple atom lists
|
2001-02-13 17:06:29 +03:00
|
|
|
if(mIDList && uniqueItems->AddItem(mIDList)){
|
|
|
|
aSize += sizeof(*mIDList);
|
|
|
|
nsAtomList *pNext = nsnull;
|
|
|
|
pNext = mIDList;
|
|
|
|
while(pNext){
|
|
|
|
if(pNext->mAtom && uniqueItems->AddItem(pNext->mAtom)){
|
|
|
|
localSize = 0;
|
|
|
|
pNext->mAtom->SizeOf(aSizeOfHandler, &localSize);
|
|
|
|
aSize += localSize;
|
|
|
|
}
|
|
|
|
pNext = pNext->mNext;
|
|
|
|
}
|
|
|
|
}
|
2000-03-31 11:08:36 +04:00
|
|
|
if(mClassList && uniqueItems->AddItem(mClassList)){
|
|
|
|
aSize += sizeof(*mClassList);
|
|
|
|
nsAtomList *pNext = nsnull;
|
|
|
|
pNext = mClassList;
|
|
|
|
while(pNext){
|
|
|
|
if(pNext->mAtom && uniqueItems->AddItem(pNext->mAtom)){
|
|
|
|
localSize = 0;
|
|
|
|
pNext->mAtom->SizeOf(aSizeOfHandler, &localSize);
|
|
|
|
aSize += localSize;
|
|
|
|
}
|
|
|
|
pNext = pNext->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(mPseudoClassList && uniqueItems->AddItem(mPseudoClassList)){
|
|
|
|
nsAtomList *pNext = nsnull;
|
|
|
|
pNext = mPseudoClassList;
|
|
|
|
while(pNext){
|
|
|
|
if(pNext->mAtom && uniqueItems->AddItem(pNext->mAtom)){
|
|
|
|
localSize = 0;
|
|
|
|
pNext->mAtom->SizeOf(aSizeOfHandler, &localSize);
|
|
|
|
aSize += localSize;
|
|
|
|
}
|
|
|
|
pNext = pNext->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// done with undelegated sizes
|
|
|
|
aSizeOfHandler->AddSize(tag, aSize);
|
|
|
|
|
|
|
|
// the AttributeList gets its own delegation-call
|
|
|
|
if(mAttrList){
|
|
|
|
localSize = 0;
|
|
|
|
mAttrList->SizeOf(aSizeOfHandler, localSize);
|
|
|
|
}
|
2001-03-20 14:49:20 +03:00
|
|
|
|
|
|
|
// don't forget the negated selectors
|
|
|
|
if(mNegations) {
|
|
|
|
localSize = 0;
|
|
|
|
mNegations->SizeOf(aSizeOfHandler, localSize);
|
|
|
|
}
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
// finally chain to the next...
|
|
|
|
if(mNext){
|
|
|
|
localSize = 0;
|
|
|
|
mNext->SizeOf(aSizeOfHandler, localSize);
|
|
|
|
}
|
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
2001-02-12 16:04:06 +03:00
|
|
|
// pseudo-elements are stored in the selectors' chain using fictional elements;
|
|
|
|
// these fictional elements have mTag starting with a colon
|
|
|
|
static PRBool IsPseudoElement(nsIAtom* aAtom)
|
|
|
|
{
|
|
|
|
if (aAtom) {
|
|
|
|
const PRUnichar *str;
|
|
|
|
aAtom->GetUnicode(&str);
|
|
|
|
return str && (*str == ':');
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2001-03-20 14:49:20 +03:00
|
|
|
void nsCSSSelector::AppendNegationToString(nsAWritableString& aString)
|
|
|
|
{
|
|
|
|
aString.Append(NS_LITERAL_STRING(":not("));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Builds the textual representation of a selector. Called by DOM 2 CSS
|
|
|
|
// StyleRule:selectorText
|
|
|
|
//
|
|
|
|
nsresult nsCSSSelector::ToString( nsAWritableString& aString, nsICSSStyleSheet* aSheet, PRBool aIsPseudoElem,
|
|
|
|
PRInt8 aNegatedIndex) const
|
2000-09-13 04:05:04 +04:00
|
|
|
{
|
2001-01-22 07:03:48 +03:00
|
|
|
const PRUnichar* temp;
|
2001-03-20 14:49:20 +03:00
|
|
|
PRBool aIsNegated = PRBool(0 < aNegatedIndex);
|
2001-01-22 07:03:48 +03:00
|
|
|
|
|
|
|
// selectors are linked from right-to-left, so the next selector in the linked list
|
|
|
|
// actually precedes this one in the resulting string
|
2001-03-20 14:49:20 +03:00
|
|
|
if (mNext) {
|
|
|
|
mNext->ToString(aString, aSheet, IsPseudoElement(mTag), PR_FALSE);
|
|
|
|
if (!aIsNegated && !IsPseudoElement(mTag)) {
|
2001-02-12 16:04:06 +03:00
|
|
|
// don't add a leading whitespace if we have a pseudo-element
|
2001-03-20 14:49:20 +03:00
|
|
|
// or a negated simple selector
|
2001-02-12 16:04:06 +03:00
|
|
|
aString.Append(PRUnichar(' '));
|
|
|
|
}
|
2001-01-22 07:03:48 +03:00
|
|
|
}
|
2001-03-20 14:49:20 +03:00
|
|
|
if (1 < aNegatedIndex) {
|
|
|
|
// the first mNegations does not contain a negated type element selector
|
|
|
|
// or a negated universal selector
|
|
|
|
NS_IF_NEGATED_START(aIsNegated, aString)
|
|
|
|
}
|
2001-01-22 07:03:48 +03:00
|
|
|
|
|
|
|
// append the namespace prefix
|
|
|
|
if (mNameSpace > 0) {
|
|
|
|
nsCOMPtr<nsINameSpace> sheetNS;
|
|
|
|
aSheet->GetNameSpace(*getter_AddRefs(sheetNS));
|
|
|
|
nsCOMPtr<nsIAtom> prefixAtom;
|
|
|
|
// will return null if namespace was the default
|
|
|
|
sheetNS->FindNameSpacePrefix(mNameSpace, *getter_AddRefs(prefixAtom));
|
|
|
|
if (prefixAtom) {
|
|
|
|
const PRUnichar* prefix;
|
|
|
|
prefixAtom->GetUnicode(&prefix);
|
|
|
|
aString.Append(prefix);
|
|
|
|
aString.Append(PRUnichar('|'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// smells like a universal selector
|
2001-02-13 17:06:29 +03:00
|
|
|
if (!mTag && !mIDList && !mClassList) {
|
2001-03-20 14:49:20 +03:00
|
|
|
if (1 != aNegatedIndex) {
|
|
|
|
aString.Append(PRUnichar('*'));
|
|
|
|
}
|
|
|
|
if (1 < aNegatedIndex) {
|
|
|
|
NS_IF_NEGATED_END(aIsNegated, aString)
|
|
|
|
}
|
2001-01-22 07:03:48 +03:00
|
|
|
} else {
|
|
|
|
// Append the tag name, if there is one
|
|
|
|
if (mTag) {
|
|
|
|
mTag->GetUnicode(&temp);
|
|
|
|
aString.Append(temp);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_END(aIsNegated, aString)
|
2001-01-22 07:03:48 +03:00
|
|
|
}
|
|
|
|
// Append the id, if there is one
|
2001-02-13 17:06:29 +03:00
|
|
|
if (mIDList) {
|
|
|
|
nsAtomList* list = mIDList;
|
|
|
|
while (list != nsnull) {
|
|
|
|
list->mAtom->GetUnicode(&temp);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_START(aIsNegated, aString)
|
2001-02-13 17:06:29 +03:00
|
|
|
aString.Append(PRUnichar('#'));
|
|
|
|
aString.Append(temp);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_END(aIsNegated, aString)
|
2001-02-13 17:06:29 +03:00
|
|
|
list = list->mNext;
|
|
|
|
}
|
2001-01-22 07:03:48 +03:00
|
|
|
}
|
|
|
|
// Append each class in the linked list
|
|
|
|
if (mClassList) {
|
|
|
|
nsAtomList* list = mClassList;
|
|
|
|
while (list != nsnull) {
|
|
|
|
list->mAtom->GetUnicode(&temp);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_START(aIsNegated, aString)
|
2001-01-22 07:03:48 +03:00
|
|
|
aString.Append(PRUnichar('.'));
|
|
|
|
aString.Append(temp);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_END(aIsNegated, aString)
|
2001-01-22 07:03:48 +03:00
|
|
|
list = list->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append each attribute selector in the linked list
|
|
|
|
if (mAttrList) {
|
|
|
|
nsAttrSelector* list = mAttrList;
|
|
|
|
while (list != nsnull) {
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_START(aIsNegated, aString)
|
2001-01-22 07:03:48 +03:00
|
|
|
aString.Append(PRUnichar('['));
|
|
|
|
// Append the namespace prefix
|
|
|
|
if (list->mNameSpace > 0) {
|
|
|
|
nsCOMPtr<nsINameSpace> sheetNS;
|
|
|
|
aSheet->GetNameSpace(*getter_AddRefs(sheetNS));
|
|
|
|
nsCOMPtr<nsIAtom> prefixAtom;
|
|
|
|
// will return null if namespace was the default
|
|
|
|
sheetNS->FindNameSpacePrefix(list->mNameSpace, *getter_AddRefs(prefixAtom));
|
|
|
|
if (prefixAtom) {
|
|
|
|
const PRUnichar* prefix;
|
|
|
|
prefixAtom->GetUnicode(&prefix);
|
|
|
|
aString.Append(prefix);
|
|
|
|
aString.Append(PRUnichar('|'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Append the attribute name
|
|
|
|
list->mAttr->GetUnicode(&temp);
|
|
|
|
aString.Append(temp);
|
|
|
|
// Append the function
|
|
|
|
if (list->mFunction == NS_ATTR_FUNC_EQUALS) {
|
|
|
|
aString.Append(PRUnichar('='));
|
|
|
|
} else if (list->mFunction == NS_ATTR_FUNC_INCLUDES) {
|
|
|
|
aString.Append(PRUnichar('~'));
|
|
|
|
aString.Append(PRUnichar('='));
|
|
|
|
} else if (list->mFunction == NS_ATTR_FUNC_DASHMATCH) {
|
|
|
|
aString.Append(PRUnichar('|'));
|
|
|
|
aString.Append(PRUnichar('='));
|
2001-03-03 03:54:04 +03:00
|
|
|
} else if (list->mFunction == NS_ATTR_FUNC_BEGINSMATCH) {
|
|
|
|
aString.Append(PRUnichar('^'));
|
|
|
|
aString.Append(PRUnichar('='));
|
|
|
|
} else if (list->mFunction == NS_ATTR_FUNC_ENDSMATCH) {
|
|
|
|
aString.Append(PRUnichar('$'));
|
|
|
|
aString.Append(PRUnichar('='));
|
|
|
|
} else if (list->mFunction == NS_ATTR_FUNC_CONTAINSMATCH) {
|
|
|
|
aString.Append(PRUnichar('*'));
|
|
|
|
aString.Append(PRUnichar('='));
|
2001-01-22 07:03:48 +03:00
|
|
|
}
|
|
|
|
// Append the value
|
|
|
|
aString.Append(list->mValue);
|
|
|
|
aString.Append(PRUnichar(']'));
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_END(aIsNegated, aString)
|
2001-01-22 07:03:48 +03:00
|
|
|
list = list->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append each pseudo-class in the linked list
|
|
|
|
if (mPseudoClassList) {
|
|
|
|
nsAtomList* list = mPseudoClassList;
|
|
|
|
while (list != nsnull) {
|
|
|
|
list->mAtom->GetUnicode(&temp);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_START(aIsNegated, aString)
|
2001-01-22 07:03:48 +03:00
|
|
|
aString.Append(temp);
|
2001-03-20 14:49:20 +03:00
|
|
|
NS_IF_NEGATED_END(aIsNegated, aString)
|
2001-01-22 07:03:48 +03:00
|
|
|
list = list->mNext;
|
|
|
|
}
|
|
|
|
}
|
2001-03-20 14:49:20 +03:00
|
|
|
|
|
|
|
if (mNegations) {
|
|
|
|
// chain all the negated selectors
|
|
|
|
mNegations->ToString(aString, aSheet, PR_FALSE, aNegatedIndex + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append the operator only if the selector is not negated and is not
|
|
|
|
// a pseudo-element
|
|
|
|
if (!aIsNegated && mOperator && !aIsPseudoElem) {
|
2001-01-22 07:03:48 +03:00
|
|
|
aString.Append(PRUnichar(' '));
|
|
|
|
aString.Append(mOperator);
|
|
|
|
}
|
2000-09-13 04:05:04 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-03-20 14:49:20 +03:00
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
// -- CSSImportantRule -------------------------------
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// New map helpers shared by both important and regular rules.
|
2002-01-16 01:43:37 +03:00
|
|
|
static nsresult MapFontForDeclaration(nsCSSDeclaration* aDecl, nsCSSFont& aFont);
|
|
|
|
static nsresult MapDisplayForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSDisplay& aDisplay);
|
|
|
|
static nsresult MapColorForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSColor& aColor);
|
|
|
|
static nsresult MapMarginForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSMargin& aMargin);
|
|
|
|
static nsresult MapListForDeclaration(nsCSSDeclaration* aDecl, nsCSSList& aList);
|
|
|
|
static nsresult MapPositionForDeclaration(nsCSSDeclaration* aDecl, nsCSSPosition& aPosition);
|
|
|
|
static nsresult MapTableForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSTable& aTable);
|
|
|
|
static nsresult MapContentForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSContent& aContent);
|
|
|
|
static nsresult MapTextForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSText& aContent);
|
|
|
|
static nsresult MapUIForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSUserInterface& aContent);
|
1998-09-11 06:07:05 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
#ifdef INCLUDE_XUL
|
2002-01-16 01:43:37 +03:00
|
|
|
static nsresult MapXULForDeclaration(nsCSSDeclaration* aDecl, nsCSSXUL& aXUL);
|
2001-06-01 02:19:43 +04:00
|
|
|
#endif
|
1998-09-11 06:07:05 +04:00
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
2002-01-16 01:43:37 +03:00
|
|
|
static nsresult MapSVGForDeclaration(nsCSSDeclaration* aDecl, nsCSSSVG& aSVG);
|
2001-12-12 10:59:31 +03:00
|
|
|
#endif
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
class CSSStyleRuleImpl;
|
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
class CSSImportantRule : public nsIStyleRule {
|
|
|
|
public:
|
2002-01-16 01:43:37 +03:00
|
|
|
CSSImportantRule(nsICSSStyleSheet* aSheet, nsCSSDeclaration* aDeclaration);
|
1998-09-11 06:07:05 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
// NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aResult) const;
|
|
|
|
// NS_IMETHOD HashValue(PRUint32& aValue) const;
|
1998-09-11 06:07:05 +04:00
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
|
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
// Strength is an out-of-band weighting, useful for mapping CSS ! important
|
1998-12-20 04:16:20 +03:00
|
|
|
NS_IMETHOD GetStrength(PRInt32& aStrength) const;
|
1998-09-11 06:07:05 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// The new mapping function.
|
|
|
|
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
|
1998-09-11 06:07:05 +04:00
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
1998-09-11 06:07:05 +04:00
|
|
|
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize);
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
protected:
|
1999-02-12 20:45:58 +03:00
|
|
|
virtual ~CSSImportantRule(void);
|
1998-09-11 06:07:05 +04:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* mDeclaration;
|
1998-11-26 04:34:53 +03:00
|
|
|
nsICSSStyleSheet* mSheet;
|
|
|
|
|
1999-04-21 08:16:46 +04:00
|
|
|
friend class CSSStyleRuleImpl;
|
1998-09-11 06:07:05 +04:00
|
|
|
};
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
CSSImportantRule::CSSImportantRule(nsICSSStyleSheet* aSheet, nsCSSDeclaration* aDeclaration)
|
1999-02-12 20:45:58 +03:00
|
|
|
: mDeclaration(aDeclaration),
|
|
|
|
mSheet(aSheet)
|
1998-09-11 06:07:05 +04:00
|
|
|
{
|
1998-09-12 06:43:48 +04:00
|
|
|
NS_INIT_REFCNT();
|
1998-09-11 06:07:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CSSImportantRule::~CSSImportantRule(void)
|
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
mDeclaration = nsnull;
|
1998-09-11 06:07:05 +04:00
|
|
|
}
|
|
|
|
|
2001-08-21 05:48:11 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(CSSImportantRule, nsIStyleRule)
|
1998-09-11 06:07:05 +04:00
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
#if 0
|
1998-09-11 06:07:05 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSImportantRule::Equals(const nsIStyleRule* aRule, PRBool& aResult) const
|
|
|
|
{
|
|
|
|
aResult = PRBool(aRule == this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSImportantRule::HashValue(PRUint32& aValue) const
|
|
|
|
{
|
|
|
|
aValue = PRUint32(mDeclaration);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-06-10 09:28:32 +04:00
|
|
|
#endif
|
1998-09-11 06:07:05 +04:00
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSImportantRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(mSheet);
|
|
|
|
aSheet = mSheet;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
// Strength is an out-of-band weighting, useful for mapping CSS ! important
|
|
|
|
NS_IMETHODIMP
|
1998-12-20 04:16:20 +03:00
|
|
|
CSSImportantRule::GetStrength(PRInt32& aStrength) const
|
1998-09-11 06:07:05 +04:00
|
|
|
{
|
|
|
|
aStrength = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-16 01:23:05 +04:00
|
|
|
NS_IMETHODIMP
|
2001-06-01 02:19:43 +04:00
|
|
|
CSSImportantRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
if (!aRuleData)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if (aRuleData->mFontData)
|
|
|
|
return MapFontForDeclaration(mDeclaration, *aRuleData->mFontData);
|
|
|
|
else if (aRuleData->mDisplayData)
|
|
|
|
return MapDisplayForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mDisplayData);
|
|
|
|
else if (aRuleData->mColorData)
|
|
|
|
return MapColorForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mColorData);
|
|
|
|
else if (aRuleData->mMarginData)
|
|
|
|
return MapMarginForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mMarginData);
|
|
|
|
else if (aRuleData->mListData)
|
|
|
|
return MapListForDeclaration(mDeclaration, *aRuleData->mListData);
|
|
|
|
else if (aRuleData->mPositionData)
|
|
|
|
return MapPositionForDeclaration(mDeclaration, *aRuleData->mPositionData);
|
|
|
|
else if (aRuleData->mTableData)
|
|
|
|
return MapTableForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mTableData);
|
|
|
|
else if (aRuleData->mContentData)
|
|
|
|
return MapContentForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mContentData);
|
|
|
|
else if (aRuleData->mTextData)
|
|
|
|
return MapTextForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mTextData);
|
|
|
|
else if (aRuleData->mUIData)
|
|
|
|
return MapUIForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mUIData);
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
else if (aRuleData->mXULData)
|
|
|
|
return MapXULForDeclaration(mDeclaration, *aRuleData->mXULData);
|
|
|
|
#endif
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
else if (aRuleData->mSVGData)
|
|
|
|
return MapSVGForDeclaration(mDeclaration, *aRuleData->mSVGData);
|
|
|
|
#endif
|
1999-04-16 01:23:05 +04:00
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
1998-09-11 06:07:05 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSImportantRule::List(FILE* out, PRInt32 aIndent) const
|
|
|
|
{
|
|
|
|
// Indent
|
|
|
|
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
fputs("! Important rule ", out);
|
|
|
|
if (nsnull != mDeclaration) {
|
|
|
|
mDeclaration->List(out);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("{ null declaration }", out);
|
|
|
|
}
|
|
|
|
fputs("\n", out);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* SizeOf method:
|
|
|
|
*
|
|
|
|
* Self (reported as CSSImportantRule's size):
|
|
|
|
* 1) sizeof(*this)
|
|
|
|
*
|
|
|
|
* Contained / Aggregated data (not reported as CSSImportantRule's size):
|
|
|
|
* 1) mDeclaration is sized seperately
|
|
|
|
* 2) mSheet is sized seperately
|
|
|
|
*
|
|
|
|
* Children / siblings / parents:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
void CSSImportantRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null");
|
|
|
|
|
|
|
|
// first get the unique items collection
|
|
|
|
UNIQUE_STYLE_ITEMS(uniqueItems);
|
|
|
|
if(! uniqueItems->AddItem((void*)this)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 localSize=0;
|
|
|
|
|
|
|
|
// create a tag for this instance
|
|
|
|
nsCOMPtr<nsIAtom> tag;
|
|
|
|
tag = getter_AddRefs(NS_NewAtom("CSSImportantRule"));
|
|
|
|
// get the size of an empty instance and add to the sizeof handler
|
|
|
|
aSize = sizeof(CSSImportantRule);
|
|
|
|
aSizeOfHandler->AddSize(tag,aSize);
|
|
|
|
|
|
|
|
// now dump the mDeclaration and mSheet
|
|
|
|
if(mDeclaration){
|
|
|
|
mDeclaration->SizeOf(aSizeOfHandler, localSize);
|
|
|
|
}
|
|
|
|
if(mSheet){
|
|
|
|
mSheet->SizeOf(aSizeOfHandler, localSize);
|
|
|
|
}
|
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
// -- nsDOMStyleRuleDeclaration -------------------------------
|
|
|
|
|
|
|
|
class DOMCSSDeclarationImpl : public nsDOMCSSDeclaration
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DOMCSSDeclarationImpl(nsICSSStyleRule *aRule);
|
1999-06-10 09:28:32 +04:00
|
|
|
~DOMCSSDeclarationImpl(void);
|
1998-10-06 05:39:33 +04:00
|
|
|
|
2000-08-23 21:27:06 +04:00
|
|
|
NS_IMETHOD RemoveProperty(const nsAReadableString& aPropertyName,
|
|
|
|
nsAWritableString& aReturn);
|
2000-04-20 17:50:56 +04:00
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
virtual void DropReference(void);
|
2002-01-16 01:43:37 +03:00
|
|
|
virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
1998-10-06 05:39:33 +04:00
|
|
|
PRBool aAllocate);
|
2002-01-16 01:43:37 +03:00
|
|
|
virtual nsresult SetCSSDeclaration(nsCSSDeclaration *aDecl);
|
2001-10-19 17:50:30 +04:00
|
|
|
virtual nsresult GetCSSParsingEnvironment(nsICSSStyleRule* aRule,
|
|
|
|
nsICSSStyleSheet** aSheet,
|
|
|
|
nsIDocument** aDocument,
|
|
|
|
nsIURI** aURI,
|
|
|
|
nsICSSLoader** aCSSLoader,
|
|
|
|
nsICSSParser** aCSSParser);
|
2001-09-28 05:38:36 +04:00
|
|
|
virtual nsresult ParsePropertyValue(const nsAReadableString& aPropName,
|
|
|
|
const nsAReadableString& aPropValue);
|
2000-08-23 21:27:06 +04:00
|
|
|
virtual nsresult ParseDeclaration(const nsAReadableString& aDecl,
|
2000-05-04 01:42:00 +04:00
|
|
|
PRBool aParseOnlyOneDecl,
|
|
|
|
PRBool aClearOldDecl);
|
1998-10-06 05:39:33 +04:00
|
|
|
virtual nsresult GetParent(nsISupports **aParent);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsICSSStyleRule *mRule;
|
|
|
|
};
|
|
|
|
|
2001-01-28 02:06:33 +03:00
|
|
|
MOZ_DECL_CTOR_COUNTER(DOMCSSDeclarationImpl)
|
1999-10-09 00:41:19 +04:00
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
DOMCSSDeclarationImpl::DOMCSSDeclarationImpl(nsICSSStyleRule *aRule)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(DOMCSSDeclarationImpl);
|
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
// This reference is not reference-counted. The rule
|
|
|
|
// object tells us when its about to go away.
|
|
|
|
mRule = aRule;
|
|
|
|
}
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
DOMCSSDeclarationImpl::~DOMCSSDeclarationImpl(void)
|
1998-10-06 05:39:33 +04:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_DTOR(DOMCSSDeclarationImpl);
|
1998-10-06 05:39:33 +04:00
|
|
|
}
|
|
|
|
|
2000-04-20 17:50:56 +04:00
|
|
|
NS_IMETHODIMP
|
2000-08-23 21:27:06 +04:00
|
|
|
DOMCSSDeclarationImpl::RemoveProperty(const nsAReadableString& aPropertyName,
|
|
|
|
nsAWritableString& aReturn)
|
2000-04-20 17:50:56 +04:00
|
|
|
{
|
|
|
|
aReturn.Truncate();
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* decl;
|
|
|
|
nsresult rv = GetCSSDeclaration(&decl, PR_TRUE);
|
2000-04-20 17:50:56 +04:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && decl) {
|
|
|
|
nsCSSProperty prop = nsCSSProps::LookupProperty(aPropertyName);
|
|
|
|
nsCSSValue val;
|
|
|
|
|
|
|
|
rv = decl->RemoveProperty(prop, val);
|
|
|
|
|
2000-05-02 04:24:45 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// We pass in eCSSProperty_UNKNOWN here so that we don't get the
|
|
|
|
// property name in the return string.
|
|
|
|
val.ToString(aReturn, eCSSProperty_UNKNOWN);
|
|
|
|
} else {
|
|
|
|
// If we tried to remove an invalid property or a property that wasn't
|
|
|
|
// set we simply return success and an empty string
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
2000-04-20 17:50:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
void
|
1999-06-10 09:28:32 +04:00
|
|
|
DOMCSSDeclarationImpl::DropReference(void)
|
1998-10-06 05:39:33 +04:00
|
|
|
{
|
|
|
|
mRule = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
DOMCSSDeclarationImpl::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
1998-10-06 05:39:33 +04:00
|
|
|
PRBool aAllocate)
|
|
|
|
{
|
|
|
|
if (nsnull != mRule) {
|
|
|
|
*aDecl = mRule->GetDeclaration();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aDecl = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-04 01:42:00 +04:00
|
|
|
nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
DOMCSSDeclarationImpl::SetCSSDeclaration(nsCSSDeclaration *aDecl)
|
2000-05-04 01:42:00 +04:00
|
|
|
{
|
|
|
|
if (nsnull != mRule) {
|
|
|
|
mRule->SetDeclaration(aDecl);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-10-19 17:50:30 +04:00
|
|
|
/*
|
|
|
|
* This is a utility function. It will only fail if it can't get a
|
|
|
|
* parser. This means it can return NS_OK without all of aSheet,
|
|
|
|
* aDocument, aURI, aCSSLoader being initialized
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsICSSStyleRule* aRule,
|
|
|
|
nsICSSStyleSheet** aSheet,
|
|
|
|
nsIDocument** aDocument,
|
|
|
|
nsIURI** aURI,
|
|
|
|
nsICSSLoader** aCSSLoader,
|
|
|
|
nsICSSParser** aCSSParser)
|
|
|
|
{
|
|
|
|
// null out the out params since some of them may not get initialized below
|
|
|
|
*aSheet = nsnull;
|
|
|
|
*aDocument = nsnull;
|
|
|
|
*aURI = nsnull;
|
|
|
|
*aCSSLoader = nsnull;
|
|
|
|
*aCSSParser = nsnull;
|
|
|
|
nsresult result;
|
|
|
|
nsCOMPtr<nsIStyleSheet> sheet;
|
|
|
|
if (aRule) {
|
|
|
|
aRule->GetStyleSheet(*getter_AddRefs(sheet));
|
|
|
|
if (sheet) {
|
|
|
|
CallQueryInterface(sheet, aSheet);
|
|
|
|
sheet->GetOwningDocument(*aDocument);
|
|
|
|
sheet->GetURL(*aURI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(*aDocument));
|
|
|
|
if (htmlContainer) {
|
|
|
|
htmlContainer->GetCSSLoader(*aCSSLoader);
|
|
|
|
}
|
|
|
|
NS_ASSERTION(*aCSSLoader || !*aDocument, "Document with no CSS loader!");
|
|
|
|
if (*aCSSLoader) {
|
|
|
|
result = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
|
|
|
|
} else {
|
|
|
|
result = NS_NewCSSParser(aCSSParser);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-09-28 05:38:36 +04:00
|
|
|
nsresult
|
|
|
|
DOMCSSDeclarationImpl::ParsePropertyValue(const nsAReadableString& aPropName,
|
|
|
|
const nsAReadableString& aPropValue)
|
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* decl;
|
|
|
|
nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
|
2001-09-28 05:38:36 +04:00
|
|
|
if (!decl) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsICSSLoader> cssLoader;
|
|
|
|
nsCOMPtr<nsICSSParser> cssParser;
|
|
|
|
nsCOMPtr<nsIURI> baseURI;
|
|
|
|
nsCOMPtr<nsICSSStyleSheet> cssSheet;
|
|
|
|
nsCOMPtr<nsIDocument> owningDoc;
|
2001-10-19 17:50:30 +04:00
|
|
|
result = GetCSSParsingEnvironment(mRule,
|
|
|
|
getter_AddRefs(cssSheet),
|
|
|
|
getter_AddRefs(owningDoc),
|
|
|
|
getter_AddRefs(baseURI),
|
|
|
|
getter_AddRefs(cssLoader),
|
|
|
|
getter_AddRefs(cssParser));
|
|
|
|
|
2001-09-28 05:38:36 +04:00
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
2001-10-19 17:50:30 +04:00
|
|
|
|
2001-09-28 05:38:36 +04:00
|
|
|
PRInt32 hint;
|
|
|
|
if (owningDoc) {
|
|
|
|
owningDoc->BeginUpdate();
|
|
|
|
}
|
|
|
|
result = cssParser->ParseProperty(aPropName, aPropValue, baseURI, decl, &hint);
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
if (cssSheet) {
|
|
|
|
cssSheet->SetModified(PR_TRUE);
|
|
|
|
}
|
|
|
|
if (owningDoc) {
|
|
|
|
owningDoc->StyleRuleChanged(cssSheet, mRule, hint);
|
|
|
|
owningDoc->EndUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cssLoader) {
|
|
|
|
cssLoader->RecycleParser(cssParser);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
nsresult
|
2000-08-23 21:27:06 +04:00
|
|
|
DOMCSSDeclarationImpl::ParseDeclaration(const nsAReadableString& aDecl,
|
2000-05-04 01:42:00 +04:00
|
|
|
PRBool aParseOnlyOneDecl,
|
|
|
|
PRBool aClearOldDecl)
|
1999-08-04 09:07:10 +04:00
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* decl;
|
|
|
|
nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
|
1999-08-04 09:07:10 +04:00
|
|
|
|
2001-09-28 05:38:36 +04:00
|
|
|
if (decl) {
|
|
|
|
nsCOMPtr<nsICSSLoader> cssLoader;
|
|
|
|
nsCOMPtr<nsICSSParser> cssParser;
|
|
|
|
nsCOMPtr<nsIURI> baseURI;
|
|
|
|
nsCOMPtr<nsICSSStyleSheet> cssSheet;
|
|
|
|
nsCOMPtr<nsIDocument> owningDoc;
|
1999-08-04 09:07:10 +04:00
|
|
|
|
2001-10-19 17:50:30 +04:00
|
|
|
result = GetCSSParsingEnvironment(mRule,
|
|
|
|
getter_AddRefs(cssSheet),
|
|
|
|
getter_AddRefs(owningDoc),
|
|
|
|
getter_AddRefs(baseURI),
|
|
|
|
getter_AddRefs(cssLoader),
|
|
|
|
getter_AddRefs(cssParser));
|
1999-08-04 09:07:10 +04:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* declClone = decl->Clone();
|
2000-05-04 01:42:00 +04:00
|
|
|
NS_ENSURE_TRUE(declClone, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
if (aClearOldDecl) {
|
|
|
|
// This should be done with decl->Clear() once such a method exists.
|
|
|
|
nsAutoString propName;
|
|
|
|
PRUint32 count, i;
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
count = decl->Count();
|
2000-05-04 01:42:00 +04:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
decl->GetNthProperty(0, propName);
|
|
|
|
|
|
|
|
nsCSSProperty prop = nsCSSProps::LookupProperty(propName);
|
|
|
|
nsCSSValue val;
|
|
|
|
|
|
|
|
decl->RemoveProperty(prop, val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-04 09:07:10 +04:00
|
|
|
PRInt32 hint;
|
2000-05-04 01:42:00 +04:00
|
|
|
result = cssParser->ParseAndAppendDeclaration(aDecl, baseURI, decl,
|
|
|
|
aParseOnlyOneDecl, &hint);
|
|
|
|
|
|
|
|
if (result == NS_CSS_PARSER_DROP_DECLARATION) {
|
|
|
|
SetCSSDeclaration(declClone);
|
|
|
|
result = NS_OK;
|
|
|
|
} else if (NS_SUCCEEDED(result)) {
|
1999-08-04 09:07:10 +04:00
|
|
|
if (cssSheet) {
|
|
|
|
cssSheet->SetModified(PR_TRUE);
|
|
|
|
}
|
|
|
|
if (owningDoc) {
|
|
|
|
owningDoc->StyleRuleChanged(cssSheet, mRule, hint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cssLoader) {
|
|
|
|
cssLoader->RecycleParser(cssParser);
|
1999-06-03 05:57:13 +04:00
|
|
|
}
|
1998-11-26 04:34:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-04 09:07:10 +04:00
|
|
|
return result;
|
1998-10-06 05:39:33 +04:00
|
|
|
}
|
|
|
|
|
1999-08-04 09:07:10 +04:00
|
|
|
|
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
nsresult
|
|
|
|
DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
|
|
|
|
{
|
|
|
|
if (nsnull != mRule) {
|
|
|
|
return mRule->QueryInterface(kISupportsIID, (void **)aParent);
|
2000-04-20 17:50:56 +04:00
|
|
|
} else {
|
|
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
|
|
|
*aParent = nsnull;
|
1998-10-06 05:39:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-11 06:07:05 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// -- nsCSSStyleRule -------------------------------
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
class CSSStyleRuleImpl : public nsCSSRule,
|
|
|
|
public nsICSSStyleRule,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
public nsIDOMCSSStyleRule
|
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
public:
|
|
|
|
CSSStyleRuleImpl(const nsCSSSelector& aSelector);
|
1999-06-03 05:57:13 +04:00
|
|
|
CSSStyleRuleImpl(const CSSStyleRuleImpl& aCopy);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
// NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aResult) const;
|
|
|
|
// NS_IMETHOD HashValue(PRUint32& aValue) const;
|
1998-09-11 06:07:05 +04:00
|
|
|
// Strength is an out-of-band weighting, useful for mapping CSS ! important
|
1998-12-20 04:16:20 +03:00
|
|
|
NS_IMETHOD GetStrength(PRInt32& aStrength) const;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
virtual nsCSSSelector* FirstSelector(void);
|
|
|
|
virtual void AddSelector(const nsCSSSelector& aSelector);
|
|
|
|
virtual void DeleteSelector(nsCSSSelector* aSelector);
|
1998-12-11 05:50:43 +03:00
|
|
|
virtual void SetSourceSelectorText(const nsString& aSelectorText);
|
|
|
|
virtual void GetSourceSelectorText(nsString& aSelectorText) const;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-01-22 07:03:48 +03:00
|
|
|
virtual PRUint32 GetLineNumber(void) const;
|
|
|
|
virtual void SetLineNumber(PRUint32 aLineNumber);
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
virtual nsCSSDeclaration* GetDeclaration(void) const;
|
|
|
|
virtual void SetDeclaration(nsCSSDeclaration* aDeclaration);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
virtual PRInt32 GetWeight(void) const;
|
|
|
|
virtual void SetWeight(PRInt32 aWeight);
|
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
virtual nsIStyleRule* GetImportantRule(void);
|
1998-09-02 06:09:43 +04:00
|
|
|
|
2002-01-16 04:34:47 +03:00
|
|
|
// hook for inspector
|
|
|
|
virtual nsresult GetValue(nsCSSProperty aProperty, nsCSSValue& aValue);
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
|
|
|
|
NS_IMETHOD SetStyleSheet(nsICSSStyleSheet* aSheet);
|
2001-09-19 18:16:34 +04:00
|
|
|
|
|
|
|
NS_IMETHOD SetParentRule(nsICSSGroupRule* aRule);
|
1998-10-06 05:39:33 +04:00
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
NS_IMETHOD GetType(PRInt32& aType) const;
|
|
|
|
NS_IMETHOD Clone(nsICSSRule*& aClone) const;
|
1999-06-03 05:57:13 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// The new mapping function.
|
|
|
|
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
1998-08-30 00:20:38 +04:00
|
|
|
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize);
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
// nsIDOMCSSRule interface
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
NS_DECL_NSIDOMCSSRULE
|
1998-10-06 05:39:33 +04:00
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
// nsIDOMCSSStyleRule interface
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
NS_DECL_NSIDOMCSSSTYLERULE
|
1998-10-06 05:39:33 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
private:
|
|
|
|
// These are not supported and are not implemented!
|
|
|
|
CSSStyleRuleImpl& operator=(const CSSStyleRuleImpl& aCopy);
|
|
|
|
|
|
|
|
protected:
|
1999-06-10 09:28:32 +04:00
|
|
|
virtual ~CSSStyleRuleImpl(void);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
protected:
|
1998-11-26 04:34:53 +03:00
|
|
|
nsCSSSelector mSelector;
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* mDeclaration;
|
1998-11-26 04:34:53 +03:00
|
|
|
PRInt32 mWeight;
|
|
|
|
CSSImportantRule* mImportantRule;
|
|
|
|
DOMCSSDeclarationImpl* mDOMDeclaration;
|
2001-01-22 07:03:48 +03:00
|
|
|
PRUint32 mLineNumber;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
PRUint32 gStyleRuleCount=0;
|
|
|
|
#endif
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
CSSStyleRuleImpl::CSSStyleRuleImpl(const nsCSSSelector& aSelector)
|
1999-06-10 09:28:32 +04:00
|
|
|
: nsCSSRule(),
|
2000-09-13 04:05:04 +04:00
|
|
|
mSelector(aSelector), mDeclaration(nsnull),
|
1999-06-10 09:28:32 +04:00
|
|
|
mWeight(0), mImportantRule(nsnull),
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
mDOMDeclaration(nsnull)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2000-03-31 11:08:36 +04:00
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gStyleRuleCount++;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "CSSStyleRuleImpl Instances (ctor): %ld\n", (long)gStyleRuleCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-06-03 05:57:13 +04:00
|
|
|
CSSStyleRuleImpl::CSSStyleRuleImpl(const CSSStyleRuleImpl& aCopy)
|
1999-06-10 09:28:32 +04:00
|
|
|
: nsCSSRule(aCopy),
|
|
|
|
mSelector(aCopy.mSelector),
|
1999-06-03 05:57:13 +04:00
|
|
|
mDeclaration(nsnull),
|
|
|
|
mWeight(aCopy.mWeight),
|
|
|
|
mImportantRule(nsnull),
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
mDOMDeclaration(nsnull)
|
1999-06-03 05:57:13 +04:00
|
|
|
{
|
2000-03-31 11:08:36 +04:00
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gStyleRuleCount++;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "CSSStyleRuleImpl Instances (cp-ctor): %ld\n", (long)gStyleRuleCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
|
|
|
|
1999-06-03 05:57:13 +04:00
|
|
|
nsCSSSelector* copySel = aCopy.mSelector.mNext;
|
|
|
|
nsCSSSelector* ourSel = &mSelector;
|
|
|
|
|
|
|
|
while (copySel && ourSel) {
|
|
|
|
ourSel->mNext = new nsCSSSelector(*copySel);
|
|
|
|
ourSel = ourSel->mNext;
|
|
|
|
copySel = copySel->mNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aCopy.mDeclaration) {
|
2002-01-16 01:43:37 +03:00
|
|
|
mDeclaration = aCopy.mDeclaration->Clone();
|
|
|
|
if (nsnull != mDeclaration) {
|
|
|
|
mDeclaration->AddRef();
|
|
|
|
}
|
1999-06-03 05:57:13 +04:00
|
|
|
}
|
|
|
|
// rest is constructed lazily on existing data
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
CSSStyleRuleImpl::~CSSStyleRuleImpl(void)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2000-03-31 11:08:36 +04:00
|
|
|
#ifdef DEBUG_REFS
|
|
|
|
gStyleRuleCount--;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf( "CSSStyleRuleImpl Instances (dtor): %ld\n", (long)gStyleRuleCount);
|
2000-03-31 11:08:36 +04:00
|
|
|
#endif
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
nsCSSSelector* next = mSelector.mNext;
|
|
|
|
|
|
|
|
while (nsnull != next) {
|
|
|
|
nsCSSSelector* selector = next;
|
|
|
|
next = selector->mNext;
|
|
|
|
delete selector;
|
|
|
|
}
|
2002-01-16 01:43:37 +03:00
|
|
|
if (nsnull != mDeclaration) {
|
|
|
|
mDeclaration->Release();
|
|
|
|
mDeclaration = nsnull;
|
|
|
|
}
|
1998-11-26 04:34:53 +03:00
|
|
|
if (nsnull != mImportantRule) {
|
|
|
|
mImportantRule->mSheet = nsnull;
|
2002-01-24 21:28:25 +03:00
|
|
|
NS_RELEASE(mImportantRule);
|
2002-01-16 01:43:37 +03:00
|
|
|
mImportantRule = nsnull;
|
1998-11-26 04:34:53 +03:00
|
|
|
}
|
1998-10-06 05:39:33 +04:00
|
|
|
if (nsnull != mDOMDeclaration) {
|
|
|
|
mDOMDeclaration->DropReference();
|
|
|
|
}
|
1998-04-22 10:40:21 +04:00
|
|
|
}
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
// QueryInterface implementation for CSSStyleRuleImpl
|
|
|
|
NS_INTERFACE_MAP_BEGIN(CSSStyleRuleImpl)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsICSSStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsICSSRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCSSStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSStyleRule)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CSSStyleRule)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(CSSStyleRuleImpl, nsCSSRule);
|
|
|
|
NS_IMPL_RELEASE_INHERITED(CSSStyleRuleImpl, nsCSSRule);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
|
1999-06-10 09:28:32 +04:00
|
|
|
#if 0
|
1998-09-02 06:09:43 +04:00
|
|
|
NS_IMETHODIMP CSSStyleRuleImpl::Equals(const nsIStyleRule* aRule, PRBool& aResult) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
nsICSSStyleRule* iCSSRule;
|
|
|
|
|
|
|
|
if (this == aRule) {
|
1998-09-02 06:09:43 +04:00
|
|
|
aResult = PR_TRUE;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-09-02 06:09:43 +04:00
|
|
|
else {
|
|
|
|
aResult = PR_FALSE;
|
|
|
|
if ((nsnull != aRule) &&
|
2001-01-04 23:44:42 +03:00
|
|
|
(NS_OK == ((nsIStyleRule*)aRule)->QueryInterface(NS_GET_IID(nsICSSStyleRule), (void**) &iCSSRule))) {
|
1998-09-02 06:09:43 +04:00
|
|
|
|
|
|
|
CSSStyleRuleImpl* rule = (CSSStyleRuleImpl*)iCSSRule;
|
|
|
|
const nsCSSSelector* local = &mSelector;
|
|
|
|
const nsCSSSelector* other = &(rule->mSelector);
|
|
|
|
aResult = PR_TRUE;
|
|
|
|
|
|
|
|
if ((rule->mDeclaration != mDeclaration) ||
|
|
|
|
(rule->mWeight != mWeight)) {
|
|
|
|
aResult = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-09-02 06:09:43 +04:00
|
|
|
while ((PR_TRUE == aResult) && (nsnull != local) && (nsnull != other)) {
|
|
|
|
if (! local->Equals(other)) {
|
|
|
|
aResult = PR_FALSE;
|
|
|
|
}
|
|
|
|
local = local->mNext;
|
|
|
|
other = other->mNext;
|
|
|
|
}
|
|
|
|
if ((nsnull != local) || (nsnull != other)) { // more were left
|
|
|
|
aResult = PR_FALSE;
|
|
|
|
}
|
|
|
|
NS_RELEASE(iCSSRule);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-02 06:09:43 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-09-02 06:09:43 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSStyleRuleImpl::HashValue(PRUint32& aValue) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-02 06:09:43 +04:00
|
|
|
aValue = (PRUint32)this;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-06-10 09:28:32 +04:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
// Strength is an out-of-band weighting, useful for mapping CSS ! important
|
|
|
|
NS_IMETHODIMP
|
1998-12-20 04:16:20 +03:00
|
|
|
CSSStyleRuleImpl::GetStrength(PRInt32& aStrength) const
|
1998-09-11 06:07:05 +04:00
|
|
|
{
|
|
|
|
aStrength = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
nsCSSSelector* CSSStyleRuleImpl::FirstSelector(void)
|
|
|
|
{
|
|
|
|
return &mSelector;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
|
|
|
{
|
1998-12-11 05:50:43 +03:00
|
|
|
nsCSSSelector* selector = new nsCSSSelector(aSelector);
|
|
|
|
nsCSSSelector* last = &mSelector;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
while (nsnull != last->mNext) {
|
|
|
|
last = last->mNext;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
last->mNext = selector;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSSStyleRuleImpl::DeleteSelector(nsCSSSelector* aSelector)
|
|
|
|
{
|
|
|
|
if (nsnull != aSelector) {
|
|
|
|
if (&mSelector == aSelector) { // handle first selector
|
1998-12-11 05:50:43 +03:00
|
|
|
if (nsnull != mSelector.mNext) {
|
|
|
|
nsCSSSelector* nextOne = mSelector.mNext;
|
|
|
|
mSelector = *nextOne; // assign values
|
|
|
|
mSelector.mNext = nextOne->mNext;
|
|
|
|
delete nextOne;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mSelector.Reset();
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsCSSSelector* selector = &mSelector;
|
|
|
|
|
|
|
|
while (nsnull != selector->mNext) {
|
|
|
|
if (aSelector == selector->mNext) {
|
|
|
|
selector->mNext = aSelector->mNext;
|
|
|
|
delete aSelector;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
selector = selector->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-11 05:50:43 +03:00
|
|
|
void CSSStyleRuleImpl::SetSourceSelectorText(const nsString& aSelectorText)
|
|
|
|
{
|
2000-09-13 04:05:04 +04:00
|
|
|
/* no need for set, since get recreates the string */
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSSStyleRuleImpl::GetSourceSelectorText(nsString& aSelectorText) const
|
|
|
|
{
|
2001-03-20 14:49:20 +03:00
|
|
|
mSelector.ToString( aSelectorText, mSheet, IsPseudoElement(mSelector.mTag),
|
|
|
|
0 );
|
2001-01-22 07:03:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 CSSStyleRuleImpl::GetLineNumber(void) const
|
|
|
|
{
|
|
|
|
return mLineNumber;
|
1998-12-11 05:50:43 +03:00
|
|
|
}
|
|
|
|
|
2001-01-22 07:03:48 +03:00
|
|
|
void CSSStyleRuleImpl::SetLineNumber(PRUint32 aLineNumber)
|
|
|
|
{
|
|
|
|
mLineNumber = aLineNumber;
|
|
|
|
}
|
1998-12-11 05:50:43 +03:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* CSSStyleRuleImpl::GetDeclaration(void) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* result = mDeclaration;
|
2000-02-18 02:19:18 +03:00
|
|
|
return result;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
void CSSStyleRuleImpl::SetDeclaration(nsCSSDeclaration* aDeclaration)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-11-26 04:34:53 +03:00
|
|
|
if (mDeclaration != aDeclaration) {
|
|
|
|
NS_IF_RELEASE(mImportantRule);
|
2002-01-16 01:43:37 +03:00
|
|
|
if (nsnull != mDeclaration) {
|
|
|
|
mDeclaration->Release();
|
|
|
|
}
|
1998-11-26 04:34:53 +03:00
|
|
|
mDeclaration = aDeclaration;
|
2002-01-16 01:43:37 +03:00
|
|
|
mDeclaration->AddRef();
|
1998-11-26 04:34:53 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 CSSStyleRuleImpl::GetWeight(void) const
|
|
|
|
{
|
|
|
|
return mWeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSSStyleRuleImpl::SetWeight(PRInt32 aWeight)
|
|
|
|
{
|
|
|
|
mWeight = aWeight;
|
|
|
|
}
|
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
nsIStyleRule* CSSStyleRuleImpl::GetImportantRule(void)
|
|
|
|
{
|
|
|
|
if ((nsnull == mImportantRule) && (nsnull != mDeclaration)) {
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* important = mDeclaration->GetImportantValues();
|
1998-09-11 06:07:05 +04:00
|
|
|
if (nsnull != important) {
|
1998-11-26 04:34:53 +03:00
|
|
|
mImportantRule = new CSSImportantRule(mSheet, important);
|
1998-09-11 06:07:05 +04:00
|
|
|
NS_ADDREF(mImportantRule);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_ADDREF(mImportantRule);
|
|
|
|
return mImportantRule;
|
|
|
|
}
|
|
|
|
|
2002-01-16 04:34:47 +03:00
|
|
|
nsresult
|
|
|
|
CSSStyleRuleImpl::GetValue(nsCSSProperty aProperty, nsCSSValue& aValue)
|
|
|
|
{
|
|
|
|
return mDeclaration->GetValue(aProperty, aValue);
|
|
|
|
}
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSStyleRuleImpl::GetStyleSheet(nsIStyleSheet*& aSheet) const
|
1998-10-06 05:39:33 +04:00
|
|
|
{
|
1999-06-10 09:28:32 +04:00
|
|
|
return nsCSSRule::GetStyleSheet(aSheet);
|
1998-10-06 05:39:33 +04:00
|
|
|
}
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSStyleRuleImpl::SetStyleSheet(nsICSSStyleSheet* aSheet)
|
1998-10-06 05:39:33 +04:00
|
|
|
{
|
1999-06-10 09:28:32 +04:00
|
|
|
nsCSSRule::SetStyleSheet(aSheet);
|
1998-11-26 04:34:53 +03:00
|
|
|
if (nsnull != mImportantRule) { // we're responsible for this guy too
|
|
|
|
mImportantRule->mSheet = aSheet;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-10-06 05:39:33 +04:00
|
|
|
}
|
|
|
|
|
2001-09-19 18:16:34 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSStyleRuleImpl::SetParentRule(nsICSSGroupRule* aRule)
|
|
|
|
{
|
|
|
|
return nsCSSRule::SetParentRule(aRule);
|
|
|
|
}
|
|
|
|
|
1999-06-03 05:57:13 +04:00
|
|
|
NS_IMETHODIMP
|
1999-06-10 09:28:32 +04:00
|
|
|
CSSStyleRuleImpl::GetType(PRInt32& aType) const
|
|
|
|
{
|
|
|
|
aType = nsICSSRule::STYLE_RULE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSStyleRuleImpl::Clone(nsICSSRule*& aClone) const
|
1999-06-03 05:57:13 +04:00
|
|
|
{
|
|
|
|
CSSStyleRuleImpl* clone = new CSSStyleRuleImpl(*this);
|
|
|
|
if (clone) {
|
2001-01-04 23:44:42 +03:00
|
|
|
return clone->QueryInterface(NS_GET_IID(nsICSSRule), (void **)&aClone);
|
1999-06-03 05:57:13 +04:00
|
|
|
}
|
|
|
|
aClone = nsnull;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
1999-04-16 01:23:05 +04:00
|
|
|
NS_IMETHODIMP
|
2001-06-01 02:19:43 +04:00
|
|
|
CSSStyleRuleImpl::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
|
|
{
|
|
|
|
if (!aRuleData)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if (aRuleData->mFontData)
|
|
|
|
return MapFontForDeclaration(mDeclaration, *aRuleData->mFontData);
|
|
|
|
else if (aRuleData->mDisplayData)
|
|
|
|
return MapDisplayForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mDisplayData);
|
|
|
|
else if (aRuleData->mColorData)
|
|
|
|
return MapColorForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mColorData);
|
|
|
|
else if (aRuleData->mMarginData)
|
|
|
|
return MapMarginForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mMarginData);
|
|
|
|
else if (aRuleData->mListData)
|
|
|
|
return MapListForDeclaration(mDeclaration, *aRuleData->mListData);
|
|
|
|
else if (aRuleData->mPositionData)
|
|
|
|
return MapPositionForDeclaration(mDeclaration, *aRuleData->mPositionData);
|
|
|
|
else if (aRuleData->mTableData)
|
|
|
|
return MapTableForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mTableData);
|
|
|
|
else if (aRuleData->mContentData)
|
|
|
|
return MapContentForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mContentData);
|
|
|
|
else if (aRuleData->mTextData)
|
|
|
|
return MapTextForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mTextData);
|
|
|
|
else if (aRuleData->mUIData)
|
|
|
|
return MapUIForDeclaration(mDeclaration, aRuleData->mSID, *aRuleData->mUIData);
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
else if (aRuleData->mXULData)
|
|
|
|
return MapXULForDeclaration(mDeclaration, *aRuleData->mXULData);
|
|
|
|
#endif
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
else if (aRuleData->mSVGData)
|
|
|
|
return MapSVGForDeclaration(mDeclaration, *aRuleData->mSVGData);
|
|
|
|
#endif
|
1999-04-16 01:23:05 +04:00
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapFontForDeclaration(nsCSSDeclaration* aDecl, nsCSSFont& aFont)
|
1999-04-02 22:49:40 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
1999-04-02 22:49:40 +04:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSFont* ourFont = (nsCSSFont*)aDecl->GetData(kCSSFontSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourFont)
|
|
|
|
return NS_OK; // We don't have any rules for fonts.
|
1999-04-02 22:49:40 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aFont.mFamily.GetUnit() && eCSSUnit_Null != ourFont->mFamily.GetUnit())
|
|
|
|
aFont.mFamily = ourFont->mFamily;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aFont.mStyle.GetUnit() && eCSSUnit_Null != ourFont->mStyle.GetUnit())
|
|
|
|
aFont.mStyle = ourFont->mStyle;
|
2000-08-23 14:28:28 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aFont.mVariant.GetUnit() && eCSSUnit_Null != ourFont->mVariant.GetUnit())
|
|
|
|
aFont.mVariant = ourFont->mVariant;
|
2000-03-25 21:54:36 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aFont.mWeight.GetUnit() && eCSSUnit_Null != ourFont->mWeight.GetUnit())
|
|
|
|
aFont.mWeight = ourFont->mWeight;
|
2000-09-21 14:21:23 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aFont.mSize.GetUnit() && eCSSUnit_Null != ourFont->mSize.GetUnit())
|
|
|
|
aFont.mSize = ourFont->mSize;
|
2000-09-21 14:21:23 +04:00
|
|
|
|
2001-09-27 22:33:58 +04:00
|
|
|
if (eCSSUnit_Null == aFont.mSizeAdjust.GetUnit() && eCSSUnit_Null != ourFont->mSizeAdjust.GetUnit())
|
|
|
|
aFont.mSizeAdjust = ourFont->mSizeAdjust;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapXULForDeclaration(nsCSSDeclaration* aDecl, nsCSSXUL& aXUL)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSXUL* ourXUL = (nsCSSXUL*)aDecl->GetData(kCSSXULSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourXUL)
|
|
|
|
return NS_OK; // We don't have any rules for XUL.
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-08-02 04:09:27 +04:00
|
|
|
// box-align: enum, inherit
|
|
|
|
if (aXUL.mBoxAlign.GetUnit() == eCSSUnit_Null && ourXUL->mBoxAlign.GetUnit() != eCSSUnit_Null)
|
|
|
|
aXUL.mBoxAlign = ourXUL->mBoxAlign;
|
|
|
|
|
|
|
|
// box-direction: enum, inherit
|
|
|
|
if (aXUL.mBoxDirection.GetUnit() == eCSSUnit_Null && ourXUL->mBoxDirection.GetUnit() != eCSSUnit_Null)
|
|
|
|
aXUL.mBoxDirection = ourXUL->mBoxDirection;
|
|
|
|
|
|
|
|
// box-flex: enum, inherit
|
|
|
|
if (aXUL.mBoxFlex.GetUnit() == eCSSUnit_Null && ourXUL->mBoxFlex.GetUnit() != eCSSUnit_Null)
|
|
|
|
aXUL.mBoxFlex = ourXUL->mBoxFlex;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// box-orient: enum, inherit
|
|
|
|
if (aXUL.mBoxOrient.GetUnit() == eCSSUnit_Null && ourXUL->mBoxOrient.GetUnit() != eCSSUnit_Null)
|
|
|
|
aXUL.mBoxOrient = ourXUL->mBoxOrient;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-08-02 04:09:27 +04:00
|
|
|
// box-pack: enum, inherit
|
|
|
|
if (aXUL.mBoxPack.GetUnit() == eCSSUnit_Null && ourXUL->mBoxPack.GetUnit() != eCSSUnit_Null)
|
|
|
|
aXUL.mBoxPack = ourXUL->mBoxPack;
|
|
|
|
|
2001-09-26 02:17:00 +04:00
|
|
|
// box-ordinal-group: number
|
|
|
|
if (aXUL.mBoxOrdinal.GetUnit() == eCSSUnit_Null && ourXUL->mBoxOrdinal.GetUnit() != eCSSUnit_Null)
|
|
|
|
aXUL.mBoxOrdinal = ourXUL->mBoxOrdinal;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_OK;
|
1999-04-16 01:23:05 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
#endif
|
1999-04-16 01:23:05 +04:00
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapSVGForDeclaration(nsCSSDeclaration* aDecl, nsCSSSVG& aSVG)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSSVG* ourSVG = (nsCSSSVG*)aDecl->GetData(kCSSSVGSID);
|
2001-12-12 10:59:31 +03:00
|
|
|
if (!ourSVG)
|
|
|
|
return NS_OK; // We don't have any rules for SVG.
|
|
|
|
|
|
|
|
// fill:
|
|
|
|
if (aSVG.mFill.GetUnit() == eCSSUnit_Null && ourSVG->mFill.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mFill = ourSVG->mFill;
|
|
|
|
// fill-opacity:
|
|
|
|
if (aSVG.mFillOpacity.GetUnit() == eCSSUnit_Null && ourSVG->mFillOpacity.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mFillOpacity = ourSVG->mFillOpacity;
|
|
|
|
// fill-rule:
|
|
|
|
if (aSVG.mFillRule.GetUnit() == eCSSUnit_Null && ourSVG->mFillRule.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mFillRule = ourSVG->mFillRule;
|
|
|
|
// stroke:
|
|
|
|
if (aSVG.mStroke.GetUnit() == eCSSUnit_Null && ourSVG->mStroke.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mStroke = ourSVG->mStroke;
|
|
|
|
// stroke-dasharray:
|
|
|
|
if (aSVG.mStrokeDasharray.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeDasharray.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mStrokeDasharray = ourSVG->mStrokeDasharray;
|
|
|
|
// stroke-dashoffset:
|
|
|
|
if (aSVG.mStrokeDashoffset.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeDashoffset.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mStrokeDashoffset = ourSVG->mStrokeDashoffset;
|
|
|
|
// stroke-linecap: enum, inherit
|
|
|
|
if (aSVG.mStrokeLinecap.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeLinecap.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mStrokeLinecap = ourSVG->mStrokeLinecap;
|
|
|
|
// stroke-linejoin
|
|
|
|
if (aSVG.mStrokeLinejoin.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeLinejoin.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mStrokeLinejoin = ourSVG->mStrokeLinejoin;
|
|
|
|
// stroke-miterlimit:
|
|
|
|
if (aSVG.mStrokeMiterlimit.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeMiterlimit.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mStrokeMiterlimit = ourSVG->mStrokeMiterlimit;
|
|
|
|
// stroke-opacity:
|
|
|
|
if (aSVG.mStrokeOpacity.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeOpacity.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mStrokeOpacity = ourSVG->mStrokeOpacity;
|
|
|
|
// stroke-width:
|
|
|
|
if (aSVG.mStrokeWidth.GetUnit() == eCSSUnit_Null && ourSVG->mStrokeWidth.GetUnit() != eCSSUnit_Null)
|
|
|
|
aSVG.mStrokeWidth = ourSVG->mStrokeWidth;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapPositionForDeclaration(nsCSSDeclaration* aDecl, nsCSSPosition& aPosition)
|
1999-04-16 01:23:05 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSPosition* ourPosition = (nsCSSPosition*)aDecl->GetData(kCSSPositionSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourPosition)
|
|
|
|
return NS_OK; // We don't have any rules for position.
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// box offsets: length, percent, auto, inherit
|
|
|
|
if (ourPosition->mOffset) {
|
|
|
|
if (aPosition.mOffset->mLeft.GetUnit() == eCSSUnit_Null && ourPosition->mOffset->mLeft.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mOffset->mLeft = ourPosition->mOffset->mLeft;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aPosition.mOffset->mRight.GetUnit() == eCSSUnit_Null && ourPosition->mOffset->mRight.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mOffset->mRight = ourPosition->mOffset->mRight;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aPosition.mOffset->mTop.GetUnit() == eCSSUnit_Null && ourPosition->mOffset->mTop.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mOffset->mTop = ourPosition->mOffset->mTop;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aPosition.mOffset->mBottom.GetUnit() == eCSSUnit_Null && ourPosition->mOffset->mBottom.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mOffset->mBottom = ourPosition->mOffset->mBottom;
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// width/min-width/max-width
|
|
|
|
if (aPosition.mWidth.GetUnit() == eCSSUnit_Null && ourPosition->mWidth.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mWidth = ourPosition->mWidth;
|
|
|
|
if (aPosition.mMinWidth.GetUnit() == eCSSUnit_Null && ourPosition->mMinWidth.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mMinWidth = ourPosition->mMinWidth;
|
|
|
|
if (aPosition.mMaxWidth.GetUnit() == eCSSUnit_Null && ourPosition->mMaxWidth.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mMaxWidth = ourPosition->mMaxWidth;
|
1998-04-28 01:26:06 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// height/min-height/max-height
|
|
|
|
if (aPosition.mHeight.GetUnit() == eCSSUnit_Null && ourPosition->mHeight.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mHeight = ourPosition->mHeight;
|
|
|
|
if (aPosition.mMinHeight.GetUnit() == eCSSUnit_Null && ourPosition->mMinHeight.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mMinHeight = ourPosition->mMinHeight;
|
|
|
|
if (aPosition.mMaxHeight.GetUnit() == eCSSUnit_Null && ourPosition->mMaxHeight.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mMaxHeight = ourPosition->mMaxHeight;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// box-sizing: enum, inherit
|
|
|
|
if (aPosition.mBoxSizing.GetUnit() == eCSSUnit_Null && ourPosition->mBoxSizing.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mBoxSizing = ourPosition->mBoxSizing;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// z-index
|
|
|
|
if (aPosition.mZIndex.GetUnit() == eCSSUnit_Null && ourPosition->mZIndex.GetUnit() != eCSSUnit_Null)
|
|
|
|
aPosition.mZIndex = ourPosition->mZIndex;
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_OK;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapListForDeclaration(nsCSSDeclaration* aDecl, nsCSSList& aList)
|
1999-09-10 09:56:19 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
1998-05-27 03:16:55 +04:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSList* ourList = (nsCSSList*)aDecl->GetData(kCSSListSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourList)
|
|
|
|
return NS_OK; // We don't have any rules for lists.
|
|
|
|
|
|
|
|
// list-style-type: enum, none, inherit
|
|
|
|
if (aList.mType.GetUnit() == eCSSUnit_Null && ourList->mType.GetUnit() != eCSSUnit_Null)
|
|
|
|
aList.mType = ourList->mType;
|
|
|
|
|
|
|
|
// list-style-image: url, none, inherit
|
|
|
|
if (aList.mImage.GetUnit() == eCSSUnit_Null && ourList->mImage.GetUnit() != eCSSUnit_Null)
|
|
|
|
aList.mImage = ourList->mImage;
|
|
|
|
|
|
|
|
// list-style-position: enum, inherit
|
|
|
|
if (aList.mPosition.GetUnit() == eCSSUnit_Null && ourList->mPosition.GetUnit() != eCSSUnit_Null)
|
|
|
|
aList.mPosition = ourList->mPosition;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-12-05 11:35:05 +03:00
|
|
|
// image region: length, auto or inherit
|
|
|
|
if (ourList->mImageRegion) {
|
|
|
|
if (aList.mImageRegion->mLeft.GetUnit() == eCSSUnit_Null &&
|
|
|
|
ourList->mImageRegion->mLeft.GetUnit() != eCSSUnit_Null)
|
|
|
|
aList.mImageRegion->mLeft = ourList->mImageRegion->mLeft;
|
|
|
|
|
|
|
|
if (aList.mImageRegion->mRight.GetUnit() == eCSSUnit_Null &&
|
|
|
|
ourList->mImageRegion->mRight.GetUnit() != eCSSUnit_Null)
|
|
|
|
aList.mImageRegion->mRight = ourList->mImageRegion->mRight;
|
|
|
|
|
|
|
|
if (aList.mImageRegion->mTop.GetUnit() == eCSSUnit_Null &&
|
|
|
|
ourList->mImageRegion->mTop.GetUnit() != eCSSUnit_Null)
|
|
|
|
aList.mImageRegion->mTop = ourList->mImageRegion->mTop;
|
|
|
|
|
|
|
|
if (aList.mImageRegion->mBottom.GetUnit() == eCSSUnit_Null &&
|
|
|
|
ourList->mImageRegion->mBottom.GetUnit() != eCSSUnit_Null)
|
|
|
|
aList.mImageRegion->mBottom = ourList->mImageRegion->mBottom;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapMarginForDeclaration(nsCSSDeclaration* aDeclaration, const nsStyleStructID& aSID, nsCSSMargin& aMargin)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSMargin* ourMargin = (nsCSSMargin*)aDeclaration->GetData(kCSSMarginSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourMargin)
|
|
|
|
return NS_OK;
|
2001-03-09 06:13:03 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// Margins
|
|
|
|
if (aSID == eStyleStruct_Margin && ourMargin->mMargin) {
|
|
|
|
if (eCSSUnit_Null == aMargin.mMargin->mLeft.GetUnit() && eCSSUnit_Null != ourMargin->mMargin->mLeft.GetUnit())
|
|
|
|
aMargin.mMargin->mLeft = ourMargin->mMargin->mLeft;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mMargin->mTop.GetUnit() && eCSSUnit_Null != ourMargin->mMargin->mTop.GetUnit())
|
|
|
|
aMargin.mMargin->mTop = ourMargin->mMargin->mTop;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mMargin->mRight.GetUnit() && eCSSUnit_Null != ourMargin->mMargin->mRight.GetUnit())
|
|
|
|
aMargin.mMargin->mRight = ourMargin->mMargin->mRight;
|
1998-05-27 03:16:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mMargin->mBottom.GetUnit() && eCSSUnit_Null != ourMargin->mMargin->mBottom.GetUnit())
|
|
|
|
aMargin.mMargin->mBottom = ourMargin->mMargin->mBottom;
|
|
|
|
}
|
1998-05-27 03:16:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// Padding
|
|
|
|
if (aSID == eStyleStruct_Padding && ourMargin->mPadding) {
|
|
|
|
if (eCSSUnit_Null == aMargin.mPadding->mLeft.GetUnit() && eCSSUnit_Null != ourMargin->mPadding->mLeft.GetUnit())
|
|
|
|
aMargin.mPadding->mLeft = ourMargin->mPadding->mLeft;
|
1998-05-27 03:16:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mPadding->mTop.GetUnit() && eCSSUnit_Null != ourMargin->mPadding->mTop.GetUnit())
|
|
|
|
aMargin.mPadding->mTop = ourMargin->mPadding->mTop;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mPadding->mRight.GetUnit() && eCSSUnit_Null != ourMargin->mPadding->mRight.GetUnit())
|
|
|
|
aMargin.mPadding->mRight = ourMargin->mPadding->mRight;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mPadding->mBottom.GetUnit() && eCSSUnit_Null != ourMargin->mPadding->mBottom.GetUnit())
|
|
|
|
aMargin.mPadding->mBottom = ourMargin->mPadding->mBottom;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// Borders
|
|
|
|
if (aSID == eStyleStruct_Border) {
|
|
|
|
// border-size
|
|
|
|
if (ourMargin->mBorderWidth) {
|
|
|
|
if (eCSSUnit_Null == aMargin.mBorderWidth->mLeft.GetUnit() && eCSSUnit_Null != ourMargin->mBorderWidth->mLeft.GetUnit())
|
|
|
|
aMargin.mBorderWidth->mLeft = ourMargin->mBorderWidth->mLeft;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderWidth->mTop.GetUnit() && eCSSUnit_Null != ourMargin->mBorderWidth->mTop.GetUnit())
|
|
|
|
aMargin.mBorderWidth->mTop = ourMargin->mBorderWidth->mTop;
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderWidth->mRight.GetUnit() && eCSSUnit_Null != ourMargin->mBorderWidth->mRight.GetUnit())
|
|
|
|
aMargin.mBorderWidth->mRight = ourMargin->mBorderWidth->mRight;
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderWidth->mBottom.GetUnit() && eCSSUnit_Null != ourMargin->mBorderWidth->mBottom.GetUnit())
|
|
|
|
aMargin.mBorderWidth->mBottom = ourMargin->mBorderWidth->mBottom;
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// border-style
|
|
|
|
if (ourMargin->mBorderStyle) {
|
|
|
|
if (eCSSUnit_Null == aMargin.mBorderStyle->mLeft.GetUnit() && eCSSUnit_Null != ourMargin->mBorderStyle->mLeft.GetUnit())
|
|
|
|
aMargin.mBorderStyle->mLeft = ourMargin->mBorderStyle->mLeft;
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderStyle->mTop.GetUnit() && eCSSUnit_Null != ourMargin->mBorderStyle->mTop.GetUnit())
|
|
|
|
aMargin.mBorderStyle->mTop = ourMargin->mBorderStyle->mTop;
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderStyle->mRight.GetUnit() && eCSSUnit_Null != ourMargin->mBorderStyle->mRight.GetUnit())
|
|
|
|
aMargin.mBorderStyle->mRight = ourMargin->mBorderStyle->mRight;
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderStyle->mBottom.GetUnit() && eCSSUnit_Null != ourMargin->mBorderStyle->mBottom.GetUnit())
|
|
|
|
aMargin.mBorderStyle->mBottom = ourMargin->mBorderStyle->mBottom;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// border-color
|
|
|
|
if (ourMargin->mBorderColor) {
|
|
|
|
if (eCSSUnit_Null == aMargin.mBorderColor->mLeft.GetUnit() && eCSSUnit_Null != ourMargin->mBorderColor->mLeft.GetUnit())
|
|
|
|
aMargin.mBorderColor->mLeft = ourMargin->mBorderColor->mLeft;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderColor->mTop.GetUnit() && eCSSUnit_Null != ourMargin->mBorderColor->mTop.GetUnit())
|
|
|
|
aMargin.mBorderColor->mTop = ourMargin->mBorderColor->mTop;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderColor->mRight.GetUnit() && eCSSUnit_Null != ourMargin->mBorderColor->mRight.GetUnit())
|
|
|
|
aMargin.mBorderColor->mRight = ourMargin->mBorderColor->mRight;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderColor->mBottom.GetUnit() && eCSSUnit_Null != ourMargin->mBorderColor->mBottom.GetUnit())
|
|
|
|
aMargin.mBorderColor->mBottom = ourMargin->mBorderColor->mBottom;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-12-05 11:35:05 +03:00
|
|
|
// border-colors
|
|
|
|
if (ourMargin->mBorderColors) {
|
|
|
|
for (PRInt32 i = 0; i < 4; i++)
|
|
|
|
if (!aMargin.mBorderColors[i] && ourMargin->mBorderColors[i])
|
|
|
|
aMargin.mBorderColors[i] = ourMargin->mBorderColors[i];
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// -moz-border-radius
|
|
|
|
if (ourMargin->mBorderRadius) {
|
|
|
|
if (eCSSUnit_Null == aMargin.mBorderRadius->mLeft.GetUnit() && eCSSUnit_Null != ourMargin->mBorderRadius->mLeft.GetUnit())
|
|
|
|
aMargin.mBorderRadius->mLeft = ourMargin->mBorderRadius->mLeft;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderRadius->mTop.GetUnit() && eCSSUnit_Null != ourMargin->mBorderRadius->mTop.GetUnit())
|
|
|
|
aMargin.mBorderRadius->mTop = ourMargin->mBorderRadius->mTop;
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderRadius->mRight.GetUnit() && eCSSUnit_Null != ourMargin->mBorderRadius->mRight.GetUnit())
|
|
|
|
aMargin.mBorderRadius->mRight = ourMargin->mBorderRadius->mRight;
|
1998-10-27 02:22:19 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mBorderRadius->mBottom.GetUnit() && eCSSUnit_Null != ourMargin->mBorderRadius->mBottom.GetUnit())
|
|
|
|
aMargin.mBorderRadius->mBottom = ourMargin->mBorderRadius->mBottom;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// float-edge
|
|
|
|
if (eCSSUnit_Null == aMargin.mFloatEdge.GetUnit() && eCSSUnit_Null != ourMargin->mFloatEdge.GetUnit())
|
|
|
|
aMargin.mFloatEdge = ourMargin->mFloatEdge;
|
|
|
|
}
|
1998-04-19 02:16:37 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// Outline
|
|
|
|
if (aSID == eStyleStruct_Outline) {
|
|
|
|
// -moz-outline-radius
|
|
|
|
if (ourMargin->mOutlineRadius) {
|
|
|
|
if (eCSSUnit_Null == aMargin.mOutlineRadius->mLeft.GetUnit() && eCSSUnit_Null != ourMargin->mOutlineRadius->mLeft.GetUnit())
|
|
|
|
aMargin.mOutlineRadius->mLeft = ourMargin->mOutlineRadius->mLeft;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mOutlineRadius->mTop.GetUnit() && eCSSUnit_Null != ourMargin->mOutlineRadius->mTop.GetUnit())
|
|
|
|
aMargin.mOutlineRadius->mTop = ourMargin->mOutlineRadius->mTop;
|
1998-04-25 22:44:55 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mOutlineRadius->mRight.GetUnit() && eCSSUnit_Null != ourMargin->mOutlineRadius->mRight.GetUnit())
|
|
|
|
aMargin.mOutlineRadius->mRight = ourMargin->mOutlineRadius->mRight;
|
1999-03-28 08:31:57 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (eCSSUnit_Null == aMargin.mOutlineRadius->mBottom.GetUnit() && eCSSUnit_Null != ourMargin->mOutlineRadius->mBottom.GetUnit())
|
|
|
|
aMargin.mOutlineRadius->mBottom = ourMargin->mOutlineRadius->mBottom;
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// outline-width
|
|
|
|
if (eCSSUnit_Null == aMargin.mOutlineWidth.GetUnit() && eCSSUnit_Null != ourMargin->mOutlineWidth.GetUnit())
|
|
|
|
aMargin.mOutlineWidth = ourMargin->mOutlineWidth;
|
1999-03-28 08:31:57 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// outline-color
|
|
|
|
if (eCSSUnit_Null == aMargin.mOutlineColor.GetUnit() && eCSSUnit_Null != ourMargin->mOutlineColor.GetUnit())
|
|
|
|
aMargin.mOutlineColor = ourMargin->mOutlineColor;
|
1999-07-24 23:04:42 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// outline-style
|
|
|
|
if (eCSSUnit_Null == aMargin.mOutlineStyle.GetUnit() && eCSSUnit_Null != ourMargin->mOutlineStyle.GetUnit())
|
|
|
|
aMargin.mOutlineStyle = ourMargin->mOutlineStyle;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapColorForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSColor& aColor)
|
1999-09-10 09:56:19 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK;
|
1998-10-27 02:22:19 +03:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSColor* ourColor = (nsCSSColor*)aDecl->GetData(kCSSColorSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourColor)
|
|
|
|
return NS_OK; // No rules for color or background.
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aID == eStyleStruct_Color) {
|
|
|
|
// color: color, string, inherit
|
|
|
|
if (aColor.mColor.GetUnit() == eCSSUnit_Null && ourColor->mColor.GetUnit() != eCSSUnit_Null)
|
|
|
|
aColor.mColor = ourColor->mColor;
|
|
|
|
}
|
|
|
|
else if (aID == eStyleStruct_Background) {
|
|
|
|
// background-color: color, string, enum (flags), inherit
|
|
|
|
if (aColor.mBackColor.GetUnit() == eCSSUnit_Null && ourColor->mBackColor.GetUnit() != eCSSUnit_Null)
|
|
|
|
aColor.mBackColor = ourColor->mBackColor;
|
1998-11-06 03:58:23 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// background-image: url, none, inherit
|
|
|
|
if (aColor.mBackImage.GetUnit() == eCSSUnit_Null && ourColor->mBackImage.GetUnit() != eCSSUnit_Null)
|
|
|
|
aColor.mBackImage = ourColor->mBackImage;
|
1998-04-24 22:34:31 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// background-repeat: enum, inherit
|
|
|
|
if (aColor.mBackRepeat.GetUnit() == eCSSUnit_Null && ourColor->mBackRepeat.GetUnit() != eCSSUnit_Null)
|
|
|
|
aColor.mBackRepeat = ourColor->mBackRepeat;
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// background-attachment: enum, inherit
|
|
|
|
if (aColor.mBackAttachment.GetUnit() == eCSSUnit_Null && ourColor->mBackAttachment.GetUnit() != eCSSUnit_Null)
|
|
|
|
aColor.mBackAttachment = ourColor->mBackAttachment;
|
|
|
|
|
|
|
|
// background-position: enum, length, percent (flags), inherit
|
|
|
|
if (aColor.mBackPositionX.GetUnit() == eCSSUnit_Null && ourColor->mBackPositionX.GetUnit() != eCSSUnit_Null)
|
|
|
|
aColor.mBackPositionX = ourColor->mBackPositionX;
|
|
|
|
if (aColor.mBackPositionY.GetUnit() == eCSSUnit_Null && ourColor->mBackPositionY.GetUnit() != eCSSUnit_Null)
|
|
|
|
aColor.mBackPositionY = ourColor->mBackPositionY;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-04-22 19:46:53 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapTableForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSTable& aTable)
|
1999-09-10 09:56:19 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
1998-10-27 02:22:19 +03:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSTable* ourTable = (nsCSSTable*)aDecl->GetData(kCSSTableSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourTable)
|
|
|
|
return NS_OK; // We don't have any rules for tables.
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aID == eStyleStruct_TableBorder) {
|
|
|
|
// border-collapse: enum, inherit
|
|
|
|
if (aTable.mBorderCollapse.GetUnit() == eCSSUnit_Null && ourTable->mBorderCollapse.GetUnit() != eCSSUnit_Null)
|
|
|
|
aTable.mBorderCollapse = ourTable->mBorderCollapse;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// border-spacing-x: length, inherit
|
|
|
|
if (aTable.mBorderSpacingX.GetUnit() == eCSSUnit_Null && ourTable->mBorderSpacingX.GetUnit() != eCSSUnit_Null)
|
|
|
|
aTable.mBorderSpacingX = ourTable->mBorderSpacingX;
|
|
|
|
|
|
|
|
// border-spacing-y: length, inherit
|
|
|
|
if (aTable.mBorderSpacingY.GetUnit() == eCSSUnit_Null && ourTable->mBorderSpacingY.GetUnit() != eCSSUnit_Null)
|
|
|
|
aTable.mBorderSpacingY = ourTable->mBorderSpacingY;
|
|
|
|
|
|
|
|
// caption-side: enum, inherit
|
|
|
|
if (aTable.mCaptionSide.GetUnit() == eCSSUnit_Null && ourTable->mCaptionSide.GetUnit() != eCSSUnit_Null)
|
|
|
|
aTable.mCaptionSide = ourTable->mCaptionSide;
|
|
|
|
|
|
|
|
// empty-cells: enum, inherit
|
|
|
|
if (aTable.mEmptyCells.GetUnit() == eCSSUnit_Null && ourTable->mEmptyCells.GetUnit() != eCSSUnit_Null)
|
|
|
|
aTable.mEmptyCells = ourTable->mEmptyCells;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
else if (aID == eStyleStruct_Table) {
|
|
|
|
// table-layout: auto, enum, inherit
|
|
|
|
if (aTable.mLayout.GetUnit() == eCSSUnit_Null && ourTable->mLayout.GetUnit() != eCSSUnit_Null)
|
|
|
|
aTable.mLayout = ourTable->mLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapContentForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSContent& aContent)
|
1999-09-10 09:56:19 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
1998-11-06 03:58:23 +03:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSContent* ourContent = (nsCSSContent*)aDecl->GetData(kCSSContentSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourContent)
|
|
|
|
return NS_OK; // We don't have any rules for content.
|
1998-11-06 03:58:23 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aID == eStyleStruct_Content) {
|
|
|
|
if (!aContent.mContent && ourContent->mContent)
|
|
|
|
aContent.mContent = ourContent->mContent;
|
1998-11-06 03:58:23 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aContent.mCounterIncrement && ourContent->mCounterIncrement)
|
|
|
|
aContent.mCounterIncrement = ourContent->mCounterIncrement;
|
1998-11-06 03:58:23 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aContent.mCounterReset && ourContent->mCounterReset)
|
|
|
|
aContent.mCounterReset = ourContent->mCounterReset;
|
|
|
|
|
|
|
|
if (aContent.mMarkerOffset.GetUnit() == eCSSUnit_Null && ourContent->mMarkerOffset.GetUnit() != eCSSUnit_Null)
|
|
|
|
aContent.mMarkerOffset = ourContent->mMarkerOffset;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
else if (aID == eStyleStruct_Quotes) {
|
|
|
|
if (!aContent.mQuotes && ourContent->mQuotes)
|
|
|
|
aContent.mQuotes = ourContent->mQuotes;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapTextForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSText& aText)
|
1999-09-10 09:56:19 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
1999-04-02 22:49:40 +04:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSText* ourText = (nsCSSText*)aDecl->GetData(kCSSTextSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourText)
|
|
|
|
return NS_OK; // We don't have any rules for text.
|
1999-04-02 22:49:40 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aID == eStyleStruct_Text) {
|
|
|
|
if (aText.mLetterSpacing.GetUnit() == eCSSUnit_Null && ourText->mLetterSpacing.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mLetterSpacing = ourText->mLetterSpacing;
|
1999-04-02 22:49:40 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aText.mLineHeight.GetUnit() == eCSSUnit_Null && ourText->mLineHeight.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mLineHeight = ourText->mLineHeight;
|
1999-04-02 22:49:40 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aText.mTextIndent.GetUnit() == eCSSUnit_Null && ourText->mTextIndent.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mTextIndent = ourText->mTextIndent;
|
1999-04-02 22:49:40 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aText.mTextTransform.GetUnit() == eCSSUnit_Null && ourText->mTextTransform.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mTextTransform = ourText->mTextTransform;
|
1999-07-24 23:04:42 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aText.mTextAlign.GetUnit() == eCSSUnit_Null && ourText->mTextAlign.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mTextAlign = ourText->mTextAlign;
|
1999-07-24 23:04:42 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aText.mWhiteSpace.GetUnit() == eCSSUnit_Null && ourText->mWhiteSpace.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mWhiteSpace = ourText->mWhiteSpace;
|
1999-07-24 23:04:42 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aText.mWordSpacing.GetUnit() == eCSSUnit_Null && ourText->mWordSpacing.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mWordSpacing = ourText->mWordSpacing;
|
|
|
|
}
|
|
|
|
else if (aID == eStyleStruct_TextReset) {
|
|
|
|
if (aText.mVerticalAlign.GetUnit() == eCSSUnit_Null && ourText->mVerticalAlign.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mVerticalAlign = ourText->mVerticalAlign;
|
2000-01-11 06:40:41 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aText.mDecoration.GetUnit() == eCSSUnit_Null && ourText->mDecoration.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mDecoration = ourText->mDecoration;
|
2001-06-29 07:15:58 +04:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (aText.mUnicodeBidi.GetUnit() == eCSSUnit_Null && ourText->mUnicodeBidi.GetUnit() != eCSSUnit_Null)
|
|
|
|
aText.mUnicodeBidi = ourText->mUnicodeBidi;
|
|
|
|
#endif
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_OK;
|
1999-07-24 23:04:42 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapDisplayForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSDisplay& aDisplay)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDisplay* ourDisplay = (nsCSSDisplay*)aDecl->GetData(kCSSDisplaySID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourDisplay)
|
|
|
|
return NS_OK; // We don't have any rules for display.
|
|
|
|
|
|
|
|
if (aID == eStyleStruct_Display) {
|
2001-12-18 01:51:39 +03:00
|
|
|
// appearance: enum, none, inherit
|
|
|
|
if (aDisplay.mAppearance.GetUnit() == eCSSUnit_Null &&
|
|
|
|
ourDisplay->mAppearance.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mAppearance = ourDisplay->mAppearance;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// display: enum, none, inherit
|
|
|
|
if (aDisplay.mDisplay.GetUnit() == eCSSUnit_Null && ourDisplay->mDisplay.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mDisplay = ourDisplay->mDisplay;
|
|
|
|
|
|
|
|
// binding: url, none, inherit
|
|
|
|
if (aDisplay.mBinding.GetUnit() == eCSSUnit_Null && ourDisplay->mBinding.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mBinding = ourDisplay->mBinding;
|
|
|
|
|
|
|
|
// position: enum, inherit
|
|
|
|
if (aDisplay.mPosition.GetUnit() == eCSSUnit_Null && ourDisplay->mPosition.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mPosition = ourDisplay->mPosition;
|
|
|
|
|
|
|
|
// clear: enum, none, inherit
|
|
|
|
if (aDisplay.mClear.GetUnit() == eCSSUnit_Null && ourDisplay->mClear.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mClear = ourDisplay->mClear;
|
|
|
|
|
|
|
|
// float: enum, none, inherit
|
|
|
|
if (aDisplay.mFloat.GetUnit() == eCSSUnit_Null && ourDisplay->mFloat.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mFloat = ourDisplay->mFloat;
|
|
|
|
|
|
|
|
// overflow: enum, auto, inherit
|
|
|
|
if (aDisplay.mOverflow.GetUnit() == eCSSUnit_Null && ourDisplay->mOverflow.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mOverflow = ourDisplay->mOverflow;
|
|
|
|
|
|
|
|
// clip property: length, auto, inherit
|
|
|
|
if (ourDisplay->mClip) {
|
|
|
|
if (aDisplay.mClip->mLeft.GetUnit() == eCSSUnit_Null && ourDisplay->mClip->mLeft.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mClip->mLeft = ourDisplay->mClip->mLeft;
|
|
|
|
if (aDisplay.mClip->mRight.GetUnit() == eCSSUnit_Null && ourDisplay->mClip->mRight.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mClip->mRight = ourDisplay->mClip->mRight;
|
|
|
|
if (aDisplay.mClip->mTop.GetUnit() == eCSSUnit_Null && ourDisplay->mClip->mTop.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mClip->mTop = ourDisplay->mClip->mTop;
|
|
|
|
if (aDisplay.mClip->mBottom.GetUnit() == eCSSUnit_Null && ourDisplay->mClip->mBottom.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mClip->mBottom = ourDisplay->mClip->mBottom;
|
1999-07-24 23:04:42 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
else if (aID == eStyleStruct_Visibility) {
|
|
|
|
// opacity: factor, percent, inherit
|
|
|
|
if (aDisplay.mOpacity.GetUnit() == eCSSUnit_Null && ourDisplay->mOpacity.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mOpacity = ourDisplay->mOpacity;
|
1999-07-24 23:04:42 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// direction: enum, inherit
|
|
|
|
if (aDisplay.mDirection.GetUnit() == eCSSUnit_Null && ourDisplay->mDirection.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mDirection = ourDisplay->mDirection;
|
1999-12-22 08:00:47 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// visibility: enum, inherit
|
|
|
|
if (aDisplay.mVisibility.GetUnit() == eCSSUnit_Null && ourDisplay->mVisibility.GetUnit() != eCSSUnit_Null)
|
|
|
|
aDisplay.mVisibility = ourDisplay->mVisibility;
|
1999-12-22 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-22 08:00:47 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
static nsresult
|
2002-01-16 01:43:37 +03:00
|
|
|
MapUIForDeclaration(nsCSSDeclaration* aDecl, const nsStyleStructID& aID, nsCSSUserInterface& aUI)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (!aDecl)
|
|
|
|
return NS_OK; // The rule must have a declaration.
|
1999-12-22 08:00:47 +03:00
|
|
|
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSUserInterface* ourUI = (nsCSSUserInterface*)aDecl->GetData(kCSSUserInterfaceSID);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!ourUI)
|
|
|
|
return NS_OK; // We don't have any rules for UI.
|
1999-12-22 08:00:47 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aID == eStyleStruct_UserInterface) {
|
|
|
|
if (aUI.mUserFocus.GetUnit() == eCSSUnit_Null && ourUI->mUserFocus.GetUnit() != eCSSUnit_Null)
|
|
|
|
aUI.mUserFocus = ourUI->mUserFocus;
|
|
|
|
|
|
|
|
if (aUI.mUserInput.GetUnit() == eCSSUnit_Null && ourUI->mUserInput.GetUnit() != eCSSUnit_Null)
|
|
|
|
aUI.mUserInput = ourUI->mUserInput;
|
1999-12-22 08:00:47 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aUI.mUserModify.GetUnit() == eCSSUnit_Null && ourUI->mUserModify.GetUnit() != eCSSUnit_Null)
|
|
|
|
aUI.mUserModify = ourUI->mUserModify;
|
2001-03-06 05:30:30 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (!aUI.mCursor && ourUI->mCursor)
|
|
|
|
aUI.mCursor = ourUI->mCursor;
|
2001-03-06 05:30:30 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
else if (aID == eStyleStruct_UIReset) {
|
|
|
|
if (aUI.mUserSelect.GetUnit() == eCSSUnit_Null && ourUI->mUserSelect.GetUnit() != eCSSUnit_Null)
|
|
|
|
aUI.mUserSelect = ourUI->mUserSelect;
|
|
|
|
|
|
|
|
if (!aUI.mKeyEquivalent && ourUI->mKeyEquivalent)
|
|
|
|
aUI.mKeyEquivalent = ourUI->mKeyEquivalent;
|
2000-06-02 03:31:00 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aUI.mResizer.GetUnit() == eCSSUnit_Null && ourUI->mResizer.GetUnit() != eCSSUnit_Null)
|
|
|
|
aUI.mResizer = ourUI->mResizer;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
1998-08-30 00:20:38 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
// Indent
|
|
|
|
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
nsAutoString buffer;
|
2001-03-28 12:02:20 +04:00
|
|
|
mSelector.ToString(buffer, mSheet, PR_FALSE, 0);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-12-16 14:58:03 +03:00
|
|
|
buffer.Append(NS_LITERAL_STRING(" weight: "));
|
2000-04-16 00:15:37 +04:00
|
|
|
buffer.AppendInt(mWeight, 10);
|
2001-12-16 14:58:03 +03:00
|
|
|
buffer.Append(NS_LITERAL_STRING(" "));
|
2001-10-16 07:53:44 +04:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(buffer).get(), out);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != mDeclaration) {
|
|
|
|
mDeclaration->List(out);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("{ null declaration }", out);
|
|
|
|
}
|
|
|
|
fputs("\n", out);
|
1998-08-30 00:20:38 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* SizeOf method:
|
|
|
|
*
|
|
|
|
* Self (reported as CSSStyleRuleImpl's size):
|
2000-09-13 04:05:04 +04:00
|
|
|
* 1) sizeof(*this)
|
2000-03-31 11:08:36 +04:00
|
|
|
* + sizeof the DOMDeclaration if it exists and is unique
|
|
|
|
*
|
|
|
|
* Contained / Aggregated data (not reported as CSSStyleRuleImpl's size):
|
|
|
|
* 1) mDeclaration if it exists
|
|
|
|
* 2) mImportantRule if it exists
|
|
|
|
*
|
|
|
|
* Children / siblings / parents:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
void CSSStyleRuleImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null");
|
|
|
|
|
|
|
|
// first get the unique items collection
|
|
|
|
UNIQUE_STYLE_ITEMS(uniqueItems);
|
|
|
|
if(! uniqueItems->AddItem((void*)this)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 localSize=0;
|
|
|
|
|
|
|
|
// create a tag for this instance
|
|
|
|
nsCOMPtr<nsIAtom> tag;
|
|
|
|
tag = getter_AddRefs(NS_NewAtom("CSSStyleRuleImpl"));
|
|
|
|
// get the size of an empty instance and add to the sizeof handler
|
|
|
|
aSize = sizeof(*this);
|
|
|
|
// remove the sizeof the mSelector's class since we count it seperately below
|
|
|
|
aSize -= sizeof(mSelector);
|
|
|
|
|
|
|
|
// and add the size of the DOMDeclaration
|
|
|
|
// XXX - investigate the size and quantity of these
|
|
|
|
if(mDOMDeclaration && uniqueItems->AddItem(mDOMDeclaration)){
|
|
|
|
aSize += sizeof(DOMCSSDeclarationImpl);
|
|
|
|
}
|
|
|
|
aSizeOfHandler->AddSize(tag,aSize);
|
|
|
|
|
|
|
|
// now delegate to the Selector, Declaration, and ImportantRule
|
|
|
|
mSelector.SizeOf(aSizeOfHandler, localSize);
|
|
|
|
|
|
|
|
if(mDeclaration){
|
|
|
|
mDeclaration->SizeOf(aSizeOfHandler, localSize);
|
|
|
|
}
|
|
|
|
if(mImportantRule){
|
|
|
|
mImportantRule->SizeOf(aSizeOfHandler, localSize);
|
|
|
|
}
|
|
|
|
}
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2000-03-31 11:08:36 +04:00
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
NS_IMETHODIMP
|
1998-11-26 04:34:53 +03:00
|
|
|
CSSStyleRuleImpl::GetType(PRUint16* aType)
|
1998-10-06 05:39:33 +04:00
|
|
|
{
|
1998-11-26 04:34:53 +03:00
|
|
|
*aType = nsIDOMCSSRule::STYLE_RULE;
|
1998-10-06 05:39:33 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHODIMP
|
2000-08-23 21:27:06 +04:00
|
|
|
CSSStyleRuleImpl::GetCssText(nsAWritableString& aCssText)
|
1998-11-26 04:34:53 +03:00
|
|
|
{
|
2001-03-20 14:49:20 +03:00
|
|
|
mSelector.ToString( aCssText, mSheet, IsPseudoElement(mSelector.mTag),
|
|
|
|
0 );
|
2001-02-13 17:10:38 +03:00
|
|
|
aCssText.Append(PRUnichar(' '));
|
|
|
|
aCssText.Append(PRUnichar('{'));
|
|
|
|
aCssText.Append(PRUnichar(' '));
|
2000-09-13 04:05:04 +04:00
|
|
|
if (mDeclaration)
|
|
|
|
{
|
|
|
|
nsAutoString tempString;
|
|
|
|
mDeclaration->ToString( tempString );
|
|
|
|
aCssText.Append( tempString );
|
|
|
|
}
|
2001-02-13 17:10:38 +03:00
|
|
|
aCssText.Append(PRUnichar(' '));
|
|
|
|
aCssText.Append(PRUnichar('}'));
|
1998-11-26 04:34:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-08-23 21:27:06 +04:00
|
|
|
CSSStyleRuleImpl::SetCssText(const nsAReadableString& aCssText)
|
1998-11-26 04:34:53 +03:00
|
|
|
{
|
1999-02-08 00:48:45 +03:00
|
|
|
// XXX TBI - need to re-parse rule & declaration
|
1998-11-26 04:34:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-04-26 17:58:56 +04:00
|
|
|
CSSStyleRuleImpl::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet)
|
1998-11-26 04:34:53 +03:00
|
|
|
{
|
|
|
|
if (nsnull != mSheet) {
|
2001-01-04 23:44:42 +03:00
|
|
|
return mSheet->QueryInterface(NS_GET_IID(nsIDOMCSSStyleSheet), (void**)aSheet);
|
1998-11-26 04:34:53 +03:00
|
|
|
}
|
|
|
|
*aSheet = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-26 17:58:56 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSStyleRuleImpl::GetParentRule(nsIDOMCSSRule** aParentRule)
|
|
|
|
{
|
2001-09-19 18:16:34 +04:00
|
|
|
if (mParentRule) {
|
|
|
|
return CallQueryInterface(mParentRule, aParentRule);
|
|
|
|
}
|
|
|
|
*aParentRule = nsnull;
|
|
|
|
return NS_OK;
|
2000-04-26 17:58:56 +04:00
|
|
|
}
|
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
NS_IMETHODIMP
|
2000-08-23 21:27:06 +04:00
|
|
|
CSSStyleRuleImpl::GetSelectorText(nsAWritableString& aSelectorText)
|
1998-10-06 05:39:33 +04:00
|
|
|
{
|
2001-03-20 14:49:20 +03:00
|
|
|
mSelector.ToString( aSelectorText, mSheet, IsPseudoElement(mSelector.mTag), 0 );
|
1998-10-06 05:39:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-08-23 21:27:06 +04:00
|
|
|
CSSStyleRuleImpl::SetSelectorText(const nsAReadableString& aSelectorText)
|
1998-10-06 05:39:33 +04:00
|
|
|
{
|
1998-12-11 05:50:43 +03:00
|
|
|
// XXX TBI - get a parser and re-parse the selectors,
|
|
|
|
// XXX then need to re-compute the cascade
|
1999-06-03 05:57:13 +04:00
|
|
|
// XXX and dirty sheet
|
1998-10-06 05:39:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CSSStyleRuleImpl::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
|
|
|
{
|
|
|
|
if (nsnull == mDOMDeclaration) {
|
|
|
|
mDOMDeclaration = new DOMCSSDeclarationImpl(this);
|
|
|
|
if (nsnull == mDOMDeclaration) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
NS_ADDREF(mDOMDeclaration);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aStyle = mDOMDeclaration;
|
|
|
|
NS_ADDREF(mDOMDeclaration);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-10-20 01:02:39 +04:00
|
|
|
NS_EXPORT nsresult
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_NewCSSStyleRule(nsICSSStyleRule** aInstancePtrResult, const nsCSSSelector& aSelector)
|
|
|
|
{
|
|
|
|
if (aInstancePtrResult == nsnull) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSSStyleRuleImpl *it = new CSSStyleRuleImpl(aSelector);
|
|
|
|
|
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2001-01-04 23:44:42 +03:00
|
|
|
return it->QueryInterface(NS_GET_IID(nsICSSStyleRule), (void **) aInstancePtrResult);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|