2001-10-24 04:01:09 +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
|
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Original Author: David W. Hyatt (hyatt@netscape.com)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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 ***** */
|
|
|
|
|
|
|
|
#ifndef nsRuleNode_h___
|
|
|
|
#define nsRuleNode_h___
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIStyleRule.h"
|
|
|
|
#include "nsFixedSizeAllocator.h"
|
|
|
|
#include "nsIPresContext.h"
|
2003-04-15 07:07:34 +04:00
|
|
|
#include "nsCSSStruct.h"
|
2001-12-11 07:12:34 +03:00
|
|
|
#include "nsILanguageAtomService.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleStruct.h"
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
class nsStyleContext;
|
2001-10-24 04:01:09 +04:00
|
|
|
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
|
|
|
|
{
|
2002-07-09 08:10:10 +04:00
|
|
|
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
2002-07-09 08:10:10 +04:00
|
|
|
nsStyle##name * m##name##Data;
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
|
2002-07-09 08:10:10 +04:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2002-07-03 00:25:30 +04:00
|
|
|
void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
|
2001-10-24 04:01:09 +04:00
|
|
|
void* result = nsnull;
|
|
|
|
aContext->AllocateFromShell(sz, &result);
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ClearInheritedData(PRUint32 aBits) {
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
2002-07-09 08:10:10 +04:00
|
|
|
if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
m##name##Data = nsnull;
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
|
2002-07-09 08:10:10 +04:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
2002-07-09 08:10:10 +04:00
|
|
|
if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
m##name##Data->Destroy(aContext);
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
|
2002-07-09 08:10:10 +04:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
|
|
|
|
};
|
|
|
|
|
2002-07-09 08:10:10 +04:00
|
|
|
nsInheritedStyleData() {
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
2002-07-09 08:10:10 +04:00
|
|
|
m##name##Data = nsnull;
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
|
2002-07-09 08:10:10 +04:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
|
|
|
|
};
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nsResetStyleData
|
|
|
|
{
|
|
|
|
nsResetStyleData()
|
|
|
|
{
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
2002-07-09 08:10:10 +04:00
|
|
|
m##name##Data = nsnull;
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
|
2002-07-09 08:10:10 +04:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
2002-07-03 00:25:30 +04:00
|
|
|
void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
|
2001-10-24 04:01:09 +04:00
|
|
|
void* result = nsnull;
|
|
|
|
aContext->AllocateFromShell(sz, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearInheritedData(PRUint32 aBits) {
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
2002-07-09 08:10:10 +04:00
|
|
|
if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
m##name##Data = nsnull;
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
|
2002-07-09 08:10:10 +04:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
2002-07-09 08:10:10 +04:00
|
|
|
if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
m##name##Data->Destroy(aContext);
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
|
2002-07-09 08:10:10 +04:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
aContext->FreeToShell(sizeof(nsResetStyleData), this);
|
|
|
|
};
|
|
|
|
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
2002-07-09 08:10:10 +04:00
|
|
|
nsStyle##name * m##name##Data;
|
2003-03-13 18:29:36 +03:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
|
2002-07-09 08:10:10 +04:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nsCachedStyleData
|
|
|
|
{
|
|
|
|
struct StyleStructInfo {
|
|
|
|
ptrdiff_t mCachedStyleDataOffset;
|
|
|
|
ptrdiff_t mInheritResetOffset;
|
|
|
|
PRBool mIsReset;
|
|
|
|
};
|
|
|
|
|
|
|
|
static StyleStructInfo gInfo[];
|
|
|
|
|
|
|
|
nsInheritedStyleData* mInheritedData;
|
|
|
|
nsResetStyleData* mResetData;
|
|
|
|
|
|
|
|
static PRBool IsReset(const nsStyleStructID& aSID) {
|
|
|
|
return gInfo[aSID].mIsReset;
|
|
|
|
};
|
|
|
|
|
|
|
|
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
|
2002-07-09 08:10:10 +04:00
|
|
|
return 1 << aSID;
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
nsStyleStruct* GetStyleData(const nsStyleStructID& aSID) {
|
2002-08-06 17:46:35 +04:00
|
|
|
// Each struct is stored at this.m##type##Data->m##name##Data where
|
|
|
|
// |type| is either Inherit or Reset, and |name| is the name of the
|
|
|
|
// style struct. The |gInfo| stores the offset of the appropriate
|
|
|
|
// m##type##Data for the struct within nsCachedStyleData (|this|)
|
|
|
|
// and the offset of the appropriate m##name##Data within the
|
|
|
|
// m##type##Data. Note that if we don't have any reset structs,
|
|
|
|
// then mResetData is null, and likewise for mInheritedData. This
|
|
|
|
// saves us from having to go through the long if-else cascade into
|
|
|
|
// which most compilers will turn a case statement.
|
|
|
|
|
2002-07-09 08:10:10 +04:00
|
|
|
// NOTE: nsStyleContext::SetStyle works roughly the same way.
|
2002-08-06 17:46:35 +04:00
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
const StyleStructInfo& info = gInfo[aSID];
|
2002-08-06 17:46:35 +04:00
|
|
|
|
|
|
|
// Get either &mInheritedData or &mResetData.
|
2001-10-24 04:01:09 +04:00
|
|
|
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, this) + info.mCachedStyleDataOffset;
|
2002-08-06 17:46:35 +04:00
|
|
|
|
|
|
|
// Get either mInheritedData or mResetData.
|
2001-10-24 04:01:09 +04:00
|
|
|
char* resetOrInherit = NS_REINTERPRET_CAST(char*, *NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
|
2002-08-06 17:46:35 +04:00
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
nsStyleStruct* data = nsnull;
|
|
|
|
if (resetOrInherit) {
|
2002-08-06 17:46:35 +04:00
|
|
|
// If we have the mInheritedData or mResetData, then we might have
|
|
|
|
// the struct, so get it.
|
2001-10-24 04:01:09 +04:00
|
|
|
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;
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* mStyleContext;
|
2001-10-24 04:01:09 +04:00
|
|
|
nsPostResolveFunc mPostResolveCallback;
|
2002-11-12 18:17:07 +03:00
|
|
|
nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures!
|
|
|
|
nsRuleDataDisplay* mDisplayData;
|
|
|
|
nsRuleDataMargin* mMarginData;
|
|
|
|
nsRuleDataList* mListData;
|
|
|
|
nsRuleDataPosition* mPositionData;
|
|
|
|
nsRuleDataTable* mTableData;
|
|
|
|
nsRuleDataColor* mColorData;
|
|
|
|
nsRuleDataContent* mContentData;
|
|
|
|
nsRuleDataText* mTextData;
|
2003-06-08 02:14:42 +04:00
|
|
|
nsRuleDataUserInterface* mUserInterfaceData;
|
2002-11-12 18:17:07 +03:00
|
|
|
nsRuleDataXUL* mXULData;
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
2002-11-12 18:17:07 +03:00
|
|
|
nsRuleDataSVG* mSVGData;
|
2001-12-12 10:59:31 +03:00
|
|
|
#endif
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsStyleContext* aStyleContext)
|
2001-10-24 04:01:09 +04:00
|
|
|
: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),
|
2003-06-08 02:14:42 +04:00
|
|
|
mUserInterfaceData(nsnull)
|
2001-10-24 04:01:09 +04:00
|
|
|
{
|
|
|
|
mCanStoreInRuleTree = PR_TRUE;
|
|
|
|
mXULData = nsnull;
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
mSVGData = nsnull;
|
2001-10-24 04:01:09 +04:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
~nsRuleData() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsRuleNode {
|
|
|
|
public:
|
|
|
|
// 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
|
|
|
|
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-10-24 04:01:09 +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-10-24 04:01:09 +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)
|
|
|
|
};
|
|
|
|
|
|
|
|
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-10-24 04:01:09 +04:00
|
|
|
nsCOMPtr<nsIStyleRule> mRule; // A pointer to our specific rule.
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2002-03-19 04:29:20 +03:00
|
|
|
PRBool HaveChildren() {
|
|
|
|
return mChildrenTaggedPtr != nsnull;
|
|
|
|
}
|
|
|
|
PRBool ChildrenAreHashed() {
|
|
|
|
return (PRWord(mChildrenTaggedPtr) & kTypeMask) == kHashType;
|
|
|
|
}
|
|
|
|
nsRuleList* ChildrenList() {
|
2002-03-19 06:09:02 +03:00
|
|
|
return NS_REINTERPRET_CAST(nsRuleList*, mChildrenTaggedPtr);
|
2002-03-19 04:29:20 +03:00
|
|
|
}
|
2003-03-06 22:14:17 +03:00
|
|
|
nsRuleList** ChildrenListPtr() {
|
|
|
|
return NS_REINTERPRET_CAST(nsRuleList**, &mChildrenTaggedPtr);
|
|
|
|
}
|
2002-03-19 04:29:20 +03:00
|
|
|
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-10-24 04:01:09 +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-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
friend struct nsRuleList;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
|
|
|
// (which comes from the presShell) to perform the allocation.
|
2002-07-03 21:14:41 +04:00
|
|
|
void* operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW;
|
2001-10-24 04:01:09 +04:00
|
|
|
void Destroy();
|
2001-12-11 07:12:34 +03:00
|
|
|
static nsILanguageAtomService *gLangService;
|
2001-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
protected:
|
2002-02-17 04:53:40 +03:00
|
|
|
void PropagateDependentBit(PRUint32 aBit, nsRuleNode* aHighestNode);
|
2001-10-24 04:01:09 +04:00
|
|
|
void PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode);
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
const nsStyleStruct* SetDefaultOnRoot(const nsStyleStructID aSID, nsStyleContext* aContext);
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
const nsStyleStruct* WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext,
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleData* aRuleData,
|
2003-06-18 05:59:57 +04:00
|
|
|
nsRuleDataStruct* aSpecificData);
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeDisplayData(nsStyleStruct* aStartDisplay, const nsRuleDataStruct& aDisplayData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeVisibilityData(nsStyleStruct* aStartVisibility, const nsRuleDataStruct& aDisplayData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeFontData(nsStyleStruct* aStartFont, const nsRuleDataStruct& aFontData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeColorData(nsStyleStruct* aStartColor, const nsRuleDataStruct& aColorData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeBackgroundData(nsStyleStruct* aStartBackground, const nsRuleDataStruct& aColorData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeMarginData(nsStyleStruct* aStartMargin, const nsRuleDataStruct& aMarginData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeBorderData(nsStyleStruct* aStartBorder, const nsRuleDataStruct& aMarginData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputePaddingData(nsStyleStruct* aStartPadding, const nsRuleDataStruct& aMarginData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeOutlineData(nsStyleStruct* aStartOutline, const nsRuleDataStruct& aMarginData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeListData(nsStyleStruct* aStartList, const nsRuleDataStruct& aListData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputePositionData(nsStyleStruct* aStartPosition, const nsRuleDataStruct& aPositionData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeTableData(nsStyleStruct* aStartTable, const nsRuleDataStruct& aTableData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2001-10-24 04:01:09 +04:00
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeTableBorderData(nsStyleStruct* aStartTable, const nsRuleDataStruct& aTableData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeContentData(nsStyleStruct* aStartContent, const nsRuleDataStruct& aData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeQuotesData(nsStyleStruct* aStartQuotes, const nsRuleDataStruct& aData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeTextData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeTextResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-07-09 08:10:10 +04:00
|
|
|
const nsStyleStruct* ComputeUserInterfaceData(nsStyleStruct* aStartData,
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsRuleDataStruct& aData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2002-07-09 08:10:10 +04:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail,
|
|
|
|
PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeUIResetData(nsStyleStruct* aStartData, const nsRuleDataStruct& aData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeXULData(nsStyleStruct* aStartXUL, const nsRuleDataStruct& aXULData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-10-24 04:01:09 +04:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
2002-11-12 18:17:07 +03:00
|
|
|
const nsStyleStruct* ComputeSVGData(nsStyleStruct* aStartSVG, const nsRuleDataStruct& aSVGData,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-12-12 10:59:31 +03:00
|
|
|
nsRuleNode* aHighestNode,
|
|
|
|
const RuleDetail& aRuleDetail, PRBool aInherited);
|
|
|
|
#endif
|
2003-12-03 01:24:32 +03:00
|
|
|
|
|
|
|
// helpers for |ComputeFontData| that need access to |mNoneBits|:
|
|
|
|
static void SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext,
|
|
|
|
nscoord aMinFontSize, PRBool aUseDocumentFonts,
|
|
|
|
PRBool aIsGeneric, const nsRuleDataFont& aFontData,
|
|
|
|
const nsFont& aDefaultFont,
|
|
|
|
const nsStyleFont* aParentFont,
|
|
|
|
nsStyleFont* aFont, PRBool& aInherited);
|
|
|
|
static void SetGenericFont(nsIPresContext* aPresContext,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
const nsRuleDataFont& aFontData,
|
|
|
|
PRUint8 aGenericFontID, nscoord aMinFontSize,
|
|
|
|
PRBool aUseDocumentFonts, nsStyleFont* aFont);
|
2004-02-04 09:10:56 +03:00
|
|
|
|
|
|
|
void AdjustLogicalBoxProp(nsStyleContext* aContext,
|
|
|
|
const nsCSSValue& aLTRSource,
|
|
|
|
const nsCSSValue& aRTLSource,
|
|
|
|
const nsCSSValue& aLTRLogicalValue,
|
|
|
|
const nsCSSValue& aRTLLogicalValue,
|
|
|
|
const nsStyleSides& aParentRect,
|
|
|
|
nsStyleSides& aRect,
|
|
|
|
PRUint8 aSide,
|
|
|
|
PRInt32 aMask,
|
|
|
|
PRBool& aInherited);
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2002-11-12 18:17:07 +03:00
|
|
|
inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, const nsRuleDataStruct& aRuleDataStruct);
|
2001-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
const nsStyleStruct* GetParentData(const nsStyleStructID aSID);
|
2003-06-18 05:59:57 +04:00
|
|
|
const nsStyleStruct* GetDisplayData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetVisibilityData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetFontData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetColorData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetBackgroundData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetMarginData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetBorderData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetPaddingData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetOutlineData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetListData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetPositionData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetTableData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetTableBorderData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetContentData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetQuotesData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetTextData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetTextResetData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetUserInterfaceData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetUIResetData(nsStyleContext* aContext);
|
|
|
|
const nsStyleStruct* GetXULData(nsStyleContext* aContext);
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
2003-06-18 05:59:57 +04:00
|
|
|
const nsStyleStruct* GetSVGData(nsStyleContext* aContext);
|
2001-12-12 10:59:31 +03:00
|
|
|
#endif
|
2001-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
public:
|
2003-03-13 18:29:36 +03:00
|
|
|
nsRuleNode(nsIPresContext* aPresContext, nsIStyleRule* aRule,
|
|
|
|
nsRuleNode* aParent);
|
2001-10-24 04:01:09 +04:00
|
|
|
virtual ~nsRuleNode();
|
|
|
|
|
2003-03-13 18:29:36 +03:00
|
|
|
static nsRuleNode* CreateRootNode(nsIPresContext* aPresContext);
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2003-03-06 22:07:22 +03:00
|
|
|
nsresult Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
|
2003-06-20 05:22:44 +04:00
|
|
|
nsRuleNode* GetParent() const { return mParent; }
|
|
|
|
PRBool IsRoot() const { return mParent == nsnull; }
|
|
|
|
|
|
|
|
// NOTE: Does not |AddRef|.
|
|
|
|
nsIStyleRule* GetRule() const { return mRule; }
|
|
|
|
// NOTE: Does not |AddRef|.
|
|
|
|
nsIPresContext* GetPresContext() const { return mPresContext; }
|
2001-10-24 10:25:08 +04:00
|
|
|
|
2003-06-18 05:59:57 +04:00
|
|
|
nsresult ClearStyleData();
|
2001-10-24 04:01:09 +04:00
|
|
|
const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-11-14 11:19:13 +03:00
|
|
|
PRBool aComputeData);
|
2003-03-06 22:14:17 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Garbage collection. Mark walks up the tree, marking any unmarked
|
|
|
|
* ancestors until it reaches a marked one. Sweep recursively sweeps
|
|
|
|
* the children, destroys any that are unmarked, and clears marks,
|
|
|
|
* returning true if the node on which it was called was destroyed.
|
|
|
|
*/
|
|
|
|
void Mark();
|
|
|
|
PRBool Sweep();
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|