Bug 1415013: Clear servo data on flattened tree changes. r=bz

MozReview-Commit-ID: 3TsM8tbzPMV
This commit is contained in:
Emilio Cobos Álvarez 2017-11-09 18:43:51 +01:00
Родитель 6c1d6be6fb
Коммит 981470d0c2
2 изменённых файлов: 31 добавлений и 0 удалений

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

@ -1781,6 +1781,9 @@ private:
// Data members
EventStates mState;
// Per-node data managed by Servo.
//
// There should not be data on nodes that are in the flattened tree, or
// descendants of display: none elements.
mozilla::ServoCell<ServoNodeData*> mServoData;
};

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

@ -2950,6 +2950,34 @@ PresShell::DestroyFramesForAndRestyle(Element* aElement)
bool didReconstruct = fc->DestroyFramesFor(aElement);
fc->EndUpdate();
if (aElement->IsStyledByServo()) {
if (aElement->GetFlattenedTreeParentNode()) {
// The element is still in the flat tree, but their children may not be
// anymore in a second.
//
// This is the case of a new shadow root or XBL binding about to be
// attached.
//
// Clear the style data from all the flattened tree descendants, but _not_
// from us, since otherwise we wouldn't see the reframe.
//
// FIXME(emilio): It'd be more ergonomic to just map the no data -> data
// case to a reframe from the style system.
StyleChildrenIterator iter(aElement);
for (nsIContent* child = iter.GetNextChild();
child;
child = iter.GetNextChild()) {
if (child->IsElement()) {
ServoRestyleManager::ClearServoDataFromSubtree(child->AsElement());
}
}
} else {
// This is the case of an element that was redistributed but is no longer
// bound to any insertion point. Just forget about all the data.
ServoRestyleManager::ClearServoDataFromSubtree(aElement);
}
}
auto changeHint = didReconstruct
? nsChangeHint(0)
: nsChangeHint_ReconstructFrame;