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

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

Issue 2435973002: INPUT element: code cleanup around setValue(). (Closed)
Patch Set: Created 4 years, 2 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 188
189 void MultipleFieldsTemporalInputTypeView::editControlValueChanged() { 189 void MultipleFieldsTemporalInputTypeView::editControlValueChanged() {
190 String oldValue = element().value(); 190 String oldValue = element().value();
191 String newValue = m_inputType->sanitizeValue(dateTimeEditElement()->value()); 191 String newValue = m_inputType->sanitizeValue(dateTimeEditElement()->value());
192 // Even if oldValue is null and newValue is "", we should assume they are 192 // Even if oldValue is null and newValue is "", we should assume they are
193 // same. 193 // same.
194 if ((oldValue.isEmpty() && newValue.isEmpty()) || oldValue == newValue) { 194 if ((oldValue.isEmpty() && newValue.isEmpty()) || oldValue == newValue) {
195 element().setNeedsValidityCheck(); 195 element().setNeedsValidityCheck();
196 } else { 196 } else {
197 element().setValueInternal(newValue, DispatchNoEvent); 197 element().setNonAttributeValue(newValue);
198 element().setNeedsStyleRecalc( 198 element().setNeedsStyleRecalc(
199 SubtreeStyleChange, 199 SubtreeStyleChange,
200 StyleChangeReasonForTracing::create(StyleChangeReason::ControlValue)); 200 StyleChangeReasonForTracing::create(StyleChangeReason::ControlValue));
201 element().dispatchFormControlInputEvent(); 201 element().dispatchFormControlInputEvent();
202 } 202 }
203 element().notifyFormStateChanged(); 203 element().notifyFormStateChanged();
204 element().updateClearButtonVisibility(); 204 element().updateClearButtonVisibility();
205 } 205 }
206 206
207 String MultipleFieldsTemporalInputTypeView::formatDateTimeFieldsState( 207 String MultipleFieldsTemporalInputTypeView::formatDateTimeFieldsState(
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 } 475 }
476 476
477 void MultipleFieldsTemporalInputTypeView::restoreFormControlState( 477 void MultipleFieldsTemporalInputTypeView::restoreFormControlState(
478 const FormControlState& state) { 478 const FormControlState& state) {
479 DateTimeEditElement* edit = dateTimeEditElement(); 479 DateTimeEditElement* edit = dateTimeEditElement();
480 if (!edit) 480 if (!edit)
481 return; 481 return;
482 DateTimeFieldsState dateTimeFieldsState = 482 DateTimeFieldsState dateTimeFieldsState =
483 DateTimeFieldsState::restoreFormControlState(state); 483 DateTimeFieldsState::restoreFormControlState(state);
484 edit->setValueAsDateTimeFieldsState(dateTimeFieldsState); 484 edit->setValueAsDateTimeFieldsState(dateTimeFieldsState);
485 element().setValueInternal(m_inputType->sanitizeValue(edit->value()), 485 element().setNonAttributeValue(m_inputType->sanitizeValue(edit->value()));
486 DispatchNoEvent);
487 updateClearButtonVisibility(); 486 updateClearButtonVisibility();
488 } 487 }
489 488
490 FormControlState MultipleFieldsTemporalInputTypeView::saveFormControlState() 489 FormControlState MultipleFieldsTemporalInputTypeView::saveFormControlState()
491 const { 490 const {
492 if (DateTimeEditElement* edit = dateTimeEditElement()) 491 if (DateTimeEditElement* edit = dateTimeEditElement())
493 return edit->valueAsDateTimeFieldsState().saveFormControlState(); 492 return edit->valueAsDateTimeFieldsState().saveFormControlState();
494 return FormControlState(); 493 return FormControlState();
495 } 494 }
496 495
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 return element().locale().isRTL() ? RTL : LTR; 624 return element().locale().isRTL() ? RTL : LTR;
626 } 625 }
627 626
628 AXObject* MultipleFieldsTemporalInputTypeView::popupRootAXObject() { 627 AXObject* MultipleFieldsTemporalInputTypeView::popupRootAXObject() {
629 if (PickerIndicatorElement* picker = pickerIndicatorElement()) 628 if (PickerIndicatorElement* picker = pickerIndicatorElement())
630 return picker->popupRootAXObject(); 629 return picker->popupRootAXObject();
631 return nullptr; 630 return nullptr;
632 } 631 }
633 632
634 } // namespace blink 633 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/InputType.cpp ('k') | third_party/WebKit/Source/core/html/forms/RangeInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698