Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* |
michael@0 | 7 | * a node in the lexicographic tree of rules that match an element, |
michael@0 | 8 | * responsible for converting the rules' information into computed style |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #ifndef nsRuleNode_h___ |
michael@0 | 12 | #define nsRuleNode_h___ |
michael@0 | 13 | |
michael@0 | 14 | #include "nsPresContext.h" |
michael@0 | 15 | #include "nsStyleStruct.h" |
michael@0 | 16 | |
michael@0 | 17 | #include <stdint.h> |
michael@0 | 18 | |
michael@0 | 19 | class nsStyleContext; |
michael@0 | 20 | struct nsRuleData; |
michael@0 | 21 | class nsIStyleRule; |
michael@0 | 22 | struct nsCSSValueList; |
michael@0 | 23 | |
michael@0 | 24 | class nsCSSValue; |
michael@0 | 25 | struct nsCSSRect; |
michael@0 | 26 | |
michael@0 | 27 | class nsStyleCoord; |
michael@0 | 28 | struct nsCSSValuePairList; |
michael@0 | 29 | |
michael@0 | 30 | template <nsStyleStructID MinIndex, nsStyleStructID Count> |
michael@0 | 31 | class FixedStyleStructArray |
michael@0 | 32 | { |
michael@0 | 33 | private: |
michael@0 | 34 | void* mArray[Count]; |
michael@0 | 35 | public: |
michael@0 | 36 | void*& operator[](nsStyleStructID aIndex) { |
michael@0 | 37 | NS_ABORT_IF_FALSE(MinIndex <= aIndex && aIndex < (MinIndex + Count), |
michael@0 | 38 | "out of range"); |
michael@0 | 39 | return mArray[aIndex - MinIndex]; |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | const void* operator[](nsStyleStructID aIndex) const { |
michael@0 | 43 | NS_ABORT_IF_FALSE(MinIndex <= aIndex && aIndex < (MinIndex + Count), |
michael@0 | 44 | "out of range"); |
michael@0 | 45 | return mArray[aIndex - MinIndex]; |
michael@0 | 46 | } |
michael@0 | 47 | }; |
michael@0 | 48 | |
michael@0 | 49 | struct nsInheritedStyleData |
michael@0 | 50 | { |
michael@0 | 51 | FixedStyleStructArray<nsStyleStructID_Inherited_Start, |
michael@0 | 52 | nsStyleStructID_Inherited_Count> mStyleStructs; |
michael@0 | 53 | |
michael@0 | 54 | void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW { |
michael@0 | 55 | return aContext->AllocateFromShell(sz); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | void DestroyStructs(uint64_t aBits, nsPresContext* aContext) { |
michael@0 | 59 | #define STYLE_STRUCT_INHERITED(name, checkdata_cb) \ |
michael@0 | 60 | void *name##Data = mStyleStructs[eStyleStruct_##name]; \ |
michael@0 | 61 | if (name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \ |
michael@0 | 62 | static_cast<nsStyle##name*>(name##Data)->Destroy(aContext); |
michael@0 | 63 | #define STYLE_STRUCT_RESET(name, checkdata_cb) |
michael@0 | 64 | |
michael@0 | 65 | #include "nsStyleStructList.h" |
michael@0 | 66 | |
michael@0 | 67 | #undef STYLE_STRUCT_INHERITED |
michael@0 | 68 | #undef STYLE_STRUCT_RESET |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | void Destroy(uint64_t aBits, nsPresContext* aContext) { |
michael@0 | 72 | DestroyStructs(aBits, aContext); |
michael@0 | 73 | aContext->FreeToShell(sizeof(nsInheritedStyleData), this); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | nsInheritedStyleData() { |
michael@0 | 77 | for (nsStyleStructID i = nsStyleStructID_Inherited_Start; |
michael@0 | 78 | i < nsStyleStructID_Inherited_Start + nsStyleStructID_Inherited_Count; |
michael@0 | 79 | i = nsStyleStructID(i + 1)) { |
michael@0 | 80 | mStyleStructs[i] = nullptr; |
michael@0 | 81 | } |
michael@0 | 82 | } |
michael@0 | 83 | }; |
michael@0 | 84 | |
michael@0 | 85 | struct nsResetStyleData |
michael@0 | 86 | { |
michael@0 | 87 | FixedStyleStructArray<nsStyleStructID_Reset_Start, |
michael@0 | 88 | nsStyleStructID_Reset_Count> mStyleStructs; |
michael@0 | 89 | |
michael@0 | 90 | nsResetStyleData() |
michael@0 | 91 | { |
michael@0 | 92 | for (nsStyleStructID i = nsStyleStructID_Reset_Start; |
michael@0 | 93 | i < nsStyleStructID_Reset_Start + nsStyleStructID_Reset_Count; |
michael@0 | 94 | i = nsStyleStructID(i + 1)) { |
michael@0 | 95 | mStyleStructs[i] = nullptr; |
michael@0 | 96 | } |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW { |
michael@0 | 100 | return aContext->AllocateFromShell(sz); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | void Destroy(uint64_t aBits, nsPresContext* aContext) { |
michael@0 | 104 | #define STYLE_STRUCT_RESET(name, checkdata_cb) \ |
michael@0 | 105 | void *name##Data = mStyleStructs[eStyleStruct_##name]; \ |
michael@0 | 106 | if (name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \ |
michael@0 | 107 | static_cast<nsStyle##name*>(name##Data)->Destroy(aContext); |
michael@0 | 108 | #define STYLE_STRUCT_INHERITED(name, checkdata_cb) |
michael@0 | 109 | |
michael@0 | 110 | #include "nsStyleStructList.h" |
michael@0 | 111 | |
michael@0 | 112 | #undef STYLE_STRUCT_RESET |
michael@0 | 113 | #undef STYLE_STRUCT_INHERITED |
michael@0 | 114 | |
michael@0 | 115 | aContext->FreeToShell(sizeof(nsResetStyleData), this); |
michael@0 | 116 | } |
michael@0 | 117 | }; |
michael@0 | 118 | |
michael@0 | 119 | struct nsCachedStyleData |
michael@0 | 120 | { |
michael@0 | 121 | nsInheritedStyleData* mInheritedData; |
michael@0 | 122 | nsResetStyleData* mResetData; |
michael@0 | 123 | |
michael@0 | 124 | static bool IsReset(const nsStyleStructID aSID) { |
michael@0 | 125 | NS_ABORT_IF_FALSE(0 <= aSID && aSID < nsStyleStructID_Length, |
michael@0 | 126 | "must be an inherited or reset SID"); |
michael@0 | 127 | return nsStyleStructID_Reset_Start <= aSID; |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | static bool IsInherited(const nsStyleStructID aSID) { |
michael@0 | 131 | return !IsReset(aSID); |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | static uint32_t GetBitForSID(const nsStyleStructID aSID) { |
michael@0 | 135 | return 1 << aSID; |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | void* NS_FASTCALL GetStyleData(const nsStyleStructID aSID) { |
michael@0 | 139 | if (IsReset(aSID)) { |
michael@0 | 140 | if (mResetData) { |
michael@0 | 141 | return mResetData->mStyleStructs[aSID]; |
michael@0 | 142 | } |
michael@0 | 143 | } else { |
michael@0 | 144 | if (mInheritedData) { |
michael@0 | 145 | return mInheritedData->mStyleStructs[aSID]; |
michael@0 | 146 | } |
michael@0 | 147 | } |
michael@0 | 148 | return nullptr; |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | void NS_FASTCALL SetStyleData(const nsStyleStructID aSID, |
michael@0 | 152 | nsPresContext *aPresContext, void *aData) { |
michael@0 | 153 | if (IsReset(aSID)) { |
michael@0 | 154 | if (!mResetData) { |
michael@0 | 155 | mResetData = new (aPresContext) nsResetStyleData; |
michael@0 | 156 | } |
michael@0 | 157 | mResetData->mStyleStructs[aSID] = aData; |
michael@0 | 158 | } else { |
michael@0 | 159 | if (!mInheritedData) { |
michael@0 | 160 | mInheritedData = new (aPresContext) nsInheritedStyleData; |
michael@0 | 161 | } |
michael@0 | 162 | mInheritedData->mStyleStructs[aSID] = aData; |
michael@0 | 163 | } |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | // Typesafe and faster versions of the above |
michael@0 | 167 | #define STYLE_STRUCT_INHERITED(name_, checkdata_cb_) \ |
michael@0 | 168 | nsStyle##name_ * NS_FASTCALL GetStyle##name_ () { \ |
michael@0 | 169 | return mInheritedData ? static_cast<nsStyle##name_*>( \ |
michael@0 | 170 | mInheritedData->mStyleStructs[eStyleStruct_##name_]) : nullptr; \ |
michael@0 | 171 | } |
michael@0 | 172 | #define STYLE_STRUCT_RESET(name_, checkdata_cb_) \ |
michael@0 | 173 | nsStyle##name_ * NS_FASTCALL GetStyle##name_ () { \ |
michael@0 | 174 | return mResetData ? static_cast<nsStyle##name_*>( \ |
michael@0 | 175 | mResetData->mStyleStructs[eStyleStruct_##name_]) : nullptr; \ |
michael@0 | 176 | } |
michael@0 | 177 | #include "nsStyleStructList.h" |
michael@0 | 178 | #undef STYLE_STRUCT_RESET |
michael@0 | 179 | #undef STYLE_STRUCT_INHERITED |
michael@0 | 180 | |
michael@0 | 181 | void Destroy(uint64_t aBits, nsPresContext* aContext) { |
michael@0 | 182 | if (mResetData) |
michael@0 | 183 | mResetData->Destroy(aBits, aContext); |
michael@0 | 184 | if (mInheritedData) |
michael@0 | 185 | mInheritedData->Destroy(aBits, aContext); |
michael@0 | 186 | mResetData = nullptr; |
michael@0 | 187 | mInheritedData = nullptr; |
michael@0 | 188 | } |
michael@0 | 189 | |
michael@0 | 190 | nsCachedStyleData() :mInheritedData(nullptr), mResetData(nullptr) {} |
michael@0 | 191 | ~nsCachedStyleData() {} |
michael@0 | 192 | }; |
michael@0 | 193 | |
michael@0 | 194 | /** |
michael@0 | 195 | * nsRuleNode is a node in a lexicographic tree (the "rule tree") |
michael@0 | 196 | * indexed by style rules (implementations of nsIStyleRule). |
michael@0 | 197 | * |
michael@0 | 198 | * The rule tree is owned by the nsStyleSet and is destroyed when the |
michael@0 | 199 | * presentation of the document goes away. It is garbage-collected |
michael@0 | 200 | * (using mark-and-sweep garbage collection) during the lifetime of the |
michael@0 | 201 | * document (when dynamic changes cause the destruction of enough style |
michael@0 | 202 | * contexts). Rule nodes are marked if they are pointed to by a style |
michael@0 | 203 | * context or one of their descendants is. |
michael@0 | 204 | * |
michael@0 | 205 | * An nsStyleContext, which represents the computed style data for an |
michael@0 | 206 | * element, points to an nsRuleNode. The path from the root of the rule |
michael@0 | 207 | * tree to the nsStyleContext's mRuleNode gives the list of the rules |
michael@0 | 208 | * matched, from least important in the cascading order to most |
michael@0 | 209 | * important in the cascading order. |
michael@0 | 210 | * |
michael@0 | 211 | * The reason for using a lexicographic tree is that it allows for |
michael@0 | 212 | * sharing of style data, which saves both memory (for storing the |
michael@0 | 213 | * computed style data) and time (for computing them). This sharing |
michael@0 | 214 | * depends on the computed style data being stored in structs (nsStyle*) |
michael@0 | 215 | * that contain only properties that are inherited by default |
michael@0 | 216 | * ("inherited structs") or structs that contain only properties that |
michael@0 | 217 | * are not inherited by default ("reset structs"). The optimization |
michael@0 | 218 | * depends on the normal case being that style rules specify relatively |
michael@0 | 219 | * few properties and even that elements generally have relatively few |
michael@0 | 220 | * properties specified. This allows sharing in the following ways: |
michael@0 | 221 | * 1. [mainly reset structs] When a style data struct will contain the |
michael@0 | 222 | * same computed value for any elements that match the same set of |
michael@0 | 223 | * rules (common for reset structs), it can be stored on the |
michael@0 | 224 | * nsRuleNode instead of on the nsStyleContext. |
michael@0 | 225 | * 2. [only? reset structs] When (1) occurs, and an nsRuleNode doesn't |
michael@0 | 226 | * have any rules that change the values in the struct, the |
michael@0 | 227 | * nsRuleNode can share that struct with its parent nsRuleNode. |
michael@0 | 228 | * 3. [mainly inherited structs] When an element doesn't match any |
michael@0 | 229 | * rules that change the value of a property (or, in the edge case, |
michael@0 | 230 | * when all the values specified are 'inherit'), the nsStyleContext |
michael@0 | 231 | * can use the same nsStyle* struct as its parent nsStyleContext. |
michael@0 | 232 | * |
michael@0 | 233 | * Since the data represented by an nsIStyleRule are immutable, the data |
michael@0 | 234 | * represented by an nsRuleNode are also immutable. |
michael@0 | 235 | */ |
michael@0 | 236 | |
michael@0 | 237 | enum nsFontSizeType { |
michael@0 | 238 | eFontSize_HTML = 1, |
michael@0 | 239 | eFontSize_CSS = 2 |
michael@0 | 240 | }; |
michael@0 | 241 | |
michael@0 | 242 | class nsRuleNode { |
michael@0 | 243 | public: |
michael@0 | 244 | enum RuleDetail { |
michael@0 | 245 | eRuleNone, // No props have been specified at all. |
michael@0 | 246 | eRulePartialReset, // At least one prop with a non-"inherit" value |
michael@0 | 247 | // has been specified. No props have been |
michael@0 | 248 | // specified with an "inherit" value. At least |
michael@0 | 249 | // one prop remains unspecified. |
michael@0 | 250 | eRulePartialMixed, // At least one prop with a non-"inherit" value |
michael@0 | 251 | // has been specified. Some props may also have |
michael@0 | 252 | // been specified with an "inherit" value. At |
michael@0 | 253 | // least one prop remains unspecified. |
michael@0 | 254 | eRulePartialInherited, // Only props with "inherit" values have |
michael@0 | 255 | // have been specified. At least one prop |
michael@0 | 256 | // remains unspecified. |
michael@0 | 257 | eRuleFullReset, // All props have been specified. None has an |
michael@0 | 258 | // "inherit" value. |
michael@0 | 259 | eRuleFullMixed, // All props have been specified. At least one has |
michael@0 | 260 | // a non-"inherit" value. |
michael@0 | 261 | eRuleFullInherited // All props have been specified with "inherit" |
michael@0 | 262 | // values. |
michael@0 | 263 | }; |
michael@0 | 264 | |
michael@0 | 265 | private: |
michael@0 | 266 | nsPresContext* const mPresContext; // Our pres context. |
michael@0 | 267 | |
michael@0 | 268 | nsRuleNode* const mParent; // A pointer to the parent node in the tree. |
michael@0 | 269 | // This enables us to walk backwards from the |
michael@0 | 270 | // most specific rule matched to the least |
michael@0 | 271 | // specific rule (which is the optimal order to |
michael@0 | 272 | // use for lookups of style properties. |
michael@0 | 273 | nsIStyleRule* const mRule; // [STRONG] A pointer to our specific rule. |
michael@0 | 274 | |
michael@0 | 275 | nsRuleNode* mNextSibling; // This value should be used only by the |
michael@0 | 276 | // parent, since the parent may store |
michael@0 | 277 | // children in a hash, which means this |
michael@0 | 278 | // pointer is not meaningful. Order of |
michael@0 | 279 | // siblings is also not meaningful. |
michael@0 | 280 | |
michael@0 | 281 | struct Key { |
michael@0 | 282 | nsIStyleRule* mRule; |
michael@0 | 283 | uint8_t mLevel; |
michael@0 | 284 | bool mIsImportantRule; |
michael@0 | 285 | |
michael@0 | 286 | Key(nsIStyleRule* aRule, uint8_t aLevel, bool aIsImportantRule) |
michael@0 | 287 | : mRule(aRule), mLevel(aLevel), mIsImportantRule(aIsImportantRule) |
michael@0 | 288 | {} |
michael@0 | 289 | |
michael@0 | 290 | bool operator==(const Key& aOther) const |
michael@0 | 291 | { |
michael@0 | 292 | return mRule == aOther.mRule && |
michael@0 | 293 | mLevel == aOther.mLevel && |
michael@0 | 294 | mIsImportantRule == aOther.mIsImportantRule; |
michael@0 | 295 | } |
michael@0 | 296 | |
michael@0 | 297 | bool operator!=(const Key& aOther) const |
michael@0 | 298 | { |
michael@0 | 299 | return !(*this == aOther); |
michael@0 | 300 | } |
michael@0 | 301 | }; |
michael@0 | 302 | |
michael@0 | 303 | static PLDHashNumber |
michael@0 | 304 | ChildrenHashHashKey(PLDHashTable *aTable, const void *aKey); |
michael@0 | 305 | |
michael@0 | 306 | static bool |
michael@0 | 307 | ChildrenHashMatchEntry(PLDHashTable *aTable, |
michael@0 | 308 | const PLDHashEntryHdr *aHdr, |
michael@0 | 309 | const void *aKey); |
michael@0 | 310 | |
michael@0 | 311 | static const PLDHashTableOps ChildrenHashOps; |
michael@0 | 312 | |
michael@0 | 313 | static PLDHashOperator |
michael@0 | 314 | EnqueueRuleNodeChildren(PLDHashTable *table, PLDHashEntryHdr *hdr, |
michael@0 | 315 | uint32_t number, void *arg); |
michael@0 | 316 | |
michael@0 | 317 | Key GetKey() const { |
michael@0 | 318 | return Key(mRule, GetLevel(), IsImportantRule()); |
michael@0 | 319 | } |
michael@0 | 320 | |
michael@0 | 321 | // The children of this node are stored in either a hashtable or list |
michael@0 | 322 | // that maps from rules to our nsRuleNode children. When matching |
michael@0 | 323 | // rules, we use this mapping to transition from node to node |
michael@0 | 324 | // (constructing new nodes as needed to flesh out the tree). |
michael@0 | 325 | |
michael@0 | 326 | union { |
michael@0 | 327 | void* asVoid; |
michael@0 | 328 | nsRuleNode* asList; |
michael@0 | 329 | PLDHashTable* asHash; |
michael@0 | 330 | } mChildren; // Accessed only through the methods below. |
michael@0 | 331 | |
michael@0 | 332 | enum { |
michael@0 | 333 | kTypeMask = 0x1, |
michael@0 | 334 | kListType = 0x0, |
michael@0 | 335 | kHashType = 0x1 |
michael@0 | 336 | }; |
michael@0 | 337 | enum { |
michael@0 | 338 | // Maximum to have in a list before converting to a hashtable. |
michael@0 | 339 | // XXX Need to optimize this. |
michael@0 | 340 | kMaxChildrenInList = 32 |
michael@0 | 341 | }; |
michael@0 | 342 | |
michael@0 | 343 | bool HaveChildren() const { |
michael@0 | 344 | return mChildren.asVoid != nullptr; |
michael@0 | 345 | } |
michael@0 | 346 | bool ChildrenAreHashed() { |
michael@0 | 347 | return (intptr_t(mChildren.asVoid) & kTypeMask) == kHashType; |
michael@0 | 348 | } |
michael@0 | 349 | nsRuleNode* ChildrenList() { |
michael@0 | 350 | return mChildren.asList; |
michael@0 | 351 | } |
michael@0 | 352 | nsRuleNode** ChildrenListPtr() { |
michael@0 | 353 | return &mChildren.asList; |
michael@0 | 354 | } |
michael@0 | 355 | PLDHashTable* ChildrenHash() { |
michael@0 | 356 | return (PLDHashTable*) (intptr_t(mChildren.asHash) & ~intptr_t(kTypeMask)); |
michael@0 | 357 | } |
michael@0 | 358 | void SetChildrenList(nsRuleNode *aList) { |
michael@0 | 359 | NS_ASSERTION(!(intptr_t(aList) & kTypeMask), |
michael@0 | 360 | "pointer not 2-byte aligned"); |
michael@0 | 361 | mChildren.asList = aList; |
michael@0 | 362 | } |
michael@0 | 363 | void SetChildrenHash(PLDHashTable *aHashtable) { |
michael@0 | 364 | NS_ASSERTION(!(intptr_t(aHashtable) & kTypeMask), |
michael@0 | 365 | "pointer not 2-byte aligned"); |
michael@0 | 366 | mChildren.asHash = (PLDHashTable*)(intptr_t(aHashtable) | kHashType); |
michael@0 | 367 | } |
michael@0 | 368 | void ConvertChildrenToHash(); |
michael@0 | 369 | |
michael@0 | 370 | nsCachedStyleData mStyleData; // Any data we cached on the rule node. |
michael@0 | 371 | |
michael@0 | 372 | uint32_t mDependentBits; // Used to cache the fact that we can look up |
michael@0 | 373 | // cached data under a parent rule. |
michael@0 | 374 | |
michael@0 | 375 | uint32_t mNoneBits; // Used to cache the fact that the branch to this |
michael@0 | 376 | // node specifies no non-inherited data for a |
michael@0 | 377 | // given struct type. (This usually implies that |
michael@0 | 378 | // the entire branch specifies no non-inherited |
michael@0 | 379 | // data, although not necessarily, if a |
michael@0 | 380 | // non-inherited value is overridden by an |
michael@0 | 381 | // explicit 'inherit' value.) For example, if an |
michael@0 | 382 | // entire rule branch specifies no color |
michael@0 | 383 | // information, then a bit will be set along every |
michael@0 | 384 | // rule node on that branch, so that you can break |
michael@0 | 385 | // out of the rule tree early and just inherit |
michael@0 | 386 | // from the parent style context. The presence of |
michael@0 | 387 | // this bit means we should just get inherited |
michael@0 | 388 | // data from the parent style context, and it is |
michael@0 | 389 | // never used for reset structs since their |
michael@0 | 390 | // Compute*Data functions don't initialize from |
michael@0 | 391 | // inherited data. |
michael@0 | 392 | |
michael@0 | 393 | // Reference count. This just counts the style contexts that reference this |
michael@0 | 394 | // rulenode. And children the rulenode has had. When this goes to 0 or |
michael@0 | 395 | // stops being 0, we notify the style set. |
michael@0 | 396 | // Note, in particular, that when a child is removed mRefCnt is NOT |
michael@0 | 397 | // decremented. This is on purpose; the notifications to the style set are |
michael@0 | 398 | // only used to determine when it's worth running GC on the ruletree, and |
michael@0 | 399 | // this setup makes it so we only count unused ruletree leaves for purposes |
michael@0 | 400 | // of deciding when to GC. We could more accurately count unused rulenodes |
michael@0 | 401 | // by releasing/addrefing our parent when our refcount transitions to or from |
michael@0 | 402 | // 0, but it doesn't seem worth it to do that. |
michael@0 | 403 | uint32_t mRefCnt; |
michael@0 | 404 | |
michael@0 | 405 | public: |
michael@0 | 406 | // Overloaded new operator. Initializes the memory to 0 and relies on an arena |
michael@0 | 407 | // (which comes from the presShell) to perform the allocation. |
michael@0 | 408 | void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW; |
michael@0 | 409 | void Destroy() { DestroyInternal(nullptr); } |
michael@0 | 410 | |
michael@0 | 411 | // Implemented in nsStyleSet.h, since it needs to know about nsStyleSet. |
michael@0 | 412 | inline void AddRef(); |
michael@0 | 413 | |
michael@0 | 414 | // Implemented in nsStyleSet.h, since it needs to know about nsStyleSet. |
michael@0 | 415 | inline void Release(); |
michael@0 | 416 | |
michael@0 | 417 | protected: |
michael@0 | 418 | void DestroyInternal(nsRuleNode ***aDestroyQueueTail); |
michael@0 | 419 | void PropagateDependentBit(nsStyleStructID aSID, nsRuleNode* aHighestNode, |
michael@0 | 420 | void* aStruct); |
michael@0 | 421 | void PropagateNoneBit(uint32_t aBit, nsRuleNode* aHighestNode); |
michael@0 | 422 | |
michael@0 | 423 | const void* SetDefaultOnRoot(const nsStyleStructID aSID, |
michael@0 | 424 | nsStyleContext* aContext); |
michael@0 | 425 | |
michael@0 | 426 | /** |
michael@0 | 427 | * Resolves any property values in aRuleData for a given style struct that |
michael@0 | 428 | * have eCSSUnit_TokenStream values, by resolving them against the computed |
michael@0 | 429 | * variable values on the style context and re-parsing the property. |
michael@0 | 430 | * |
michael@0 | 431 | * @return Whether any properties with eCSSUnit_TokenStream values were |
michael@0 | 432 | * encountered. |
michael@0 | 433 | */ |
michael@0 | 434 | static bool ResolveVariableReferences(const nsStyleStructID aSID, |
michael@0 | 435 | nsRuleData* aRuleData, |
michael@0 | 436 | nsStyleContext* aContext); |
michael@0 | 437 | |
michael@0 | 438 | const void* |
michael@0 | 439 | WalkRuleTree(const nsStyleStructID aSID, nsStyleContext* aContext); |
michael@0 | 440 | |
michael@0 | 441 | const void* |
michael@0 | 442 | ComputeDisplayData(void* aStartStruct, |
michael@0 | 443 | const nsRuleData* aRuleData, |
michael@0 | 444 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 445 | RuleDetail aRuleDetail, |
michael@0 | 446 | const bool aCanStoreInRuleTree); |
michael@0 | 447 | |
michael@0 | 448 | const void* |
michael@0 | 449 | ComputeVisibilityData(void* aStartStruct, |
michael@0 | 450 | const nsRuleData* aRuleData, |
michael@0 | 451 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 452 | RuleDetail aRuleDetail, |
michael@0 | 453 | const bool aCanStoreInRuleTree); |
michael@0 | 454 | |
michael@0 | 455 | const void* |
michael@0 | 456 | ComputeFontData(void* aStartStruct, |
michael@0 | 457 | const nsRuleData* aRuleData, |
michael@0 | 458 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 459 | RuleDetail aRuleDetail, |
michael@0 | 460 | const bool aCanStoreInRuleTree); |
michael@0 | 461 | |
michael@0 | 462 | const void* |
michael@0 | 463 | ComputeColorData(void* aStartStruct, |
michael@0 | 464 | const nsRuleData* aRuleData, |
michael@0 | 465 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 466 | RuleDetail aRuleDetail, |
michael@0 | 467 | const bool aCanStoreInRuleTree); |
michael@0 | 468 | |
michael@0 | 469 | const void* |
michael@0 | 470 | ComputeBackgroundData(void* aStartStruct, |
michael@0 | 471 | const nsRuleData* aRuleData, |
michael@0 | 472 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 473 | RuleDetail aRuleDetail, |
michael@0 | 474 | const bool aCanStoreInRuleTree); |
michael@0 | 475 | |
michael@0 | 476 | const void* |
michael@0 | 477 | ComputeMarginData(void* aStartStruct, |
michael@0 | 478 | const nsRuleData* aRuleData, |
michael@0 | 479 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 480 | RuleDetail aRuleDetail, |
michael@0 | 481 | const bool aCanStoreInRuleTree); |
michael@0 | 482 | |
michael@0 | 483 | const void* |
michael@0 | 484 | ComputeBorderData(void* aStartStruct, |
michael@0 | 485 | const nsRuleData* aRuleData, |
michael@0 | 486 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 487 | RuleDetail aRuleDetail, |
michael@0 | 488 | const bool aCanStoreInRuleTree); |
michael@0 | 489 | |
michael@0 | 490 | const void* |
michael@0 | 491 | ComputePaddingData(void* aStartStruct, |
michael@0 | 492 | const nsRuleData* aRuleData, |
michael@0 | 493 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 494 | RuleDetail aRuleDetail, |
michael@0 | 495 | const bool aCanStoreInRuleTree); |
michael@0 | 496 | |
michael@0 | 497 | const void* |
michael@0 | 498 | ComputeOutlineData(void* aStartStruct, |
michael@0 | 499 | const nsRuleData* aRuleData, |
michael@0 | 500 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 501 | RuleDetail aRuleDetail, |
michael@0 | 502 | const bool aCanStoreInRuleTree); |
michael@0 | 503 | |
michael@0 | 504 | const void* |
michael@0 | 505 | ComputeListData(void* aStartStruct, |
michael@0 | 506 | const nsRuleData* aRuleData, |
michael@0 | 507 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 508 | RuleDetail aRuleDetail, |
michael@0 | 509 | const bool aCanStoreInRuleTree); |
michael@0 | 510 | |
michael@0 | 511 | const void* |
michael@0 | 512 | ComputePositionData(void* aStartStruct, |
michael@0 | 513 | const nsRuleData* aRuleData, |
michael@0 | 514 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 515 | RuleDetail aRuleDetail, |
michael@0 | 516 | const bool aCanStoreInRuleTree); |
michael@0 | 517 | |
michael@0 | 518 | const void* |
michael@0 | 519 | ComputeTableData(void* aStartStruct, |
michael@0 | 520 | const nsRuleData* aRuleData, |
michael@0 | 521 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 522 | RuleDetail aRuleDetail, |
michael@0 | 523 | const bool aCanStoreInRuleTree); |
michael@0 | 524 | |
michael@0 | 525 | const void* |
michael@0 | 526 | ComputeTableBorderData(void* aStartStruct, |
michael@0 | 527 | const nsRuleData* aRuleData, |
michael@0 | 528 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 529 | RuleDetail aRuleDetail, |
michael@0 | 530 | const bool aCanStoreInRuleTree); |
michael@0 | 531 | |
michael@0 | 532 | const void* |
michael@0 | 533 | ComputeContentData(void* aStartStruct, |
michael@0 | 534 | const nsRuleData* aRuleData, |
michael@0 | 535 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 536 | RuleDetail aRuleDetail, |
michael@0 | 537 | const bool aCanStoreInRuleTree); |
michael@0 | 538 | |
michael@0 | 539 | const void* |
michael@0 | 540 | ComputeQuotesData(void* aStartStruct, |
michael@0 | 541 | const nsRuleData* aRuleData, |
michael@0 | 542 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 543 | RuleDetail aRuleDetail, |
michael@0 | 544 | const bool aCanStoreInRuleTree); |
michael@0 | 545 | |
michael@0 | 546 | const void* |
michael@0 | 547 | ComputeTextData(void* aStartStruct, |
michael@0 | 548 | const nsRuleData* aRuleData, |
michael@0 | 549 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 550 | RuleDetail aRuleDetail, |
michael@0 | 551 | const bool aCanStoreInRuleTree); |
michael@0 | 552 | |
michael@0 | 553 | const void* |
michael@0 | 554 | ComputeTextResetData(void* aStartStruct, |
michael@0 | 555 | const nsRuleData* aRuleData, |
michael@0 | 556 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 557 | RuleDetail aRuleDetail, |
michael@0 | 558 | const bool aCanStoreInRuleTree); |
michael@0 | 559 | |
michael@0 | 560 | const void* |
michael@0 | 561 | ComputeUserInterfaceData(void* aStartStruct, |
michael@0 | 562 | const nsRuleData* aRuleData, |
michael@0 | 563 | nsStyleContext* aContext, |
michael@0 | 564 | nsRuleNode* aHighestNode, |
michael@0 | 565 | RuleDetail aRuleDetail, |
michael@0 | 566 | const bool aCanStoreInRuleTree); |
michael@0 | 567 | |
michael@0 | 568 | const void* |
michael@0 | 569 | ComputeUIResetData(void* aStartStruct, |
michael@0 | 570 | const nsRuleData* aRuleData, |
michael@0 | 571 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 572 | RuleDetail aRuleDetail, |
michael@0 | 573 | const bool aCanStoreInRuleTree); |
michael@0 | 574 | |
michael@0 | 575 | const void* |
michael@0 | 576 | ComputeXULData(void* aStartStruct, |
michael@0 | 577 | const nsRuleData* aRuleData, |
michael@0 | 578 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 579 | RuleDetail aRuleDetail, |
michael@0 | 580 | const bool aCanStoreInRuleTree); |
michael@0 | 581 | |
michael@0 | 582 | const void* |
michael@0 | 583 | ComputeColumnData(void* aStartStruct, |
michael@0 | 584 | const nsRuleData* aRuleData, |
michael@0 | 585 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 586 | RuleDetail aRuleDetail, |
michael@0 | 587 | const bool aCanStoreInRuleTree); |
michael@0 | 588 | |
michael@0 | 589 | const void* |
michael@0 | 590 | ComputeSVGData(void* aStartStruct, |
michael@0 | 591 | const nsRuleData* aRuleData, |
michael@0 | 592 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 593 | RuleDetail aRuleDetail, |
michael@0 | 594 | const bool aCanStoreInRuleTree); |
michael@0 | 595 | |
michael@0 | 596 | const void* |
michael@0 | 597 | ComputeSVGResetData(void* aStartStruct, |
michael@0 | 598 | const nsRuleData* aRuleData, |
michael@0 | 599 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 600 | RuleDetail aRuleDetail, |
michael@0 | 601 | const bool aCanStoreInRuleTree); |
michael@0 | 602 | |
michael@0 | 603 | const void* |
michael@0 | 604 | ComputeVariablesData(void* aStartStruct, |
michael@0 | 605 | const nsRuleData* aRuleData, |
michael@0 | 606 | nsStyleContext* aContext, nsRuleNode* aHighestNode, |
michael@0 | 607 | RuleDetail aRuleDetail, |
michael@0 | 608 | const bool aCanStoreInRuleTree); |
michael@0 | 609 | |
michael@0 | 610 | // helpers for |ComputeFontData| that need access to |mNoneBits|: |
michael@0 | 611 | static void SetFontSize(nsPresContext* aPresContext, |
michael@0 | 612 | const nsRuleData* aRuleData, |
michael@0 | 613 | const nsStyleFont* aFont, |
michael@0 | 614 | const nsStyleFont* aParentFont, |
michael@0 | 615 | nscoord* aSize, |
michael@0 | 616 | const nsFont& aSystemFont, |
michael@0 | 617 | nscoord aParentSize, |
michael@0 | 618 | nscoord aScriptLevelAdjustedParentSize, |
michael@0 | 619 | bool aUsedStartStruct, |
michael@0 | 620 | bool aAtRoot, |
michael@0 | 621 | bool& aCanStoreInRuleTree); |
michael@0 | 622 | |
michael@0 | 623 | static void SetFont(nsPresContext* aPresContext, |
michael@0 | 624 | nsStyleContext* aContext, |
michael@0 | 625 | uint8_t aGenericFontID, |
michael@0 | 626 | const nsRuleData* aRuleData, |
michael@0 | 627 | const nsStyleFont* aParentFont, |
michael@0 | 628 | nsStyleFont* aFont, |
michael@0 | 629 | bool aStartStruct, |
michael@0 | 630 | bool& aCanStoreInRuleTree); |
michael@0 | 631 | |
michael@0 | 632 | static void SetGenericFont(nsPresContext* aPresContext, |
michael@0 | 633 | nsStyleContext* aContext, |
michael@0 | 634 | uint8_t aGenericFontID, |
michael@0 | 635 | nsStyleFont* aFont); |
michael@0 | 636 | |
michael@0 | 637 | void AdjustLogicalBoxProp(nsStyleContext* aContext, |
michael@0 | 638 | const nsCSSValue& aLTRSource, |
michael@0 | 639 | const nsCSSValue& aRTLSource, |
michael@0 | 640 | const nsCSSValue& aLTRLogicalValue, |
michael@0 | 641 | const nsCSSValue& aRTLLogicalValue, |
michael@0 | 642 | mozilla::css::Side aSide, |
michael@0 | 643 | nsCSSRect& aValueRect, |
michael@0 | 644 | bool& aCanStoreInRuleTree); |
michael@0 | 645 | |
michael@0 | 646 | inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, |
michael@0 | 647 | const nsRuleData* aRuleData); |
michael@0 | 648 | |
michael@0 | 649 | already_AddRefed<nsCSSShadowArray> |
michael@0 | 650 | GetShadowData(const nsCSSValueList* aList, |
michael@0 | 651 | nsStyleContext* aContext, |
michael@0 | 652 | bool aIsBoxShadow, |
michael@0 | 653 | bool& aCanStoreInRuleTree); |
michael@0 | 654 | bool SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, |
michael@0 | 655 | const nsCSSValue& aValue, |
michael@0 | 656 | nsStyleContext* aStyleContext, |
michael@0 | 657 | nsPresContext* aPresContext, |
michael@0 | 658 | bool& aCanStoreInRuleTree); |
michael@0 | 659 | |
michael@0 | 660 | private: |
michael@0 | 661 | nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent, |
michael@0 | 662 | nsIStyleRule* aRule, uint8_t aLevel, bool aIsImportant); |
michael@0 | 663 | ~nsRuleNode(); |
michael@0 | 664 | |
michael@0 | 665 | public: |
michael@0 | 666 | static nsRuleNode* CreateRootNode(nsPresContext* aPresContext); |
michael@0 | 667 | |
michael@0 | 668 | static void EnsureBlockDisplay(uint8_t& display, |
michael@0 | 669 | bool aConvertListItem = false); |
michael@0 | 670 | |
michael@0 | 671 | // Transition never returns null; on out of memory it'll just return |this|. |
michael@0 | 672 | nsRuleNode* Transition(nsIStyleRule* aRule, uint8_t aLevel, |
michael@0 | 673 | bool aIsImportantRule); |
michael@0 | 674 | nsRuleNode* GetParent() const { return mParent; } |
michael@0 | 675 | bool IsRoot() const { return mParent == nullptr; } |
michael@0 | 676 | |
michael@0 | 677 | // These uint8_ts are really nsStyleSet::sheetType values. |
michael@0 | 678 | uint8_t GetLevel() const { |
michael@0 | 679 | NS_ASSERTION(!IsRoot(), "can't call on root"); |
michael@0 | 680 | return (mDependentBits & NS_RULE_NODE_LEVEL_MASK) >> |
michael@0 | 681 | NS_RULE_NODE_LEVEL_SHIFT; |
michael@0 | 682 | } |
michael@0 | 683 | bool IsImportantRule() const { |
michael@0 | 684 | NS_ASSERTION(!IsRoot(), "can't call on root"); |
michael@0 | 685 | return (mDependentBits & NS_RULE_NODE_IS_IMPORTANT) != 0; |
michael@0 | 686 | } |
michael@0 | 687 | |
michael@0 | 688 | /** |
michael@0 | 689 | * Has this rule node at some time in its lifetime been the mRuleNode |
michael@0 | 690 | * of some style context (as opposed to only being the ancestor of |
michael@0 | 691 | * some style context's mRuleNode)? |
michael@0 | 692 | */ |
michael@0 | 693 | void SetUsedDirectly(); |
michael@0 | 694 | bool IsUsedDirectly() const { |
michael@0 | 695 | return (mDependentBits & NS_RULE_NODE_USED_DIRECTLY) != 0; |
michael@0 | 696 | } |
michael@0 | 697 | |
michael@0 | 698 | // NOTE: Does not |AddRef|. Null only for the root. |
michael@0 | 699 | nsIStyleRule* GetRule() const { return mRule; } |
michael@0 | 700 | // NOTE: Does not |AddRef|. Never null. |
michael@0 | 701 | nsPresContext* PresContext() const { return mPresContext; } |
michael@0 | 702 | |
michael@0 | 703 | const void* GetStyleData(nsStyleStructID aSID, |
michael@0 | 704 | nsStyleContext* aContext, |
michael@0 | 705 | bool aComputeData); |
michael@0 | 706 | |
michael@0 | 707 | #define STYLE_STRUCT(name_, checkdata_cb_) \ |
michael@0 | 708 | const nsStyle##name_* GetStyle##name_(nsStyleContext* aContext, \ |
michael@0 | 709 | bool aComputeData); |
michael@0 | 710 | #include "nsStyleStructList.h" |
michael@0 | 711 | #undef STYLE_STRUCT |
michael@0 | 712 | |
michael@0 | 713 | /* |
michael@0 | 714 | * Garbage collection. Mark walks up the tree, marking any unmarked |
michael@0 | 715 | * ancestors until it reaches a marked one. Sweep recursively sweeps |
michael@0 | 716 | * the children, destroys any that are unmarked, and clears marks, |
michael@0 | 717 | * returning true if the node on which it was called was destroyed. |
michael@0 | 718 | */ |
michael@0 | 719 | void Mark(); |
michael@0 | 720 | bool Sweep(); |
michael@0 | 721 | |
michael@0 | 722 | static bool |
michael@0 | 723 | HasAuthorSpecifiedRules(nsStyleContext* aStyleContext, |
michael@0 | 724 | uint32_t ruleTypeMask, |
michael@0 | 725 | bool aAuthorColorsAllowed); |
michael@0 | 726 | |
michael@0 | 727 | // Expose this so media queries can use it |
michael@0 | 728 | static nscoord CalcLengthWithInitialFont(nsPresContext* aPresContext, |
michael@0 | 729 | const nsCSSValue& aValue); |
michael@0 | 730 | // Expose this so nsTransformFunctions can use it. |
michael@0 | 731 | static nscoord CalcLength(const nsCSSValue& aValue, |
michael@0 | 732 | nsStyleContext* aStyleContext, |
michael@0 | 733 | nsPresContext* aPresContext, |
michael@0 | 734 | bool& aCanStoreInRuleTree); |
michael@0 | 735 | |
michael@0 | 736 | struct ComputedCalc { |
michael@0 | 737 | nscoord mLength; |
michael@0 | 738 | float mPercent; |
michael@0 | 739 | |
michael@0 | 740 | ComputedCalc(nscoord aLength, float aPercent) |
michael@0 | 741 | : mLength(aLength), mPercent(aPercent) {} |
michael@0 | 742 | }; |
michael@0 | 743 | static ComputedCalc |
michael@0 | 744 | SpecifiedCalcToComputedCalc(const nsCSSValue& aValue, |
michael@0 | 745 | nsStyleContext* aStyleContext, |
michael@0 | 746 | nsPresContext* aPresContext, |
michael@0 | 747 | bool& aCanStoreInRuleTree); |
michael@0 | 748 | |
michael@0 | 749 | // Compute the value of an nsStyleCoord that IsCalcUnit(). |
michael@0 | 750 | // (Values that don't require aPercentageBasis should be handled |
michael@0 | 751 | // inside nsRuleNode rather than through this API.) |
michael@0 | 752 | static nscoord ComputeComputedCalc(const nsStyleCoord& aCoord, |
michael@0 | 753 | nscoord aPercentageBasis); |
michael@0 | 754 | |
michael@0 | 755 | // Compute the value of an nsStyleCoord that is either a coord, a |
michael@0 | 756 | // percent, or a calc expression. |
michael@0 | 757 | static nscoord ComputeCoordPercentCalc(const nsStyleCoord& aCoord, |
michael@0 | 758 | nscoord aPercentageBasis); |
michael@0 | 759 | |
michael@0 | 760 | // Return whether the rule tree for which this node is the root has |
michael@0 | 761 | // cached data such that we need to do dynamic change handling for |
michael@0 | 762 | // changes that change the results of media queries or require |
michael@0 | 763 | // rebuilding all style data. |
michael@0 | 764 | bool TreeHasCachedData() const { |
michael@0 | 765 | NS_ASSERTION(IsRoot(), "should only be called on root of rule tree"); |
michael@0 | 766 | return HaveChildren() || mStyleData.mInheritedData || mStyleData.mResetData; |
michael@0 | 767 | } |
michael@0 | 768 | |
michael@0 | 769 | bool NodeHasCachedData(const nsStyleStructID aSID) { |
michael@0 | 770 | return !!mStyleData.GetStyleData(aSID); |
michael@0 | 771 | } |
michael@0 | 772 | |
michael@0 | 773 | static void ComputeFontFeatures(const nsCSSValuePairList *aFeaturesList, |
michael@0 | 774 | nsTArray<gfxFontFeature>& aFeatureSettings); |
michael@0 | 775 | |
michael@0 | 776 | static nscoord CalcFontPointSize(int32_t aHTMLSize, int32_t aBasePointSize, |
michael@0 | 777 | nsPresContext* aPresContext, |
michael@0 | 778 | nsFontSizeType aFontSizeType = eFontSize_HTML); |
michael@0 | 779 | |
michael@0 | 780 | static nscoord FindNextSmallerFontSize(nscoord aFontSize, int32_t aBasePointSize, |
michael@0 | 781 | nsPresContext* aPresContext, |
michael@0 | 782 | nsFontSizeType aFontSizeType = eFontSize_HTML); |
michael@0 | 783 | |
michael@0 | 784 | static nscoord FindNextLargerFontSize(nscoord aFontSize, int32_t aBasePointSize, |
michael@0 | 785 | nsPresContext* aPresContext, |
michael@0 | 786 | nsFontSizeType aFontSizeType = eFontSize_HTML); |
michael@0 | 787 | |
michael@0 | 788 | /** |
michael@0 | 789 | * @param aValue The color value, returned from nsCSSParser::ParseColorString |
michael@0 | 790 | * @param aPresContext Presentation context whose preferences are used |
michael@0 | 791 | * for certain enumerated colors |
michael@0 | 792 | * @param aStyleContext Style context whose color is used for 'currentColor' |
michael@0 | 793 | * |
michael@0 | 794 | * @note aPresContext and aStyleContext may be null, but in that case, fully |
michael@0 | 795 | * opaque black will be returned for the values that rely on these |
michael@0 | 796 | * objects to compute the color. (For example, -moz-hyperlinktext.) |
michael@0 | 797 | * |
michael@0 | 798 | * @return false if we fail to extract a color; this will not happen if both |
michael@0 | 799 | * aPresContext and aStyleContext are non-null |
michael@0 | 800 | */ |
michael@0 | 801 | static bool ComputeColor(const nsCSSValue& aValue, |
michael@0 | 802 | nsPresContext* aPresContext, |
michael@0 | 803 | nsStyleContext* aStyleContext, |
michael@0 | 804 | nscolor& aResult); |
michael@0 | 805 | }; |
michael@0 | 806 | |
michael@0 | 807 | #endif |