summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLElement.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/HTMLElement.h')
-rw-r--r--Source/WebCore/html/HTMLElement.h135
1 files changed, 72 insertions, 63 deletions
diff --git a/Source/WebCore/html/HTMLElement.h b/Source/WebCore/html/HTMLElement.h
index 0080677d4..3bada1bf3 100644
--- a/Source/WebCore/html/HTMLElement.h
+++ b/Source/WebCore/html/HTMLElement.h
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -20,8 +20,11 @@
*
*/
-#ifndef HTMLElement_h
-#define HTMLElement_h
+#pragma once
+
+#if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
+#include "Autocapitalize.h"
+#endif
#include "StyledElement.h"
@@ -32,59 +35,45 @@ class FormNamedItem;
class HTMLCollection;
class HTMLFormElement;
-enum TranslateAttributeMode {
- TranslateAttributeYes,
- TranslateAttributeNo,
- TranslateAttributeInherit
-};
-
class HTMLElement : public StyledElement {
public:
- static PassRefPtr<HTMLElement> create(const QualifiedName& tagName, Document&);
-
- PassRefPtr<HTMLCollection> children();
-
- virtual String title() const override final;
+ static Ref<HTMLElement> create(const QualifiedName& tagName, Document&);
- virtual short tabIndex() const override;
- void setTabIndex(int);
+ WEBCORE_EXPORT String title() const final;
- String innerHTML() const;
- String outerHTML() const;
- void setInnerHTML(const String&, ExceptionCode&);
- void setOuterHTML(const String&, ExceptionCode&);
- void setInnerText(const String&, ExceptionCode&);
- void setOuterText(const String&, ExceptionCode&);
+ int tabIndex() const override;
- Element* insertAdjacentElement(const String& where, Element* newChild, ExceptionCode&);
- void insertAdjacentHTML(const String& where, const String& html, ExceptionCode&);
- void insertAdjacentText(const String& where, const String& text, ExceptionCode&);
+ WEBCORE_EXPORT ExceptionOr<void> setInnerText(const String&);
+ WEBCORE_EXPORT ExceptionOr<void> setOuterText(const String&);
virtual bool hasCustomFocusLogic() const;
- virtual bool supportsFocus() const override;
+ bool supportsFocus() const override;
- String contentEditable() const;
- void setContentEditable(const String&, ExceptionCode&);
+ WEBCORE_EXPORT String contentEditable() const;
+ WEBCORE_EXPORT ExceptionOr<void> setContentEditable(const String&);
+
+ static Editability editabilityFromContentEditableAttr(const Node&);
virtual bool draggable() const;
- void setDraggable(bool);
+ WEBCORE_EXPORT void setDraggable(bool);
- bool spellcheck() const;
- void setSpellcheck(bool);
+ WEBCORE_EXPORT bool spellcheck() const;
+ WEBCORE_EXPORT void setSpellcheck(bool);
- bool translate() const;
- void setTranslate(bool);
+ WEBCORE_EXPORT bool translate() const;
+ WEBCORE_EXPORT void setTranslate(bool);
- void click();
+ WEBCORE_EXPORT void click();
- virtual void accessKeyAction(bool sendMouseEvents) override;
+ void accessKeyAction(bool sendMouseEvents) override;
- bool ieForbidsInsertHTML() const;
+ bool rendererIsNeeded(const RenderStyle&) override;
+ RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
- virtual bool rendererIsNeeded(const RenderStyle&) override;
- virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
+ WEBCORE_EXPORT virtual HTMLFormElement* form() const;
- HTMLFormElement* form() const { return virtualForm(); }
+ WEBCORE_EXPORT const AtomicString& dir() const;
+ WEBCORE_EXPORT void setDir(const AtomicString&);
bool hasDirectionAuto() const;
TextDirection directionalityIfhasDirAutoAttribute(bool& isAuto) const;
@@ -92,13 +81,31 @@ public:
virtual bool isHTMLUnknownElement() const { return false; }
virtual bool isTextControlInnerTextElement() const { return false; }
- virtual bool willRespondToMouseMoveEvents() override;
- virtual bool willRespondToMouseWheelEvents() override;
- virtual bool willRespondToMouseClickEvents() override;
+ bool willRespondToMouseMoveEvents() override;
+ bool willRespondToMouseWheelEvents() override;
+ bool willRespondToMouseClickEvents() override;
virtual bool isLabelable() const { return false; }
virtual FormNamedItem* asFormNamedItem() { return 0; }
+ bool hasTagName(const HTMLQualifiedName& name) const { return hasLocalName(name.localName()); }
+
+ static const AtomicString& eventNameForEventHandlerAttribute(const QualifiedName& attributeName);
+
+ // Only some element types can be disabled: https://html.spec.whatwg.org/multipage/scripting.html#concept-element-disabled
+ bool canBeActuallyDisabled() const;
+ bool isActuallyDisabled() const;
+
+#if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
+ WEBCORE_EXPORT virtual AutocapitalizeType autocapitalizeType() const;
+ WEBCORE_EXPORT const AtomicString& autocapitalize() const;
+ WEBCORE_EXPORT void setAutocapitalize(const AtomicString& value);
+
+ bool autocorrect() const { return shouldAutocorrect(); }
+ WEBCORE_EXPORT virtual bool shouldAutocorrect() const;
+ WEBCORE_EXPORT void setAutocorrect(bool);
+#endif
+
protected:
HTMLElement(const QualifiedName& tagName, Document&, ConstructionType);
@@ -108,32 +115,31 @@ protected:
void applyAlignmentAttributeToStyle(const AtomicString&, MutableStyleProperties&);
void applyBorderAttributeToStyle(const AtomicString&, MutableStyleProperties&);
- virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
- virtual bool isPresentationAttribute(const QualifiedName&) const override;
- virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;
+ bool matchesReadWritePseudoClass() const override;
+ void parseAttribute(const QualifiedName&, const AtomicString&) override;
+ bool isPresentationAttribute(const QualifiedName&) const override;
+ void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;
unsigned parseBorderWidthAttribute(const AtomicString&) const;
- virtual void childrenChanged(const ChildChange&) override;
+ void childrenChanged(const ChildChange&) override;
void calculateAndAdjustDirectionality();
- virtual bool isURLAttribute(const Attribute&) const override;
+ typedef HashMap<AtomicStringImpl*, AtomicString> EventHandlerNameMap;
+ template<size_t tableSize> static void populateEventHandlerNameMap(EventHandlerNameMap&, const QualifiedName* const (&table)[tableSize]);
+ static const AtomicString& eventNameForEventHandlerAttribute(const QualifiedName& attributeName, const EventHandlerNameMap&);
private:
- virtual String nodeName() const override final;
+ String nodeName() const final;
void mapLanguageAttributeToLocale(const AtomicString&, MutableStyleProperties&);
- virtual HTMLFormElement* virtualForm() const;
-
- Node* insertAdjacent(const String& where, Node* newChild, ExceptionCode&);
- PassRefPtr<DocumentFragment> textToFragment(const String&, ExceptionCode&);
-
void dirAttributeChanged(const AtomicString&);
void adjustDirectionalityIfNeededAfterChildAttributeChanged(Element* child);
void adjustDirectionalityIfNeededAfterChildrenChanged(Element* beforeChange, ChildChangeType);
TextDirection directionality(Node** strongDirectionalityTextNode= 0) const;
- TranslateAttributeMode translateAttributeMode() const;
+ static void populateEventHandlerNameMap(EventHandlerNameMap&, const QualifiedName* const table[], size_t tableSize);
+ static EventHandlerNameMap createEventHandlerNameMap();
};
inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document& document, ConstructionType type = CreateHTMLElement)
@@ -142,17 +148,20 @@ inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document& document
ASSERT(tagName.localName().impl());
}
-template <typename Type> bool isElementOfType(const HTMLElement&);
-
-void isHTMLElement(const HTMLElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLElement(const Node& node) { return node.isHTMLElement(); }
-template <> inline bool isElementOfType<const HTMLElement>(const HTMLElement&) { return true; }
-template <> inline bool isElementOfType<const HTMLElement>(const Element& element) { return element.isHTMLElement(); }
+template<size_t tableSize> inline void HTMLElement::populateEventHandlerNameMap(EventHandlerNameMap& map, const QualifiedName* const (&table)[tableSize])
+{
+ populateEventHandlerNameMap(map, table, tableSize);
+}
-NODE_TYPE_CASTS(HTMLElement)
+inline bool Node::hasTagName(const HTMLQualifiedName& name) const
+{
+ return is<HTMLElement>(*this) && downcast<HTMLElement>(*this).hasTagName(name);
+}
} // namespace WebCore
-#include "HTMLElementTypeHelpers.h"
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLElement)
+ static bool isType(const WebCore::Node& node) { return node.isHTMLElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
-#endif // HTMLElement_h
+#include "HTMLElementTypeHelpers.h"