Bug 1351791: Simplify PostRestyleEventForLazyConstruction. r?bholley
MozReview-Commit-ID: 2jsrojLzYeo
--- a/layout/base/GeckoRestyleManager.cpp
+++ b/layout/base/GeckoRestyleManager.cpp
@@ -600,24 +600,23 @@ GeckoRestyleManager::UpdateOnlyAnimation
}
ProcessRestyles(tracker);
transitionManager->SetInAnimationOnlyStyleUpdate(false);
}
void
-GeckoRestyleManager::PostRestyleEventInternal(bool aForLazyConstruction)
+GeckoRestyleManager::PostRestyleEventInternal()
{
// Make sure we're not in a style refresh; if we are, we still have
// a call to ProcessPendingRestyles coming and there's no need to
// add ourselves as a refresh observer until then.
- bool inRefresh = !aForLazyConstruction && mInStyleRefresh;
nsIPresShell* presShell = PresContext()->PresShell();
- if (!inRefresh) {
+ if (!mInStyleRefresh) {
presShell->ObserveStyleFlushes();
}
// Unconditionally flag our document as needing a flush. The other
// option here would be a dedicated boolean to track whether we need
// to do so (set here and unset in ProcessPendingRestyles).
presShell->SetNeedStyleFlush();
}
@@ -645,17 +644,17 @@ GeckoRestyleManager::PostRestyleEvent(El
// Set mHavePendingNonAnimationRestyles for any restyle that could
// possibly contain non-animation styles (i.e., those that require us
// to do an animation-only style flush before processing style changes
// to ensure correct initialization of CSS transitions).
if (aRestyleHint & ~eRestyle_AllHintsWithAnimations) {
mHavePendingNonAnimationRestyles = true;
}
- PostRestyleEventInternal(false);
+ PostRestyleEventInternal();
}
void
GeckoRestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint)
{
NS_ASSERTION(!(aExtraHint & nsChangeHint_ReconstructFrame),
"Should not reconstruct the root of the frame tree. "
@@ -664,17 +663,17 @@ GeckoRestyleManager::PostRebuildAllStyle
"PostRebuildAllStyleDataEvent does not handle "
"eRestyle_SomeDescendants");
mDoRebuildAllStyleData = true;
mRebuildAllExtraHint |= aExtraHint;
mRebuildAllRestyleHint |= aRestyleHint;
// Get a restyle event posted if necessary
- PostRestyleEventInternal(false);
+ PostRestyleEventInternal();
}
// aContent must be the content for the frame in question, which may be
// :before/:after content
/* static */ bool
GeckoRestyleManager::TryInitiatingTransition(nsPresContext* aPresContext,
nsIContent* aContent,
nsStyleContext* aOldStyleContext,
--- a/layout/base/GeckoRestyleManager.h
+++ b/layout/base/GeckoRestyleManager.h
@@ -52,18 +52,16 @@ protected:
}
public:
// Forwarded nsIDocumentObserver method, to handle restyling (and
// passing the notification to the frame).
void ContentStateChanged(nsIContent* aContent,
EventStates aStateMask);
- void PostRestyleEventForLazyConstruction() { PostRestyleEventInternal(true); }
-
// Forwarded nsIMutationObserver method, to handle restyling.
void AttributeWillChange(Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType,
const nsAttrValue* aNewValue);
// Forwarded nsIMutationObserver method, to handle restyling (and
// passing the notification to the frame).
@@ -110,18 +108,20 @@ public:
* @param aFrame the root of the subtree to reparent. Must not be null.
*/
nsresult ReparentStyleContext(nsIFrame* aFrame);
void ClearSelectors() {
mPendingRestyles.ClearSelectors();
}
+ void PostRestyleEventForLazyConstruction() { PostRestyleEventInternal(); }
+
private:
- void PostRestyleEventInternal(bool aForLazyConstruction);
+ void PostRestyleEventInternal();
// Used when restyling an element with a frame.
void ComputeAndProcessStyleChange(nsIFrame* aFrame,
nsChangeHint aMinChange,
RestyleTracker& aRestyleTracker,
nsRestyleHint aRestyleHint,
const RestyleHintData& aRestyleHintData);
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7408,16 +7408,17 @@ nsCSSFrameConstructor::StyleNewChildRang
void
nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent,
bool aAllowLazyConstruction,
TreeMatchContext* aProvidedTreeMatchContext)
{
MOZ_ASSERT_IF(aProvidedTreeMatchContext, !aAllowLazyConstruction);
+ MOZ_ASSERT_IF(aAllowLazyConstruction, !RestyleManager()->IsInStyleRefresh());
AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC);
NS_PRECONDITION(mUpdateCount != 0,
"Should be in an update while creating frames");
#ifdef DEBUG
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ContentAppended container=%p "
@@ -7481,21 +7482,16 @@ nsCSSFrameConstructor::ContentAppended(n
}
return;
}
if (aAllowLazyConstruction &&
MaybeConstructLazily(CONTENTAPPEND, aContainer, aFirstNewContent)) {
if (isNewlyAddedContentForServo) {
aContainer->AsElement()->NoteDirtyDescendantsForServo();
- } else {
- // Lazy frame construction is done by the restyle flushes, so we need to
- // ensure a refresh happens.
- mPresShell->SetNeedStyleFlush();
- mPresShell->ObserveStyleFlushes();
}
return;
}
}
// We couldn't construct lazily. Make Servo eagerly traverse the new content.
if (isNewlyAddedContentForServo) {
StyleNewChildRange(aFirstNewContent, nullptr);
@@ -7812,16 +7808,19 @@ nsCSSFrameConstructor::ContentInserted(n
void
nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
nsILayoutHistoryState* aFrameState,
bool aAllowLazyConstruction,
TreeMatchContext* aProvidedTreeMatchContext)
{
+ MOZ_ASSERT_IF(aProvidedTreeMatchContext, !aAllowLazyConstruction);
+ MOZ_ASSERT_IF(aAllowLazyConstruction, !RestyleManager()->IsInStyleRefresh());
+
AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC);
NS_PRECONDITION(mUpdateCount != 0,
"Should be in an update while creating frames");
NS_PRECONDITION(aStartChild, "must always pass a child");
// XXXldb Do we need to re-resolve style to handle the CSS2 + combinator and
// the :empty pseudo-class?
@@ -7963,21 +7962,16 @@ nsCSSFrameConstructor::ContentRangeInser
// Otherwise, we've got parent content. Find its frame.
NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer ||
GetDisplayContentsStyleFor(aContainer), "New XBL code is possibly wrong!");
if (aAllowLazyConstruction &&
MaybeConstructLazily(CONTENTINSERT, aContainer, aStartChild)) {
if (isNewlyAddedContentForServo) {
aContainer->AsElement()->NoteDirtyDescendantsForServo();
- } else {
- // Lazy frame construction is done by the restyle flushes, so we need to
- // ensure a refresh happens.
- mPresShell->SetNeedStyleFlush();
- mPresShell->ObserveStyleFlushes();
}
return;
}
}
// We couldn't construct lazily. Make Servo eagerly traverse the new content.
if (isNewlyAddedContentForServo) {
StyleNewChildRange(aStartChild, aEndChild);