2013-07-20 19:14:24 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Code responsible for managing style changes: tracking what style
|
|
|
|
* changes need to happen, scheduling them, and doing them.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef mozilla_RestyleManager_h
|
|
|
|
#define mozilla_RestyleManager_h
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
#include "mozilla/RestyleLogging.h"
|
2013-07-20 19:14:24 +00:00
|
|
|
#include "nsISupportsImpl.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "nsChangeHint.h"
|
|
|
|
#include "RestyleTracker.h"
|
|
|
|
#include "nsPresContext.h"
|
2014-07-25 04:35:34 +00:00
|
|
|
#include "nsRefreshDriver.h"
|
2014-08-13 22:39:01 +00:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2014-08-13 22:39:02 +00:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2015-02-16 22:15:04 +00:00
|
|
|
#include "nsTransitionManager.h"
|
2013-07-20 19:14:24 +00:00
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
class nsIFrame;
|
2014-06-12 17:09:31 +00:00
|
|
|
class nsStyleChangeList;
|
2013-07-20 19:14:25 +00:00
|
|
|
struct TreeMatchContext;
|
2013-07-20 19:14:24 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-04-03 04:18:36 +00:00
|
|
|
class EventStates;
|
2014-11-20 18:24:10 +00:00
|
|
|
struct UndisplayedNode;
|
2013-07-20 19:14:24 +00:00
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
} // namespace dom
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class RestyleManager final
|
2014-11-20 18:24:09 +00:00
|
|
|
{
|
2013-07-20 19:14:24 +00:00
|
|
|
public:
|
2013-07-20 19:14:25 +00:00
|
|
|
friend class ::nsRefreshDriver;
|
|
|
|
friend class RestyleTracker;
|
|
|
|
|
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit RestyleManager(nsPresContext* aPresContext);
|
2013-07-20 19:14:24 +00:00
|
|
|
|
2014-03-21 01:16:20 +00:00
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
|
|
|
~RestyleManager()
|
|
|
|
{
|
2014-08-13 22:39:01 +00:00
|
|
|
MOZ_ASSERT(!mReframingStyleContexts,
|
|
|
|
"temporary member should be nulled out before destruction");
|
2014-03-21 01:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2013-07-20 19:14:24 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(mozilla::RestyleManager)
|
|
|
|
|
|
|
|
void Disconnect() {
|
|
|
|
mPresContext = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPresContext* PresContext() const {
|
|
|
|
MOZ_ASSERT(mPresContext);
|
|
|
|
return mPresContext;
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
nsCSSFrameConstructor* FrameConstructor() const
|
|
|
|
{ return PresContext()->FrameConstructor(); }
|
|
|
|
|
|
|
|
// Should be called when a frame is going to be destroyed and
|
|
|
|
// WillDestroyFrameTree hasn't been called yet.
|
|
|
|
void NotifyDestroyingFrame(nsIFrame* aFrame);
|
|
|
|
|
|
|
|
// Forwarded nsIDocumentObserver method, to handle restyling (and
|
|
|
|
// passing the notification to the frame).
|
|
|
|
nsresult ContentStateChanged(nsIContent* aContent,
|
2014-04-03 04:18:36 +00:00
|
|
|
EventStates aStateMask);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
// Forwarded nsIMutationObserver method, to handle restyling.
|
|
|
|
void AttributeWillChange(Element* aElement,
|
|
|
|
int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType);
|
|
|
|
// Forwarded nsIMutationObserver method, to handle restyling (and
|
|
|
|
// passing the notification to the frame).
|
|
|
|
void AttributeChanged(Element* aElement,
|
|
|
|
int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType);
|
|
|
|
|
|
|
|
// Get an integer that increments every time there is a style change
|
|
|
|
// as a result of a change to the :hover content state.
|
|
|
|
uint32_t GetHoverGeneration() const { return mHoverGeneration; }
|
|
|
|
|
|
|
|
// Get a counter that increments on every style change, that we use to
|
|
|
|
// track whether off-main-thread animations are up-to-date.
|
|
|
|
uint64_t GetAnimationGeneration() const { return mAnimationGeneration; }
|
|
|
|
|
2014-11-17 04:46:00 +00:00
|
|
|
// A workaround until bug 847286 lands that gets the maximum of the animation
|
|
|
|
// generation counters stored on the set of animations and transitions
|
|
|
|
// respectively for |aFrame|.
|
|
|
|
static uint64_t GetMaxAnimationGenerationForFrame(nsIFrame* aFrame);
|
|
|
|
|
2014-11-17 04:45:59 +00:00
|
|
|
// Update the animation generation count to mark that animation state
|
|
|
|
// has changed.
|
|
|
|
//
|
|
|
|
// This is normally performed automatically by ProcessPendingRestyles
|
|
|
|
// but it is also called when we have out-of-band changes to animations
|
|
|
|
// such as changes made through the Web Animations API.
|
|
|
|
void IncrementAnimationGeneration() { ++mAnimationGeneration; }
|
|
|
|
|
2014-10-03 04:53:23 +00:00
|
|
|
// Whether rule matching should skip styles associated with animation
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-16 22:15:05 +00:00
|
|
|
bool SkipAnimationRules() const { return mSkipAnimationRules; }
|
2014-10-03 04:53:23 +00:00
|
|
|
|
2015-02-16 22:15:01 +00:00
|
|
|
void SetSkipAnimationRules(bool aSkipAnimationRules) {
|
|
|
|
mSkipAnimationRules = aSkipAnimationRules;
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
/**
|
|
|
|
* Reparent the style contexts of this frame subtree. The parent frame of
|
|
|
|
* aFrame must be changed to the new parent before this function is called;
|
|
|
|
* the new parent style context will be automatically computed based on the
|
|
|
|
* new position in the frame tree.
|
|
|
|
*
|
|
|
|
* @param aFrame the root of the subtree to reparent. Must not be null.
|
|
|
|
*/
|
2014-06-02 12:08:21 +00:00
|
|
|
nsresult ReparentStyleContext(nsIFrame* aFrame);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2014-08-13 22:39:00 +00:00
|
|
|
private:
|
2014-11-20 18:24:10 +00:00
|
|
|
// Used when restyling an element with a frame.
|
|
|
|
void ComputeAndProcessStyleChange(nsIFrame* aFrame,
|
|
|
|
nsChangeHint aMinChange,
|
2014-08-13 22:39:00 +00:00
|
|
|
RestyleTracker& aRestyleTracker,
|
2014-11-20 18:24:10 +00:00
|
|
|
nsRestyleHint aRestyleHint);
|
|
|
|
// Used when restyling a display:contents element.
|
|
|
|
void ComputeAndProcessStyleChange(nsStyleContext* aNewContext,
|
|
|
|
Element* aElement,
|
|
|
|
nsChangeHint aMinChange,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
|
|
|
nsRestyleHint aRestyleHint);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2014-08-13 22:39:00 +00:00
|
|
|
public:
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/**
|
|
|
|
* DEBUG ONLY method to verify integrity of style tree versus frame tree
|
|
|
|
*/
|
2014-06-02 12:08:21 +00:00
|
|
|
void DebugVerifyStyleTree(nsIFrame* aFrame);
|
2013-07-20 19:14:25 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// Note: It's the caller's responsibility to make sure to wrap a
|
|
|
|
// ProcessRestyledFrames call in a view update batch and a script blocker.
|
|
|
|
// This function does not call ProcessAttachedQueue() on the binding manager.
|
|
|
|
// If the caller wants that to happen synchronously, it needs to handle that
|
|
|
|
// itself.
|
|
|
|
nsresult ProcessRestyledFrames(nsStyleChangeList& aRestyleArray);
|
|
|
|
|
2014-08-13 22:39:01 +00:00
|
|
|
/**
|
|
|
|
* In order to start CSS transitions on elements that are being
|
|
|
|
* reframed, we need to stash their style contexts somewhere during
|
|
|
|
* the reframing process.
|
|
|
|
*
|
|
|
|
* In all cases, the content node in the hash table is the real
|
|
|
|
* content node, not the anonymous content node we create for ::before
|
2014-08-13 22:39:01 +00:00
|
|
|
* or ::after. The content node passed to the Get and Put methods is,
|
|
|
|
* however, the content node to be associate with the frame's style
|
|
|
|
* context.
|
2014-08-13 22:39:01 +00:00
|
|
|
*/
|
|
|
|
typedef nsRefPtrHashtable<nsRefPtrHashKey<nsIContent>, nsStyleContext>
|
|
|
|
ReframingStyleContextTable;
|
2015-03-21 16:28:04 +00:00
|
|
|
class MOZ_STACK_CLASS ReframingStyleContexts final {
|
2014-08-13 22:39:01 +00:00
|
|
|
public:
|
2015-01-14 05:03:13 +00:00
|
|
|
/**
|
|
|
|
* Construct a ReframingStyleContexts object. The caller must
|
|
|
|
* ensure that aRestyleManager lives at least as long as the
|
|
|
|
* object. (This is generally easy since the caller is typically a
|
|
|
|
* method of RestyleManager.)
|
|
|
|
*/
|
|
|
|
explicit ReframingStyleContexts(RestyleManager* aRestyleManager);
|
2015-01-14 05:03:13 +00:00
|
|
|
~ReframingStyleContexts();
|
2015-01-14 05:03:13 +00:00
|
|
|
|
2014-08-13 22:39:01 +00:00
|
|
|
void Put(nsIContent* aContent, nsStyleContext* aStyleContext) {
|
|
|
|
MOZ_ASSERT(aContent);
|
|
|
|
nsCSSPseudoElements::Type pseudoType = aStyleContext->GetPseudoType();
|
|
|
|
if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
|
|
|
|
mElementContexts.Put(aContent, aStyleContext);
|
|
|
|
} else if (pseudoType == nsCSSPseudoElements::ePseudo_before) {
|
2015-03-03 11:09:00 +00:00
|
|
|
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore);
|
2014-08-13 22:39:01 +00:00
|
|
|
mBeforePseudoContexts.Put(aContent->GetParent(), aStyleContext);
|
|
|
|
} else if (pseudoType == nsCSSPseudoElements::ePseudo_after) {
|
2015-03-03 11:09:00 +00:00
|
|
|
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter);
|
2014-08-13 22:39:01 +00:00
|
|
|
mAfterPseudoContexts.Put(aContent->GetParent(), aStyleContext);
|
|
|
|
}
|
|
|
|
}
|
2014-08-13 22:39:02 +00:00
|
|
|
|
|
|
|
nsStyleContext* Get(nsIContent* aContent,
|
|
|
|
nsCSSPseudoElements::Type aPseudoType) {
|
|
|
|
MOZ_ASSERT(aContent);
|
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
|
|
|
|
return mElementContexts.GetWeak(aContent);
|
|
|
|
}
|
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
|
2015-03-03 11:09:00 +00:00
|
|
|
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore);
|
2014-08-13 22:39:02 +00:00
|
|
|
return mBeforePseudoContexts.GetWeak(aContent->GetParent());
|
|
|
|
}
|
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
|
2015-03-03 11:09:00 +00:00
|
|
|
MOZ_ASSERT(aContent->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter);
|
2014-08-13 22:39:02 +00:00
|
|
|
return mAfterPseudoContexts.GetWeak(aContent->GetParent());
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(false, "unexpected aPseudoType");
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-08-13 22:39:01 +00:00
|
|
|
private:
|
2015-01-14 05:03:13 +00:00
|
|
|
RestyleManager* mRestyleManager;
|
2015-01-14 05:03:13 +00:00
|
|
|
AutoRestore<ReframingStyleContexts*> mRestorePointer;
|
2014-08-13 22:39:01 +00:00
|
|
|
ReframingStyleContextTable mElementContexts;
|
|
|
|
ReframingStyleContextTable mBeforePseudoContexts;
|
|
|
|
ReframingStyleContextTable mAfterPseudoContexts;
|
|
|
|
};
|
|
|
|
|
2014-08-13 22:39:01 +00:00
|
|
|
/**
|
|
|
|
* Return the current ReframingStyleContexts struct, or null if we're
|
|
|
|
* not currently in a restyling operation.
|
|
|
|
*/
|
|
|
|
ReframingStyleContexts* GetReframingStyleContexts() {
|
|
|
|
return mReframingStyleContexts;
|
|
|
|
}
|
|
|
|
|
2014-08-13 22:39:01 +00:00
|
|
|
/**
|
|
|
|
* Try starting a transition for an element or a ::before or ::after
|
|
|
|
* pseudo-element, given an old and new style context. This may
|
2015-03-04 05:08:00 +00:00
|
|
|
* change the new style context if a transition is started. Returns
|
|
|
|
* true iff it does change aNewStyleContext.
|
2014-08-13 22:39:01 +00:00
|
|
|
*
|
|
|
|
* For the pseudo-elements, aContent must be the anonymous content
|
|
|
|
* that we're creating for that pseudo-element, not the real element.
|
|
|
|
*/
|
2015-03-04 05:08:00 +00:00
|
|
|
static bool
|
2014-08-13 22:39:01 +00:00
|
|
|
TryStartingTransition(nsPresContext* aPresContext, nsIContent* aContent,
|
|
|
|
nsStyleContext* aOldStyleContext,
|
|
|
|
nsRefPtr<nsStyleContext>* aNewStyleContext /* inout */);
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
private:
|
|
|
|
void RestyleForEmptyChange(Element* aContainer);
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Restyling for a ContentInserted (notification after insertion) or
|
|
|
|
// for a CharacterDataChanged. |aContainer| must be non-null; when
|
|
|
|
// the container is null, no work is needed.
|
|
|
|
void RestyleForInsertOrChange(Element* aContainer, nsIContent* aChild);
|
|
|
|
|
|
|
|
// This would be the same as RestyleForInsertOrChange if we got the
|
|
|
|
// notification before the removal. However, we get it after, so we need the
|
|
|
|
// following sibling in addition to the old child. |aContainer| must be
|
|
|
|
// non-null; when the container is null, no work is needed. aFollowingSibling
|
|
|
|
// is the sibling that used to come after aOldChild before the removal.
|
|
|
|
void RestyleForRemove(Element* aContainer,
|
|
|
|
nsIContent* aOldChild,
|
|
|
|
nsIContent* aFollowingSibling);
|
|
|
|
|
|
|
|
// Same for a ContentAppended. |aContainer| must be non-null; when
|
|
|
|
// the container is null, no work is needed.
|
|
|
|
void RestyleForAppend(Element* aContainer, nsIContent* aFirstNewContent);
|
|
|
|
|
|
|
|
// Process any pending restyles. This should be called after
|
|
|
|
// CreateNeededFrames.
|
|
|
|
// Note: It's the caller's responsibility to make sure to wrap a
|
|
|
|
// ProcessPendingRestyles call in a view update batch and a script blocker.
|
|
|
|
// This function does not call ProcessAttachedQueue() on the binding manager.
|
|
|
|
// If the caller wants that to happen synchronously, it needs to handle that
|
|
|
|
// itself.
|
|
|
|
void ProcessPendingRestyles();
|
|
|
|
|
2014-10-02 02:32:09 +00:00
|
|
|
// Returns whether there are any pending restyles.
|
|
|
|
bool HasPendingRestyles() { return mPendingRestyles.Count() != 0; }
|
|
|
|
|
2013-07-31 00:36:08 +00:00
|
|
|
// ProcessPendingRestyles calls into one of our RestyleTracker
|
|
|
|
// objects. It then calls back to these functions at the beginning
|
|
|
|
// and end of its work.
|
2015-01-14 05:03:12 +00:00
|
|
|
void BeginProcessingRestyles(RestyleTracker& aRestyleTracker);
|
2013-07-31 00:36:08 +00:00
|
|
|
void EndProcessingRestyles();
|
|
|
|
|
2014-07-25 04:35:34 +00:00
|
|
|
// Update styles for animations that are running on the compositor and
|
|
|
|
// whose updating is suppressed on the main thread (to save
|
|
|
|
// unnecessary work), while leaving all other aspects of style
|
|
|
|
// out-of-date.
|
2014-08-07 05:58:44 +00:00
|
|
|
//
|
|
|
|
// Performs an animation-only style flush to make styles from
|
|
|
|
// throttled transitions up-to-date prior to processing an unrelated
|
|
|
|
// style change, so that any transitions triggered by that style
|
|
|
|
// change produce correct results.
|
|
|
|
//
|
|
|
|
// In more detail: when we're able to run animations on the
|
|
|
|
// compositor, we sometimes "throttle" these animations by skipping
|
|
|
|
// updating style data on the main thread. However, whenever we
|
|
|
|
// process a normal (non-animation) style change, any changes in
|
|
|
|
// computed style on elements that have transition-* properties set
|
|
|
|
// may need to trigger new transitions; this process requires knowing
|
|
|
|
// both the old and new values of the property. To do this correctly,
|
|
|
|
// we need to have an up-to-date *old* value of the property on the
|
|
|
|
// primary frame. So the purpose of the mini-flush is to update the
|
|
|
|
// style for all throttled transitions and animations to the current
|
|
|
|
// animation state without making any other updates, so that when we
|
|
|
|
// process the queued style updates we'll have correct old data to
|
|
|
|
// compare against. When we do this, we don't bother touching frames
|
|
|
|
// other than primary frames.
|
2014-07-25 04:35:34 +00:00
|
|
|
void UpdateOnlyAnimationStyles();
|
|
|
|
|
2014-07-25 04:35:34 +00:00
|
|
|
bool ThrottledAnimationStyleIsUpToDate() const {
|
|
|
|
return mLastUpdateForThrottledAnimations ==
|
|
|
|
mPresContext->RefreshDriver()->MostRecentRefresh();
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// Rebuilds all style data by throwing out the old rule tree and
|
|
|
|
// building a new one, and additionally applying aExtraHint (which
|
|
|
|
// must not contain nsChangeHint_ReconstructFrame) to the root frame.
|
2014-10-08 21:26:57 +00:00
|
|
|
//
|
|
|
|
// aRestyleHint says which restyle hint to use for the computation;
|
|
|
|
// the only sensible values to use are eRestyle_Subtree (which says
|
|
|
|
// that the rebuild must run selector matching) and nsRestyleHint(0)
|
|
|
|
// (which says that rerunning selector matching is not required. (The
|
|
|
|
// method adds eRestyle_ForceDescendants internally, and including it
|
|
|
|
// in the restyle hint is harmless; some callers (e.g.,
|
|
|
|
// nsPresContext::MediaFeatureValuesChanged) might do this for their
|
|
|
|
// own reasons.)
|
|
|
|
void RebuildAllStyleData(nsChangeHint aExtraHint,
|
|
|
|
nsRestyleHint aRestyleHint);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-16 22:15:05 +00:00
|
|
|
/**
|
|
|
|
* Notify the frame constructor that an element needs to have its
|
|
|
|
* style recomputed.
|
|
|
|
* @param aElement: The element to be restyled.
|
|
|
|
* @param aRestyleHint: Which nodes need to have selector matching run
|
|
|
|
* on them.
|
|
|
|
* @param aMinChangeHint: A minimum change hint for aContent and its
|
|
|
|
* descendants.
|
|
|
|
*/
|
2013-07-20 19:14:25 +00:00
|
|
|
void PostRestyleEvent(Element* aElement,
|
|
|
|
nsRestyleHint aRestyleHint,
|
Bug 960465 patch 17 - Remove separate animation and non-animation phases of restyling. r=birtles
Note that this means that when we start transitions, we post restyles
that are processed during the current restyling operation, rather than
in a later phase. This depends on patch 11, which makes the transition
manager skip style changes that it posts while starting transitions, to
ensure that this doesn't lead to an infinite loop. This also depends on
patch 16, which only consumes restyle data for the primary frame, to
ensure that the animation restyles posted are processed properly. It
also depends on patch 14, which makes us retain data on finished
transitions, to avoid triggering extra transitions on descendants when
both an ancestor and a descendant transition an inherited property, and
the descendant does so faster.
This fixes a known failure in layout/style/test/test_animations.html and
test_animations_omta.html (as visible in the patch). I believe this is
because this patch changes us to compute keyframe values for animations
on top of a style context *with* animation data rather than one without,
which means what we're computing them on top of changes each time. (The
purpose of patch 3 was to avoid this in the case where avoiding it
matters, i.e., implicit 0% and 100% keyframes.)
2015-02-16 22:15:05 +00:00
|
|
|
nsChangeHint aMinChangeHint);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
|
|
|
void PostRestyleEventForLazyConstruction()
|
|
|
|
{
|
|
|
|
PostRestyleEventInternal(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlushOverflowChangedTracker()
|
|
|
|
{
|
|
|
|
mOverflowChangedTracker.Flush();
|
|
|
|
}
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
static nsCString RestyleHintToString(nsRestyleHint aHint);
|
|
|
|
static nsCString ChangeHintToString(nsChangeHint aHint);
|
|
|
|
#endif
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
private:
|
|
|
|
void PostRestyleEventInternal(bool aForLazyConstruction);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Asynchronously clear style data from the root frame downwards and ensure
|
|
|
|
* it will all be rebuilt. This is safe to call anytime; it will schedule
|
|
|
|
* a restyle and take effect next time style changes are flushed.
|
|
|
|
* This method is used to recompute the style data when some change happens
|
|
|
|
* outside of any style rules, like a color preference change or a change
|
|
|
|
* in a system font size, or to fix things up when an optimization in the
|
|
|
|
* style data has become invalid. We assume that the root frame will not
|
|
|
|
* need to be reframed.
|
2014-10-08 21:27:02 +00:00
|
|
|
*
|
|
|
|
* For parameters, see RebuildAllStyleData.
|
2013-07-20 19:14:25 +00:00
|
|
|
*/
|
2014-10-08 21:27:02 +00:00
|
|
|
void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
|
|
|
|
nsRestyleHint aRestyleHint);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
/**
|
|
|
|
* Returns whether a restyle event currently being processed by this
|
|
|
|
* RestyleManager should be logged.
|
|
|
|
*/
|
|
|
|
bool ShouldLogRestyle() {
|
|
|
|
return ShouldLogRestyle(mPresContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether a restyle event currently being processed for the
|
|
|
|
* document with the specified nsPresContext should be logged.
|
|
|
|
*/
|
|
|
|
static bool ShouldLogRestyle(nsPresContext* aPresContext) {
|
|
|
|
return aPresContext->RestyleLoggingEnabled() &&
|
2015-02-16 22:15:04 +00:00
|
|
|
(!aPresContext->TransitionManager()->
|
|
|
|
InAnimationOnlyStyleUpdate() ||
|
2014-09-25 05:45:36 +00:00
|
|
|
AnimationRestyleLoggingEnabled());
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool RestyleLoggingInitiallyEnabled() {
|
|
|
|
static bool enabled = getenv("MOZ_DEBUG_RESTYLE") != 0;
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool AnimationRestyleLoggingEnabled() {
|
|
|
|
static bool animations = getenv("MOZ_DEBUG_RESTYLE_ANIMATIONS") != 0;
|
|
|
|
return animations;
|
|
|
|
}
|
|
|
|
|
2014-09-30 23:13:57 +00:00
|
|
|
// Set MOZ_DEBUG_RESTYLE_STRUCTS to a comma-separated string of
|
|
|
|
// style struct names -- such as "Font,SVGReset" -- to log the style context
|
|
|
|
// tree and those cached struct pointers before each restyle. This
|
|
|
|
// function returns a bitfield of the structs named in the
|
|
|
|
// environment variable.
|
|
|
|
static uint32_t StructsToLog();
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
static nsCString StructNamesToString(uint32_t aSIDs);
|
|
|
|
int32_t& LoggingDepth() { return mLoggingDepth; }
|
|
|
|
#endif
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
private:
|
|
|
|
/* aMinHint is the minimal change that should be made to the element */
|
|
|
|
// XXXbz do we really need the aPrimaryFrame argument here?
|
2013-07-20 19:14:25 +00:00
|
|
|
void RestyleElement(Element* aElement,
|
2013-07-20 19:14:25 +00:00
|
|
|
nsIFrame* aPrimaryFrame,
|
|
|
|
nsChangeHint aMinHint,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
2014-06-19 00:07:26 +00:00
|
|
|
nsRestyleHint aRestyleHint);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
void StartRebuildAllStyleData(RestyleTracker& aRestyleTracker);
|
2015-01-14 05:03:12 +00:00
|
|
|
void FinishRebuildAllStyleData();
|
|
|
|
|
2014-05-13 00:47:53 +00:00
|
|
|
void StyleChangeReflow(nsIFrame* aFrame, nsChangeHint aHint);
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2014-06-17 14:32:00 +00:00
|
|
|
// Recursively add all the given frame and all children to the tracker.
|
|
|
|
void AddSubtreeToOverflowTracker(nsIFrame* aFrame);
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
// Returns true if this function managed to successfully move a frame, and
|
|
|
|
// false if it could not process the position change, and a reflow should
|
|
|
|
// be performed instead.
|
|
|
|
bool RecomputePosition(nsIFrame* aFrame);
|
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
bool ShouldStartRebuildAllFor(RestyleTracker& aRestyleTracker) {
|
|
|
|
// When we process our primary restyle tracker and we have a pending
|
|
|
|
// rebuild-all, we need to process it.
|
|
|
|
return mDoRebuildAllStyleData &&
|
|
|
|
&aRestyleTracker == &mPendingRestyles;
|
|
|
|
}
|
|
|
|
|
2015-01-14 05:03:12 +00:00
|
|
|
void ProcessRestyles(RestyleTracker& aRestyleTracker) {
|
|
|
|
// Fast-path the common case (esp. for the animation restyle
|
|
|
|
// tracker) of not having anything to do.
|
2015-01-14 05:03:12 +00:00
|
|
|
if (aRestyleTracker.Count() || ShouldStartRebuildAllFor(aRestyleTracker)) {
|
2015-01-14 05:03:12 +00:00
|
|
|
aRestyleTracker.DoProcessRestyles();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-20 19:14:24 +00:00
|
|
|
private:
|
|
|
|
nsPresContext* mPresContext; // weak, disconnected in Disconnect
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2015-01-14 05:03:11 +00:00
|
|
|
// True if we need to reconstruct the rule tree the next time we
|
|
|
|
// process restyles.
|
|
|
|
bool mDoRebuildAllStyleData : 1;
|
2015-01-14 05:03:12 +00:00
|
|
|
// True if we're currently in the process of reconstructing the rule tree.
|
|
|
|
bool mInRebuildAllStyleData : 1;
|
2013-07-20 19:14:25 +00:00
|
|
|
// True if we're already waiting for a refresh notification
|
|
|
|
bool mObservingRefreshDriver : 1;
|
|
|
|
// True if we're in the middle of a nsRefreshDriver refresh
|
|
|
|
bool mInStyleRefresh : 1;
|
2014-10-03 04:53:23 +00:00
|
|
|
// Whether rule matching should skip styles associated with animation
|
|
|
|
bool mSkipAnimationRules : 1;
|
2015-02-16 22:15:02 +00:00
|
|
|
bool mHavePendingNonAnimationRestyles : 1;
|
2014-10-03 04:53:23 +00:00
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
uint32_t mHoverGeneration;
|
|
|
|
nsChangeHint mRebuildAllExtraHint;
|
2014-10-08 21:26:57 +00:00
|
|
|
nsRestyleHint mRebuildAllRestyleHint;
|
2013-07-20 19:14:25 +00:00
|
|
|
|
2014-07-25 04:35:34 +00:00
|
|
|
mozilla::TimeStamp mLastUpdateForThrottledAnimations;
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
OverflowChangedTracker mOverflowChangedTracker;
|
|
|
|
|
|
|
|
// The total number of animation flushes by this frame constructor.
|
|
|
|
// Used to keep the layer and animation manager in sync.
|
|
|
|
uint64_t mAnimationGeneration;
|
|
|
|
|
2014-08-13 22:39:01 +00:00
|
|
|
ReframingStyleContexts* mReframingStyleContexts;
|
|
|
|
|
2013-07-20 19:14:25 +00:00
|
|
|
RestyleTracker mPendingRestyles;
|
2014-09-25 05:45:36 +00:00
|
|
|
|
2014-10-03 04:53:23 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
bool mIsProcessingRestyles;
|
|
|
|
#endif
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
int32_t mLoggingDepth;
|
|
|
|
#endif
|
2013-07-20 19:14:24 +00:00
|
|
|
};
|
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
/**
|
|
|
|
* An ElementRestyler is created for *each* element in a subtree that we
|
|
|
|
* recompute styles for.
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
class ElementRestyler final
|
2014-11-20 18:24:09 +00:00
|
|
|
{
|
2013-07-31 00:36:09 +00:00
|
|
|
public:
|
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2015-02-17 22:28:53 +00:00
|
|
|
struct ContextToClear {
|
|
|
|
nsRefPtr<nsStyleContext> mStyleContext;
|
|
|
|
uint32_t mStructs;
|
|
|
|
};
|
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
// Construct for the root of the subtree that we're restyling.
|
2013-07-31 00:36:09 +00:00
|
|
|
ElementRestyler(nsPresContext* aPresContext,
|
2013-07-31 00:36:09 +00:00
|
|
|
nsIFrame* aFrame,
|
2013-07-31 00:36:10 +00:00
|
|
|
nsStyleChangeList* aChangeList,
|
2013-07-31 00:36:10 +00:00
|
|
|
nsChangeHint aHintsHandledByAncestors,
|
2013-07-31 00:36:10 +00:00
|
|
|
RestyleTracker& aRestyleTracker,
|
2013-07-31 00:36:10 +00:00
|
|
|
TreeMatchContext& aTreeMatchContext,
|
2015-02-17 22:28:53 +00:00
|
|
|
nsTArray<nsIContent*>& aVisibleKidsOfHiddenElement,
|
|
|
|
nsTArray<ContextToClear>& aContextsToClear,
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>>& aSwappedStructOwners);
|
2013-07-31 00:36:09 +00:00
|
|
|
|
|
|
|
// Construct for an element whose parent is being restyled.
|
2013-07-31 00:36:10 +00:00
|
|
|
enum ConstructorFlags {
|
|
|
|
FOR_OUT_OF_FLOW_CHILD = 1<<0
|
|
|
|
};
|
2013-07-31 00:36:09 +00:00
|
|
|
ElementRestyler(const ElementRestyler& aParentRestyler,
|
2013-07-31 00:36:10 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint32_t aConstructorFlags);
|
2013-07-31 00:36:09 +00:00
|
|
|
|
|
|
|
// Construct for a frame whose parent is being restyled, but whose
|
|
|
|
// style context is the parent style context for its parent frame.
|
|
|
|
// (This is only used for table frames, whose style contexts are used
|
|
|
|
// as the parent style context for their outer table frame (table
|
|
|
|
// wrapper frame). We should probably try to get rid of this
|
|
|
|
// exception and have the inheritance go the other way.)
|
|
|
|
enum ParentContextFromChildFrame { PARENT_CONTEXT_FROM_CHILD_FRAME };
|
|
|
|
ElementRestyler(ParentContextFromChildFrame,
|
2013-07-31 00:36:09 +00:00
|
|
|
const ElementRestyler& aParentFrameRestyler,
|
|
|
|
nsIFrame* aFrame);
|
2013-07-31 00:36:09 +00:00
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
// For restyling undisplayed content only (mFrame==null).
|
|
|
|
ElementRestyler(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleChangeList* aChangeList,
|
|
|
|
nsChangeHint aHintsHandledByAncestors,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
|
|
|
TreeMatchContext& aTreeMatchContext,
|
2015-02-17 22:28:53 +00:00
|
|
|
nsTArray<nsIContent*>& aVisibleKidsOfHiddenElement,
|
|
|
|
nsTArray<ContextToClear>& aContextsToClear,
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>>& aSwappedStructOwners);
|
2014-11-20 18:24:10 +00:00
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
/**
|
|
|
|
* Restyle our frame's element and its subtree.
|
|
|
|
*
|
|
|
|
* Use eRestyle_Self for the aRestyleHint argument to mean
|
|
|
|
* "reresolve our style context but not kids", use eRestyle_Subtree
|
|
|
|
* to mean "reresolve our style context and kids", and use
|
|
|
|
* nsRestyleHint(0) to mean recompute a new style context for our
|
|
|
|
* current parent and existing rulenode, and the same for kids.
|
|
|
|
*/
|
2013-07-31 00:36:10 +00:00
|
|
|
void Restyle(nsRestyleHint aRestyleHint);
|
2013-07-31 00:36:09 +00:00
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
/**
|
|
|
|
* mHintsHandled changes over time; it starts off as the hints that
|
|
|
|
* have been handled by ancestors, and by the end of Restyle it
|
|
|
|
* represents the hints that have been handled for this frame. This
|
|
|
|
* method is intended to be called after Restyle, to find out what
|
|
|
|
* hints have been handled for this frame.
|
|
|
|
*/
|
|
|
|
nsChangeHint HintsHandledForFrame() { return mHintsHandled; }
|
|
|
|
|
2014-11-20 18:24:10 +00:00
|
|
|
/**
|
|
|
|
* Called from RestyleManager::ComputeAndProcessStyleChange to restyle
|
|
|
|
* children of a display:contents element.
|
|
|
|
*/
|
|
|
|
void RestyleChildrenOfDisplayContentsElement(nsIFrame* aParentFrame,
|
|
|
|
nsStyleContext* aNewContext,
|
|
|
|
nsChangeHint aMinHint,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
|
|
|
nsRestyleHint aRestyleHint);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Re-resolve the style contexts for a frame tree, building aChangeList
|
|
|
|
* based on the resulting style changes, plus aMinChange applied to aFrame.
|
|
|
|
*/
|
|
|
|
static void ComputeStyleChangeFor(nsIFrame* aFrame,
|
|
|
|
nsStyleChangeList* aChangeList,
|
|
|
|
nsChangeHint aMinChange,
|
|
|
|
RestyleTracker& aRestyleTracker,
|
2015-02-17 22:28:53 +00:00
|
|
|
nsRestyleHint aRestyleHint,
|
|
|
|
nsTArray<ContextToClear>& aContextsToClear,
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>>&
|
|
|
|
aSwappedStructOwners);
|
2014-11-20 18:24:10 +00:00
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
bool ShouldLogRestyle() {
|
|
|
|
return RestyleManager::ShouldLogRestyle(mPresContext);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
private:
|
2014-09-05 03:48:45 +00:00
|
|
|
// Enum for the result of RestyleSelf, which indicates whether the
|
|
|
|
// restyle procedure should continue to the children, and how.
|
|
|
|
//
|
|
|
|
// These values must be ordered so that later values imply that all
|
|
|
|
// the work of the earlier values is also done.
|
|
|
|
enum RestyleResult {
|
|
|
|
|
|
|
|
// do not restyle children
|
|
|
|
eRestyleResult_Stop = 1,
|
|
|
|
|
|
|
|
// continue restyling children
|
|
|
|
eRestyleResult_Continue,
|
|
|
|
|
|
|
|
// continue restyling children with eRestyle_ForceDescendants set
|
|
|
|
eRestyleResult_ContinueAndForceDescendants
|
|
|
|
};
|
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
/**
|
|
|
|
* First half of Restyle().
|
|
|
|
*/
|
2014-09-05 03:48:47 +00:00
|
|
|
RestyleResult RestyleSelf(nsIFrame* aSelf,
|
|
|
|
nsRestyleHint aRestyleHint,
|
2014-09-25 05:30:18 +00:00
|
|
|
uint32_t* aSwappedStructs);
|
2013-07-31 00:36:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Restyle the children of this frame (and, in turn, their children).
|
|
|
|
*
|
|
|
|
* Second half of Restyle().
|
|
|
|
*/
|
|
|
|
void RestyleChildren(nsRestyleHint aChildRestyleHint);
|
|
|
|
|
2014-11-17 04:46:00 +00:00
|
|
|
/**
|
|
|
|
* Helpers for Restyle().
|
|
|
|
*/
|
|
|
|
void AddLayerChangesForAnimation();
|
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
/**
|
2014-09-05 03:48:46 +00:00
|
|
|
* Helpers for RestyleSelf().
|
2013-07-31 00:36:11 +00:00
|
|
|
*/
|
2013-07-31 00:36:09 +00:00
|
|
|
void CaptureChange(nsStyleContext* aOldContext,
|
|
|
|
nsStyleContext* aNewContext,
|
2014-09-05 03:48:45 +00:00
|
|
|
nsChangeHint aChangeToAssume,
|
|
|
|
uint32_t* aEqualStructs);
|
2014-09-05 03:48:46 +00:00
|
|
|
RestyleResult ComputeRestyleResultFromFrame(nsIFrame* aSelf);
|
|
|
|
RestyleResult ComputeRestyleResultFromNewContext(nsIFrame* aSelf,
|
|
|
|
nsStyleContext* aNewContext);
|
2013-07-31 00:36:09 +00:00
|
|
|
|
2013-07-31 00:36:11 +00:00
|
|
|
/**
|
|
|
|
* Helpers for RestyleChildren().
|
|
|
|
*/
|
2014-11-20 18:24:10 +00:00
|
|
|
void RestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint);
|
2014-11-20 18:24:10 +00:00
|
|
|
/**
|
|
|
|
* In the following two methods, aParentStyleContext is either
|
|
|
|
* mFrame->StyleContext() if we have a frame, or a display:contents
|
|
|
|
* style context if we don't.
|
|
|
|
*/
|
2014-11-20 18:24:10 +00:00
|
|
|
void DoRestyleUndisplayedDescendants(nsRestyleHint aChildRestyleHint,
|
2014-11-20 18:24:10 +00:00
|
|
|
nsIContent* aParent,
|
|
|
|
nsStyleContext* aParentStyleContext);
|
2014-11-20 18:24:10 +00:00
|
|
|
void RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint,
|
|
|
|
UndisplayedNode* aUndisplayed,
|
|
|
|
nsIContent* aUndisplayedParent,
|
2014-11-20 18:24:10 +00:00
|
|
|
nsStyleContext* aParentStyleContext,
|
2014-11-20 18:24:10 +00:00
|
|
|
const uint8_t aDisplay);
|
2014-08-25 04:48:21 +00:00
|
|
|
void MaybeReframeForBeforePseudo();
|
2014-11-20 18:24:10 +00:00
|
|
|
void MaybeReframeForBeforePseudo(nsIFrame* aGenConParentFrame,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext);
|
2014-08-25 04:48:21 +00:00
|
|
|
void MaybeReframeForAfterPseudo(nsIFrame* aFrame);
|
2014-11-20 18:24:10 +00:00
|
|
|
void MaybeReframeForAfterPseudo(nsIFrame* aGenConParentFrame,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext);
|
2013-09-25 19:28:07 +00:00
|
|
|
void RestyleContentChildren(nsIFrame* aParent,
|
|
|
|
nsRestyleHint aChildRestyleHint);
|
2014-11-20 18:24:10 +00:00
|
|
|
void InitializeAccessibilityNotifications(nsStyleContext* aNewContext);
|
2013-07-31 00:36:11 +00:00
|
|
|
void SendAccessibilityNotifications();
|
|
|
|
|
2013-07-31 00:36:10 +00:00
|
|
|
enum DesiredA11yNotifications {
|
|
|
|
eSkipNotifications,
|
|
|
|
eSendAllNotifications,
|
|
|
|
eNotifyIfShown
|
|
|
|
};
|
|
|
|
|
|
|
|
enum A11yNotificationType {
|
|
|
|
eDontNotify,
|
|
|
|
eNotifyShown,
|
|
|
|
eNotifyHidden
|
|
|
|
};
|
|
|
|
|
2014-09-25 05:45:36 +00:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
int32_t& LoggingDepth() { return mLoggingDepth; }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
static nsCString RestyleResultToString(RestyleResult aRestyleResult);
|
|
|
|
#endif
|
|
|
|
|
2013-07-31 00:36:09 +00:00
|
|
|
private:
|
|
|
|
nsPresContext* const mPresContext;
|
2013-07-31 00:36:09 +00:00
|
|
|
nsIFrame* const mFrame;
|
2013-07-31 00:36:09 +00:00
|
|
|
nsIContent* const mParentContent;
|
|
|
|
// |mContent| is the node that we used for rule matching of
|
|
|
|
// normal elements (not pseudo-elements) and for which we generate
|
|
|
|
// framechange hints if we need them.
|
|
|
|
nsIContent* const mContent;
|
2013-07-31 00:36:10 +00:00
|
|
|
nsStyleChangeList* const mChangeList;
|
2013-07-31 00:36:09 +00:00
|
|
|
// We have already generated change list entries for hints listed in
|
|
|
|
// mHintsHandled (initially it's those handled by ancestors, but by
|
|
|
|
// the end of Restyle it is those handled for this frame as well). We
|
|
|
|
// need to generate a new change list entry for the frame when its
|
|
|
|
// style comparision returns a hint other than one of these hints.
|
|
|
|
nsChangeHint mHintsHandled;
|
2013-07-31 00:36:10 +00:00
|
|
|
// See nsStyleContext::CalcStyleDifference
|
|
|
|
nsChangeHint mParentFrameHintsNotHandledForDescendants;
|
|
|
|
nsChangeHint mHintsNotHandledForDescendants;
|
2013-07-31 00:36:10 +00:00
|
|
|
RestyleTracker& mRestyleTracker;
|
2013-07-31 00:36:10 +00:00
|
|
|
TreeMatchContext& mTreeMatchContext;
|
2013-07-31 00:36:11 +00:00
|
|
|
nsIFrame* mResolvedChild; // child that provides our parent style context
|
2015-02-17 22:28:53 +00:00
|
|
|
// Array of style context subtrees in which we need to clear out cached
|
|
|
|
// structs at the end of the restyle (after change hints have been
|
|
|
|
// processed).
|
|
|
|
nsTArray<ContextToClear>& mContextsToClear;
|
|
|
|
// Style contexts that had old structs swapped into it and which should
|
|
|
|
// stay alive until the end of the restyle. (See comment in
|
|
|
|
// ElementRestyler::Restyle.)
|
|
|
|
nsTArray<nsRefPtr<nsStyleContext>>& mSwappedStructOwners;
|
2013-07-31 00:36:10 +00:00
|
|
|
|
2013-08-01 02:15:19 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2013-07-31 00:36:10 +00:00
|
|
|
const DesiredA11yNotifications mDesiredA11yNotifications;
|
|
|
|
DesiredA11yNotifications mKidsDesiredA11yNotifications;
|
|
|
|
A11yNotificationType mOurA11yNotification;
|
2013-07-31 00:36:10 +00:00
|
|
|
nsTArray<nsIContent*>& mVisibleKidsOfHiddenElement;
|
2013-07-31 00:36:11 +00:00
|
|
|
bool mWasFrameVisible;
|
2013-08-01 02:15:19 +00:00
|
|
|
#endif
|
2014-09-25 05:45:36 +00:00
|
|
|
|
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
int32_t mLoggingDepth;
|
|
|
|
#endif
|
2013-07-31 00:36:09 +00:00
|
|
|
};
|
|
|
|
|
2014-11-20 18:24:09 +00:00
|
|
|
/**
|
|
|
|
* This pushes any display:contents nodes onto a TreeMatchContext.
|
|
|
|
* Use it before resolving style for kids of aParent where aParent
|
|
|
|
* (and further ancestors) may be display:contents nodes which have
|
|
|
|
* not yet been pushed onto TreeMatchContext.
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
class MOZ_STACK_CLASS AutoDisplayContentsAncestorPusher final
|
2014-11-20 18:24:09 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
AutoDisplayContentsAncestorPusher(TreeMatchContext& aTreeMatchContext,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsIContent* aParent);
|
|
|
|
~AutoDisplayContentsAncestorPusher();
|
|
|
|
bool IsEmpty() const { return mAncestors.Length() == 0; }
|
|
|
|
private:
|
|
|
|
TreeMatchContext& mTreeMatchContext;
|
|
|
|
nsPresContext* const mPresContext;
|
|
|
|
nsAutoTArray<mozilla::dom::Element*, 4> mAncestors;
|
|
|
|
};
|
|
|
|
|
2013-07-20 19:14:24 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* mozilla_RestyleManager_h */
|