| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 unsigned selectionStart() const; |
| 72 int selectionEnd() const; | 72 unsigned 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(unsigned start, unsigned end, const String& direction
); |
| 81 void setSelectionRange(int start, int end, TextFieldSelectionDirection = Sel
ectionHasNoDirection, NeedToDispatchSelectEvent = DispatchSelectEvent, Selection
Option = ChangeSelection); | 81 void setSelectionRange(unsigned start, unsigned end, TextFieldSelectionDirec
tion = SelectionHasNoDirection, NeedToDispatchSelectEvent = DispatchSelectEvent,
SelectionOption = 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 void dispatchFormControlChangeEvent() final; | 89 void dispatchFormControlChangeEvent() final; |
| 90 | 90 |
| 91 virtual String value() const = 0; | 91 virtual String value() const = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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 void parseAttribute(const QualifiedName&, const AtomicString&) override; | 117 void parseAttribute(const QualifiedName&, const AtomicString&) override; |
| 118 | 118 |
| 119 void cacheSelection(int start, int end, TextFieldSelectionDirection directio
n) | 119 void cacheSelection(unsigned start, unsigned end, TextFieldSelectionDirectio
n direction) |
| 120 { | 120 { |
| 121 ASSERT(start >= 0); | |
| 122 m_cachedSelectionStart = start; | 121 m_cachedSelectionStart = start; |
| 123 m_cachedSelectionEnd = end; | 122 m_cachedSelectionEnd = end; |
| 124 m_cachedSelectionDirection = direction; | 123 m_cachedSelectionDirection = direction; |
| 125 } | 124 } |
| 126 | 125 |
| 127 void restoreCachedSelection(); | 126 void restoreCachedSelection(); |
| 128 | 127 |
| 129 void defaultEventHandler(Event*) override; | 128 void defaultEventHandler(Event*) override; |
| 130 virtual void subtreeHasChanged() = 0; | 129 virtual void subtreeHasChanged() = 0; |
| 131 | 130 |
| 132 void setLastChangeWasNotUserEdit() { m_lastChangeWasUserEdit = false; } | 131 void setLastChangeWasNotUserEdit() { m_lastChangeWasUserEdit = false; } |
| 133 | 132 |
| 134 String valueWithHardLineBreaks() const; | 133 String valueWithHardLineBreaks() const; |
| 135 | 134 |
| 136 virtual bool shouldDispatchFormControlChangeEvent(String&, String&); | 135 virtual bool shouldDispatchFormControlChangeEvent(String&, String&); |
| 137 void copyNonAttributePropertiesFromElement(const Element&) override; | 136 void copyNonAttributePropertiesFromElement(const Element&) override; |
| 138 | 137 |
| 139 private: | 138 private: |
| 140 int computeSelectionStart() const; | 139 unsigned computeSelectionStart() const; |
| 141 int computeSelectionEnd() const; | 140 unsigned computeSelectionEnd() const; |
| 142 TextFieldSelectionDirection computeSelectionDirection() const; | 141 TextFieldSelectionDirection computeSelectionDirection() const; |
| 143 | 142 |
| 144 void dispatchFocusEvent(Element* oldFocusedElement, WebFocusType, InputDevic
e* sourceDevice) final; | 143 void dispatchFocusEvent(Element* oldFocusedElement, WebFocusType, InputDevic
e* sourceDevice) final; |
| 145 void dispatchBlurEvent(Element* newFocusedElement, WebFocusType, InputDevice
* sourceDevice) final; | 144 void dispatchBlurEvent(Element* newFocusedElement, WebFocusType, InputDevice
* sourceDevice) final; |
| 146 void scheduleSelectEvent(); | 145 void scheduleSelectEvent(); |
| 147 | 146 |
| 148 // Returns true if user-editable value is empty. Used to check placeholder v
isibility. | 147 // Returns true if user-editable value is empty. Used to check placeholder v
isibility. |
| 149 virtual bool isEmptyValue() const = 0; | 148 virtual bool isEmptyValue() const = 0; |
| 150 // Returns true if suggested value is empty. Used to check placeholder visib
ility. | 149 // Returns true if suggested value is empty. Used to check placeholder visib
ility. |
| 151 virtual bool isEmptySuggestedValue() const { return true; } | 150 virtual bool isEmptySuggestedValue() const { return true; } |
| 152 // Called in dispatchFocusEvent(), after placeholder process, before calling
parent's dispatchFocusEvent(). | 151 // Called in dispatchFocusEvent(), after placeholder process, before calling
parent's dispatchFocusEvent(). |
| 153 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) {
} | 152 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) {
} |
| 154 // Called in dispatchBlurEvent(), after placeholder process, before calling
parent's dispatchBlurEvent(). | 153 // Called in dispatchBlurEvent(), after placeholder process, before calling
parent's dispatchBlurEvent(). |
| 155 virtual void handleBlurEvent() { } | 154 virtual void handleBlurEvent() { } |
| 156 | 155 |
| 157 String m_textAsOfLastFormControlChangeEvent; | 156 String m_textAsOfLastFormControlChangeEvent; |
| 158 bool m_lastChangeWasUserEdit; | 157 bool m_lastChangeWasUserEdit; |
| 159 | 158 |
| 160 int m_cachedSelectionStart; | 159 unsigned m_cachedSelectionStart; |
| 161 int m_cachedSelectionEnd; | 160 unsigned m_cachedSelectionEnd; |
| 162 TextFieldSelectionDirection m_cachedSelectionDirection; | 161 TextFieldSelectionDirection m_cachedSelectionDirection; |
| 163 }; | 162 }; |
| 164 | 163 |
| 165 inline bool isHTMLTextFormControlElement(const Element& element) | 164 inline bool isHTMLTextFormControlElement(const Element& element) |
| 166 { | 165 { |
| 167 return element.isTextFormControl(); | 166 return element.isTextFormControl(); |
| 168 } | 167 } |
| 169 | 168 |
| 170 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); | 169 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); |
| 171 | 170 |
| 172 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); | 171 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); |
| 173 HTMLTextFormControlElement* enclosingTextFormControl(Node*); | 172 HTMLTextFormControlElement* enclosingTextFormControl(Node*); |
| 174 | 173 |
| 175 } // namespace | 174 } // namespace |
| 176 | 175 |
| 177 #endif | 176 #endif |
| OLD | NEW |