Bug 1441136: Some other minor cleanup. r?smaug draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 29 Mar 2018 17:42:01 +0200
changeset 775311 21492cc1319767816a5adfaec22f74c74771da3c
parent 775310 693a5cf33340bc4788d6e36bd63cc047f5639f6e
push id104692
push userbmo:emilio@crisal.io
push dateFri, 30 Mar 2018 21:40:28 +0000
reviewerssmaug
bugs1441136
milestone61.0a1
Bug 1441136: Some other minor cleanup. r?smaug Now that XBL and Shadow DOM are not entangled we don't really need to do this. MozReview-Commit-ID: GdgnE5QT2NR
dom/base/Element.cpp
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1698,20 +1698,19 @@ Element::BindToTree(nsIDocument* aDocume
   if (IsHTMLElement()) {
     SetDirOnBind(this, aParent);
   }
 
   uint32_t editableDescendantCount = 0;
 
   UpdateEditableState(false);
 
-  // If we had a pre-existing XBL binding,
-  // we might have anonymous children that also need to be told that they are
-  // moving.
-  if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) && !GetShadowRoot()) {
+  // If we had a pre-existing XBL binding, we might have anonymous children that
+  // also need to be told that they are moving.
+  if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
     nsXBLBinding* binding =
       OwnerDoc()->BindingManager()->GetBindingWithContent(this);
 
     if (binding) {
       binding->BindAnonymousContent(
         binding->GetAnonymousContent(),
         this,
         binding->PrototypeBinding()->ChromeOnlyContent());
@@ -1763,18 +1762,17 @@ Element::BindToTree(nsIDocument* aDocume
   if (MayHaveStyle() && !IsXULElement()) {
     // XXXbz if we already have a style attr parsed, this won't do
     // anything... need to fix that.
     // If MayHaveStyle() is true, we must be an nsStyledElement
     static_cast<nsStyledElement*>(this)->ReparseStyleAttribute(false, false);
   }
 
   // Call BindToTree on shadow root children.
-  ShadowRoot* shadowRoot = GetShadowRoot();
-  if (shadowRoot) {
+  if (ShadowRoot* shadowRoot = GetShadowRoot()) {
     shadowRoot->SetIsComposedDocParticipant(IsInComposedDoc());
     for (nsIContent* child = shadowRoot->GetFirstChild(); child;
          child = child->GetNextSibling()) {
       rv = child->BindToTree(nullptr, shadowRoot,
                              shadowRoot->GetBindingParent(),
                              aCompileEventHandlers);
       NS_ENSURE_SUCCESS(rv, rv);
     }
@@ -1984,21 +1982,19 @@ Element::UnbindFromTree(bool aDeep, bool
       slots->mBindingParent = nullptr;
     }
     if (aNullParent || !mParent->IsInShadowTree()) {
       slots->mContainingShadow = nullptr;
     }
   }
 
   if (document) {
-    // Notify XBL- & nsIAnonymousContentCreator-generated
-    // anonymous content that the document is changing.
-    // Unlike XBL, bindings for web components shadow DOM
-    // do not get uninstalled.
-    if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) && !GetShadowRoot()) {
+    if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
+      // Notify XBL- & nsIAnonymousContentCreator-generated anonymous content
+      // that the document is changing.
       nsContentUtils::AddScriptRunner(
         new RemoveFromBindingManagerRunnable(
           document->BindingManager(), this, document));
       nsXBLBinding* binding =
         document->BindingManager()->GetBindingWithContent(this);
       if (binding) {
         nsXBLBinding::UnbindAnonymousContent(
           document,