Bug 1492894 - part 1 - make the node hierarchy consistently constructed with NodeInfo&&; r=mccr8

Various places in dom/ use the pattern:

  already_AddRefed<NodeInfo> ni = ...;

which is supposed to be disallowed by our static analysis code, but
isn't, for whatever reason.  To fix our static analysis code, we need to
eliminate instances of the above pattern.

Unfortunately, eliminating this pattern requires restructuring how Nodes
are created.  Most Node subclasses take `already_AddRefed<NodeInfo>&` in
their constructors, and a few accept `already_AddRefed<NodeInfo>&&`.  We
need to enforce the latter pattern consistently, which requires changing
dozens of source files.
This commit is contained in:
Nathan Froyd
2018-09-21 16:45:49 -04:00
parent 81be54808c
commit f93834868a
256 changed files with 493 additions and 536 deletions

View File

@@ -117,8 +117,8 @@ private:
bool mUseUrgentStartForChannel;
};
HTMLImageElement::HTMLImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
HTMLImageElement::HTMLImageElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
: nsGenericHTMLElement(std::move(aNodeInfo))
, mForm(nullptr)
, mInDocResponsiveContent(false)
, mCurrentDensity(1.0)
@@ -734,12 +734,12 @@ HTMLImageElement::Image(const GlobalObject& aGlobal,
return nullptr;
}
already_AddRefed<mozilla::dom::NodeInfo> nodeInfo =
RefPtr<mozilla::dom::NodeInfo> nodeInfo =
doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::img, nullptr,
kNameSpaceID_XHTML,
ELEMENT_NODE);
RefPtr<HTMLImageElement> img = new HTMLImageElement(nodeInfo);
RefPtr<HTMLImageElement> img = new HTMLImageElement(nodeInfo.forget());
if (aWidth.WasPassed()) {
img->SetWidth(aWidth.Value(), aError);