2001-10-24 04:01:09 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-10-24 04:01:09 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* 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/
|
2001-10-24 04:01:09 +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.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-10-24 04:01:09 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2004-04-18 01:52:36 +04:00
|
|
|
* Original Author: David W. Hyatt (hyatt@netscape.com)
|
2007-09-27 20:26:22 +04:00
|
|
|
* L. David Baron <dbaron@dbaron.org>
|
2001-10-24 04:01:09 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04:00
|
|
|
* 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"),
|
2001-10-24 04:01:09 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-10-24 04:01:09 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-10-24 04:01:09 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/*
|
|
|
|
* a node in the lexicographic tree of rules that match an element,
|
|
|
|
* responsible for converting the rules' information into computed style
|
|
|
|
*/
|
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
#ifndef nsRuleNode_h___
|
|
|
|
#define nsRuleNode_h___
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.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;
|
2002-03-19 04:29:20 +03:00
|
|
|
struct PLDHashTable;
|
2004-07-20 10:11:27 +04:00
|
|
|
class nsILanguageAtomService;
|
|
|
|
struct nsRuleData;
|
|
|
|
class nsIStyleRule;
|
|
|
|
struct nsCSSStruct;
|
2008-07-08 04:56:52 +04:00
|
|
|
struct nsCSSValueList;
|
2004-07-20 10:11:27 +04:00
|
|
|
// Copy of typedef that's in nsCSSStruct.h, for compilation speed.
|
|
|
|
typedef nsCSSStruct nsRuleDataStruct;
|
|
|
|
|
|
|
|
struct nsRuleDataFont;
|
|
|
|
class nsCSSValue;
|
2007-07-04 22:51:16 +04:00
|
|
|
struct nsCSSRect;
|
2007-03-23 02:01:14 +03:00
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
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
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 04:28:44 +04:00
|
|
|
return aContext->AllocateFromShell(sz);
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
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
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void Destroy(PRUint32 aBits, nsPresContext* 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);
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
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
|
|
|
|
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
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
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 04:28:44 +04:00
|
|
|
return aContext->AllocateFromShell(sz);
|
2001-10-24 04:01:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void Destroy(PRUint32 aBits, nsPresContext* 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);
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
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;
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
|
2002-07-09 08:10:10 +04:00
|
|
|
return 1 << aSID;
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(void*) NS_FASTCALL 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.
|
2007-07-08 11:08:04 +04:00
|
|
|
char* resetOrInheritSlot = reinterpret_cast<char*>(this) + info.mCachedStyleDataOffset;
|
2002-08-06 17:46:35 +04:00
|
|
|
|
|
|
|
// Get either mInheritedData or mResetData.
|
2007-07-08 11:08:04 +04:00
|
|
|
char* resetOrInherit = reinterpret_cast<char*>(*reinterpret_cast<void**>(resetOrInheritSlot));
|
2002-08-06 17:46:35 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
void* data = nsnull;
|
2001-10-24 04:01:09 +04:00
|
|
|
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;
|
2008-01-10 23:56:49 +03:00
|
|
|
data = *reinterpret_cast<void**>(dataSlot);
|
2001-10-24 04:01:09 +04:00
|
|
|
}
|
|
|
|
return data;
|
2007-04-23 18:21:53 +04:00
|
|
|
}
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2006-12-12 20:44:45 +03: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
|
|
|
|
|
2004-05-13 01:20:09 +04:00
|
|
|
NS_HIDDEN_(void) ClearInheritedData(PRUint32 aBits) {
|
2001-10-24 04:01:09 +04:00
|
|
|
if (mResetData)
|
|
|
|
mResetData->ClearInheritedData(aBits);
|
|
|
|
if (mInheritedData)
|
|
|
|
mInheritedData->ClearInheritedData(aBits);
|
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_HIDDEN_(void) Destroy(PRUint32 aBits, nsPresContext* aContext) {
|
2001-10-24 04:01:09 +04:00
|
|
|
if (mResetData)
|
|
|
|
mResetData->Destroy(aBits, aContext);
|
|
|
|
if (mInheritedData)
|
|
|
|
mInheritedData->Destroy(aBits, aContext);
|
|
|
|
mResetData = nsnull;
|
|
|
|
mInheritedData = nsnull;
|
|
|
|
}
|
|
|
|
|
2007-04-23 18:21:53 +04:00
|
|
|
nsCachedStyleData() :mInheritedData(nsnull), mResetData(nsnull) {}
|
|
|
|
~nsCachedStyleData() {}
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
2005-02-04 23:11:00 +03:00
|
|
|
/**
|
|
|
|
* nsRuleNode is a node in a lexicographic tree (the "rule tree")
|
2005-02-05 08:24:21 +03:00
|
|
|
* 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.
|
2005-02-04 23:11:00 +03:00
|
|
|
*
|
|
|
|
* 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:
|
2005-02-04 23:29:18 +03:00
|
|
|
* 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.
|
2005-02-04 23:11:00 +03:00
|
|
|
*
|
|
|
|
* Since the data represented by an nsIStyleRule are immutable, the data
|
2007-09-27 20:26:22 +04:00
|
|
|
* represented by an nsRuleNode are also immutable.
|
2005-02-04 23:11:00 +03:00
|
|
|
*/
|
|
|
|
|
2001-10-24 04:01:09 +04:00
|
|
|
class nsRuleNode {
|
|
|
|
public:
|
|
|
|
enum RuleDetail {
|
|
|
|
eRuleNone, // No props have been specified at all.
|
2005-12-27 22:37:14 +03:00
|
|
|
eRulePartialReset, // At least one prop with a non-"inherit" value
|
2002-02-17 04:53:40 +03:00
|
|
|
// has been specified. No props have been
|
2005-12-27 22:37:14 +03:00
|
|
|
// specified with an "inherit" value. At least
|
2002-02-17 04:53:40 +03:00
|
|
|
// one prop remains unspecified.
|
2005-12-27 22:37:14 +03:00
|
|
|
eRulePartialMixed, // At least one prop with a non-"inherit" value
|
2001-10-24 04:01:09 +04:00
|
|
|
// has been specified. Some props may also have
|
2005-12-27 22:37:14 +03:00
|
|
|
// been specified with an "inherit" value. At
|
2001-10-24 04:01:09 +04:00
|
|
|
// least one prop remains unspecified.
|
2005-12-27 22:37:14 +03:00
|
|
|
eRulePartialInherited, // Only props with "inherit" values have
|
2001-10-24 04:01:09 +04:00
|
|
|
// 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
|
2005-12-27 22:37:14 +03:00
|
|
|
// "inherit" value.
|
2001-10-24 04:01:09 +04:00
|
|
|
eRuleFullMixed, // All props have been specified. At least one has
|
2005-12-27 22:37:14 +03:00
|
|
|
// a non-"inherit" value.
|
2006-04-15 11:17:43 +04:00
|
|
|
eRuleFullInherited // All props have been specified with "inherit"
|
2001-10-24 04:01:09 +04:00
|
|
|
// values.
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* mPresContext; // Our pres context.
|
2001-10-24 04:01:09 +04:00
|
|
|
|
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.
|
2004-07-20 10:11:27 +04:00
|
|
|
nsIStyleRule* mRule; // [STRONG] A pointer to our specific rule.
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2008-07-14 00:57:38 +04: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-17 01:08:51 +04: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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static PR_CALLBACK PLDHashNumber
|
|
|
|
ChildrenHashHashKey(PLDHashTable *aTable, const void *aKey);
|
|
|
|
|
|
|
|
static PR_CALLBACK PRBool
|
|
|
|
ChildrenHashMatchEntry(PLDHashTable *aTable,
|
|
|
|
const PLDHashEntryHdr *aHdr,
|
|
|
|
const void *aKey);
|
|
|
|
|
|
|
|
static PLDHashTableOps ChildrenHashOps;
|
|
|
|
|
2008-07-14 00:57:38 +04:00
|
|
|
static PR_CALLBACK PLDHashOperator
|
|
|
|
EnqueueRuleNodeChildren(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
|
|
|
PRUint32 number, void *arg);
|
|
|
|
|
2007-05-17 01:08:51 +04:00
|
|
|
Key GetKey() const {
|
|
|
|
return Key(mRule, GetLevel(), IsImportantRule());
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2008-07-14 00:57:38 +04:00
|
|
|
nsRuleNode* ChildrenList() {
|
|
|
|
return reinterpret_cast<nsRuleNode*>(mChildrenTaggedPtr);
|
2002-03-19 04:29:20 +03:00
|
|
|
}
|
2008-07-14 00:57:38 +04:00
|
|
|
nsRuleNode** ChildrenListPtr() {
|
|
|
|
return reinterpret_cast<nsRuleNode**>(&mChildrenTaggedPtr);
|
2003-03-06 22:14:17 +03:00
|
|
|
}
|
2002-03-19 04:29:20 +03:00
|
|
|
PLDHashTable* ChildrenHash() {
|
|
|
|
return (PLDHashTable*) (PRWord(mChildrenTaggedPtr) & ~PRWord(kTypeMask));
|
|
|
|
}
|
2008-07-14 00:57:38 +04:00
|
|
|
void SetChildrenList(nsRuleNode *aList) {
|
2002-03-19 04:29:20 +03:00
|
|
|
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
|
|
|
|
|
|
|
public:
|
|
|
|
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
|
|
|
// (which comes from the presShell) to perform the allocation.
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_HIDDEN_(void*) operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
|
2008-07-14 00:57:38 +04:00
|
|
|
NS_HIDDEN_(void) Destroy() { DestroyInternal(nsnull); }
|
2004-05-13 01:20:09 +04:00
|
|
|
static NS_HIDDEN_(nsILanguageAtomService*) gLangService;
|
2001-10-24 04:01:09 +04:00
|
|
|
|
|
|
|
protected:
|
2008-07-14 00:57:38 +04:00
|
|
|
NS_HIDDEN_(void) DestroyInternal(nsRuleNode ***aDestroyQueueTail);
|
2004-05-13 01:20:09 +04:00
|
|
|
NS_HIDDEN_(void) PropagateDependentBit(PRUint32 aBit,
|
|
|
|
nsRuleNode* aHighestNode);
|
|
|
|
NS_HIDDEN_(void) PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode);
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*) SetDefaultOnRoot(const nsStyleStructID aSID,
|
|
|
|
nsStyleContext* aContext);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
2004-05-13 01:20:09 +04:00
|
|
|
WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext,
|
|
|
|
nsRuleData* aRuleData, nsRuleDataStruct* aSpecificData);
|
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeDisplayData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeVisibilityData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeFontData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeColorData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeBackgroundData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeMarginData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeBorderData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputePaddingData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeOutlineData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeListData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputePositionData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeTableData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeTableBorderData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeContentData(void* aStartStruct,
|
2004-05-13 01:20:09 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeQuotesData(void* aStartStruct,
|
2004-05-13 01:20:09 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeTextData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeTextResetData(void* aStartStruct,
|
2004-05-13 01:20:09 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeUserInterfaceData(void* aStartStruct,
|
2004-05-13 01:20:09 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeUIResetData(void* aStartStruct,
|
2004-05-13 01:20:09 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeXULData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeColumnData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-06-17 15:57:37 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-06-17 15:57:37 +04:00
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeSVGData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*)
|
|
|
|
ComputeSVGResetData(void* aStartStruct,
|
2006-04-15 11:17:43 +04:00
|
|
|
const nsRuleDataStruct& aData,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2007-07-22 21:56:56 +04:00
|
|
|
RuleDetail aRuleDetail, PRBool aInherited);
|
2001-12-12 10:59:31 +03:00
|
|
|
#endif
|
2003-12-03 01:24:32 +03:00
|
|
|
|
|
|
|
// helpers for |ComputeFontData| that need access to |mNoneBits|:
|
2008-01-09 12:38:28 +03: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,
|
|
|
|
PRBool& aInherited);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
static NS_HIDDEN_(void) SetFont(nsPresContext* aPresContext,
|
2004-05-13 01:20:09 +04:00
|
|
|
nsStyleContext* aContext,
|
|
|
|
nscoord aMinFontSize,
|
2007-07-26 03:12:38 +04:00
|
|
|
PRUint8 aGenericFontID,
|
2004-05-13 01:20:09 +04:00
|
|
|
const nsRuleDataFont& aFontData,
|
|
|
|
const nsStyleFont* aParentFont,
|
2008-01-09 12:38:28 +03:00
|
|
|
nsStyleFont* aFont,
|
|
|
|
PRBool aStartStruct, PRBool& aInherited);
|
2004-05-13 01:20:09 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
static NS_HIDDEN_(void) SetGenericFont(nsPresContext* aPresContext,
|
2004-05-13 01:20:09 +04:00
|
|
|
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 22:51:16 +04:00
|
|
|
nsCSSRect& aValueRect,
|
2004-05-13 01:20:09 +04:00
|
|
|
PRBool& aInherited);
|
2007-07-04 22:51:16 +04: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
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*) GetParentData(const nsStyleStructID aSID);
|
2006-12-12 20:44:45 +03: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 23:56:49 +03: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);
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*) GetSVGData(nsStyleContext* aContext);
|
|
|
|
NS_HIDDEN_(const void*) GetSVGResetData(nsStyleContext* aContext);
|
2001-12-12 10:59:31 +03:00
|
|
|
#endif
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2008-07-08 04:56:52 +04:00
|
|
|
NS_HIDDEN_(already_AddRefed<nsCSSShadowArray>)
|
|
|
|
GetShadowData(nsCSSValueList* aList,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
PRBool aUsesSpread,
|
|
|
|
PRBool& inherited);
|
|
|
|
|
2006-04-28 00:01:59 +04:00
|
|
|
private:
|
2007-05-17 01:08:51 +04:00
|
|
|
nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,
|
|
|
|
nsIStyleRule* aRule, PRUint8 aLevel, PRBool aIsImportant)
|
|
|
|
NS_HIDDEN;
|
2006-04-28 00:01:59 +04:00
|
|
|
~nsRuleNode() NS_HIDDEN;
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2006-04-28 00:01:59 +04:00
|
|
|
public:
|
2004-08-01 03:15:21 +04:00
|
|
|
static NS_HIDDEN_(nsRuleNode*) CreateRootNode(nsPresContext* aPresContext);
|
2001-10-24 04:01:09 +04:00
|
|
|
|
2007-05-17 01:08:51 +04:00
|
|
|
NS_HIDDEN_(nsRuleNode*) Transition(nsIStyleRule* aRule, PRUint8 aLevel,
|
|
|
|
PRPackedBool aIsImportantRule);
|
2003-06-20 05:22:44 +04:00
|
|
|
nsRuleNode* GetParent() const { return mParent; }
|
|
|
|
PRBool IsRoot() const { return mParent == nsnull; }
|
|
|
|
|
2007-05-17 01:08:51 +04: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;
|
|
|
|
}
|
|
|
|
|
2003-06-20 05:22:44 +04:00
|
|
|
// NOTE: Does not |AddRef|.
|
|
|
|
nsIStyleRule* GetRule() const { return mRule; }
|
|
|
|
// NOTE: Does not |AddRef|.
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* GetPresContext() const { return mPresContext; }
|
2001-10-24 10:25:08 +04:00
|
|
|
|
2008-01-10 23:56:49 +03:00
|
|
|
NS_HIDDEN_(const void*) GetStyleData(nsStyleStructID aSID,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
PRBool aComputeData);
|
2003-03-06 22:14:17 +03:00
|
|
|
|
2006-12-12 20:44:45 +03: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
|
|
|
|
|
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.
|
|
|
|
*/
|
2004-05-13 01:20:09 +04:00
|
|
|
NS_HIDDEN_(void) Mark();
|
|
|
|
NS_HIDDEN_(PRBool) Sweep();
|
2007-10-09 03:11:01 +04:00
|
|
|
|
|
|
|
static PRBool
|
2008-04-26 03:12:45 +04:00
|
|
|
HasAuthorSpecifiedRules(nsStyleContext* aStyleContext, PRUint32 ruleTypeMask);
|
2008-07-26 20:14:48 +04:00
|
|
|
|
|
|
|
// Expose this so media queries can use it
|
|
|
|
static nscoord CalcLengthWithInitialFont(nsPresContext* aPresContext,
|
|
|
|
const nsCSSValue& aValue);
|
2001-10-24 04:01:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|