OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 ensureElementRareData().setCustomElementDefinition(definition); | 1731 ensureElementRareData().setCustomElementDefinition(definition); |
1732 } | 1732 } |
1733 | 1733 |
1734 CustomElementDefinition* Element::customElementDefinition() const | 1734 CustomElementDefinition* Element::customElementDefinition() const |
1735 { | 1735 { |
1736 if (hasRareData()) | 1736 if (hasRareData()) |
1737 return elementRareData()->customElementDefinition(); | 1737 return elementRareData()->customElementDefinition(); |
1738 return 0; | 1738 return 0; |
1739 } | 1739 } |
1740 | 1740 |
1741 PassRefPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& exceptionState) | 1741 PassRefPtrWillBeRawPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& exc
eptionState) |
1742 { | 1742 { |
1743 if (alwaysCreateUserAgentShadowRoot()) | 1743 if (alwaysCreateUserAgentShadowRoot()) |
1744 ensureUserAgentShadowRoot(); | 1744 ensureUserAgentShadowRoot(); |
1745 | 1745 |
1746 // Some elements make assumptions about what kind of renderers they allow | 1746 // Some elements make assumptions about what kind of renderers they allow |
1747 // as children so we can't allow author shadows on them for now. An override | 1747 // as children so we can't allow author shadows on them for now. An override |
1748 // flag is provided for testing how author shadows interact on these element
s. | 1748 // flag is provided for testing how author shadows interact on these element
s. |
1749 if (!areAuthorShadowsAllowed() && !RuntimeEnabledFeatures::authorShadowDOMFo
rAnyElementEnabled()) { | 1749 if (!areAuthorShadowsAllowed() && !RuntimeEnabledFeatures::authorShadowDOMFo
rAnyElementEnabled()) { |
1750 exceptionState.throwDOMException(HierarchyRequestError, "Author-created
shadow roots are disabled for this element."); | 1750 exceptionState.throwDOMException(HierarchyRequestError, "Author-created
shadow roots are disabled for this element."); |
1751 return nullptr; | 1751 return nullptr; |
1752 } | 1752 } |
1753 | 1753 |
1754 return PassRefPtr<ShadowRoot>(ensureShadow().addShadowRoot(*this, ShadowRoot
::AuthorShadowRoot)); | 1754 return PassRefPtrWillBeRawPtr<ShadowRoot>(ensureShadow().addShadowRoot(*this
, ShadowRoot::AuthorShadowRoot)); |
1755 } | 1755 } |
1756 | 1756 |
1757 ShadowRoot* Element::shadowRoot() const | 1757 ShadowRoot* Element::shadowRoot() const |
1758 { | 1758 { |
1759 ElementShadow* elementShadow = shadow(); | 1759 ElementShadow* elementShadow = shadow(); |
1760 if (!elementShadow) | 1760 if (!elementShadow) |
1761 return 0; | 1761 return 0; |
1762 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); | 1762 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); |
1763 if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot) | 1763 if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot) |
1764 return shadowRoot; | 1764 return shadowRoot; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2204 return createMarkup(this, ChildrenOnly); | 2204 return createMarkup(this, ChildrenOnly); |
2205 } | 2205 } |
2206 | 2206 |
2207 String Element::outerHTML() const | 2207 String Element::outerHTML() const |
2208 { | 2208 { |
2209 return createMarkup(this); | 2209 return createMarkup(this); |
2210 } | 2210 } |
2211 | 2211 |
2212 void Element::setInnerHTML(const String& html, ExceptionState& exceptionState) | 2212 void Element::setInnerHTML(const String& html, ExceptionState& exceptionState) |
2213 { | 2213 { |
2214 if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html
, this, AllowScriptingContent, "innerHTML", exceptionState)) { | 2214 if (RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOu
terHTML(html, this, AllowScriptingContent, "innerHTML", exceptionState)) { |
2215 ContainerNode* container = this; | 2215 ContainerNode* container = this; |
2216 if (isHTMLTemplateElement(*this)) | 2216 if (isHTMLTemplateElement(*this)) |
2217 container = toHTMLTemplateElement(this)->content(); | 2217 container = toHTMLTemplateElement(this)->content(); |
2218 replaceChildrenWithFragment(container, fragment.release(), exceptionStat
e); | 2218 replaceChildrenWithFragment(container, fragment.release(), exceptionStat
e); |
2219 } | 2219 } |
2220 } | 2220 } |
2221 | 2221 |
2222 void Element::setOuterHTML(const String& html, ExceptionState& exceptionState) | 2222 void Element::setOuterHTML(const String& html, ExceptionState& exceptionState) |
2223 { | 2223 { |
2224 Node* p = parentNode(); | 2224 Node* p = parentNode(); |
2225 if (!p) { | 2225 if (!p) { |
2226 exceptionState.throwDOMException(NoModificationAllowedError, "This eleme
nt has no parent node."); | 2226 exceptionState.throwDOMException(NoModificationAllowedError, "This eleme
nt has no parent node."); |
2227 return; | 2227 return; |
2228 } | 2228 } |
2229 if (!p->isElementNode()) { | 2229 if (!p->isElementNode()) { |
2230 exceptionState.throwDOMException(NoModificationAllowedError, "This eleme
nt's parent is of type '" + p->nodeName() + "', which is not an element node."); | 2230 exceptionState.throwDOMException(NoModificationAllowedError, "This eleme
nt's parent is of type '" + p->nodeName() + "', which is not an element node."); |
2231 return; | 2231 return; |
2232 } | 2232 } |
2233 | 2233 |
2234 RefPtr<Element> parent = toElement(p); | 2234 RefPtr<Element> parent = toElement(p); |
2235 RefPtr<Node> prev = previousSibling(); | 2235 RefPtr<Node> prev = previousSibling(); |
2236 RefPtr<Node> next = nextSibling(); | 2236 RefPtr<Node> next = nextSibling(); |
2237 | 2237 |
2238 RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html, pa
rent.get(), AllowScriptingContent, "outerHTML", exceptionState); | 2238 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH
TML(html, parent.get(), AllowScriptingContent, "outerHTML", exceptionState); |
2239 if (exceptionState.hadException()) | 2239 if (exceptionState.hadException()) |
2240 return; | 2240 return; |
2241 | 2241 |
2242 parent->replaceChild(fragment.release(), this, exceptionState); | 2242 parent->replaceChild(fragment.release(), this, exceptionState); |
2243 RefPtr<Node> node = next ? next->previousSibling() : 0; | 2243 RefPtr<Node> node = next ? next->previousSibling() : 0; |
2244 if (!exceptionState.hadException() && node && node->isTextNode()) | 2244 if (!exceptionState.hadException() && node && node->isTextNode()) |
2245 mergeWithNextTextNode(node.release(), exceptionState); | 2245 mergeWithNextTextNode(node.release(), exceptionState); |
2246 | 2246 |
2247 if (!exceptionState.hadException() && prev && prev->isTextNode()) | 2247 if (!exceptionState.hadException() && prev && prev->isTextNode()) |
2248 mergeWithNextTextNode(prev.release(), exceptionState); | 2248 mergeWithNextTextNode(prev.release(), exceptionState); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 { | 2315 { |
2316 insertAdjacent(where, document().createTextNode(text).get(), exceptionState)
; | 2316 insertAdjacent(where, document().createTextNode(text).get(), exceptionState)
; |
2317 } | 2317 } |
2318 | 2318 |
2319 void Element::insertAdjacentHTML(const String& where, const String& markup, Exce
ptionState& exceptionState) | 2319 void Element::insertAdjacentHTML(const String& where, const String& markup, Exce
ptionState& exceptionState) |
2320 { | 2320 { |
2321 RefPtr<Element> contextElement = contextElementForInsertion(where, this, exc
eptionState); | 2321 RefPtr<Element> contextElement = contextElementForInsertion(where, this, exc
eptionState); |
2322 if (!contextElement) | 2322 if (!contextElement) |
2323 return; | 2323 return; |
2324 | 2324 |
2325 RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup,
contextElement.get(), AllowScriptingContent, "insertAdjacentHTML", exceptionStat
e); | 2325 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH
TML(markup, contextElement.get(), AllowScriptingContent, "insertAdjacentHTML", e
xceptionState); |
2326 if (!fragment) | 2326 if (!fragment) |
2327 return; | 2327 return; |
2328 insertAdjacent(where, fragment.get(), exceptionState); | 2328 insertAdjacent(where, fragment.get(), exceptionState); |
2329 } | 2329 } |
2330 | 2330 |
2331 String Element::innerText() | 2331 String Element::innerText() |
2332 { | 2332 { |
2333 // We need to update layout, since plainText uses line boxes in the render t
ree. | 2333 // We need to update layout, since plainText uses line boxes in the render t
ree. |
2334 document().updateLayoutIgnorePendingStylesheets(); | 2334 document().updateLayoutIgnorePendingStylesheets(); |
2335 | 2335 |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3301 | 3301 |
3302 void Element::trace(Visitor* visitor) | 3302 void Element::trace(Visitor* visitor) |
3303 { | 3303 { |
3304 if (hasRareData()) | 3304 if (hasRareData()) |
3305 visitor->trace(elementRareData()); | 3305 visitor->trace(elementRareData()); |
3306 | 3306 |
3307 ContainerNode::trace(visitor); | 3307 ContainerNode::trace(visitor); |
3308 } | 3308 } |
3309 | 3309 |
3310 } // namespace WebCore | 3310 } // namespace WebCore |
OLD | NEW |