Bug 1415149: Simplify nsCSSFrameConstructor::GetRangeInsertionPoint. r?mats draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 06 Nov 2017 19:08:08 +0100
changeset 694163 6c3f54ffb7e6e460be97bb34081d4c1dd6229e34
parent 694162 7e302b16878c52a4e786a685195662d232e14d51
child 739272 c43fbda3a7bbe470442698c9128868ae73e9d1f6
push id88061
push userbmo:emilio@crisal.io
push dateTue, 07 Nov 2017 13:35:35 +0000
reviewersmats
bugs1415149
milestone58.0a1
Bug 1415149: Simplify nsCSSFrameConstructor::GetRangeInsertionPoint. r?mats MozReview-Commit-ID: HsICs5TvhGU
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7415,40 +7415,21 @@ nsCSSFrameConstructor::GetRangeInsertion
   // real parent frame; if not, then the frame hasn't been built yet
   // and we just bail.
   InsertionPoint insertionPoint = GetInsertionPoint(aContainer, nullptr);
   if (!insertionPoint.mParentFrame && !insertionPoint.mMultiple) {
     return insertionPoint; // Don't build the frames.
   }
 
   if (insertionPoint.mMultiple || aStartChild->GetXBLInsertionPoint()) {
-    // We have an insertion point.  There are some additional tests we need to do
-    // in order to ensure that an append is a safe operation.
-    uint32_t childCount = 0;
-
-    if (!insertionPoint.mMultiple) {
-      // We may need to make multiple ContentInserted calls instead.  A
-      // reasonable heuristic to employ (in order to maintain good performance)
-      // is to find out if the insertion point's content node contains any
-      // explicit children.  If it does not, then it is highly likely that
-      // an append is occurring.  (Note it is not definite, and there are insane
-      // cases we will not deal with by employing this heuristic, but it beats
-      // always falling back to multiple ContentInserted calls).
-      //
-      // In the multiple insertion point case, we know we're going to need to do
-      // multiple ContentInserted calls anyway.
-      // XXXndeakin This test doesn't work in the new world. Or rather, it works, but
-      // it's slow
-      childCount = insertionPoint.mParentFrame->GetContent()->GetChildCount();
-    }
-
     // If we have multiple insertion points or if we have an insertion point
     // and the operation is not a true append or if the insertion point already
     // has explicit children, then we must fall back.
-    if (insertionPoint.mMultiple || aEndChild != nullptr || childCount > 0) {
+    if (insertionPoint.mMultiple || aEndChild ||
+        insertionPoint.mParentFrame->GetContent()->HasChildren()) {
       // Now comes the fun part.  For each inserted child, make a
       // ContentInserted call as if it had just gotten inserted and
       // let ContentInserted handle the mess.
       IssueSingleInsertNofications(aContainer, aStartChild, aEndChild,
                                    aInsertionKind);
       insertionPoint.mParentFrame = nullptr;
     }
   }