Bug 596094 - fix a race condition w/ipc disabled in focus related event handling...
[mozilla-central.git] / layout / style / nsTransitionManager.h
blobff2675d42246f9f56de68a3305c55070561ea732
1 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is nsTransitionManager.
17 * The Initial Developer of the Original Code is the Mozilla Foundation.
18 * Portions created by the Initial Developer are Copyright (C) 2009
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (original author)
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* Code to start and animate CSS transitions. */
40 #ifndef nsTransitionManager_h_
41 #define nsTransitionManager_h_
43 #include "prclist.h"
44 #include "nsCSSProperty.h"
45 #include "nsIStyleRuleProcessor.h"
46 #include "nsRefreshDriver.h"
47 #include "nsCSSPseudoElements.h"
49 class nsStyleContext;
50 class nsPresContext;
51 class nsCSSPropertySet;
52 struct nsTransition;
53 struct ElementTransitions;
55 class nsTransitionManager : public nsIStyleRuleProcessor,
56 public nsARefreshObserver {
57 public:
58 nsTransitionManager(nsPresContext *aPresContext);
59 ~nsTransitionManager();
61 /**
62 * Notify the transition manager that the pres context is going away.
64 void Disconnect();
66 /**
67 * StyleContextChanged
69 * To be called from nsFrameManager::ReResolveStyleContext when the
70 * style of an element has changed, to initiate transitions from
71 * that style change. For style contexts with :before and :after
72 * pseudos, aElement is expected to be the generated before/after
73 * element.
75 * It may return a "cover rule" (see CoverTransitionStartStyleRule) to
76 * cover up some of the changes for the duration of the restyling of
77 * descendants. If it does, this function will take care of causing
78 * the necessary restyle afterwards, but the caller must restyle the
79 * element *again* with the original sequence of rules plus the
80 * returned cover rule as the most specific rule.
82 already_AddRefed<nsIStyleRule>
83 StyleContextChanged(mozilla::dom::Element *aElement,
84 nsStyleContext *aOldStyleContext,
85 nsStyleContext *aNewStyleContext);
87 // nsISupports
88 NS_DECL_ISUPPORTS
90 // nsIStyleRuleProcessor
91 virtual void RulesMatching(ElementRuleProcessorData* aData);
92 virtual void RulesMatching(PseudoElementRuleProcessorData* aData);
93 virtual void RulesMatching(AnonBoxRuleProcessorData* aData);
94 #ifdef MOZ_XUL
95 virtual void RulesMatching(XULTreeRuleProcessorData* aData);
96 #endif
97 virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData);
98 virtual PRBool HasDocumentStateDependentStyle(StateRuleProcessorData* aData);
99 virtual nsRestyleHint
100 HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
101 virtual PRBool MediumFeaturesChanged(nsPresContext* aPresContext);
103 // nsARefreshObserver
104 virtual void WillRefresh(mozilla::TimeStamp aTime);
106 private:
107 friend class ElementTransitions; // for TransitionsRemoved
109 void ConsiderStartingTransition(nsCSSProperty aProperty,
110 const nsTransition& aTransition,
111 mozilla::dom::Element *aElement,
112 ElementTransitions *&aElementTransitions,
113 nsStyleContext *aOldStyleContext,
114 nsStyleContext *aNewStyleContext,
115 PRBool *aStartedAny,
116 nsCSSPropertySet *aWhichStarted);
117 ElementTransitions* GetElementTransitions(mozilla::dom::Element *aElement,
118 nsCSSPseudoElements::Type aPseudoType,
119 PRBool aCreateIfNeeded);
120 void AddElementTransitions(ElementTransitions* aElementTransitions);
121 void TransitionsRemoved();
122 void WalkTransitionRule(RuleProcessorData* aData,
123 nsCSSPseudoElements::Type aPseudoType);
125 void RemoveAllTransitions();
127 PRCList mElementTransitions;
128 nsPresContext *mPresContext; // weak (non-null from ctor to Disconnect)
131 #endif /* !defined(nsTransitionManager_h_) */