layout/style/nsIStyleRuleProcessor.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/nsIStyleRuleProcessor.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,140 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * internal abstract interface for containers (roughly origins within
    1.11 + * the CSS cascade) that provide style rules matching an element or
    1.12 + * pseudo-element
    1.13 + */
    1.14 +
    1.15 +#ifndef nsIStyleRuleProcessor_h___
    1.16 +#define nsIStyleRuleProcessor_h___
    1.17 +
    1.18 +#include "mozilla/MemoryReporting.h"
    1.19 +#include "nsISupports.h"
    1.20 +#include "nsChangeHint.h"
    1.21 +
    1.22 +struct RuleProcessorData;
    1.23 +struct ElementDependentRuleProcessorData;
    1.24 +struct ElementRuleProcessorData;
    1.25 +struct PseudoElementRuleProcessorData;
    1.26 +struct AnonBoxRuleProcessorData;
    1.27 +#ifdef MOZ_XUL
    1.28 +struct XULTreeRuleProcessorData;
    1.29 +#endif
    1.30 +struct StateRuleProcessorData;
    1.31 +struct PseudoElementStateRuleProcessorData;
    1.32 +struct AttributeRuleProcessorData;
    1.33 +class nsPresContext;
    1.34 +
    1.35 +// IID for the nsIStyleRuleProcessor interface
    1.36 +// {c1d6001e-4fcb-4c40-bce1-5eba80bfd8f3}
    1.37 +#define NS_ISTYLE_RULE_PROCESSOR_IID     \
    1.38 +{ 0xc1d6001e, 0x4fcb, 0x4c40, \
    1.39 +  {0xbc, 0xe1, 0x5e, 0xba, 0x80, 0xbf, 0xd8, 0xf3} }
    1.40 +
    1.41 +
    1.42 +/* The style rule processor interface is a mechanism to separate the matching
    1.43 + * of style rules from style sheet instances.
    1.44 + * Simple style sheets can and will act as their own processor. 
    1.45 + * Sheets where rule ordering interlaces between multiple sheets, will need to 
    1.46 + * share a single rule processor between them (CSS sheets do this for cascading order)
    1.47 + *
    1.48 + * @see nsIStyleRule (for significantly more detailed comments)
    1.49 + */
    1.50 +class nsIStyleRuleProcessor : public nsISupports {
    1.51 +public:
    1.52 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
    1.53 +
    1.54 +  // Shorthand for:
    1.55 +  //  nsCOMArray<nsIStyleRuleProcessor>::nsCOMArrayEnumFunc
    1.56 +  typedef bool (* EnumFunc)(nsIStyleRuleProcessor*, void*);
    1.57 +
    1.58 +  /**
    1.59 +   * Find the |nsIStyleRule|s matching the given content node and
    1.60 +   * position the given |nsRuleWalker| at the |nsRuleNode| in the rule
    1.61 +   * tree representing that ordered list of rules (with higher
    1.62 +   * precedence being farther from the root of the lexicographic tree).
    1.63 +   */
    1.64 +  virtual void RulesMatching(ElementRuleProcessorData* aData) = 0;
    1.65 +
    1.66 +  /**
    1.67 +   * Just like the previous |RulesMatching|, except for a given content
    1.68 +   * node <em>and pseudo-element</em>.
    1.69 +   */
    1.70 +  virtual void RulesMatching(PseudoElementRuleProcessorData* aData) = 0;
    1.71 +
    1.72 +  /**
    1.73 +   * Just like the previous |RulesMatching|, except for a given anonymous box.
    1.74 +   */
    1.75 +  virtual void RulesMatching(AnonBoxRuleProcessorData* aData) = 0;
    1.76 +
    1.77 +#ifdef MOZ_XUL
    1.78 +  /**
    1.79 +   * Just like the previous |RulesMatching|, except for a given content
    1.80 +   * node <em>and tree pseudo</em>.
    1.81 +   */
    1.82 +  virtual void RulesMatching(XULTreeRuleProcessorData* aData) = 0;
    1.83 +#endif
    1.84 +
    1.85 +  /**
    1.86 +   * Return whether style can depend on a change of the given document state.
    1.87 +   *
    1.88 +   * Document states are defined in nsIDocument.h.
    1.89 +   */
    1.90 +  virtual bool
    1.91 +    HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0;
    1.92 +
    1.93 +  /**
    1.94 +   * Return how (as described by nsRestyleHint) style can depend on a
    1.95 +   * change of the given content state on the given content node.  This
    1.96 +   * test is used for optimization only, and may err on the side of
    1.97 +   * reporting more dependencies than really exist.
    1.98 +   *
    1.99 +   * Event states are defined in mozilla/EventStates.h.
   1.100 +   */
   1.101 +  virtual nsRestyleHint
   1.102 +    HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
   1.103 +  virtual nsRestyleHint
   1.104 +    HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) = 0;
   1.105 +
   1.106 +  /**
   1.107 +   * This method will be called twice for every attribute change.
   1.108 +   * During the first call, aData->mAttrHasChanged will be false and
   1.109 +   * the attribute change will not have happened yet.  During the
   1.110 +   * second call, aData->mAttrHasChanged will be true and the
   1.111 +   * change will have already happened.  The bitwise OR of the two
   1.112 +   * return values must describe the style changes that are needed due
   1.113 +   * to the attribute change.  It's up to the rule processor
   1.114 +   * implementation to decide how to split the bits up amongst the two
   1.115 +   * return values.  For example, it could return the bits needed by
   1.116 +   * rules that might stop matching the node from the first call and
   1.117 +   * the bits needed by rules that might have started matching the
   1.118 +   * node from the second call.  This test is used for optimization
   1.119 +   * only, and may err on the side of reporting more dependencies than
   1.120 +   * really exist.
   1.121 +   */
   1.122 +  virtual nsRestyleHint
   1.123 +    HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0;
   1.124 +
   1.125 +  /**
   1.126 +   * Do any processing that needs to happen as a result of a change in
   1.127 +   * the characteristics of the medium, and return whether this rule
   1.128 +   * processor's rules have changed (e.g., because of media queries).
   1.129 +   */
   1.130 +  virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) = 0;
   1.131 +
   1.132 +  /**
   1.133 +   * Report the size of this style rule processor to about:memory.  A
   1.134 +   * processor may return 0.
   1.135 +   */
   1.136 +  virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0;
   1.137 +  virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0;
   1.138 +};
   1.139 +
   1.140 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor,
   1.141 +                              NS_ISTYLE_RULE_PROCESSOR_IID)
   1.142 +
   1.143 +#endif /* nsIStyleRuleProcessor_h___ */

mercurial