2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the container for the style sheets that apply to a presentation, and
|
|
|
|
* the internal API that the style system exposes for creating (and
|
|
|
|
* potentially re-creating) style contexts
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsStyleSet_h_
|
|
|
|
#define nsStyleSet_h_
|
|
|
|
|
2011-12-16 11:42:07 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIStyleRuleProcessor.h"
|
2009-12-31 07:56:33 -08:00
|
|
|
#include "nsCSSStyleSheet.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBindingManager.h"
|
|
|
|
#include "nsRuleNode.h"
|
2007-07-25 10:14:13 -07:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsCOMArray.h"
|
2008-11-25 15:22:38 -08:00
|
|
|
#include "nsAutoPtr.h"
|
2008-12-12 10:59:03 -08:00
|
|
|
#include "nsIStyleRule.h"
|
2009-12-10 23:37:40 -08:00
|
|
|
#include "nsCSSPseudoElements.h"
|
|
|
|
#include "nsCSSAnonBoxes.h"
|
2012-06-18 20:26:34 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIURI;
|
2008-11-25 15:22:38 -08:00
|
|
|
class nsCSSFontFaceRule;
|
2011-04-11 23:18:43 -07:00
|
|
|
class nsCSSKeyframesRule;
|
2012-08-31 14:21:28 -07:00
|
|
|
class nsCSSPageRule;
|
2009-08-01 08:53:40 -07:00
|
|
|
class nsRuleWalker;
|
2012-11-14 11:09:01 -08:00
|
|
|
struct ElementDependentRuleProcessorData;
|
2011-03-29 10:29:21 -07:00
|
|
|
struct TreeMatchContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-18 20:26:34 -07:00
|
|
|
class nsEmptyStyleRule MOZ_FINAL : public nsIStyleRule
|
2008-12-12 10:59:03 -08:00
|
|
|
{
|
|
|
|
NS_DECL_ISUPPORTS
|
2010-05-19 19:28:00 -07:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
|
2008-12-12 10:59:03 -08:00
|
|
|
#ifdef DEBUG
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2008-12-12 10:59:03 -08:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2012-06-18 20:26:34 -07:00
|
|
|
class nsInitialStyleRule MOZ_FINAL : public nsIStyleRule
|
2011-08-22 16:34:12 -07:00
|
|
|
{
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
|
|
|
|
#ifdef DEBUG
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2011-08-22 16:34:12 -07:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// The style set object is created by the document viewer and ownership is
|
|
|
|
// then handed off to the PresShell. Only the PresShell should delete a
|
|
|
|
// style set.
|
|
|
|
|
|
|
|
class nsStyleSet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsStyleSet();
|
|
|
|
|
2011-12-08 21:01:52 -08:00
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
2011-08-01 11:24:38 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Initialize the object. You must check the return code and not use
|
|
|
|
// the nsStyleSet if Init() fails.
|
|
|
|
|
|
|
|
nsresult Init(nsPresContext *aPresContext);
|
|
|
|
|
2009-01-29 20:39:23 -08:00
|
|
|
nsRuleNode* GetRuleTree() { return mRuleTree; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// enable / disable the Quirk style sheet
|
2011-09-28 23:19:26 -07:00
|
|
|
void EnableQuirkStyleSheet(bool aEnable);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// get a style context for a non-pseudo frame.
|
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 06:12:06 -07:00
|
|
|
ResolveStyleFor(mozilla::dom::Element* aElement,
|
|
|
|
nsStyleContext* aParentContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-29 10:29:21 -07:00
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolveStyleFor(mozilla::dom::Element* aElement,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
TreeMatchContext& aTreeMatchContext);
|
|
|
|
|
2010-04-02 18:58:25 -07:00
|
|
|
// Get a style context (with the given parent) for the
|
|
|
|
// sequence of style rules in the |aRules| array.
|
2007-07-25 11:21:34 -07:00
|
|
|
already_AddRefed<nsStyleContext>
|
2009-08-10 15:52:29 -07:00
|
|
|
ResolveStyleForRules(nsStyleContext* aParentContext,
|
2012-10-17 14:01:56 -07:00
|
|
|
const nsTArray< nsCOMPtr<nsIStyleRule> > &aRules);
|
2007-07-25 11:21:34 -07:00
|
|
|
|
2012-12-11 13:12:43 -08:00
|
|
|
// used in ResolveStyleForRules below
|
|
|
|
struct RuleAndLevel
|
|
|
|
{
|
|
|
|
nsIStyleRule* mRule;
|
|
|
|
uint8_t mLevel;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Get a new style context for aElement for the rules in aRules
|
|
|
|
// aRules is an array of rules and their levels in reverse order,
|
|
|
|
// that is from the leaf-most to the root-most rule in the rule tree.
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolveStyleForRules(nsStyleContext* aParentContext,
|
|
|
|
nsStyleContext* aOldStyle,
|
|
|
|
const nsTArray<RuleAndLevel>& aRules);
|
|
|
|
|
2010-04-02 18:58:25 -07:00
|
|
|
// Get a style context that represents aBaseContext, but as though
|
|
|
|
// it additionally matched the rules in the aRules array (in that
|
|
|
|
// order, as more specific than any other rules).
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
|
|
|
|
const nsCOMArray<nsIStyleRule> &aRules);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Get a style context for a non-element (which no rules will match),
|
|
|
|
// such as text nodes, placeholder frames, and the nsFirstLetterFrame
|
|
|
|
// for everything after the first letter.
|
|
|
|
//
|
|
|
|
// Perhaps this should go away and we shouldn't even create style
|
|
|
|
// contexts for such content nodes. However, not doing any rule
|
|
|
|
// matching for them is a first step.
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolveStyleForNonElement(nsStyleContext* aParentContext);
|
|
|
|
|
2010-04-30 06:12:06 -07:00
|
|
|
// Get a style context for a pseudo-element. aParentElement must be
|
2009-12-10 23:37:40 -08:00
|
|
|
// non-null. aPseudoID is the nsCSSPseudoElements::Type for the
|
|
|
|
// pseudo-element.
|
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 06:12:06 -07:00
|
|
|
ResolvePseudoElementStyle(mozilla::dom::Element* aParentElement,
|
2009-12-10 23:37:40 -08:00
|
|
|
nsCSSPseudoElements::Type aType,
|
2009-12-10 23:37:40 -08:00
|
|
|
nsStyleContext* aParentContext);
|
2009-12-10 23:37:40 -08:00
|
|
|
|
|
|
|
// This functions just like ResolvePseudoElementStyle except that it will
|
2012-07-30 07:20:58 -07:00
|
|
|
// return nullptr if there are no explicit style rules for that
|
2009-12-10 23:37:40 -08:00
|
|
|
// pseudo element.
|
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 06:12:06 -07:00
|
|
|
ProbePseudoElementStyle(mozilla::dom::Element* aParentElement,
|
2009-12-10 23:37:40 -08:00
|
|
|
nsCSSPseudoElements::Type aType,
|
|
|
|
nsStyleContext* aParentContext);
|
2011-03-29 10:29:21 -07:00
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ProbePseudoElementStyle(mozilla::dom::Element* aParentElement,
|
|
|
|
nsCSSPseudoElements::Type aType,
|
|
|
|
nsStyleContext* aParentContext,
|
|
|
|
TreeMatchContext& aTreeMatchContext);
|
2009-12-10 23:37:40 -08:00
|
|
|
|
|
|
|
// Get a style context for an anonymous box. aPseudoTag is the
|
|
|
|
// pseudo-tag to use and must be non-null.
|
|
|
|
already_AddRefed<nsStyleContext>
|
2009-12-10 23:37:40 -08:00
|
|
|
ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, nsStyleContext* aParentContext);
|
2009-12-10 23:37:40 -08:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
// Get a style context for a XUL tree pseudo. aPseudoTag is the
|
|
|
|
// pseudo-tag to use and must be non-null. aParentContent must be
|
|
|
|
// non-null. aComparator must be non-null.
|
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-30 06:12:06 -07:00
|
|
|
ResolveXULTreePseudoStyle(mozilla::dom::Element* aParentElement,
|
2009-12-10 23:37:40 -08:00
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsStyleContext* aParentContext,
|
2009-12-10 23:37:40 -08:00
|
|
|
nsICSSPseudoComparator* aComparator);
|
2009-12-10 23:37:40 -08:00
|
|
|
#endif
|
|
|
|
|
2008-11-25 15:22:38 -08:00
|
|
|
// Append all the currently-active font face rules to aArray. Return
|
|
|
|
// true for success and false for failure.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AppendFontFaceRules(nsPresContext* aPresContext,
|
2008-11-26 19:50:16 -08:00
|
|
|
nsTArray<nsFontFaceRuleContainer>& aArray);
|
2008-11-25 15:22:38 -08:00
|
|
|
|
2011-04-11 23:18:43 -07:00
|
|
|
// Append all the currently-active keyframes rules to aArray. Return
|
|
|
|
// true for success and false for failure.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AppendKeyframesRules(nsPresContext* aPresContext,
|
2011-04-11 23:18:43 -07:00
|
|
|
nsTArray<nsCSSKeyframesRule*>& aArray);
|
|
|
|
|
2012-08-31 14:21:28 -07:00
|
|
|
// Append all the currently-active page rules to aArray. Return
|
|
|
|
// true for success and false for failure.
|
|
|
|
bool AppendPageRules(nsPresContext* aPresContext,
|
|
|
|
nsTArray<nsCSSPageRule*>& aArray);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Begin ignoring style context destruction, to avoid lots of unnecessary
|
|
|
|
// work on document teardown.
|
|
|
|
void BeginShutdown(nsPresContext* aPresContext);
|
|
|
|
|
|
|
|
// Free all of the data associated with this style set.
|
|
|
|
void Shutdown(nsPresContext* aPresContext);
|
|
|
|
|
|
|
|
// Notification that a style context is being destroyed.
|
|
|
|
void NotifyStyleContextDestroyed(nsPresContext* aPresContext,
|
|
|
|
nsStyleContext* aStyleContext);
|
|
|
|
|
|
|
|
// Get a new style context that lives in a different parent
|
|
|
|
// The new context will be the same as the old if the new parent is the
|
|
|
|
// same as the old parent.
|
2010-06-22 21:46:27 -07:00
|
|
|
// aElement should be non-null if this is a style context for an
|
|
|
|
// element or pseudo-element; in the latter case it should be the
|
|
|
|
// real element the pseudo-element is for.
|
2007-03-22 10:30:00 -07:00
|
|
|
already_AddRefed<nsStyleContext>
|
2010-04-01 23:07:42 -07:00
|
|
|
ReparentStyleContext(nsStyleContext* aStyleContext,
|
2010-06-22 21:46:27 -07:00
|
|
|
nsStyleContext* aNewParentContext,
|
|
|
|
mozilla::dom::Element* aElement);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-17 10:10:57 -07:00
|
|
|
// Test if style is dependent on a document state.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasDocumentStateDependentStyle(nsPresContext* aPresContext,
|
2010-03-17 10:10:57 -07:00
|
|
|
nsIContent* aContent,
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates aStateMask);
|
2010-03-17 10:10:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Test if style is dependent on content state
|
2010-03-31 17:43:32 -07:00
|
|
|
nsRestyleHint HasStateDependentStyle(nsPresContext* aPresContext,
|
2010-05-14 10:04:51 -07:00
|
|
|
mozilla::dom::Element* aElement,
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates aStateMask);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Test if style is dependent on the presence of an attribute.
|
2010-03-31 17:43:32 -07:00
|
|
|
nsRestyleHint HasAttributeDependentStyle(nsPresContext* aPresContext,
|
2010-05-14 10:04:51 -07:00
|
|
|
mozilla::dom::Element* aElement,
|
2007-07-12 13:05:45 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAttrHasChanged);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-07-26 09:14:48 -07:00
|
|
|
/*
|
|
|
|
* Do any processing that needs to happen as a result of a change in
|
|
|
|
* the characteristics of the medium, and return whether style rules
|
|
|
|
* may have changed as a result.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool MediumFeaturesChanged(nsPresContext* aPresContext);
|
2008-07-26 09:14:48 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// APIs for registering objects that can supply additional
|
|
|
|
// rules during processing.
|
|
|
|
void SetBindingManager(nsBindingManager* aBindingManager)
|
|
|
|
{
|
|
|
|
mBindingManager = aBindingManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The "origins" of the CSS cascade, from lowest precedence to
|
|
|
|
// highest (for non-!important rules).
|
|
|
|
enum sheetType {
|
|
|
|
eAgentSheet, // CSS
|
|
|
|
eUserSheet, // CSS
|
2011-01-14 18:14:41 -08:00
|
|
|
ePresHintSheet,
|
2007-03-22 10:30:00 -07:00
|
|
|
eDocSheet, // CSS
|
|
|
|
eStyleAttrSheet,
|
|
|
|
eOverrideSheet, // CSS
|
2011-04-11 23:18:44 -07:00
|
|
|
eAnimationSheet,
|
2011-04-30 15:16:19 -07:00
|
|
|
eTransitionSheet,
|
2007-03-22 10:30:00 -07:00
|
|
|
eSheetTypeCount
|
2007-05-16 14:08:51 -07:00
|
|
|
// be sure to keep the number of bits in |mDirty| below and in
|
|
|
|
// NS_RULE_NODE_LEVEL_MASK updated when changing the number of sheet
|
|
|
|
// types
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// APIs to manipulate the style sheet lists. The sheets in each
|
|
|
|
// list are stored with the most significant sheet last.
|
|
|
|
nsresult AppendStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
|
|
|
|
nsresult PrependStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
|
|
|
|
nsresult RemoveStyleSheet(sheetType aType, nsIStyleSheet *aSheet);
|
|
|
|
nsresult ReplaceSheets(sheetType aType,
|
|
|
|
const nsCOMArray<nsIStyleSheet> &aNewSheets);
|
2012-10-29 04:21:15 -07:00
|
|
|
nsresult InsertStyleSheetBefore(sheetType aType, nsIStyleSheet *aNewSheet,
|
|
|
|
nsIStyleSheet *aReferenceSheet);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-08 00:36:21 -08:00
|
|
|
// Enable/Disable entire author style level (Doc & PresHint levels)
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetAuthorStyleDisabled();
|
|
|
|
nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t SheetCount(sheetType aType) const {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mSheets[aType].Count();
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIStyleSheet* StyleSheetAt(sheetType aType, int32_t aIndex) const {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mSheets[aType].ObjectAt(aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument);
|
|
|
|
|
|
|
|
void BeginUpdate();
|
|
|
|
nsresult EndUpdate();
|
|
|
|
|
2007-07-25 10:14:13 -07:00
|
|
|
// Methods for reconstructing the tree; BeginReconstruct basically moves the
|
|
|
|
// old rule tree root and style context roots out of the way,
|
|
|
|
// and EndReconstruct destroys the old rule tree when we're done
|
|
|
|
nsresult BeginReconstruct();
|
|
|
|
// Note: EndReconstruct should not be called if BeginReconstruct fails
|
|
|
|
void EndReconstruct();
|
|
|
|
|
2008-11-02 18:29:51 -08:00
|
|
|
// Let the style set know that a particular sheet is the quirks sheet. This
|
|
|
|
// sheet must already have been added to the UA sheets. The pointer must not
|
|
|
|
// be null. This should only be called once for a given style set.
|
|
|
|
void SetQuirkStyleSheet(nsIStyleSheet* aQuirkStyleSheet);
|
2008-12-29 07:07:36 -08:00
|
|
|
|
|
|
|
// Return whether the rule tree 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.
|
|
|
|
// We don't care whether we have cached rule processors or whether
|
|
|
|
// they have cached rule cascades; getting the rule cascades again in
|
|
|
|
// order to do rule matching will get the correct rule cascade.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasCachedStyleData() const {
|
2008-12-29 07:07:36 -08:00
|
|
|
return (mRuleTree && mRuleTree->TreeHasCachedData()) || !mRoots.IsEmpty();
|
|
|
|
}
|
2009-09-24 10:59:43 -07:00
|
|
|
|
|
|
|
// Notify the style set that a rulenode is no longer in use, or was
|
|
|
|
// just created and is not in use yet.
|
|
|
|
void RuleNodeUnused() {
|
|
|
|
++mUnusedRuleNodeCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify the style set that a rulenode that wasn't in use now is
|
|
|
|
void RuleNodeInUse() {
|
|
|
|
--mUnusedRuleNodeCount;
|
|
|
|
}
|
2009-12-31 07:56:33 -08:00
|
|
|
|
|
|
|
nsCSSStyleSheet::EnsureUniqueInnerResult EnsureUniqueInnerOnCSSSheets();
|
|
|
|
|
2011-08-22 16:34:12 -07:00
|
|
|
nsIStyleRule* InitialStyleRule();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2011-12-16 11:42:07 -08:00
|
|
|
nsStyleSet(const nsStyleSet& aCopy) MOZ_DELETE;
|
|
|
|
nsStyleSet& operator=(const nsStyleSet& aCopy) MOZ_DELETE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-29 20:39:23 -08:00
|
|
|
// Run mark-and-sweep GC on mRuleTree and mOldRuleTrees, based on mRoots.
|
|
|
|
void GCRuleTrees();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Update the rule processor list after a change to the style sheet list.
|
|
|
|
nsresult GatherRuleProcessors(sheetType aType);
|
|
|
|
|
|
|
|
void AddImportantRules(nsRuleNode* aCurrLevelNode,
|
2009-10-02 14:06:42 -07:00
|
|
|
nsRuleNode* aLastPrevLevelNode,
|
|
|
|
nsRuleWalker* aRuleWalker);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-10-02 14:06:42 -07:00
|
|
|
// Move aRuleWalker forward by the appropriate rule if we need to add
|
2008-12-12 10:59:03 -08:00
|
|
|
// a rule due to property restrictions on pseudo-elements.
|
2009-12-10 23:37:40 -08:00
|
|
|
void WalkRestrictionRule(nsCSSPseudoElements::Type aPseudoType,
|
2009-10-02 14:06:42 -07:00
|
|
|
nsRuleWalker* aRuleWalker);
|
2008-12-12 10:59:03 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Just like AddImportantRules except it doesn't actually add anything; it
|
|
|
|
// just asserts that there are no important rules between aCurrLevelNode and
|
|
|
|
// aLastPrevLevelNode.
|
|
|
|
void AssertNoImportantRules(nsRuleNode* aCurrLevelNode,
|
|
|
|
nsRuleNode* aLastPrevLevelNode);
|
|
|
|
|
|
|
|
// Just like AddImportantRules except it doesn't actually add anything; it
|
|
|
|
// just asserts that there are no CSS rules between aCurrLevelNode and
|
2011-01-14 18:14:41 -08:00
|
|
|
// aLastPrevLevelNode. Mostly useful for the preshint level.
|
2007-03-22 10:30:00 -07:00
|
|
|
void AssertNoCSSRules(nsRuleNode* aCurrLevelNode,
|
|
|
|
nsRuleNode* aLastPrevLevelNode);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Enumerate the rules in a way that cares about the order of the
|
|
|
|
// rules.
|
2013-01-08 15:25:47 -08:00
|
|
|
// aElement is the element the rules are for. It might be null. aData
|
2009-12-10 23:37:40 -08:00
|
|
|
// is the closure to pass to aCollectorFunc. If aContent is not null,
|
|
|
|
// aData must be a RuleProcessorData*
|
2007-03-22 10:30:00 -07:00
|
|
|
void FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
2013-01-08 15:25:47 -08:00
|
|
|
RuleProcessorData* aData, mozilla::dom::Element* aElement,
|
2012-11-14 11:09:01 -08:00
|
|
|
nsRuleWalker* aRuleWalker);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Enumerate all the rules in a way that doesn't care about the order
|
|
|
|
// of the rules and break out if the enumeration is halted.
|
|
|
|
void WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
|
2012-11-14 11:09:01 -08:00
|
|
|
ElementDependentRuleProcessorData* aData,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aWalkAllXBLStylesheets);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-01 23:07:42 -07:00
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
GetContext(nsStyleContext* aParentContext,
|
|
|
|
nsRuleNode* aRuleNode,
|
2010-04-02 18:58:27 -07:00
|
|
|
nsRuleNode* aVisitedRuleNode,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsLink,
|
|
|
|
bool aIsVisitedLink,
|
2010-04-01 23:07:42 -07:00
|
|
|
nsIAtom* aPseudoTag,
|
2011-04-11 23:18:44 -07:00
|
|
|
nsCSSPseudoElements::Type aPseudoType,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDoAnimation,
|
2011-04-11 23:18:44 -07:00
|
|
|
mozilla::dom::Element* aElementForAnimation);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsPresContext* PresContext() { return mRuleTree->GetPresContext(); }
|
|
|
|
|
|
|
|
// The sheets in each array in mSheets are stored with the most significant
|
|
|
|
// sheet last.
|
|
|
|
nsCOMArray<nsIStyleSheet> mSheets[eSheetTypeCount];
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStyleRuleProcessor> mRuleProcessors[eSheetTypeCount];
|
|
|
|
|
|
|
|
// cached instance for enabling/disabling
|
|
|
|
nsCOMPtr<nsIStyleSheet> mQuirkStyleSheet;
|
|
|
|
|
|
|
|
nsRefPtr<nsBindingManager> mBindingManager;
|
|
|
|
|
|
|
|
nsRuleNode* mRuleTree; // This is the root of our rule tree. It is a
|
|
|
|
// lexicographic tree of matched rules that style
|
|
|
|
// contexts use to look up properties.
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t mBatching;
|
2012-04-17 12:22:49 -07:00
|
|
|
|
|
|
|
unsigned mInShutdown : 1;
|
|
|
|
unsigned mAuthorStyleDisabled: 1;
|
|
|
|
unsigned mInReconstruct : 1;
|
2013-01-08 00:36:21 -08:00
|
|
|
unsigned mDirty : 8; // one dirty bit is used per sheet type
|
2012-04-17 12:22:49 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mUnusedRuleNodeCount; // used to batch rule node GC
|
2007-07-25 10:14:13 -07:00
|
|
|
nsTArray<nsStyleContext*> mRoots; // style contexts with no parent
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-12-12 10:59:03 -08:00
|
|
|
// Empty style rules to force things that restrict which properties
|
|
|
|
// apply into different branches of the rule tree.
|
2012-11-09 02:25:52 -08:00
|
|
|
nsRefPtr<nsEmptyStyleRule> mFirstLineRule, mFirstLetterRule, mPlaceholderRule;
|
2008-12-12 10:59:03 -08:00
|
|
|
|
2011-08-22 16:34:12 -07:00
|
|
|
// Style rule which sets all properties to their initial values for
|
|
|
|
// determining when context-sensitive values are in use.
|
|
|
|
nsRefPtr<nsInitialStyleRule> mInitialStyleRule;
|
|
|
|
|
2009-01-29 20:39:23 -08:00
|
|
|
// Old rule trees, which should only be non-empty between
|
|
|
|
// BeginReconstruct and EndReconstruct, but in case of bugs that cause
|
|
|
|
// style contexts to exist too long, may last longer.
|
|
|
|
nsTArray<nsRuleNode*> mOldRuleTrees;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2010-04-19 08:41:39 -07:00
|
|
|
#ifdef _IMPL_NS_LAYOUT
|
2009-09-24 10:59:43 -07:00
|
|
|
inline
|
2010-04-06 14:52:17 -07:00
|
|
|
void nsRuleNode::AddRef()
|
2009-09-24 10:59:43 -07:00
|
|
|
{
|
|
|
|
if (mRefCnt++ == 0 && !IsRoot()) {
|
|
|
|
mPresContext->StyleSet()->RuleNodeInUse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2010-04-06 14:52:17 -07:00
|
|
|
void nsRuleNode::Release()
|
2009-09-24 10:59:43 -07:00
|
|
|
{
|
|
|
|
if (--mRefCnt == 0 && !IsRoot()) {
|
|
|
|
mPresContext->StyleSet()->RuleNodeUnused();
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2010-04-19 08:41:39 -07:00
|
|
|
|
|
|
|
#endif
|