Bug 931668 - Part 10: Record pending restyles of restyle root descendants and ensure we restyle them if we didn't get to them. r=dbaron

--HG--
extra : rebase_source : b259e02c38362a12735158e30d6aa54556cf54ab
This commit is contained in:
Cameron McCormack 2014-09-05 13:48:45 +10:00
Родитель 5cf22e3dc6
Коммит ba762a2f5c
3 изменённых файлов: 46 добавлений и 4 удалений

Просмотреть файл

@ -203,6 +203,23 @@ RestyleTracker::DoProcessRestyles()
}
ProcessOneRestyle(element, data.mRestyleHint, data.mChangeHint);
// Any descendant elements that we expected we would restyle,
// but did not up restyling, we should restyle next time around
// the loop.
//
// Note that data.mDescendants maintains the same invariant that
// mRestyleRoots does, i.e. that ancestors appear after descendants.
// Since we have removed |element| from the end of mRestyleRoots,
// and |element| is an ancestor of all elements in data.mDescendants,
// we are safe to simply append to the end of mRestyleRoots to
// maintain its invariant.
for (uint32_t i = 0; i < data.mDescendants.Length(); ++i) {
Element* descendant = data.mDescendants[i];
if (descendant->HasFlag(RestyleBit())) {
mRestyleRoots.AppendElement(descendant);
}
}
}
if (mHaveLaterSiblingRestyles) {
@ -232,6 +249,8 @@ RestyleTracker::DoProcessRestyles()
ProcessOneRestyle(currentRestyle->mElement,
currentRestyle->mRestyleHint,
currentRestyle->mChangeHint);
MOZ_ASSERT(currentRestyle->mDescendants.IsEmpty());
}
}
}
@ -261,6 +280,8 @@ RestyleTracker::GetRestyleData(Element* aElement, RestyleData* aData)
// element. Leave it around for now, but remove the other restyle
// hints and the change hint for it. Also unset its root bit,
// since it's no longer a root with the new restyle data.
NS_ASSERTION(aData->mDescendants.IsEmpty(),
"expected descendants to be handled by now");
RestyleData newData;
newData.mChangeHint = nsChangeHint(0);
newData.mRestyleHint = eRestyle_LaterSiblings;

Просмотреть файл

@ -290,6 +290,9 @@ public:
struct RestyleData {
nsRestyleHint mRestyleHint; // What we want to restyle
nsChangeHint mChangeHint; // The minimal change hint for "self"
nsTArray<Element*> mDescendants; // Descendant elements we must check that
// we ended up restyling, ordered with the
// same invariant as mRestyleRoots
};
/**
@ -400,7 +403,8 @@ RestyleTracker::AddPendingRestyle(Element* aElement,
// ReResolveStyleContext on it or just reframe it).
if ((aRestyleHint & ~eRestyle_LaterSiblings) ||
(aMinChangeHint & nsChangeHint_ReconstructFrame)) {
for (const Element* cur = aElement; !cur->HasFlag(RootBit()); ) {
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
@ -418,6 +422,7 @@ RestyleTracker::AddPendingRestyle(Element* aElement,
cur->GetPrimaryFrame() &&
cur->GetPrimaryFrame()->GetParent() != parent->GetPrimaryFrame())) {
mRestyleRoots.AppendElement(aElement);
cur = aElement;
break;
}
cur = parent->AsElement();
@ -426,6 +431,22 @@ RestyleTracker::AddPendingRestyle(Element* 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());
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.
RestyleData curData;
// XXX We should avoid copying RestyleData::mDescendants around.
mPendingRestyles.Get(cur, &curData);
curData.mDescendants.AppendElement(aElement);
mPendingRestyles.Put(cur, curData);
}
}
mHaveLaterSiblingRestyles =

Просмотреть файл

@ -61,7 +61,7 @@ load 385552-2.svg
load 385840-1.svg
load 385852-1.svg
load 386475-1.xhtml
asserts(1) load 386566-1.svg # Bug 713626
load 386566-1.svg
load 386690-1.svg
load 387290-1.svg
load 402408-1.svg