2001-09-25 05:32:19 +04: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
|
1999-10-08 07:09:31 +04: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/
|
1999-10-08 07:09:31 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04: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.
|
1999-10-08 07:09:31 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 05:32:19 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* 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"),
|
2001-09-25 05:32:19 +04: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
|
2001-09-25 05:32:19 +04: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.
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-10-08 07:09:31 +04:00
|
|
|
#ifndef nsIStyleRuleProcessor_h___
|
|
|
|
#define nsIStyleRuleProcessor_h___
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h" // for nsCompatability
|
2001-11-11 02:51:45 +03:00
|
|
|
#include "nsILinkHandler.h"
|
2002-08-14 16:34:39 +04:00
|
|
|
#include "nsString.h"
|
2004-01-14 04:36:35 +03:00
|
|
|
#include "nsChangeHint.h"
|
1999-10-08 07:09:31 +04:00
|
|
|
|
|
|
|
class nsIStyleSheet;
|
2004-08-01 03:15:21 +04:00
|
|
|
class nsPresContext;
|
1999-10-08 07:09:31 +04:00
|
|
|
class nsIContent;
|
2001-11-11 02:51:45 +03:00
|
|
|
class nsIStyledContent;
|
1999-10-08 07:09:31 +04:00
|
|
|
class nsISupportsArray;
|
|
|
|
class nsIAtom;
|
2001-02-16 00:24:47 +03:00
|
|
|
class nsICSSPseudoComparator;
|
2001-10-24 04:01:09 +04:00
|
|
|
class nsRuleWalker;
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2001-11-11 02:51:45 +03:00
|
|
|
// The implementation of the constructor and destructor are currently in
|
|
|
|
// nsCSSStyleSheet.cpp.
|
|
|
|
|
|
|
|
struct RuleProcessorData {
|
2004-08-01 03:15:21 +04:00
|
|
|
RuleProcessorData(nsPresContext* aPresContext,
|
2001-11-11 02:51:45 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsRuleWalker* aRuleWalker,
|
|
|
|
nsCompatibility* aCompat = nsnull);
|
|
|
|
|
2001-11-11 23:46:42 +03:00
|
|
|
// NOTE: not |virtual|
|
|
|
|
~RuleProcessorData();
|
2001-11-11 02:51:45 +03:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 04:28:44 +04:00
|
|
|
return aContext->AllocateFromShell(sz);
|
2001-11-11 02:51:45 +03:00
|
|
|
}
|
2004-08-01 03:15:21 +04:00
|
|
|
void Destroy(nsPresContext* aContext) {
|
2001-11-11 02:51:45 +03:00
|
|
|
this->~RuleProcessorData();
|
|
|
|
aContext->FreeToShell(sizeof(RuleProcessorData), this);
|
|
|
|
};
|
|
|
|
|
2002-08-14 16:34:39 +04:00
|
|
|
const nsString* GetLang();
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* mPresContext;
|
2003-07-29 01:09:56 +04:00
|
|
|
nsIContent* mContent; // weak ref
|
|
|
|
nsIContent* mParentContent; // if content, content->GetParent(); weak ref
|
2001-11-11 02:51:45 +03:00
|
|
|
nsRuleWalker* mRuleWalker; // Used to add rules to our results.
|
|
|
|
nsIContent* mScopedRoot; // Root of scoped stylesheet (set and unset by the supplier of the scoped stylesheet
|
|
|
|
|
|
|
|
nsIAtom* mContentTag; // if content, then content->GetTag()
|
2004-11-23 20:21:37 +03:00
|
|
|
nsIAtom* mContentID; // if styled content, then weak reference to styledcontent->GetID()
|
2001-11-11 02:51:45 +03:00
|
|
|
nsIStyledContent* mStyledContent; // if content, content->QI(nsIStyledContent)
|
2001-12-15 02:07:43 +03:00
|
|
|
PRPackedBool mIsHTMLContent; // if content, then does QI on HTMLContent, true or false
|
|
|
|
PRPackedBool mIsHTMLLink; // if content, calls nsStyleUtil::IsHTMLLink
|
|
|
|
PRPackedBool mIsSimpleXLink; // if content, calls nsStyleUtil::IsSimpleXLink
|
2002-06-26 01:16:17 +04:00
|
|
|
nsCompatibility mCompatMode; // Possibly remove use of this in SelectorMatches?
|
2001-12-15 02:07:43 +03:00
|
|
|
PRPackedBool mHasAttributes; // if content, content->GetAttrCount() > 0
|
2002-03-07 06:34:29 +03:00
|
|
|
nsLinkState mLinkState; // if a link, this is the state, otherwise unknown
|
2001-11-11 02:51:45 +03:00
|
|
|
PRInt32 mEventState; // if content, eventStateMgr->GetContentState()
|
|
|
|
PRInt32 mNameSpaceID; // if content, content->GetNameSapce()
|
|
|
|
RuleProcessorData* mPreviousSiblingData;
|
|
|
|
RuleProcessorData* mParentData;
|
2002-08-14 16:34:39 +04:00
|
|
|
|
|
|
|
protected:
|
2002-08-14 18:01:39 +04:00
|
|
|
nsAutoString *mLanguage; // NULL means we haven't found out the language yet
|
2001-11-11 02:51:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ElementRuleProcessorData : public RuleProcessorData {
|
2004-08-01 03:15:21 +04:00
|
|
|
ElementRuleProcessorData(nsPresContext* aPresContext,
|
2001-11-11 02:51:45 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsRuleWalker* aRuleWalker)
|
|
|
|
: RuleProcessorData(aPresContext,aContent,aRuleWalker)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aContent, "null pointer");
|
|
|
|
NS_PRECONDITION(aRuleWalker, "null pointer");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PseudoRuleProcessorData : public RuleProcessorData {
|
2004-08-01 03:15:21 +04:00
|
|
|
PseudoRuleProcessorData(nsPresContext* aPresContext,
|
2001-11-11 02:51:45 +03:00
|
|
|
nsIContent* aParentContent,
|
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
nsICSSPseudoComparator* aComparator,
|
|
|
|
nsRuleWalker* aRuleWalker)
|
|
|
|
: RuleProcessorData(aPresContext, aParentContent, aRuleWalker)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPseudoTag, "null pointer");
|
|
|
|
NS_PRECONDITION(aRuleWalker, "null pointer");
|
|
|
|
mPseudoTag = aPseudoTag;
|
|
|
|
mComparator = aComparator;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom* mPseudoTag;
|
|
|
|
nsICSSPseudoComparator* mComparator;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StateRuleProcessorData : public RuleProcessorData {
|
2004-08-01 03:15:21 +04:00
|
|
|
StateRuleProcessorData(nsPresContext* aPresContext,
|
2002-04-11 07:49:30 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
PRInt32 aStateMask)
|
|
|
|
: RuleProcessorData(aPresContext, aContent, nsnull),
|
|
|
|
mStateMask(aStateMask)
|
2001-11-11 02:51:45 +03:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aContent, "null pointer");
|
|
|
|
}
|
2002-04-11 07:49:30 +04:00
|
|
|
const PRInt32 mStateMask; // |HasStateDependentStyle| for which state(s)?
|
|
|
|
// Constants defined in nsIEventStateManager.h .
|
2001-11-11 02:51:45 +03:00
|
|
|
};
|
|
|
|
|
2003-02-22 19:10:53 +03:00
|
|
|
struct AttributeRuleProcessorData : public RuleProcessorData {
|
2004-08-01 03:15:21 +04:00
|
|
|
AttributeRuleProcessorData(nsPresContext* aPresContext,
|
2003-02-22 19:10:53 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType)
|
|
|
|
: RuleProcessorData(aPresContext, aContent, nsnull),
|
|
|
|
mAttribute(aAttribute),
|
|
|
|
mModType(aModType)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aContent, "null pointer");
|
|
|
|
}
|
|
|
|
nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute?
|
|
|
|
PRInt32 mModType; // The type of modification (see nsIDOMMutationEvent).
|
|
|
|
};
|
|
|
|
|
2001-11-11 02:51:45 +03:00
|
|
|
|
1999-10-08 07:09:31 +04:00
|
|
|
// IID for the nsIStyleRuleProcessor interface {015575fe-7b6c-11d3-ba05-001083023c2b}
|
|
|
|
#define NS_ISTYLE_RULE_PROCESSOR_IID \
|
|
|
|
{0x015575fe, 0x7b6c, 0x11d3, {0xba, 0x05, 0x00, 0x10, 0x83, 0x02, 0x3c, 0x2b}}
|
|
|
|
|
2003-03-24 07:15:34 +03:00
|
|
|
/* The style rule processor interface is a mechanism to separate the matching
|
1999-10-08 07:09:31 +04:00
|
|
|
* of style rules from style sheet instances.
|
|
|
|
* Simple style sheets can and will act as their own processor.
|
|
|
|
* Sheets where rule ordering interlaces between multiple sheets, will need to
|
|
|
|
* share a single rule processor between them (CSS sheets do this for cascading order)
|
2005-07-26 06:28:02 +04:00
|
|
|
*
|
|
|
|
* @see nsIStyleRule (for significantly more detailed comments)
|
1999-10-08 07:09:31 +04:00
|
|
|
*/
|
|
|
|
class nsIStyleRuleProcessor : public nsISupports {
|
|
|
|
public:
|
2002-06-26 07:38:55 +04:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2004-01-08 01:30:53 +03:00
|
|
|
// Shorthand for:
|
|
|
|
// nsCOMArray<nsIStyleRuleProcessor>::nsCOMArrayEnumFunc
|
|
|
|
typedef PRBool (* PR_CALLBACK EnumFunc)(nsIStyleRuleProcessor*, void*);
|
|
|
|
|
2005-07-26 06:28:02 +04:00
|
|
|
/**
|
|
|
|
* Find the |nsIStyleRule|s matching the given content node and
|
|
|
|
* position the given |nsRuleWalker| at the |nsRuleNode| in the rule
|
|
|
|
* tree representing that ordered list of rules (with higher
|
|
|
|
* precedence being farther from the root of the lexicographic tree).
|
|
|
|
*/
|
2004-08-05 22:26:14 +04:00
|
|
|
NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData) = 0;
|
2001-11-11 02:51:45 +03:00
|
|
|
|
2005-07-26 06:28:02 +04:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given content
|
|
|
|
* node <em>and pseudo-element</em>.
|
|
|
|
*/
|
2004-08-05 22:26:14 +04:00
|
|
|
NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData) = 0;
|
1999-10-08 07:09:31 +04:00
|
|
|
|
2004-02-26 00:04:50 +03:00
|
|
|
/**
|
2005-07-26 06:28:02 +04:00
|
|
|
* Return how (as described by nsReStyleHint) style can depend on a
|
|
|
|
* change of the given content state on the given content node. This
|
|
|
|
* test is used for optimization only, and may err on the side of
|
|
|
|
* reporting more dependencies than really exist.
|
2004-02-26 00:04:50 +03:00
|
|
|
*
|
|
|
|
* Event states are defined in nsIEventStateManager.h.
|
|
|
|
*/
|
2002-04-11 07:49:30 +04:00
|
|
|
NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
|
2004-01-14 04:36:35 +03:00
|
|
|
nsReStyleHint* aResult) = 0;
|
2004-02-26 00:04:50 +03:00
|
|
|
|
|
|
|
/**
|
2005-07-26 06:28:02 +04:00
|
|
|
* Return how (as described by nsReStyleHint) style can depend on the
|
|
|
|
* presence or value of the given attribute for the given content
|
|
|
|
* node. This test is used for optimization only, and may err on the
|
|
|
|
* side of reporting more dependencies than really exist.
|
2004-02-26 00:04:50 +03:00
|
|
|
*/
|
2003-02-22 19:10:53 +03:00
|
|
|
NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
|
2004-01-14 04:36:35 +03:00
|
|
|
nsReStyleHint* aResult) = 0;
|
1999-10-08 07:09:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsIStyleRuleProcessor_h___ */
|