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

Side by Side Diff: Source/core/html/forms/BaseMultipleFieldsDateAndTimeInputType.cpp

Issue 228633003: Do not dispatch change event when pressing spin button for input type=datetime (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Detach handling for DateTime field Created 6 years, 8 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
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void BaseMultipleFieldsDateAndTimeInputType::didBlurFromControl() 154 void BaseMultipleFieldsDateAndTimeInputType::didBlurFromControl()
155 { 155 {
156 // We don't need to call blur(). This function is called when control 156 // We don't need to call blur(). This function is called when control
157 // lost focus. 157 // lost focus.
158 158
159 if (containsFocusedShadowElement()) 159 if (containsFocusedShadowElement())
160 return; 160 return;
161 RefPtr<HTMLInputElement> protector(element()); 161 RefPtr<HTMLInputElement> protector(element());
162 // Remove focus ring by CSS "focus" pseudo class. 162 // Remove focus ring by CSS "focus" pseudo class.
163 element().setFocus(false); 163 element().setFocus(false);
164 if (SpinButtonElement *spinButton = spinButtonElement())
165 spinButton->releaseCapture();
164 } 166 }
165 167
166 void BaseMultipleFieldsDateAndTimeInputType::didFocusOnControl() 168 void BaseMultipleFieldsDateAndTimeInputType::didFocusOnControl()
167 { 169 {
168 // We don't need to call focus(). This function is called when control 170 // We don't need to call focus(). This function is called when control
169 // got focus. 171 // got focus.
170 172
171 if (!containsFocusedShadowElement()) 173 if (!containsFocusedShadowElement())
172 return; 174 return;
173 // Add focus ring by CSS "focus" pseudo class. 175 // Add focus ring by CSS "focus" pseudo class.
174 // FIXME: Setting the focus flag to non-focused element is too tricky. 176 // FIXME: Setting the focus flag to non-focused element is too tricky.
175 element().setFocus(true); 177 element().setFocus(true);
176 } 178 }
177 179
178 void BaseMultipleFieldsDateAndTimeInputType::editControlValueChanged() 180 void BaseMultipleFieldsDateAndTimeInputType::editControlValueChanged()
179 { 181 {
180 RefPtr<HTMLInputElement> input(element()); 182 RefPtr<HTMLInputElement> input(element());
181 String oldValue = input->value(); 183 String oldValue = input->value();
182 String newValue = sanitizeValue(dateTimeEditElement()->value()); 184 String newValue = sanitizeValue(dateTimeEditElement()->value());
183 // Even if oldValue is null and newValue is "", we should assume they are sa me. 185 // Even if oldValue is null and newValue is "", we should assume they are sa me.
184 if ((oldValue.isEmpty() && newValue.isEmpty()) || oldValue == newValue) { 186 if ((oldValue.isEmpty() && newValue.isEmpty()) || oldValue == newValue) {
185 input->setNeedsValidityCheck(); 187 input->setNeedsValidityCheck();
186 } else { 188 } else {
187 input->setValueInternal(newValue, DispatchNoEvent); 189 input->setValueInternal(newValue, DispatchNoEvent);
188 input->setNeedsStyleRecalc(SubtreeStyleChange); 190 input->setNeedsStyleRecalc(SubtreeStyleChange);
189 input->dispatchFormControlInputEvent(); 191 input->dispatchFormControlInputEvent();
190 input->dispatchFormControlChangeEvent();
191 } 192 }
192 input->notifyFormStateChanged(); 193 input->notifyFormStateChanged();
193 input->updateClearButtonVisibility(); 194 input->updateClearButtonVisibility();
194 } 195 }
195 196
196 bool BaseMultipleFieldsDateAndTimeInputType::hasCustomFocusLogic() const 197 bool BaseMultipleFieldsDateAndTimeInputType::hasCustomFocusLogic() const
197 { 198 {
198 return false; 199 return false;
199 } 200 }
200 201
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return; 258 return;
258 } 259 }
259 260
260 DateTimeEditElement* edit = this->dateTimeEditElement(); 261 DateTimeEditElement* edit = this->dateTimeEditElement();
261 if (!edit) 262 if (!edit)
262 return; 263 return;
263 DateComponents date; 264 DateComponents date;
264 unsigned end; 265 unsigned end;
265 if (date.parseDate(value, 0, end) && end == value.length()) 266 if (date.parseDate(value, 0, end) && end == value.length())
266 edit->setOnlyYearMonthDay(date); 267 edit->setOnlyYearMonthDay(date);
268 element().dispatchFormControlChangeEvent();
267 } 269 }
268 270
269 void BaseMultipleFieldsDateAndTimeInputType::pickerIndicatorChooseValue(double v alue) 271 void BaseMultipleFieldsDateAndTimeInputType::pickerIndicatorChooseValue(double v alue)
270 { 272 {
271 ASSERT(std::isfinite(value) || std::isnan(value)); 273 ASSERT(std::isfinite(value) || std::isnan(value));
272 if (std::isnan(value)) 274 if (std::isnan(value))
273 element().setValue(emptyString(), DispatchInputAndChangeEvent); 275 element().setValue(emptyString(), DispatchInputAndChangeEvent);
274 else 276 else
275 element().setValueAsNumber(value, ASSERT_NO_EXCEPTION, DispatchInputAndC hangeEvent); 277 element().setValueAsNumber(value, ASSERT_NO_EXCEPTION, DispatchInputAndC hangeEvent);
276 } 278 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 { 436 {
435 DateTimeEditElement* edit = dateTimeEditElement(); 437 DateTimeEditElement* edit = dateTimeEditElement();
436 return element().value().isEmpty() && edit && edit->anyEditableFieldsHaveVal ues(); 438 return element().value().isEmpty() && edit && edit->anyEditableFieldsHaveVal ues();
437 } 439 }
438 440
439 AtomicString BaseMultipleFieldsDateAndTimeInputType::localeIdentifier() const 441 AtomicString BaseMultipleFieldsDateAndTimeInputType::localeIdentifier() const
440 { 442 {
441 return element().computeInheritedLanguage(); 443 return element().computeInheritedLanguage();
442 } 444 }
443 445
446 void BaseMultipleFieldsDateAndTimeInputType::editControlDidChangeValueByKeyboard ()
447 {
448 element().dispatchFormControlChangeEvent();
449 }
450
444 void BaseMultipleFieldsDateAndTimeInputType::minOrMaxAttributeChanged() 451 void BaseMultipleFieldsDateAndTimeInputType::minOrMaxAttributeChanged()
445 { 452 {
446 updateView(); 453 updateView();
447 } 454 }
448 455
449 void BaseMultipleFieldsDateAndTimeInputType::readonlyAttributeChanged() 456 void BaseMultipleFieldsDateAndTimeInputType::readonlyAttributeChanged()
450 { 457 {
451 spinButtonElement()->releaseCapture(); 458 spinButtonElement()->releaseCapture();
452 clearButtonElement()->releaseCapture(); 459 clearButtonElement()->releaseCapture();
453 if (DateTimeEditElement* edit = dateTimeEditElement()) 460 if (DateTimeEditElement* edit = dateTimeEditElement())
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 clearButton->setInlineStyleProperty(CSSPropertyPointerEvents, CSSValueNo ne); 609 clearButton->setInlineStyleProperty(CSSPropertyPointerEvents, CSSValueNo ne);
603 } else { 610 } else {
604 clearButton->removeInlineStyleProperty(CSSPropertyOpacity); 611 clearButton->removeInlineStyleProperty(CSSPropertyOpacity);
605 clearButton->removeInlineStyleProperty(CSSPropertyPointerEvents); 612 clearButton->removeInlineStyleProperty(CSSPropertyPointerEvents);
606 } 613 }
607 } 614 }
608 615
609 } // namespace WebCore 616 } // namespace WebCore
610 617
611 #endif 618 #endif
OLDNEW
« no previous file with comments | « Source/core/html/forms/BaseMultipleFieldsDateAndTimeInputType.h ('k') | Source/core/html/shadow/DateTimeEditElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698