Bug 1471095 - Don't do extra work we don't need to in ReparentWrappersInSubtree. r=smaug, a=RyanVM
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 28 Jun 2018 23:36:46 -0400
changeset 480275 30c32c21df574fa81317837ded730aa03d296712
parent 480274 cd20a5a8658bb5bb119ba77dfe3db38b5c1820e6
child 480276 6f9103e33409b8465cad9fa46c05defb130c0ece
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, RyanVM
bugs1471095
milestone62.0
Bug 1471095 - Don't do extra work we don't need to in ReparentWrappersInSubtree. r=smaug, a=RyanVM
dom/base/nsINode.cpp
layout/base/nsCSSFrameConstructor.cpp
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1307,28 +1307,16 @@ ReparentWrappersInSubtree(nsIContent* aR
 {
   MOZ_ASSERT(ShouldUseXBLScope(aRoot));
   // Start off with no global so we don't fire any error events on failure.
   AutoJSAPI jsapi;
   jsapi.Init();
 
   JSContext* cx = jsapi.cx();
 
-  nsIGlobalObject* docGlobal = aRoot->OwnerDoc()->GetScopeObject();
-  if (NS_WARN_IF(!docGlobal)) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  JS::Rooted<JSObject*> rootedGlobal(cx, docGlobal->GetGlobalJSObject());
-  if (NS_WARN_IF(!rootedGlobal)) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  rootedGlobal = xpc::GetXBLScope(cx, rootedGlobal);
-
   ErrorResult rv;
   JS::Rooted<JSObject*> reflector(cx);
   for (nsIContent* cur = aRoot; cur; cur = cur->GetNextNode(aRoot)) {
     if ((reflector = cur->GetWrapper())) {
       JSAutoRealm ar(cx, reflector);
       ReparentWrapper(cx, reflector, rv);
       rv.WouldReportJSException();
       if (rv.Failed()) {
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -1911,16 +1911,21 @@ nsCSSFrameConstructor::CreateGeneratedCo
   }
 
   uint32_t contentCount = pseudoComputedStyle->StyleContent()->ContentCount();
   for (uint32_t contentIndex = 0; contentIndex < contentCount; contentIndex++) {
     nsCOMPtr<nsIContent> content =
       CreateGeneratedContent(aState, aParentContent, pseudoComputedStyle,
                              contentIndex);
     if (content) {
+      // We don't strictly have to set NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE
+      // here; it would get set under AppendChildTo.  But AppendChildTo might
+      // think that we're going from not being anonymous to being anonymous and
+      // do some extra work; setting the flag here avoids that.
+      content->SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
       container->AppendChildTo(content, false);
       if (content->IsElement()) {
         // If we created any children elements, Servo needs to traverse them, but
         // the root is already set up.
         mPresShell->StyleSet()->StyleNewSubtree(content->AsElement());
       }
     }
   }