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

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

Issue 2417753003: Input element: Fix the dirty value flag after type change. (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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/input-type-change3-expected.txt ('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) 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) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
9 * Copyright (C) 2010 Google Inc. All rights reserved. 9 * Copyright (C) 2010 Google Inc. All rights reserved.
10 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. 10 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved.
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 lazyReattachIfAttached(); 424 lazyReattachIfAttached();
425 425
426 m_inputType = newType; 426 m_inputType = newType;
427 m_inputTypeView = m_inputType->createView(); 427 m_inputTypeView = m_inputType->createView();
428 m_inputTypeView->createShadowSubtree(); 428 m_inputTypeView->createShadowSubtree();
429 429
430 setNeedsWillValidateCheck(); 430 setNeedsWillValidateCheck();
431 431
432 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); 432 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute();
433 433
434 // https://html.spec.whatwg.org/multipage/forms.html#input-type-change
435 //
436 // 1. If the previous state of the element's type attribute put the value IDL
437 // attribute in the value mode, and the element's value is not the empty
438 // string, and the new state of the element's type attribute puts the value
439 // IDL attribute in either the default mode or the default/on mode, then set
440 // the element's value content attribute to the element's value.
434 if (didStoreValue && !willStoreValue && hasDirtyValue()) { 441 if (didStoreValue && !willStoreValue && hasDirtyValue()) {
435 setAttribute(valueAttr, AtomicString(m_valueIfDirty)); 442 setAttribute(valueAttr, AtomicString(m_valueIfDirty));
436 m_valueIfDirty = String(); 443 m_valueIfDirty = String();
437 m_hasDirtyValue = false; 444 m_hasDirtyValue = false;
438 } 445 }
446 // 2. Otherwise, if the previous state of the element's type attribute put the
447 // value IDL attribute in any mode other than the value mode, and the new
448 // state of the element's type attribute puts the value IDL attribute in the
449 // value mode, then set the value of the element to the value of the value
450 // content attribute, if there is one, or the empty string otherwise, and then
451 // set the control's dirty value flag to false.
439 if (!didStoreValue && willStoreValue) { 452 if (!didStoreValue && willStoreValue) {
440 AtomicString valueString = fastGetAttribute(valueAttr); 453 AtomicString valueString = fastGetAttribute(valueAttr);
441 m_inputType->warnIfValueIsInvalid(valueString); 454 m_inputType->warnIfValueIsInvalid(valueString);
442 m_valueIfDirty = sanitizeValue(valueString); 455 m_valueIfDirty = String();
443 m_hasDirtyValue = !m_valueIfDirty.isNull(); 456 m_hasDirtyValue = false;
444 } else { 457 } else {
445 if (!hasDirtyValue()) 458 if (!hasDirtyValue())
446 m_inputType->warnIfValueIsInvalid( 459 m_inputType->warnIfValueIsInvalid(
447 fastGetAttribute(valueAttr).getString()); 460 fastGetAttribute(valueAttr).getString());
448 updateValueIfNeeded(); 461 updateValueIfNeeded();
449 } 462 }
450 463
451 m_needsToUpdateViewValue = true; 464 m_needsToUpdateViewValue = true;
452 m_inputTypeView->updateView(); 465 m_inputTypeView->updateView();
453 466
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 1927
1915 bool HTMLInputElement::hasFallbackContent() const { 1928 bool HTMLInputElement::hasFallbackContent() const {
1916 return m_inputTypeView->hasFallbackContent(); 1929 return m_inputTypeView->hasFallbackContent();
1917 } 1930 }
1918 1931
1919 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) { 1932 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) {
1920 return m_inputType->setFilesFromPaths(paths); 1933 return m_inputType->setFilesFromPaths(paths);
1921 } 1934 }
1922 1935
1923 } // namespace blink 1936 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/input-type-change3-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698