Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 #include "core/dom/SelectorQuery.h" | 65 #include "core/dom/SelectorQuery.h" |
| 66 #include "core/dom/Text.h" | 66 #include "core/dom/Text.h" |
| 67 #include "core/dom/WhitespaceChildList.h" | 67 #include "core/dom/WhitespaceChildList.h" |
| 68 #include "core/dom/custom/CustomElement.h" | 68 #include "core/dom/custom/CustomElement.h" |
| 69 #include "core/dom/custom/CustomElementRegistrationContext.h" | 69 #include "core/dom/custom/CustomElementRegistrationContext.h" |
| 70 #include "core/dom/shadow/InsertionPoint.h" | 70 #include "core/dom/shadow/InsertionPoint.h" |
| 71 #include "core/dom/shadow/ShadowRoot.h" | 71 #include "core/dom/shadow/ShadowRoot.h" |
| 72 #include "core/editing/FrameSelection.h" | 72 #include "core/editing/FrameSelection.h" |
| 73 #include "core/editing/TextIterator.h" | 73 #include "core/editing/TextIterator.h" |
| 74 #include "core/editing/htmlediting.h" | 74 #include "core/editing/htmlediting.h" |
| 75 #include "core/editing/markup.h" | |
| 75 #include "core/events/EventDispatcher.h" | 76 #include "core/events/EventDispatcher.h" |
| 76 #include "core/events/FocusEvent.h" | 77 #include "core/events/FocusEvent.h" |
| 77 #include "core/frame/ContentSecurityPolicy.h" | 78 #include "core/frame/ContentSecurityPolicy.h" |
| 78 #include "core/frame/Frame.h" | 79 #include "core/frame/Frame.h" |
| 79 #include "core/frame/FrameView.h" | 80 #include "core/frame/FrameView.h" |
| 80 #include "core/html/ClassList.h" | 81 #include "core/html/ClassList.h" |
| 81 #include "core/html/HTMLCollection.h" | 82 #include "core/html/HTMLCollection.h" |
| 82 #include "core/html/HTMLDocument.h" | 83 #include "core/html/HTMLDocument.h" |
| 83 #include "core/html/HTMLElement.h" | 84 #include "core/html/HTMLElement.h" |
| 84 #include "core/html/HTMLFormControlsCollection.h" | 85 #include "core/html/HTMLFormControlsCollection.h" |
| 85 #include "core/html/HTMLFrameOwnerElement.h" | 86 #include "core/html/HTMLFrameOwnerElement.h" |
| 86 #include "core/html/HTMLLabelElement.h" | 87 #include "core/html/HTMLLabelElement.h" |
| 87 #include "core/html/HTMLOptionsCollection.h" | 88 #include "core/html/HTMLOptionsCollection.h" |
| 88 #include "core/html/HTMLTableRowsCollection.h" | 89 #include "core/html/HTMLTableRowsCollection.h" |
| 90 #include "core/html/HTMLTemplateElement.h" | |
| 89 #include "core/html/parser/HTMLParserIdioms.h" | 91 #include "core/html/parser/HTMLParserIdioms.h" |
| 90 #include "core/page/FocusController.h" | 92 #include "core/page/FocusController.h" |
| 91 #include "core/page/Page.h" | 93 #include "core/page/Page.h" |
| 92 #include "core/page/PointerLockController.h" | 94 #include "core/page/PointerLockController.h" |
| 93 #include "core/rendering/FlowThreadController.h" | 95 #include "core/rendering/FlowThreadController.h" |
| 94 #include "core/rendering/RenderRegion.h" | 96 #include "core/rendering/RenderRegion.h" |
| 95 #include "core/rendering/RenderView.h" | 97 #include "core/rendering/RenderView.h" |
| 96 #include "core/rendering/RenderWidget.h" | 98 #include "core/rendering/RenderWidget.h" |
| 97 #include "core/svg/SVGDocumentExtensions.h" | 99 #include "core/svg/SVGDocumentExtensions.h" |
| 98 #include "core/svg/SVGElement.h" | 100 #include "core/svg/SVGElement.h" |
| (...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2197 dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(Foc usEvent::create(eventType, true, false, document().domWindow(), 0, oldFocusedEle ment))); | 2199 dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(Foc usEvent::create(eventType, true, false, document().domWindow(), 0, oldFocusedEle ment))); |
| 2198 } | 2200 } |
| 2199 | 2201 |
| 2200 void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newF ocusedElement) | 2202 void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newF ocusedElement) |
| 2201 { | 2203 { |
| 2202 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 2204 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); |
| 2203 ASSERT(eventType == EventTypeNames::focusout || eventType == EventTypeNames: :DOMFocusOut); | 2205 ASSERT(eventType == EventTypeNames::focusout || eventType == EventTypeNames: :DOMFocusOut); |
| 2204 dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(Fo cusEvent::create(eventType, true, false, document().domWindow(), 0, newFocusedEl ement))); | 2206 dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(Fo cusEvent::create(eventType, true, false, document().domWindow(), 0, newFocusedEl ement))); |
| 2205 } | 2207 } |
| 2206 | 2208 |
| 2209 String Element::innerHTML() const | |
| 2210 { | |
| 2211 return createMarkup(this, ChildrenOnly); | |
| 2212 } | |
| 2213 | |
| 2214 String Element::outerHTML() const | |
| 2215 { | |
| 2216 return createMarkup(this); | |
| 2217 } | |
| 2218 | |
| 2219 void Element::setInnerHTML(const String& html, ExceptionState& es) | |
| 2220 { | |
| 2221 if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html , this, AllowScriptingContent, "innerHTML", es)) { | |
| 2222 ContainerNode* container = this; | |
| 2223 if (hasLocalName(templateTag)) | |
| 2224 container = toHTMLTemplateElement(this)->content(); | |
|
abarth-chromium
2013/10/29 04:04:42
This is a bad cast. Just because an element has a
davve
2013/10/29 09:15:38
*blush*. Good eyes. I've added a crash test.
| |
| 2225 replaceChildrenWithFragment(container, fragment.release(), es); | |
| 2226 } | |
| 2227 } | |
| 2228 | |
| 2229 void Element::setOuterHTML(const String& html, ExceptionState& es) | |
| 2230 { | |
| 2231 Node* p = parentNode(); | |
| 2232 if (!p || !p->isElementNode()) { | |
| 2233 es.throwUninformativeAndGenericDOMException(NoModificationAllowedError); | |
| 2234 return; | |
| 2235 } | |
| 2236 RefPtr<Element> parent = toElement(p); | |
| 2237 RefPtr<Node> prev = previousSibling(); | |
| 2238 RefPtr<Node> next = nextSibling(); | |
| 2239 | |
| 2240 RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(html, pa rent.get(), AllowScriptingContent, "outerHTML", es); | |
| 2241 if (es.hadException()) | |
| 2242 return; | |
| 2243 | |
| 2244 parent->replaceChild(fragment.release(), this, es); | |
|
abarth-chromium
2013/10/29 04:04:42
We don't need to protect |this| during this functi
| |
| 2245 RefPtr<Node> node = next ? next->previousSibling() : 0; | |
| 2246 if (!es.hadException() && node && node->isTextNode()) | |
| 2247 mergeWithNextTextNode(node.release(), es); | |
| 2248 | |
| 2249 if (!es.hadException() && prev && prev->isTextNode()) | |
| 2250 mergeWithNextTextNode(prev.release(), es); | |
| 2251 } | |
| 2252 | |
| 2207 String Element::innerText() | 2253 String Element::innerText() |
| 2208 { | 2254 { |
| 2209 // We need to update layout, since plainText uses line boxes in the render t ree. | 2255 // We need to update layout, since plainText uses line boxes in the render t ree. |
| 2210 document().updateLayoutIgnorePendingStylesheets(); | 2256 document().updateLayoutIgnorePendingStylesheets(); |
| 2211 | 2257 |
| 2212 if (!renderer()) | 2258 if (!renderer()) |
| 2213 return textContent(true); | 2259 return textContent(true); |
| 2214 | 2260 |
| 2215 return plainText(rangeOfContents(const_cast<Element*>(this)).get()); | 2261 return plainText(rangeOfContents(const_cast<Element*>(this)).get()); |
| 2216 } | 2262 } |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3427 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems | 3473 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi stItems |
| 3428 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 | 3474 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg i?id=88405 |
| 3429 if (hasTagName(optionTag) || hasTagName(optgroupTag)) | 3475 if (hasTagName(optionTag) || hasTagName(optgroupTag)) |
| 3430 return false; | 3476 return false; |
| 3431 if (FullscreenElementStack::isActiveFullScreenElement(this)) | 3477 if (FullscreenElementStack::isActiveFullScreenElement(this)) |
| 3432 return false; | 3478 return false; |
| 3433 return true; | 3479 return true; |
| 3434 } | 3480 } |
| 3435 | 3481 |
| 3436 } // namespace WebCore | 3482 } // namespace WebCore |
| OLD | NEW |