Inline static Create() from core/html - 2

As advised in [1], this CL ports calls to Foo::Create() factory
functions to use MakeGarbageCollected<Foo> from classes in
//third_party/blink/renderer/core/html.

[1] https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/iJ1bawbxbWs/vEdfT5QtBgAJ

Bug: 939691
Change-Id: I9bb9edba1d507315231d6a461b18124a609b323e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572130
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#652128}
diff --git a/third_party/blink/renderer/core/html/html_base_element.cc b/third_party/blink/renderer/core/html/html_base_element.cc
index 607a667..f3010d9 100644
--- a/third_party/blink/renderer/core/html/html_base_element.cc
+++ b/third_party/blink/renderer/core/html/html_base_element.cc
@@ -34,7 +34,7 @@
 
 using namespace html_names;
 
-inline HTMLBaseElement::HTMLBaseElement(Document& document)
+HTMLBaseElement::HTMLBaseElement(Document& document)
     : HTMLElement(kBaseTag, document) {}
 
 DEFINE_NODE_FACTORY(HTMLBaseElement)
diff --git a/third_party/blink/renderer/core/html/html_iframe_element.cc b/third_party/blink/renderer/core/html/html_iframe_element.cc
index 601ac65..a6a5518 100644
--- a/third_party/blink/renderer/core/html/html_iframe_element.cc
+++ b/third_party/blink/renderer/core/html/html_iframe_element.cc
@@ -44,7 +44,7 @@
 
 using namespace html_names;
 
-inline HTMLIFrameElement::HTMLIFrameElement(Document& document)
+HTMLIFrameElement::HTMLIFrameElement(Document& document)
     : HTMLFrameElementBase(kIFrameTag, document),
       collapsed_by_client_(false),
       sandbox_(MakeGarbageCollected<HTMLIFrameElementSandbox>(this)),
diff --git a/third_party/blink/renderer/core/html/html_iframe_element_test.cc b/third_party/blink/renderer/core/html/html_iframe_element_test.cc
index 0816532..4740f10 100644
--- a/third_party/blink/renderer/core/html/html_iframe_element_test.cc
+++ b/third_party/blink/renderer/core/html/html_iframe_element_test.cc
@@ -20,144 +20,119 @@
     return element->GetOriginForFeaturePolicy();
   }
 
+  void SetUp() final {
+    document_ = Document::CreateForTest();
+    const KURL document_url("http://example.com");
+    document_->SetURL(document_url);
+    document_->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
+
+    frame_element_ = MakeGarbageCollected<HTMLIFrameElement>(*document_);
+  }
+
+  void TearDown() final {
+    frame_element_.Clear();
+    document_.Clear();
+  }
+
  protected:
   const PolicyValue min_value = PolicyValue(false);
   const PolicyValue max_value = PolicyValue(true);
+
+  Persistent<Document> document_;
+  Persistent<HTMLIFrameElement> frame_element_;
 };
 
 // Test that the correct origin is used when constructing the container policy,
 // and that frames which should inherit their parent document's origin do so.
 TEST_F(HTMLIFrameElementTest, FramesUseCorrectOrigin) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSrcAttr, "about:blank");
+  frame_element_->setAttribute(html_names::kSrcAttr, "about:blank");
   scoped_refptr<const SecurityOrigin> effective_origin =
-      GetOriginForFeaturePolicy(frame_element);
+      GetOriginForFeaturePolicy(frame_element_);
   EXPECT_TRUE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
 
-  frame_element->setAttribute(html_names::kSrcAttr,
-                              "data:text/html;base64,PHRpdGxlPkFCQzwvdGl0bGU+");
-  effective_origin = GetOriginForFeaturePolicy(frame_element);
+  frame_element_->setAttribute(
+      html_names::kSrcAttr, "data:text/html;base64,PHRpdGxlPkFCQzwvdGl0bGU+");
+  effective_origin = GetOriginForFeaturePolicy(frame_element_);
   EXPECT_FALSE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
   EXPECT_TRUE(effective_origin->IsOpaque());
 
-  frame_element->setAttribute(html_names::kSrcAttr, "http://example.net/");
-  effective_origin = GetOriginForFeaturePolicy(frame_element);
+  frame_element_->setAttribute(html_names::kSrcAttr, "http://example.net/");
+  effective_origin = GetOriginForFeaturePolicy(frame_element_);
   EXPECT_FALSE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
   EXPECT_FALSE(effective_origin->IsOpaque());
 }
 
 // Test that a unique origin is used when constructing the container policy in a
 // sandboxed iframe.
 TEST_F(HTMLIFrameElementTest, SandboxFramesUseCorrectOrigin) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSandboxAttr, "");
-  frame_element->setAttribute(html_names::kSrcAttr, "http://example.com/");
+  frame_element_->setAttribute(html_names::kSandboxAttr, "");
+  frame_element_->setAttribute(html_names::kSrcAttr, "http://example.com/");
   scoped_refptr<const SecurityOrigin> effective_origin =
-      GetOriginForFeaturePolicy(frame_element);
+      GetOriginForFeaturePolicy(frame_element_);
   EXPECT_FALSE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
   EXPECT_TRUE(effective_origin->IsOpaque());
 
-  frame_element->setAttribute(html_names::kSrcAttr, "http://example.net/");
-  effective_origin = GetOriginForFeaturePolicy(frame_element);
+  frame_element_->setAttribute(html_names::kSrcAttr, "http://example.net/");
+  effective_origin = GetOriginForFeaturePolicy(frame_element_);
   EXPECT_FALSE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
   EXPECT_TRUE(effective_origin->IsOpaque());
 }
 
 // Test that a sandboxed iframe with the allow-same-origin sandbox flag uses the
 // parent document's origin for the container policy.
 TEST_F(HTMLIFrameElementTest, SameOriginSandboxFramesUseCorrectOrigin) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSandboxAttr, "allow-same-origin");
-  frame_element->setAttribute(html_names::kSrcAttr, "http://example.com/");
+  frame_element_->setAttribute(html_names::kSandboxAttr, "allow-same-origin");
+  frame_element_->setAttribute(html_names::kSrcAttr, "http://example.com/");
   scoped_refptr<const SecurityOrigin> effective_origin =
-      GetOriginForFeaturePolicy(frame_element);
+      GetOriginForFeaturePolicy(frame_element_);
   EXPECT_TRUE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
   EXPECT_FALSE(effective_origin->IsOpaque());
 }
 
 // Test that the parent document's origin is used when constructing the
 // container policy in a srcdoc iframe.
 TEST_F(HTMLIFrameElementTest, SrcdocFramesUseCorrectOrigin) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSrcdocAttr, "<title>title</title>");
+  frame_element_->setAttribute(html_names::kSrcdocAttr, "<title>title</title>");
   scoped_refptr<const SecurityOrigin> effective_origin =
-      GetOriginForFeaturePolicy(frame_element);
+      GetOriginForFeaturePolicy(frame_element_);
   EXPECT_TRUE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
 }
 
 // Test that a unique origin is used when constructing the container policy in a
 // sandboxed iframe with a srcdoc.
 TEST_F(HTMLIFrameElementTest, SandboxedSrcdocFramesUseCorrectOrigin) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSandboxAttr, "");
-  frame_element->setAttribute(html_names::kSrcdocAttr, "<title>title</title>");
+  frame_element_->setAttribute(html_names::kSandboxAttr, "");
+  frame_element_->setAttribute(html_names::kSrcdocAttr, "<title>title</title>");
   scoped_refptr<const SecurityOrigin> effective_origin =
-      GetOriginForFeaturePolicy(frame_element);
+      GetOriginForFeaturePolicy(frame_element_);
   EXPECT_FALSE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
   EXPECT_TRUE(effective_origin->IsOpaque());
 }
 
 // Test that iframes with relative src urls correctly construct their origin
 // relative to the parent document.
 TEST_F(HTMLIFrameElementTest, RelativeURLsUseCorrectOrigin) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
   // Host-relative URLs should resolve to the same domain as the parent.
-  frame_element->setAttribute(html_names::kSrcAttr, "index2.html");
+  frame_element_->setAttribute(html_names::kSrcAttr, "index2.html");
   scoped_refptr<const SecurityOrigin> effective_origin =
-      GetOriginForFeaturePolicy(frame_element);
+      GetOriginForFeaturePolicy(frame_element_);
   EXPECT_TRUE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
 
   // Scheme-relative URLs should not resolve to the same domain as the parent.
-  frame_element->setAttribute(html_names::kSrcAttr,
-                              "//example.net/index2.html");
-  effective_origin = GetOriginForFeaturePolicy(frame_element);
+  frame_element_->setAttribute(html_names::kSrcAttr,
+                               "//example.net/index2.html");
+  effective_origin = GetOriginForFeaturePolicy(frame_element_);
   EXPECT_FALSE(
-      effective_origin->IsSameSchemeHostPort(document->GetSecurityOrigin()));
+      effective_origin->IsSameSchemeHostPort(document_->GetSecurityOrigin()));
 }
 
 // Test that various iframe attribute configurations result in the correct
@@ -165,37 +140,23 @@
 
 // Test that the correct container policy is constructed on an iframe element.
 TEST_F(HTMLIFrameElementTest, DefaultContainerPolicy) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSrcAttr, "http://example.net/");
-  frame_element->UpdateContainerPolicyForTests();
+  frame_element_->setAttribute(html_names::kSrcAttr, "http://example.net/");
+  frame_element_->UpdateContainerPolicyForTests();
 
   const ParsedFeaturePolicy& container_policy =
-      frame_element->GetFramePolicy().container_policy;
+      frame_element_->GetFramePolicy().container_policy;
   EXPECT_EQ(0UL, container_policy.size());
 }
 
 // Test that the allow attribute results in a container policy which is
 // restricted to the domain in the src attribute.
 TEST_F(HTMLIFrameElementTest, AllowAttributeContainerPolicy) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSrcAttr, "http://example.net/");
-  frame_element->setAttribute(html_names::kAllowAttr, "fullscreen");
-  frame_element->UpdateContainerPolicyForTests();
+  frame_element_->setAttribute(html_names::kSrcAttr, "http://example.net/");
+  frame_element_->setAttribute(html_names::kAllowAttr, "fullscreen");
+  frame_element_->UpdateContainerPolicyForTests();
 
   const ParsedFeaturePolicy& container_policy1 =
-      frame_element->GetFramePolicy().container_policy;
+      frame_element_->GetFramePolicy().container_policy;
 
   EXPECT_EQ(1UL, container_policy1.size());
   EXPECT_EQ(mojom::FeaturePolicyFeature::kFullscreen,
@@ -205,11 +166,11 @@
   EXPECT_EQ("http://example.net",
             container_policy1[0].values.begin()->first.Serialize());
 
-  frame_element->setAttribute(html_names::kAllowAttr, "payment; fullscreen");
-  frame_element->UpdateContainerPolicyForTests();
+  frame_element_->setAttribute(html_names::kAllowAttr, "payment; fullscreen");
+  frame_element_->UpdateContainerPolicyForTests();
 
   const ParsedFeaturePolicy& container_policy2 =
-      frame_element->GetFramePolicy().container_policy;
+      frame_element_->GetFramePolicy().container_policy;
   EXPECT_EQ(2UL, container_policy2.size());
   EXPECT_TRUE(container_policy2[0].feature ==
                   mojom::FeaturePolicyFeature::kFullscreen ||
@@ -232,18 +193,11 @@
 TEST_F(HTMLIFrameElementTest, SandboxAttributeContainerPolicy) {
   ASSERT_TRUE(RuntimeEnabledFeatures::FeaturePolicyForSandboxEnabled());
 
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSandboxAttr, "");
-  frame_element->UpdateContainerPolicyForTests();
+  frame_element_->setAttribute(html_names::kSandboxAttr, "");
+  frame_element_->UpdateContainerPolicyForTests();
 
   const ParsedFeaturePolicy& container_policy =
-      frame_element->GetFramePolicy().container_policy;
+      frame_element_->GetFramePolicy().container_policy;
 
   EXPECT_EQ(expected_number_of_sandbox_features, container_policy.size());
 }
@@ -252,20 +206,14 @@
 // policy which is restricted to a unique origin.
 TEST_F(HTMLIFrameElementTest, CrossOriginSandboxAttributeContainerPolicy) {
   ASSERT_TRUE(RuntimeEnabledFeatures::FeaturePolicyForSandboxEnabled());
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
 
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSrcAttr, "http://example.net/");
-  frame_element->setAttribute(html_names::kAllowAttr, "fullscreen");
-  frame_element->setAttribute(html_names::kSandboxAttr, "");
-  frame_element->UpdateContainerPolicyForTests();
+  frame_element_->setAttribute(html_names::kSrcAttr, "http://example.net/");
+  frame_element_->setAttribute(html_names::kAllowAttr, "fullscreen");
+  frame_element_->setAttribute(html_names::kSandboxAttr, "");
+  frame_element_->UpdateContainerPolicyForTests();
 
   const ParsedFeaturePolicy& container_policy =
-      frame_element->GetFramePolicy().container_policy;
+      frame_element_->GetFramePolicy().container_policy;
 
   EXPECT_EQ(expected_number_of_sandbox_features + 1, container_policy.size());
   const auto& container_policy_item = std::find_if(
@@ -288,20 +236,14 @@
 // containing document.
 TEST_F(HTMLIFrameElementTest, SameOriginSandboxAttributeContainerPolicy) {
   ASSERT_TRUE(RuntimeEnabledFeatures::FeaturePolicyForSandboxEnabled());
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
 
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
-  frame_element->setAttribute(html_names::kSrcAttr, "http://example.net/");
-  frame_element->setAttribute(html_names::kAllowAttr, "fullscreen");
-  frame_element->setAttribute(html_names::kSandboxAttr, "allow-same-origin");
-  frame_element->UpdateContainerPolicyForTests();
+  frame_element_->setAttribute(html_names::kSrcAttr, "http://example.net/");
+  frame_element_->setAttribute(html_names::kAllowAttr, "fullscreen");
+  frame_element_->setAttribute(html_names::kSandboxAttr, "allow-same-origin");
+  frame_element_->UpdateContainerPolicyForTests();
 
   const ParsedFeaturePolicy& container_policy =
-      frame_element->GetFramePolicy().container_policy;
+      frame_element_->GetFramePolicy().container_policy;
 
   EXPECT_EQ(expected_number_of_sandbox_features + 1, container_policy.size());
   const auto& container_policy_item = std::find_if(
@@ -324,55 +266,36 @@
 // Test the ConstructContainerPolicy method when no attributes are set on the
 // iframe element.
 TEST_F(HTMLIFrameElementTest, ConstructEmptyContainerPolicy) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-
   ParsedFeaturePolicy container_policy =
-      frame_element->ConstructContainerPolicy(nullptr);
+      frame_element_->ConstructContainerPolicy(nullptr);
   EXPECT_EQ(0UL, container_policy.size());
 }
 
 // Test the ConstructContainerPolicy method when the "allow" attribute is used
 // to enable features in the frame.
 TEST_F(HTMLIFrameElementTest, ConstructContainerPolicy) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-  frame_element->setAttribute(html_names::kAllowAttr, "payment; usb");
+  frame_element_->setAttribute(html_names::kAllowAttr, "payment; usb");
   ParsedFeaturePolicy container_policy =
-      frame_element->ConstructContainerPolicy(nullptr);
+      frame_element_->ConstructContainerPolicy(nullptr);
   EXPECT_EQ(2UL, container_policy.size());
   EXPECT_EQ(mojom::FeaturePolicyFeature::kPayment, container_policy[0].feature);
   EXPECT_GE(min_value, container_policy[0].fallback_value);
   EXPECT_EQ(1UL, container_policy[0].values.size());
   EXPECT_TRUE(container_policy[0].values.begin()->first.IsSameOriginWith(
-      GetOriginForFeaturePolicy(frame_element)->ToUrlOrigin()));
+      GetOriginForFeaturePolicy(frame_element_)->ToUrlOrigin()));
   EXPECT_EQ(mojom::FeaturePolicyFeature::kUsb, container_policy[1].feature);
   EXPECT_EQ(1UL, container_policy[1].values.size());
   EXPECT_TRUE(container_policy[1].values.begin()->first.IsSameOriginWith(
-      GetOriginForFeaturePolicy(frame_element)->ToUrlOrigin()));
+      GetOriginForFeaturePolicy(frame_element_)->ToUrlOrigin()));
 }
 
 // Test the ConstructContainerPolicy method when the "allowfullscreen" attribute
 // is used to enable fullscreen in the frame.
 TEST_F(HTMLIFrameElementTest, ConstructContainerPolicyWithAllowFullscreen) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-  frame_element->SetBooleanAttribute(html_names::kAllowfullscreenAttr, true);
+  frame_element_->SetBooleanAttribute(html_names::kAllowfullscreenAttr, true);
 
   ParsedFeaturePolicy container_policy =
-      frame_element->ConstructContainerPolicy(nullptr);
+      frame_element_->ConstructContainerPolicy(nullptr);
   EXPECT_EQ(1UL, container_policy.size());
   EXPECT_EQ(mojom::FeaturePolicyFeature::kFullscreen,
             container_policy[0].feature);
@@ -382,24 +305,18 @@
 // Test the ConstructContainerPolicy method when the "allowpaymentrequest"
 // attribute is used to enable the paymentrequest API in the frame.
 TEST_F(HTMLIFrameElementTest, ConstructContainerPolicyWithAllowPaymentRequest) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-  frame_element->setAttribute(html_names::kAllowAttr, "usb");
-  frame_element->SetBooleanAttribute(html_names::kAllowpaymentrequestAttr,
-                                     true);
+  frame_element_->setAttribute(html_names::kAllowAttr, "usb");
+  frame_element_->SetBooleanAttribute(html_names::kAllowpaymentrequestAttr,
+                                      true);
 
   ParsedFeaturePolicy container_policy =
-      frame_element->ConstructContainerPolicy(nullptr);
+      frame_element_->ConstructContainerPolicy(nullptr);
   EXPECT_EQ(2UL, container_policy.size());
   EXPECT_EQ(mojom::FeaturePolicyFeature::kUsb, container_policy[0].feature);
   EXPECT_GE(min_value, container_policy[0].fallback_value);
   EXPECT_EQ(1UL, container_policy[0].values.size());
   EXPECT_TRUE(container_policy[0].values.begin()->first.IsSameOriginWith(
-      GetOriginForFeaturePolicy(frame_element)->ToUrlOrigin()));
+      GetOriginForFeaturePolicy(frame_element_)->ToUrlOrigin()));
   EXPECT_EQ(mojom::FeaturePolicyFeature::kPayment, container_policy[1].feature);
 }
 
@@ -410,29 +327,23 @@
 // only for the frame's origin, (since the allow attribute overrides
 // allowpaymentrequest,) while fullscreen should be enabled for all origins.
 TEST_F(HTMLIFrameElementTest, ConstructContainerPolicyWithAllowAttributes) {
-  Document* document = Document::CreateForTest();
-  const KURL document_url("http://example.com");
-  document->SetURL(document_url);
-  document->UpdateSecurityOrigin(SecurityOrigin::Create(document_url));
-
-  HTMLIFrameElement* frame_element = HTMLIFrameElement::Create(*document);
-  frame_element->setAttribute(html_names::kAllowAttr, "payment; usb");
-  frame_element->SetBooleanAttribute(html_names::kAllowfullscreenAttr, true);
-  frame_element->SetBooleanAttribute(html_names::kAllowpaymentrequestAttr,
-                                     true);
+  frame_element_->setAttribute(html_names::kAllowAttr, "payment; usb");
+  frame_element_->SetBooleanAttribute(html_names::kAllowfullscreenAttr, true);
+  frame_element_->SetBooleanAttribute(html_names::kAllowpaymentrequestAttr,
+                                      true);
 
   ParsedFeaturePolicy container_policy =
-      frame_element->ConstructContainerPolicy(nullptr);
+      frame_element_->ConstructContainerPolicy(nullptr);
   EXPECT_EQ(3UL, container_policy.size());
   EXPECT_EQ(mojom::FeaturePolicyFeature::kPayment, container_policy[0].feature);
   EXPECT_GE(min_value, container_policy[0].fallback_value);
   EXPECT_EQ(1UL, container_policy[0].values.size());
   EXPECT_TRUE(container_policy[0].values.begin()->first.IsSameOriginWith(
-      GetOriginForFeaturePolicy(frame_element)->ToUrlOrigin()));
+      GetOriginForFeaturePolicy(frame_element_)->ToUrlOrigin()));
   EXPECT_EQ(mojom::FeaturePolicyFeature::kUsb, container_policy[1].feature);
   EXPECT_EQ(1UL, container_policy[1].values.size());
   EXPECT_TRUE(container_policy[1].values.begin()->first.IsSameOriginWith(
-      GetOriginForFeaturePolicy(frame_element)->ToUrlOrigin()));
+      GetOriginForFeaturePolicy(frame_element_)->ToUrlOrigin()));
   EXPECT_EQ(mojom::FeaturePolicyFeature::kFullscreen,
             container_policy[2].feature);
 }
diff --git a/third_party/blink/renderer/core/html/html_marquee_element.cc b/third_party/blink/renderer/core/html/html_marquee_element.cc
index ad3089e..8c1b99b 100644
--- a/third_party/blink/renderer/core/html/html_marquee_element.cc
+++ b/third_party/blink/renderer/core/html/html_marquee_element.cc
@@ -47,6 +47,7 @@
 #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
 #include "third_party/blink/renderer/core/html_names.h"
 #include "third_party/blink/renderer/platform/bindings/exception_state.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
 
 namespace blink {
 
@@ -63,7 +64,8 @@
 }
 
 void HTMLMarqueeElement::DidAddUserAgentShadowRoot(ShadowRoot& shadow_root) {
-  auto* style = HTMLStyleElement::Create(GetDocument(), CreateElementFlags());
+  auto* style = MakeGarbageCollected<HTMLStyleElement>(GetDocument(),
+                                                       CreateElementFlags());
   style->setTextContent(
       ":host { display: inline-block; overflow: hidden;"
       "text-align: initial; white-space: nowrap; }"
diff --git a/third_party/blink/renderer/core/html/html_paragraph_element.cc b/third_party/blink/renderer/core/html/html_paragraph_element.cc
index 3ad635b..b2fd50e 100644
--- a/third_party/blink/renderer/core/html/html_paragraph_element.cc
+++ b/third_party/blink/renderer/core/html/html_paragraph_element.cc
@@ -30,7 +30,7 @@
 
 using namespace html_names;
 
-inline HTMLParagraphElement::HTMLParagraphElement(Document& document)
+HTMLParagraphElement::HTMLParagraphElement(Document& document)
     : HTMLElement(kPTag, document) {}
 
 DEFINE_NODE_FACTORY(HTMLParagraphElement)
diff --git a/third_party/blink/renderer/core/html/html_table_cell_element.cc b/third_party/blink/renderer/core/html/html_table_cell_element.cc
index fa74704..fa7f180 100644
--- a/third_party/blink/renderer/core/html/html_table_cell_element.cc
+++ b/third_party/blink/renderer/core/html/html_table_cell_element.cc
@@ -39,8 +39,8 @@
 
 using namespace html_names;
 
-inline HTMLTableCellElement::HTMLTableCellElement(const QualifiedName& tag_name,
-                                                  Document& document)
+HTMLTableCellElement::HTMLTableCellElement(const QualifiedName& tag_name,
+                                           Document& document)
     : HTMLTablePartElement(tag_name, document) {}
 
 DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableCellElement)
diff --git a/third_party/blink/renderer/core/html/html_table_cell_element.h b/third_party/blink/renderer/core/html/html_table_cell_element.h
index c896313..5920531 100644
--- a/third_party/blink/renderer/core/html/html_table_cell_element.h
+++ b/third_party/blink/renderer/core/html/html_table_cell_element.h
@@ -37,6 +37,8 @@
  public:
   DECLARE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableCellElement);
 
+  HTMLTableCellElement(const QualifiedName&, Document&);
+
   int cellIndex() const;
 
   unsigned colSpan() const;
@@ -53,8 +55,6 @@
   bool HasNonInBodyInsertionMode() const override { return true; }
 
  private:
-  HTMLTableCellElement(const QualifiedName&, Document&);
-
   void ParseAttribute(const AttributeModificationParams&) override;
   bool IsPresentationAttribute(const QualifiedName&) const override;
   void CollectStyleForPresentationAttribute(
diff --git a/third_party/blink/renderer/core/html/html_table_element.cc b/third_party/blink/renderer/core/html/html_table_element.cc
index 833a0a5..1851d87 100644
--- a/third_party/blink/renderer/core/html/html_table_element.cc
+++ b/third_party/blink/renderer/core/html/html_table_element.cc
@@ -51,7 +51,7 @@
 
 using namespace html_names;
 
-inline HTMLTableElement::HTMLTableElement(Document& document)
+HTMLTableElement::HTMLTableElement(Document& document)
     : HTMLElement(kTableTag, document),
       border_attr_(false),
       border_color_attr_(false),
diff --git a/third_party/blink/renderer/core/html/html_table_row_element.cc b/third_party/blink/renderer/core/html/html_table_row_element.cc
index 12c9272..19e20ce 100644
--- a/third_party/blink/renderer/core/html/html_table_row_element.cc
+++ b/third_party/blink/renderer/core/html/html_table_row_element.cc
@@ -34,12 +34,13 @@
 #include "third_party/blink/renderer/core/html/html_table_section_element.h"
 #include "third_party/blink/renderer/core/html_names.h"
 #include "third_party/blink/renderer/platform/bindings/exception_state.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
 
 namespace blink {
 
 using namespace html_names;
 
-inline HTMLTableRowElement::HTMLTableRowElement(Document& document)
+HTMLTableRowElement::HTMLTableRowElement(Document& document)
     : HTMLTablePartElement(kTrTag, document) {}
 
 DEFINE_NODE_FACTORY(HTMLTableRowElement)
@@ -102,8 +103,8 @@
     return nullptr;
   }
 
-  HTMLTableCellElement* cell =
-      HTMLTableCellElement::Create(kTdTag, GetDocument());
+  auto* cell =
+      MakeGarbageCollected<HTMLTableCellElement>(kTdTag, GetDocument());
   if (num_cells == index || index == -1)
     AppendChild(cell, exception_state);
   else
diff --git a/third_party/blink/renderer/core/html/html_table_row_element_test.cc b/third_party/blink/renderer/core/html/html_table_row_element_test.cc
index cdf795e..e38d091 100644
--- a/third_party/blink/renderer/core/html/html_table_row_element_test.cc
+++ b/third_party/blink/renderer/core/html/html_table_row_element_test.cc
@@ -8,6 +8,7 @@
 #include "third_party/blink/renderer/core/dom/document.h"
 #include "third_party/blink/renderer/core/html/html_paragraph_element.h"
 #include "third_party/blink/renderer/core/html/html_table_element.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
 
 namespace blink {
 
@@ -16,15 +17,15 @@
 
 TEST(HTMLTableRowElementTest, rowIndex_notInTable) {
   Document* document = Document::CreateForTest();
-  HTMLTableRowElement* row = HTMLTableRowElement::Create(*document);
+  auto* row = MakeGarbageCollected<HTMLTableRowElement>(*document);
   EXPECT_EQ(-1, row->rowIndex())
       << "rows not in tables should have row index -1";
 }
 
 TEST(HTMLTableRowElementTest, rowIndex_directChildOfTable) {
   Document* document = Document::CreateForTest();
-  HTMLTableElement* table = HTMLTableElement::Create(*document);
-  HTMLTableRowElement* row = HTMLTableRowElement::Create(*document);
+  auto* table = MakeGarbageCollected<HTMLTableElement>(*document);
+  auto* row = MakeGarbageCollected<HTMLTableRowElement>(*document);
   table->AppendChild(row);
   EXPECT_EQ(0, row->rowIndex())
       << "rows that are direct children of a table should have a row index";
@@ -32,11 +33,11 @@
 
 TEST(HTMLTableRowElementTest, rowIndex_inUnrelatedElementInTable) {
   Document* document = Document::CreateForTest();
-  HTMLTableElement* table = HTMLTableElement::Create(*document);
+  auto* table = MakeGarbageCollected<HTMLTableElement>(*document);
   // Almost any element will do; what's pertinent is that this is not
   // THEAD, TBODY or TFOOT.
-  HTMLParagraphElement* paragraph = HTMLParagraphElement::Create(*document);
-  HTMLTableRowElement* row = HTMLTableRowElement::Create(*document);
+  auto* paragraph = MakeGarbageCollected<HTMLParagraphElement>(*document);
+  auto* row = MakeGarbageCollected<HTMLTableRowElement>(*document);
   table->AppendChild(paragraph);
   paragraph->AppendChild(row);
   EXPECT_EQ(-1, row->rowIndex())
diff --git a/third_party/blink/renderer/core/html/html_table_section_element.cc b/third_party/blink/renderer/core/html/html_table_section_element.cc
index 1c5a455..8bf5436 100644
--- a/third_party/blink/renderer/core/html/html_table_section_element.cc
+++ b/third_party/blink/renderer/core/html/html_table_section_element.cc
@@ -30,12 +30,12 @@
 #include "third_party/blink/renderer/core/html/html_table_element.h"
 #include "third_party/blink/renderer/core/html/html_table_row_element.h"
 #include "third_party/blink/renderer/platform/bindings/exception_state.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
 
 namespace blink {
 
-inline HTMLTableSectionElement::HTMLTableSectionElement(
-    const QualifiedName& tag_name,
-    Document& document)
+HTMLTableSectionElement::HTMLTableSectionElement(const QualifiedName& tag_name,
+                                                 Document& document)
     : HTMLTablePartElement(tag_name, document) {}
 
 DEFINE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableSectionElement)
@@ -62,7 +62,7 @@
     return nullptr;
   }
 
-  HTMLTableRowElement* row = HTMLTableRowElement::Create(GetDocument());
+  auto* row = MakeGarbageCollected<HTMLTableRowElement>(GetDocument());
   if (num_rows == index || index == -1)
     AppendChild(row, exception_state);
   else
diff --git a/third_party/blink/renderer/core/html/html_table_section_element.h b/third_party/blink/renderer/core/html/html_table_section_element.h
index 151730e..cfedc050 100644
--- a/third_party/blink/renderer/core/html/html_table_section_element.h
+++ b/third_party/blink/renderer/core/html/html_table_section_element.h
@@ -38,6 +38,8 @@
  public:
   DECLARE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLTableSectionElement);
 
+  HTMLTableSectionElement(const QualifiedName& tag_name, Document&);
+
   HTMLElement* insertRow(int index, ExceptionState&);
   void deleteRow(int index, ExceptionState&);
 
@@ -46,8 +48,6 @@
   bool HasNonInBodyInsertionMode() const override { return true; }
 
  private:
-  HTMLTableSectionElement(const QualifiedName& tag_name, Document&);
-
   const CSSPropertyValueSet* AdditionalPresentationAttributeStyle() override;
 };
 
diff --git a/third_party/blink/renderer/core/html/html_view_source_document.cc b/third_party/blink/renderer/core/html/html_view_source_document.cc
index 4dd94e5..12284bf 100644
--- a/third_party/blink/renderer/core/html/html_view_source_document.cc
+++ b/third_party/blink/renderer/core/html/html_view_source_document.cc
@@ -38,6 +38,7 @@
 #include "third_party/blink/renderer/core/html/html_table_row_element.h"
 #include "third_party/blink/renderer/core/html/html_table_section_element.h"
 #include "third_party/blink/renderer/core/html/parser/html_view_source_parser.h"
+#include "third_party/blink/renderer/platform/heap/heap.h"
 
 namespace blink {
 
@@ -64,11 +65,11 @@
 }
 
 void HTMLViewSourceDocument::CreateContainingTable() {
-  HTMLHtmlElement* html = HTMLHtmlElement::Create(*this);
+  auto* html = MakeGarbageCollected<HTMLHtmlElement>(*this);
   ParserAppendChild(html);
-  HTMLHeadElement* head = HTMLHeadElement::Create(*this);
+  auto* head = MakeGarbageCollected<HTMLHeadElement>(*this);
   html->ParserAppendChild(head);
-  HTMLBodyElement* body = HTMLBodyElement::Create(*this);
+  auto* body = MakeGarbageCollected<HTMLBodyElement>(*this);
   html->ParserAppendChild(body);
 
   // Create a line gutter div that can be used to make sure the gutter extends
@@ -77,9 +78,9 @@
   div->setAttribute(kClassAttr, "line-gutter-backdrop");
   body->ParserAppendChild(div);
 
-  HTMLTableElement* table = HTMLTableElement::Create(*this);
+  auto* table = MakeGarbageCollected<HTMLTableElement>(*this);
   body->ParserAppendChild(table);
-  tbody_ = HTMLTableSectionElement::Create(kTbodyTag, *this);
+  tbody_ = MakeGarbageCollected<HTMLTableSectionElement>(kTbodyTag, *this);
   table->ParserAppendChild(tbody_);
   current_ = tbody_;
   line_number_ = 0;
@@ -206,18 +207,18 @@
 
 void HTMLViewSourceDocument::AddLine(const AtomicString& class_name) {
   // Create a table row.
-  HTMLTableRowElement* trow = HTMLTableRowElement::Create(*this);
+  auto* trow = MakeGarbageCollected<HTMLTableRowElement>(*this);
   tbody_->ParserAppendChild(trow);
 
   // Create a cell that will hold the line number (it is generated in the
   // stylesheet using counters).
-  HTMLTableCellElement* td = HTMLTableCellElement::Create(kTdTag, *this);
+  auto* td = MakeGarbageCollected<HTMLTableCellElement>(kTdTag, *this);
   td->setAttribute(kClassAttr, "line-number");
   td->SetIntegralAttribute(kValueAttr, ++line_number_);
   trow->ParserAppendChild(td);
 
   // Create a second cell for the line contents
-  td = HTMLTableCellElement::Create(kTdTag, *this);
+  td = MakeGarbageCollected<HTMLTableCellElement>(kTdTag, *this);
   td->setAttribute(kClassAttr, "line-content");
   trow->ParserAppendChild(td);
   current_ = td_ = td;
@@ -233,7 +234,7 @@
 
 void HTMLViewSourceDocument::FinishLine() {
   if (!current_->HasChildren()) {
-    HTMLBRElement* br = HTMLBRElement::Create(*this);
+    auto* br = MakeGarbageCollected<HTMLBRElement>(*this);
     current_->ParserAppendChild(br);
   }
   current_ = tbody_;
@@ -293,7 +294,7 @@
 }
 
 Element* HTMLViewSourceDocument::AddBase(const AtomicString& href) {
-  HTMLBaseElement* base = HTMLBaseElement::Create(*this);
+  auto* base = MakeGarbageCollected<HTMLBaseElement>(*this);
   base->setAttribute(kHrefAttr, href);
   current_->ParserAppendChild(base);
   return base;
@@ -305,7 +306,7 @@
     AddLine("html-tag");
 
   // Now create a link for the attribute value instead of a span.
-  HTMLAnchorElement* anchor = HTMLAnchorElement::Create(*this);
+  auto* anchor = MakeGarbageCollected<HTMLAnchorElement>(*this);
   const char* class_value;
   if (is_anchor)
     class_value = "html-attribute-value html-external-link";