Bug 1577592 - Properly set the has part attribute bit when cloning a XUL element. r=bzbarsky
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 30 Aug 2019 00:10:36 +0000
changeset 490812 b78fd9e42adcaeac7548f5a999630b5c75d5c039
parent 490811 59e90b5a43fab3c2d485c070785d4704e3525a47
child 490813 a334d3b33b26f99947e93c6264aaab6632497156
push id36513
push usershindli@mozilla.com
push dateFri, 30 Aug 2019 16:20:43 +0000
treeherdermozilla-central@8d251dd4a9be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1577592
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1577592 - Properly set the has part attribute bit when cloning a XUL element. r=bzbarsky Test is in the other revision for this bug. Do the same we do for the other bits. This setup looks pretty error prone though... Differential Revision: https://phabricator.services.mozilla.com/D44069
dom/xul/nsXULElement.cpp
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -309,16 +309,20 @@ nsresult nsXULElement::Clone(mozilla::do
 
   nsresult rv = element->mAttrs.EnsureCapacityToClone(mAttrs);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Note that we're _not_ copying mControllers.
 
   uint32_t count = mAttrs.AttrCount();
   rv = NS_OK;
+  // FIXME(emilio): This setup looks somewhat error prone. Other than the
+  // AddListenerFor bit (what is that for?), everything else could be handled by
+  // the generic Element::CopyInnerTo, or the equivalent in
+  // nsGenericHTMLElement (somehow), both of which go through AfterSetAttr...
   for (uint32_t i = 0; i < count; ++i) {
     const nsAttrName* originalName = mAttrs.AttrNameAt(i);
     const nsAttrValue* originalValue = mAttrs.AttrAt(i);
     nsAttrValue attrValue;
 
     // Style rules need to be cloned.
     if (originalValue->Type() == nsAttrValue::eCSSDeclaration) {
       DeclarationBlock* decl = originalValue->GetCSSDeclarationValue();
@@ -347,16 +351,19 @@ nsresult nsXULElement::Clone(mozilla::do
       element->SetHasID();
     }
     if (originalName->Equals(nsGkAtoms::_class)) {
       element->SetMayHaveClass();
     }
     if (originalName->Equals(nsGkAtoms::style)) {
       element->SetMayHaveStyle();
     }
+    if (originalName->Equals(nsGkAtoms::part)) {
+      element->SetHasPartAttribute(true);
+    }
   }
 
   element.forget(aResult);
   return rv;
 }
 
 //----------------------------------------------------------------------