| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 PassRefPtr<HTMLTemplateElement> HTMLTemplateElement::create(const QualifiedName&
tagName, Handle<Document> document) | 55 PassRefPtr<HTMLTemplateElement> HTMLTemplateElement::create(const QualifiedName&
tagName, Handle<Document> document) |
| 56 { | 56 { |
| 57 return adoptRef(new HTMLTemplateElement(tagName, document)); | 57 return adoptRef(new HTMLTemplateElement(tagName, document)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 DocumentFragment* HTMLTemplateElement::content() const | 60 DocumentFragment* HTMLTemplateElement::content() const |
| 61 { | 61 { |
| 62 // FIXME(oilpan): Handlify TemplateContentDocumentFragment. |
| 62 if (!m_content) | 63 if (!m_content) |
| 63 m_content = TemplateContentDocumentFragment::create(document()->ensureTe
mplateDocument(), this); | 64 m_content = adoptRawResult(TemplateContentDocumentFragment::create(docum
ent()->ensureTemplateDocument(), this).get()); |
| 64 | 65 |
| 65 return m_content.get(); | 66 return Handle<DocumentFragment>(m_content).raw(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 PassRefPtr<Node> HTMLTemplateElement::cloneNode(bool deep) | 69 PassRefPtr<Node> HTMLTemplateElement::cloneNode(bool deep) |
| 69 { | 70 { |
| 70 if (!deep) | 71 if (!deep) |
| 71 return cloneElementWithoutChildren(); | 72 return cloneElementWithoutChildren(); |
| 72 | 73 |
| 73 RefPtr<Node> clone = cloneElementWithChildren(); | 74 RefPtr<Node> clone = cloneElementWithChildren(); |
| 74 if (m_content) | 75 if (m_content) |
| 75 content()->cloneChildNodes(toHTMLTemplateElement(clone.get())->content()
); | 76 content()->cloneChildNodes(toHTMLTemplateElement(clone.get())->content()
); |
| 76 return clone.release(); | 77 return clone.release(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void HTMLTemplateElement::didMoveToNewDocument(Handle<Document> oldDocument) | 80 void HTMLTemplateElement::didMoveToNewDocument(Handle<Document> oldDocument) |
| 80 { | 81 { |
| 81 HTMLElement::didMoveToNewDocument(oldDocument); | 82 HTMLElement::didMoveToNewDocument(oldDocument); |
| 82 if (!m_content) | 83 if (!m_content) |
| 83 return; | 84 return; |
| 84 document()->ensureTemplateDocument()->adoptIfNeeded(m_content.get()); | 85 document()->ensureTemplateDocument()->adoptIfNeeded(Handle<DocumentFragment>
(m_content).raw()); |
| 85 } | 86 } |
| 86 | 87 |
| 87 #ifndef NDEBUG | 88 #ifndef NDEBUG |
| 88 const HTMLTemplateElement* toHTMLTemplateElement(const Node* node) | 89 const HTMLTemplateElement* toHTMLTemplateElement(const Node* node) |
| 89 { | 90 { |
| 90 ASSERT_WITH_SECURITY_IMPLICATION(!node || (node->isHTMLElement() && node->ha
sTagName(templateTag))); | 91 ASSERT_WITH_SECURITY_IMPLICATION(!node || (node->isHTMLElement() && node->ha
sTagName(templateTag))); |
| 91 return static_cast<const HTMLTemplateElement*>(node); | 92 return static_cast<const HTMLTemplateElement*>(node); |
| 92 } | 93 } |
| 93 #endif | 94 #endif |
| 94 | 95 |
| 96 void HTMLTemplateElement::acceptHeapVisitor(Visitor* visitor) const |
| 97 { |
| 98 visitor->visit(m_content); |
| 99 HTMLElement::acceptHeapVisitor(visitor); |
| 100 } |
| 101 |
| 95 } // namespace WebCore | 102 } // namespace WebCore |
| OLD | NEW |