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 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
6 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 6 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // HTMLInputElement::tooShort() and HTMLTextAreaElement::tooShort(). | 45 // HTMLInputElement::tooShort() and HTMLTextAreaElement::tooShort(). |
46 enum NeedsToCheckDirtyFlag {CheckDirtyFlag, IgnoreDirtyFlag}; | 46 enum NeedsToCheckDirtyFlag {CheckDirtyFlag, IgnoreDirtyFlag}; |
47 // Option of setSelectionRange. | 47 // Option of setSelectionRange. |
48 enum SelectionOption { | 48 enum SelectionOption { |
49 ChangeSelection, | 49 ChangeSelection, |
50 ChangeSelectionAndFocus, | 50 ChangeSelectionAndFocus, |
51 ChangeSelectionIfFocused, | 51 ChangeSelectionIfFocused, |
52 NotChangeSelection | 52 NotChangeSelection |
53 }; | 53 }; |
54 | 54 |
55 virtual ~HTMLTextFormControlElement(); | 55 ~HTMLTextFormControlElement() override; |
56 | 56 |
57 void forwardEvent(Event*); | 57 void forwardEvent(Event*); |
58 | 58 |
59 | 59 |
60 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; | 60 InsertionNotificationRequest insertedInto(ContainerNode*) override; |
61 | 61 |
62 // The derived class should return true if placeholder processing is needed. | 62 // The derived class should return true if placeholder processing is needed. |
63 virtual bool supportsPlaceholder() const = 0; | 63 virtual bool supportsPlaceholder() const = 0; |
64 String strippedPlaceholder() const; | 64 String strippedPlaceholder() const; |
65 bool placeholderShouldBeVisible() const; | 65 bool placeholderShouldBeVisible() const; |
66 HTMLElement* placeholderElement() const; | 66 HTMLElement* placeholderElement() const; |
67 void updatePlaceholderVisibility(bool); | 67 void updatePlaceholderVisibility(bool); |
68 | 68 |
69 VisiblePosition visiblePositionForIndex(int) const; | 69 VisiblePosition visiblePositionForIndex(int) const; |
70 int indexForVisiblePosition(const VisiblePosition&) const; | 70 int indexForVisiblePosition(const VisiblePosition&) const; |
71 int selectionStart() const; | 71 int selectionStart() const; |
72 int selectionEnd() const; | 72 int selectionEnd() const; |
73 const AtomicString& selectionDirection() const; | 73 const AtomicString& selectionDirection() const; |
74 void setSelectionStart(int); | 74 void setSelectionStart(int); |
75 void setSelectionEnd(int); | 75 void setSelectionEnd(int); |
76 void setSelectionDirection(const String&); | 76 void setSelectionDirection(const String&); |
77 void select(NeedToDispatchSelectEvent = DispatchSelectEvent); | 77 void select(NeedToDispatchSelectEvent = DispatchSelectEvent); |
78 virtual void setRangeText(const String& replacement, ExceptionState&); | 78 virtual void setRangeText(const String& replacement, ExceptionState&); |
79 virtual void setRangeText(const String& replacement, unsigned start, unsigne
d end, const String& selectionMode, ExceptionState&); | 79 virtual void setRangeText(const String& replacement, unsigned start, unsigne
d end, const String& selectionMode, ExceptionState&); |
80 void setSelectionRange(int start, int end, const String& direction); | 80 void setSelectionRange(int start, int end, const String& direction); |
81 void setSelectionRange(int start, int end, TextFieldSelectionDirection = Sel
ectionHasNoDirection, NeedToDispatchSelectEvent = DispatchSelectEvent, Selection
Option = ChangeSelection); | 81 void setSelectionRange(int start, int end, TextFieldSelectionDirection = Sel
ectionHasNoDirection, NeedToDispatchSelectEvent = DispatchSelectEvent, Selection
Option = ChangeSelection); |
82 PassRefPtrWillBeRawPtr<Range> selection() const; | 82 PassRefPtrWillBeRawPtr<Range> selection() const; |
83 | 83 |
84 virtual bool supportsAutocapitalize() const = 0; | 84 virtual bool supportsAutocapitalize() const = 0; |
85 virtual const AtomicString& defaultAutocapitalize() const = 0; | 85 virtual const AtomicString& defaultAutocapitalize() const = 0; |
86 const AtomicString& autocapitalize() const; | 86 const AtomicString& autocapitalize() const; |
87 void setAutocapitalize(const AtomicString&); | 87 void setAutocapitalize(const AtomicString&); |
88 | 88 |
89 virtual void dispatchFormControlChangeEvent() override final; | 89 void dispatchFormControlChangeEvent() final; |
90 | 90 |
91 virtual String value() const = 0; | 91 virtual String value() const = 0; |
92 | 92 |
93 HTMLElement* innerEditorElement() const; | 93 HTMLElement* innerEditorElement() const; |
94 | 94 |
95 void selectionChanged(bool userTriggered); | 95 void selectionChanged(bool userTriggered); |
96 bool lastChangeWasUserEdit() const; | 96 bool lastChangeWasUserEdit() const; |
97 virtual void setInnerEditorValue(const String&); | 97 virtual void setInnerEditorValue(const String&); |
98 String innerEditorValue() const; | 98 String innerEditorValue() const; |
99 | 99 |
100 String directionForFormData() const; | 100 String directionForFormData() const; |
101 | 101 |
102 void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfL
astFormControlChangeEvent = text; } | 102 void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfL
astFormControlChangeEvent = text; } |
103 | 103 |
104 // These functions don't cause synchronous layout and SpellChecker uses | 104 // These functions don't cause synchronous layout and SpellChecker uses |
105 // them to improve performance. | 105 // them to improve performance. |
106 // Passed |Position| must point inside of a text form control. | 106 // Passed |Position| must point inside of a text form control. |
107 static Position startOfWord(const Position&); | 107 static Position startOfWord(const Position&); |
108 static Position endOfWord(const Position&); | 108 static Position endOfWord(const Position&); |
109 static Position startOfSentence(const Position&); | 109 static Position startOfSentence(const Position&); |
110 static Position endOfSentence(const Position&); | 110 static Position endOfSentence(const Position&); |
111 | 111 |
112 protected: | 112 protected: |
113 HTMLTextFormControlElement(const QualifiedName&, Document&, HTMLFormElement*
); | 113 HTMLTextFormControlElement(const QualifiedName&, Document&, HTMLFormElement*
); |
114 bool isPlaceholderEmpty() const; | 114 bool isPlaceholderEmpty() const; |
115 virtual void updatePlaceholderText() = 0; | 115 virtual void updatePlaceholderText() = 0; |
116 | 116 |
117 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr
ide; | 117 void parseAttribute(const QualifiedName&, const AtomicString&) override; |
118 | 118 |
119 void cacheSelection(int start, int end, TextFieldSelectionDirection directio
n) | 119 void cacheSelection(int start, int end, TextFieldSelectionDirection directio
n) |
120 { | 120 { |
121 ASSERT(start >= 0); | 121 ASSERT(start >= 0); |
122 m_cachedSelectionStart = start; | 122 m_cachedSelectionStart = start; |
123 m_cachedSelectionEnd = end; | 123 m_cachedSelectionEnd = end; |
124 m_cachedSelectionDirection = direction; | 124 m_cachedSelectionDirection = direction; |
125 } | 125 } |
126 | 126 |
127 void restoreCachedSelection(); | 127 void restoreCachedSelection(); |
128 | 128 |
129 virtual void defaultEventHandler(Event*) override; | 129 void defaultEventHandler(Event*) override; |
130 virtual void subtreeHasChanged() = 0; | 130 virtual void subtreeHasChanged() = 0; |
131 | 131 |
132 void setLastChangeWasNotUserEdit() { m_lastChangeWasUserEdit = false; } | 132 void setLastChangeWasNotUserEdit() { m_lastChangeWasUserEdit = false; } |
133 | 133 |
134 String valueWithHardLineBreaks() const; | 134 String valueWithHardLineBreaks() const; |
135 | 135 |
136 virtual bool shouldDispatchFormControlChangeEvent(String&, String&); | 136 virtual bool shouldDispatchFormControlChangeEvent(String&, String&); |
137 virtual void copyNonAttributePropertiesFromElement(const Element&) override; | 137 void copyNonAttributePropertiesFromElement(const Element&) override; |
138 | 138 |
139 private: | 139 private: |
140 int computeSelectionStart() const; | 140 int computeSelectionStart() const; |
141 int computeSelectionEnd() const; | 141 int computeSelectionEnd() const; |
142 TextFieldSelectionDirection computeSelectionDirection() const; | 142 TextFieldSelectionDirection computeSelectionDirection() const; |
143 | 143 |
144 virtual void dispatchFocusEvent(Element* oldFocusedElement, WebFocusType) ov
erride final; | 144 void dispatchFocusEvent(Element* oldFocusedElement, WebFocusType) final; |
145 virtual void dispatchBlurEvent(Element* newFocusedElement, WebFocusType) ove
rride final; | 145 void dispatchBlurEvent(Element* newFocusedElement, WebFocusType) final; |
146 void scheduleSelectEvent(); | 146 void scheduleSelectEvent(); |
147 | 147 |
148 // Returns true if user-editable value is empty. Used to check placeholder v
isibility. | 148 // Returns true if user-editable value is empty. Used to check placeholder v
isibility. |
149 virtual bool isEmptyValue() const = 0; | 149 virtual bool isEmptyValue() const = 0; |
150 // Returns true if suggested value is empty. Used to check placeholder visib
ility. | 150 // Returns true if suggested value is empty. Used to check placeholder visib
ility. |
151 virtual bool isEmptySuggestedValue() const { return true; } | 151 virtual bool isEmptySuggestedValue() const { return true; } |
152 // Called in dispatchFocusEvent(), after placeholder process, before calling
parent's dispatchFocusEvent(). | 152 // Called in dispatchFocusEvent(), after placeholder process, before calling
parent's dispatchFocusEvent(). |
153 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) {
} | 153 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) {
} |
154 // Called in dispatchBlurEvent(), after placeholder process, before calling
parent's dispatchBlurEvent(). | 154 // Called in dispatchBlurEvent(), after placeholder process, before calling
parent's dispatchBlurEvent(). |
155 virtual void handleBlurEvent() { } | 155 virtual void handleBlurEvent() { } |
(...skipping 12 matching lines...) Expand all Loading... |
168 } | 168 } |
169 | 169 |
170 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); | 170 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); |
171 | 171 |
172 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); | 172 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); |
173 HTMLTextFormControlElement* enclosingTextFormControl(Node*); | 173 HTMLTextFormControlElement* enclosingTextFormControl(Node*); |
174 | 174 |
175 } // namespace | 175 } // namespace |
176 | 176 |
177 #endif | 177 #endif |
OLD | NEW |