Bug 1351535 - Part 7: Call StyleSubtreeForReconstruct when doing frame reconstruction. r=bholley
MozReview-Commit-ID: HxoGLPKJpnt
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7439,16 +7439,32 @@ nsCSSFrameConstructor::StyleNewChildRang
if (parent->HasServoData()) {
styleSet->StyleNewChildren(parent);
}
}
}
}
void
+nsCSSFrameConstructor::StyleChildRangeForReconstruct(nsIContent* aStartChild,
+ nsIContent* aEndChild)
+{
+ ServoStyleSet* styleSet = mPresShell->StyleSet()->AsServo();
+
+ // We take a parallelism hit here, since we don't have a great API to pass
+ // a range of elements to style to Servo.
+ for (nsIContent* child = aStartChild; child != aEndChild;
+ child = child->GetNextSibling()) {
+ if (child->IsElement()) {
+ styleSet->StyleSubtreeForReconstruct(child->AsElement());
+ }
+ }
+}
+
+void
nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
nsIContent* aFirstNewContent,
bool aAllowLazyConstruction,
bool aForReconstruction,
TreeMatchContext* aProvidedTreeMatchContext)
{
MOZ_ASSERT_IF(aProvidedTreeMatchContext, !aAllowLazyConstruction);
MOZ_ASSERT_IF(aAllowLazyConstruction, !RestyleManager()->IsInStyleRefresh());
@@ -7526,18 +7542,22 @@ nsCSSFrameConstructor::ContentAppended(n
if (isNewlyAddedContentForServo) {
LazilyStyleNewChildRange(aFirstNewContent, nullptr);
}
return;
}
}
// We couldn't construct lazily. Make Servo eagerly traverse the new content.
- if (isNewlyAddedContentForServo) {
- StyleNewChildRange(aFirstNewContent, nullptr);
+ if (aContainer->IsStyledByServo()) {
+ if (aForReconstruction) {
+ StyleChildRangeForReconstruct(aFirstNewContent, nullptr);
+ } else {
+ StyleNewChildRange(aFirstNewContent, nullptr);
+ }
}
if (isNewShadowTreeContent) {
// Recreate frames if content is appended into a ShadowRoot
// because children of ShadowRoot are rendered in place of children
// of the host.
//XXXsmaug This is super unefficient!
nsIContent* bindingParent = aContainer->GetBindingParent();
@@ -8007,18 +8027,22 @@ nsCSSFrameConstructor::ContentRangeInser
if (isNewlyAddedContentForServo) {
LazilyStyleNewChildRange(aStartChild, aEndChild);
}
return;
}
}
// We couldn't construct lazily. Make Servo eagerly traverse the new content.
- if (isNewlyAddedContentForServo) {
- StyleNewChildRange(aStartChild, aEndChild);
+ if (aContainer->IsStyledByServo()) {
+ if (aForReconstruction) {
+ StyleChildRangeForReconstruct(aStartChild, aEndChild);
+ } else {
+ StyleNewChildRange(aStartChild, aEndChild);
+ }
}
if (isNewShadowTreeContent) {
// Recreate frames if content is inserted into a ShadowRoot
// because children of ShadowRoot are rendered in place of
// the children of the host.
//XXXsmaug This is super unefficient!
nsIContent* bindingParent = aContainer->GetBindingParent();
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -173,16 +173,23 @@ private:
* on their flattened tree parents. This is used when content is inserted
* into the document and we decide that we cannot do lazy frame construction.
* It handles children being rebound to different insertion points by calling
* StyleNewChildren on each child's flattened tree parent. Only used when we
* are styled by Servo.
*/
void StyleNewChildRange(nsIContent* aStartChild, nsIContent* aEndChild);
+ /**
+ * Calls StyleSubtreeForReconstruct on each child in the aStartChild/aEndChild
+ * range. Only used when we are styled by Servo.
+ */
+ void StyleChildRangeForReconstruct(nsIContent* aStartChild,
+ nsIContent* aEndChild);
+
public:
/**
* Lazy frame construction is controlled by the aAllowLazyConstruction bool
* parameter of nsCSSFrameConstructor::ContentAppended/Inserted. It is true
* for all inserts/appends as passed from the presshell, except for the
* insert of the root element, which is always non-lazy. Even if the
* aAllowLazyConstruction passed to ContentAppended/Inserted is true we still
* may not be able to construct lazily, so we call MaybeConstructLazily.