2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
2001-06-01 02:19:43 +04:00
|
|
|
* Original Author: David W. Hyatt (hyatt@netscape.com)
|
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
#ifndef nsRuleNode_h___
|
|
|
|
#define nsRuleNode_h___
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIStyleRule.h"
|
2001-10-24 04:01:09 +04:00
|
|
|
#include "nsIFrame.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "nsFixedSizeAllocator.h"
|
|
|
|
#include "nsIPresContext.h"
|
2002-01-16 01:43:37 +03:00
|
|
|
#include "nsCSSDeclaration.h"
|
2001-12-11 07:12:34 +03:00
|
|
|
#include "nsILanguageAtomService.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
class nsIStyleContext;
|
|
|
|
struct nsRuleList;
|
2002-03-19 04:29:20 +03:00
|
|
|
struct PLDHashTable;
|
2001-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData);
|
|
|
|
|
|
|
|
struct nsInheritedStyleData
|
|
|
|
{
|
|
|
|
nsStyleVisibility* mVisibilityData;
|
|
|
|
nsStyleFont* mFontData;
|
|
|
|
nsStyleList* mListData;
|
|
|
|
nsStyleTableBorder* mTableData;
|
|
|
|
nsStyleColor* mColorData;
|
|
|
|
nsStyleQuotes* mQuotesData;
|
|
|
|
nsStyleText* mTextData;
|
|
|
|
nsStyleUserInterface* mUIData;
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
nsStyleSVG* mSVGData;
|
|
|
|
#endif
|
2001-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
|
|
|
void* result = nsnull;
|
|
|
|
aContext->AllocateFromShell(sz, &result);
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ClearInheritedData(PRUint32 aBits) {
|
|
|
|
if (mVisibilityData && (aBits & NS_STYLE_INHERIT_VISIBILITY))
|
|
|
|
mVisibilityData = nsnull;
|
|
|
|
if (mFontData && (aBits & NS_STYLE_INHERIT_FONT))
|
|
|
|
mFontData = nsnull;
|
|
|
|
if (mListData && (aBits & NS_STYLE_INHERIT_LIST))
|
|
|
|
mListData = nsnull;
|
|
|
|
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE_BORDER))
|
|
|
|
mTableData = nsnull;
|
|
|
|
if (mColorData && (aBits & NS_STYLE_INHERIT_COLOR))
|
|
|
|
mColorData = nsnull;
|
|
|
|
if (mQuotesData && (aBits & NS_STYLE_INHERIT_QUOTES))
|
|
|
|
mQuotesData = nsnull;
|
|
|
|
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT))
|
|
|
|
mTextData = nsnull;
|
|
|
|
if (mUIData && (aBits & NS_STYLE_INHERIT_UI))
|
|
|
|
mUIData = nsnull;
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
if (mSVGData && (aBits & NS_STYLE_INHERIT_SVG))
|
|
|
|
mSVGData = nsnull;
|
|
|
|
#endif
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
|
|
|
|
if (mVisibilityData && !(aBits & NS_STYLE_INHERIT_VISIBILITY))
|
|
|
|
mVisibilityData->Destroy(aContext);
|
|
|
|
if (mFontData && !(aBits & NS_STYLE_INHERIT_FONT))
|
|
|
|
mFontData->Destroy(aContext);
|
|
|
|
if (mListData && !(aBits & NS_STYLE_INHERIT_LIST))
|
|
|
|
mListData->Destroy(aContext);
|
|
|
|
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE_BORDER))
|
|
|
|
mTableData->Destroy(aContext);
|
|
|
|
if (mColorData && !(aBits & NS_STYLE_INHERIT_COLOR))
|
|
|
|
mColorData->Destroy(aContext);
|
|
|
|
if (mQuotesData && !(aBits & NS_STYLE_INHERIT_QUOTES))
|
|
|
|
mQuotesData->Destroy(aContext);
|
|
|
|
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT))
|
|
|
|
mTextData->Destroy(aContext);
|
|
|
|
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI))
|
|
|
|
mUIData->Destroy(aContext);
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
if (mSVGData && !(aBits & NS_STYLE_INHERIT_SVG))
|
|
|
|
mSVGData->Destroy(aContext);
|
|
|
|
#endif
|
2001-10-24 04:01:09 +04:00
|
|
|
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
|
|
|
|
};
|
|
|
|
|
|
|
|
nsInheritedStyleData()
|
|
|
|
:mVisibilityData(nsnull), mFontData(nsnull), mListData(nsnull),
|
|
|
|
mTableData(nsnull), mColorData(nsnull), mQuotesData(nsnull), mTextData(nsnull), mUIData(nsnull)
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
, mSVGData(nsnull)
|
|
|
|
#endif
|
2001-10-24 04:01:09 +04:00
|
|
|
{};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nsResetStyleData
|
|
|
|
{
|
|
|
|
nsResetStyleData()
|
|
|
|
:mDisplayData(nsnull), mMarginData(nsnull), mBorderData(nsnull), mPaddingData(nsnull),
|
|
|
|
mOutlineData(nsnull), mPositionData(nsnull), mTableData(nsnull), mBackgroundData(nsnull),
|
|
|
|
mContentData(nsnull), mTextData(nsnull), mUIData(nsnull)
|
|
|
|
{
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
mXULData = nsnull;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
void* operator new(size_t sz, nsIPresContext* aContext) {
|
|
|
|
void* result = nsnull;
|
|
|
|
aContext->AllocateFromShell(sz, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearInheritedData(PRUint32 aBits) {
|
|
|
|
if (mDisplayData && (aBits & NS_STYLE_INHERIT_DISPLAY))
|
|
|
|
mDisplayData = nsnull;
|
|
|
|
if (mMarginData && (aBits & NS_STYLE_INHERIT_MARGIN))
|
|
|
|
mMarginData = nsnull;
|
|
|
|
if (mBorderData && (aBits & NS_STYLE_INHERIT_BORDER))
|
|
|
|
mBorderData = nsnull;
|
|
|
|
if (mPaddingData && (aBits & NS_STYLE_INHERIT_PADDING))
|
|
|
|
mPaddingData = nsnull;
|
|
|
|
if (mOutlineData && (aBits & NS_STYLE_INHERIT_OUTLINE))
|
|
|
|
mOutlineData = nsnull;
|
|
|
|
if (mPositionData && (aBits & NS_STYLE_INHERIT_POSITION))
|
|
|
|
mPositionData = nsnull;
|
|
|
|
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE))
|
|
|
|
mTableData = nsnull;
|
|
|
|
if (mBackgroundData && (aBits & NS_STYLE_INHERIT_BACKGROUND))
|
|
|
|
mBackgroundData = nsnull;
|
|
|
|
if (mContentData && (aBits & NS_STYLE_INHERIT_CONTENT))
|
|
|
|
mContentData = nsnull;
|
|
|
|
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT_RESET))
|
|
|
|
mTextData = nsnull;
|
|
|
|
if (mUIData && (aBits & NS_STYLE_INHERIT_UI_RESET))
|
|
|
|
mUIData = nsnull;
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
if (mXULData && (aBits & NS_STYLE_INHERIT_XUL))
|
|
|
|
mXULData = nsnull;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
|
|
|
|
if (mDisplayData && !(aBits & NS_STYLE_INHERIT_DISPLAY))
|
|
|
|
mDisplayData->Destroy(aContext);
|
|
|
|
if (mMarginData && !(aBits & NS_STYLE_INHERIT_MARGIN))
|
|
|
|
mMarginData->Destroy(aContext);
|
|
|
|
if (mBorderData && !(aBits & NS_STYLE_INHERIT_BORDER))
|
|
|
|
mBorderData->Destroy(aContext);
|
|
|
|
if (mPaddingData && !(aBits & NS_STYLE_INHERIT_PADDING))
|
|
|
|
mPaddingData->Destroy(aContext);
|
|
|
|
if (mOutlineData && !(aBits & NS_STYLE_INHERIT_OUTLINE))
|
|
|
|
mOutlineData->Destroy(aContext);
|
|
|
|
if (mPositionData && !(aBits & NS_STYLE_INHERIT_POSITION))
|
|
|
|
mPositionData->Destroy(aContext);
|
|
|
|
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE))
|
|
|
|
mTableData->Destroy(aContext);
|
|
|
|
if (mBackgroundData && !(aBits & NS_STYLE_INHERIT_BACKGROUND))
|
|
|
|
mBackgroundData->Destroy(aContext);
|
|
|
|
if (mContentData && !(aBits & NS_STYLE_INHERIT_CONTENT))
|
|
|
|
mContentData->Destroy(aContext);
|
|
|
|
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT_RESET))
|
|
|
|
mTextData->Destroy(aContext);
|
|
|
|
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI_RESET))
|
|
|
|
mUIData->Destroy(aContext);
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
if (mXULData && !(aBits & NS_STYLE_INHERIT_XUL))
|
|
|
|
mXULData->Destroy(aContext);
|
|
|
|
#endif
|
|
|
|
aContext->FreeToShell(sizeof(nsResetStyleData), this);
|
|
|
|
};
|
|
|
|
|
|
|
|
nsStyleDisplay* mDisplayData;
|
|
|
|
nsStyleMargin* mMarginData;
|
|
|
|
nsStyleBorder* mBorderData;
|
|
|
|
nsStylePadding* mPaddingData;
|
|
|
|
nsStyleOutline* mOutlineData;
|
|
|
|
nsStylePosition* mPositionData;
|
|
|
|
nsStyleTable* mTableData;
|
|
|
|
nsStyleBackground* mBackgroundData;
|
|
|
|
nsStyleContent* mContentData;
|
|
|
|
nsStyleTextReset* mTextData;
|
|
|
|
nsStyleUIReset* mUIData;
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
nsStyleXUL* mXULData;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nsCachedStyleData
|
|
|
|
{
|
|
|
|
struct StyleStructInfo {
|
|
|
|
ptrdiff_t mCachedStyleDataOffset;
|
|
|
|
ptrdiff_t mInheritResetOffset;
|
|
|
|
PRBool mIsReset;
|
|
|
|
};
|
|
|
|
|
|
|
|
static StyleStructInfo gInfo[];
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
nsInheritedStyleData* mInheritedData;
|
|
|
|
nsResetStyleData* mResetData;
|
|
|
|
|
|
|
|
static PRBool IsReset(const nsStyleStructID& aSID) {
|
|
|
|
return gInfo[aSID].mIsReset;
|
|
|
|
};
|
|
|
|
|
|
|
|
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
|
|
|
|
return 1 << (aSID - 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
nsStyleStruct* GetStyleData(const nsStyleStructID& aSID) {
|
|
|
|
const StyleStructInfo& info = gInfo[aSID];
|
|
|
|
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, this) + info.mCachedStyleDataOffset;
|
|
|
|
char* resetOrInherit = NS_REINTERPRET_CAST(char*, *NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
|
|
|
|
nsStyleStruct* data = nsnull;
|
|
|
|
if (resetOrInherit) {
|
|
|
|
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
|
|
|
|
data = *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ClearInheritedData(PRUint32 aBits) {
|
|
|
|
if (mResetData)
|
|
|
|
mResetData->ClearInheritedData(aBits);
|
|
|
|
if (mInheritedData)
|
|
|
|
mInheritedData->ClearInheritedData(aBits);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
|
|
|
|
if (mResetData)
|
|
|
|
mResetData->Destroy(aBits, aContext);
|
|
|
|
if (mInheritedData)
|
|
|
|
mInheritedData->Destroy(aBits, aContext);
|
|
|
|
mResetData = nsnull;
|
|
|
|
mInheritedData = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCachedStyleData() :mInheritedData(nsnull), mResetData(nsnull) {};
|
|
|
|
~nsCachedStyleData() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nsRuleData
|
|
|
|
{
|
|
|
|
nsStyleStructID mSID;
|
2001-12-15 02:10:42 +03:00
|
|
|
PRPackedBool mCanStoreInRuleTree;
|
2001-10-24 04:01:09 +04:00
|
|
|
nsIPresContext* mPresContext;
|
|
|
|
nsIStyleContext* mStyleContext;
|
|
|
|
nsPostResolveFunc mPostResolveCallback;
|
|
|
|
nsCSSFont* mFontData; // Should always be stack-allocated! We don't own these structures!
|
|
|
|
nsCSSDisplay* mDisplayData;
|
|
|
|
nsCSSMargin* mMarginData;
|
|
|
|
nsCSSList* mListData;
|
|
|
|
nsCSSPosition* mPositionData;
|
|
|
|
nsCSSTable* mTableData;
|
|
|
|
nsCSSColor* mColorData;
|
|
|
|
nsCSSContent* mContentData;
|
|
|
|
nsCSSText* mTextData;
|
|
|
|
nsCSSUserInterface* mUIData;
|
|
|
|
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
nsCSSXUL* mXULData;
|
|
|
|
#endif
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
nsCSSSVG* mSVGData;
|
|
|
|
#endif
|
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext)
|
|
|
|
:mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
|
2001-12-11 07:12:34 +03:00
|
|
|
mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
|
2001-10-24 04:01:09 +04:00
|
|
|
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
|
|
|
|
mUIData(nsnull)
|
|
|
|
{
|
|
|
|
mCanStoreInRuleTree = PR_TRUE;
|
|
|
|
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
mXULData = nsnull;
|
2001-12-12 10:59:31 +03:00
|
|
|
#endif
|
|
|
|
#ifdef MOZ_SVG
|
|
|
|
mSVGData = nsnull;
|
2001-10-24 04:01:09 +04:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
~nsRuleData() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsRuleNode {
|
|
|
|
public:
|
2001-09-05 07:13:58 +04:00
|
|
|
// for purposes of the RuleDetail (and related code),
|
|
|
|
// * a non-inherited value is one that is specified as a
|
|
|
|
// non-"inherit" value or as an "inherit" value that is reflected
|
|
|
|
// in the struct and to the user of the style system with an
|
|
|
|
// eCSSUnit_Inherit value
|
|
|
|
// * an inherited value is one that is specified as "inherit" and
|
|
|
|
// where the inheritance is computed by the style system
|
2001-06-01 02:19:43 +04:00
|
|
|
enum RuleDetail {
|
|
|
|
eRuleNone, // No props have been specified at all.
|
2002-02-17 04:53:40 +03:00
|
|
|
eRulePartialReset, // At least one prop with a non-inherited value
|
|
|
|
// has been specified. No props have been
|
|
|
|
// specified with an inherited value. At least
|
|
|
|
// one prop remains unspecified.
|
2001-09-05 07:13:58 +04:00
|
|
|
eRulePartialMixed, // At least one prop with a non-inherited value
|
|
|
|
// has been specified. Some props may also have
|
|
|
|
// been specified with an inherited value. At
|
|
|
|
// least one prop remains unspecified.
|
|
|
|
eRulePartialInherited, // Only props with inherited values have
|
|
|
|
// have been specified. At least one prop
|
|
|
|
// remains unspecified.
|
2002-02-17 04:53:40 +03:00
|
|
|
eRuleFullReset, // All props have been specified. None has an
|
|
|
|
// inherited value.
|
2001-09-05 07:13:58 +04:00
|
|
|
eRuleFullMixed, // All props have been specified. At least one has
|
|
|
|
// a non-inherited value.
|
|
|
|
eRuleFullInherited, // All props have been specified with inherited
|
|
|
|
// values.
|
|
|
|
eRuleUnknown // Information unknown (used as a result from a check
|
|
|
|
// callback to trigger the normal checking codepath)
|
2001-06-01 02:19:43 +04:00
|
|
|
};
|
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
enum { // Types of RuleBits
|
|
|
|
eNoneBits,
|
2002-02-17 04:53:40 +03:00
|
|
|
eDependentBits
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
private:
|
|
|
|
nsIPresContext* mPresContext; // Our pres context.
|
|
|
|
|
2002-03-19 04:29:20 +03:00
|
|
|
nsRuleNode* mParent; // A pointer to the parent node in the tree.
|
|
|
|
// This enables us to walk backwards from the
|
|
|
|
// most specific rule matched to the least
|
|
|
|
// specific rule (which is the optimal order to
|
|
|
|
// use for lookups of style properties.
|
2001-06-02 01:04:23 +04:00
|
|
|
nsCOMPtr<nsIStyleRule> mRule; // A pointer to our specific rule.
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2002-03-19 04:29:20 +03:00
|
|
|
// The children of this node are stored in either a hashtable or list
|
|
|
|
// that maps from rules to our nsRuleNode children. When matching
|
|
|
|
// rules, we use this mapping to transition from node to node
|
|
|
|
// (constructing new nodes as needed to flesh out the tree).
|
|
|
|
|
|
|
|
void *mChildrenTaggedPtr; // Accessed only through the methods below.
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kTypeMask = 0x1,
|
|
|
|
kListType = 0x0,
|
|
|
|
kHashType = 0x1
|
|
|
|
};
|
|
|
|
enum {
|
|
|
|
// Maximum to have in a list before converting to a hashtable.
|
|
|
|
// XXX Need to optimize this.
|
|
|
|
kMaxChildrenInList = 32
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2002-03-19 04:29:20 +03:00
|
|
|
PRBool HaveChildren() {
|
|
|
|
return mChildrenTaggedPtr != nsnull;
|
|
|
|
}
|
|
|
|
PRBool ChildrenAreHashed() {
|
|
|
|
return (PRWord(mChildrenTaggedPtr) & kTypeMask) == kHashType;
|
|
|
|
}
|
|
|
|
nsRuleList* ChildrenList() {
|
|
|
|
return NS_STATIC_CAST(nsRuleList*, mChildrenTaggedPtr);
|
|
|
|
}
|
|
|
|
PLDHashTable* ChildrenHash() {
|
|
|
|
return (PLDHashTable*) (PRWord(mChildrenTaggedPtr) & ~PRWord(kTypeMask));
|
|
|
|
}
|
|
|
|
void SetChildrenList(nsRuleList *aList) {
|
|
|
|
NS_ASSERTION(!(PRWord(aList) & kTypeMask),
|
|
|
|
"pointer not 2-byte aligned");
|
|
|
|
mChildrenTaggedPtr = aList;
|
|
|
|
}
|
|
|
|
void SetChildrenHash(PLDHashTable *aHashtable) {
|
|
|
|
NS_ASSERTION(!(PRWord(aHashtable) & kTypeMask),
|
|
|
|
"pointer not 2-byte aligned");
|
|
|
|
mChildrenTaggedPtr = (void*)(PRWord(aHashtable) | kHashType);
|
|
|
|
}
|
|
|
|
void ConvertChildrenToHash();
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsCachedStyleData mStyleData; // Any data we cached on the rule node.
|
|
|
|
|
2002-02-17 04:53:40 +03:00
|
|
|
PRUint32 mDependentBits; // Used to cache the fact that we can look up
|
|
|
|
// cached data under a parent rule.
|
|
|
|
|
|
|
|
PRUint32 mNoneBits; // Used to cache the fact that the branch to this
|
|
|
|
// node specifies no non-inherited data for a
|
|
|
|
// given struct type. (This usually implies that
|
|
|
|
// the entire branch specifies no non-inherited
|
|
|
|
// data, although not necessarily, if a
|
|
|
|
// non-inherited value is overridden by an
|
|
|
|
// explicit 'inherit' value.) For example, if an
|
|
|
|
// entire rule branch specifies no color
|
|
|
|
// information, then a bit will be set along every
|
|
|
|
// rule node on that branch, so that you can break
|
|
|
|
// out of the rule tree early and just inherit
|
|
|
|
// from the parent style context. The presence of
|
|
|
|
// this bit means we should just get inherited
|
|
|
|
// data from the parent style context, and it is
|
|
|
|
// never used for reset structs since their
|
|
|
|
// Compute*Data functions don't initialize from
|
|
|
|
// inherited data.
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
friend struct nsRuleList;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
2001-06-01 02:19:43 +04:00
|
|
|
// (which comes from the presShell) to perform the allocation.
|
|
|
|
void* operator new(size_t sz, nsIPresContext* aContext);
|
|
|
|
void Destroy();
|
2001-12-11 07:12:34 +03:00
|
|
|
static nsILanguageAtomService *gLangService;
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
protected:
|
2002-02-17 04:53:40 +03:00
|
|
|
void PropagateDependentBit(PRUint32 aBit, nsRuleNode* aHighestNode);
|
2001-06-01 02:19:43 +04:00
|
|
|
void PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode);
|
|
|
|
|
2001-09-05 07:13:58 +04:00
|
|
|
const nsStyleStruct* SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aContext);
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-09-05 07:13:58 +04:00
|
|
|
const nsStyleStruct* WalkRuleTree(const nsStyleStructID aSID, nsIStyleContext* aContext,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsRuleData* aRuleData,
|
2001-11-14 11:19:13 +03:00
|
|
|
nsCSSStruct* aSpecificData,
|
|
|
|
PRBool aComputeData);
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeDisplayData(nsStyleStruct* aStartDisplay, const nsCSSStruct& aDisplayData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeVisibilityData(nsStyleStruct* aStartVisibility, const nsCSSStruct& aDisplayData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeFontData(nsStyleStruct* aStartFont, const nsCSSStruct& aFontData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeColorData(nsStyleStruct* aStartColor, const nsCSSStruct& aColorData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeBackgroundData(nsStyleStruct* aStartBackground, const nsCSSStruct& aColorData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeMarginData(nsStyleStruct* aStartMargin, const nsCSSStruct& aMarginData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeBorderData(nsStyleStruct* aStartBorder, const nsCSSStruct& aMarginData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputePaddingData(nsStyleStruct* aStartPadding, const nsCSSStruct& aMarginData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeOutlineData(nsStyleStruct* aStartOutline, const nsCSSStruct& aMarginData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeListData(nsStyleStruct* aStartList, const nsCSSStruct& aListData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputePositionData(nsStyleStruct* aStartPosition, const nsCSSStruct& aPositionData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeTableData(nsStyleStruct* aStartTable, const nsCSSStruct& aTableData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeTableBorderData(nsStyleStruct* aStartTable, const nsCSSStruct& aTableData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeContentData(nsStyleStruct* aStartContent, const nsCSSStruct& aData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeQuotesData(nsStyleStruct* aStartQuotes, const nsCSSStruct& aData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeTextData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeTextResetData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
|
|
|
#ifdef INCLUDE_XUL
|
2001-06-30 02:42:46 +04:00
|
|
|
const nsStyleStruct* ComputeXULData(nsStyleStruct* aStartXUL, const nsCSSStruct& aXULData,
|
2001-06-01 02:19:43 +04:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
|
|
|
#endif
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
const nsStyleStruct* ComputeSVGData(nsStyleStruct* aStartSVG, const nsCSSStruct& aSVGData,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
|
|
|
#endif
|
|
|
|
|
2001-06-30 02:42:46 +04:00
|
|
|
typedef const nsStyleStruct*
|
|
|
|
(nsRuleNode::*ComputeStyleDataFn)(nsStyleStruct* aStartStruct,
|
|
|
|
const nsCSSStruct& aStartData,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail,
|
|
|
|
PRBool aInherited);
|
|
|
|
|
|
|
|
static ComputeStyleDataFn gComputeStyleDataFn[];
|
|
|
|
|
2001-09-05 07:13:58 +04:00
|
|
|
inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, const nsCSSStruct& aCSSStruct);
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-09-05 07:13:58 +04:00
|
|
|
const nsStyleStruct* GetParentData(const nsStyleStructID aSID);
|
2001-11-14 11:19:13 +03:00
|
|
|
const nsStyleStruct* GetDisplayData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetVisibilityData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetFontData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetColorData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetBackgroundData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetMarginData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetBorderData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetPaddingData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetOutlineData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetListData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetPositionData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetTableData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetTableBorderData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetContentData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetQuotesData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetTextData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetTextResetData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetUIData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
const nsStyleStruct* GetUIResetData(nsIStyleContext* aContext, PRBool aComputeData);
|
2001-06-01 02:19:43 +04:00
|
|
|
#ifdef INCLUDE_XUL
|
2001-11-14 11:19:13 +03:00
|
|
|
const nsStyleStruct* GetXULData(nsIStyleContext* aContext, PRBool aComputeData);
|
2001-06-01 02:19:43 +04:00
|
|
|
#endif
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
const nsStyleStruct* GetSVGData(nsIStyleContext* aContext, PRBool aComputeData);
|
|
|
|
#endif
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-11-14 11:19:13 +03:00
|
|
|
typedef const nsStyleStruct* (nsRuleNode::*GetStyleDataFn)(nsIStyleContext*, PRBool);
|
2001-06-30 02:42:46 +04:00
|
|
|
static GetStyleDataFn gGetStyleDataFn[];
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
public:
|
|
|
|
nsRuleNode(nsIPresContext* aPresContext, nsIStyleRule* aRule=nsnull, nsRuleNode* aParent=nsnull);
|
|
|
|
virtual ~nsRuleNode();
|
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
static void CreateRootNode(nsIPresContext* aPresContext, nsRuleNode** aResult);
|
|
|
|
|
|
|
|
nsresult GetBits(PRInt32 aType, PRUint32* aResult);
|
|
|
|
nsresult Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
|
|
|
|
nsRuleNode* GetParent() { return mParent; }
|
|
|
|
PRBool IsRoot() { return mParent == nsnull; }
|
2001-10-24 10:25:08 +04:00
|
|
|
nsresult GetRule(nsIStyleRule** aResult)
|
|
|
|
{
|
|
|
|
*aResult = mRule;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-03-19 04:29:20 +03:00
|
|
|
nsIStyleRule* Rule() {
|
|
|
|
// NOTE: Does not |AddRef|.
|
|
|
|
return mRule;
|
|
|
|
}
|
2001-10-24 10:25:08 +04:00
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
nsresult ClearCachedData(nsIStyleRule* aRule);
|
|
|
|
nsresult ClearCachedDataInSubtree(nsIStyleRule* aRule);
|
|
|
|
nsresult GetPresContext(nsIPresContext** aResult);
|
|
|
|
nsresult PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched);
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
|
2001-11-14 11:19:13 +03:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
PRBool aComputeData);
|
2001-06-01 02:19:43 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|