2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* 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)
|
2007-09-27 09:26:22 -07:00
|
|
|
* L. David Baron <dbaron@dbaron.org>
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* a node in the lexicographic tree of rules that match an element,
|
|
|
|
* responsible for converting the rules' information into computed style
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsRuleNode_h___
|
|
|
|
#define nsRuleNode_h___
|
|
|
|
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsStyleStruct.h"
|
|
|
|
|
|
|
|
class nsStyleContext;
|
|
|
|
struct PLDHashTable;
|
|
|
|
class nsILanguageAtomService;
|
|
|
|
struct nsRuleData;
|
|
|
|
class nsIStyleRule;
|
|
|
|
struct nsCSSStruct;
|
2008-07-07 17:56:52 -07:00
|
|
|
struct nsCSSValueList;
|
2007-03-22 10:30:00 -07:00
|
|
|
// Copy of typedef that's in nsCSSStruct.h, for compilation speed.
|
|
|
|
typedef nsCSSStruct nsRuleDataStruct;
|
|
|
|
|
|
|
|
struct nsRuleDataFont;
|
|
|
|
class nsCSSValue;
|
2007-07-04 11:51:16 -07:00
|
|
|
struct nsCSSRect;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
struct nsInheritedStyleData
|
|
|
|
{
|
|
|
|
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
|
|
|
nsStyle##name * m##name##Data;
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
|
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
|
|
|
return aContext->AllocateFromShell(sz);
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void ClearInheritedData(PRUint32 aBits) {
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
|
|
|
if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
m##name##Data = nsnull;
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void Destroy(PRUint32 aBits, nsPresContext* aContext) {
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
|
|
|
if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
m##name##Data->Destroy(aContext);
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
|
|
|
|
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsInheritedStyleData() {
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args) \
|
|
|
|
m##name##Data = nsnull;
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nsResetStyleData
|
|
|
|
{
|
|
|
|
nsResetStyleData()
|
|
|
|
{
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
|
|
|
m##name##Data = nsnull;
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
|
|
|
return aContext->AllocateFromShell(sz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearInheritedData(PRUint32 aBits) {
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
|
|
|
if (m##name##Data && (aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
m##name##Data = nsnull;
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void Destroy(PRUint32 aBits, nsPresContext* aContext) {
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
|
|
|
if (m##name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
m##name##Data->Destroy(aContext);
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
|
|
|
|
aContext->FreeToShell(sizeof(nsResetStyleData), this);
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb, ctor_args) \
|
|
|
|
nsStyle##name * m##name##Data;
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb, ctor_args)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
|
|
|
|
return 1 << aSID;
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(void*) NS_FASTCALL GetStyleData(const nsStyleStructID& aSID) {
|
2007-03-22 10:30:00 -07: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.
|
|
|
|
|
|
|
|
// NOTE: nsStyleContext::SetStyle works roughly the same way.
|
|
|
|
|
|
|
|
const StyleStructInfo& info = gInfo[aSID];
|
|
|
|
|
|
|
|
// Get either &mInheritedData or &mResetData.
|
2007-07-08 00:08:04 -07:00
|
|
|
char* resetOrInheritSlot = reinterpret_cast<char*>(this) + info.mCachedStyleDataOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Get either mInheritedData or mResetData.
|
2007-07-08 00:08:04 -07:00
|
|
|
char* resetOrInherit = reinterpret_cast<char*>(*reinterpret_cast<void**>(resetOrInheritSlot));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
void* data = nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (resetOrInherit) {
|
|
|
|
// If we have the mInheritedData or mResetData, then we might have
|
|
|
|
// the struct, so get it.
|
|
|
|
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
|
2008-01-10 12:56:49 -08:00
|
|
|
data = *reinterpret_cast<void**>(dataSlot);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return data;
|
2007-04-23 07:21:53 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Typesafe and faster versions of the above
|
|
|
|
#define STYLE_STRUCT_INHERITED(name_, checkdata_cb_, ctor_args_) \
|
|
|
|
NS_HIDDEN_(nsStyle##name_ *) NS_FASTCALL GetStyle##name_ () { \
|
|
|
|
return mInheritedData ? mInheritedData->m##name_##Data : nsnull; \
|
|
|
|
}
|
|
|
|
#define STYLE_STRUCT_RESET(name_, checkdata_cb_, ctor_args_) \
|
|
|
|
NS_HIDDEN_(nsStyle##name_ *) NS_FASTCALL GetStyle##name_ () { \
|
|
|
|
return mResetData ? mResetData->m##name_##Data : nsnull; \
|
|
|
|
}
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
|
|
|
|
NS_HIDDEN_(void) ClearInheritedData(PRUint32 aBits) {
|
|
|
|
if (mResetData)
|
|
|
|
mResetData->ClearInheritedData(aBits);
|
|
|
|
if (mInheritedData)
|
|
|
|
mInheritedData->ClearInheritedData(aBits);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_HIDDEN_(void) Destroy(PRUint32 aBits, nsPresContext* aContext) {
|
|
|
|
if (mResetData)
|
|
|
|
mResetData->Destroy(aBits, aContext);
|
|
|
|
if (mInheritedData)
|
|
|
|
mInheritedData->Destroy(aBits, aContext);
|
|
|
|
mResetData = nsnull;
|
|
|
|
mInheritedData = nsnull;
|
|
|
|
}
|
|
|
|
|
2007-04-23 07:21:53 -07:00
|
|
|
nsCachedStyleData() :mInheritedData(nsnull), mResetData(nsnull) {}
|
|
|
|
~nsCachedStyleData() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsRuleNode is a node in a lexicographic tree (the "rule tree")
|
|
|
|
* indexed by style rules (implementations of nsIStyleRule).
|
|
|
|
*
|
|
|
|
* The rule tree is owned by the nsStyleSet and is destroyed when the
|
|
|
|
* presentation of the document goes away. It is garbage-collected
|
|
|
|
* (using mark-and-sweep garbage collection) during the lifetime of the
|
|
|
|
* document (when dynamic changes cause the destruction of enough style
|
|
|
|
* contexts). Rule nodes are marked if they are pointed to by a style
|
|
|
|
* context or one of their descendants is.
|
|
|
|
*
|
|
|
|
* An nsStyleContext, which represents the computed style data for an
|
|
|
|
* element, points to an nsRuleNode. The path from the root of the rule
|
|
|
|
* tree to the nsStyleContext's mRuleNode gives the list of the rules
|
|
|
|
* matched, from least important in the cascading order to most
|
|
|
|
* important in the cascading order.
|
|
|
|
*
|
|
|
|
* The reason for using a lexicographic tree is that it allows for
|
|
|
|
* sharing of style data, which saves both memory (for storing the
|
|
|
|
* computed style data) and time (for computing them). This sharing
|
|
|
|
* depends on the computed style data being stored in structs (nsStyle*)
|
|
|
|
* that contain only properties that are inherited by default
|
|
|
|
* ("inherited structs") or structs that contain only properties that
|
|
|
|
* are not inherited by default ("reset structs"). The optimization
|
|
|
|
* depends on the normal case being that style rules specify relatively
|
|
|
|
* few properties and even that elements generally have relatively few
|
|
|
|
* properties specified. This allows sharing in the following ways:
|
|
|
|
* 1. [mainly reset structs] When a style data struct will contain the
|
|
|
|
* same computed value for any elements that match the same set of
|
|
|
|
* rules (common for reset structs), it can be stored on the
|
|
|
|
* nsRuleNode instead of on the nsStyleContext.
|
|
|
|
* 2. [only? reset structs] When (1) occurs, and an nsRuleNode doesn't
|
|
|
|
* have any rules that change the values in the struct, the
|
|
|
|
* nsRuleNode can share that struct with its parent nsRuleNode.
|
|
|
|
* 3. [mainly inherited structs] When an element doesn't match any
|
|
|
|
* rules that change the value of a property (or, in the edge case,
|
|
|
|
* when all the values specified are 'inherit'), the nsStyleContext
|
|
|
|
* can use the same nsStyle* struct as its parent nsStyleContext.
|
|
|
|
*
|
|
|
|
* Since the data represented by an nsIStyleRule are immutable, the data
|
2007-09-27 09:26:22 -07:00
|
|
|
* represented by an nsRuleNode are also immutable.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
class nsRuleNode {
|
|
|
|
public:
|
|
|
|
enum RuleDetail {
|
|
|
|
eRuleNone, // No props have been specified at all.
|
|
|
|
eRulePartialReset, // At least one prop with a non-"inherit" value
|
|
|
|
// has been specified. No props have been
|
|
|
|
// specified with an "inherit" value. At least
|
|
|
|
// one prop remains unspecified.
|
|
|
|
eRulePartialMixed, // At least one prop with a non-"inherit" value
|
|
|
|
// has been specified. Some props may also have
|
|
|
|
// been specified with an "inherit" value. At
|
|
|
|
// least one prop remains unspecified.
|
|
|
|
eRulePartialInherited, // Only props with "inherit" values have
|
|
|
|
// have been specified. At least one prop
|
|
|
|
// remains unspecified.
|
|
|
|
eRuleFullReset, // All props have been specified. None has an
|
|
|
|
// "inherit" value.
|
|
|
|
eRuleFullMixed, // All props have been specified. At least one has
|
|
|
|
// a non-"inherit" value.
|
|
|
|
eRuleFullInherited // All props have been specified with "inherit"
|
|
|
|
// values.
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsPresContext* mPresContext; // Our pres context.
|
|
|
|
|
|
|
|
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.
|
|
|
|
nsIStyleRule* mRule; // [STRONG] A pointer to our specific rule.
|
|
|
|
|
2008-07-13 13:57:38 -07:00
|
|
|
nsRuleNode* mNextSibling; // This value should be used only by the
|
|
|
|
// parent, since the parent may store
|
|
|
|
// children in a hash, which means this
|
|
|
|
// pointer is not meaningful. Order of
|
|
|
|
// siblings is also not meaningful.
|
|
|
|
|
2007-05-16 14:08:51 -07:00
|
|
|
struct Key {
|
|
|
|
nsIStyleRule* mRule;
|
|
|
|
PRUint8 mLevel;
|
|
|
|
PRPackedBool mIsImportantRule;
|
|
|
|
|
|
|
|
Key(nsIStyleRule* aRule, PRUint8 aLevel, PRPackedBool aIsImportantRule)
|
|
|
|
: mRule(aRule), mLevel(aLevel), mIsImportantRule(aIsImportantRule)
|
|
|
|
{}
|
|
|
|
|
|
|
|
PRBool operator==(const Key& aOther) const
|
|
|
|
{
|
|
|
|
return mRule == aOther.mRule &&
|
|
|
|
mLevel == aOther.mLevel &&
|
|
|
|
mIsImportantRule == aOther.mIsImportantRule;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool operator!=(const Key& aOther) const
|
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-10-10 08:04:34 -07:00
|
|
|
static PLDHashNumber
|
2007-05-16 14:08:51 -07:00
|
|
|
ChildrenHashHashKey(PLDHashTable *aTable, const void *aKey);
|
|
|
|
|
2008-10-10 08:04:34 -07:00
|
|
|
static PRBool
|
2007-05-16 14:08:51 -07:00
|
|
|
ChildrenHashMatchEntry(PLDHashTable *aTable,
|
|
|
|
const PLDHashEntryHdr *aHdr,
|
|
|
|
const void *aKey);
|
|
|
|
|
|
|
|
static PLDHashTableOps ChildrenHashOps;
|
|
|
|
|
2008-10-10 08:04:34 -07:00
|
|
|
static PLDHashOperator
|
2008-07-13 13:57:38 -07:00
|
|
|
EnqueueRuleNodeChildren(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
|
|
|
PRUint32 number, void *arg);
|
|
|
|
|
2007-05-16 14:08:51 -07:00
|
|
|
Key GetKey() const {
|
|
|
|
return Key(mRule, GetLevel(), IsImportantRule());
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07: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).
|
|
|
|
|
2008-10-07 15:10:19 -07:00
|
|
|
union {
|
|
|
|
void* asVoid;
|
|
|
|
nsRuleNode* asList;
|
|
|
|
PLDHashTable* asHash;
|
|
|
|
} mChildren; // Accessed only through the methods below.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2008-12-29 07:07:36 -08:00
|
|
|
PRBool HaveChildren() const {
|
2008-10-07 15:10:19 -07:00
|
|
|
return mChildren.asVoid != nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
PRBool ChildrenAreHashed() {
|
2008-10-07 15:10:19 -07:00
|
|
|
return (PRWord(mChildren.asVoid) & kTypeMask) == kHashType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-07-13 13:57:38 -07:00
|
|
|
nsRuleNode* ChildrenList() {
|
2008-10-07 15:10:19 -07:00
|
|
|
return mChildren.asList;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-07-13 13:57:38 -07:00
|
|
|
nsRuleNode** ChildrenListPtr() {
|
2008-10-07 15:10:19 -07:00
|
|
|
return &mChildren.asList;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
PLDHashTable* ChildrenHash() {
|
2008-10-07 15:10:19 -07:00
|
|
|
return (PLDHashTable*) (PRWord(mChildren.asHash) & ~PRWord(kTypeMask));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-07-13 13:57:38 -07:00
|
|
|
void SetChildrenList(nsRuleNode *aList) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(!(PRWord(aList) & kTypeMask),
|
|
|
|
"pointer not 2-byte aligned");
|
2008-10-07 15:10:19 -07:00
|
|
|
mChildren.asList = aList;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
void SetChildrenHash(PLDHashTable *aHashtable) {
|
|
|
|
NS_ASSERTION(!(PRWord(aHashtable) & kTypeMask),
|
|
|
|
"pointer not 2-byte aligned");
|
2008-10-07 15:10:19 -07:00
|
|
|
mChildren.asHash = (PLDHashTable*)(PRWord(aHashtable) | kHashType);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
void ConvertChildrenToHash();
|
|
|
|
|
|
|
|
nsCachedStyleData mStyleData; // Any data we cached on the rule node.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2009-09-24 10:59:43 -07:00
|
|
|
// Reference count. This just counts the style contexts that
|
|
|
|
// reference this rulenode. When this goes to 0 or stops being 0,
|
|
|
|
// we notify the style set.
|
|
|
|
PRUint32 mRefCnt;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
|
|
|
// (which comes from the presShell) to perform the allocation.
|
|
|
|
NS_HIDDEN_(void*) operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
|
2008-07-13 13:57:38 -07:00
|
|
|
NS_HIDDEN_(void) Destroy() { DestroyInternal(nsnull); }
|
2007-03-22 10:30:00 -07:00
|
|
|
static NS_HIDDEN_(nsILanguageAtomService*) gLangService;
|
|
|
|
|
2009-09-24 10:59:43 -07:00
|
|
|
// Implemented in nsStyleSet.h, since it needs to know about nsStyleSet.
|
|
|
|
inline NS_HIDDEN_(void) AddRef();
|
|
|
|
|
|
|
|
// Implemented in nsStyleSet.h, since it needs to know about nsStyleSet.
|
|
|
|
inline NS_HIDDEN_(void) Release();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2008-07-13 13:57:38 -07:00
|
|
|
NS_HIDDEN_(void) DestroyInternal(nsRuleNode ***aDestroyQueueTail);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_HIDDEN_(void) PropagateDependentBit(PRUint32 aBit,
|
|
|
|
nsRuleNode* aHighestNode);
|
|
|
|
NS_HIDDEN_(void) PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode);
|
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*) SetDefaultOnRoot(const nsStyleStructID aSID,
|
|
|
|
nsStyleContext* aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
2007-03-22 10:30:00 -07:00
|
|
|
WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext,
|
|
|
|
nsRuleData* aRuleData, nsRuleDataStruct* aSpecificData);
|
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeDisplayData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeVisibilityData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeFontData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeColorData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeBackgroundData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeMarginData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeBorderData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputePaddingData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeOutlineData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeListData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputePositionData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeTableData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeTableBorderData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeContentData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeQuotesData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeTextData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeTextResetData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeUserInterfaceData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeUIResetData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeXULData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeColumnData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_SVG
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeSVGData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeSVGResetData(void* aStartStruct,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 13:24:18 -08:00
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const PRBool aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// helpers for |ComputeFontData| that need access to |mNoneBits|:
|
2008-01-09 01:38:28 -08:00
|
|
|
static NS_HIDDEN_(void) SetFontSize(nsPresContext* aPresContext,
|
|
|
|
const nsRuleDataFont& aFontData,
|
|
|
|
const nsStyleFont* aFont,
|
|
|
|
const nsStyleFont* aParentFont,
|
|
|
|
nscoord* aSize,
|
|
|
|
const nsFont& aSystemFont,
|
|
|
|
nscoord aParentSize,
|
|
|
|
nscoord aScriptLevelAdjustedParentSize,
|
|
|
|
PRBool aUsedStartStruct,
|
2009-01-20 13:58:48 -08:00
|
|
|
PRBool aAtRoot,
|
2009-02-04 13:24:18 -08:00
|
|
|
PRBool& aCanStoreInRuleTree);
|
2008-01-09 01:38:28 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static NS_HIDDEN_(void) SetFont(nsPresContext* aPresContext,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
nscoord aMinFontSize,
|
2007-07-25 16:12:38 -07:00
|
|
|
PRUint8 aGenericFontID,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRuleDataFont& aFontData,
|
|
|
|
const nsStyleFont* aParentFont,
|
2008-01-09 01:38:28 -08:00
|
|
|
nsStyleFont* aFont,
|
2009-02-04 13:24:18 -08:00
|
|
|
PRBool aStartStruct,
|
|
|
|
PRBool& aCanStoreInRuleTree);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static NS_HIDDEN_(void) SetGenericFont(nsPresContext* aPresContext,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
PRUint8 aGenericFontID,
|
|
|
|
nscoord aMinFontSize,
|
|
|
|
nsStyleFont* aFont);
|
|
|
|
|
|
|
|
NS_HIDDEN_(void) AdjustLogicalBoxProp(nsStyleContext* aContext,
|
|
|
|
const nsCSSValue& aLTRSource,
|
|
|
|
const nsCSSValue& aRTLSource,
|
|
|
|
const nsCSSValue& aLTRLogicalValue,
|
|
|
|
const nsCSSValue& aRTLLogicalValue,
|
|
|
|
PRUint8 aSide,
|
2007-07-04 11:51:16 -07:00
|
|
|
nsCSSRect& aValueRect,
|
2009-02-04 13:24:18 -08:00
|
|
|
PRBool& aCanStoreInRuleTree);
|
2007-07-04 11:51:16 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, const nsRuleDataStruct& aRuleDataStruct);
|
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*) GetParentData(const nsStyleStructID aSID);
|
2007-03-22 10:30:00 -07:00
|
|
|
#define STYLE_STRUCT(name_, checkdata_cb_, ctor_args_) \
|
|
|
|
NS_HIDDEN_(const nsStyle##name_*) GetParent##name_();
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT
|
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*) GetDisplayData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetVisibilityData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetFontData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetColorData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetBackgroundData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetMarginData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetBorderData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetPaddingData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetOutlineData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetListData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetPositionData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetTableData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetTableBorderData(nsStyleContext* aContext);
|
|
|
|
|
|
|
|
NS_HIDDEN_(const void*) GetContentData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetQuotesData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetTextData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetTextResetData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetUserInterfaceData(nsStyleContext* aContext);
|
|
|
|
|
|
|
|
NS_HIDDEN_(const void*) GetUIResetData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetXULData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetColumnData(nsStyleContext* aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef MOZ_SVG
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*) GetSVGData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetSVGResetData(nsStyleContext* aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2008-07-07 17:56:52 -07:00
|
|
|
NS_HIDDEN_(already_AddRefed<nsCSSShadowArray>)
|
|
|
|
GetShadowData(nsCSSValueList* aList,
|
|
|
|
nsStyleContext* aContext,
|
2009-02-10 00:45:13 -08:00
|
|
|
PRBool aIsBoxShadow,
|
2008-07-07 17:56:52 -07:00
|
|
|
PRBool& inherited);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2007-05-16 14:08:51 -07:00
|
|
|
nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,
|
|
|
|
nsIStyleRule* aRule, PRUint8 aLevel, PRBool aIsImportant)
|
|
|
|
NS_HIDDEN;
|
2007-03-22 10:30:00 -07:00
|
|
|
~nsRuleNode() NS_HIDDEN;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static NS_HIDDEN_(nsRuleNode*) CreateRootNode(nsPresContext* aPresContext);
|
|
|
|
|
2009-12-11 22:36:34 -08:00
|
|
|
// Transition never returns null; on out of memory it'll just return |this|.
|
2007-05-16 14:08:51 -07:00
|
|
|
NS_HIDDEN_(nsRuleNode*) Transition(nsIStyleRule* aRule, PRUint8 aLevel,
|
|
|
|
PRPackedBool aIsImportantRule);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRuleNode* GetParent() const { return mParent; }
|
|
|
|
PRBool IsRoot() const { return mParent == nsnull; }
|
|
|
|
|
2007-05-16 14:08:51 -07:00
|
|
|
// These PRUint8s are really nsStyleSet::sheetType values.
|
|
|
|
PRUint8 GetLevel() const {
|
|
|
|
NS_ASSERTION(!IsRoot(), "can't call on root");
|
|
|
|
return (mDependentBits & NS_RULE_NODE_LEVEL_MASK) >>
|
|
|
|
NS_RULE_NODE_LEVEL_SHIFT;
|
|
|
|
}
|
|
|
|
PRBool IsImportantRule() const {
|
|
|
|
NS_ASSERTION(!IsRoot(), "can't call on root");
|
|
|
|
return (mDependentBits & NS_RULE_NODE_IS_IMPORTANT) != 0;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// NOTE: Does not |AddRef|.
|
|
|
|
nsIStyleRule* GetRule() const { return mRule; }
|
|
|
|
// NOTE: Does not |AddRef|.
|
|
|
|
nsPresContext* GetPresContext() const { return mPresContext; }
|
|
|
|
|
2008-01-10 12:56:49 -08:00
|
|
|
NS_HIDDEN_(const void*) GetStyleData(nsStyleStructID aSID,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
PRBool aComputeData);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define STYLE_STRUCT(name_, checkdata_cb_, ctor_args_) \
|
|
|
|
NS_HIDDEN_(const nsStyle##name_*) \
|
|
|
|
GetStyle##name_(nsStyleContext* aContext, \
|
|
|
|
PRBool aComputeData);
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
NS_HIDDEN_(void) Mark();
|
|
|
|
NS_HIDDEN_(PRBool) Sweep();
|
2007-10-08 16:11:01 -07:00
|
|
|
|
|
|
|
static PRBool
|
2009-06-16 15:05:12 -07:00
|
|
|
HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
|
|
|
|
PRUint32 ruleTypeMask,
|
|
|
|
PRBool aAuthorColorsAllowed);
|
2008-07-26 09:14:48 -07:00
|
|
|
|
|
|
|
// Expose this so media queries can use it
|
|
|
|
static nscoord CalcLengthWithInitialFont(nsPresContext* aPresContext,
|
|
|
|
const nsCSSValue& aValue);
|
2008-09-13 02:42:11 -07:00
|
|
|
// Expose this so nsTransformFunctions can use it.
|
|
|
|
static nscoord CalcLength(const nsCSSValue& aValue,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsPresContext* aPresContext,
|
2009-02-04 13:24:18 -08:00
|
|
|
PRBool& aCanStoreInRuleTree);
|
2008-12-29 07:07:36 -08:00
|
|
|
|
|
|
|
// Return whether the rule tree for which this node is the root has
|
|
|
|
// cached data such that we need to do dynamic change handling for
|
|
|
|
// changes that change the results of media queries or require
|
|
|
|
// rebuilding all style data.
|
|
|
|
PRBool TreeHasCachedData() const {
|
|
|
|
NS_ASSERTION(IsRoot(), "should only be called on root of rule tree");
|
|
|
|
return HaveChildren() || mStyleData.mInheritedData || mStyleData.mResetData;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|