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

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

Issue 105693009: Move insertAdjacentHTML to Element (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Correct base. Should not include patches it depends on. Created 7 years 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
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLElement.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLElement.cpp
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index c9ca7578d6139d4713b362a2e3173ef70d5b5b25..8862b0c76838d69145e699d53b5f05e2c0c4b8c5 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -452,48 +452,6 @@ void HTMLElement::setOuterText(const String &text, ExceptionState& exceptionStat
mergeWithNextTextNode(prev.release(), exceptionState);
}
-Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, ExceptionState& exceptionState)
-{
- // In Internet Explorer if the element has no parent and where is "beforeBegin" or "afterEnd",
- // a document fragment is created and the elements appended in the correct order. This document
- // fragment isn't returned anywhere.
- //
- // This is impossible for us to implement as the DOM tree does not allow for such structures,
- // Opera also appears to disallow such usage.
-
- if (equalIgnoringCase(where, "beforeBegin")) {
- if (ContainerNode* parent = this->parentNode()) {
- parent->insertBefore(newChild, this, exceptionState);
- if (!exceptionState.hadException())
- return newChild;
- }
- return 0;
- }
-
- if (equalIgnoringCase(where, "afterBegin")) {
- insertBefore(newChild, firstChild(), exceptionState);
- return exceptionState.hadException() ? 0 : newChild;
- }
-
- if (equalIgnoringCase(where, "beforeEnd")) {
- appendChild(newChild, exceptionState);
- return exceptionState.hadException() ? 0 : newChild;
- }
-
- if (equalIgnoringCase(where, "afterEnd")) {
- if (ContainerNode* parent = this->parentNode()) {
- parent->insertBefore(newChild, nextSibling(), exceptionState);
- if (!exceptionState.hadException())
- return newChild;
- }
- return 0;
- }
-
- // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative.
- exceptionState.throwDOMException(SyntaxError, "The value provided ('" + where + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.");
- return 0;
-}
-
Element* HTMLElement::insertAdjacentElement(const String& where, Element* newChild, ExceptionState& exceptionState)
{
if (!newChild) {
@@ -506,35 +464,6 @@ Element* HTMLElement::insertAdjacentElement(const String& where, Element* newChi
return toElement(returnValue);
}
-// Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml()
-static Element* contextElementForInsertion(const String& where, Element* element, ExceptionState& exceptionState)
-{
- if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "afterEnd")) {
- ContainerNode* parent = element->parentNode();
- if (!parent || !parent->isElementNode()) {
- exceptionState.throwDOMException(NoModificationAllowedError, "The element has no parent.");
- return 0;
- }
- return toElement(parent);
- }
- if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "beforeEnd"))
- return element;
- exceptionState.throwDOMException(SyntaxError, "The value provided ('" + where + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.");
- return 0;
-}
-
-void HTMLElement::insertAdjacentHTML(const String& where, const String& markup, ExceptionState& exceptionState)
-{
- RefPtr<Element> contextElement = contextElementForInsertion(where, this, exceptionState);
- if (!contextElement)
- return;
-
- RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, contextElement.get(), AllowScriptingContent, "insertAdjacentHTML", exceptionState);
- if (!fragment)
- return;
- insertAdjacent(where, fragment.get(), exceptionState);
-}
-
void HTMLElement::insertAdjacentText(const String& where, const String& text, ExceptionState& exceptionState)
{
RefPtr<Text> textNode = document().createTextNode(text);
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698