summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLTextFormControlElement.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLTextFormControlElement.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/html/HTMLTextFormControlElement.h')
-rw-r--r--Source/WebCore/html/HTMLTextFormControlElement.h111
1 files changed, 66 insertions, 45 deletions
diff --git a/Source/WebCore/html/HTMLTextFormControlElement.h b/Source/WebCore/html/HTMLTextFormControlElement.h
index 976670ad5..128b0318b 100644
--- a/Source/WebCore/html/HTMLTextFormControlElement.h
+++ b/Source/WebCore/html/HTMLTextFormControlElement.h
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
* Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -22,8 +22,7 @@
*
*/
-#ifndef HTMLTextFormControlElement_h
-#define HTMLTextFormControlElement_h
+#pragma once
#include "HTMLFormControlElementWithState.h"
@@ -34,52 +33,59 @@ class RenderTextControl;
class TextControlInnerTextElement;
class VisiblePosition;
+enum class AutoFillButtonType : uint8_t { None, Credentials, Contacts };
enum TextFieldSelectionDirection { SelectionHasNoDirection, SelectionHasForwardDirection, SelectionHasBackwardDirection };
enum TextFieldEventBehavior { DispatchNoEvent, DispatchChangeEvent, DispatchInputAndChangeEvent };
class HTMLTextFormControlElement : public HTMLFormControlElementWithState {
public:
- // Common flag for HTMLInputElement::tooLong() and HTMLTextAreaElement::tooLong().
+ // Common flag for HTMLInputElement::tooLong() / tooShort() and HTMLTextAreaElement::tooLong() / tooShort().
enum NeedsToCheckDirtyFlag {CheckDirtyFlag, IgnoreDirtyFlag};
virtual ~HTMLTextFormControlElement();
- void forwardEvent(Event*);
+ void didEditInnerTextValue();
+ void forwardEvent(Event&);
- virtual InsertionNotificationRequest insertedInto(ContainerNode&) override;
+ int maxLength() const { return m_maxLength; }
+ WEBCORE_EXPORT ExceptionOr<void> setMaxLength(int);
+ int minLength() const { return m_minLength; }
+ ExceptionOr<void> setMinLength(int);
+
+ InsertionNotificationRequest insertedInto(ContainerNode&) override;
// The derived class should return true if placeholder processing is needed.
+ bool isPlaceholderVisible() const { return m_isPlaceholderVisible; }
virtual bool supportsPlaceholder() const = 0;
String strippedPlaceholder() const;
- bool placeholderShouldBeVisible() const;
virtual HTMLElement* placeholderElement() const = 0;
- void updatePlaceholderVisibility(bool);
+ void updatePlaceholderVisibility();
int indexForVisiblePosition(const VisiblePosition&) const;
- VisiblePosition visiblePositionForIndex(int index) const;
- int selectionStart() const;
- int selectionEnd() const;
- const AtomicString& selectionDirection() const;
- void setSelectionStart(int);
- void setSelectionEnd(int);
- void setSelectionDirection(const String&);
- void select();
- virtual void setRangeText(const String& replacement, ExceptionCode&);
- virtual void setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode, ExceptionCode&);
- void setSelectionRange(int start, int end, const String& direction);
- void setSelectionRange(int start, int end, TextFieldSelectionDirection = SelectionHasNoDirection);
- PassRefPtr<Range> selection() const;
+ WEBCORE_EXPORT VisiblePosition visiblePositionForIndex(int index) const;
+ WEBCORE_EXPORT int selectionStart() const;
+ WEBCORE_EXPORT int selectionEnd() const;
+ WEBCORE_EXPORT const AtomicString& selectionDirection() const;
+ WEBCORE_EXPORT void setSelectionStart(int);
+ WEBCORE_EXPORT void setSelectionEnd(int);
+ WEBCORE_EXPORT void setSelectionDirection(const String&);
+ WEBCORE_EXPORT void select(const AXTextStateChangeIntent& = AXTextStateChangeIntent());
+ WEBCORE_EXPORT virtual ExceptionOr<void> setRangeText(const String& replacement);
+ WEBCORE_EXPORT virtual ExceptionOr<void> setRangeText(const String& replacement, unsigned start, unsigned end, const String& selectionMode);
+ void setSelectionRange(int start, int end, const String& direction, const AXTextStateChangeIntent& = AXTextStateChangeIntent());
+ WEBCORE_EXPORT void setSelectionRange(int start, int end, TextFieldSelectionDirection = SelectionHasNoDirection, const AXTextStateChangeIntent& = AXTextStateChangeIntent());
+ RefPtr<Range> selection() const;
String selectedText() const;
- virtual void dispatchFormControlChangeEvent() override final;
+ void dispatchFormControlChangeEvent() final;
- virtual int maxLength() const = 0;
virtual String value() const = 0;
virtual TextControlInnerTextElement* innerTextElement() const = 0;
+ virtual RenderStyle createInnerTextStyle(const RenderStyle&) const = 0;
- void selectionChanged(bool userTriggered);
- bool lastChangeWasUserEdit() const;
+ void selectionChanged(bool shouldFireSelectEvent);
+ WEBCORE_EXPORT bool lastChangeWasUserEdit() const;
void setInnerTextValue(const String&);
String innerTextValue() const;
@@ -87,8 +93,8 @@ public:
void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfLastFormControlChangeEvent = text; }
#if PLATFORM(IOS)
- void hidePlaceholder();
- void showPlaceholderIfNecessary();
+ WEBCORE_EXPORT void hidePlaceholder();
+ WEBCORE_EXPORT void showPlaceholderIfNecessary();
#endif
protected:
@@ -96,7 +102,11 @@ protected:
bool isPlaceholderEmpty() const;
virtual void updatePlaceholderText() = 0;
- virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
+ void parseAttribute(const QualifiedName&, const AtomicString&) override;
+
+ void disabledStateChanged() override;
+ void readOnlyAttributeChanged() override;
+ void updateInnerTextElementEditability();
void cacheSelection(int start, int end, TextFieldSelectionDirection direction)
{
@@ -105,49 +115,60 @@ protected:
m_cachedSelectionDirection = direction;
}
- void restoreCachedSelection();
+ void restoreCachedSelection(const AXTextStateChangeIntent& = AXTextStateChangeIntent());
bool hasCachedSelection() const { return m_cachedSelectionStart >= 0; }
- virtual void defaultEventHandler(Event*) override;
virtual void subtreeHasChanged() = 0;
void setLastChangeWasNotUserEdit() { m_lastChangeWasUserEdit = false; }
String valueWithHardLineBreaks() const;
+ void adjustInnerTextStyle(const RenderStyle& parentStyle, RenderStyle& textBlockStyle) const;
+
+ void internalSetMaxLength(int maxLength) { m_maxLength = maxLength; }
+ void internalSetMinLength(int minLength) { m_minLength = minLength; }
+
private:
+ TextFieldSelectionDirection cachedSelectionDirection() const { return static_cast<TextFieldSelectionDirection>(m_cachedSelectionDirection); }
+
int computeSelectionStart() const;
int computeSelectionEnd() const;
TextFieldSelectionDirection computeSelectionDirection() const;
- virtual void dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection) override final;
- virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) override final;
- virtual bool childShouldCreateRenderer(const Node&) const override;
+ void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection) final;
+ void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) final;
+ bool childShouldCreateRenderer(const Node&) const override;
+
+ unsigned indexForPosition(const Position&) const;
// Returns true if user-editable value is empty. Used to check placeholder visibility.
virtual bool isEmptyValue() const = 0;
- // Returns true if suggested value is empty. Used to check placeholder visibility.
- virtual bool isEmptySuggestedValue() const { return true; }
// Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent().
virtual void handleFocusEvent(Node* /* oldFocusedNode */, FocusDirection) { }
// Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent().
virtual void handleBlurEvent() { }
+ bool placeholderShouldBeVisible() const;
+
+ unsigned m_cachedSelectionDirection : 2;
+ unsigned m_lastChangeWasUserEdit : 1;
+ unsigned m_isPlaceholderVisible : 1;
+
String m_textAsOfLastFormControlChangeEvent;
- bool m_lastChangeWasUserEdit;
-
+
int m_cachedSelectionStart;
int m_cachedSelectionEnd;
- TextFieldSelectionDirection m_cachedSelectionDirection;
-};
-void isHTMLTextFormControlElement(const HTMLTextFormControlElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isHTMLTextFormControlElement(const Element& element) { return element.isTextFormControl(); }
-inline bool isHTMLTextFormControlElement(const Node& node) { return node.isElementNode() && toElement(node).isTextFormControl(); }
-NODE_TYPE_CASTS(HTMLTextFormControlElement)
+ int m_maxLength { -1 };
+ int m_minLength { -1 };
+};
HTMLTextFormControlElement* enclosingTextFormControl(const Position&);
-} // namespace
+} // namespace WebCore
-#endif
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLTextFormControlElement)
+ static bool isType(const WebCore::Element& element) { return element.isTextFormControl(); }
+ static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()