2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2008-06-02 20:17:35 -07:00
|
|
|
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* internal abstract interface for containers (roughly origins within
|
|
|
|
* the CSS cascade) that provide style rules matching an element or
|
|
|
|
* pseudo-element
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsIStyleRuleProcessor_h___
|
|
|
|
#define nsIStyleRuleProcessor_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsChangeHint.h"
|
2009-07-13 04:48:06 -07:00
|
|
|
#include "nsIContent.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-08-01 08:53:40 -07:00
|
|
|
struct RuleProcessorData;
|
|
|
|
struct ElementRuleProcessorData;
|
2009-12-10 23:37:40 -08:00
|
|
|
struct PseudoElementRuleProcessorData;
|
2009-12-10 23:37:40 -08:00
|
|
|
struct AnonBoxRuleProcessorData;
|
2009-12-10 23:37:40 -08:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
struct XULTreeRuleProcessorData;
|
|
|
|
#endif
|
2009-08-01 08:53:40 -07:00
|
|
|
struct StateRuleProcessorData;
|
|
|
|
struct AttributeRuleProcessorData;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsPresContext;
|
|
|
|
|
2009-12-10 23:37:40 -08:00
|
|
|
// IID for the nsIStyleRuleProcessor interface
|
2011-12-08 21:01:52 -08:00
|
|
|
// {c1d6001e-4fcb-4c40-bce1-5eba80bfd8f3}
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_ISTYLE_RULE_PROCESSOR_IID \
|
2011-12-08 21:01:52 -08:00
|
|
|
{ 0xc1d6001e, 0x4fcb, 0x4c40, \
|
|
|
|
{0xbc, 0xe1, 0x5e, 0xba, 0x80, 0xbf, 0xd8, 0xf3} }
|
2010-07-18 14:20:40 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* The style rule processor interface is a mechanism to separate the matching
|
|
|
|
* 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)
|
|
|
|
*
|
|
|
|
* @see nsIStyleRule (for significantly more detailed comments)
|
|
|
|
*/
|
|
|
|
class nsIStyleRuleProcessor : public nsISupports {
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
|
|
|
|
|
|
|
|
// Shorthand for:
|
|
|
|
// nsCOMArray<nsIStyleRuleProcessor>::nsCOMArrayEnumFunc
|
2011-09-28 23:19:26 -07:00
|
|
|
typedef bool (* EnumFunc)(nsIStyleRuleProcessor*, void*);
|
2007-03-22 10:30:00 -07: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).
|
|
|
|
*/
|
2010-07-18 14:20:40 -07:00
|
|
|
virtual void RulesMatching(ElementRuleProcessorData* aData) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given content
|
|
|
|
* node <em>and pseudo-element</em>.
|
|
|
|
*/
|
2010-07-18 14:20:40 -07:00
|
|
|
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) = 0;
|
2009-12-10 23:37:40 -08:00
|
|
|
|
2009-12-10 23:37:40 -08:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given anonymous box.
|
|
|
|
*/
|
2010-07-18 14:20:40 -07:00
|
|
|
virtual void RulesMatching(AnonBoxRuleProcessorData* aData) = 0;
|
2009-12-10 23:37:40 -08:00
|
|
|
|
2009-12-10 23:37:40 -08:00
|
|
|
#ifdef MOZ_XUL
|
2009-12-10 23:37:40 -08:00
|
|
|
/**
|
|
|
|
* Just like the previous |RulesMatching|, except for a given content
|
2009-12-10 23:37:40 -08:00
|
|
|
* node <em>and tree pseudo</em>.
|
2009-12-10 23:37:40 -08:00
|
|
|
*/
|
2010-07-18 14:20:40 -07:00
|
|
|
virtual void RulesMatching(XULTreeRuleProcessorData* aData) = 0;
|
2009-12-10 23:37:40 -08:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-17 10:10:57 -07:00
|
|
|
/**
|
|
|
|
* Return whether style can depend on a change of the given document state.
|
|
|
|
*
|
|
|
|
* Document states are defined in nsIDocument.h.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool
|
2010-03-17 10:10:57 -07:00
|
|
|
HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2010-03-31 17:43:32 -07:00
|
|
|
* Return how (as described by nsRestyleHint) style can depend on a
|
2007-03-22 10:30:00 -07:00
|
|
|
* 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.
|
|
|
|
*
|
2011-04-21 10:35:52 -07:00
|
|
|
* Event states are defined in nsEventStates.h.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-03-31 17:43:32 -07:00
|
|
|
virtual nsRestyleHint
|
2009-12-11 22:36:34 -08:00
|
|
|
HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2009-12-10 14:36:03 -08:00
|
|
|
* This method will be called twice for every attribute change.
|
|
|
|
* During the first call, aData->mAttrHasChanged will be false and
|
|
|
|
* the attribute change will not have happened yet. During the
|
|
|
|
* second call, aData->mAttrHasChanged will be true and the
|
|
|
|
* change will have already happened. The bitwise OR of the two
|
|
|
|
* return values must describe the style changes that are needed due
|
|
|
|
* to the attribute change. It's up to the rule processor
|
|
|
|
* implementation to decide how to split the bits up amongst the two
|
|
|
|
* return values. For example, it could return the bits needed by
|
|
|
|
* rules that might stop matching the node from the first call and
|
|
|
|
* the bits needed by rules that might have started matching the
|
|
|
|
* node from the second call. This test is used for optimization
|
|
|
|
* only, and may err on the side of reporting more dependencies than
|
|
|
|
* really exist.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-03-31 17:43:32 -07:00
|
|
|
virtual nsRestyleHint
|
2009-12-10 14:36:03 -08:00
|
|
|
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0;
|
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 this rule
|
|
|
|
* processor's rules have changed (e.g., because of media queries).
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) = 0;
|
2011-08-01 11:25:20 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Report the size of this style rule processor to about:memory. A
|
|
|
|
* processor may return 0.
|
|
|
|
*/
|
2011-12-08 21:01:52 -08:00
|
|
|
virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const = 0;
|
|
|
|
virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) const = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor,
|
|
|
|
NS_ISTYLE_RULE_PROCESSOR_IID)
|
|
|
|
|
|
|
|
#endif /* nsIStyleRuleProcessor_h___ */
|