Commit adfc51ef authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Use new downcast helper for blink::HTMLTemplateElement

This CL has two goals,
1. Use To<HTMLTemplateElement> and DynamicTo<HTMLTemplateElement> as
   new downcast helper
2. Use IsA<HTMLTemplateElement>(element) in place of
   IsHTMLTemplateElement(element)

Bug: 891908
Change-Id: I4220214482d1c4a78b3f5ef2cd450fabdf00c823
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901150
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713742}
parent 7c762fe1
...@@ -961,7 +961,7 @@ TEST_F(DisplayLockContextTest, ElementInTemplate) { ...@@ -961,7 +961,7 @@ TEST_F(DisplayLockContextTest, ElementInTemplate) {
EXPECT_EQ(GetDocument().ActivationBlockingDisplayLockCount(), 0); EXPECT_EQ(GetDocument().ActivationBlockingDisplayLockCount(), 0);
auto* template_el = auto* template_el =
ToHTMLTemplateElement(GetDocument().getElementById("template")); To<HTMLTemplateElement>(GetDocument().getElementById("template"));
auto* child = To<Element>(template_el->content()->firstChild()); auto* child = To<Element>(template_el->content()->firstChild());
EXPECT_FALSE(child->isConnected()); EXPECT_FALSE(child->isConnected());
......
...@@ -41,9 +41,9 @@ void ConvertTemplatesToShadowRoots(HTMLElement& element) { ...@@ -41,9 +41,9 @@ void ConvertTemplatesToShadowRoots(HTMLElement& element) {
Document* const document = element.ownerDocument(); Document* const document = element.ownerDocument();
ShadowRoot& shadow_root = ShadowRoot& shadow_root =
parent->AttachShadowRootInternal(ShadowRootType::kOpen); parent->AttachShadowRootInternal(ShadowRootType::kOpen);
Node* const fragment = Node* const fragment = document->importNode(
document->importNode(ToHTMLTemplateElement(template_element)->content(), To<HTMLTemplateElement>(template_element)->content(), true,
true, ASSERT_NO_EXCEPTION); ASSERT_NO_EXCEPTION);
shadow_root.AppendChild(fragment); shadow_root.AppendChild(fragment);
} }
} }
......
...@@ -60,8 +60,10 @@ void HTMLTemplateElement::CloneNonAttributePropertiesFrom( ...@@ -60,8 +60,10 @@ void HTMLTemplateElement::CloneNonAttributePropertiesFrom(
CloneChildrenFlag flag) { CloneChildrenFlag flag) {
if (flag == CloneChildrenFlag::kSkip) if (flag == CloneChildrenFlag::kSkip)
return; return;
if (ToHTMLTemplateElement(source).content_)
content()->CloneChildNodesFrom(*ToHTMLTemplateElement(source).content()); auto& html_template_element = To<HTMLTemplateElement>(source);
if (html_template_element.content_)
content()->CloneChildNodesFrom(*html_template_element.content());
} }
void HTMLTemplateElement::DidMoveToNewDocument(Document& old_document) { void HTMLTemplateElement::DidMoveToNewDocument(Document& old_document) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment