2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2006-03-25 05:47:31 +00:00
|
|
|
/*
|
|
|
|
* a node in the lexicographic tree of rules that match an element,
|
|
|
|
* responsible for converting the rules' information into computed style
|
|
|
|
*/
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
#ifndef nsRuleNode_h___
|
|
|
|
#define nsRuleNode_h___
|
|
|
|
|
2015-09-17 02:08:19 +00:00
|
|
|
#include "mozilla/ArenaObjectID.h"
|
2016-03-25 01:40:40 +00:00
|
|
|
#include "mozilla/LinkedList.h"
|
2015-06-23 01:48:18 +00:00
|
|
|
#include "mozilla/PodOperations.h"
|
2015-05-23 02:50:44 +00:00
|
|
|
#include "mozilla/RangedArray.h"
|
2015-06-23 01:48:18 +00:00
|
|
|
#include "mozilla/RuleNodeCacheConditions.h"
|
2015-10-19 23:16:20 +00:00
|
|
|
#include "mozilla/SheetType.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleStruct.h"
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2015-03-31 22:05:54 +00:00
|
|
|
class nsCSSPropertySet;
|
2004-07-20 06:11:27 +00:00
|
|
|
class nsCSSValue;
|
2015-06-23 01:48:18 +00:00
|
|
|
class nsIStyleRule;
|
|
|
|
class nsStyleContext;
|
2010-07-03 04:18:55 +00:00
|
|
|
class nsStyleCoord;
|
2015-06-23 01:48:18 +00:00
|
|
|
struct nsCSSRect;
|
|
|
|
struct nsCSSValueList;
|
2012-05-04 19:45:03 +00:00
|
|
|
struct nsCSSValuePairList;
|
2015-06-23 01:48:18 +00:00
|
|
|
struct nsRuleData;
|
2010-07-03 04:18:55 +00:00
|
|
|
|
2011-03-18 03:14:32 +00:00
|
|
|
struct nsInheritedStyleData
|
|
|
|
{
|
2015-05-23 02:50:44 +00:00
|
|
|
mozilla::RangedArray<void*,
|
|
|
|
nsStyleStructID_Inherited_Start,
|
|
|
|
nsStyleStructID_Inherited_Count> mStyleStructs;
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2014-07-19 04:22:20 +00:00
|
|
|
return aContext->PresShell()->
|
2015-09-17 02:08:19 +00:00
|
|
|
AllocateByObjectID(mozilla::eArenaObjectID_nsInheritedStyleData, sz);
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2013-12-12 02:09:40 +00:00
|
|
|
void DestroyStructs(uint64_t aBits, nsPresContext* aContext) {
|
2013-04-02 01:45:48 +00:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
|
2011-03-18 03:14:32 +00:00
|
|
|
void *name##Data = mStyleStructs[eStyleStruct_##name]; \
|
|
|
|
if (name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
static_cast<nsStyle##name*>(name##Data)->Destroy(aContext);
|
2013-04-02 01:45:48 +00:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb)
|
2002-07-09 04:10:10 +00:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
#undef STYLE_STRUCT_RESET
|
2010-03-02 23:27:20 +00:00
|
|
|
}
|
2002-07-09 04:10:10 +00:00
|
|
|
|
2013-12-12 02:09:40 +00:00
|
|
|
void Destroy(uint64_t aBits, nsPresContext* aContext) {
|
2010-03-02 23:27:20 +00:00
|
|
|
DestroyStructs(aBits, aContext);
|
2014-07-19 04:22:20 +00:00
|
|
|
aContext->PresShell()->
|
2015-09-17 02:08:19 +00:00
|
|
|
FreeByObjectID(mozilla::eArenaObjectID_nsInheritedStyleData, this);
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2002-07-09 04:10:10 +00:00
|
|
|
nsInheritedStyleData() {
|
2011-03-18 03:14:32 +00:00
|
|
|
for (nsStyleStructID i = nsStyleStructID_Inherited_Start;
|
|
|
|
i < nsStyleStructID_Inherited_Start + nsStyleStructID_Inherited_Count;
|
|
|
|
i = nsStyleStructID(i + 1)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mStyleStructs[i] = nullptr;
|
2011-03-18 03:14:32 +00:00
|
|
|
}
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nsResetStyleData
|
|
|
|
{
|
2015-05-23 02:50:44 +00:00
|
|
|
mozilla::RangedArray<void*,
|
|
|
|
nsStyleStructID_Reset_Start,
|
|
|
|
nsStyleStructID_Reset_Count> mStyleStructs;
|
2011-03-18 03:14:32 +00:00
|
|
|
|
2001-10-24 00:01:09 +00:00
|
|
|
nsResetStyleData()
|
|
|
|
{
|
2011-03-18 03:14:32 +00:00
|
|
|
for (nsStyleStructID i = nsStyleStructID_Reset_Start;
|
|
|
|
i < nsStyleStructID_Reset_Start + nsStyleStructID_Reset_Count;
|
|
|
|
i = nsStyleStructID(i + 1)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mStyleStructs[i] = nullptr;
|
2011-03-18 03:14:32 +00:00
|
|
|
}
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2014-07-19 04:22:20 +00:00
|
|
|
return aContext->PresShell()->
|
2015-09-17 02:08:19 +00:00
|
|
|
AllocateByObjectID(mozilla::eArenaObjectID_nsResetStyleData, sz);
|
2001-10-24 00:01:09 +00:00
|
|
|
}
|
|
|
|
|
2013-12-12 02:09:40 +00:00
|
|
|
void Destroy(uint64_t aBits, nsPresContext* aContext) {
|
2013-04-02 01:45:48 +00:00
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
|
2011-03-18 03:14:32 +00:00
|
|
|
void *name##Data = mStyleStructs[eStyleStruct_##name]; \
|
|
|
|
if (name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \
|
|
|
|
static_cast<nsStyle##name*>(name##Data)->Destroy(aContext);
|
2013-04-02 01:45:48 +00:00
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
|
2002-07-09 04:10:10 +00:00
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
|
2014-07-19 04:22:20 +00:00
|
|
|
aContext->PresShell()->
|
2015-09-17 02:08:19 +00:00
|
|
|
FreeByObjectID(mozilla::eArenaObjectID_nsResetStyleData, this);
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
};
|
|
|
|
|
2015-06-23 01:48:18 +00:00
|
|
|
struct nsConditionalResetStyleData
|
|
|
|
{
|
|
|
|
static uint32_t GetBitForSID(const nsStyleStructID aSID) {
|
|
|
|
return 1 << aSID;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Entry
|
|
|
|
{
|
|
|
|
Entry(const mozilla::RuleNodeCacheConditions& aConditions,
|
|
|
|
void* aStyleStruct,
|
|
|
|
Entry* aNext)
|
|
|
|
: mConditions(aConditions), mStyleStruct(aStyleStruct), mNext(aNext) {}
|
|
|
|
|
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2015-09-17 02:08:19 +00:00
|
|
|
return aContext->PresShell()->AllocateByObjectID(
|
|
|
|
mozilla::eArenaObjectID_nsConditionalResetStyleDataEntry, sz);
|
2015-06-23 01:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const mozilla::RuleNodeCacheConditions mConditions;
|
|
|
|
void* const mStyleStruct;
|
|
|
|
Entry* const mNext;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Each entry is either a pointer to a style struct or a
|
|
|
|
// pointer to an Entry object. A bit in mConditionalBits
|
|
|
|
// means that it is an Entry.
|
|
|
|
mozilla::RangedArray<void*,
|
|
|
|
nsStyleStructID_Reset_Start,
|
|
|
|
nsStyleStructID_Reset_Count> mEntries;
|
|
|
|
|
|
|
|
uint32_t mConditionalBits;
|
|
|
|
|
|
|
|
nsConditionalResetStyleData()
|
|
|
|
{
|
|
|
|
for (nsStyleStructID i = nsStyleStructID_Reset_Start;
|
|
|
|
i < nsStyleStructID_Reset_Start + nsStyleStructID_Reset_Count;
|
|
|
|
i = nsStyleStructID(i + 1)) {
|
|
|
|
mEntries[i] = nullptr;
|
|
|
|
}
|
|
|
|
mConditionalBits = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2015-09-17 02:08:19 +00:00
|
|
|
return aContext->PresShell()->AllocateByObjectID(
|
|
|
|
mozilla::eArenaObjectID_nsConditionalResetStyleData, sz);
|
2015-06-23 01:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void* GetStyleData(nsStyleStructID aSID) const {
|
|
|
|
if (mConditionalBits & GetBitForSID(aSID)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mEntries[aSID];
|
|
|
|
}
|
|
|
|
|
|
|
|
void* GetStyleData(nsStyleStructID aSID,
|
2015-10-22 23:57:35 +00:00
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
bool aCanComputeData) const {
|
2015-06-23 01:48:18 +00:00
|
|
|
if (!(mConditionalBits & GetBitForSID(aSID))) {
|
|
|
|
return mEntries[aSID];
|
|
|
|
}
|
2015-10-22 23:57:35 +00:00
|
|
|
if (!aCanComputeData) {
|
|
|
|
// If aCanComputeData is false, then any previously-computed data
|
|
|
|
// would have been cached on the style context. Therefore it's
|
|
|
|
// unnecessary to check the conditional data. It's also
|
|
|
|
// incorrect, because calling e->mConditions.Matches() below could
|
|
|
|
// cause additional structs to be computed, which is incorrect
|
|
|
|
// during CalcStyleDifference.
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-10-22 23:57:35 +00:00
|
|
|
return GetConditionalStyleData(aSID, aStyleContext);
|
2015-06-23 01:48:18 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 23:57:35 +00:00
|
|
|
private:
|
|
|
|
// non-inline helper for GetStyleData
|
|
|
|
void* GetConditionalStyleData(nsStyleStructID aSID,
|
|
|
|
nsStyleContext* aStyleContext) const;
|
|
|
|
|
|
|
|
public:
|
2015-06-23 01:48:18 +00:00
|
|
|
void SetStyleData(nsStyleStructID aSID, void* aStyleStruct) {
|
|
|
|
MOZ_ASSERT(!(mConditionalBits & GetBitForSID(aSID)),
|
|
|
|
"rule node should not have unconditional and conditional style "
|
|
|
|
"data for a given struct");
|
|
|
|
mEntries[aSID] = aStyleStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStyleData(nsStyleStructID aSID,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
void* aStyleStruct,
|
|
|
|
const mozilla::RuleNodeCacheConditions& aConditions) {
|
|
|
|
MOZ_ASSERT((mConditionalBits & GetBitForSID(aSID)) ||
|
|
|
|
!mEntries[aSID],
|
|
|
|
"rule node should not have unconditional and conditional style "
|
|
|
|
"data for a given struct");
|
|
|
|
MOZ_ASSERT(aConditions.CacheableWithDependencies(),
|
|
|
|
"don't call SetStyleData with a cache key that has no "
|
|
|
|
"conditions or is uncacheable");
|
|
|
|
#ifdef DEBUG
|
|
|
|
for (Entry* e = static_cast<Entry*>(mEntries[aSID]); e; e = e->mNext) {
|
|
|
|
NS_WARN_IF_FALSE(e->mConditions != aConditions,
|
|
|
|
"wasteful to have duplicate conditional style data");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mConditionalBits |= GetBitForSID(aSID);
|
|
|
|
mEntries[aSID] =
|
|
|
|
new (aPresContext) Entry(aConditions, aStyleStruct,
|
|
|
|
static_cast<Entry*>(mEntries[aSID]));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Destroy(uint64_t aBits, nsPresContext* aContext) {
|
|
|
|
#define STYLE_STRUCT_RESET(name, checkdata_cb) \
|
|
|
|
void* name##Ptr = mEntries[eStyleStruct_##name]; \
|
|
|
|
if (name##Ptr) { \
|
|
|
|
if (!(mConditionalBits & NS_STYLE_INHERIT_BIT(name))) { \
|
|
|
|
if (!(aBits & NS_STYLE_INHERIT_BIT(name))) { \
|
|
|
|
static_cast<nsStyle##name*>(name##Ptr)->Destroy(aContext); \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
Entry* e = static_cast<Entry*>(name##Ptr); \
|
|
|
|
MOZ_ASSERT(e, "if mConditionalBits bit is set, we must have at least " \
|
|
|
|
"one conditional style struct"); \
|
|
|
|
do { \
|
|
|
|
static_cast<nsStyle##name*>(e->mStyleStruct)->Destroy(aContext); \
|
|
|
|
Entry* next = e->mNext; \
|
|
|
|
aContext->PresShell()->FreeByObjectID( \
|
2015-09-17 02:08:19 +00:00
|
|
|
mozilla::eArenaObjectID_nsConditionalResetStyleDataEntry, e); \
|
2015-06-23 01:48:18 +00:00
|
|
|
e = next; \
|
|
|
|
} while (e); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define STYLE_STRUCT_INHERITED(name, checkdata_cb)
|
|
|
|
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
|
2015-09-17 02:08:19 +00:00
|
|
|
aContext->PresShell()->FreeByObjectID(
|
|
|
|
mozilla::eArenaObjectID_nsConditionalResetStyleData, this);
|
2015-06-23 01:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2001-10-24 00:01:09 +00:00
|
|
|
struct nsCachedStyleData
|
|
|
|
{
|
|
|
|
nsInheritedStyleData* mInheritedData;
|
2015-06-23 01:48:18 +00:00
|
|
|
nsConditionalResetStyleData* mResetData;
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsReset(const nsStyleStructID aSID) {
|
2015-02-09 22:34:50 +00:00
|
|
|
MOZ_ASSERT(0 <= aSID && aSID < nsStyleStructID_Length,
|
|
|
|
"must be an inherited or reset SID");
|
2011-03-18 03:14:32 +00:00
|
|
|
return nsStyleStructID_Reset_Start <= aSID;
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2013-12-03 03:42:09 +00:00
|
|
|
static bool IsInherited(const nsStyleStructID aSID) {
|
|
|
|
return !IsReset(aSID);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t GetBitForSID(const nsStyleStructID aSID) {
|
2015-06-23 01:48:18 +00:00
|
|
|
return nsConditionalResetStyleData::GetBitForSID(aSID);
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2011-03-18 03:14:32 +00:00
|
|
|
void* NS_FASTCALL GetStyleData(const nsStyleStructID aSID) {
|
|
|
|
if (IsReset(aSID)) {
|
|
|
|
if (mResetData) {
|
2015-06-23 01:48:18 +00:00
|
|
|
return mResetData->GetStyleData(aSID);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (mInheritedData) {
|
|
|
|
return mInheritedData->mStyleStructs[aSID];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* NS_FASTCALL GetStyleData(const nsStyleStructID aSID,
|
2015-10-22 23:57:35 +00:00
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
bool aCanComputeData) {
|
2015-06-23 01:48:18 +00:00
|
|
|
if (IsReset(aSID)) {
|
|
|
|
if (mResetData) {
|
2015-10-22 23:57:35 +00:00
|
|
|
return mResetData->GetStyleData(aSID, aStyleContext, aCanComputeData);
|
2011-03-18 03:14:32 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (mInheritedData) {
|
|
|
|
return mInheritedData->mStyleStructs[aSID];
|
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2007-04-23 14:21:53 +00:00
|
|
|
}
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2012-11-07 19:55:53 +00:00
|
|
|
void NS_FASTCALL SetStyleData(const nsStyleStructID aSID,
|
|
|
|
nsPresContext *aPresContext, void *aData) {
|
|
|
|
if (IsReset(aSID)) {
|
|
|
|
if (!mResetData) {
|
2015-06-23 01:48:18 +00:00
|
|
|
mResetData = new (aPresContext) nsConditionalResetStyleData;
|
2012-11-07 19:55:53 +00:00
|
|
|
}
|
2015-06-23 01:48:18 +00:00
|
|
|
mResetData->SetStyleData(aSID, aData);
|
2012-11-07 19:55:53 +00:00
|
|
|
} else {
|
|
|
|
if (!mInheritedData) {
|
|
|
|
mInheritedData = new (aPresContext) nsInheritedStyleData;
|
|
|
|
}
|
|
|
|
mInheritedData->mStyleStructs[aSID] = aData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-12 17:44:45 +00:00
|
|
|
// Typesafe and faster versions of the above
|
2015-06-23 01:48:18 +00:00
|
|
|
#define STYLE_STRUCT_INHERITED(name_, checkdata_cb_) \
|
|
|
|
nsStyle##name_ * NS_FASTCALL GetStyle##name_ () { \
|
|
|
|
return mInheritedData ? static_cast<nsStyle##name_*>( \
|
|
|
|
mInheritedData->mStyleStructs[eStyleStruct_##name_]) : nullptr; \
|
2006-12-12 17:44:45 +00:00
|
|
|
}
|
2015-06-23 01:48:18 +00:00
|
|
|
#define STYLE_STRUCT_RESET(name_, checkdata_cb_) \
|
2015-10-22 23:57:35 +00:00
|
|
|
nsStyle##name_ * NS_FASTCALL GetStyle##name_ (nsStyleContext* aContext, \
|
2015-10-30 01:00:01 +00:00
|
|
|
bool aCanComputeData) { \
|
2015-06-23 01:48:18 +00:00
|
|
|
return mResetData ? static_cast<nsStyle##name_*>( \
|
2015-10-30 01:00:01 +00:00
|
|
|
mResetData->GetStyleData(eStyleStruct_##name_, aContext, \
|
|
|
|
aCanComputeData)) \
|
2015-10-22 23:57:35 +00:00
|
|
|
: nullptr; \
|
2006-12-12 17:44:45 +00:00
|
|
|
}
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
|
|
|
|
2013-12-12 02:09:40 +00:00
|
|
|
void Destroy(uint64_t aBits, nsPresContext* aContext) {
|
2001-10-24 00:01:09 +00:00
|
|
|
if (mResetData)
|
|
|
|
mResetData->Destroy(aBits, aContext);
|
|
|
|
if (mInheritedData)
|
|
|
|
mInheritedData->Destroy(aBits, aContext);
|
2012-07-30 14:20:58 +00:00
|
|
|
mResetData = nullptr;
|
|
|
|
mInheritedData = nullptr;
|
2001-10-24 00:01:09 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsCachedStyleData() :mInheritedData(nullptr), mResetData(nullptr) {}
|
2007-04-23 14:21:53 +00:00
|
|
|
~nsCachedStyleData() {}
|
2001-10-24 00:01:09 +00:00
|
|
|
};
|
|
|
|
|
2005-02-04 20:11:00 +00:00
|
|
|
/**
|
|
|
|
* nsRuleNode is a node in a lexicographic tree (the "rule tree")
|
2005-02-05 05:24:21 +00:00
|
|
|
* indexed by style rules (implementations of nsIStyleRule).
|
|
|
|
*
|
|
|
|
* The rule tree is owned by the nsStyleSet and is destroyed when the
|
2016-03-25 01:40:40 +00:00
|
|
|
* presentation of the document goes away. Its entries are reference-
|
|
|
|
* counted, with strong references held by child nodes, style structs
|
|
|
|
* and (for the root), the style set. Rule nodes are not immediately
|
|
|
|
* destroyed when their reference-count drops to zero, but are instead
|
|
|
|
* destroyed during a GC sweep.
|
2005-02-04 20:11:00 +00: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 20:29:18 +00: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 20:11:00 +00:00
|
|
|
*
|
|
|
|
* Since the data represented by an nsIStyleRule are immutable, the data
|
2007-09-27 16:26:22 +00:00
|
|
|
* represented by an nsRuleNode are also immutable.
|
2005-02-04 20:11:00 +00:00
|
|
|
*/
|
|
|
|
|
2012-05-31 04:39:46 +00:00
|
|
|
enum nsFontSizeType {
|
|
|
|
eFontSize_HTML = 1,
|
|
|
|
eFontSize_CSS = 2
|
|
|
|
};
|
|
|
|
|
2016-03-25 01:40:40 +00:00
|
|
|
// Note: This LinkedListElement is used for storing unused nodes in the
|
|
|
|
// linked list on nsStyleSet. We use mNextSibling for the singly-linked
|
|
|
|
// sibling list.
|
|
|
|
class nsRuleNode : public mozilla::LinkedListElement<nsRuleNode> {
|
2001-10-24 00:01:09 +00:00
|
|
|
public:
|
2001-05-31 22:19:43 +00:00
|
|
|
enum RuleDetail {
|
|
|
|
eRuleNone, // No props have been specified at all.
|
2005-12-27 19:37:14 +00:00
|
|
|
eRulePartialReset, // At least one prop with a non-"inherit" value
|
2002-02-17 01:53:40 +00:00
|
|
|
// has been specified. No props have been
|
2005-12-27 19:37:14 +00:00
|
|
|
// specified with an "inherit" value. At least
|
2002-02-17 01:53:40 +00:00
|
|
|
// one prop remains unspecified.
|
2005-12-27 19:37:14 +00:00
|
|
|
eRulePartialMixed, // At least one prop with a non-"inherit" value
|
2001-09-05 03:13:58 +00:00
|
|
|
// has been specified. Some props may also have
|
2005-12-27 19:37:14 +00:00
|
|
|
// been specified with an "inherit" value. At
|
2001-09-05 03:13:58 +00:00
|
|
|
// least one prop remains unspecified.
|
2005-12-27 19:37:14 +00:00
|
|
|
eRulePartialInherited, // Only props with "inherit" values have
|
2001-09-05 03:13:58 +00:00
|
|
|
// have been specified. At least one prop
|
|
|
|
// remains unspecified.
|
2002-02-17 01:53:40 +00:00
|
|
|
eRuleFullReset, // All props have been specified. None has an
|
2005-12-27 19:37:14 +00:00
|
|
|
// "inherit" value.
|
2001-09-05 03:13:58 +00:00
|
|
|
eRuleFullMixed, // All props have been specified. At least one has
|
2005-12-27 19:37:14 +00:00
|
|
|
// a non-"inherit" value.
|
2006-04-15 07:17:43 +00:00
|
|
|
eRuleFullInherited // All props have been specified with "inherit"
|
2001-09-05 03:13:58 +00:00
|
|
|
// values.
|
2001-05-31 22:19:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2013-02-16 21:04:54 +00:00
|
|
|
nsPresContext* const mPresContext; // Our pres context.
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2016-03-25 01:40:40 +00:00
|
|
|
const RefPtr<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.
|
2016-03-25 01:26:46 +00:00
|
|
|
|
|
|
|
const nsCOMPtr<nsIStyleRule> mRule; // A pointer to our specific rule.
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2008-07-13 20:57:38 +00: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 21:08:51 +00:00
|
|
|
struct Key {
|
|
|
|
nsIStyleRule* mRule;
|
2015-10-19 23:16:20 +00:00
|
|
|
mozilla::SheetType mLevel;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsImportantRule;
|
2007-05-16 21:08:51 +00:00
|
|
|
|
2015-10-19 23:16:20 +00:00
|
|
|
Key(nsIStyleRule* aRule, mozilla::SheetType aLevel, bool aIsImportantRule)
|
2007-05-16 21:08:51 +00:00
|
|
|
: mRule(aRule), mLevel(aLevel), mIsImportantRule(aIsImportantRule)
|
|
|
|
{}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool operator==(const Key& aOther) const
|
2007-05-16 21:08:51 +00:00
|
|
|
{
|
|
|
|
return mRule == aOther.mRule &&
|
|
|
|
mLevel == aOther.mLevel &&
|
|
|
|
mIsImportantRule == aOther.mIsImportantRule;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool operator!=(const Key& aOther) const
|
2007-05-16 21:08:51 +00:00
|
|
|
{
|
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-10-10 15:04:34 +00:00
|
|
|
static PLDHashNumber
|
2016-03-16 04:33:44 +00:00
|
|
|
ChildrenHashHashKey(const void *aKey);
|
2007-05-16 21:08:51 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool
|
2016-03-16 04:33:44 +00:00
|
|
|
ChildrenHashMatchEntry(const PLDHashEntryHdr *aHdr, const void *aKey);
|
2007-05-16 21:08:51 +00:00
|
|
|
|
2013-11-19 02:51:48 +00:00
|
|
|
static const PLDHashTableOps ChildrenHashOps;
|
2007-05-16 21:08:51 +00:00
|
|
|
|
|
|
|
Key GetKey() const {
|
|
|
|
return Key(mRule, GetLevel(), IsImportantRule());
|
|
|
|
}
|
|
|
|
|
2002-03-19 01:29:20 +00: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 22:10:19 +00:00
|
|
|
union {
|
|
|
|
void* asVoid;
|
|
|
|
nsRuleNode* asList;
|
2015-05-19 23:46:17 +00:00
|
|
|
PLDHashTable* asHash;
|
2008-10-07 22:10:19 +00:00
|
|
|
} mChildren; // Accessed only through the methods below.
|
2002-03-19 01:29:20 +00: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
|
2001-10-24 00:01:09 +00:00
|
|
|
};
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HaveChildren() const {
|
2012-07-30 14:20:58 +00:00
|
|
|
return mChildren.asVoid != nullptr;
|
2002-03-19 01:29:20 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool ChildrenAreHashed() {
|
2012-04-12 00:17:44 +00:00
|
|
|
return (intptr_t(mChildren.asVoid) & kTypeMask) == kHashType;
|
2002-03-19 01:29:20 +00:00
|
|
|
}
|
2008-07-13 20:57:38 +00:00
|
|
|
nsRuleNode* ChildrenList() {
|
2008-10-07 22:10:19 +00:00
|
|
|
return mChildren.asList;
|
2002-03-19 01:29:20 +00:00
|
|
|
}
|
2008-07-13 20:57:38 +00:00
|
|
|
nsRuleNode** ChildrenListPtr() {
|
2008-10-07 22:10:19 +00:00
|
|
|
return &mChildren.asList;
|
2003-03-06 19:14:17 +00:00
|
|
|
}
|
2015-05-19 23:46:17 +00:00
|
|
|
PLDHashTable* ChildrenHash() {
|
|
|
|
return (PLDHashTable*) (intptr_t(mChildren.asHash) & ~intptr_t(kTypeMask));
|
2002-03-19 01:29:20 +00:00
|
|
|
}
|
2008-07-13 20:57:38 +00:00
|
|
|
void SetChildrenList(nsRuleNode *aList) {
|
2012-04-12 00:17:44 +00:00
|
|
|
NS_ASSERTION(!(intptr_t(aList) & kTypeMask),
|
2002-03-19 01:29:20 +00:00
|
|
|
"pointer not 2-byte aligned");
|
2008-10-07 22:10:19 +00:00
|
|
|
mChildren.asList = aList;
|
2002-03-19 01:29:20 +00:00
|
|
|
}
|
2015-05-19 23:46:17 +00:00
|
|
|
void SetChildrenHash(PLDHashTable *aHashtable) {
|
2012-04-12 00:17:44 +00:00
|
|
|
NS_ASSERTION(!(intptr_t(aHashtable) & kTypeMask),
|
2002-03-19 01:29:20 +00:00
|
|
|
"pointer not 2-byte aligned");
|
2015-05-19 23:46:17 +00:00
|
|
|
mChildren.asHash = (PLDHashTable*)(intptr_t(aHashtable) | kHashType);
|
2002-03-19 01:29:20 +00:00
|
|
|
}
|
2014-08-06 13:31:21 +00:00
|
|
|
void ConvertChildrenToHash(int32_t aNumKids);
|
2002-03-19 01:29:20 +00:00
|
|
|
|
2016-03-25 01:40:40 +00:00
|
|
|
void RemoveChild(nsRuleNode* aNode);
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
nsCachedStyleData mStyleData; // Any data we cached on the rule node.
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mDependentBits; // Used to cache the fact that we can look up
|
2002-02-17 01:53:40 +00:00
|
|
|
// cached data under a parent rule.
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mNoneBits; // Used to cache the fact that the branch to this
|
2002-02-17 01:53:40 +00:00
|
|
|
// 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-05-31 22:19:43 +00:00
|
|
|
|
2016-03-25 01:40:40 +00:00
|
|
|
// Reference count. Style contexts hold strong references to their rule node,
|
|
|
|
// and rule nodes hold strong references to their parent.
|
|
|
|
//
|
|
|
|
// When the refcount drops to zero, we don't necessarily free the node.
|
|
|
|
// Instead, we notify the style set, which performs periodic sweeps.
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mRefCnt;
|
2009-09-24 17:59:43 +00:00
|
|
|
|
2001-10-24 00:01:09 +00:00
|
|
|
public:
|
2015-06-04 06:45:11 +00:00
|
|
|
// Infallible overloaded new operator that allocates from a presShell arena.
|
2010-04-06 21:52:17 +00:00
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW;
|
2016-03-25 01:40:40 +00:00
|
|
|
void Destroy();
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2009-09-24 17:59:43 +00:00
|
|
|
// Implemented in nsStyleSet.h, since it needs to know about nsStyleSet.
|
2010-04-06 21:52:17 +00:00
|
|
|
inline void AddRef();
|
2009-09-24 17:59:43 +00:00
|
|
|
|
|
|
|
// Implemented in nsStyleSet.h, since it needs to know about nsStyleSet.
|
2010-04-06 21:52:17 +00:00
|
|
|
inline void Release();
|
2009-09-24 17:59:43 +00:00
|
|
|
|
2001-10-24 00:01:09 +00:00
|
|
|
protected:
|
2012-11-07 19:55:53 +00:00
|
|
|
void PropagateDependentBit(nsStyleStructID aSID, nsRuleNode* aHighestNode,
|
|
|
|
void* aStruct);
|
2012-08-22 15:56:38 +00:00
|
|
|
void PropagateNoneBit(uint32_t aBit, nsRuleNode* aHighestNode);
|
2014-09-05 03:48:44 +00:00
|
|
|
static void PropagateGrandancestorBit(nsStyleContext* aContext,
|
|
|
|
nsStyleContext* aContextInheritedFrom);
|
2010-04-27 16:15:01 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void* SetDefaultOnRoot(const nsStyleStructID aSID,
|
|
|
|
nsStyleContext* aContext);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2013-12-12 02:09:44 +00:00
|
|
|
/**
|
|
|
|
* Resolves any property values in aRuleData for a given style struct that
|
|
|
|
* have eCSSUnit_TokenStream values, by resolving them against the computed
|
|
|
|
* variable values on the style context and re-parsing the property.
|
|
|
|
*
|
|
|
|
* @return Whether any properties with eCSSUnit_TokenStream values were
|
|
|
|
* encountered.
|
|
|
|
*/
|
|
|
|
static bool ResolveVariableReferences(const nsStyleStructID aSID,
|
|
|
|
nsRuleData* aRuleData,
|
|
|
|
nsStyleContext* aContext);
|
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2011-03-18 03:14:31 +00:00
|
|
|
WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeDisplayData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeVisibilityData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeFontData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeColorData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeBackgroundData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeMarginData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeBorderData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputePaddingData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeOutlineData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeListData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputePositionData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeTableData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeTableBorderData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeContentData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeTextData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeTextResetData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeUserInterfaceData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext,
|
|
|
|
nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeUIResetData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeXULData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeColumnData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-06-17 11:57:37 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-06-17 11:57:37 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeSVGData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2004-05-12 21:20:09 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
const void*
|
2008-01-10 20:56:49 +00:00
|
|
|
ComputeSVGResetData(void* aStartStruct,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2004-05-12 21:20:09 +00:00
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
2009-02-04 21:24:18 +00:00
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2003-12-02 22:24:32 +00:00
|
|
|
|
2013-12-12 02:09:40 +00:00
|
|
|
const void*
|
|
|
|
ComputeVariablesData(void* aStartStruct,
|
|
|
|
const nsRuleData* aRuleData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
RuleDetail aRuleDetail,
|
2015-06-23 01:48:18 +00:00
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
2013-12-12 02:09:40 +00:00
|
|
|
|
2016-04-12 05:52:42 +00:00
|
|
|
const void*
|
|
|
|
ComputeEffectsData(void* aStartStruct,
|
|
|
|
const nsRuleData* aRuleData,
|
|
|
|
nsStyleContext* aContext, nsRuleNode* aHighestNode,
|
|
|
|
RuleDetail aRuleDetail,
|
|
|
|
const mozilla::RuleNodeCacheConditions aConditions);
|
|
|
|
|
2003-12-02 22:24:32 +00:00
|
|
|
// helpers for |ComputeFontData| that need access to |mNoneBits|:
|
2010-04-06 21:52:17 +00:00
|
|
|
static void SetFontSize(nsPresContext* aPresContext,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2010-04-06 21:52:17 +00:00
|
|
|
const nsStyleFont* aFont,
|
|
|
|
const nsStyleFont* aParentFont,
|
|
|
|
nscoord* aSize,
|
|
|
|
const nsFont& aSystemFont,
|
|
|
|
nscoord aParentSize,
|
|
|
|
nscoord aScriptLevelAdjustedParentSize,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aUsedStartStruct,
|
|
|
|
bool aAtRoot,
|
2015-06-23 01:48:18 +00:00
|
|
|
mozilla::RuleNodeCacheConditions& aConditions);
|
2010-04-06 21:52:17 +00:00
|
|
|
|
|
|
|
static void SetFont(nsPresContext* aPresContext,
|
|
|
|
nsStyleContext* aContext,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aGenericFontID,
|
2011-03-18 03:14:31 +00:00
|
|
|
const nsRuleData* aRuleData,
|
2010-04-06 21:52:17 +00:00
|
|
|
const nsStyleFont* aParentFont,
|
|
|
|
nsStyleFont* aFont,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aStartStruct,
|
2015-06-23 01:48:18 +00:00
|
|
|
mozilla::RuleNodeCacheConditions& aConditions);
|
2010-04-06 21:52:17 +00:00
|
|
|
|
|
|
|
static void SetGenericFont(nsPresContext* aPresContext,
|
|
|
|
nsStyleContext* aContext,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t aGenericFontID,
|
2010-04-06 21:52:17 +00:00
|
|
|
nsStyleFont* aFont);
|
|
|
|
|
2011-03-18 03:14:31 +00:00
|
|
|
inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID,
|
|
|
|
const nsRuleData* aRuleData);
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2010-04-06 21:52:17 +00:00
|
|
|
already_AddRefed<nsCSSShadowArray>
|
2010-08-19 19:33:44 +00:00
|
|
|
GetShadowData(const nsCSSValueList* aList,
|
2010-04-06 21:52:17 +00:00
|
|
|
nsStyleContext* aContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsBoxShadow,
|
2015-06-23 01:48:18 +00:00
|
|
|
mozilla::RuleNodeCacheConditions& aConditions);
|
2013-10-17 18:37:57 +00:00
|
|
|
bool SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter,
|
2013-08-05 07:02:27 +00:00
|
|
|
const nsCSSValue& aValue,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsPresContext* aPresContext,
|
2015-06-23 01:48:18 +00:00
|
|
|
mozilla::RuleNodeCacheConditions& aConditions);
|
2014-09-27 23:56:00 +00:00
|
|
|
void SetStyleClipPathToCSSValue(nsStyleClipPath* aStyleClipPath,
|
|
|
|
const nsCSSValue* aValue,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsPresContext* aPresContext,
|
2015-06-23 01:48:18 +00:00
|
|
|
mozilla::RuleNodeCacheConditions& aConditions);
|
2008-07-08 00:56:52 +00:00
|
|
|
|
2006-04-27 20:01:59 +00:00
|
|
|
private:
|
2007-05-16 21:08:51 +00:00
|
|
|
nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent,
|
2015-10-19 23:16:20 +00:00
|
|
|
nsIStyleRule* aRule, mozilla::SheetType aLevel, bool aIsImportant);
|
2010-04-06 21:52:17 +00:00
|
|
|
~nsRuleNode();
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2006-04-27 20:01:59 +00:00
|
|
|
public:
|
2015-06-04 06:45:11 +00:00
|
|
|
// This is infallible; it will never return nullptr.
|
2016-03-25 01:40:40 +00:00
|
|
|
static already_AddRefed<nsRuleNode> CreateRootNode(nsPresContext* aPresContext);
|
2014-02-15 18:42:35 +00:00
|
|
|
|
|
|
|
static void EnsureBlockDisplay(uint8_t& display,
|
|
|
|
bool aConvertListItem = false);
|
2014-07-23 02:08:13 +00:00
|
|
|
static void EnsureInlineDisplay(uint8_t& display);
|
2001-10-24 00:01:09 +00:00
|
|
|
|
2009-12-12 06:36:34 +00:00
|
|
|
// Transition never returns null; on out of memory it'll just return |this|.
|
2015-10-19 23:16:20 +00:00
|
|
|
nsRuleNode* Transition(nsIStyleRule* aRule, mozilla::SheetType aLevel,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsImportantRule);
|
2003-06-20 01:22:44 +00:00
|
|
|
nsRuleNode* GetParent() const { return mParent; }
|
2012-07-30 14:20:58 +00:00
|
|
|
bool IsRoot() const { return mParent == nullptr; }
|
2003-06-20 01:22:44 +00:00
|
|
|
|
2014-10-03 04:53:22 +00:00
|
|
|
// Return the root of the rule tree that this rule node is in.
|
|
|
|
nsRuleNode* RuleTree();
|
|
|
|
const nsRuleNode* RuleTree() const {
|
|
|
|
return const_cast<nsRuleNode*>(this)->RuleTree();
|
|
|
|
}
|
|
|
|
|
2015-10-19 23:16:20 +00:00
|
|
|
mozilla::SheetType GetLevel() const {
|
2007-05-16 21:08:51 +00:00
|
|
|
NS_ASSERTION(!IsRoot(), "can't call on root");
|
2015-10-19 23:16:20 +00:00
|
|
|
return mozilla::SheetType(
|
|
|
|
(mDependentBits & NS_RULE_NODE_LEVEL_MASK) >>
|
|
|
|
NS_RULE_NODE_LEVEL_SHIFT);
|
2007-05-16 21:08:51 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsImportantRule() const {
|
2007-05-16 21:08:51 +00:00
|
|
|
NS_ASSERTION(!IsRoot(), "can't call on root");
|
|
|
|
return (mDependentBits & NS_RULE_NODE_IS_IMPORTANT) != 0;
|
|
|
|
}
|
|
|
|
|
2012-11-07 19:55:53 +00:00
|
|
|
/**
|
|
|
|
* Has this rule node at some time in its lifetime been the mRuleNode
|
|
|
|
* of some style context (as opposed to only being the ancestor of
|
|
|
|
* some style context's mRuleNode)?
|
|
|
|
*/
|
2012-11-07 19:55:53 +00:00
|
|
|
void SetUsedDirectly();
|
2012-11-07 19:55:53 +00:00
|
|
|
bool IsUsedDirectly() const {
|
|
|
|
return (mDependentBits & NS_RULE_NODE_USED_DIRECTLY) != 0;
|
|
|
|
}
|
|
|
|
|
2015-07-27 06:43:44 +00:00
|
|
|
/**
|
|
|
|
* Is the mRule of this rule node an AnimValuesStyleRule?
|
|
|
|
*/
|
|
|
|
void SetIsAnimationRule() {
|
|
|
|
MOZ_ASSERT(!HaveChildren() ||
|
|
|
|
(mDependentBits & NS_RULE_NODE_IS_ANIMATION_RULE),
|
|
|
|
"SetIsAnimationRule must only set the IS_ANIMATION_RULE bit "
|
|
|
|
"before the rule node has children");
|
|
|
|
mDependentBits |= NS_RULE_NODE_IS_ANIMATION_RULE;
|
|
|
|
mNoneBits |= NS_RULE_NODE_HAS_ANIMATION_DATA;
|
|
|
|
}
|
|
|
|
bool IsAnimationRule() const {
|
|
|
|
return (mDependentBits & NS_RULE_NODE_IS_ANIMATION_RULE) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the mRule of this rule node or any of its ancestors an
|
|
|
|
* AnimValuesStyleRule?
|
|
|
|
*/
|
|
|
|
bool HasAnimationData() const {
|
|
|
|
return (mNoneBits & NS_RULE_NODE_HAS_ANIMATION_DATA) != 0;
|
|
|
|
}
|
|
|
|
|
2013-02-16 21:04:54 +00:00
|
|
|
// NOTE: Does not |AddRef|. Null only for the root.
|
2003-06-20 01:22:44 +00:00
|
|
|
nsIStyleRule* GetRule() const { return mRule; }
|
2013-02-16 21:04:54 +00:00
|
|
|
// NOTE: Does not |AddRef|. Never null.
|
|
|
|
nsPresContext* PresContext() const { return mPresContext; }
|
2001-10-24 06:25:08 +00:00
|
|
|
|
2010-04-27 16:15:01 +00:00
|
|
|
const void* GetStyleData(nsStyleStructID aSID,
|
2010-04-06 21:52:17 +00:00
|
|
|
nsStyleContext* aContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aComputeData);
|
2003-03-06 19:14:17 +00:00
|
|
|
|
2015-04-14 22:55:56 +00:00
|
|
|
|
|
|
|
// See comments in GetStyleData for an explanation of what the
|
|
|
|
// code below does.
|
2015-06-23 01:48:18 +00:00
|
|
|
#define STYLE_STRUCT_INHERITED(name_, checkdata_cb_) \
|
2015-04-14 22:55:56 +00:00
|
|
|
template<bool aComputeData> \
|
|
|
|
const nsStyle##name_* \
|
2015-10-20 03:42:29 +00:00
|
|
|
GetStyle##name_(nsStyleContext* aContext, uint64_t& aContextStyleBits) \
|
2015-04-14 22:55:56 +00:00
|
|
|
{ \
|
|
|
|
NS_ASSERTION(IsUsedDirectly(), \
|
|
|
|
"if we ever call this on rule nodes that aren't used " \
|
|
|
|
"directly, we should adjust handling of mDependentBits " \
|
|
|
|
"in some way."); \
|
2015-10-20 03:42:28 +00:00
|
|
|
MOZ_ASSERT(!ContextHasCachedData(aContext, eStyleStruct_##name_), \
|
|
|
|
"style context should not have cached data for struct"); \
|
2015-04-14 22:55:56 +00:00
|
|
|
\
|
|
|
|
const nsStyle##name_ *data; \
|
2015-07-27 06:43:44 +00:00
|
|
|
\
|
|
|
|
/* Never use cached data for animated style inside a pseudo-element; */ \
|
|
|
|
/* see comment on cacheability in AnimValuesStyleRule::MapRuleInfoInto */ \
|
|
|
|
if (!(HasAnimationData() && ParentHasPseudoElementData(aContext))) { \
|
|
|
|
data = mStyleData.GetStyle##name_(); \
|
2015-10-20 03:42:29 +00:00
|
|
|
if (data != nullptr) { \
|
|
|
|
/* For inherited structs, mark the struct (which will be set on */ \
|
|
|
|
/* the context by our caller) as not being owned by the context. */ \
|
|
|
|
/* Normally this would be aContext->AddStyleBit(), but aContext is */ \
|
|
|
|
/* an incomplete type here, so we work around that with a param. */ \
|
|
|
|
aContextStyleBits |= NS_STYLE_INHERIT_BIT(name_); \
|
|
|
|
/* Our caller will cache the data on the style context. */ \
|
2015-07-27 06:43:44 +00:00
|
|
|
return data; \
|
2015-10-20 03:42:29 +00:00
|
|
|
} \
|
2015-07-27 06:43:44 +00:00
|
|
|
} \
|
2015-04-14 22:55:56 +00:00
|
|
|
\
|
|
|
|
if (!aComputeData) \
|
|
|
|
return nullptr; \
|
|
|
|
\
|
|
|
|
data = static_cast<const nsStyle##name_ *> \
|
|
|
|
(WalkRuleTree(eStyleStruct_##name_, aContext)); \
|
|
|
|
\
|
|
|
|
MOZ_ASSERT(data, "should have aborted on out-of-memory"); \
|
|
|
|
return data; \
|
|
|
|
}
|
2015-06-23 01:48:18 +00:00
|
|
|
|
|
|
|
#define STYLE_STRUCT_RESET(name_, checkdata_cb_) \
|
|
|
|
template<bool aComputeData> \
|
|
|
|
const nsStyle##name_* \
|
2015-10-22 23:57:36 +00:00
|
|
|
GetStyle##name_(nsStyleContext* aContext) \
|
2015-06-23 01:48:18 +00:00
|
|
|
{ \
|
|
|
|
NS_ASSERTION(IsUsedDirectly(), \
|
|
|
|
"if we ever call this on rule nodes that aren't used " \
|
|
|
|
"directly, we should adjust handling of mDependentBits " \
|
|
|
|
"in some way."); \
|
2015-10-20 03:42:28 +00:00
|
|
|
MOZ_ASSERT(!ContextHasCachedData(aContext, eStyleStruct_##name_), \
|
|
|
|
"style context should not have cached data for struct"); \
|
2015-06-23 01:48:18 +00:00
|
|
|
\
|
|
|
|
const nsStyle##name_ *data; \
|
2015-07-27 06:43:44 +00:00
|
|
|
\
|
|
|
|
/* Never use cached data for animated style inside a pseudo-element; */ \
|
|
|
|
/* see comment on cacheability in AnimValuesStyleRule::MapRuleInfoInto */ \
|
|
|
|
if (!(HasAnimationData() && ParentHasPseudoElementData(aContext))) { \
|
2015-10-22 23:57:35 +00:00
|
|
|
data = mStyleData.GetStyle##name_(aContext, aComputeData); \
|
2015-10-20 03:42:29 +00:00
|
|
|
if (MOZ_LIKELY(data != nullptr)) { \
|
2015-07-27 06:43:44 +00:00
|
|
|
return data; \
|
2015-10-20 03:42:29 +00:00
|
|
|
} \
|
2015-07-27 06:43:44 +00:00
|
|
|
} \
|
2015-06-23 01:48:18 +00:00
|
|
|
\
|
|
|
|
if (!aComputeData) \
|
|
|
|
return nullptr; \
|
|
|
|
\
|
|
|
|
data = static_cast<const nsStyle##name_ *> \
|
|
|
|
(WalkRuleTree(eStyleStruct_##name_, aContext)); \
|
|
|
|
\
|
|
|
|
MOZ_ASSERT(data, "should have aborted on out-of-memory"); \
|
|
|
|
return data; \
|
|
|
|
}
|
|
|
|
|
2006-12-12 17:44:45 +00:00
|
|
|
#include "nsStyleStructList.h"
|
2015-06-23 01:48:18 +00:00
|
|
|
|
|
|
|
#undef STYLE_STRUCT_RESET
|
|
|
|
#undef STYLE_STRUCT_INHERITED
|
2006-12-12 17:44:45 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool
|
2009-06-16 22:05:12 +00:00
|
|
|
HasAuthorSpecifiedRules(nsStyleContext* aStyleContext,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t ruleTypeMask,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aAuthorColorsAllowed);
|
2008-07-26 16:14:48 +00:00
|
|
|
|
2015-03-31 22:05:54 +00:00
|
|
|
/**
|
|
|
|
* Fill in to aPropertiesOverridden all of the properties in aProperties
|
|
|
|
* that, for this rule node, have a declaration that is higher than the
|
|
|
|
* animation level in the CSS Cascade.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ComputePropertiesOverridingAnimation(
|
|
|
|
const nsTArray<nsCSSProperty>& aProperties,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsCSSPropertySet& aPropertiesOverridden);
|
|
|
|
|
2008-07-26 16:14:48 +00:00
|
|
|
// Expose this so media queries can use it
|
|
|
|
static nscoord CalcLengthWithInitialFont(nsPresContext* aPresContext,
|
|
|
|
const nsCSSValue& aValue);
|
2008-09-13 09:42:11 +00:00
|
|
|
// Expose this so nsTransformFunctions can use it.
|
|
|
|
static nscoord CalcLength(const nsCSSValue& aValue,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsPresContext* aPresContext,
|
2015-06-23 01:48:18 +00:00
|
|
|
mozilla::RuleNodeCacheConditions& aConditions);
|
2008-12-29 15:07:36 +00:00
|
|
|
|
2010-09-11 16:27:13 +00:00
|
|
|
struct ComputedCalc {
|
|
|
|
nscoord mLength;
|
|
|
|
float mPercent;
|
|
|
|
|
|
|
|
ComputedCalc(nscoord aLength, float aPercent)
|
|
|
|
: mLength(aLength), mPercent(aPercent) {}
|
|
|
|
};
|
|
|
|
static ComputedCalc
|
|
|
|
SpecifiedCalcToComputedCalc(const nsCSSValue& aValue,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsPresContext* aPresContext,
|
2015-06-23 01:48:18 +00:00
|
|
|
mozilla::RuleNodeCacheConditions& aConditions);
|
2010-09-11 16:27:13 +00:00
|
|
|
|
2010-07-03 04:18:55 +00:00
|
|
|
// Compute the value of an nsStyleCoord that IsCalcUnit().
|
|
|
|
// (Values that don't require aPercentageBasis should be handled
|
|
|
|
// inside nsRuleNode rather than through this API.)
|
|
|
|
static nscoord ComputeComputedCalc(const nsStyleCoord& aCoord,
|
|
|
|
nscoord aPercentageBasis);
|
|
|
|
|
2010-07-03 04:18:55 +00:00
|
|
|
// Compute the value of an nsStyleCoord that is either a coord, a
|
|
|
|
// percent, or a calc expression.
|
|
|
|
static nscoord ComputeCoordPercentCalc(const nsStyleCoord& aCoord,
|
2010-09-11 16:27:13 +00:00
|
|
|
nscoord aPercentageBasis);
|
2010-07-03 04:18:55 +00:00
|
|
|
|
2008-12-29 15:07:36 +00: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.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool TreeHasCachedData() const {
|
2008-12-29 15:07:36 +00:00
|
|
|
NS_ASSERTION(IsRoot(), "should only be called on root of rule tree");
|
|
|
|
return HaveChildren() || mStyleData.mInheritedData || mStyleData.mResetData;
|
|
|
|
}
|
2011-08-22 23:34:12 +00:00
|
|
|
|
2015-06-23 01:48:18 +00:00
|
|
|
// Note that this will return false if we have cached conditional
|
|
|
|
// style structs.
|
|
|
|
bool NodeHasCachedUnconditionalData(const nsStyleStructID aSID) {
|
2011-08-22 23:34:12 +00:00
|
|
|
return !!mStyleData.GetStyleData(aSID);
|
|
|
|
}
|
2012-04-26 06:24:26 +00:00
|
|
|
|
|
|
|
static void ComputeFontFeatures(const nsCSSValuePairList *aFeaturesList,
|
|
|
|
nsTArray<gfxFontFeature>& aFeatureSettings);
|
2012-05-31 04:39:46 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static nscoord CalcFontPointSize(int32_t aHTMLSize, int32_t aBasePointSize,
|
2012-05-31 04:39:46 +00:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsFontSizeType aFontSizeType = eFontSize_HTML);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static nscoord FindNextSmallerFontSize(nscoord aFontSize, int32_t aBasePointSize,
|
2012-05-31 04:39:46 +00:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsFontSizeType aFontSizeType = eFontSize_HTML);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static nscoord FindNextLargerFontSize(nscoord aFontSize, int32_t aBasePointSize,
|
2012-05-31 04:39:46 +00:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsFontSizeType aFontSizeType = eFontSize_HTML);
|
2012-06-06 07:36:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aValue The color value, returned from nsCSSParser::ParseColorString
|
|
|
|
* @param aPresContext Presentation context whose preferences are used
|
|
|
|
* for certain enumerated colors
|
|
|
|
* @param aStyleContext Style context whose color is used for 'currentColor'
|
|
|
|
*
|
|
|
|
* @note aPresContext and aStyleContext may be null, but in that case, fully
|
|
|
|
* opaque black will be returned for the values that rely on these
|
|
|
|
* objects to compute the color. (For example, -moz-hyperlinktext.)
|
|
|
|
*
|
|
|
|
* @return false if we fail to extract a color; this will not happen if both
|
|
|
|
* aPresContext and aStyleContext are non-null
|
|
|
|
*/
|
|
|
|
static bool ComputeColor(const nsCSSValue& aValue,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nscolor& aResult);
|
2015-07-27 06:43:44 +00:00
|
|
|
|
|
|
|
static bool ParentHasPseudoElementData(nsStyleContext* aContext);
|
2015-10-20 03:42:28 +00:00
|
|
|
|
2015-10-22 08:22:37 +00:00
|
|
|
static void ComputeTimingFunction(const nsCSSValue& aValue,
|
|
|
|
nsTimingFunction& aResult);
|
|
|
|
|
2015-10-20 03:42:28 +00:00
|
|
|
private:
|
|
|
|
#ifdef DEBUG
|
|
|
|
// non-inline helper function to allow assertions without incomplete
|
|
|
|
// type errors
|
|
|
|
bool ContextHasCachedData(nsStyleContext* aContext, nsStyleStructID aSID);
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|