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

Side by Side Diff: third_party/WebKit/Source/core/html/forms/SearchInputType.cpp

Issue 1537313002: Fix a crash by search event handler for <input type=search incremental>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 5 years 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 | « third_party/WebKit/Source/core/html/HTMLInputElement.cpp ('k') | no next file » | 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/html/forms/SearchInputType.h" 32 #include "core/html/forms/SearchInputType.h"
33 33
34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 34 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
35 #include "core/HTMLNames.h" 35 #include "core/HTMLNames.h"
36 #include "core/InputTypeNames.h" 36 #include "core/InputTypeNames.h"
37 #include "core/dom/ExecutionContextTask.h"
37 #include "core/dom/shadow/ShadowRoot.h" 38 #include "core/dom/shadow/ShadowRoot.h"
38 #include "core/events/KeyboardEvent.h" 39 #include "core/events/KeyboardEvent.h"
39 #include "core/html/HTMLInputElement.h" 40 #include "core/html/HTMLInputElement.h"
40 #include "core/html/shadow/ShadowElementNames.h" 41 #include "core/html/shadow/ShadowElementNames.h"
41 #include "core/html/shadow/TextControlInnerElements.h" 42 #include "core/html/shadow/TextControlInnerElements.h"
42 #include "core/layout/LayoutSearchField.h" 43 #include "core/layout/LayoutSearchField.h"
43 #include "wtf/PassOwnPtr.h" 44 #include "wtf/PassOwnPtr.h"
44 45
45 namespace blink { 46 namespace blink {
46 47
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 TextFieldInputType::handleKeydownEvent(event); 108 TextFieldInputType::handleKeydownEvent(event);
108 } 109 }
109 110
110 void SearchInputType::startSearchEventTimer() 111 void SearchInputType::startSearchEventTimer()
111 { 112 {
112 ASSERT(element().layoutObject()); 113 ASSERT(element().layoutObject());
113 unsigned length = element().innerEditorValue().length(); 114 unsigned length = element().innerEditorValue().length();
114 115
115 if (!length) { 116 if (!length) {
116 stopSearchEventTimer(); 117 stopSearchEventTimer();
117 element().onSearch(); 118 element().document().postTask(BLINK_FROM_HERE, createSameThreadTask(&HTM LInputElement::onSearch, PassRefPtrWillBeRawPtr<HTMLInputElement>(&element())));
118 return; 119 return;
119 } 120 }
120 121
121 // After typing the first key, we wait 0.5 seconds. 122 // After typing the first key, we wait 0.5 seconds.
122 // After the second key, 0.4 seconds, then 0.3, then 0.2 from then on. 123 // After the second key, 0.4 seconds, then 0.3, then 0.2 from then on.
123 m_searchEventTimer.startOneShot(max(0.2, 0.6 - 0.1 * length), BLINK_FROM_HER E); 124 m_searchEventTimer.startOneShot(max(0.2, 0.6 - 0.1 * length), BLINK_FROM_HER E);
124 } 125 }
125 126
126 void SearchInputType::stopSearchEventTimer() 127 void SearchInputType::stopSearchEventTimer()
127 { 128 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 button->removeInlineStyleProperty(CSSPropertyPointerEvents); 175 button->removeInlineStyleProperty(CSSPropertyPointerEvents);
175 } 176 }
176 } 177 }
177 178
178 bool SearchInputType::supportsInputModeAttribute() const 179 bool SearchInputType::supportsInputModeAttribute() const
179 { 180 {
180 return true; 181 return true;
181 } 182 }
182 183
183 } // namespace blink 184 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLInputElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698