1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03: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
|
|
|
*
|
1999-11-06 06:40:37 +03: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.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2001-02-13 17:06:29 +03:00
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
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"
|
|
|
|
#include "nsICSSDeclaration.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"
|
1999-10-16 08:05:59 +04:00
|
|
|
#include "nsIMutableStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#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"
|
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-10-11 12:33:01 +04:00
|
|
|
// MJA: bug 31816
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
// - END MJA
|
|
|
|
|
2000-03-31 11:08:36 +04:00
|
|
|
// #define DEBUG_REFS
|
|
|
|
|
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);
|
1999-12-22 08:00:47 +03:00
|
|
|
static NS_DEFINE_IID(kCSSBreaksSID, NS_CSS_BREAKS_SID);
|
|
|
|
static NS_DEFINE_IID(kCSSPageSID, NS_CSS_PAGE_SID);
|
2001-03-06 05:30:30 +03:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
static NS_DEFINE_IID(kCSSXULSID, NS_CSS_XUL_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;
|
|
|
|
}
|
|
|
|
|
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-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);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (0 < aTag.Length()) {
|
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
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
if (0 < aID.Length()) {
|
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)
|
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
if (0 < aClass.Length()) {
|
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)
|
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
if (0 < aPseudoClass.Length()) {
|
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
|
|
|
{
|
|
|
|
if (0 < aAttr.Length()) {
|
|
|
|
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
|
|
|
{
|
|
|
|
if (0 < aAttr.Length()) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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-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 -------------------------------
|
|
|
|
|
1999-06-22 23:23:56 +04:00
|
|
|
static nscoord CalcLength(const nsCSSValue& aValue, const nsFont& aFont,
|
1998-09-11 06:07:05 +04:00
|
|
|
nsIPresContext* aPresContext);
|
|
|
|
static PRBool SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord,
|
1999-09-10 09:56:19 +04:00
|
|
|
const nsStyleCoord& aParentCoord,
|
1999-06-22 23:23:56 +04:00
|
|
|
PRInt32 aMask, const nsFont& aFont,
|
1998-09-11 06:07:05 +04:00
|
|
|
nsIPresContext* aPresContext);
|
|
|
|
|
1999-04-16 01:23:05 +04:00
|
|
|
static void MapDeclarationFontInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext,
|
1999-04-16 01:23:05 +04:00
|
|
|
nsIPresContext* aPresContext);
|
1998-09-11 06:07:05 +04:00
|
|
|
static void MapDeclarationInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext,
|
|
|
|
nsIPresContext* aPresContext);
|
1998-09-11 06:07:05 +04:00
|
|
|
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
class CSSStyleRuleImpl;
|
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
class CSSImportantRule : public nsIStyleRule {
|
|
|
|
public:
|
1998-11-26 04:34:53 +03:00
|
|
|
CSSImportantRule(nsICSSStyleSheet* aSheet, nsICSSDeclaration* 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
|
|
|
|
1999-10-16 08:05:59 +04:00
|
|
|
NS_IMETHOD MapFontStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext);
|
|
|
|
NS_IMETHOD MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext);
|
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);
|
|
|
|
|
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
|
|
|
|
|
|
|
nsICSSDeclaration* 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
|
|
|
};
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
CSSImportantRule::CSSImportantRule(nsICSSStyleSheet* aSheet, nsICSSDeclaration* 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
|
|
|
NS_IF_ADDREF(mDeclaration);
|
|
|
|
}
|
|
|
|
|
|
|
|
CSSImportantRule::~CSSImportantRule(void)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mDeclaration);
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:42 +03:00
|
|
|
NS_IMPL_ISUPPORTS(CSSImportantRule, NS_GET_IID(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
|
1999-10-16 08:05:59 +04:00
|
|
|
CSSImportantRule::MapFontStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
1999-04-16 01:23:05 +04:00
|
|
|
{
|
|
|
|
MapDeclarationFontInto(mDeclaration, aContext, aPresContext);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
NS_IMETHODIMP
|
1999-10-16 08:05:59 +04:00
|
|
|
CSSImportantRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
1998-09-11 06:07:05 +04:00
|
|
|
{
|
|
|
|
MapDeclarationInto(mDeclaration, aContext, aPresContext);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
1998-10-06 05:39:33 +04:00
|
|
|
virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl,
|
|
|
|
PRBool aAllocate);
|
2000-05-04 01:42:00 +04:00
|
|
|
virtual nsresult SetCSSDeclaration(nsICSSDeclaration *aDecl);
|
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();
|
|
|
|
|
|
|
|
nsCOMPtr<nsICSSDeclaration> decl;
|
|
|
|
nsresult rv = GetCSSDeclaration(getter_AddRefs(decl), PR_TRUE);
|
|
|
|
|
|
|
|
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
|
|
|
|
DOMCSSDeclarationImpl::GetCSSDeclaration(nsICSSDeclaration **aDecl,
|
|
|
|
PRBool aAllocate)
|
|
|
|
{
|
|
|
|
if (nsnull != mRule) {
|
|
|
|
*aDecl = mRule->GetDeclaration();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aDecl = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-04 01:42:00 +04:00
|
|
|
nsresult
|
|
|
|
DOMCSSDeclarationImpl::SetCSSDeclaration(nsICSSDeclaration *aDecl)
|
|
|
|
{
|
|
|
|
if (nsnull != mRule) {
|
|
|
|
mRule->SetDeclaration(aDecl);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
nsICSSDeclaration *decl;
|
|
|
|
nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && (decl)) {
|
|
|
|
nsICSSLoader* cssLoader = nsnull;
|
|
|
|
nsICSSParser* cssParser = nsnull;
|
|
|
|
nsIURI* baseURI = nsnull;
|
|
|
|
nsICSSStyleSheet* cssSheet = nsnull;
|
|
|
|
nsIDocument* owningDoc = nsnull;
|
|
|
|
|
|
|
|
nsIStyleSheet* sheet = nsnull;
|
|
|
|
if (mRule) {
|
|
|
|
mRule->GetStyleSheet(sheet);
|
|
|
|
if (sheet) {
|
|
|
|
sheet->GetURL(baseURI);
|
|
|
|
sheet->GetOwningDocument(owningDoc);
|
2001-01-04 23:44:42 +03:00
|
|
|
sheet->QueryInterface(NS_GET_IID(nsICSSStyleSheet), (void**)&cssSheet);
|
1999-08-04 09:07:10 +04:00
|
|
|
if (owningDoc) {
|
|
|
|
nsIHTMLContentContainer* htmlContainer;
|
2001-01-04 23:44:42 +03:00
|
|
|
result = owningDoc->QueryInterface(NS_GET_IID(nsIHTMLContentContainer), (void**)&htmlContainer);
|
1999-08-04 09:07:10 +04:00
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
result = htmlContainer->GetCSSLoader(cssLoader);
|
|
|
|
NS_RELEASE(htmlContainer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(sheet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cssLoader) {
|
|
|
|
result = cssLoader->GetParserFor(nsnull, &cssParser);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = NS_NewCSSParser(&cssParser);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
2000-05-04 01:42:00 +04:00
|
|
|
nsCOMPtr<nsICSSDeclaration> declClone;
|
|
|
|
decl->Clone(*getter_AddRefs(declClone));
|
|
|
|
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;
|
|
|
|
|
|
|
|
decl->Count(&count);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
1999-08-04 09:07:10 +04:00
|
|
|
else {
|
|
|
|
NS_RELEASE(cssParser);
|
1998-11-26 04:34:53 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-04 09:07:10 +04:00
|
|
|
NS_IF_RELEASE(cssLoader);
|
|
|
|
NS_IF_RELEASE(baseURI);
|
|
|
|
NS_IF_RELEASE(cssSheet);
|
|
|
|
NS_IF_RELEASE(owningDoc);
|
|
|
|
NS_RELEASE(decl);
|
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);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
virtual nsICSSDeclaration* GetDeclaration(void) const;
|
|
|
|
virtual void SetDeclaration(nsICSSDeclaration* aDeclaration);
|
|
|
|
|
|
|
|
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
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
|
|
|
|
NS_IMETHOD SetStyleSheet(nsICSSStyleSheet* aSheet);
|
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
|
|
|
|
1999-10-16 08:05:59 +04:00
|
|
|
NS_IMETHOD MapFontStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext);
|
|
|
|
NS_IMETHOD MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
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);
|
|
|
|
|
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;
|
|
|
|
nsICSSDeclaration* mDeclaration;
|
|
|
|
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) {
|
|
|
|
aCopy.mDeclaration->Clone(mDeclaration);
|
|
|
|
}
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(mDeclaration);
|
1998-11-26 04:34:53 +03:00
|
|
|
if (nsnull != mImportantRule) {
|
|
|
|
mImportantRule->mSheet = nsnull;
|
|
|
|
NS_RELEASE(mImportantRule);
|
|
|
|
}
|
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
|
|
|
// XPConnect interface list for CSSStyleRuleImpl
|
|
|
|
NS_CLASSINFO_MAP_BEGIN(CSSStyleRule)
|
|
|
|
NS_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
|
|
|
|
NS_CLASSINFO_MAP_END
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
nsICSSDeclaration* CSSStyleRuleImpl::GetDeclaration(void) const
|
|
|
|
{
|
2000-02-18 02:19:18 +03:00
|
|
|
nsICSSDeclaration* result = mDeclaration;
|
|
|
|
NS_IF_ADDREF(result);
|
|
|
|
return result;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSSStyleRuleImpl::SetDeclaration(nsICSSDeclaration* aDeclaration)
|
|
|
|
{
|
1998-11-26 04:34:53 +03:00
|
|
|
if (mDeclaration != aDeclaration) {
|
|
|
|
NS_IF_RELEASE(mImportantRule);
|
|
|
|
NS_IF_RELEASE(mDeclaration);
|
|
|
|
mDeclaration = aDeclaration;
|
|
|
|
NS_IF_ADDREF(mDeclaration);
|
|
|
|
}
|
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)) {
|
|
|
|
nsICSSDeclaration* important;
|
|
|
|
mDeclaration->GetImportantValues(important);
|
|
|
|
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_RELEASE(important);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_ADDREF(mImportantRule);
|
|
|
|
return mImportantRule;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1998-09-11 06:07:05 +04:00
|
|
|
nscoord CalcLength(const nsCSSValue& aValue,
|
1999-06-22 23:23:56 +04:00
|
|
|
const nsFont& aFont,
|
1998-09-11 06:07:05 +04:00
|
|
|
nsIPresContext* aPresContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aValue.IsLengthUnit(), "not a length unit");
|
|
|
|
if (aValue.IsFixedLengthUnit()) {
|
|
|
|
return aValue.GetLengthTwips();
|
|
|
|
}
|
|
|
|
nsCSSUnit unit = aValue.GetUnit();
|
|
|
|
switch (unit) {
|
|
|
|
case eCSSUnit_EM:
|
1999-07-18 04:27:02 +04:00
|
|
|
case eCSSUnit_Char:
|
1999-06-22 23:23:56 +04:00
|
|
|
return NSToCoordRound(aValue.GetFloatValue() * (float)aFont.size);
|
|
|
|
// XXX scale against font metrics height instead?
|
1998-04-14 00:24:54 +04:00
|
|
|
case eCSSUnit_EN:
|
1999-06-22 23:23:56 +04:00
|
|
|
return NSToCoordRound((aValue.GetFloatValue() * (float)aFont.size) / 2.0f);
|
1998-09-17 04:19:47 +04:00
|
|
|
case eCSSUnit_XHeight: {
|
1999-02-12 20:45:58 +03:00
|
|
|
nsIFontMetrics* fm;
|
1999-06-22 23:23:56 +04:00
|
|
|
aPresContext->GetMetricsFor(aFont, &fm);
|
1998-09-17 04:19:47 +04:00
|
|
|
NS_ASSERTION(nsnull != fm, "can't get font metrics");
|
|
|
|
nscoord xHeight;
|
|
|
|
if (nsnull != fm) {
|
|
|
|
fm->GetXHeight(xHeight);
|
|
|
|
NS_RELEASE(fm);
|
|
|
|
}
|
|
|
|
else {
|
1999-06-22 23:23:56 +04:00
|
|
|
xHeight = ((aFont.size * 2) / 3);
|
1998-09-17 04:19:47 +04:00
|
|
|
}
|
|
|
|
return NSToCoordRound(aValue.GetFloatValue() * (float)xHeight);
|
|
|
|
}
|
|
|
|
case eCSSUnit_CapHeight: {
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("cap height unit");
|
1999-06-22 23:23:56 +04:00
|
|
|
nscoord capHeight = ((aFont.size / 3) * 2); // XXX HACK!
|
1998-09-17 04:19:47 +04:00
|
|
|
return NSToCoordRound(aValue.GetFloatValue() * (float)capHeight);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
case eCSSUnit_Pixel:
|
1998-11-14 04:52:27 +03:00
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
1998-11-14 04:52:27 +03:00
|
|
|
return NSFloatPixelsToTwips(aValue.GetFloatValue(), p2t);
|
1999-02-12 20:45:58 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-05-13 02:57:52 +04:00
|
|
|
|
|
|
|
#define SETCOORD_NORMAL 0x01
|
|
|
|
#define SETCOORD_AUTO 0x02
|
|
|
|
#define SETCOORD_INHERIT 0x04
|
|
|
|
#define SETCOORD_PERCENT 0x08
|
|
|
|
#define SETCOORD_FACTOR 0x10
|
|
|
|
#define SETCOORD_LENGTH 0x20
|
|
|
|
#define SETCOORD_INTEGER 0x40
|
|
|
|
#define SETCOORD_ENUMERATED 0x80
|
|
|
|
|
|
|
|
#define SETCOORD_LP (SETCOORD_LENGTH | SETCOORD_PERCENT)
|
|
|
|
#define SETCOORD_LH (SETCOORD_LENGTH | SETCOORD_INHERIT)
|
|
|
|
#define SETCOORD_AH (SETCOORD_AUTO | SETCOORD_INHERIT)
|
|
|
|
#define SETCOORD_LPH (SETCOORD_LP | SETCOORD_INHERIT)
|
|
|
|
#define SETCOORD_LPFHN (SETCOORD_LPH | SETCOORD_FACTOR | SETCOORD_NORMAL)
|
|
|
|
#define SETCOORD_LPAH (SETCOORD_LP | SETCOORD_AH)
|
|
|
|
#define SETCOORD_LPEH (SETCOORD_LP | SETCOORD_ENUMERATED | SETCOORD_INHERIT)
|
1999-03-28 08:31:57 +04:00
|
|
|
#define SETCOORD_LE (SETCOORD_LENGTH | SETCOORD_ENUMERATED)
|
|
|
|
#define SETCOORD_LEH (SETCOORD_LE | SETCOORD_INHERIT)
|
1999-09-10 09:56:19 +04:00
|
|
|
#define SETCOORD_IA (SETCOORD_INTEGER | SETCOORD_AUTO)
|
1999-12-22 08:00:47 +03:00
|
|
|
#define SETCOORD_LAE (SETCOORD_LENGTH | SETCOORD_AUTO | SETCOORD_ENUMERATED)
|
1998-05-13 02:57:52 +04:00
|
|
|
|
1998-10-27 02:22:19 +03:00
|
|
|
static PRBool SetCoord(const nsCSSValue& aValue, nsStyleCoord& aCoord,
|
1999-09-10 09:56:19 +04:00
|
|
|
const nsStyleCoord& aParentCoord,
|
1999-06-22 23:23:56 +04:00
|
|
|
PRInt32 aMask, const nsFont& aFont,
|
1998-10-27 02:22:19 +03:00
|
|
|
nsIPresContext* aPresContext)
|
1998-04-30 23:57:36 +04:00
|
|
|
{
|
1998-05-13 02:57:52 +04:00
|
|
|
PRBool result = PR_TRUE;
|
|
|
|
if (aValue.GetUnit() == eCSSUnit_Null) {
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
1999-07-18 04:27:02 +04:00
|
|
|
else if (((aMask & SETCOORD_LENGTH) != 0) &&
|
|
|
|
(aValue.GetUnit() == eCSSUnit_Char)) {
|
|
|
|
aCoord.SetIntValue(NSToIntFloor(aValue.GetFloatValue()), eStyleUnit_Chars);
|
|
|
|
}
|
1998-05-13 02:57:52 +04:00
|
|
|
else if (((aMask & SETCOORD_LENGTH) != 0) &&
|
|
|
|
aValue.IsLengthUnit()) {
|
1998-04-30 23:57:36 +04:00
|
|
|
aCoord.SetCoordValue(CalcLength(aValue, aFont, aPresContext));
|
|
|
|
}
|
|
|
|
else if (((aMask & SETCOORD_PERCENT) != 0) &&
|
|
|
|
(aValue.GetUnit() == eCSSUnit_Percent)) {
|
|
|
|
aCoord.SetPercentValue(aValue.GetPercentValue());
|
|
|
|
}
|
|
|
|
else if (((aMask & SETCOORD_INTEGER) != 0) &&
|
|
|
|
(aValue.GetUnit() == eCSSUnit_Integer)) {
|
|
|
|
aCoord.SetIntValue(aValue.GetIntValue(), eStyleUnit_Integer);
|
|
|
|
}
|
|
|
|
else if (((aMask & SETCOORD_ENUMERATED) != 0) &&
|
|
|
|
(aValue.GetUnit() == eCSSUnit_Enumerated)) {
|
|
|
|
aCoord.SetIntValue(aValue.GetIntValue(), eStyleUnit_Enumerated);
|
|
|
|
}
|
|
|
|
else if (((aMask & SETCOORD_AUTO) != 0) &&
|
|
|
|
(aValue.GetUnit() == eCSSUnit_Auto)) {
|
|
|
|
aCoord.SetAutoValue();
|
|
|
|
}
|
|
|
|
else if (((aMask & SETCOORD_INHERIT) != 0) &&
|
|
|
|
(aValue.GetUnit() == eCSSUnit_Inherit)) {
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleUnit unit = aParentCoord.GetUnit();
|
|
|
|
if ((eStyleUnit_Null == unit) || // parent has explicit computed value
|
|
|
|
(eStyleUnit_Factor == unit) ||
|
|
|
|
(eStyleUnit_Coord == unit) ||
|
|
|
|
(eStyleUnit_Integer == unit) ||
|
|
|
|
(eStyleUnit_Enumerated == unit) ||
|
|
|
|
(eStyleUnit_Normal == unit) ||
|
|
|
|
(eStyleUnit_Chars == unit)) {
|
|
|
|
aCoord = aParentCoord; // just inherit value from parent
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aCoord.SetInheritValue(); // needs to be computed by client
|
|
|
|
}
|
1998-04-30 23:57:36 +04:00
|
|
|
}
|
|
|
|
else if (((aMask & SETCOORD_NORMAL) != 0) &&
|
|
|
|
(aValue.GetUnit() == eCSSUnit_Normal)) {
|
|
|
|
aCoord.SetNormalValue();
|
|
|
|
}
|
1998-05-13 02:57:52 +04:00
|
|
|
else if (((aMask & SETCOORD_FACTOR) != 0) &&
|
|
|
|
(aValue.GetUnit() == eCSSUnit_Number)) {
|
|
|
|
aCoord.SetFactorValue(aValue.GetFloatValue());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = PR_FALSE; // didn't set anything
|
|
|
|
}
|
|
|
|
return result;
|
1998-04-30 23:57:36 +04:00
|
|
|
}
|
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static PRBool SetColor(const nsCSSValue& aValue, const nscolor aParentColor,
|
|
|
|
nsIPresContext* aPresContext, nscolor& aResult)
|
1998-10-27 02:22:19 +03:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsCSSUnit unit = aValue.GetUnit();
|
|
|
|
|
|
|
|
if (eCSSUnit_Color == unit) {
|
|
|
|
aResult = aValue.GetColorValue();
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_String == unit) {
|
|
|
|
nsAutoString value;
|
|
|
|
aValue.GetStringValue(value);
|
|
|
|
nscolor rgba;
|
1999-07-18 04:27:02 +04:00
|
|
|
if (NS_ColorNameToRGB(value, &rgba)) {
|
1998-10-27 02:22:19 +03:00
|
|
|
aResult = rgba;
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
1999-10-12 05:31:33 +04:00
|
|
|
else if (eCSSUnit_Integer == unit) {
|
1999-09-10 09:56:19 +04:00
|
|
|
nsILookAndFeel* look = nsnull;
|
|
|
|
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {
|
|
|
|
nsILookAndFeel::nsColorID colorID = (nsILookAndFeel::nsColorID)aValue.GetIntValue();
|
1999-10-12 05:31:33 +04:00
|
|
|
if (NS_SUCCEEDED(look->GetColor(colorID, aResult))) {
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
NS_RELEASE(look);
|
|
|
|
}
|
|
|
|
}
|
1999-03-28 08:31:57 +04:00
|
|
|
else if (eCSSUnit_Inherit == unit) {
|
|
|
|
aResult = aParentColor;
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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
|
1999-10-16 08:05:59 +04:00
|
|
|
CSSStyleRuleImpl::MapFontStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
1999-04-16 01:23:05 +04:00
|
|
|
{
|
|
|
|
MapDeclarationFontInto(mDeclaration, aContext, aPresContext);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-02 06:09:43 +04:00
|
|
|
NS_IMETHODIMP
|
1999-10-16 08:05:59 +04:00
|
|
|
CSSStyleRuleImpl::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-11 06:07:05 +04:00
|
|
|
MapDeclarationInto(mDeclaration, aContext, aPresContext);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-05-03 17:20:48 +04:00
|
|
|
static nsString& Unquote(nsString& aString)
|
1999-04-02 22:49:40 +04:00
|
|
|
{
|
|
|
|
PRUnichar start = aString.First();
|
|
|
|
PRUnichar end = aString.Last();
|
|
|
|
|
|
|
|
if ((start == end) &&
|
1999-09-10 01:05:32 +04:00
|
|
|
((start == PRUnichar('\"')) ||
|
1999-04-02 22:49:40 +04:00
|
|
|
(start == PRUnichar('\'')))) {
|
|
|
|
PRInt32 length = aString.Length();
|
|
|
|
aString.Truncate(length - 1);
|
|
|
|
aString.Cut(0, 1);
|
|
|
|
}
|
|
|
|
return aString;
|
|
|
|
}
|
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationFontInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
1998-09-11 06:07:05 +04:00
|
|
|
{
|
|
|
|
if (nsnull != aDeclaration) {
|
1998-10-27 02:22:19 +03:00
|
|
|
nsIStyleContext* parentContext = aContext->GetParent();
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleFont font(aContext);
|
|
|
|
const nsStyleFont* parentFont = font.get();
|
1998-10-27 02:22:19 +03:00
|
|
|
if (nsnull != parentContext) {
|
|
|
|
parentFont = (const nsStyleFont*)parentContext->GetStyleData(eStyleStruct_Font);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
nsCSSFont* ourFont;
|
1998-09-11 06:07:05 +04:00
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSFontSID, (nsCSSStruct**)&ourFont)) {
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != ourFont) {
|
1999-02-12 20:45:58 +03:00
|
|
|
const nsFont& defaultFont = aPresContext->GetDefaultFontDeprecated();
|
|
|
|
const nsFont& defaultFixedFont = aPresContext->GetDefaultFixedFontDeprecated();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-27 02:22:19 +03:00
|
|
|
// font-family: string list, enum, inherit
|
|
|
|
if (eCSSUnit_String == ourFont->mFamily.GetUnit()) {
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
|
|
|
aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
1999-02-12 21:41:26 +03:00
|
|
|
if (dc) {
|
1998-08-07 06:16:38 +04:00
|
|
|
nsAutoString familyList;
|
|
|
|
|
|
|
|
ourFont->mFamily.GetStringValue(familyList);
|
|
|
|
|
|
|
|
font->mFont.name = familyList;
|
|
|
|
nsAutoString face;
|
2000-10-11 12:33:01 +04:00
|
|
|
|
|
|
|
// MJA: bug 31816
|
|
|
|
// if we are not using document fonts, but this is a xul document,
|
|
|
|
// then we set the chromeOverride bit so we use the document fonts anyway
|
|
|
|
PRBool chromeOverride = PR_FALSE;
|
|
|
|
PRBool useDocumentFonts = PR_TRUE;
|
|
|
|
aPresContext->GetCachedBoolPref(kPresContext_UseDocumentFonts,useDocumentFonts);
|
|
|
|
if (!useDocumentFonts) {
|
|
|
|
// check if the prefs have been disabled for this shell
|
|
|
|
// - if prefs are disabled then we use the document fonts anyway (yet another override)
|
|
|
|
PRBool prefsEnabled = PR_TRUE;
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
if (shell) {
|
|
|
|
shell->ArePrefStyleRulesEnabled(prefsEnabled);
|
|
|
|
}
|
|
|
|
if (!prefsEnabled) {
|
|
|
|
useDocumentFonts = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
// see if we are in the chrome, if so, use the document fonts (override the useDocFonts setting)
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsCOMPtr<nsISupports> container;
|
|
|
|
result = aPresContext->GetContainer(getter_AddRefs(container));
|
|
|
|
if (NS_SUCCEEDED(result) && container) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(container, &result));
|
|
|
|
if (NS_SUCCEEDED(result) && docShell){
|
|
|
|
PRInt32 docShellType;
|
|
|
|
result = docShell->GetItemType(&docShellType);
|
|
|
|
if (NS_SUCCEEDED(result)){
|
|
|
|
if (nsIDocShellTreeItem::typeChrome == docShellType){
|
|
|
|
chromeOverride = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// find the correct font if we are usingDocumentFonts OR we are overriding for XUL
|
|
|
|
// MJA: bug 31816
|
2000-10-26 04:34:08 +04:00
|
|
|
PRBool fontFaceOK = PR_TRUE;
|
|
|
|
PRBool isMozFixed = font->mFont.name.EqualsIgnoreCase("-moz-fixed");
|
|
|
|
if ((chromeOverride || useDocumentFonts)) {
|
|
|
|
fontFaceOK = (NS_OK == dc->FirstExistingFont(font->mFont, face));
|
1998-08-07 06:16:38 +04:00
|
|
|
}
|
2000-10-26 04:34:08 +04:00
|
|
|
if (!fontFaceOK || !(chromeOverride || useDocumentFonts)) {
|
|
|
|
// now set to defaults
|
1998-08-07 06:16:38 +04:00
|
|
|
font->mFont.name = defaultFont.name;
|
2000-10-26 04:34:08 +04:00
|
|
|
font->mFixedFont.name= defaultFixedFont.name;
|
|
|
|
}
|
|
|
|
// set to monospace if using moz-fixed
|
|
|
|
if (isMozFixed) {
|
|
|
|
font->mFlags |= NS_STYLE_FONT_USE_FIXED;
|
|
|
|
} else {
|
|
|
|
font->mFlags &= ~NS_STYLE_FONT_USE_FIXED;
|
1998-08-07 06:16:38 +04:00
|
|
|
}
|
|
|
|
font->mFlags |= NS_STYLE_FONT_FACE_EXPLICIT;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
else if (eCSSUnit_Enumerated == ourFont->mFamily.GetUnit()) {
|
2000-03-25 21:54:36 +03:00
|
|
|
nsSystemAttrID sysID;
|
2000-08-23 14:28:28 +04:00
|
|
|
switch (ourFont->mFamily.GetIntValue()) {
|
|
|
|
case NS_STYLE_FONT_CAPTION: sysID = eSystemAttr_Font_Caption; break; // css2
|
|
|
|
case NS_STYLE_FONT_ICON: sysID = eSystemAttr_Font_Icon; break;
|
|
|
|
case NS_STYLE_FONT_MENU: sysID = eSystemAttr_Font_Menu; break;
|
|
|
|
case NS_STYLE_FONT_MESSAGE_BOX: sysID = eSystemAttr_Font_MessageBox; break;
|
|
|
|
case NS_STYLE_FONT_SMALL_CAPTION: sysID = eSystemAttr_Font_SmallCaption; break;
|
|
|
|
case NS_STYLE_FONT_STATUS_BAR: sysID = eSystemAttr_Font_StatusBar; break;
|
|
|
|
case NS_STYLE_FONT_WINDOW: sysID = eSystemAttr_Font_Window; break; // css3
|
|
|
|
case NS_STYLE_FONT_DOCUMENT: sysID = eSystemAttr_Font_Document; break;
|
|
|
|
case NS_STYLE_FONT_WORKSPACE: sysID = eSystemAttr_Font_Workspace; break;
|
|
|
|
case NS_STYLE_FONT_DESKTOP: sysID = eSystemAttr_Font_Desktop; break;
|
|
|
|
case NS_STYLE_FONT_INFO: sysID = eSystemAttr_Font_Info; break;
|
|
|
|
case NS_STYLE_FONT_DIALOG: sysID = eSystemAttr_Font_Dialog; break;
|
|
|
|
case NS_STYLE_FONT_BUTTON: sysID = eSystemAttr_Font_Button; break;
|
|
|
|
case NS_STYLE_FONT_PULL_DOWN_MENU:sysID = eSystemAttr_Font_PullDownMenu; break;
|
|
|
|
case NS_STYLE_FONT_LIST: sysID = eSystemAttr_Font_List; break;
|
|
|
|
case NS_STYLE_FONT_FIELD: sysID = eSystemAttr_Font_Field; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCompatibility mode;
|
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
2000-03-25 21:54:36 +03:00
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
|
|
|
aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
|
|
|
if (dc) {
|
|
|
|
SystemAttrStruct sysInfo;
|
|
|
|
sysInfo.mFont = &font->mFont;
|
2000-09-21 14:21:23 +04:00
|
|
|
font->mFont.size = defaultFont.size; // GetSystemAttribute sets the font face but not necessarily the size
|
2000-03-25 21:54:36 +03:00
|
|
|
if (NS_FAILED(dc->GetSystemAttribute(sysID, &sysInfo))) {
|
|
|
|
font->mFont.name = defaultFont.name;
|
|
|
|
font->mFixedFont.name = defaultFixedFont.name;
|
|
|
|
}
|
|
|
|
font->mFlags |= NS_STYLE_FONT_FACE_EXPLICIT;
|
|
|
|
}
|
|
|
|
|
2000-08-23 14:28:28 +04:00
|
|
|
// NavQuirks uses sans-serif instead of whatever the native font is
|
|
|
|
if (eCompatibility_NavQuirks == mode) {
|
2000-09-21 14:21:23 +04:00
|
|
|
#ifdef XP_MAC
|
|
|
|
switch (sysID) {
|
|
|
|
case eSystemAttr_Font_Field:
|
|
|
|
case eSystemAttr_Font_List:
|
|
|
|
font->mFont.name.AssignWithConversion("monospace");
|
|
|
|
font->mFont.size = defaultFixedFont.size;
|
|
|
|
break;
|
|
|
|
case eSystemAttr_Font_Button:
|
|
|
|
font->mFont.name.AssignWithConversion("serif");
|
|
|
|
font->mFont.size = defaultFont.size;
|
|
|
|
break;
|
2000-08-23 14:28:28 +04:00
|
|
|
}
|
2000-09-21 14:21:23 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XP_PC
|
|
|
|
switch (sysID) {
|
|
|
|
case eSystemAttr_Font_Field:
|
|
|
|
font->mFont.name.AssignWithConversion("monospace");
|
|
|
|
font->mFont.size = defaultFixedFont.size;
|
|
|
|
break;
|
|
|
|
case eSystemAttr_Font_Button:
|
|
|
|
case eSystemAttr_Font_List:
|
|
|
|
font->mFont.name.AssignWithConversion("sans-serif");
|
2000-10-04 06:17:44 +04:00
|
|
|
font->mFont.size = PR_MAX(defaultFont.size - NSIntPointsToTwips(2), 0);
|
2000-09-21 14:21:23 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XP_UNIX
|
|
|
|
switch (sysID) {
|
|
|
|
case eSystemAttr_Font_Field:
|
|
|
|
font->mFont.name.AssignWithConversion("monospace");
|
|
|
|
font->mFont.size = defaultFixedFont.size;
|
|
|
|
break;
|
|
|
|
case eSystemAttr_Font_Button:
|
|
|
|
case eSystemAttr_Font_List:
|
|
|
|
font->mFont.name.AssignWithConversion("serif");
|
|
|
|
font->mFont.size = defaultFont.size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2000-08-23 14:28:28 +04:00
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourFont->mFamily.GetUnit()) {
|
|
|
|
font->mFont.name = parentFont->mFont.name;
|
|
|
|
font->mFixedFont.name = parentFont->mFixedFont.name;
|
2000-03-14 10:30:29 +03:00
|
|
|
font->mFlags &= ~(NS_STYLE_FONT_FACE_EXPLICIT | NS_STYLE_FONT_USE_FIXED);
|
|
|
|
font->mFlags |= (parentFont->mFlags & (NS_STYLE_FONT_FACE_EXPLICIT | NS_STYLE_FONT_USE_FIXED));
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-27 02:22:19 +03:00
|
|
|
// font-style: enum, normal, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourFont->mStyle.GetUnit()) {
|
1998-04-14 00:24:54 +04:00
|
|
|
font->mFont.style = ourFont->mStyle.GetIntValue();
|
1998-07-17 09:46:12 +04:00
|
|
|
font->mFixedFont.style = ourFont->mStyle.GetIntValue();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
else if (eCSSUnit_Normal == ourFont->mStyle.GetUnit()) {
|
|
|
|
font->mFont.style = NS_STYLE_FONT_STYLE_NORMAL;
|
|
|
|
font->mFixedFont.style = NS_STYLE_FONT_STYLE_NORMAL;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourFont->mStyle.GetUnit()) {
|
|
|
|
font->mFont.style = parentFont->mFont.style;
|
|
|
|
font->mFixedFont.style = parentFont->mFixedFont.style;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-27 02:22:19 +03:00
|
|
|
// font-variant: enum, normal, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourFont->mVariant.GetUnit()) {
|
1998-04-14 00:24:54 +04:00
|
|
|
font->mFont.variant = ourFont->mVariant.GetIntValue();
|
1998-07-17 09:46:12 +04:00
|
|
|
font->mFixedFont.variant = ourFont->mVariant.GetIntValue();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
else if (eCSSUnit_Normal == ourFont->mVariant.GetUnit()) {
|
|
|
|
font->mFont.variant = NS_STYLE_FONT_VARIANT_NORMAL;
|
|
|
|
font->mFixedFont.variant = NS_STYLE_FONT_VARIANT_NORMAL;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourFont->mVariant.GetUnit()) {
|
|
|
|
font->mFont.variant = parentFont->mFont.variant;
|
|
|
|
font->mFixedFont.variant = parentFont->mFixedFont.variant;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-27 02:22:19 +03:00
|
|
|
// font-weight: int, enum, normal, inherit
|
|
|
|
if (eCSSUnit_Integer == ourFont->mWeight.GetUnit()) {
|
1998-07-17 09:46:12 +04:00
|
|
|
font->mFont.weight = ourFont->mWeight.GetIntValue();
|
|
|
|
font->mFixedFont.weight = ourFont->mWeight.GetIntValue();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
else if (eCSSUnit_Enumerated == ourFont->mWeight.GetUnit()) {
|
1998-04-14 00:24:54 +04:00
|
|
|
PRInt32 value = ourFont->mWeight.GetIntValue();
|
|
|
|
switch (value) {
|
|
|
|
case NS_STYLE_FONT_WEIGHT_NORMAL:
|
|
|
|
case NS_STYLE_FONT_WEIGHT_BOLD:
|
|
|
|
font->mFont.weight = value;
|
1998-07-17 09:46:12 +04:00
|
|
|
font->mFixedFont.weight = value;
|
1998-04-14 00:24:54 +04:00
|
|
|
break;
|
|
|
|
case NS_STYLE_FONT_WEIGHT_BOLDER:
|
|
|
|
case NS_STYLE_FONT_WEIGHT_LIGHTER:
|
1999-09-10 09:56:19 +04:00
|
|
|
font->mFont.weight = nsStyleUtil::ConstrainFontWeight(parentFont->mFont.weight + value);
|
|
|
|
font->mFixedFont.weight = nsStyleUtil::ConstrainFontWeight(parentFont->mFixedFont.weight + value);
|
1998-04-14 00:24:54 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
else if (eCSSUnit_Normal == ourFont->mWeight.GetUnit()) {
|
|
|
|
font->mFont.weight = NS_STYLE_FONT_WEIGHT_NORMAL;
|
|
|
|
font->mFixedFont.weight = NS_STYLE_FONT_WEIGHT_NORMAL;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourFont->mWeight.GetUnit()) {
|
|
|
|
font->mFont.weight = parentFont->mFont.weight;
|
|
|
|
font->mFixedFont.weight = parentFont->mFixedFont.weight;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-27 02:22:19 +03:00
|
|
|
// font-size: enum, length, percent, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourFont->mSize.GetUnit()) {
|
1998-04-14 00:24:54 +04:00
|
|
|
PRInt32 value = ourFont->mSize.GetIntValue();
|
1998-11-26 21:14:41 +03:00
|
|
|
PRInt32 scaler;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext->GetFontScaler(&scaler);
|
1998-07-25 05:22:10 +04:00
|
|
|
float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
if ((NS_STYLE_FONT_SIZE_XXSMALL <= value) &&
|
|
|
|
(value <= NS_STYLE_FONT_SIZE_XXLARGE)) {
|
2000-02-24 15:51:28 +03:00
|
|
|
font->mFont.size = nsStyleUtil::CalcFontPointSize(value, (PRInt32)defaultFont.size, scaleFactor, aPresContext, eFontSize_CSS);
|
|
|
|
font->mFixedFont.size = nsStyleUtil::CalcFontPointSize(value, (PRInt32)defaultFixedFont.size, scaleFactor, aPresContext, eFontSize_CSS);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
else if (NS_STYLE_FONT_SIZE_LARGER == value) {
|
2000-03-25 16:48:50 +03:00
|
|
|
PRInt32 index = nsStyleUtil::FindNextLargerFontSize(parentFont->mFont.size, (PRInt32)defaultFont.size, scaleFactor, aPresContext, eFontSize_CSS);
|
2001-04-18 03:23:09 +04:00
|
|
|
nscoord largerSize = nsStyleUtil::CalcFontPointSize(index, (PRInt32)defaultFont.size, scaleFactor, aPresContext, eFontSize_CSS);
|
|
|
|
nscoord largerFixedSize = nsStyleUtil::CalcFontPointSize(index, (PRInt32)defaultFixedFont.size, scaleFactor, aPresContext, eFontSize_CSS);
|
2001-04-18 04:33:23 +04:00
|
|
|
font->mFont.size = PR_MAX(largerSize, parentFont->mFont.size);
|
|
|
|
font->mFixedFont.size = PR_MAX(largerFixedSize, parentFont->mFixedFont.size);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
else if (NS_STYLE_FONT_SIZE_SMALLER == value) {
|
2000-03-25 16:48:50 +03:00
|
|
|
PRInt32 index = nsStyleUtil::FindNextSmallerFontSize(parentFont->mFont.size, (PRInt32)defaultFont.size, scaleFactor, aPresContext, eFontSize_CSS);
|
2001-04-18 03:23:09 +04:00
|
|
|
nscoord smallerSize = nsStyleUtil::CalcFontPointSize(index, (PRInt32)defaultFont.size, scaleFactor, aPresContext, eFontSize_CSS);
|
|
|
|
nscoord smallerFixedSize = nsStyleUtil::CalcFontPointSize(index, (PRInt32)defaultFixedFont.size, scaleFactor, aPresContext, eFontSize_CSS);
|
2001-04-18 04:33:23 +04:00
|
|
|
font->mFont.size = PR_MIN(smallerSize, parentFont->mFont.size);
|
|
|
|
font->mFixedFont.size = PR_MIN(smallerFixedSize, parentFont->mFixedFont.size);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-07-23 22:03:55 +04:00
|
|
|
// this does NOT explicitly set font size
|
1998-10-27 02:22:19 +03:00
|
|
|
font->mFlags &= ~NS_STYLE_FONT_SIZE_EXPLICIT;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
else if (ourFont->mSize.IsLengthUnit()) {
|
1999-06-22 23:23:56 +04:00
|
|
|
font->mFont.size = CalcLength(ourFont->mSize, parentFont->mFont, aPresContext);
|
|
|
|
font->mFixedFont.size = CalcLength(ourFont->mSize, parentFont->mFixedFont, aPresContext);
|
1998-07-23 22:03:55 +04:00
|
|
|
font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
else if (eCSSUnit_Percent == ourFont->mSize.GetUnit()) {
|
1998-04-30 23:57:36 +04:00
|
|
|
font->mFont.size = (nscoord)((float)(parentFont->mFont.size) * ourFont->mSize.GetPercentValue());
|
1998-07-17 09:49:03 +04:00
|
|
|
font->mFixedFont.size = (nscoord)((float)(parentFont->mFixedFont.size) * ourFont->mSize.GetPercentValue());
|
1998-07-23 22:03:55 +04:00
|
|
|
font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
else if (eCSSUnit_Inherit == ourFont->mSize.GetUnit()) {
|
|
|
|
font->mFont.size = parentFont->mFont.size;
|
|
|
|
font->mFixedFont.size = parentFont->mFixedFont.size;
|
|
|
|
font->mFlags &= ~NS_STYLE_FONT_SIZE_EXPLICIT;
|
|
|
|
font->mFlags |= (parentFont->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-16 01:23:05 +04:00
|
|
|
NS_IF_RELEASE(parentContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationTextInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
1999-04-16 01:23:05 +04:00
|
|
|
{
|
1999-09-10 09:56:19 +04:00
|
|
|
const nsStyleFont* parentFont = aFont;
|
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentFont = (const nsStyleFont*)aParentContext->GetStyleData(eStyleStruct_Font);
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
nsCSSText* ourText;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSTextSID, (nsCSSStruct**)&ourText)) {
|
|
|
|
if (nsnull != ourText) {
|
|
|
|
// Get our text style and our parent's text style
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleText text(aContext);
|
|
|
|
const nsStyleText* parentText = text.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentText = (const nsStyleText*)aParentContext->GetStyleData(eStyleStruct_Text);
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// letter-spacing: normal, length, inherit
|
|
|
|
SetCoord(ourText->mLetterSpacing, text->mLetterSpacing, parentText->mLetterSpacing,
|
|
|
|
SETCOORD_LH | SETCOORD_NORMAL, aFont->mFont, aPresContext);
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// line-height: normal, number, length, percent, inherit
|
|
|
|
SetCoord(ourText->mLineHeight, text->mLineHeight, parentText->mLineHeight,
|
|
|
|
SETCOORD_LPFHN, aFont->mFont, aPresContext);
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// text-align: enum, string, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourText->mTextAlign.GetUnit()) {
|
|
|
|
text->mTextAlign = ourText->mTextAlign.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_String == ourText->mTextAlign.GetUnit()) {
|
|
|
|
NS_NOTYETIMPLEMENTED("align string");
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourText->mTextAlign.GetUnit()) {
|
|
|
|
text->mTextAlign = parentText->mTextAlign;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// text-indent: length, percent, inherit
|
|
|
|
SetCoord(ourText->mTextIndent, text->mTextIndent, parentText->mTextIndent,
|
|
|
|
SETCOORD_LPH, aFont->mFont, aPresContext);
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// text-decoration: none, enum (bit field), inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourText->mDecoration.GetUnit()) {
|
|
|
|
PRInt32 td = ourText->mDecoration.GetIntValue();
|
|
|
|
aFont->mFont.decorations = (parentFont->mFont.decorations | td);
|
|
|
|
aFont->mFixedFont.decorations = (parentFont->mFixedFont.decorations | td);
|
|
|
|
text->mTextDecoration = td;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourText->mDecoration.GetUnit()) {
|
|
|
|
aFont->mFont.decorations = parentFont->mFont.decorations;
|
|
|
|
aFont->mFixedFont.decorations = parentFont->mFixedFont.decorations;
|
|
|
|
text->mTextDecoration = NS_STYLE_TEXT_DECORATION_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourText->mDecoration.GetUnit()) {
|
|
|
|
aFont->mFont.decorations = parentFont->mFont.decorations;
|
|
|
|
aFont->mFixedFont.decorations = parentFont->mFixedFont.decorations;
|
|
|
|
text->mTextDecoration = parentText->mTextDecoration;
|
|
|
|
}
|
1998-04-28 01:26:06 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// text-transform: enum, none, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourText->mTextTransform.GetUnit()) {
|
|
|
|
text->mTextTransform = ourText->mTextTransform.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourText->mTextTransform.GetUnit()) {
|
|
|
|
text->mTextTransform = NS_STYLE_TEXT_TRANSFORM_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourText->mTextTransform.GetUnit()) {
|
|
|
|
text->mTextTransform = parentText->mTextTransform;
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// vertical-align: enum, length, percent, inherit
|
|
|
|
if (! SetCoord(ourText->mVerticalAlign, text->mVerticalAlign, parentText->mVerticalAlign,
|
|
|
|
SETCOORD_LPH | SETCOORD_ENUMERATED, aFont->mFont, aPresContext)) {
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// white-space: enum, normal, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourText->mWhiteSpace.GetUnit()) {
|
|
|
|
text->mWhiteSpace = ourText->mWhiteSpace.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Normal == ourText->mWhiteSpace.GetUnit()) {
|
|
|
|
text->mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourText->mWhiteSpace.GetUnit()) {
|
|
|
|
text->mWhiteSpace = parentText->mWhiteSpace;
|
1998-04-25 22:44:55 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
|
|
|
|
// word-spacing: normal, length, inherit
|
|
|
|
SetCoord(ourText->mWordSpacing, text->mWordSpacing, parentText->mWordSpacing,
|
|
|
|
SETCOORD_LH | SETCOORD_NORMAL, aFont->mFont, aPresContext);
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
// unicode-bidi: enum, normal, inherit
|
|
|
|
// normal means that override prohibited
|
|
|
|
if (eCSSUnit_Normal == ourText->mUnicodeBidi.GetUnit() ) {
|
|
|
|
text->mUnicodeBidi = NS_STYLE_UNICODE_BIDI_NORMAL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (eCSSUnit_Enumerated == ourText->mUnicodeBidi.GetUnit() ) {
|
|
|
|
text->mUnicodeBidi = ourText->mUnicodeBidi.GetIntValue();
|
|
|
|
}
|
|
|
|
if (NS_STYLE_UNICODE_BIDI_INHERIT == text->mUnicodeBidi) {
|
|
|
|
text->mUnicodeBidi = parentText->mUnicodeBidi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
1998-04-25 22:44:55 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationDisplayInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSDisplay* ourDisplay;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSDisplaySID, (nsCSSStruct**)&ourDisplay)) {
|
|
|
|
if (nsnull != ourDisplay) {
|
|
|
|
// Get our style and our parent's style
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleDisplay display(aContext);
|
|
|
|
const nsStyleDisplay* parentDisplay = display.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentDisplay = (const nsStyleDisplay*)aParentContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
}
|
1998-05-27 03:16:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// display: enum, none, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourDisplay->mDisplay.GetUnit()) {
|
|
|
|
display->mDisplay = ourDisplay->mDisplay.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourDisplay->mDisplay.GetUnit()) {
|
|
|
|
display->mDisplay = NS_STYLE_DISPLAY_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourDisplay->mDisplay.GetUnit()) {
|
|
|
|
display->mDisplay = parentDisplay->mDisplay;
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// direction: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourDisplay->mDirection.GetUnit()) {
|
|
|
|
display->mDirection = ourDisplay->mDirection.GetIntValue();
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
display->mExplicitDirection = display->mDirection;
|
|
|
|
|
|
|
|
if (NS_STYLE_DIRECTION_RTL == display->mDirection) {
|
2001-05-16 17:40:08 +04:00
|
|
|
aPresContext->SetBidiEnabled(PR_TRUE);
|
2001-03-09 06:13:03 +03:00
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourDisplay->mDirection.GetUnit()) {
|
|
|
|
display->mDirection = parentDisplay->mDirection;
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// clear: enum, none, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourDisplay->mClear.GetUnit()) {
|
|
|
|
display->mBreakType = ourDisplay->mClear.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourDisplay->mClear.GetUnit()) {
|
|
|
|
display->mBreakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourDisplay->mClear.GetUnit()) {
|
|
|
|
display->mBreakType = parentDisplay->mBreakType;
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// float: enum, none, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourDisplay->mFloat.GetUnit()) {
|
|
|
|
display->mFloats = ourDisplay->mFloat.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourDisplay->mFloat.GetUnit()) {
|
|
|
|
display->mFloats = NS_STYLE_FLOAT_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourDisplay->mFloat.GetUnit()) {
|
|
|
|
display->mFloats = parentDisplay->mFloats;
|
|
|
|
}
|
1998-05-27 03:16:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// visibility: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourDisplay->mVisibility.GetUnit()) {
|
|
|
|
display->mVisible = ourDisplay->mVisibility.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourDisplay->mVisibility.GetUnit()) {
|
|
|
|
display->mVisible = parentDisplay->mVisible;
|
|
|
|
}
|
1998-05-27 03:16:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// overflow: enum, auto, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourDisplay->mOverflow.GetUnit()) {
|
|
|
|
display->mOverflow = ourDisplay->mOverflow.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Auto == ourDisplay->mOverflow.GetUnit()) {
|
|
|
|
display->mOverflow = NS_STYLE_OVERFLOW_AUTO;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourDisplay->mOverflow.GetUnit()) {
|
|
|
|
display->mOverflow = parentDisplay->mOverflow;
|
|
|
|
}
|
1998-05-27 03:16:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// clip property: length, auto, inherit
|
|
|
|
if (nsnull != ourDisplay->mClip) {
|
|
|
|
if (eCSSUnit_Inherit == ourDisplay->mClip->mTop.GetUnit()) { // if one is inherit, they all are
|
|
|
|
display->mClipFlags = NS_STYLE_CLIP_INHERIT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PRBool fullAuto = PR_TRUE;
|
|
|
|
|
|
|
|
display->mClipFlags = 0; // clear it
|
|
|
|
|
|
|
|
if (eCSSUnit_Auto == ourDisplay->mClip->mTop.GetUnit()) {
|
2000-04-25 08:43:11 +04:00
|
|
|
display->mClip.y = 0;
|
1999-09-10 09:56:19 +04:00
|
|
|
display->mClipFlags |= NS_STYLE_CLIP_TOP_AUTO;
|
|
|
|
}
|
|
|
|
else if (ourDisplay->mClip->mTop.IsLengthUnit()) {
|
2000-04-25 08:43:11 +04:00
|
|
|
display->mClip.y = CalcLength(ourDisplay->mClip->mTop, aFont->mFont, aPresContext);
|
1999-09-10 09:56:19 +04:00
|
|
|
fullAuto = PR_FALSE;
|
|
|
|
}
|
|
|
|
if (eCSSUnit_Auto == ourDisplay->mClip->mBottom.GetUnit()) {
|
2000-04-25 08:43:11 +04:00
|
|
|
display->mClip.height = 0;
|
1999-09-10 09:56:19 +04:00
|
|
|
display->mClipFlags |= NS_STYLE_CLIP_BOTTOM_AUTO;
|
|
|
|
}
|
|
|
|
else if (ourDisplay->mClip->mBottom.IsLengthUnit()) {
|
2000-04-25 08:43:11 +04:00
|
|
|
display->mClip.height = CalcLength(ourDisplay->mClip->mBottom, aFont->mFont, aPresContext) -
|
|
|
|
display->mClip.y;
|
1999-09-10 09:56:19 +04:00
|
|
|
fullAuto = PR_FALSE;
|
|
|
|
}
|
|
|
|
if (eCSSUnit_Auto == ourDisplay->mClip->mLeft.GetUnit()) {
|
2000-04-25 08:43:11 +04:00
|
|
|
display->mClip.x = 0;
|
1999-09-10 09:56:19 +04:00
|
|
|
display->mClipFlags |= NS_STYLE_CLIP_LEFT_AUTO;
|
|
|
|
}
|
|
|
|
else if (ourDisplay->mClip->mLeft.IsLengthUnit()) {
|
2000-04-25 08:43:11 +04:00
|
|
|
display->mClip.x = CalcLength(ourDisplay->mClip->mLeft, aFont->mFont, aPresContext);
|
|
|
|
fullAuto = PR_FALSE;
|
|
|
|
}
|
|
|
|
if (eCSSUnit_Auto == ourDisplay->mClip->mRight.GetUnit()) {
|
|
|
|
display->mClip.width = 0;
|
|
|
|
display->mClipFlags |= NS_STYLE_CLIP_RIGHT_AUTO;
|
|
|
|
}
|
|
|
|
else if (ourDisplay->mClip->mRight.IsLengthUnit()) {
|
|
|
|
display->mClip.width = CalcLength(ourDisplay->mClip->mRight, aFont->mFont, aPresContext) -
|
|
|
|
display->mClip.x;
|
1999-09-10 09:56:19 +04:00
|
|
|
fullAuto = PR_FALSE;
|
|
|
|
}
|
|
|
|
display->mClipFlags &= ~NS_STYLE_CLIP_TYPE_MASK;
|
|
|
|
if (fullAuto) {
|
|
|
|
display->mClipFlags |= NS_STYLE_CLIP_AUTO;
|
1998-05-27 03:16:55 +04:00
|
|
|
}
|
|
|
|
else {
|
1999-09-10 09:56:19 +04:00
|
|
|
display->mClipFlags |= NS_STYLE_CLIP_RECT;
|
1998-05-27 03:16:55 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationColorInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSColor* ourColor;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSColorSID, (nsCSSStruct**)&ourColor)) {
|
|
|
|
if (nsnull != ourColor) {
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleColor color(aContext);
|
|
|
|
const nsStyleColor* parentColor = color.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentColor = (const nsStyleColor*)aParentContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// color: color, string, inherit
|
|
|
|
if (! SetColor(ourColor->mColor, parentColor->mColor, aPresContext, color->mColor)) {
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// cursor: enum, auto, url, inherit
|
|
|
|
nsCSSValueList* list = ourColor->mCursor;
|
|
|
|
if (nsnull != list) {
|
|
|
|
// XXX need to deal with multiple URL values
|
|
|
|
if (eCSSUnit_Enumerated == list->mValue.GetUnit()) {
|
|
|
|
color->mCursor = list->mValue.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Auto == list->mValue.GetUnit()) {
|
|
|
|
color->mCursor = NS_STYLE_CURSOR_AUTO;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_URL == list->mValue.GetUnit()) {
|
|
|
|
list->mValue.GetStringValue(color->mCursorImage);
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == list->mValue.GetUnit()) {
|
|
|
|
color->mCursor = parentColor->mCursor;
|
1998-11-03 23:31:21 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// background-color: color, string, enum (flags), inherit
|
|
|
|
if (eCSSUnit_Inherit == ourColor->mBackColor.GetUnit()) { // do inherit first, so SetColor doesn't do it
|
2000-04-15 14:38:13 +04:00
|
|
|
const nsStyleColor* inheritColor = parentColor;
|
|
|
|
if (inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT) {
|
2000-08-05 00:44:08 +04:00
|
|
|
// walk up the contexts until we get to a context that does not have its
|
|
|
|
// background propagated to its parent (or a context that has had its background
|
|
|
|
// propagated from its child)
|
2000-04-15 14:38:13 +04:00
|
|
|
if (nsnull != aParentContext) {
|
2000-08-05 00:44:08 +04:00
|
|
|
nsCOMPtr<nsIStyleContext> higherContext = getter_AddRefs(aParentContext->GetParent());
|
|
|
|
do {
|
|
|
|
if (higherContext) {
|
|
|
|
inheritColor = (const nsStyleColor*)higherContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
if (inheritColor &&
|
|
|
|
(!(inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT)) ||
|
|
|
|
(inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_FROM_CHILD)) {
|
|
|
|
// done walking up the higher contexts
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
higherContext = getter_AddRefs(higherContext->GetParent());
|
|
|
|
}
|
|
|
|
} while (higherContext);
|
2000-04-15 14:38:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
color->mBackgroundColor = inheritColor->mBackgroundColor;
|
1999-09-10 09:56:19 +04:00
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
2000-04-15 14:38:13 +04:00
|
|
|
color->mBackgroundFlags |= (inheritColor->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (SetColor(ourColor->mBackColor, parentColor->mBackgroundColor,
|
|
|
|
aPresContext, color->mBackgroundColor)) {
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Enumerated == ourColor->mBackColor.GetUnit()) {
|
2000-03-29 10:55:15 +04:00
|
|
|
color->mBackgroundColor = parentColor->mBackgroundColor;
|
1999-09-10 09:56:19 +04:00
|
|
|
color->mBackgroundFlags |= NS_STYLE_BG_COLOR_TRANSPARENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// background-image: url, none, inherit
|
|
|
|
if (eCSSUnit_URL == ourColor->mBackImage.GetUnit()) {
|
|
|
|
ourColor->mBackImage.GetStringValue(color->mBackgroundImage);
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourColor->mBackImage.GetUnit()) {
|
|
|
|
color->mBackgroundImage.Truncate();
|
|
|
|
color->mBackgroundFlags |= NS_STYLE_BG_IMAGE_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourColor->mBackImage.GetUnit()) {
|
|
|
|
color->mBackgroundImage = parentColor->mBackgroundImage;
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE;
|
|
|
|
color->mBackgroundFlags |= (parentColor->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// background-repeat: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourColor->mBackRepeat.GetUnit()) {
|
|
|
|
color->mBackgroundRepeat = ourColor->mBackRepeat.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourColor->mBackRepeat.GetUnit()) {
|
|
|
|
color->mBackgroundRepeat = parentColor->mBackgroundRepeat;
|
|
|
|
}
|
|
|
|
|
|
|
|
// background-attachment: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourColor->mBackAttachment.GetUnit()) {
|
|
|
|
color->mBackgroundAttachment = ourColor->mBackAttachment.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourColor->mBackAttachment.GetUnit()) {
|
|
|
|
color->mBackgroundAttachment = parentColor->mBackgroundAttachment;
|
|
|
|
}
|
|
|
|
|
|
|
|
// background-position: enum, length, percent (flags), inherit
|
|
|
|
if (eCSSUnit_Percent == ourColor->mBackPositionX.GetUnit()) {
|
|
|
|
color->mBackgroundXPosition = (nscoord)(100.0f * ourColor->mBackPositionX.GetPercentValue());
|
|
|
|
color->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
|
|
|
}
|
|
|
|
else if (ourColor->mBackPositionX.IsLengthUnit()) {
|
|
|
|
color->mBackgroundXPosition = CalcLength(ourColor->mBackPositionX,
|
|
|
|
aFont->mFont, aPresContext);
|
|
|
|
color->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_LENGTH;
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_PERCENT;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Enumerated == ourColor->mBackPositionX.GetUnit()) {
|
|
|
|
color->mBackgroundXPosition = (nscoord)ourColor->mBackPositionX.GetIntValue();
|
|
|
|
color->mBackgroundFlags |= NS_STYLE_BG_X_POSITION_PERCENT;
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_X_POSITION_LENGTH;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourColor->mBackPositionX.GetUnit()) {
|
|
|
|
color->mBackgroundXPosition = parentColor->mBackgroundXPosition;
|
|
|
|
color->mBackgroundFlags &= ~(NS_STYLE_BG_X_POSITION_LENGTH | NS_STYLE_BG_X_POSITION_PERCENT);
|
|
|
|
color->mBackgroundFlags |= (parentColor->mBackgroundFlags & (NS_STYLE_BG_X_POSITION_LENGTH | NS_STYLE_BG_X_POSITION_PERCENT));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eCSSUnit_Percent == ourColor->mBackPositionY.GetUnit()) {
|
|
|
|
color->mBackgroundYPosition = (nscoord)(100.0f * ourColor->mBackPositionY.GetPercentValue());
|
|
|
|
color->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
|
|
|
}
|
|
|
|
else if (ourColor->mBackPositionY.IsLengthUnit()) {
|
|
|
|
color->mBackgroundYPosition = CalcLength(ourColor->mBackPositionY,
|
|
|
|
aFont->mFont, aPresContext);
|
|
|
|
color->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_LENGTH;
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_PERCENT;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Enumerated == ourColor->mBackPositionY.GetUnit()) {
|
|
|
|
color->mBackgroundYPosition = (nscoord)ourColor->mBackPositionY.GetIntValue();
|
|
|
|
color->mBackgroundFlags |= NS_STYLE_BG_Y_POSITION_PERCENT;
|
|
|
|
color->mBackgroundFlags &= ~NS_STYLE_BG_Y_POSITION_LENGTH;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourColor->mBackPositionY.GetUnit()) {
|
|
|
|
color->mBackgroundYPosition = parentColor->mBackgroundYPosition;
|
|
|
|
color->mBackgroundFlags &= ~(NS_STYLE_BG_Y_POSITION_LENGTH | NS_STYLE_BG_Y_POSITION_PERCENT);
|
|
|
|
color->mBackgroundFlags |= (parentColor->mBackgroundFlags & (NS_STYLE_BG_Y_POSITION_LENGTH | NS_STYLE_BG_Y_POSITION_PERCENT));
|
|
|
|
}
|
|
|
|
|
|
|
|
// opacity: factor, percent, inherit
|
|
|
|
if (eCSSUnit_Percent == ourColor->mOpacity.GetUnit()) {
|
|
|
|
float opacity = parentColor->mOpacity * ourColor->mOpacity.GetPercentValue();
|
|
|
|
if (opacity < 0.0f) {
|
|
|
|
color->mOpacity = 0.0f;
|
|
|
|
} else if (1.0 < opacity) {
|
|
|
|
color->mOpacity = 1.0f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
color->mOpacity = opacity;
|
1998-04-25 22:44:55 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Number == ourColor->mOpacity.GetUnit()) {
|
|
|
|
color->mOpacity = ourColor->mOpacity.GetFloatValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourColor->mOpacity.GetUnit()) {
|
|
|
|
color->mOpacity = parentColor->mOpacity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
MapDeclarationMarginInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSMargin* ourMargin;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSMarginSID, (nsCSSStruct**)&ourMargin)) {
|
|
|
|
if (nsnull != ourMargin) {
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleMargin margin(aContext);
|
|
|
|
nsMutableStylePadding padding(aContext);
|
|
|
|
nsMutableStyleBorder border(aContext);
|
|
|
|
nsMutableStyleOutline outline(aContext);
|
|
|
|
|
|
|
|
const nsStyleMargin* parentMargin = margin.get();
|
|
|
|
const nsStylePadding* parentPadding = padding.get();
|
|
|
|
const nsStyleBorder* parentBorder = border.get();
|
|
|
|
const nsStyleOutline* parentOutline = outline.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
2001-02-07 12:57:26 +03:00
|
|
|
parentMargin = (const nsStyleMargin*)aParentContext->GetStyleData(eStyleStruct_Margin);
|
|
|
|
parentPadding = (const nsStylePadding*)aParentContext->GetStyleData(eStyleStruct_Padding);
|
|
|
|
parentBorder = (const nsStyleBorder*)aParentContext->GetStyleData(eStyleStruct_Border);
|
|
|
|
parentOutline = (const nsStyleOutline*)aParentContext->GetStyleData(eStyleStruct_Outline);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// margin: length, percent, auto, inherit
|
|
|
|
if (nsnull != ourMargin->mMargin) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
nsStyleCoord parentCoord;
|
2001-02-07 12:57:26 +03:00
|
|
|
parentMargin->mMargin.GetLeft(parentCoord);
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mMargin->mLeft, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
margin->mMargin.SetLeft(coord);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentMargin->mMargin.GetTop(parentCoord);
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mMargin->mTop, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
margin->mMargin.SetTop(coord);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentMargin->mMargin.GetRight(parentCoord);
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mMargin->mRight, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
margin->mMargin.SetRight(coord);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentMargin->mMargin.GetBottom(parentCoord);
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mMargin->mBottom, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
margin->mMargin.SetBottom(coord);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// padding: length, percent, inherit
|
|
|
|
if (nsnull != ourMargin->mPadding) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
nsStyleCoord parentCoord;
|
2001-02-07 12:57:26 +03:00
|
|
|
parentPadding->mPadding.GetLeft(parentCoord);
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mPadding->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
padding->mPadding.SetLeft(coord);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentPadding->mPadding.GetTop(parentCoord);
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mPadding->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
padding->mPadding.SetTop(coord);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentPadding->mPadding.GetRight(parentCoord);
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mPadding->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
padding->mPadding.SetRight(coord);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentPadding->mPadding.GetBottom(parentCoord);
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mPadding->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
padding->mPadding.SetBottom(coord);
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// border-size: length, enum, inherit
|
|
|
|
if (nsnull != ourMargin->mBorderWidth) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
nsStyleCoord parentCoord;
|
|
|
|
if (SetCoord(ourMargin->mBorderWidth->mLeft, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorder.SetLeft(coord);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mLeft.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorder.SetLeft(parentBorder->mBorder.GetLeft(coord));
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mBorderWidth->mTop, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorder.SetTop(coord);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mTop.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorder.SetTop(parentBorder->mBorder.GetTop(coord));
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
if (SetCoord(ourMargin->mBorderWidth->mRight, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorder.SetRight(coord);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mRight.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorder.SetRight(parentBorder->mBorder.GetRight(coord));
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
|
|
|
|
if (SetCoord(ourMargin->mBorderWidth->mBottom, coord, parentCoord, SETCOORD_LE, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorder.SetBottom(coord);
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourMargin->mBorderWidth->mBottom.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorder.SetBottom(parentBorder->mBorder.GetBottom(coord));
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// border-style: enum, none, inhert
|
|
|
|
if (nsnull != ourMargin->mBorderStyle) {
|
|
|
|
nsCSSRect* ourStyle = ourMargin->mBorderStyle;
|
|
|
|
if (eCSSUnit_Enumerated == ourStyle->mTop.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_TOP, ourStyle->mTop.GetIntValue());
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_None == ourStyle->mTop.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourStyle->mTop.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_TOP, parentBorder->GetBorderStyle(NS_SIDE_TOP));
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Enumerated == ourStyle->mRight.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_RIGHT, ourStyle->mRight.GetIntValue());
|
1998-05-28 06:02:43 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_None == ourStyle->mRight.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
|
1998-05-28 06:02:43 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourStyle->mRight.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_RIGHT, parentBorder->GetBorderStyle(NS_SIDE_RIGHT));
|
1998-05-28 06:02:43 +04:00
|
|
|
}
|
1998-04-19 02:16:37 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Enumerated == ourStyle->mBottom.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_BOTTOM, ourStyle->mBottom.GetIntValue());
|
1998-10-27 02:22:19 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_None == ourStyle->mBottom.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
|
1998-04-19 02:16:37 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourStyle->mBottom.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_BOTTOM, parentBorder->GetBorderStyle(NS_SIDE_BOTTOM));
|
1998-04-25 22:44:55 +04:00
|
|
|
}
|
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Enumerated == ourStyle->mLeft.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_LEFT, ourStyle->mLeft.GetIntValue());
|
1998-04-25 22:44:55 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_None == ourStyle->mLeft.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
|
1998-04-25 22:44:55 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourStyle->mLeft.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderStyle(NS_SIDE_LEFT, parentBorder->GetBorderStyle(NS_SIDE_LEFT));
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-25 22:44:55 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// border-color: color, string, enum, inherit
|
|
|
|
if (nsnull != ourMargin->mBorderColor) {
|
|
|
|
nsCSSRect* ourBorderColor = ourMargin->mBorderColor;
|
|
|
|
nscolor borderColor;
|
|
|
|
nscolor unused = NS_RGB(0,0,0);
|
2001-05-02 14:31:31 +04:00
|
|
|
// top
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Inherit == ourBorderColor->mTop.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
if (parentBorder->GetBorderColor(NS_SIDE_TOP, borderColor)) {
|
|
|
|
border->SetBorderColor(NS_SIDE_TOP, borderColor);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderTransparent(NS_SIDE_TOP);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (SetColor(ourBorderColor->mTop, unused, aPresContext, borderColor)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderColor(NS_SIDE_TOP, borderColor);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Enumerated == ourBorderColor->mTop.GetUnit()) {
|
2001-05-02 14:31:31 +04:00
|
|
|
switch (ourBorderColor->mTop.GetIntValue()) {
|
|
|
|
case NS_STYLE_COLOR_TRANSPARENT:
|
|
|
|
border->SetBorderTransparent(NS_SIDE_TOP);
|
|
|
|
break;
|
|
|
|
case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:
|
|
|
|
const nsStyleColor* ourColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
border->SetBorderColor(NS_SIDE_TOP, ourColor->mColor);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-05-02 14:31:31 +04:00
|
|
|
// right
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Inherit == ourBorderColor->mRight.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
if (parentBorder->GetBorderColor(NS_SIDE_RIGHT, borderColor)) {
|
|
|
|
border->SetBorderColor(NS_SIDE_RIGHT, borderColor);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderTransparent(NS_SIDE_RIGHT);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (SetColor(ourBorderColor->mRight, unused, aPresContext, borderColor)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderColor(NS_SIDE_RIGHT, borderColor);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-05-03 11:39:57 +04:00
|
|
|
else if (eCSSUnit_Enumerated == ourBorderColor->mRight.GetUnit()) {
|
2001-05-02 14:31:31 +04:00
|
|
|
switch (ourBorderColor->mRight.GetIntValue()) {
|
|
|
|
case NS_STYLE_COLOR_TRANSPARENT:
|
|
|
|
border->SetBorderTransparent(NS_SIDE_RIGHT);
|
|
|
|
break;
|
|
|
|
case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:
|
|
|
|
const nsStyleColor* ourColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
border->SetBorderColor(NS_SIDE_RIGHT, ourColor->mColor);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-05-02 14:31:31 +04:00
|
|
|
// bottom
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Inherit == ourBorderColor->mBottom.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
if (parentBorder->GetBorderColor(NS_SIDE_BOTTOM, borderColor)) {
|
|
|
|
border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderTransparent(NS_SIDE_BOTTOM);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (SetColor(ourBorderColor->mBottom, unused, aPresContext, borderColor)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderColor(NS_SIDE_BOTTOM, borderColor);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-05-03 11:39:57 +04:00
|
|
|
else if (eCSSUnit_Enumerated == ourBorderColor->mBottom.GetUnit()) {
|
2001-05-02 14:31:31 +04:00
|
|
|
switch (ourBorderColor->mBottom.GetIntValue()) {
|
|
|
|
case NS_STYLE_COLOR_TRANSPARENT:
|
|
|
|
border->SetBorderTransparent(NS_SIDE_BOTTOM);
|
|
|
|
break;
|
|
|
|
case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:
|
|
|
|
const nsStyleColor* ourColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
border->SetBorderColor(NS_SIDE_BOTTOM, ourColor->mColor);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
2001-05-02 14:31:31 +04:00
|
|
|
// left
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Inherit == ourBorderColor->mLeft.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
if (parentBorder->GetBorderColor(NS_SIDE_LEFT, borderColor)) {
|
|
|
|
border->SetBorderColor(NS_SIDE_LEFT, borderColor);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderTransparent(NS_SIDE_LEFT);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (SetColor(ourBorderColor->mLeft, unused, aPresContext, borderColor)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->SetBorderColor(NS_SIDE_LEFT, borderColor);
|
1999-04-03 07:15:01 +04:00
|
|
|
}
|
2001-05-03 11:39:57 +04:00
|
|
|
else if (eCSSUnit_Enumerated == ourBorderColor->mLeft.GetUnit()) {
|
2001-05-02 14:31:31 +04:00
|
|
|
switch (ourBorderColor->mLeft.GetIntValue()) {
|
|
|
|
case NS_STYLE_COLOR_TRANSPARENT:
|
|
|
|
border->SetBorderTransparent(NS_SIDE_LEFT);
|
|
|
|
break;
|
|
|
|
case NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR:
|
|
|
|
const nsStyleColor* ourColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
border->SetBorderColor(NS_SIDE_LEFT, ourColor->mColor);
|
|
|
|
break;
|
|
|
|
}
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1999-03-28 08:31:57 +04:00
|
|
|
|
1999-12-22 14:27:10 +03:00
|
|
|
// -moz-border-radius: length, percent, inherit
|
|
|
|
if (nsnull != ourMargin->mBorderRadius) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
nsStyleCoord parentCoord;
|
2001-02-07 12:57:26 +03:00
|
|
|
parentBorder->mBorderRadius.GetLeft(parentCoord);
|
1999-12-22 14:27:10 +03:00
|
|
|
if (SetCoord(ourMargin->mBorderRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorderRadius.SetLeft(coord);
|
1999-12-22 14:27:10 +03:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentBorder->mBorderRadius.GetTop(parentCoord);
|
1999-12-22 14:27:10 +03:00
|
|
|
if (SetCoord(ourMargin->mBorderRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorderRadius.SetTop(coord);
|
1999-12-22 14:27:10 +03:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentBorder->mBorderRadius.GetRight(parentCoord);
|
1999-12-22 14:27:10 +03:00
|
|
|
if (SetCoord(ourMargin->mBorderRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorderRadius.SetRight(coord);
|
1999-12-22 14:27:10 +03:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentBorder->mBorderRadius.GetBottom(parentCoord);
|
1999-12-22 14:27:10 +03:00
|
|
|
if (SetCoord(ourMargin->mBorderRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mBorderRadius.SetBottom(coord);
|
1999-12-22 14:27:10 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
|
2000-01-24 14:19:55 +03:00
|
|
|
// -moz-outline-radius: length, percent, inherit
|
|
|
|
if (nsnull != ourMargin->mOutlineRadius) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
nsStyleCoord parentCoord;
|
2001-02-07 12:57:26 +03:00
|
|
|
parentOutline->mOutlineRadius.GetLeft(parentCoord);
|
2000-01-24 14:19:55 +03:00
|
|
|
if (SetCoord(ourMargin->mOutlineRadius->mLeft, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->mOutlineRadius.SetLeft(coord);
|
2000-01-24 14:19:55 +03:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentOutline->mOutlineRadius.GetTop(parentCoord);
|
2000-01-24 14:19:55 +03:00
|
|
|
if (SetCoord(ourMargin->mOutlineRadius->mTop, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->mOutlineRadius.SetTop(coord);
|
2000-01-24 14:19:55 +03:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentOutline->mOutlineRadius.GetRight(parentCoord);
|
2000-01-24 14:19:55 +03:00
|
|
|
if (SetCoord(ourMargin->mOutlineRadius->mRight, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->mOutlineRadius.SetRight(coord);
|
2000-01-24 14:19:55 +03:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
parentOutline->mOutlineRadius.GetBottom(parentCoord);
|
2000-01-24 14:19:55 +03:00
|
|
|
if (SetCoord(ourMargin->mOutlineRadius->mBottom, coord, parentCoord, SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->mOutlineRadius.SetBottom(coord);
|
2000-01-24 14:19:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// outline-width: length, enum, inherit
|
2001-02-07 12:57:26 +03:00
|
|
|
if (! SetCoord(ourMargin->mOutlineWidth, outline->mOutlineWidth, parentOutline->mOutlineWidth,
|
1999-09-10 09:56:19 +04:00
|
|
|
SETCOORD_LEH, aFont->mFont, aPresContext)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// outline-color: color, string, enum, inherit
|
|
|
|
nscolor outlineColor;
|
|
|
|
nscolor unused = NS_RGB(0,0,0);
|
|
|
|
if (eCSSUnit_Inherit == ourMargin->mOutlineColor.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
if (parentOutline->GetOutlineColor(outlineColor)) {
|
|
|
|
outline->SetOutlineColor(outlineColor);
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->SetOutlineInvert();
|
1999-03-28 08:31:57 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (SetColor(ourMargin->mOutlineColor, unused, aPresContext, outlineColor)) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->SetOutlineColor(outlineColor);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Enumerated == ourMargin->mOutlineColor.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->SetOutlineInvert();
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1999-03-28 08:31:57 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// outline-style: enum, none, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourMargin->mOutlineStyle.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->SetOutlineStyle(ourMargin->mOutlineStyle.GetIntValue());
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourMargin->mOutlineStyle.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->SetOutlineStyle(NS_STYLE_BORDER_STYLE_NONE);
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourMargin->mOutlineStyle.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
outline->SetOutlineStyle(parentOutline->GetOutlineStyle());
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// float-edge: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourMargin->mFloatEdge.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mFloatEdge = ourMargin->mFloatEdge.GetIntValue();
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourMargin->mFloatEdge.GetUnit()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
border->mFloatEdge = parentBorder->mFloatEdge;
|
1998-04-19 02:16:37 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationPositionInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSPosition* ourPosition;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSPositionSID, (nsCSSStruct**)&ourPosition)) {
|
|
|
|
if (nsnull != ourPosition) {
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStylePosition position(aContext);
|
|
|
|
const nsStylePosition* parentPosition = position.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentPosition = (const nsStylePosition*)aParentContext->GetStyleData(eStyleStruct_Position);
|
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// position: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourPosition->mPosition.GetUnit()) {
|
|
|
|
position->mPosition = ourPosition->mPosition.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourPosition->mPosition.GetUnit()) {
|
|
|
|
position->mPosition = parentPosition->mPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
// box offsets: length, percent, auto, inherit
|
|
|
|
if (nsnull != ourPosition->mOffset) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
nsStyleCoord parentCoord;
|
|
|
|
parentPosition->mOffset.GetTop(parentCoord);
|
|
|
|
if (SetCoord(ourPosition->mOffset->mTop, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
|
|
|
|
position->mOffset.SetTop(coord);
|
1998-04-23 03:28:02 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
parentPosition->mOffset.GetRight(parentCoord);
|
|
|
|
if (SetCoord(ourPosition->mOffset->mRight, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
|
|
|
|
position->mOffset.SetRight(coord);
|
1998-05-14 02:40:17 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
parentPosition->mOffset.GetBottom(parentCoord);
|
|
|
|
if (SetCoord(ourPosition->mOffset->mBottom, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
|
|
|
|
position->mOffset.SetBottom(coord);
|
1998-10-08 05:31:38 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
parentPosition->mOffset.GetLeft(parentCoord);
|
|
|
|
if (SetCoord(ourPosition->mOffset->mLeft, coord, parentCoord, SETCOORD_LPAH, aFont->mFont, aPresContext)) {
|
|
|
|
position->mOffset.SetLeft(coord);
|
1998-11-06 03:58:23 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
SetCoord(ourPosition->mWidth, position->mWidth, parentPosition->mWidth,
|
|
|
|
SETCOORD_LPAH, aFont->mFont, aPresContext);
|
|
|
|
SetCoord(ourPosition->mMinWidth, position->mMinWidth, parentPosition->mMinWidth,
|
|
|
|
SETCOORD_LPH, aFont->mFont, aPresContext);
|
|
|
|
if (! SetCoord(ourPosition->mMaxWidth, position->mMaxWidth, parentPosition->mMaxWidth,
|
|
|
|
SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
|
|
|
if (eCSSUnit_None == ourPosition->mMaxWidth.GetUnit()) {
|
|
|
|
position->mMaxWidth.Reset();
|
1998-11-06 03:58:23 +03:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1998-04-24 22:34:31 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
SetCoord(ourPosition->mHeight, position->mHeight, parentPosition->mHeight,
|
|
|
|
SETCOORD_LPAH, aFont->mFont, aPresContext);
|
|
|
|
SetCoord(ourPosition->mMinHeight, position->mMinHeight, parentPosition->mMinHeight,
|
|
|
|
SETCOORD_LPH, aFont->mFont, aPresContext);
|
|
|
|
if (! SetCoord(ourPosition->mMaxHeight, position->mMaxHeight, parentPosition->mMaxHeight,
|
|
|
|
SETCOORD_LPH, aFont->mFont, aPresContext)) {
|
|
|
|
if (eCSSUnit_None == ourPosition->mMaxHeight.GetUnit()) {
|
|
|
|
position->mMaxHeight.Reset();
|
1999-07-24 23:04:42 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// box-sizing: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourPosition->mBoxSizing.GetUnit()) {
|
|
|
|
position->mBoxSizing = ourPosition->mBoxSizing.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourPosition->mBoxSizing.GetUnit()) {
|
|
|
|
position->mBoxSizing = parentPosition->mBoxSizing;
|
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// z-index
|
|
|
|
if (! SetCoord(ourPosition->mZIndex, position->mZIndex, parentPosition->mZIndex,
|
|
|
|
SETCOORD_IA, aFont->mFont, nsnull)) {
|
|
|
|
if (eCSSUnit_Inherit == ourPosition->mZIndex.GetUnit()) {
|
|
|
|
// handle inherit, because it's ok to inherit 'auto' here
|
|
|
|
position->mZIndex = parentPosition->mZIndex;
|
|
|
|
}
|
1998-04-22 19:46:53 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-22 19:46:53 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationListInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* /*aFont*/, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSList* ourList;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSListSID, (nsCSSStruct**)&ourList)) {
|
|
|
|
if (nsnull != ourList) {
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleList list(aContext);
|
|
|
|
const nsStyleList* parentList = list.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentList = (const nsStyleList*)aParentContext->GetStyleData(eStyleStruct_List);
|
|
|
|
}
|
1998-10-27 02:22:19 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// list-style-type: enum, none, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourList->mType.GetUnit()) {
|
|
|
|
list->mListStyleType = ourList->mType.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourList->mType.GetUnit()) {
|
|
|
|
list->mListStyleType = NS_STYLE_LIST_STYLE_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourList->mType.GetUnit()) {
|
|
|
|
list->mListStyleType = parentList->mListStyleType;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// list-style-image: url, none, inherit
|
|
|
|
if (eCSSUnit_URL == ourList->mImage.GetUnit()) {
|
|
|
|
ourList->mImage.GetStringValue(list->mListStyleImage);
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourList->mImage.GetUnit()) {
|
|
|
|
list->mListStyleImage.Truncate();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourList->mImage.GetUnit()) {
|
|
|
|
list->mListStyleImage = parentList->mListStyleImage;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// list-style-position: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourList->mPosition.GetUnit()) {
|
|
|
|
list->mListStylePosition = ourList->mPosition.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourList->mPosition.GetUnit()) {
|
|
|
|
list->mListStylePosition = parentList->mListStylePosition;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationTableInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSTable* ourTable;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSTableSID, (nsCSSStruct**)&ourTable)) {
|
|
|
|
if (nsnull != ourTable) {
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleTable table(aContext);
|
|
|
|
const nsStyleTable* parentTable = table.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentTable = (const nsStyleTable*)aParentContext->GetStyleData(eStyleStruct_Table);
|
|
|
|
}
|
|
|
|
nsStyleCoord coord;
|
1998-11-06 03:58:23 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// border-collapse: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourTable->mBorderCollapse.GetUnit()) {
|
|
|
|
table->mBorderCollapse = ourTable->mBorderCollapse.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourTable->mBorderCollapse.GetUnit()) {
|
|
|
|
table->mBorderCollapse = parentTable->mBorderCollapse;
|
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// border-spacing-x: length, inherit
|
|
|
|
if (SetCoord(ourTable->mBorderSpacingX, coord, coord, SETCOORD_LENGTH, aFont->mFont, aPresContext)) {
|
|
|
|
table->mBorderSpacingX = coord.GetCoordValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourTable->mBorderSpacingX.GetUnit()) {
|
|
|
|
table->mBorderSpacingX = parentTable->mBorderSpacingX;
|
|
|
|
}
|
|
|
|
// border-spacing-y: length, inherit
|
|
|
|
if (SetCoord(ourTable->mBorderSpacingY, coord, coord, SETCOORD_LENGTH, aFont->mFont, aPresContext)) {
|
|
|
|
table->mBorderSpacingY = coord.GetCoordValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourTable->mBorderSpacingY.GetUnit()) {
|
|
|
|
table->mBorderSpacingY = parentTable->mBorderSpacingY;
|
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// caption-side: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourTable->mCaptionSide.GetUnit()) {
|
|
|
|
table->mCaptionSide = ourTable->mCaptionSide.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourTable->mCaptionSide.GetUnit()) {
|
|
|
|
table->mCaptionSide = parentTable->mCaptionSide;
|
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// empty-cells: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourTable->mEmptyCells.GetUnit()) {
|
|
|
|
table->mEmptyCells = ourTable->mEmptyCells.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourTable->mEmptyCells.GetUnit()) {
|
|
|
|
table->mEmptyCells = parentTable->mEmptyCells;
|
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// table-layout: auto, enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourTable->mLayout.GetUnit()) {
|
|
|
|
table->mLayoutStrategy = ourTable->mLayout.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Auto == ourTable->mLayout.GetUnit()) {
|
|
|
|
table->mLayoutStrategy = NS_STYLE_TABLE_LAYOUT_AUTO;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourTable->mLayout.GetUnit()) {
|
|
|
|
table->mLayoutStrategy = parentTable->mLayoutStrategy;
|
1998-11-06 03:58:23 +03:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1998-11-06 03:58:23 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationContentInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSContent* ourContent;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSContentSID, (nsCSSStruct**)&ourContent)) {
|
|
|
|
if (ourContent) {
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleContent content(aContext);
|
|
|
|
const nsStyleContent* parentContent = content.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentContent = (const nsStyleContent*)aParentContext->GetStyleData(eStyleStruct_Content);
|
|
|
|
}
|
1999-04-02 22:49:40 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
PRUint32 count;
|
|
|
|
nsAutoString buffer;
|
|
|
|
|
|
|
|
// content: [string, url, counter, attr, enum]+, inherit
|
|
|
|
nsCSSValueList* contentValue = ourContent->mContent;
|
|
|
|
if (contentValue) {
|
|
|
|
if (eCSSUnit_Inherit == contentValue->mValue.GetUnit()) {
|
|
|
|
count = parentContent->ContentCount();
|
|
|
|
if (NS_SUCCEEDED(content->AllocateContents(count))) {
|
|
|
|
nsStyleContentType type;
|
|
|
|
while (0 < count--) {
|
|
|
|
parentContent->GetContentAt(count, type, buffer);
|
|
|
|
content->SetContentAt(count, type, buffer);
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
count = 0;
|
|
|
|
while (contentValue) {
|
|
|
|
count++;
|
|
|
|
contentValue = contentValue->mNext;
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(content->AllocateContents(count))) {
|
|
|
|
const nsAutoString nullStr;
|
1999-04-02 22:49:40 +04:00
|
|
|
count = 0;
|
1999-09-10 09:56:19 +04:00
|
|
|
contentValue = ourContent->mContent;
|
1999-04-02 22:49:40 +04:00
|
|
|
while (contentValue) {
|
1999-09-10 09:56:19 +04:00
|
|
|
const nsCSSValue& value = contentValue->mValue;
|
|
|
|
nsCSSUnit unit = value.GetUnit();
|
|
|
|
nsStyleContentType type;
|
|
|
|
switch (unit) {
|
|
|
|
case eCSSUnit_String: type = eStyleContentType_String; break;
|
|
|
|
case eCSSUnit_URL: type = eStyleContentType_URL; break;
|
|
|
|
case eCSSUnit_Attr: type = eStyleContentType_Attr; break;
|
|
|
|
case eCSSUnit_Counter: type = eStyleContentType_Counter; break;
|
|
|
|
case eCSSUnit_Counters: type = eStyleContentType_Counters; break;
|
|
|
|
case eCSSUnit_Enumerated:
|
|
|
|
switch (value.GetIntValue()) {
|
|
|
|
case NS_STYLE_CONTENT_OPEN_QUOTE:
|
|
|
|
type = eStyleContentType_OpenQuote; break;
|
|
|
|
case NS_STYLE_CONTENT_CLOSE_QUOTE:
|
|
|
|
type = eStyleContentType_CloseQuote; break;
|
|
|
|
case NS_STYLE_CONTENT_NO_OPEN_QUOTE:
|
|
|
|
type = eStyleContentType_NoOpenQuote; break;
|
|
|
|
case NS_STYLE_CONTENT_NO_CLOSE_QUOTE:
|
|
|
|
type = eStyleContentType_NoCloseQuote; break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("bad content value");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("bad content type");
|
|
|
|
}
|
|
|
|
if (type < eStyleContentType_OpenQuote) {
|
|
|
|
value.GetStringValue(buffer);
|
|
|
|
Unquote(buffer);
|
|
|
|
content->SetContentAt(count++, type, buffer);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
content->SetContentAt(count++, type, nullStr);
|
|
|
|
}
|
1999-04-02 22:49:40 +04:00
|
|
|
contentValue = contentValue->mNext;
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1999-04-02 22:49:40 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// counter-increment: [string [int]]+, none, inherit
|
|
|
|
nsCSSCounterData* ourIncrement = ourContent->mCounterIncrement;
|
|
|
|
if (ourIncrement) {
|
|
|
|
PRInt32 increment;
|
|
|
|
if (eCSSUnit_Inherit == ourIncrement->mCounter.GetUnit()) {
|
|
|
|
count = parentContent->CounterIncrementCount();
|
|
|
|
if (NS_SUCCEEDED(content->AllocateCounterIncrements(count))) {
|
|
|
|
while (0 < count--) {
|
|
|
|
parentContent->GetCounterIncrementAt(count, buffer, increment);
|
|
|
|
content->SetCounterIncrementAt(count, buffer, increment);
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourIncrement->mCounter.GetUnit()) {
|
|
|
|
content->AllocateCounterIncrements(0);
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_String == ourIncrement->mCounter.GetUnit()) {
|
|
|
|
count = 0;
|
|
|
|
while (ourIncrement) {
|
|
|
|
count++;
|
|
|
|
ourIncrement = ourIncrement->mNext;
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
if (NS_SUCCEEDED(content->AllocateCounterIncrements(count))) {
|
1999-04-02 22:49:40 +04:00
|
|
|
count = 0;
|
1999-09-10 09:56:19 +04:00
|
|
|
ourIncrement = ourContent->mCounterIncrement;
|
1999-04-02 22:49:40 +04:00
|
|
|
while (ourIncrement) {
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Integer == ourIncrement->mValue.GetUnit()) {
|
|
|
|
increment = ourIncrement->mValue.GetIntValue();
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else {
|
|
|
|
increment = 1;
|
|
|
|
}
|
|
|
|
ourIncrement->mCounter.GetStringValue(buffer);
|
|
|
|
content->SetCounterIncrementAt(count++, buffer, increment);
|
|
|
|
ourIncrement = ourIncrement->mNext;
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1999-04-02 22:49:40 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// counter-reset: [string [int]]+, none, inherit
|
|
|
|
nsCSSCounterData* ourReset = ourContent->mCounterReset;
|
|
|
|
if (ourReset) {
|
|
|
|
PRInt32 reset;
|
|
|
|
if (eCSSUnit_Inherit == ourReset->mCounter.GetUnit()) {
|
|
|
|
count = parentContent->CounterResetCount();
|
|
|
|
if (NS_SUCCEEDED(content->AllocateCounterResets(count))) {
|
|
|
|
while (0 < count--) {
|
|
|
|
parentContent->GetCounterResetAt(count, buffer, reset);
|
|
|
|
content->SetCounterResetAt(count, buffer, reset);
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourReset->mCounter.GetUnit()) {
|
|
|
|
content->AllocateCounterResets(0);
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_String == ourReset->mCounter.GetUnit()) {
|
|
|
|
count = 0;
|
|
|
|
while (ourReset) {
|
|
|
|
count++;
|
|
|
|
ourReset = ourReset->mNext;
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
if (NS_SUCCEEDED(content->AllocateCounterResets(count))) {
|
1999-04-02 22:49:40 +04:00
|
|
|
count = 0;
|
1999-09-10 09:56:19 +04:00
|
|
|
ourReset = ourContent->mCounterReset;
|
1999-04-02 22:49:40 +04:00
|
|
|
while (ourReset) {
|
1999-09-10 09:56:19 +04:00
|
|
|
if (eCSSUnit_Integer == ourReset->mValue.GetUnit()) {
|
|
|
|
reset = ourReset->mValue.GetIntValue();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
reset = 0;
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
ourReset->mCounter.GetStringValue(buffer);
|
|
|
|
content->SetCounterResetAt(count++, buffer, reset);
|
|
|
|
ourReset = ourReset->mNext;
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1999-04-02 22:49:40 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// marker-offset: length, auto, inherit
|
|
|
|
if (! SetCoord(ourContent->mMarkerOffset, content->mMarkerOffset, parentContent->mMarkerOffset,
|
|
|
|
SETCOORD_LH | SETCOORD_AUTO, aFont->mFont, aPresContext)) {
|
|
|
|
}
|
1999-04-02 22:49:40 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// quotes: [string string]+, none, inherit
|
|
|
|
nsCSSQuotes* ourQuotes = ourContent->mQuotes;
|
|
|
|
if (ourQuotes) {
|
|
|
|
nsAutoString closeBuffer;
|
|
|
|
if (eCSSUnit_Inherit == ourQuotes->mOpen.GetUnit()) {
|
|
|
|
count = parentContent->QuotesCount();
|
|
|
|
if (NS_SUCCEEDED(content->AllocateQuotes(count))) {
|
|
|
|
while (0 < count--) {
|
|
|
|
parentContent->GetQuotesAt(count, buffer, closeBuffer);
|
|
|
|
content->SetQuotesAt(count, buffer, closeBuffer);
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourQuotes->mOpen.GetUnit()) {
|
|
|
|
content->AllocateQuotes(0);
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_String == ourQuotes->mOpen.GetUnit()) {
|
|
|
|
count = 0;
|
|
|
|
while (ourQuotes) {
|
|
|
|
count++;
|
|
|
|
ourQuotes = ourQuotes->mNext;
|
1999-04-02 22:49:40 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
if (NS_SUCCEEDED(content->AllocateQuotes(count))) {
|
1999-04-02 22:49:40 +04:00
|
|
|
count = 0;
|
1999-09-10 09:56:19 +04:00
|
|
|
ourQuotes = ourContent->mQuotes;
|
1999-04-02 22:49:40 +04:00
|
|
|
while (ourQuotes) {
|
1999-09-10 09:56:19 +04:00
|
|
|
ourQuotes->mOpen.GetStringValue(buffer);
|
|
|
|
ourQuotes->mClose.GetStringValue(closeBuffer);
|
|
|
|
Unquote(buffer);
|
|
|
|
Unquote(closeBuffer);
|
|
|
|
content->SetQuotesAt(count++, buffer, closeBuffer);
|
1999-04-02 22:49:40 +04:00
|
|
|
ourQuotes = ourQuotes->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1999-04-02 22:49:40 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
static void
|
|
|
|
MapDeclarationUIInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
1999-09-10 09:56:19 +04:00
|
|
|
nsStyleFont* /*aFont*/, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSUserInterface* ourUI;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSUserInterfaceSID, (nsCSSStruct**)&ourUI)) {
|
|
|
|
if (nsnull != ourUI) {
|
|
|
|
// Get our user interface style and our parent's user interface style
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleUserInterface ui(aContext);
|
|
|
|
const nsStyleUserInterface* parentUI = ui.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentUI = (const nsStyleUserInterface*)aParentContext->GetStyleData(eStyleStruct_UserInterface);
|
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// user-input: auto, none, enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourUI->mUserInput.GetUnit()) {
|
|
|
|
ui->mUserInput = ourUI->mUserInput.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Auto == ourUI->mUserInput.GetUnit()) {
|
|
|
|
ui->mUserInput = NS_STYLE_USER_INPUT_AUTO;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourUI->mUserInput.GetUnit()) {
|
|
|
|
ui->mUserInput = NS_STYLE_USER_INPUT_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourUI->mUserInput.GetUnit()) {
|
|
|
|
ui->mUserInput = parentUI->mUserInput;
|
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// user-modify: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourUI->mUserModify.GetUnit()) {
|
|
|
|
ui->mUserModify = ourUI->mUserModify.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourUI->mUserModify.GetUnit()) {
|
|
|
|
ui->mUserModify = parentUI->mUserModify;
|
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// user-select: none, enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourUI->mUserSelect.GetUnit()) {
|
|
|
|
ui->mUserSelect = ourUI->mUserSelect.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourUI->mUserSelect.GetUnit()) {
|
|
|
|
ui->mUserSelect = NS_STYLE_USER_SELECT_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourUI->mUserSelect.GetUnit()) {
|
|
|
|
ui->mUserSelect = parentUI->mUserSelect;
|
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
2000-01-11 06:40:41 +03:00
|
|
|
// behavior: url, none
|
|
|
|
if (eCSSUnit_URL == ourUI->mBehavior.GetUnit()) {
|
|
|
|
ourUI->mBehavior.GetStringValue(ui->mBehavior);
|
|
|
|
}
|
2000-02-01 03:20:26 +03:00
|
|
|
else if (eCSSUnit_None == ourUI->mBehavior.GetUnit()) {
|
|
|
|
ui->mBehavior.Truncate();
|
|
|
|
}
|
2000-04-04 10:29:20 +04:00
|
|
|
else if (eCSSUnit_Inherit == ourUI->mBehavior.GetUnit()) {
|
|
|
|
ui->mBehavior = parentUI->mBehavior;
|
|
|
|
}
|
2000-01-11 06:40:41 +03:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// key-equivalent: none, enum XXX, inherit
|
|
|
|
nsCSSValueList* keyEquiv = ourUI->mKeyEquivalent;
|
|
|
|
if (keyEquiv) {
|
|
|
|
// XXX need to deal with multiple values
|
|
|
|
if (eCSSUnit_Enumerated == keyEquiv->mValue.GetUnit()) {
|
|
|
|
ui->mKeyEquivalent = PRUnichar(0); // XXX To be implemented
|
1999-07-24 23:04:42 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_None == keyEquiv->mValue.GetUnit()) {
|
|
|
|
ui->mKeyEquivalent = PRUnichar(0);
|
1999-07-24 23:04:42 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
else if (eCSSUnit_Inherit == keyEquiv->mValue.GetUnit()) {
|
|
|
|
ui->mKeyEquivalent = parentUI->mKeyEquivalent;
|
1999-07-24 23:04:42 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// user-focus: none, normal, enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourUI->mUserFocus.GetUnit()) {
|
|
|
|
ui->mUserFocus = ourUI->mUserFocus.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourUI->mUserFocus.GetUnit()) {
|
|
|
|
ui->mUserFocus = NS_STYLE_USER_FOCUS_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Normal == ourUI->mUserFocus.GetUnit()) {
|
|
|
|
ui->mUserFocus = NS_STYLE_USER_FOCUS_NORMAL;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourUI->mUserFocus.GetUnit()) {
|
|
|
|
ui->mUserFocus = parentUI->mUserFocus;
|
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
// resizer: auto, none, enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourUI->mResizer.GetUnit()) {
|
|
|
|
ui->mResizer = ourUI->mResizer.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Auto == ourUI->mResizer.GetUnit()) {
|
|
|
|
ui->mResizer = NS_STYLE_RESIZER_AUTO;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_None == ourUI->mResizer.GetUnit()) {
|
|
|
|
ui->mResizer = NS_STYLE_RESIZER_NONE;
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourUI->mResizer.GetUnit()) {
|
|
|
|
ui->mResizer = parentUI->mResizer;
|
1999-07-24 23:04:42 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
|
1999-07-24 23:04:42 +04:00
|
|
|
}
|
1999-09-10 09:56:19 +04:00
|
|
|
}
|
|
|
|
}
|
1999-07-24 23:04:42 +04:00
|
|
|
|
1999-12-22 08:00:47 +03:00
|
|
|
static void
|
|
|
|
MapDeclarationPrintInto(nsICSSDeclaration* aDeclaration,
|
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
|
|
|
{
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStylePrint print(aContext);
|
|
|
|
const nsStylePrint* parentPrint = print.get();
|
1999-12-22 08:00:47 +03:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentPrint = (const nsStylePrint*)aParentContext->GetStyleData(eStyleStruct_Print);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSBreaks* ourBreaks;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSBreaksSID, (nsCSSStruct**)&ourBreaks)) {
|
|
|
|
if (nsnull != ourBreaks) {
|
|
|
|
|
|
|
|
// page-break-before: enum, auto, inherit
|
|
|
|
switch (ourBreaks->mPageBreakBefore.GetUnit()) {
|
|
|
|
case eCSSUnit_Enumerated: print->mPageBreakBefore = ourBreaks->mPageBreakBefore.GetIntValue(); break;
|
|
|
|
case eCSSUnit_Auto: print->mPageBreakBefore = NS_STYLE_PAGE_BREAK_AUTO; break;
|
|
|
|
case eCSSUnit_Inherit: print->mPageBreakBefore = parentPrint->mPageBreakBefore; break;
|
1999-12-23 21:35:35 +03:00
|
|
|
default: break;
|
1999-12-22 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// page-break-after: enum, auto, inherit
|
|
|
|
switch (ourBreaks->mPageBreakAfter.GetUnit()) {
|
|
|
|
case eCSSUnit_Enumerated: print->mPageBreakAfter = ourBreaks->mPageBreakAfter.GetIntValue(); break;
|
|
|
|
case eCSSUnit_Auto: print->mPageBreakAfter = NS_STYLE_PAGE_BREAK_AUTO; break;
|
|
|
|
case eCSSUnit_Inherit: print->mPageBreakAfter = parentPrint->mPageBreakAfter; break;
|
1999-12-23 21:35:35 +03:00
|
|
|
default: break;
|
1999-12-22 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// page-break-inside: enum, auto, inherit
|
|
|
|
switch (ourBreaks->mPageBreakInside.GetUnit()) {
|
|
|
|
case eCSSUnit_Enumerated: print->mPageBreakInside = ourBreaks->mPageBreakInside.GetIntValue(); break;
|
|
|
|
case eCSSUnit_Auto: print->mPageBreakInside = NS_STYLE_PAGE_BREAK_AUTO; break;
|
|
|
|
case eCSSUnit_Inherit: print->mPageBreakInside = parentPrint->mPageBreakInside; break;
|
1999-12-23 21:35:35 +03:00
|
|
|
default: break;
|
1999-12-22 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// page: string, auto
|
|
|
|
switch (ourBreaks->mPage.GetUnit()) {
|
|
|
|
case eCSSUnit_String: ourBreaks->mPage.GetStringValue(print->mPage); break;
|
|
|
|
case eCSSUnit_Auto: print->mPage.SetLength(0); break;
|
1999-12-23 21:35:35 +03:00
|
|
|
default: break;
|
1999-12-22 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// widows: int, inherit
|
|
|
|
switch (ourBreaks->mWidows.GetUnit()) {
|
|
|
|
case eCSSUnit_Integer: print->mWidows = ourBreaks->mWidows.GetIntValue(); break;
|
|
|
|
case eCSSUnit_Inherit: print->mWidows = parentPrint->mWidows; break;
|
1999-12-23 21:35:35 +03:00
|
|
|
default: break;
|
1999-12-22 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// orphans: int, inherit
|
|
|
|
switch (ourBreaks->mOrphans.GetUnit()) {
|
|
|
|
case eCSSUnit_Integer: print->mOrphans = ourBreaks->mOrphans.GetIntValue(); break;
|
|
|
|
case eCSSUnit_Inherit: print->mOrphans = parentPrint->mOrphans; break;
|
1999-12-23 21:35:35 +03:00
|
|
|
default: break;
|
1999-12-22 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSPage* ourPage;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSPageSID, (nsCSSStruct**)&ourPage)) {
|
|
|
|
if (nsnull != ourPage) {
|
|
|
|
|
|
|
|
// marks: enum, none
|
|
|
|
switch (ourPage->mMarks.GetUnit()) {
|
|
|
|
case eCSSUnit_Enumerated: print->mMarks = ourPage->mMarks.GetIntValue(); break;
|
|
|
|
case eCSSUnit_None: print->mMarks = NS_STYLE_PAGE_MARKS_NONE; break;
|
1999-12-23 21:35:35 +03:00
|
|
|
default: break;
|
1999-12-22 08:00:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// size-width: length, enum, auto
|
|
|
|
SetCoord(ourPage->mSizeWidth, print->mSizeWidth, parentPrint->mSizeWidth,
|
|
|
|
SETCOORD_LAE, aFont->mFont, aPresContext);
|
|
|
|
|
|
|
|
// size-height: length, enum, auto
|
|
|
|
SetCoord(ourPage->mSizeHeight, print->mSizeHeight, parentPrint->mSizeHeight,
|
|
|
|
SETCOORD_LAE, aFont->mFont, aPresContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-06 05:30:30 +03:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
static void
|
|
|
|
MapDeclarationXULInto(nsICSSDeclaration* aDeclaration,
|
|
|
|
nsIMutableStyleContext* aContext, nsIStyleContext* aParentContext,
|
|
|
|
nsStyleFont* aFont, nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsCSSXUL* ourXUL;
|
|
|
|
if (NS_OK == aDeclaration->GetData(kCSSXULSID, (nsCSSStruct**)&ourXUL)) {
|
|
|
|
if (nsnull != ourXUL) {
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleXUL xul(aContext);
|
|
|
|
const nsStyleXUL* parentXUL = xul.get();
|
2001-03-06 05:30:30 +03:00
|
|
|
if (nsnull != aParentContext) {
|
|
|
|
parentXUL = (const nsStyleXUL*)aParentContext->GetStyleData(eStyleStruct_XUL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// box-orient: enum, inherit
|
|
|
|
if (eCSSUnit_Enumerated == ourXUL->mBoxOrient.GetUnit()) {
|
|
|
|
xul->mBoxOrient = ourXUL->mBoxOrient.GetIntValue();
|
|
|
|
}
|
|
|
|
else if (eCSSUnit_Inherit == ourXUL->mBoxOrient.GetUnit()) {
|
|
|
|
xul->mBoxOrient = parentXUL->mBoxOrient;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_XUL
|
|
|
|
|
1999-09-10 09:56:19 +04:00
|
|
|
void MapDeclarationInto(nsICSSDeclaration* aDeclaration,
|
1999-10-16 08:05:59 +04:00
|
|
|
nsIMutableStyleContext* aContext, nsIPresContext* aPresContext)
|
1999-09-10 09:56:19 +04:00
|
|
|
{
|
|
|
|
if (nsnull != aDeclaration) {
|
|
|
|
nsIStyleContext* parentContext = aContext->GetParent();
|
2001-05-03 17:20:48 +04:00
|
|
|
nsMutableStyleFont mutableFont(aContext);
|
|
|
|
nsStyleFont* font = mutableFont.get();
|
1999-09-10 09:56:19 +04:00
|
|
|
|
|
|
|
MapDeclarationTextInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
MapDeclarationDisplayInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
MapDeclarationColorInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
MapDeclarationMarginInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
MapDeclarationPositionInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
MapDeclarationListInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
MapDeclarationTableInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
MapDeclarationContentInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
MapDeclarationUIInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
1999-12-22 08:00:47 +03:00
|
|
|
MapDeclarationPrintInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
2001-03-06 05:30:30 +03:00
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
MapDeclarationXULInto(aDeclaration, aContext, parentContext, font, aPresContext);
|
|
|
|
#endif
|
2000-06-02 03:31:00 +04:00
|
|
|
|
1998-10-27 02:22:19 +03:00
|
|
|
NS_IF_RELEASE(parentContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-03-28 12:02:20 +04:00
|
|
|
buffer.AppendWithConversion(" weight: ");
|
2000-04-16 00:15:37 +04:00
|
|
|
buffer.AppendInt(mWeight, 10);
|
|
|
|
buffer.AppendWithConversion(" ");
|
1998-04-14 00:24:54 +04:00
|
|
|
fputs(buffer, out);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_HTML nsresult
|
|
|
|
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
|
|
|
}
|