Bug 828312 patch 11: Don't generate change hints for restyling of later continuations, since the handling of the change hints from the first continuation is required to do the necessary work. r=bzbarsky

This depends on bug 898333 in order to avoid causing:
TEST-UNEXPECTED-FAIL | chrome://mochitests/content/chrome/dom/tests/mochitest/chrome/test_focused_link_scroll.xul | Assertion count 1 is greater than expected range 0-0 assertions.
due to the assertion:
###!!! ASSERTION: Shouldn't be trying to restyle non-elements directly: '!aContent || aContent->IsElement()', file ../../../layout/base/nsStyleChangeList.cpp, line 62

The assertion count change in layout/generic/crashtests/571995.xhtml is
expected because it changes us from having 7 of:
###!!! ASSERTION: Shouldn't be trying to restyle non-elements directly: '!aContent || aContent->IsElement()', file ../../../layout/base/nsStyleChangeList.cpp, line 62
with the stack:
  mozilla::ElementRestyler::CaptureChange(nsStyleContext*, nsStyleContext*, nsChangeHint) [layout/base/nsChangeHint.h:191]
  mozilla::ElementRestyler::RestyleSelf(nsRestyleHint) [layout/base/RestyleManager.cpp:2304]
to only having one.  This is expected since this patch changes
RestyleSelf to only call CaptureChange for the first continuation or
block-in-inline sibling.
This commit is contained in:
L. David Baron 2013-09-25 12:28:08 -07:00
parent 36acc15f31
commit d01753dad0
3 changed files with 23 additions and 23 deletions

View File

@ -1923,14 +1923,16 @@ RestyleManager::ReparentStyleContext(nsIFrame* aFrame)
// Make sure to call CalcStyleDifference so that the new context ends
// up resolving all the structs the old context resolved.
DebugOnly<nsChangeHint> styleChange =
oldContext->CalcStyleDifference(newContext, nsChangeHint(0));
// The style change is always 0 because we have the same rulenode and
// CalcStyleDifference optimizes us away. That's OK, though:
// reparenting should never trigger a frame reconstruct, and whenever
// it's happening we already plan to reflow and repaint the frames.
NS_ASSERTION(!(styleChange & nsChangeHint_ReconstructFrame),
"Our frame tree is likely to be bogus!");
if (!copyFromContinuation) {
DebugOnly<nsChangeHint> styleChange =
oldContext->CalcStyleDifference(newContext, nsChangeHint(0));
// The style change is always 0 because we have the same rulenode and
// CalcStyleDifference optimizes us away. That's OK, though:
// reparenting should never trigger a frame reconstruct, and whenever
// it's happening we already plan to reflow and repaint the frames.
NS_ASSERTION(!(styleChange & nsChangeHint_ReconstructFrame),
"Our frame tree is likely to be bogus!");
}
aFrame->SetStyleContext(newContext);
@ -1986,7 +1988,7 @@ RestyleManager::ReparentStyleContext(nsIFrame* aFrame)
// Make sure to call CalcStyleDifference so that the new
// context ends up resolving all the structs the old context
// resolved.
styleChange =
DebugOnly<nsChangeHint> styleChange =
oldExtraContext->CalcStyleDifference(newExtraContext,
nsChangeHint(0));
// The style change is always 0 because we have the same
@ -2112,7 +2114,6 @@ ElementRestyler::ElementRestyler(ParentContextFromChildFrame,
void
ElementRestyler::CaptureChange(nsStyleContext* aOldContext,
nsStyleContext* aNewContext,
nsIFrame* aContinuation, // TEMPORARY (until bug 828312 patch 11)
nsChangeHint aChangeToAssume)
{
// Check some invariants about replacing one style context with another.
@ -2138,7 +2139,7 @@ ElementRestyler::CaptureChange(nsStyleContext* aOldContext,
NS_UpdateHint(ourChange, aChangeToAssume);
if (NS_UpdateHint(mHintsHandled, ourChange)) {
if (!(ourChange & nsChangeHint_ReconstructFrame) || mContent) {
mChangeList->AppendChange(aContinuation, mContent, ourChange);
mChangeList->AppendChange(mFrame, mContent, ourChange);
}
}
NS_UpdateHint(mHintsNotHandledForDescendants,
@ -2197,15 +2198,9 @@ ElementRestyler::Restyle(nsRestyleHint aRestyleHint)
// TEMPORARY (until bug 918064): Call RestyleSelf for each
// continuation or block-in-inline sibling.
nsChangeHint hintsHandled = mHintsHandled;
for (nsIFrame* f = mFrame; f;
f = GetNextContinuationWithSameStyle(f, oldContext)) {
// restore for each continuation, since we need the change hint
// posted for each continuation and failing to restore would
// suppress that.
mHintsHandled = hintsHandled;
RestyleSelf(f, aRestyleHint);
}
}
@ -2380,11 +2375,18 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint)
if (!copyFromContinuation) {
TryStartingTransition(mPresContext, aSelf->GetContent(),
oldContext, &newContext);
CaptureChange(oldContext, newContext, assumeDifferenceHint);
}
CaptureChange(oldContext, newContext, aSelf, assumeDifferenceHint);
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
// if frame gets regenerated, let it keep old context
// If the frame gets regenerated, let it keep its old context,
// which is important to maintain various invariants about
// frame types matching their style contexts.
// Note that this check even makes sense if we didn't call
// CaptureChange because of copyFromContinuation being true,
// since we'll have copied the existing context from the
// previous continuation, so newContext == oldContext.
aSelf->SetStyleContext(newContext);
}
}
@ -2422,8 +2424,7 @@ ElementRestyler::RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint)
MOZ_ASSERT(newExtraContext);
if (oldExtraContext != newExtraContext) {
CaptureChange(oldExtraContext, newExtraContext, aSelf,
assumeDifferenceHint);
CaptureChange(oldExtraContext, newExtraContext, assumeDifferenceHint);
if (!(mHintsHandled & nsChangeHint_ReconstructFrame)) {
aSelf->SetAdditionalStyleContext(contextIndex, newExtraContext);
}

View File

@ -336,7 +336,6 @@ private:
*/
void CaptureChange(nsStyleContext* aOldContext,
nsStyleContext* aNewContext,
nsIFrame* aContinuation, // TEMPORARY (until bug 828312 patch 11)
nsChangeHint aChangeToAssume);
/**

View File

@ -389,7 +389,7 @@ load 570160.html
load 570289-1.html
load 571618-1.svg
asserts(1) load 571975-1.html # bug 574889
asserts(7) load 571995.xhtml # 761848
asserts(1) load 571995.xhtml # 761848
load 574958.xhtml
asserts(0-4) load 578977.html # bug 757305
load 580504-1.xhtml