2004-01-08 01:30:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2004-01-08 01:30:53 +03:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2004-01-08 01:30:53 +03:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2004-01-08 01:30:53 +03:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
|
|
|
* Brian Ryner <bryner@brianryner.com>
|
2008-07-26 20:14:48 +04:00
|
|
|
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
|
2004-01-08 01:30:53 +03:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2004-01-08 01:30:53 +03:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2004-01-08 01:30:53 +03:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2004-01-08 01:30:53 +03:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2006-03-25 08:47:31 +03: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
|
|
|
|
*/
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
#ifndef nsStyleSet_h_
|
|
|
|
#define nsStyleSet_h_
|
|
|
|
|
|
|
|
#include "nsIStyleRuleProcessor.h"
|
2009-12-31 18:56:33 +03:00
|
|
|
#include "nsCSSStyleSheet.h"
|
2007-02-17 02:02:08 +03:00
|
|
|
#include "nsBindingManager.h"
|
2004-01-08 01:30:53 +03:00
|
|
|
#include "nsRuleNode.h"
|
2007-07-25 21:14:13 +04:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsCOMArray.h"
|
2008-11-26 02:22:38 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2008-12-12 21:59:03 +03:00
|
|
|
#include "nsIStyleRule.h"
|
2009-12-11 10:37:40 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
|
|
|
#include "nsCSSAnonBoxes.h"
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
class nsIURI;
|
2008-11-26 02:22:38 +03:00
|
|
|
class nsCSSFontFaceRule;
|
2009-08-01 19:53:40 +04:00
|
|
|
class nsRuleWalker;
|
|
|
|
struct RuleProcessorData;
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2008-12-12 21:59:03 +03:00
|
|
|
class nsEmptyStyleRule : public nsIStyleRule
|
|
|
|
{
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2004-01-08 22:23:12 +03: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.
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
class nsStyleSet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsStyleSet();
|
|
|
|
|
|
|
|
// Initialize the object. You must check the return code and not use
|
|
|
|
// the nsStyleSet if Init() fails.
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsresult Init(nsPresContext *aPresContext);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
// For getting the cached default data in case we hit out-of-memory.
|
|
|
|
// To be used only by nsRuleNode.
|
|
|
|
nsCachedStyleData* DefaultStyleData() { return &mDefaultStyleData; }
|
|
|
|
|
2009-01-30 07:39:23 +03:00
|
|
|
nsRuleNode* GetRuleTree() { return mRuleTree; }
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// enable / disable the Quirk style sheet
|
|
|
|
void EnableQuirkStyleSheet(PRBool aEnable);
|
|
|
|
|
|
|
|
// get a style context for a non-pseudo frame.
|
|
|
|
already_AddRefed<nsStyleContext>
|
2004-01-28 03:18:22 +03:00
|
|
|
ResolveStyleFor(nsIContent* aContent, nsStyleContext* aParentContext);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
// Get a style context (with the given parent and pseudo-tag/type) for a
|
2009-08-11 02:52:29 +04:00
|
|
|
// sequence of style rules consisting of the concatenation of:
|
|
|
|
// (1) the rule sequence represented by aRuleNode (which is the empty
|
|
|
|
// sequence if aRuleNode is null or the root of the rule tree), and
|
|
|
|
// (2) the rules in the |aRules| array.
|
2007-07-25 22:21:34 +04:00
|
|
|
already_AddRefed<nsStyleContext>
|
2009-08-11 02:52:29 +04:00
|
|
|
ResolveStyleForRules(nsStyleContext* aParentContext,
|
|
|
|
nsIAtom* aPseudoTag,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsCSSPseudoElements::Type aPseudoType,
|
2009-08-11 02:52:29 +04:00
|
|
|
nsRuleNode *aRuleNode,
|
|
|
|
const nsCOMArray<nsIStyleRule> &aRules);
|
2007-07-25 22:21:34 +04:00
|
|
|
|
2005-09-12 03:17:28 +04: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
|
2004-01-08 01:30:53 +03:00
|
|
|
// contexts for such content nodes. However, not doing any rule
|
|
|
|
// matching for them is a first step.
|
|
|
|
already_AddRefed<nsStyleContext>
|
2004-01-28 03:18:22 +03:00
|
|
|
ResolveStyleForNonElement(nsStyleContext* aParentContext);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2009-12-11 10:37:40 +03:00
|
|
|
// Get a style context for a pseudo-element. aParentContent must be
|
|
|
|
// non-null. aPseudoID is the nsCSSPseudoElements::Type for the
|
|
|
|
// pseudo-element.
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ResolvePseudoElementStyle(nsIContent* aParentContent,
|
|
|
|
nsCSSPseudoElements::Type aType,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsStyleContext* aParentContext);
|
2009-12-11 10:37:40 +03:00
|
|
|
|
|
|
|
// This functions just like ResolvePseudoElementStyle except that it will
|
|
|
|
// return nsnull if there are no explicit style rules for that
|
|
|
|
// pseudo element.
|
|
|
|
already_AddRefed<nsStyleContext>
|
|
|
|
ProbePseudoElementStyle(nsIContent* aParentContent,
|
|
|
|
nsCSSPseudoElements::Type aType,
|
|
|
|
nsStyleContext* aParentContext);
|
|
|
|
|
|
|
|
// 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-11 10:37:40 +03:00
|
|
|
ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, nsStyleContext* aParentContext);
|
2009-12-11 10:37:40 +03: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>
|
|
|
|
ResolveXULTreePseudoStyle(nsIContent* aParentContent,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsStyleContext* aParentContext,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsICSSPseudoComparator* aComparator);
|
2009-12-11 10:37:40 +03:00
|
|
|
#endif
|
|
|
|
|
2008-11-26 02:22:38 +03:00
|
|
|
// Append all the currently-active font face rules to aArray. Return
|
|
|
|
// true for success and false for failure.
|
|
|
|
PRBool AppendFontFaceRules(nsPresContext* aPresContext,
|
2008-11-27 06:50:16 +03:00
|
|
|
nsTArray<nsFontFaceRuleContainer>& aArray);
|
2008-11-26 02:22:38 +03:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// Begin ignoring style context destruction, to avoid lots of unnecessary
|
|
|
|
// work on document teardown.
|
2004-08-01 03:15:21 +04:00
|
|
|
void BeginShutdown(nsPresContext* aPresContext);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
// Free all of the data associated with this style set.
|
2004-08-01 03:15:21 +04:00
|
|
|
void Shutdown(nsPresContext* aPresContext);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
// Notification that a style context is being destroyed.
|
2004-08-01 03:15:21 +04:00
|
|
|
void NotifyStyleContextDestroyed(nsPresContext* aPresContext,
|
2004-01-08 01:30:53 +03:00
|
|
|
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.
|
|
|
|
already_AddRefed<nsStyleContext>
|
2004-08-01 03:15:21 +04:00
|
|
|
ReParentStyleContext(nsPresContext* aPresContext,
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsStyleContext* aNewParentContext);
|
|
|
|
|
2010-03-17 20:10:57 +03:00
|
|
|
// Test if style is dependent on a document state.
|
|
|
|
PRBool HasDocumentStateDependentStyle(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
PRInt32 aStateMask);
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// Test if style is dependent on content state
|
2010-04-01 04:43:32 +04:00
|
|
|
nsRestyleHint HasStateDependentStyle(nsPresContext* aPresContext,
|
2004-01-14 04:36:35 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
PRInt32 aStateMask);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
// Test if style is dependent on the presence of an attribute.
|
2010-04-01 04:43:32 +04:00
|
|
|
nsRestyleHint HasAttributeDependentStyle(nsPresContext* aPresContext,
|
2007-07-13 00:05:45 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType,
|
2009-12-11 01:36:03 +03:00
|
|
|
PRBool aAttrHasChanged);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2008-07-26 20:14:48 +04: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.
|
|
|
|
*/
|
|
|
|
PRBool MediumFeaturesChanged(nsPresContext* aPresContext);
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// APIs for registering objects that can supply additional
|
|
|
|
// rules during processing.
|
2007-02-17 02:02:08 +03:00
|
|
|
void SetBindingManager(nsBindingManager* aBindingManager)
|
2004-01-08 01:30:53 +03:00
|
|
|
{
|
2007-02-17 02:02:08 +03:00
|
|
|
mBindingManager = aBindingManager;
|
2004-01-08 01:30:53 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 05:24:00 +04:00
|
|
|
// The "origins" of the CSS cascade, from lowest precedence to
|
|
|
|
// highest (for non-!important rules).
|
2004-01-08 01:30:53 +03:00
|
|
|
enum sheetType {
|
2004-07-28 11:08:41 +04:00
|
|
|
eAgentSheet, // CSS
|
2004-05-05 04:30:57 +04:00
|
|
|
ePresHintSheet,
|
2004-07-28 11:08:41 +04:00
|
|
|
eUserSheet, // CSS
|
2004-07-16 00:30:30 +04:00
|
|
|
eHTMLPresHintSheet,
|
2004-07-28 11:08:41 +04:00
|
|
|
eDocSheet, // CSS
|
|
|
|
eStyleAttrSheet,
|
|
|
|
eOverrideSheet, // CSS
|
2009-10-08 07:22:42 +04:00
|
|
|
eTransitionSheet,
|
2004-01-08 01:30:53 +03:00
|
|
|
eSheetTypeCount
|
2007-05-17 01:08:51 +04: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
|
2004-01-08 01:30:53 +03:00
|
|
|
};
|
|
|
|
|
2005-08-20 05:24:00 +04:00
|
|
|
// APIs to manipulate the style sheet lists. The sheets in each
|
|
|
|
// list are stored with the most significant sheet last.
|
2004-01-08 01:30:53 +03:00
|
|
|
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);
|
|
|
|
|
2004-08-05 15:38:42 +04:00
|
|
|
//Enable/Disable entire author style level (Doc & PresHint levels)
|
|
|
|
PRBool GetAuthorStyleDisabled();
|
|
|
|
nsresult SetAuthorStyleDisabled(PRBool aStyleDisabled);
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
PRInt32 SheetCount(sheetType aType) const {
|
|
|
|
return mSheets[aType].Count();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIStyleSheet* StyleSheetAt(sheetType aType, PRInt32 aIndex) const {
|
|
|
|
return mSheets[aType].ObjectAt(aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument);
|
|
|
|
|
|
|
|
void BeginUpdate();
|
|
|
|
nsresult EndUpdate();
|
|
|
|
|
2007-07-25 21:14:13 +04: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-03 05:29:51 +03: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 18:07:36 +03: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.
|
|
|
|
PRBool HasCachedStyleData() const {
|
|
|
|
return (mRuleTree && mRuleTree->TreeHasCachedData()) || !mRoots.IsEmpty();
|
|
|
|
}
|
2009-09-24 21:59:43 +04: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 18:56:33 +03:00
|
|
|
|
|
|
|
nsCSSStyleSheet::EnsureUniqueInnerResult EnsureUniqueInnerOnCSSSheets();
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
private:
|
|
|
|
// Not to be implemented
|
|
|
|
nsStyleSet(const nsStyleSet& aCopy);
|
|
|
|
nsStyleSet& operator=(const nsStyleSet& aCopy);
|
|
|
|
|
|
|
|
// Returns false on out-of-memory.
|
2004-08-01 03:15:21 +04:00
|
|
|
PRBool BuildDefaultStyleData(nsPresContext* aPresContext);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2009-01-30 07:39:23 +03:00
|
|
|
// Run mark-and-sweep GC on mRuleTree and mOldRuleTrees, based on mRoots.
|
|
|
|
void GCRuleTrees();
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// Update the rule processor list after a change to the style sheet list.
|
2004-07-28 11:08:41 +04:00
|
|
|
nsresult GatherRuleProcessors(sheetType aType);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
void AddImportantRules(nsRuleNode* aCurrLevelNode,
|
2009-10-03 01:06:42 +04:00
|
|
|
nsRuleNode* aLastPrevLevelNode,
|
|
|
|
nsRuleWalker* aRuleWalker);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2009-10-03 01:06:42 +04:00
|
|
|
// Move aRuleWalker forward by the appropriate rule if we need to add
|
2008-12-12 21:59:03 +03:00
|
|
|
// a rule due to property restrictions on pseudo-elements.
|
2009-12-11 10:37:40 +03:00
|
|
|
void WalkRestrictionRule(nsCSSPseudoElements::Type aPseudoType,
|
2009-10-03 01:06:42 +04:00
|
|
|
nsRuleWalker* aRuleWalker);
|
2008-12-12 21:59:03 +03:00
|
|
|
|
2004-07-16 00:30:30 +04: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
|
|
|
|
// aLastPrevLevelNode. Mostly useful for the preshint levels.
|
|
|
|
void AssertNoCSSRules(nsRuleNode* aCurrLevelNode,
|
|
|
|
nsRuleNode* aLastPrevLevelNode);
|
|
|
|
#endif
|
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// Enumerate the rules in a way that cares about the order of the
|
|
|
|
// rules.
|
2009-12-11 10:37:40 +03:00
|
|
|
// aContent is the node the rules are for. It might be null. aData
|
|
|
|
// is the closure to pass to aCollectorFunc. If aContent is not null,
|
|
|
|
// aData must be a RuleProcessorData*
|
2004-01-08 01:30:53 +03:00
|
|
|
void FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
|
2009-12-11 10:37:40 +03:00
|
|
|
void* aData, nsIContent* aContent, nsRuleWalker* aRuleWalker);
|
2004-01-08 01:30:53 +03: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,
|
2010-03-25 12:22:58 +03:00
|
|
|
RuleProcessorData* aData,
|
|
|
|
PRBool aWalkAllXBLStylesheets);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
already_AddRefed<nsStyleContext> GetContext(nsPresContext* aPresContext,
|
2004-01-08 01:30:53 +03:00
|
|
|
nsStyleContext* aParentContext,
|
2009-10-03 01:06:42 +04:00
|
|
|
nsRuleNode* aRuleNode,
|
2009-12-11 10:37:40 +03:00
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsCSSPseudoElements::Type aPseudoType);
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* PresContext() { return mRuleTree->GetPresContext(); }
|
2004-01-28 03:18:22 +03:00
|
|
|
|
2006-06-08 18:32:20 +04:00
|
|
|
// The sheets in each array in mSheets are stored with the most significant
|
|
|
|
// sheet last.
|
2004-01-08 01:30:53 +03:00
|
|
|
nsCOMArray<nsIStyleSheet> mSheets[eSheetTypeCount];
|
|
|
|
|
2004-07-28 11:08:41 +04:00
|
|
|
nsCOMPtr<nsIStyleRuleProcessor> mRuleProcessors[eSheetTypeCount];
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
// cached instance for enabling/disabling
|
|
|
|
nsCOMPtr<nsIStyleSheet> mQuirkStyleSheet;
|
|
|
|
|
2007-02-17 02:02:08 +03:00
|
|
|
nsRefPtr<nsBindingManager> mBindingManager;
|
2004-01-08 01:30:53 +03:00
|
|
|
|
|
|
|
// To be used only in case of emergency, such as being out of memory
|
|
|
|
// or operating on a deleted rule node. The latter should never
|
|
|
|
// happen, of course.
|
|
|
|
nsCachedStyleData mDefaultStyleData;
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2009-09-24 21:59:43 +04:00
|
|
|
PRUint32 mUnusedRuleNodeCount; // used to batch rule node GC
|
2007-07-25 21:14:13 +04:00
|
|
|
nsTArray<nsStyleContext*> mRoots; // style contexts with no parent
|
2004-01-08 01:30:53 +03:00
|
|
|
|
2008-12-12 21:59:03 +03:00
|
|
|
// Empty style rules to force things that restrict which properties
|
|
|
|
// apply into different branches of the rule tree.
|
|
|
|
nsRefPtr<nsEmptyStyleRule> mFirstLineRule, mFirstLetterRule;
|
|
|
|
|
2004-01-08 22:23:12 +03:00
|
|
|
PRUint16 mBatching;
|
|
|
|
|
2009-01-30 07:39:23 +03: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-07-25 21:14:13 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
unsigned mInShutdown : 1;
|
2004-08-05 15:38:42 +04:00
|
|
|
unsigned mAuthorStyleDisabled: 1;
|
2009-01-30 07:39:23 +03:00
|
|
|
unsigned mInReconstruct : 1;
|
2009-10-08 07:22:42 +04:00
|
|
|
unsigned mDirty : 8; // one dirty bit is used per sheet type
|
2007-07-25 21:14:13 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
};
|
|
|
|
|
2009-09-24 21:59:43 +04:00
|
|
|
inline
|
|
|
|
NS_HIDDEN_(void) nsRuleNode::AddRef()
|
|
|
|
{
|
|
|
|
if (mRefCnt++ == 0 && !IsRoot()) {
|
|
|
|
mPresContext->StyleSet()->RuleNodeInUse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
NS_HIDDEN_(void) nsRuleNode::Release()
|
|
|
|
{
|
|
|
|
if (--mRefCnt == 0 && !IsRoot()) {
|
|
|
|
mPresContext->StyleSet()->RuleNodeUnused();
|
|
|
|
}
|
|
|
|
}
|
2004-01-08 01:30:53 +03:00
|
|
|
#endif
|