layout/style/nsIStyleRuleProcessor.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * internal abstract interface for containers (roughly origins within
michael@0 8 * the CSS cascade) that provide style rules matching an element or
michael@0 9 * pseudo-element
michael@0 10 */
michael@0 11
michael@0 12 #ifndef nsIStyleRuleProcessor_h___
michael@0 13 #define nsIStyleRuleProcessor_h___
michael@0 14
michael@0 15 #include "mozilla/MemoryReporting.h"
michael@0 16 #include "nsISupports.h"
michael@0 17 #include "nsChangeHint.h"
michael@0 18
michael@0 19 struct RuleProcessorData;
michael@0 20 struct ElementDependentRuleProcessorData;
michael@0 21 struct ElementRuleProcessorData;
michael@0 22 struct PseudoElementRuleProcessorData;
michael@0 23 struct AnonBoxRuleProcessorData;
michael@0 24 #ifdef MOZ_XUL
michael@0 25 struct XULTreeRuleProcessorData;
michael@0 26 #endif
michael@0 27 struct StateRuleProcessorData;
michael@0 28 struct PseudoElementStateRuleProcessorData;
michael@0 29 struct AttributeRuleProcessorData;
michael@0 30 class nsPresContext;
michael@0 31
michael@0 32 // IID for the nsIStyleRuleProcessor interface
michael@0 33 // {c1d6001e-4fcb-4c40-bce1-5eba80bfd8f3}
michael@0 34 #define NS_ISTYLE_RULE_PROCESSOR_IID \
michael@0 35 { 0xc1d6001e, 0x4fcb, 0x4c40, \
michael@0 36 {0xbc, 0xe1, 0x5e, 0xba, 0x80, 0xbf, 0xd8, 0xf3} }
michael@0 37
michael@0 38
michael@0 39 /* The style rule processor interface is a mechanism to separate the matching
michael@0 40 * of style rules from style sheet instances.
michael@0 41 * Simple style sheets can and will act as their own processor.
michael@0 42 * Sheets where rule ordering interlaces between multiple sheets, will need to
michael@0 43 * share a single rule processor between them (CSS sheets do this for cascading order)
michael@0 44 *
michael@0 45 * @see nsIStyleRule (for significantly more detailed comments)
michael@0 46 */
michael@0 47 class nsIStyleRuleProcessor : public nsISupports {
michael@0 48 public:
michael@0 49 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
michael@0 50
michael@0 51 // Shorthand for:
michael@0 52 // nsCOMArray<nsIStyleRuleProcessor>::nsCOMArrayEnumFunc
michael@0 53 typedef bool (* EnumFunc)(nsIStyleRuleProcessor*, void*);
michael@0 54
michael@0 55 /**
michael@0 56 * Find the |nsIStyleRule|s matching the given content node and
michael@0 57 * position the given |nsRuleWalker| at the |nsRuleNode| in the rule
michael@0 58 * tree representing that ordered list of rules (with higher
michael@0 59 * precedence being farther from the root of the lexicographic tree).
michael@0 60 */
michael@0 61 virtual void RulesMatching(ElementRuleProcessorData* aData) = 0;
michael@0 62
michael@0 63 /**
michael@0 64 * Just like the previous |RulesMatching|, except for a given content
michael@0 65 * node <em>and pseudo-element</em>.
michael@0 66 */
michael@0 67 virtual void RulesMatching(PseudoElementRuleProcessorData* aData) = 0;
michael@0 68
michael@0 69 /**
michael@0 70 * Just like the previous |RulesMatching|, except for a given anonymous box.
michael@0 71 */
michael@0 72 virtual void RulesMatching(AnonBoxRuleProcessorData* aData) = 0;
michael@0 73
michael@0 74 #ifdef MOZ_XUL
michael@0 75 /**
michael@0 76 * Just like the previous |RulesMatching|, except for a given content
michael@0 77 * node <em>and tree pseudo</em>.
michael@0 78 */
michael@0 79 virtual void RulesMatching(XULTreeRuleProcessorData* aData) = 0;
michael@0 80 #endif
michael@0 81
michael@0 82 /**
michael@0 83 * Return whether style can depend on a change of the given document state.
michael@0 84 *
michael@0 85 * Document states are defined in nsIDocument.h.
michael@0 86 */
michael@0 87 virtual bool
michael@0 88 HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0;
michael@0 89
michael@0 90 /**
michael@0 91 * Return how (as described by nsRestyleHint) style can depend on a
michael@0 92 * change of the given content state on the given content node. This
michael@0 93 * test is used for optimization only, and may err on the side of
michael@0 94 * reporting more dependencies than really exist.
michael@0 95 *
michael@0 96 * Event states are defined in mozilla/EventStates.h.
michael@0 97 */
michael@0 98 virtual nsRestyleHint
michael@0 99 HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
michael@0 100 virtual nsRestyleHint
michael@0 101 HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) = 0;
michael@0 102
michael@0 103 /**
michael@0 104 * This method will be called twice for every attribute change.
michael@0 105 * During the first call, aData->mAttrHasChanged will be false and
michael@0 106 * the attribute change will not have happened yet. During the
michael@0 107 * second call, aData->mAttrHasChanged will be true and the
michael@0 108 * change will have already happened. The bitwise OR of the two
michael@0 109 * return values must describe the style changes that are needed due
michael@0 110 * to the attribute change. It's up to the rule processor
michael@0 111 * implementation to decide how to split the bits up amongst the two
michael@0 112 * return values. For example, it could return the bits needed by
michael@0 113 * rules that might stop matching the node from the first call and
michael@0 114 * the bits needed by rules that might have started matching the
michael@0 115 * node from the second call. This test is used for optimization
michael@0 116 * only, and may err on the side of reporting more dependencies than
michael@0 117 * really exist.
michael@0 118 */
michael@0 119 virtual nsRestyleHint
michael@0 120 HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0;
michael@0 121
michael@0 122 /**
michael@0 123 * Do any processing that needs to happen as a result of a change in
michael@0 124 * the characteristics of the medium, and return whether this rule
michael@0 125 * processor's rules have changed (e.g., because of media queries).
michael@0 126 */
michael@0 127 virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) = 0;
michael@0 128
michael@0 129 /**
michael@0 130 * Report the size of this style rule processor to about:memory. A
michael@0 131 * processor may return 0.
michael@0 132 */
michael@0 133 virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0;
michael@0 134 virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0;
michael@0 135 };
michael@0 136
michael@0 137 NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor,
michael@0 138 NS_ISTYLE_RULE_PROCESSOR_IID)
michael@0 139
michael@0 140 #endif /* nsIStyleRuleProcessor_h___ */

mercurial