layout/style/nsStyleSet.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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 * the container for the style sheets that apply to a presentation, and
michael@0 8 * the internal API that the style system exposes for creating (and
michael@0 9 * potentially re-creating) style contexts
michael@0 10 */
michael@0 11
michael@0 12 #ifndef nsStyleSet_h_
michael@0 13 #define nsStyleSet_h_
michael@0 14
michael@0 15 #include "mozilla/Attributes.h"
michael@0 16 #include "mozilla/MemoryReporting.h"
michael@0 17
michael@0 18 #include "nsIStyleRuleProcessor.h"
michael@0 19 #include "nsCSSStyleSheet.h"
michael@0 20 #include "nsBindingManager.h"
michael@0 21 #include "nsRuleNode.h"
michael@0 22 #include "nsTArray.h"
michael@0 23 #include "nsCOMArray.h"
michael@0 24 #include "nsAutoPtr.h"
michael@0 25 #include "nsIStyleRule.h"
michael@0 26 #include "nsCSSPseudoElements.h"
michael@0 27 #include "gfxFontFeatures.h"
michael@0 28
michael@0 29 class nsCSSFontFaceRule;
michael@0 30 class nsCSSKeyframesRule;
michael@0 31 class nsCSSFontFeatureValuesRule;
michael@0 32 class nsCSSPageRule;
michael@0 33 class nsRuleWalker;
michael@0 34 struct ElementDependentRuleProcessorData;
michael@0 35 struct TreeMatchContext;
michael@0 36
michael@0 37 namespace mozilla {
michael@0 38 class EventStates;
michael@0 39 } // namespace mozilla
michael@0 40
michael@0 41 class nsEmptyStyleRule MOZ_FINAL : public nsIStyleRule
michael@0 42 {
michael@0 43 NS_DECL_ISUPPORTS
michael@0 44 virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
michael@0 45 #ifdef DEBUG
michael@0 46 virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
michael@0 47 #endif
michael@0 48 };
michael@0 49
michael@0 50 class nsInitialStyleRule MOZ_FINAL : public nsIStyleRule
michael@0 51 {
michael@0 52 NS_DECL_ISUPPORTS
michael@0 53 virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
michael@0 54 #ifdef DEBUG
michael@0 55 virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
michael@0 56 #endif
michael@0 57 };
michael@0 58
michael@0 59 class nsDisableTextZoomStyleRule MOZ_FINAL : public nsIStyleRule
michael@0 60 {
michael@0 61 NS_DECL_ISUPPORTS
michael@0 62 virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
michael@0 63 #ifdef DEBUG
michael@0 64 virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
michael@0 65 #endif
michael@0 66 };
michael@0 67
michael@0 68 // The style set object is created by the document viewer and ownership is
michael@0 69 // then handed off to the PresShell. Only the PresShell should delete a
michael@0 70 // style set.
michael@0 71
michael@0 72 class nsStyleSet
michael@0 73 {
michael@0 74 public:
michael@0 75 nsStyleSet();
michael@0 76
michael@0 77 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
michael@0 78
michael@0 79 void Init(nsPresContext *aPresContext);
michael@0 80
michael@0 81 nsRuleNode* GetRuleTree() { return mRuleTree; }
michael@0 82
michael@0 83 // enable / disable the Quirk style sheet
michael@0 84 void EnableQuirkStyleSheet(bool aEnable);
michael@0 85
michael@0 86 // get a style context for a non-pseudo frame.
michael@0 87 already_AddRefed<nsStyleContext>
michael@0 88 ResolveStyleFor(mozilla::dom::Element* aElement,
michael@0 89 nsStyleContext* aParentContext);
michael@0 90
michael@0 91 already_AddRefed<nsStyleContext>
michael@0 92 ResolveStyleFor(mozilla::dom::Element* aElement,
michael@0 93 nsStyleContext* aParentContext,
michael@0 94 TreeMatchContext& aTreeMatchContext);
michael@0 95
michael@0 96 // Get a style context (with the given parent) for the
michael@0 97 // sequence of style rules in the |aRules| array.
michael@0 98 already_AddRefed<nsStyleContext>
michael@0 99 ResolveStyleForRules(nsStyleContext* aParentContext,
michael@0 100 const nsTArray< nsCOMPtr<nsIStyleRule> > &aRules);
michael@0 101
michael@0 102 // used in ResolveStyleForRules below
michael@0 103 struct RuleAndLevel
michael@0 104 {
michael@0 105 nsIStyleRule* mRule;
michael@0 106 uint8_t mLevel;
michael@0 107 };
michael@0 108
michael@0 109 // Get a new style context for aElement for the rules in aRules
michael@0 110 // aRules is an array of rules and their levels in reverse order,
michael@0 111 // that is from the leaf-most to the root-most rule in the rule tree.
michael@0 112 already_AddRefed<nsStyleContext>
michael@0 113 ResolveStyleForRules(nsStyleContext* aParentContext,
michael@0 114 nsStyleContext* aOldStyle,
michael@0 115 const nsTArray<RuleAndLevel>& aRules);
michael@0 116
michael@0 117 // Get a style context that represents aBaseContext, but as though
michael@0 118 // it additionally matched the rules in the aRules array (in that
michael@0 119 // order, as more specific than any other rules).
michael@0 120 already_AddRefed<nsStyleContext>
michael@0 121 ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
michael@0 122 const nsCOMArray<nsIStyleRule> &aRules);
michael@0 123
michael@0 124 // Get a style context for a non-element (which no rules will match),
michael@0 125 // such as text nodes, placeholder frames, and the nsFirstLetterFrame
michael@0 126 // for everything after the first letter.
michael@0 127 //
michael@0 128 // Perhaps this should go away and we shouldn't even create style
michael@0 129 // contexts for such content nodes. However, not doing any rule
michael@0 130 // matching for them is a first step.
michael@0 131 already_AddRefed<nsStyleContext>
michael@0 132 ResolveStyleForNonElement(nsStyleContext* aParentContext);
michael@0 133
michael@0 134 // Get a style context for a pseudo-element. aParentElement must be
michael@0 135 // non-null. aPseudoID is the nsCSSPseudoElements::Type for the
michael@0 136 // pseudo-element. aPseudoElement must be non-null if the pseudo-element
michael@0 137 // type is one that allows user action pseudo-classes after it; otherwise,
michael@0 138 // it is ignored.
michael@0 139 already_AddRefed<nsStyleContext>
michael@0 140 ResolvePseudoElementStyle(mozilla::dom::Element* aParentElement,
michael@0 141 nsCSSPseudoElements::Type aType,
michael@0 142 nsStyleContext* aParentContext,
michael@0 143 mozilla::dom::Element* aPseudoElement);
michael@0 144
michael@0 145 // This functions just like ResolvePseudoElementStyle except that it will
michael@0 146 // return nullptr if there are no explicit style rules for that
michael@0 147 // pseudo element.
michael@0 148 already_AddRefed<nsStyleContext>
michael@0 149 ProbePseudoElementStyle(mozilla::dom::Element* aParentElement,
michael@0 150 nsCSSPseudoElements::Type aType,
michael@0 151 nsStyleContext* aParentContext);
michael@0 152 already_AddRefed<nsStyleContext>
michael@0 153 ProbePseudoElementStyle(mozilla::dom::Element* aParentElement,
michael@0 154 nsCSSPseudoElements::Type aType,
michael@0 155 nsStyleContext* aParentContext,
michael@0 156 TreeMatchContext& aTreeMatchContext,
michael@0 157 mozilla::dom::Element* aPseudoElement = nullptr);
michael@0 158
michael@0 159 // Get a style context for an anonymous box. aPseudoTag is the
michael@0 160 // pseudo-tag to use and must be non-null.
michael@0 161 already_AddRefed<nsStyleContext>
michael@0 162 ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, nsStyleContext* aParentContext);
michael@0 163
michael@0 164 #ifdef MOZ_XUL
michael@0 165 // Get a style context for a XUL tree pseudo. aPseudoTag is the
michael@0 166 // pseudo-tag to use and must be non-null. aParentContent must be
michael@0 167 // non-null. aComparator must be non-null.
michael@0 168 already_AddRefed<nsStyleContext>
michael@0 169 ResolveXULTreePseudoStyle(mozilla::dom::Element* aParentElement,
michael@0 170 nsIAtom* aPseudoTag,
michael@0 171 nsStyleContext* aParentContext,
michael@0 172 nsICSSPseudoComparator* aComparator);
michael@0 173 #endif
michael@0 174
michael@0 175 // Append all the currently-active font face rules to aArray. Return
michael@0 176 // true for success and false for failure.
michael@0 177 bool AppendFontFaceRules(nsPresContext* aPresContext,
michael@0 178 nsTArray<nsFontFaceRuleContainer>& aArray);
michael@0 179
michael@0 180 // Return the winning (in the cascade) @keyframes rule for the given name.
michael@0 181 nsCSSKeyframesRule* KeyframesRuleForName(nsPresContext* aPresContext,
michael@0 182 const nsString& aName);
michael@0 183
michael@0 184 // Fetch object for looking up font feature values
michael@0 185 already_AddRefed<gfxFontFeatureValueSet> GetFontFeatureValuesLookup();
michael@0 186
michael@0 187 // Append all the currently-active font feature values rules to aArray.
michael@0 188 // Return true for success and false for failure.
michael@0 189 bool AppendFontFeatureValuesRules(nsPresContext* aPresContext,
michael@0 190 nsTArray<nsCSSFontFeatureValuesRule*>& aArray);
michael@0 191
michael@0 192 // Append all the currently-active page rules to aArray. Return
michael@0 193 // true for success and false for failure.
michael@0 194 bool AppendPageRules(nsPresContext* aPresContext,
michael@0 195 nsTArray<nsCSSPageRule*>& aArray);
michael@0 196
michael@0 197 // Begin ignoring style context destruction, to avoid lots of unnecessary
michael@0 198 // work on document teardown.
michael@0 199 void BeginShutdown(nsPresContext* aPresContext);
michael@0 200
michael@0 201 // Free all of the data associated with this style set.
michael@0 202 void Shutdown(nsPresContext* aPresContext);
michael@0 203
michael@0 204 // Notification that a style context is being destroyed.
michael@0 205 void NotifyStyleContextDestroyed(nsPresContext* aPresContext,
michael@0 206 nsStyleContext* aStyleContext);
michael@0 207
michael@0 208 // Get a new style context that lives in a different parent
michael@0 209 // The new context will be the same as the old if the new parent is the
michael@0 210 // same as the old parent.
michael@0 211 // aElement should be non-null if this is a style context for an
michael@0 212 // element or pseudo-element; in the latter case it should be the
michael@0 213 // real element the pseudo-element is for.
michael@0 214 already_AddRefed<nsStyleContext>
michael@0 215 ReparentStyleContext(nsStyleContext* aStyleContext,
michael@0 216 nsStyleContext* aNewParentContext,
michael@0 217 mozilla::dom::Element* aElement);
michael@0 218
michael@0 219 // Test if style is dependent on a document state.
michael@0 220 bool HasDocumentStateDependentStyle(nsPresContext* aPresContext,
michael@0 221 nsIContent* aContent,
michael@0 222 mozilla::EventStates aStateMask);
michael@0 223
michael@0 224 // Test if style is dependent on content state
michael@0 225 nsRestyleHint HasStateDependentStyle(nsPresContext* aPresContext,
michael@0 226 mozilla::dom::Element* aElement,
michael@0 227 mozilla::EventStates aStateMask);
michael@0 228 nsRestyleHint HasStateDependentStyle(nsPresContext* aPresContext,
michael@0 229 mozilla::dom::Element* aElement,
michael@0 230 nsCSSPseudoElements::Type aPseudoType,
michael@0 231 mozilla::dom::Element* aPseudoElement,
michael@0 232 mozilla::EventStates aStateMask);
michael@0 233
michael@0 234 // Test if style is dependent on the presence of an attribute.
michael@0 235 nsRestyleHint HasAttributeDependentStyle(nsPresContext* aPresContext,
michael@0 236 mozilla::dom::Element* aElement,
michael@0 237 nsIAtom* aAttribute,
michael@0 238 int32_t aModType,
michael@0 239 bool aAttrHasChanged);
michael@0 240
michael@0 241 /*
michael@0 242 * Do any processing that needs to happen as a result of a change in
michael@0 243 * the characteristics of the medium, and return whether style rules
michael@0 244 * may have changed as a result.
michael@0 245 */
michael@0 246 bool MediumFeaturesChanged(nsPresContext* aPresContext);
michael@0 247
michael@0 248 // APIs for registering objects that can supply additional
michael@0 249 // rules during processing.
michael@0 250 void SetBindingManager(nsBindingManager* aBindingManager)
michael@0 251 {
michael@0 252 mBindingManager = aBindingManager;
michael@0 253 }
michael@0 254
michael@0 255 // The "origins" of the CSS cascade, from lowest precedence to
michael@0 256 // highest (for non-!important rules).
michael@0 257 enum sheetType {
michael@0 258 eAgentSheet, // CSS
michael@0 259 eUserSheet, // CSS
michael@0 260 ePresHintSheet,
michael@0 261 eDocSheet, // CSS
michael@0 262 eScopedDocSheet,
michael@0 263 eStyleAttrSheet,
michael@0 264 eOverrideSheet, // CSS
michael@0 265 eAnimationSheet,
michael@0 266 eTransitionSheet,
michael@0 267 eSheetTypeCount
michael@0 268 // be sure to keep the number of bits in |mDirty| below and in
michael@0 269 // NS_RULE_NODE_LEVEL_MASK updated when changing the number of sheet
michael@0 270 // types
michael@0 271 };
michael@0 272
michael@0 273 // APIs to manipulate the style sheet lists. The sheets in each
michael@0 274 // list are stored with the most significant sheet last.
michael@0 275 nsresult AppendStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
michael@0 276 nsresult PrependStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
michael@0 277 nsresult RemoveStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
michael@0 278 nsresult ReplaceSheets(sheetType aType,
michael@0 279 const nsCOMArray<nsIStyleSheet> &aNewSheets);
michael@0 280 nsresult InsertStyleSheetBefore(sheetType aType, nsIStyleSheet *aNewSheet,
michael@0 281 nsIStyleSheet *aReferenceSheet);
michael@0 282
michael@0 283 nsresult DirtyRuleProcessors(sheetType aType);
michael@0 284
michael@0 285 // Enable/Disable entire author style level (Doc, ScopedDoc & PresHint levels)
michael@0 286 bool GetAuthorStyleDisabled();
michael@0 287 nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
michael@0 288
michael@0 289 int32_t SheetCount(sheetType aType) const {
michael@0 290 return mSheets[aType].Count();
michael@0 291 }
michael@0 292
michael@0 293 nsIStyleSheet* StyleSheetAt(sheetType aType, int32_t aIndex) const {
michael@0 294 return mSheets[aType].ObjectAt(aIndex);
michael@0 295 }
michael@0 296
michael@0 297 nsresult RemoveDocStyleSheet(nsIStyleSheet* aSheet);
michael@0 298 nsresult AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument);
michael@0 299
michael@0 300 void BeginUpdate();
michael@0 301 nsresult EndUpdate();
michael@0 302
michael@0 303 // Methods for reconstructing the tree; BeginReconstruct basically moves the
michael@0 304 // old rule tree root and style context roots out of the way,
michael@0 305 // and EndReconstruct destroys the old rule tree when we're done
michael@0 306 nsresult BeginReconstruct();
michael@0 307 // Note: EndReconstruct should not be called if BeginReconstruct fails
michael@0 308 void EndReconstruct();
michael@0 309
michael@0 310 // Let the style set know that a particular sheet is the quirks sheet. This
michael@0 311 // sheet must already have been added to the UA sheets. The pointer must not
michael@0 312 // be null. This should only be called once for a given style set.
michael@0 313 void SetQuirkStyleSheet(nsIStyleSheet* aQuirkStyleSheet);
michael@0 314
michael@0 315 // Return whether the rule tree has cached data such that we need to
michael@0 316 // do dynamic change handling for changes that change the results of
michael@0 317 // media queries or require rebuilding all style data.
michael@0 318 // We don't care whether we have cached rule processors or whether
michael@0 319 // they have cached rule cascades; getting the rule cascades again in
michael@0 320 // order to do rule matching will get the correct rule cascade.
michael@0 321 bool HasCachedStyleData() const {
michael@0 322 return (mRuleTree && mRuleTree->TreeHasCachedData()) || !mRoots.IsEmpty();
michael@0 323 }
michael@0 324
michael@0 325 // Notify the style set that a rulenode is no longer in use, or was
michael@0 326 // just created and is not in use yet.
michael@0 327 void RuleNodeUnused() {
michael@0 328 ++mUnusedRuleNodeCount;
michael@0 329 }
michael@0 330
michael@0 331 // Notify the style set that a rulenode that wasn't in use now is
michael@0 332 void RuleNodeInUse() {
michael@0 333 --mUnusedRuleNodeCount;
michael@0 334 }
michael@0 335
michael@0 336 nsCSSStyleSheet::EnsureUniqueInnerResult EnsureUniqueInnerOnCSSSheets();
michael@0 337
michael@0 338 nsIStyleRule* InitialStyleRule();
michael@0 339
michael@0 340 private:
michael@0 341 nsStyleSet(const nsStyleSet& aCopy) MOZ_DELETE;
michael@0 342 nsStyleSet& operator=(const nsStyleSet& aCopy) MOZ_DELETE;
michael@0 343
michael@0 344 // Run mark-and-sweep GC on mRuleTree and mOldRuleTrees, based on mRoots.
michael@0 345 void GCRuleTrees();
michael@0 346
michael@0 347 // Update the rule processor list after a change to the style sheet list.
michael@0 348 nsresult GatherRuleProcessors(sheetType aType);
michael@0 349
michael@0 350 void AddImportantRules(nsRuleNode* aCurrLevelNode,
michael@0 351 nsRuleNode* aLastPrevLevelNode,
michael@0 352 nsRuleWalker* aRuleWalker);
michael@0 353
michael@0 354 // Move aRuleWalker forward by the appropriate rule if we need to add
michael@0 355 // a rule due to property restrictions on pseudo-elements.
michael@0 356 void WalkRestrictionRule(nsCSSPseudoElements::Type aPseudoType,
michael@0 357 nsRuleWalker* aRuleWalker);
michael@0 358
michael@0 359 void WalkDisableTextZoomRule(mozilla::dom::Element* aElement,
michael@0 360 nsRuleWalker* aRuleWalker);
michael@0 361
michael@0 362 #ifdef DEBUG
michael@0 363 // Just like AddImportantRules except it doesn't actually add anything; it
michael@0 364 // just asserts that there are no important rules between aCurrLevelNode and
michael@0 365 // aLastPrevLevelNode.
michael@0 366 void AssertNoImportantRules(nsRuleNode* aCurrLevelNode,
michael@0 367 nsRuleNode* aLastPrevLevelNode);
michael@0 368
michael@0 369 // Just like AddImportantRules except it doesn't actually add anything; it
michael@0 370 // just asserts that there are no CSS rules between aCurrLevelNode and
michael@0 371 // aLastPrevLevelNode. Mostly useful for the preshint level.
michael@0 372 void AssertNoCSSRules(nsRuleNode* aCurrLevelNode,
michael@0 373 nsRuleNode* aLastPrevLevelNode);
michael@0 374 #endif
michael@0 375
michael@0 376 // Enumerate the rules in a way that cares about the order of the
michael@0 377 // rules.
michael@0 378 // aElement is the element the rules are for. It might be null. aData
michael@0 379 // is the closure to pass to aCollectorFunc. If aContent is not null,
michael@0 380 // aData must be a RuleProcessorData*
michael@0 381 void FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
michael@0 382 RuleProcessorData* aData, mozilla::dom::Element* aElement,
michael@0 383 nsRuleWalker* aRuleWalker);
michael@0 384
michael@0 385 // Enumerate all the rules in a way that doesn't care about the order
michael@0 386 // of the rules and break out if the enumeration is halted.
michael@0 387 void WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
michael@0 388 ElementDependentRuleProcessorData* aData,
michael@0 389 bool aWalkAllXBLStylesheets);
michael@0 390
michael@0 391 /**
michael@0 392 * Bit-flags that can be passed to GetContext() in its parameter 'aFlags'.
michael@0 393 */
michael@0 394 enum {
michael@0 395 eNoFlags = 0,
michael@0 396 eIsLink = 1 << 0,
michael@0 397 eIsVisitedLink = 1 << 1,
michael@0 398 eDoAnimation = 1 << 2,
michael@0 399
michael@0 400 // Indicates that we should skip the flex-item-specific chunk of
michael@0 401 // ApplyStyleFixups(). This is useful if our parent has "display: flex"
michael@0 402 // but we can tell it's not going to actually be a flex container (e.g. if
michael@0 403 // it's the outer frame of a button widget, and we're the inline frame for
michael@0 404 // the button's label).
michael@0 405 eSkipFlexItemStyleFixup = 1 << 3
michael@0 406 };
michael@0 407
michael@0 408 already_AddRefed<nsStyleContext>
michael@0 409 GetContext(nsStyleContext* aParentContext,
michael@0 410 nsRuleNode* aRuleNode,
michael@0 411 nsRuleNode* aVisitedRuleNode,
michael@0 412 nsIAtom* aPseudoTag,
michael@0 413 nsCSSPseudoElements::Type aPseudoType,
michael@0 414 mozilla::dom::Element* aElementForAnimation,
michael@0 415 uint32_t aFlags);
michael@0 416
michael@0 417 nsPresContext* PresContext() { return mRuleTree->PresContext(); }
michael@0 418
michael@0 419 // The sheets in each array in mSheets are stored with the most significant
michael@0 420 // sheet last.
michael@0 421 // The arrays for ePresHintSheet, eStyleAttrSheet, eTransitionSheet,
michael@0 422 // and eAnimationSheet are always empty. (FIXME: We should reduce
michael@0 423 // the storage needed for them.)
michael@0 424 nsCOMArray<nsIStyleSheet> mSheets[eSheetTypeCount];
michael@0 425
michael@0 426 // mRuleProcessors[eScopedDocSheet] is always null; rule processors
michael@0 427 // for scoped style sheets are stored in mScopedDocSheetRuleProcessors.
michael@0 428 nsCOMPtr<nsIStyleRuleProcessor> mRuleProcessors[eSheetTypeCount];
michael@0 429
michael@0 430 // Rule processors for HTML5 scoped style sheets, one per scope.
michael@0 431 nsTArray<nsCOMPtr<nsIStyleRuleProcessor> > mScopedDocSheetRuleProcessors;
michael@0 432
michael@0 433 // cached instance for enabling/disabling
michael@0 434 nsCOMPtr<nsIStyleSheet> mQuirkStyleSheet;
michael@0 435
michael@0 436 nsRefPtr<nsBindingManager> mBindingManager;
michael@0 437
michael@0 438 nsRuleNode* mRuleTree; // This is the root of our rule tree. It is a
michael@0 439 // lexicographic tree of matched rules that style
michael@0 440 // contexts use to look up properties.
michael@0 441
michael@0 442 uint16_t mBatching;
michael@0 443
michael@0 444 unsigned mInShutdown : 1;
michael@0 445 unsigned mAuthorStyleDisabled: 1;
michael@0 446 unsigned mInReconstruct : 1;
michael@0 447 unsigned mInitFontFeatureValuesLookup : 1;
michael@0 448 unsigned mDirty : 9; // one dirty bit is used per sheet type
michael@0 449
michael@0 450 uint32_t mUnusedRuleNodeCount; // used to batch rule node GC
michael@0 451 nsTArray<nsStyleContext*> mRoots; // style contexts with no parent
michael@0 452
michael@0 453 // Empty style rules to force things that restrict which properties
michael@0 454 // apply into different branches of the rule tree.
michael@0 455 nsRefPtr<nsEmptyStyleRule> mFirstLineRule, mFirstLetterRule, mPlaceholderRule;
michael@0 456
michael@0 457 // Style rule which sets all properties to their initial values for
michael@0 458 // determining when context-sensitive values are in use.
michael@0 459 nsRefPtr<nsInitialStyleRule> mInitialStyleRule;
michael@0 460
michael@0 461 // Style rule that sets the internal -x-text-zoom property on
michael@0 462 // <svg:text> elements to disable the effect of text zooming.
michael@0 463 nsRefPtr<nsDisableTextZoomStyleRule> mDisableTextZoomStyleRule;
michael@0 464
michael@0 465 // Old rule trees, which should only be non-empty between
michael@0 466 // BeginReconstruct and EndReconstruct, but in case of bugs that cause
michael@0 467 // style contexts to exist too long, may last longer.
michael@0 468 nsTArray<nsRuleNode*> mOldRuleTrees;
michael@0 469
michael@0 470 // whether font feature values lookup object needs initialization
michael@0 471 nsRefPtr<gfxFontFeatureValueSet> mFontFeatureValuesLookup;
michael@0 472 };
michael@0 473
michael@0 474 #ifdef MOZILLA_INTERNAL_API
michael@0 475 inline
michael@0 476 void nsRuleNode::AddRef()
michael@0 477 {
michael@0 478 if (mRefCnt++ == 0 && !IsRoot()) {
michael@0 479 mPresContext->StyleSet()->RuleNodeInUse();
michael@0 480 }
michael@0 481 }
michael@0 482
michael@0 483 inline
michael@0 484 void nsRuleNode::Release()
michael@0 485 {
michael@0 486 if (--mRefCnt == 0 && !IsRoot()) {
michael@0 487 mPresContext->StyleSet()->RuleNodeUnused();
michael@0 488 }
michael@0 489 }
michael@0 490 #endif
michael@0 491
michael@0 492 #endif

mercurial