2010-06-18 20:23:04 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2010-06-18 20:23:04 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A class which manages pending restyles. This handles keeping track
|
|
|
|
* of what nodes restyles need to happen on and so forth.
|
|
|
|
*/
|
|
|
|
|
2013-07-20 23:14:24 +04:00
|
|
|
#ifndef mozilla_RestyleTracker_h
|
|
|
|
#define mozilla_RestyleTracker_h
|
2010-06-18 23:35:52 +04:00
|
|
|
|
2010-06-18 20:23:04 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2016-07-28 03:22:13 +03:00
|
|
|
#include "mozilla/OverflowChangedTracker.h"
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2014-09-05 07:48:48 +04:00
|
|
|
#include "nsClassHashtable.h"
|
2014-05-25 02:20:39 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2016-08-19 03:03:49 +03:00
|
|
|
#include "nsIContentInlines.h"
|
2013-01-16 03:12:40 +04:00
|
|
|
#include "mozilla/SplayTree.h"
|
2014-09-25 09:45:36 +04:00
|
|
|
#include "mozilla/RestyleLogging.h"
|
2015-03-19 04:19:00 +03:00
|
|
|
#include "GeckoProfiler.h"
|
2015-08-05 15:42:21 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2010-06-18 20:23:04 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-08-04 00:11:55 +04:00
|
|
|
class ElementRestyler;
|
2017-02-13 06:21:32 +03:00
|
|
|
class GeckoRestyleManager;
|
2013-07-20 23:14:25 +04:00
|
|
|
|
2010-06-18 20:23:04 +04:00
|
|
|
class RestyleTracker {
|
|
|
|
public:
|
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2014-08-04 00:11:55 +04:00
|
|
|
friend class ElementRestyler; // for AddPendingRestyleToTable
|
|
|
|
|
2014-09-25 09:45:36 +04:00
|
|
|
explicit RestyleTracker(Element::FlagsType aRestyleBits)
|
|
|
|
: mRestyleBits(aRestyleBits)
|
|
|
|
, mHaveLaterSiblingRestyles(false)
|
2015-08-05 15:42:21 +03:00
|
|
|
, mHaveSelectors(false)
|
2010-06-18 20:23:04 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION((mRestyleBits & ~ELEMENT_ALL_RESTYLE_FLAGS) == 0,
|
|
|
|
"Why do we have these bits set?");
|
|
|
|
NS_PRECONDITION((mRestyleBits & ELEMENT_PENDING_RESTYLE_FLAGS) != 0,
|
|
|
|
"Must have a restyle flag");
|
|
|
|
NS_PRECONDITION((mRestyleBits & ELEMENT_PENDING_RESTYLE_FLAGS) !=
|
|
|
|
ELEMENT_PENDING_RESTYLE_FLAGS,
|
|
|
|
"Shouldn't have both restyle flags set");
|
2015-09-12 12:08:10 +03:00
|
|
|
NS_PRECONDITION((mRestyleBits & ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS) != 0,
|
2010-06-18 20:23:04 +04:00
|
|
|
"Must have root flag");
|
2015-09-12 12:08:10 +03:00
|
|
|
NS_PRECONDITION((mRestyleBits & ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS) !=
|
|
|
|
ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS,
|
2010-06-18 20:23:04 +04:00
|
|
|
"Shouldn't have both root flags");
|
|
|
|
}
|
|
|
|
|
2017-02-13 06:21:32 +03:00
|
|
|
void Init(GeckoRestyleManager* aRestyleManager) {
|
2013-07-20 23:14:25 +04:00
|
|
|
mRestyleManager = aRestyleManager;
|
2010-06-18 20:23:04 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t Count() const {
|
2010-06-18 20:23:04 +04:00
|
|
|
return mPendingRestyles.Count();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-06-18 20:23:05 +04:00
|
|
|
* Add a restyle for the given element to the tracker. Returns true
|
|
|
|
* if the element already had eRestyle_LaterSiblings set on it.
|
2015-08-05 15:42:21 +03:00
|
|
|
*
|
|
|
|
* aRestyleRoot is the closest restyle root for aElement. If the caller
|
|
|
|
* does not know what the closest restyle root is, Nothing should be
|
|
|
|
* passed. A Some(nullptr) restyle root can be passed if there is no
|
|
|
|
* ancestor element that is a restyle root.
|
2010-06-18 20:23:04 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool AddPendingRestyle(Element* aElement, nsRestyleHint aRestyleHint,
|
2015-08-05 15:42:20 +03:00
|
|
|
nsChangeHint aMinChangeHint,
|
2015-08-05 15:42:21 +03:00
|
|
|
const RestyleHintData* aRestyleHintData = nullptr,
|
2017-02-13 20:07:40 +03:00
|
|
|
const mozilla::Maybe<Element*>& aRestyleRoot =
|
2015-08-05 15:42:21 +03:00
|
|
|
mozilla::Nothing());
|
|
|
|
|
|
|
|
Element* FindClosestRestyleRoot(Element* aElement);
|
2010-06-18 20:23:04 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Process the restyles we've been tracking.
|
|
|
|
*/
|
2015-01-14 08:03:12 +03:00
|
|
|
void DoProcessRestyles();
|
2010-06-18 20:23:04 +04:00
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
// Return our ELEMENT_HAS_PENDING_(ANIMATION_)RESTYLE bit
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t RestyleBit() const {
|
2010-06-18 20:23:05 +04:00
|
|
|
return mRestyleBits & ELEMENT_PENDING_RESTYLE_FLAGS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return our ELEMENT_IS_POTENTIAL_(ANIMATION_)RESTYLE_ROOT bit
|
2014-06-19 04:07:26 +04:00
|
|
|
Element::FlagsType RootBit() const {
|
2015-09-12 12:08:10 +03:00
|
|
|
return mRestyleBits & ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return our ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR bit if present,
|
|
|
|
// or 0 if it is not.
|
|
|
|
Element::FlagsType ConditionalDescendantsBit() const {
|
|
|
|
return mRestyleBits & ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR;
|
2010-06-18 20:23:05 +04:00
|
|
|
}
|
2014-09-05 07:48:48 +04:00
|
|
|
|
2014-09-19 05:12:30 +04:00
|
|
|
struct Hints {
|
2015-08-05 15:42:20 +03:00
|
|
|
nsRestyleHint mRestyleHint; // What we want to restyle
|
|
|
|
nsChangeHint mChangeHint; // The minimal change hint for "self"
|
|
|
|
RestyleHintData mRestyleHintData; // Data associated with mRestyleHint
|
2014-09-19 05:12:30 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RestyleData : Hints {
|
2014-09-05 07:48:48 +04:00
|
|
|
RestyleData() {
|
|
|
|
mRestyleHint = nsRestyleHint(0);
|
2016-07-17 17:20:21 +03:00
|
|
|
mChangeHint = nsChangeHint(0);
|
2014-09-05 07:48:48 +04:00
|
|
|
}
|
|
|
|
|
2015-08-05 15:42:20 +03:00
|
|
|
RestyleData(nsRestyleHint aRestyleHint, nsChangeHint aChangeHint,
|
|
|
|
const RestyleHintData* aRestyleHintData) {
|
2014-09-05 07:48:48 +04:00
|
|
|
mRestyleHint = aRestyleHint;
|
|
|
|
mChangeHint = aChangeHint;
|
2015-08-05 15:42:20 +03:00
|
|
|
if (aRestyleHintData) {
|
|
|
|
mRestyleHintData = *aRestyleHintData;
|
|
|
|
}
|
2014-09-05 07:48:48 +04:00
|
|
|
}
|
|
|
|
|
2014-09-05 07:48:47 +04:00
|
|
|
// Descendant elements we must check that we ended up restyling, ordered
|
|
|
|
// with the same invariant as mRestyleRoots. The elements here are those
|
|
|
|
// that we called AddPendingRestyle for and found the element this is
|
|
|
|
// the RestyleData for as its nearest restyle root.
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<Element>> mDescendants;
|
2017-10-04 01:11:18 +03:00
|
|
|
#if defined(MOZ_GECKO_PROFILER)
|
2017-01-06 17:21:01 +03:00
|
|
|
UniqueProfilerBacktrace mBacktrace;
|
2017-10-04 01:11:18 +03:00
|
|
|
#endif
|
2010-06-18 20:23:04 +04:00
|
|
|
};
|
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
/**
|
|
|
|
* If the given Element has a restyle pending for it, return the
|
|
|
|
* relevant restyle data. This function will clear everything other
|
|
|
|
* than a possible eRestyle_LaterSiblings hint for aElement out of
|
|
|
|
* our hashtable. The returned aData will never have an
|
|
|
|
* eRestyle_LaterSiblings hint in it.
|
|
|
|
*
|
|
|
|
* The return value indicates whether any restyle data was found for
|
2014-09-05 07:48:48 +04:00
|
|
|
* the element. aData is set to nullptr iff false is returned.
|
2010-06-18 20:23:05 +04:00
|
|
|
*/
|
2014-09-05 07:48:48 +04:00
|
|
|
bool GetRestyleData(Element* aElement, nsAutoPtr<RestyleData>& aData);
|
2010-06-18 20:23:05 +04:00
|
|
|
|
2015-08-05 15:42:20 +03:00
|
|
|
/**
|
|
|
|
* Returns whether there is a RestyleData entry in mPendingRestyles
|
|
|
|
* for the given element.
|
|
|
|
*/
|
|
|
|
bool HasRestyleData(Element* aElement) {
|
|
|
|
return mPendingRestyles.Contains(aElement);
|
|
|
|
}
|
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
/**
|
2014-09-05 07:48:47 +04:00
|
|
|
* For each element in aElements, appends it to mRestyleRoots if it
|
|
|
|
* has its restyle bit set. This is used to ensure we restyle elements
|
|
|
|
* that we did not add as restyle roots initially (due to there being
|
|
|
|
* an ancestor with the restyle root bit set), but which we might
|
|
|
|
* not have got around to restyling due to the restyle process
|
2016-07-19 16:10:59 +03:00
|
|
|
* terminating early with RestyleResul::eStop (see ElementRestyler::Restyle).
|
2014-09-05 07:48:47 +04:00
|
|
|
*
|
|
|
|
* This function must be called with elements in order such that
|
|
|
|
* appending them to mRestyleRoots maintains its ordering invariant that
|
|
|
|
* ancestors appear after descendants.
|
|
|
|
*/
|
|
|
|
void AddRestyleRootsIfAwaitingRestyle(
|
2015-10-18 08:24:48 +03:00
|
|
|
const nsTArray<RefPtr<Element>>& aElements);
|
2014-09-05 07:48:47 +04:00
|
|
|
|
2015-08-05 15:42:21 +03:00
|
|
|
/**
|
|
|
|
* Converts any eRestyle_SomeDescendants restyle hints in the pending restyle
|
|
|
|
* table into eRestyle_Subtree hints and clears out the associated arrays of
|
|
|
|
* nsCSSSelector pointers. This is called in response to a style sheet change
|
|
|
|
* that might have cause an nsCSSSelector to be destroyed.
|
|
|
|
*/
|
|
|
|
void ClearSelectors();
|
|
|
|
|
2014-09-05 07:48:47 +04:00
|
|
|
/**
|
2010-06-18 20:23:05 +04:00
|
|
|
* The document we're associated with.
|
|
|
|
*/
|
|
|
|
inline nsIDocument* Document() const;
|
|
|
|
|
2014-09-25 09:45:36 +04:00
|
|
|
#ifdef RESTYLE_LOGGING
|
|
|
|
// Defined in RestyleTrackerInlines.h.
|
|
|
|
inline bool ShouldLogRestyle();
|
|
|
|
inline int32_t& LoggingDepth();
|
|
|
|
#endif
|
|
|
|
|
2010-06-18 20:23:04 +04:00
|
|
|
private:
|
2014-08-04 00:11:55 +04:00
|
|
|
bool AddPendingRestyleToTable(Element* aElement, nsRestyleHint aRestyleHint,
|
2015-08-05 15:42:20 +03:00
|
|
|
nsChangeHint aMinChangeHint,
|
|
|
|
const RestyleHintData* aRestyleHintData = nullptr);
|
2014-08-04 00:11:55 +04:00
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
/**
|
2010-06-18 20:23:05 +04:00
|
|
|
* Handle a single mPendingRestyles entry. aRestyleHint must not
|
|
|
|
* include eRestyle_LaterSiblings; that needs to be dealt with
|
|
|
|
* before calling this function.
|
2010-06-18 20:23:05 +04:00
|
|
|
*/
|
2010-06-18 20:23:05 +04:00
|
|
|
inline void ProcessOneRestyle(Element* aElement,
|
|
|
|
nsRestyleHint aRestyleHint,
|
2015-08-05 15:42:20 +03:00
|
|
|
nsChangeHint aChangeHint,
|
|
|
|
const RestyleHintData& aRestyleHintData);
|
2010-06-18 20:23:05 +04:00
|
|
|
|
2014-09-05 07:48:48 +04:00
|
|
|
typedef nsClassHashtable<nsISupportsHashKey, RestyleData> PendingRestyleTable;
|
2016-02-02 18:36:30 +03:00
|
|
|
typedef AutoTArray< RefPtr<Element>, 32> RestyleRootArray;
|
2010-06-18 20:23:04 +04:00
|
|
|
// Our restyle bits. These will be a subset of ELEMENT_ALL_RESTYLE_FLAGS, and
|
2015-09-12 12:08:10 +03:00
|
|
|
// will include one flag from ELEMENT_PENDING_RESTYLE_FLAGS, one flag
|
|
|
|
// from ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS, and might also include
|
|
|
|
// ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR.
|
2014-06-19 04:07:26 +04:00
|
|
|
Element::FlagsType mRestyleBits;
|
2017-02-13 06:21:32 +03:00
|
|
|
GeckoRestyleManager* mRestyleManager; // Owns us
|
2014-09-05 07:48:48 +04:00
|
|
|
// A hashtable that maps elements to pointers to RestyleData structs. The
|
2010-06-18 20:23:05 +04:00
|
|
|
// values only make sense if the element's current document is our
|
|
|
|
// document and it has our RestyleBit() flag set. In particular,
|
|
|
|
// said bit might not be set if the element had a restyle posted and
|
|
|
|
// then was moved around in the DOM.
|
2010-06-18 20:23:04 +04:00
|
|
|
PendingRestyleTable mPendingRestyles;
|
2010-06-18 20:23:05 +04:00
|
|
|
// An array that keeps track of our possible restyle roots. This
|
|
|
|
// maintains the invariant that if A and B are both restyle roots
|
|
|
|
// and A is an ancestor of B then A will come after B in the array.
|
|
|
|
// We maintain this invariant by checking whether an element has an
|
|
|
|
// ancestor with the restyle root bit set before appending it to the
|
|
|
|
// array.
|
|
|
|
RestyleRootArray mRestyleRoots;
|
|
|
|
// True if we have some entries with the eRestyle_LaterSiblings
|
|
|
|
// flag. We need this to avoid enumerating the hashtable looking
|
|
|
|
// for such entries when we can't possibly have any.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mHaveLaterSiblingRestyles;
|
2015-08-05 15:42:21 +03:00
|
|
|
// True if we have some entries with selectors in the restyle hint data.
|
|
|
|
// We use this to skip iterating over mPendingRestyles in ClearSelectors.
|
|
|
|
bool mHaveSelectors;
|
2010-06-18 20:23:04 +04:00
|
|
|
};
|
|
|
|
|
2014-08-04 00:11:55 +04:00
|
|
|
inline bool
|
|
|
|
RestyleTracker::AddPendingRestyleToTable(Element* aElement,
|
|
|
|
nsRestyleHint aRestyleHint,
|
2015-08-05 15:42:20 +03:00
|
|
|
nsChangeHint aMinChangeHint,
|
|
|
|
const RestyleHintData* aRestyleHintData)
|
2010-06-18 20:23:04 +04:00
|
|
|
{
|
2014-09-05 07:48:48 +04:00
|
|
|
RestyleData* existingData;
|
2010-06-18 20:23:04 +04:00
|
|
|
|
2015-08-05 15:42:21 +03:00
|
|
|
if (aRestyleHintData &&
|
|
|
|
!aRestyleHintData->mSelectorsForDescendants.IsEmpty()) {
|
|
|
|
mHaveSelectors = true;
|
|
|
|
}
|
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
// Check the RestyleBit() flag before doing the hashtable Get, since
|
|
|
|
// it's possible that the data in the hashtable isn't actually
|
|
|
|
// relevant anymore (if the flag is not set).
|
|
|
|
if (aElement->HasFlag(RestyleBit())) {
|
|
|
|
mPendingRestyles.Get(aElement, &existingData);
|
|
|
|
} else {
|
|
|
|
aElement->SetFlags(RestyleBit());
|
2014-09-05 07:48:48 +04:00
|
|
|
existingData = nullptr;
|
2010-06-18 20:23:05 +04:00
|
|
|
}
|
2010-06-18 20:23:04 +04:00
|
|
|
|
2015-09-12 12:08:10 +03:00
|
|
|
if (aRestyleHint & eRestyle_SomeDescendants) {
|
|
|
|
NS_ASSERTION(ConditionalDescendantsBit(),
|
|
|
|
"why are we getting eRestyle_SomeDescendants in an "
|
|
|
|
"animation-only restyle?");
|
|
|
|
aElement->SetFlags(ConditionalDescendantsBit());
|
|
|
|
}
|
|
|
|
|
2014-09-05 07:48:48 +04:00
|
|
|
if (!existingData) {
|
2015-08-05 15:42:20 +03:00
|
|
|
RestyleData* rd =
|
|
|
|
new RestyleData(aRestyleHint, aMinChangeHint, aRestyleHintData);
|
2017-10-04 01:11:18 +03:00
|
|
|
#if defined(MOZ_GECKO_PROFILER)
|
2017-05-01 07:23:34 +03:00
|
|
|
if (profiler_feature_active(ProfilerFeature::Restyle)) {
|
2017-01-06 17:21:01 +03:00
|
|
|
rd->mBacktrace = profiler_get_backtrace();
|
2015-03-19 04:19:00 +03:00
|
|
|
}
|
2017-10-04 01:11:18 +03:00
|
|
|
#endif
|
2015-03-19 04:19:00 +03:00
|
|
|
mPendingRestyles.Put(aElement, rd);
|
2014-09-05 07:48:48 +04:00
|
|
|
return false;
|
|
|
|
}
|
2010-06-18 20:23:04 +04:00
|
|
|
|
2014-09-05 07:48:48 +04:00
|
|
|
bool hadRestyleLaterSiblings =
|
|
|
|
(existingData->mRestyleHint & eRestyle_LaterSiblings) != 0;
|
|
|
|
existingData->mRestyleHint =
|
|
|
|
nsRestyleHint(existingData->mRestyleHint | aRestyleHint);
|
2016-05-23 06:26:03 +03:00
|
|
|
existingData->mChangeHint |= aMinChangeHint;
|
2015-08-05 15:42:20 +03:00
|
|
|
if (aRestyleHintData) {
|
|
|
|
existingData->mRestyleHintData.mSelectorsForDescendants
|
|
|
|
.AppendElements(aRestyleHintData->mSelectorsForDescendants);
|
|
|
|
}
|
2010-06-18 20:23:05 +04:00
|
|
|
|
2014-08-04 00:11:55 +04:00
|
|
|
return hadRestyleLaterSiblings;
|
|
|
|
}
|
|
|
|
|
2015-08-05 15:42:21 +03:00
|
|
|
inline mozilla::dom::Element*
|
|
|
|
RestyleTracker::FindClosestRestyleRoot(Element* aElement)
|
|
|
|
{
|
|
|
|
Element* cur = aElement;
|
|
|
|
while (!cur->HasFlag(RootBit())) {
|
|
|
|
nsIContent* parent = cur->GetFlattenedTreeParent();
|
|
|
|
// Stop if we have no parent or the parent is not an element or
|
|
|
|
// we're part of the viewport scrollbars (because those are not
|
|
|
|
// frametree descendants of the primary frame of the root
|
|
|
|
// element).
|
|
|
|
// XXXbz maybe the primary frame of the root should be the root scrollframe?
|
|
|
|
if (!parent || !parent->IsElement() ||
|
|
|
|
// If we've hit the root via a native anonymous kid and that
|
|
|
|
// this native anonymous kid is not obviously a descendant
|
|
|
|
// of the root's primary frame, assume we're under the root
|
|
|
|
// scrollbars. Since those don't get reresolved when
|
|
|
|
// reresolving the root, we need to make sure to add the
|
|
|
|
// element to mRestyleRoots.
|
|
|
|
(cur->IsInNativeAnonymousSubtree() && !parent->GetParent() &&
|
|
|
|
cur->GetPrimaryFrame() &&
|
|
|
|
cur->GetPrimaryFrame()->GetParent() != parent->GetPrimaryFrame())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
cur = parent->AsElement();
|
|
|
|
}
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2014-08-04 00:11:55 +04:00
|
|
|
inline bool
|
|
|
|
RestyleTracker::AddPendingRestyle(Element* aElement,
|
|
|
|
nsRestyleHint aRestyleHint,
|
2015-08-05 15:42:20 +03:00
|
|
|
nsChangeHint aMinChangeHint,
|
2015-08-05 15:42:21 +03:00
|
|
|
const RestyleHintData* aRestyleHintData,
|
2017-02-13 20:07:40 +03:00
|
|
|
const mozilla::Maybe<Element*>& aRestyleRoot)
|
2014-08-04 00:11:55 +04:00
|
|
|
{
|
|
|
|
bool hadRestyleLaterSiblings =
|
2015-08-05 15:42:20 +03:00
|
|
|
AddPendingRestyleToTable(aElement, aRestyleHint, aMinChangeHint,
|
|
|
|
aRestyleHintData);
|
2014-08-04 00:11:55 +04:00
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
// We can only treat this element as a restyle root if we would
|
|
|
|
// actually restyle its descendants (so either call
|
2016-09-23 13:08:01 +03:00
|
|
|
// ElementRestyler::Restyle on it or just reframe it).
|
2014-08-03 06:37:43 +04:00
|
|
|
if ((aRestyleHint & ~eRestyle_LaterSiblings) ||
|
2010-06-18 20:23:05 +04:00
|
|
|
(aMinChangeHint & nsChangeHint_ReconstructFrame)) {
|
2015-08-05 15:42:21 +03:00
|
|
|
Element* cur =
|
|
|
|
aRestyleRoot ? *aRestyleRoot : FindClosestRestyleRoot(aElement);
|
|
|
|
if (!cur) {
|
|
|
|
mRestyleRoots.AppendElement(aElement);
|
|
|
|
cur = aElement;
|
2010-06-18 20:23:05 +04:00
|
|
|
}
|
|
|
|
// At this point some ancestor of aElement (possibly aElement
|
|
|
|
// itself) is in mRestyleRoots. Set the root bit on aElement, to
|
|
|
|
// speed up searching for an existing root on its descendants.
|
|
|
|
aElement->SetFlags(RootBit());
|
2014-09-05 07:48:45 +04:00
|
|
|
if (cur != aElement) {
|
|
|
|
// We are already going to restyle cur, one of aElement's ancestors,
|
|
|
|
// but we might not end up restyling all the way down to aElement.
|
|
|
|
// Record it in the RestyleData so we can ensure it does get restyled
|
|
|
|
// after we deal with cur.
|
|
|
|
//
|
|
|
|
// As with the mRestyleRoots array, mDescendants maintains the
|
|
|
|
// invariant that if two elements appear in the array and one
|
|
|
|
// is an ancestor of the other, that the ancestor appears after
|
|
|
|
// the descendant.
|
2014-09-05 07:48:48 +04:00
|
|
|
RestyleData* curData;
|
2014-09-05 07:48:45 +04:00
|
|
|
mPendingRestyles.Get(cur, &curData);
|
2017-04-18 02:49:49 +03:00
|
|
|
|
|
|
|
// Even if cur has a ForceDescendants restyle hint, we're not guaranteed
|
|
|
|
// to reach aElement in the case the PresShell posts a restyle event from
|
|
|
|
// PostRecreateFramesFor, so we need to track it here.
|
|
|
|
MOZ_ASSERT(curData, "expected to find a RestyleData for cur");
|
2017-04-27 01:26:40 +03:00
|
|
|
if (curData) {
|
|
|
|
curData->mDescendants.AppendElement(aElement);
|
|
|
|
}
|
2014-09-05 07:48:45 +04:00
|
|
|
}
|
2010-06-18 20:23:05 +04:00
|
|
|
}
|
|
|
|
|
2017-09-13 11:47:03 +03:00
|
|
|
// If we need to restyle later siblings, we will need a flag on parent to note
|
|
|
|
// that some children need restyle for nsComputedDOMStyle.
|
|
|
|
if (aRestyleHint & eRestyle_LaterSiblings) {
|
|
|
|
nsIContent* parent = aElement->GetFlattenedTreeParent();
|
|
|
|
if (parent && parent->IsElement()) {
|
|
|
|
parent->SetFlags(ELEMENT_HAS_CHILD_WITH_LATER_SIBLINGS_HINT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
mHaveLaterSiblingRestyles =
|
|
|
|
mHaveLaterSiblingRestyles || (aRestyleHint & eRestyle_LaterSiblings) != 0;
|
|
|
|
return hadRestyleLaterSiblings;
|
2010-06-18 20:23:04 +04:00
|
|
|
}
|
|
|
|
|
2010-06-18 23:18:02 +04:00
|
|
|
} // namespace mozilla
|
2010-06-18 20:23:04 +04:00
|
|
|
|
2013-07-20 23:14:24 +04:00
|
|
|
#endif /* mozilla_RestyleTracker_h */
|