Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Unified Diff: Source/core/html/HTMLElement.cpp

Issue 44333002: Move innerHTML and outerHTML to Element (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased to latest master Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLElement.cpp
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index c19dcfbdabac5421a8e86b27cbeba7a5527bbbd6..2500b8a53596aa222e187172cb7312d9e698b7ca 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -325,64 +325,6 @@ void HTMLElement::parseAttribute(const QualifiedName& name, const AtomicString&
}
}
-String HTMLElement::innerHTML() const
-{
- return createMarkup(this, ChildrenOnly);
-}
-
-String HTMLElement::outerHTML() const
-{
- return createMarkup(this);
-}
-
-void HTMLElement::setInnerHTML(const String& html, ExceptionState& es)
-{
- if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html, this, AllowScriptingContent, "innerHTML", es)) {
- ContainerNode* container = this;
- if (hasLocalName(templateTag))
- container = toHTMLTemplateElement(this)->content();
- replaceChildrenWithFragment(container, fragment.release(), es);
- }
-}
-
-static void mergeWithNextTextNode(PassRefPtr<Node> node, ExceptionState& es)
-{
- ASSERT(node && node->isTextNode());
- Node* next = node->nextSibling();
- if (!next || !next->isTextNode())
- return;
-
- RefPtr<Text> textNode = toText(node.get());
- RefPtr<Text> textNext = toText(next);
- textNode->appendData(textNext->data());
- if (textNext->parentNode()) // Might have been removed by mutation event.
- textNext->remove(es);
-}
-
-void HTMLElement::setOuterHTML(const String& html, ExceptionState& es)
-{
- Node* p = parentNode();
- if (!p || !p->isHTMLElement()) {
- es.throwUninformativeAndGenericDOMException(NoModificationAllowedError);
- return;
- }
- RefPtr<HTMLElement> parent = toHTMLElement(p);
- RefPtr<Node> prev = previousSibling();
- RefPtr<Node> next = nextSibling();
-
- RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html, parent.get(), AllowScriptingContent, "outerHTML", es);
- if (es.hadException())
- return;
-
- parent->replaceChild(fragment.release(), this, es);
- RefPtr<Node> node = next ? next->previousSibling() : 0;
- if (!es.hadException() && node && node->isTextNode())
- mergeWithNextTextNode(node.release(), es);
-
- if (!es.hadException() && prev && prev->isTextNode())
- mergeWithNextTextNode(prev.release(), es);
-}
-
PassRefPtr<DocumentFragment> HTMLElement::textToFragment(const String& text, ExceptionState& es)
{
RefPtr<DocumentFragment> fragment = DocumentFragment::create(document());

Powered by Google App Engine
This is Rietveld 408576698