From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/html/HTMLElement.h | 135 ++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 63 deletions(-) (limited to 'Source/WebCore/html/HTMLElement.h') 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 create(const QualifiedName& tagName, Document&); - - PassRefPtr children(); - - virtual String title() const override final; + static Ref 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 setInnerText(const String&); + WEBCORE_EXPORT ExceptionOr 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 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 createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; - virtual bool rendererIsNeeded(const RenderStyle&) override; - virtual RenderPtr createElementRenderer(PassRef) 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 EventHandlerNameMap; + template 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 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 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&) { return true; } -template <> inline bool isElementOfType(const Element& element) { return element.isHTMLElement(); } +template 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(*this) && downcast(*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" -- cgit v1.2.1