| 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 * Copyright (C) 2004-2007, 2009, 2014 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004-2007, 2009, 2014 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 * | 20 * |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef SKY_ENGINE_CORE_HTML_HTMLELEMENT_H_ | 23 #ifndef SKY_ENGINE_CORE_HTML_HTMLELEMENT_H_ |
| 24 #define SKY_ENGINE_CORE_HTML_HTMLELEMENT_H_ | 24 #define SKY_ENGINE_CORE_HTML_HTMLELEMENT_H_ |
| 25 | 25 |
| 26 #include "sky/engine/core/dom/Element.h" | 26 #include "sky/engine/core/dom/Element.h" |
| 27 | 27 |
| 28 namespace blink { | 28 namespace blink { |
| 29 | 29 |
| 30 class ExceptionState; | |
| 31 | |
| 32 class HTMLElement : public Element { | 30 class HTMLElement : public Element { |
| 33 DEFINE_WRAPPERTYPEINFO(); | 31 DEFINE_WRAPPERTYPEINFO(); |
| 34 public: | 32 public: |
| 35 DECLARE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLElement); | 33 DECLARE_ELEMENT_FACTORY_WITH_TAGNAME(HTMLElement); |
| 36 | 34 |
| 37 bool hasTagName(const HTMLQualifiedName& name) const { return hasLocalName(n
ame.localName()); } | |
| 38 | |
| 39 virtual String title() const override final; | |
| 40 virtual short tabIndex() const override; | |
| 41 | |
| 42 String contentEditable() const; | |
| 43 void setContentEditable(const String&, ExceptionState&); | |
| 44 | |
| 45 bool spellcheck() const; | |
| 46 void setSpellcheck(bool); | |
| 47 | |
| 48 const AtomicString& dir(); | |
| 49 void setDir(const AtomicString&); | |
| 50 | |
| 51 void click(); | |
| 52 | |
| 53 virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext,
v8::Isolate*) override; | 35 virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext,
v8::Isolate*) override; |
| 54 | 36 |
| 55 protected: | 37 protected: |
| 56 HTMLElement(const QualifiedName& tagName, Document&, ConstructionType); | 38 HTMLElement(const QualifiedName& tagName, Document&, ConstructionType); |
| 57 | 39 |
| 58 private: | 40 private: |
| 59 bool isHTMLElement() const = delete; // This will catch anyone doing an unne
cessary check. | 41 bool isHTMLElement() const = delete; // This will catch anyone doing an unne
cessary check. |
| 60 bool isStyledElement() const = delete; // This will catch anyone doing an un
necessary check. | 42 bool isStyledElement() const = delete; // This will catch anyone doing an un
necessary check. |
| 61 }; | 43 }; |
| 62 | 44 |
| 63 DEFINE_ELEMENT_TYPE_CASTS(HTMLElement, isHTMLElement()); | 45 DEFINE_ELEMENT_TYPE_CASTS(HTMLElement, isHTMLElement()); |
| 64 | 46 |
| 65 template <typename T> bool isElementOfType(const HTMLElement&); | 47 template <typename T> bool isElementOfType(const HTMLElement&); |
| 66 template <> inline bool isElementOfType<const HTMLElement>(const HTMLElement&) {
return true; } | 48 template <> inline bool isElementOfType<const HTMLElement>(const HTMLElement&) {
return true; } |
| 67 | 49 |
| 68 inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document& document
, ConstructionType type = CreateHTMLElement) | 50 inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document& document
, ConstructionType type = CreateHTMLElement) |
| 69 : Element(tagName, &document, type) | 51 : Element(tagName, &document, type) |
| 70 { | 52 { |
| 71 ASSERT(!tagName.localName().isNull()); | 53 ASSERT(!tagName.localName().isNull()); |
| 72 } | 54 } |
| 73 | 55 |
| 74 inline bool Node::hasTagName(const HTMLQualifiedName& name) const | |
| 75 { | |
| 76 return isHTMLElement() && toHTMLElement(*this).hasTagName(name); | |
| 77 } | |
| 78 | |
| 79 // Functor used to match HTMLElements with a specific HTML tag when using the El
ementTraversal API. | |
| 80 class HasHTMLTagName { | |
| 81 public: | |
| 82 explicit HasHTMLTagName(const HTMLQualifiedName& tagName): m_tagName(tagName
) { } | |
| 83 bool operator() (const HTMLElement& element) const { return element.hasTagNa
me(m_tagName); } | |
| 84 private: | |
| 85 const HTMLQualifiedName& m_tagName; | |
| 86 }; | |
| 87 | |
| 88 // This requires isHTML*Element(const Element&) and isHTML*Element(const HTMLEle
ment&). | 56 // This requires isHTML*Element(const Element&) and isHTML*Element(const HTMLEle
ment&). |
| 89 // When the input element is an HTMLElement, we don't need to check the namespac
e URI, just the local name. | 57 // When the input element is an HTMLElement, we don't need to check the namespac
e URI, just the local name. |
| 90 #define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ | 58 #define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ |
| 91 inline bool is##thisType(const thisType* element); \ | 59 inline bool is##thisType(const thisType* element); \ |
| 92 inline bool is##thisType(const thisType& element); \ | 60 inline bool is##thisType(const thisType& element); \ |
| 93 inline bool is##thisType(const HTMLElement* element) { return element && is#
#thisType(*element); } \ | 61 inline bool is##thisType(const HTMLElement* element) { return element && is#
#thisType(*element); } \ |
| 94 inline bool is##thisType(const Node& node) { return node.isHTMLElement() ? i
s##thisType(toHTMLElement(node)) : false; } \ | 62 inline bool is##thisType(const Node& node) { return node.isHTMLElement() ? i
s##thisType(toHTMLElement(node)) : false; } \ |
| 95 inline bool is##thisType(const Node* node) { return node && is##thisType(*no
de); } \ | 63 inline bool is##thisType(const Node* node) { return node && is##thisType(*no
de); } \ |
| 96 inline bool is##thisType(const Element* element) { return element && is##thi
sType(*element); } \ | 64 inline bool is##thisType(const Element* element) { return element && is##thi
sType(*element); } \ |
| 97 template<typename T> inline bool is##thisType(const PassRefPtr<T>& node) { r
eturn is##thisType(node.get()); } \ | 65 template<typename T> inline bool is##thisType(const PassRefPtr<T>& node) { r
eturn is##thisType(node.get()); } \ |
| 98 template<typename T> inline bool is##thisType(const RefPtr<T>& node) { retur
n is##thisType(node.get()); } \ | 66 template<typename T> inline bool is##thisType(const RefPtr<T>& node) { retur
n is##thisType(node.get()); } \ |
| 99 template <> inline bool isElementOfType<const thisType>(const HTMLElement& e
lement) { return is##thisType(element); } \ | 67 template <> inline bool isElementOfType<const thisType>(const HTMLElement& e
lement) { return is##thisType(element); } \ |
| 100 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) | 68 DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) |
| 101 | 69 |
| 102 } // namespace blink | 70 } // namespace blink |
| 103 | 71 |
| 104 #include "gen/sky/core/HTMLElementTypeHelpers.h" | 72 #include "gen/sky/core/HTMLElementTypeHelpers.h" |
| 105 | 73 |
| 106 #endif // SKY_ENGINE_CORE_HTML_HTMLELEMENT_H_ | 74 #endif // SKY_ENGINE_CORE_HTML_HTMLELEMENT_H_ |
| OLD | NEW |