| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #include "sky/engine/public/web/WebElement.h" | |
| 32 | |
| 33 #include "sky/engine/bindings/exception_state.h" | |
| 34 #include "sky/engine/core/dom/Element.h" | |
| 35 #include "sky/engine/core/dom/custom/custom_element_callback_scope.h" | |
| 36 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | |
| 37 #include "sky/engine/core/rendering/RenderBoxModelObject.h" | |
| 38 #include "sky/engine/core/rendering/RenderObject.h" | |
| 39 #include "sky/engine/public/platform/WebRect.h" | |
| 40 #include "sky/engine/public/web/WebDocument.h" | |
| 41 #include "sky/engine/wtf/PassRefPtr.h" | |
| 42 | |
| 43 namespace blink { | |
| 44 | |
| 45 WebString WebElement::tagName() const | |
| 46 { | |
| 47 return constUnwrap<Element>()->tagName(); | |
| 48 } | |
| 49 | |
| 50 bool WebElement::hasAttribute(const WebString& attrName) const | |
| 51 { | |
| 52 return constUnwrap<Element>()->hasAttribute(attrName); | |
| 53 } | |
| 54 | |
| 55 void WebElement::removeAttribute(const WebString& attrName) | |
| 56 { | |
| 57 // TODO: Custom element callbacks need to be called on WebKit API methods th
at | |
| 58 // mutate the DOM in any way. | |
| 59 CustomElementCallbackScope deliveryScope; | |
| 60 unwrap<Element>()->removeAttribute(attrName); | |
| 61 } | |
| 62 | |
| 63 WebString WebElement::getAttribute(const WebString& attrName) const | |
| 64 { | |
| 65 return constUnwrap<Element>()->getAttribute(attrName); | |
| 66 } | |
| 67 | |
| 68 bool WebElement::setAttribute(const WebString& attrName, const WebString& attrVa
lue) | |
| 69 { | |
| 70 // TODO: Custom element callbacks need to be called on WebKit API methods th
at | |
| 71 // mutate the DOM in any way. | |
| 72 CustomElementCallbackScope deliveryScope; | |
| 73 TrackExceptionState exceptionState; | |
| 74 unwrap<Element>()->setAttribute(attrName, attrValue, exceptionState); | |
| 75 return !exceptionState.had_exception(); | |
| 76 } | |
| 77 | |
| 78 unsigned WebElement::attributeCount() const | |
| 79 { | |
| 80 if (!constUnwrap<Element>()->hasAttributes()) | |
| 81 return 0; | |
| 82 return constUnwrap<Element>()->attributes().size(); | |
| 83 } | |
| 84 | |
| 85 WebNode WebElement::shadowRoot() const | |
| 86 { | |
| 87 ShadowRoot* shadowRoot = constUnwrap<Element>()->shadowRoot(); | |
| 88 if (!shadowRoot) | |
| 89 return WebNode(); | |
| 90 return WebNode(shadowRoot->toNode()); | |
| 91 } | |
| 92 | |
| 93 WebString WebElement::attributeLocalName(unsigned index) const | |
| 94 { | |
| 95 if (index >= attributeCount()) | |
| 96 return WebString(); | |
| 97 return constUnwrap<Element>()->attributes().at(index).localName(); | |
| 98 } | |
| 99 | |
| 100 WebString WebElement::attributeValue(unsigned index) const | |
| 101 { | |
| 102 if (index >= attributeCount()) | |
| 103 return WebString(); | |
| 104 return constUnwrap<Element>()->attributes().at(index).value(); | |
| 105 } | |
| 106 | |
| 107 WebString WebElement::computeInheritedLanguage() const | |
| 108 { | |
| 109 return WebString(constUnwrap<Element>()->computeInheritedLanguage()); | |
| 110 } | |
| 111 | |
| 112 void WebElement::requestFullScreen() | |
| 113 { | |
| 114 } | |
| 115 | |
| 116 WebElement::WebElement(const PassRefPtr<Element>& elem) | |
| 117 : WebNode(elem) | |
| 118 { | |
| 119 } | |
| 120 | |
| 121 WebElement& WebElement::operator=(const PassRefPtr<Element>& elem) | |
| 122 { | |
| 123 m_private = elem; | |
| 124 return *this; | |
| 125 } | |
| 126 | |
| 127 WebElement::operator PassRefPtr<Element>() const | |
| 128 { | |
| 129 return toElement(m_private.get()); | |
| 130 } | |
| 131 | |
| 132 } // namespace blink | |
| OLD | NEW |