| 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 enum SelectionOption { | 45 enum SelectionOption { |
| 46 ChangeSelection, | 46 ChangeSelection, |
| 47 NotChangeSelection | 47 NotChangeSelection |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 virtual ~HTMLTextFormControlElement(); | 50 virtual ~HTMLTextFormControlElement(); |
| 51 | 51 |
| 52 void forwardEvent(Event*); | 52 void forwardEvent(Event*); |
| 53 | 53 |
| 54 | 54 |
| 55 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; | 55 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; |
| 56 | 56 |
| 57 // The derived class should return true if placeholder processing is needed. | 57 // The derived class should return true if placeholder processing is needed. |
| 58 virtual bool supportsPlaceholder() const = 0; | 58 virtual bool supportsPlaceholder() const = 0; |
| 59 String strippedPlaceholder() const; | 59 String strippedPlaceholder() const; |
| 60 bool placeholderShouldBeVisible() const; | 60 bool placeholderShouldBeVisible() const; |
| 61 HTMLElement* placeholderElement() const; | 61 HTMLElement* placeholderElement() const; |
| 62 void updatePlaceholderVisibility(bool); | 62 void updatePlaceholderVisibility(bool); |
| 63 | 63 |
| 64 VisiblePosition visiblePositionForIndex(int) const; | 64 VisiblePosition visiblePositionForIndex(int) const; |
| 65 int indexForVisiblePosition(const VisiblePosition&) const; | 65 int indexForVisiblePosition(const VisiblePosition&) const; |
| 66 int selectionStart() const; | 66 int selectionStart() const; |
| 67 int selectionEnd() const; | 67 int selectionEnd() const; |
| 68 const AtomicString& selectionDirection() const; | 68 const AtomicString& selectionDirection() const; |
| 69 void setSelectionStart(int); | 69 void setSelectionStart(int); |
| 70 void setSelectionEnd(int); | 70 void setSelectionEnd(int); |
| 71 void setSelectionDirection(const String&); | 71 void setSelectionDirection(const String&); |
| 72 void select(); | 72 void select(); |
| 73 virtual void setRangeText(const String& replacement, ExceptionState&); | 73 virtual void setRangeText(const String& replacement, ExceptionState&); |
| 74 virtual void setRangeText(const String& replacement, unsigned start, unsigne
d end, const String& selectionMode, ExceptionState&); | 74 virtual void setRangeText(const String& replacement, unsigned start, unsigne
d end, const String& selectionMode, ExceptionState&); |
| 75 void setSelectionRange(int start, int end, const String& direction); | 75 void setSelectionRange(int start, int end, const String& direction); |
| 76 void setSelectionRange(int start, int end, TextFieldSelectionDirection = Sel
ectionHasNoDirection, SelectionOption = ChangeSelection); | 76 void setSelectionRange(int start, int end, TextFieldSelectionDirection = Sel
ectionHasNoDirection, SelectionOption = ChangeSelection); |
| 77 PassRefPtrWillBeRawPtr<Range> selection() const; | 77 PassRefPtrWillBeRawPtr<Range> selection() const; |
| 78 | 78 |
| 79 virtual void dispatchFormControlChangeEvent() OVERRIDE FINAL; | 79 virtual void dispatchFormControlChangeEvent() override final; |
| 80 | 80 |
| 81 virtual String value() const = 0; | 81 virtual String value() const = 0; |
| 82 | 82 |
| 83 HTMLElement* innerEditorElement() const; | 83 HTMLElement* innerEditorElement() const; |
| 84 | 84 |
| 85 void selectionChanged(bool userTriggered); | 85 void selectionChanged(bool userTriggered); |
| 86 bool lastChangeWasUserEdit() const; | 86 bool lastChangeWasUserEdit() const; |
| 87 virtual void setInnerEditorValue(const String&); | 87 virtual void setInnerEditorValue(const String&); |
| 88 String innerEditorValue() const; | 88 String innerEditorValue() const; |
| 89 | 89 |
| 90 String directionForFormData() const; | 90 String directionForFormData() const; |
| 91 | 91 |
| 92 void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfL
astFormControlChangeEvent = text; } | 92 void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfL
astFormControlChangeEvent = text; } |
| 93 | 93 |
| 94 // These functions don't cause synchronous layout and SpellChecker uses | 94 // These functions don't cause synchronous layout and SpellChecker uses |
| 95 // them to improve performance. | 95 // them to improve performance. |
| 96 // Passed |Position| must point inside of a text form control. | 96 // Passed |Position| must point inside of a text form control. |
| 97 static Position startOfWord(const Position&); | 97 static Position startOfWord(const Position&); |
| 98 static Position endOfWord(const Position&); | 98 static Position endOfWord(const Position&); |
| 99 static Position startOfSentence(const Position&); | 99 static Position startOfSentence(const Position&); |
| 100 static Position endOfSentence(const Position&); | 100 static Position endOfSentence(const Position&); |
| 101 | 101 |
| 102 protected: | 102 protected: |
| 103 HTMLTextFormControlElement(const QualifiedName&, Document&, HTMLFormElement*
); | 103 HTMLTextFormControlElement(const QualifiedName&, Document&, HTMLFormElement*
); |
| 104 bool isPlaceholderEmpty() const; | 104 bool isPlaceholderEmpty() const; |
| 105 virtual void updatePlaceholderText() = 0; | 105 virtual void updatePlaceholderText() = 0; |
| 106 | 106 |
| 107 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; | 107 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr
ide; |
| 108 | 108 |
| 109 void cacheSelection(int start, int end, TextFieldSelectionDirection directio
n) | 109 void cacheSelection(int start, int end, TextFieldSelectionDirection directio
n) |
| 110 { | 110 { |
| 111 ASSERT(start >= 0); | 111 ASSERT(start >= 0); |
| 112 m_cachedSelectionStart = start; | 112 m_cachedSelectionStart = start; |
| 113 m_cachedSelectionEnd = end; | 113 m_cachedSelectionEnd = end; |
| 114 m_cachedSelectionDirection = direction; | 114 m_cachedSelectionDirection = direction; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void restoreCachedSelection(); | 117 void restoreCachedSelection(); |
| 118 | 118 |
| 119 virtual void defaultEventHandler(Event*) OVERRIDE; | 119 virtual void defaultEventHandler(Event*) override; |
| 120 virtual void subtreeHasChanged() = 0; | 120 virtual void subtreeHasChanged() = 0; |
| 121 | 121 |
| 122 void setLastChangeWasNotUserEdit() { m_lastChangeWasUserEdit = false; } | 122 void setLastChangeWasNotUserEdit() { m_lastChangeWasUserEdit = false; } |
| 123 | 123 |
| 124 String valueWithHardLineBreaks() const; | 124 String valueWithHardLineBreaks() const; |
| 125 | 125 |
| 126 virtual bool shouldDispatchFormControlChangeEvent(String&, String&); | 126 virtual bool shouldDispatchFormControlChangeEvent(String&, String&); |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 int computeSelectionStart() const; | 129 int computeSelectionStart() const; |
| 130 int computeSelectionEnd() const; | 130 int computeSelectionEnd() const; |
| 131 TextFieldSelectionDirection computeSelectionDirection() const; | 131 TextFieldSelectionDirection computeSelectionDirection() const; |
| 132 | 132 |
| 133 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) OVERR
IDE FINAL; | 133 virtual void dispatchFocusEvent(Element* oldFocusedElement, FocusType) overr
ide final; |
| 134 virtual void dispatchBlurEvent(Element* newFocusedElement) OVERRIDE FINAL; | 134 virtual void dispatchBlurEvent(Element* newFocusedElement) override final; |
| 135 | 135 |
| 136 // Returns true if user-editable value is empty. Used to check placeholder v
isibility. | 136 // Returns true if user-editable value is empty. Used to check placeholder v
isibility. |
| 137 virtual bool isEmptyValue() const = 0; | 137 virtual bool isEmptyValue() const = 0; |
| 138 // Returns true if suggested value is empty. Used to check placeholder visib
ility. | 138 // Returns true if suggested value is empty. Used to check placeholder visib
ility. |
| 139 virtual bool isEmptySuggestedValue() const { return true; } | 139 virtual bool isEmptySuggestedValue() const { return true; } |
| 140 // Called in dispatchFocusEvent(), after placeholder process, before calling
parent's dispatchFocusEvent(). | 140 // Called in dispatchFocusEvent(), after placeholder process, before calling
parent's dispatchFocusEvent(). |
| 141 virtual void handleFocusEvent(Element* /* oldFocusedNode */, FocusType) { } | 141 virtual void handleFocusEvent(Element* /* oldFocusedNode */, FocusType) { } |
| 142 // Called in dispatchBlurEvent(), after placeholder process, before calling
parent's dispatchBlurEvent(). | 142 // Called in dispatchBlurEvent(), after placeholder process, before calling
parent's dispatchBlurEvent(). |
| 143 virtual void handleBlurEvent() { } | 143 virtual void handleBlurEvent() { } |
| 144 | 144 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 156 } | 156 } |
| 157 | 157 |
| 158 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); | 158 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); |
| 159 | 159 |
| 160 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); | 160 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); |
| 161 HTMLTextFormControlElement* enclosingTextFormControl(Node*); | 161 HTMLTextFormControlElement* enclosingTextFormControl(Node*); |
| 162 | 162 |
| 163 } // namespace | 163 } // namespace |
| 164 | 164 |
| 165 #endif | 165 #endif |
| OLD | NEW |