Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTextFormControlElement.h

Issue 2278373002: Fix selectionEnd value in a case of dragging out from an INPUT element. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 * 22 *
23 */ 23 */
24 24
25 #ifndef HTMLTextFormControlElement_h 25 #ifndef HTMLTextFormControlElement_h
26 #define HTMLTextFormControlElement_h 26 #define HTMLTextFormControlElement_h
27 27
28 #include "base/gtest_prod_util.h"
28 #include "core/CoreExport.h" 29 #include "core/CoreExport.h"
29 #include "core/editing/VisiblePosition.h" 30 #include "core/editing/VisiblePosition.h"
30 #include "core/html/HTMLFormControlElementWithState.h" 31 #include "core/html/HTMLFormControlElementWithState.h"
31 32
32 namespace blink { 33 namespace blink {
33 34
34 class ExceptionState; 35 class ExceptionState;
35 class Range; 36 class Range;
36 37
37 enum TextFieldSelectionDirection { SelectionHasNoDirection, SelectionHasForwardD irection, SelectionHasBackwardDirection }; 38 enum TextFieldSelectionDirection { SelectionHasNoDirection, SelectionHasForwardD irection, SelectionHasBackwardDirection };
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 virtual bool shouldDispatchFormControlChangeEvent(String&, String&); 128 virtual bool shouldDispatchFormControlChangeEvent(String&, String&);
128 void copyNonAttributePropertiesFromElement(const Element&) override; 129 void copyNonAttributePropertiesFromElement(const Element&) override;
129 130
130 private: 131 private:
131 int computeSelectionStart() const; 132 int computeSelectionStart() const;
132 int computeSelectionEnd() const; 133 int computeSelectionEnd() const;
133 TextFieldSelectionDirection computeSelectionDirection() const; 134 TextFieldSelectionDirection computeSelectionDirection() const;
134 void cacheSelection(int start, int end, TextFieldSelectionDirection directio n) 135 void cacheSelection(int start, int end, TextFieldSelectionDirection directio n)
135 { 136 {
136 DCHECK_GE(start, 0); 137 DCHECK_GE(start, 0);
137 // TODO(tkent): Add DCHECK_LE(start, end). It breaks 138 DCHECK_LE(start, end);
138 // editing/selection/select-across-readonly-input-{1,4}.html
139 m_cachedSelectionStart = start; 139 m_cachedSelectionStart = start;
140 m_cachedSelectionEnd = end; 140 m_cachedSelectionEnd = end;
141 m_cachedSelectionDirection = direction; 141 m_cachedSelectionDirection = direction;
142 } 142 }
143 static int indexForPosition(HTMLElement* innerEditor, const Position&);
143 144
144 void dispatchFocusEvent(Element* oldFocusedElement, WebFocusType, InputDevic eCapabilities* sourceCapabilities) final; 145 void dispatchFocusEvent(Element* oldFocusedElement, WebFocusType, InputDevic eCapabilities* sourceCapabilities) final;
145 void dispatchBlurEvent(Element* newFocusedElement, WebFocusType, InputDevice Capabilities* sourceCapabilities) final; 146 void dispatchBlurEvent(Element* newFocusedElement, WebFocusType, InputDevice Capabilities* sourceCapabilities) final;
146 void scheduleSelectEvent(); 147 void scheduleSelectEvent();
147 148
148 // Returns true if user-editable value is empty. Used to check placeholder v isibility. 149 // Returns true if user-editable value is empty. Used to check placeholder v isibility.
149 virtual bool isEmptyValue() const = 0; 150 virtual bool isEmptyValue() const = 0;
150 // Returns true if suggested value is empty. Used to check placeholder visib ility. 151 // Returns true if suggested value is empty. Used to check placeholder visib ility.
151 virtual bool isEmptySuggestedValue() const { return true; } 152 virtual bool isEmptySuggestedValue() const { return true; }
152 // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent(). 153 // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent().
153 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) { } 154 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) { }
154 // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent(). 155 // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent().
155 virtual void handleBlurEvent() { } 156 virtual void handleBlurEvent() { }
156 157
157 bool placeholderShouldBeVisible() const; 158 bool placeholderShouldBeVisible() const;
158 159
159 String m_textAsOfLastFormControlChangeEvent; 160 String m_textAsOfLastFormControlChangeEvent;
160 bool m_lastChangeWasUserEdit; 161 bool m_lastChangeWasUserEdit;
161 162
162 int m_cachedSelectionStart; 163 int m_cachedSelectionStart;
163 int m_cachedSelectionEnd; 164 int m_cachedSelectionEnd;
164 TextFieldSelectionDirection m_cachedSelectionDirection; 165 TextFieldSelectionDirection m_cachedSelectionDirection;
166
167 FRIEND_TEST_ALL_PREFIXES(HTMLTextFormControlElementTest, IndexForPosition);
165 }; 168 };
166 169
167 inline bool isHTMLTextFormControlElement(const Element& element) 170 inline bool isHTMLTextFormControlElement(const Element& element)
168 { 171 {
169 return element.isTextFormControl(); 172 return element.isTextFormControl();
170 } 173 }
171 174
172 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement); 175 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLTextFormControlElement);
173 176
174 HTMLTextFormControlElement* enclosingTextFormControl(const Position&); 177 HTMLTextFormControlElement* enclosingTextFormControl(const Position&);
175 HTMLTextFormControlElement* enclosingTextFormControl(Node*); 178 HTMLTextFormControlElement* enclosingTextFormControl(Node*);
176 179
177 } // namespace blink 180 } // namespace blink
178 181
179 #endif 182 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698