| OLD | NEW |
| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 #include "core/layout/LayoutTheme.h" | 71 #include "core/layout/LayoutTheme.h" |
| 72 #include "core/page/ChromeClient.h" | 72 #include "core/page/ChromeClient.h" |
| 73 #include "platform/Language.h" | 73 #include "platform/Language.h" |
| 74 #include "platform/PlatformMouseEvent.h" | 74 #include "platform/PlatformMouseEvent.h" |
| 75 #include "platform/RuntimeEnabledFeatures.h" | 75 #include "platform/RuntimeEnabledFeatures.h" |
| 76 #include "platform/text/PlatformLocale.h" | 76 #include "platform/text/PlatformLocale.h" |
| 77 #include "wtf/MathExtras.h" | 77 #include "wtf/MathExtras.h" |
| 78 | 78 |
| 79 namespace blink { | 79 namespace blink { |
| 80 | 80 |
| 81 using ValueMode = InputType::ValueMode; |
| 81 using namespace HTMLNames; | 82 using namespace HTMLNames; |
| 82 | 83 |
| 83 class ListAttributeTargetObserver : public IdTargetObserver { | 84 class ListAttributeTargetObserver : public IdTargetObserver { |
| 84 public: | 85 public: |
| 85 static ListAttributeTargetObserver* create(const AtomicString& id, | 86 static ListAttributeTargetObserver* create(const AtomicString& id, |
| 86 HTMLInputElement*); | 87 HTMLInputElement*); |
| 87 DECLARE_VIRTUAL_TRACE(); | 88 DECLARE_VIRTUAL_TRACE(); |
| 88 void idTargetChanged() override; | 89 void idTargetChanged() override; |
| 89 | 90 |
| 90 private: | 91 private: |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 DCHECK(m_inputTypeView); | 409 DCHECK(m_inputTypeView); |
| 409 | 410 |
| 410 const AtomicString& newTypeName = | 411 const AtomicString& newTypeName = |
| 411 InputType::normalizeTypeName(fastGetAttribute(typeAttr)); | 412 InputType::normalizeTypeName(fastGetAttribute(typeAttr)); |
| 412 if (m_inputType->formControlType() == newTypeName) | 413 if (m_inputType->formControlType() == newTypeName) |
| 413 return; | 414 return; |
| 414 | 415 |
| 415 InputType* newType = InputType::create(*this, newTypeName); | 416 InputType* newType = InputType::create(*this, newTypeName); |
| 416 removeFromRadioButtonGroup(); | 417 removeFromRadioButtonGroup(); |
| 417 | 418 |
| 418 bool didStoreValue = m_inputType->storesValueSeparateFromAttribute(); | 419 bool didStoreValue = m_inputType->valueMode() == ValueMode::kValue || |
| 420 m_inputType->valueMode() == ValueMode::kFilename; |
| 419 bool didRespectHeightAndWidth = | 421 bool didRespectHeightAndWidth = |
| 420 m_inputType->shouldRespectHeightAndWidthAttributes(); | 422 m_inputType->shouldRespectHeightAndWidthAttributes(); |
| 421 bool couldBeSuccessfulSubmitButton = canBeSuccessfulSubmitButton(); | 423 bool couldBeSuccessfulSubmitButton = canBeSuccessfulSubmitButton(); |
| 422 | 424 |
| 423 m_inputTypeView->destroyShadowSubtree(); | 425 m_inputTypeView->destroyShadowSubtree(); |
| 424 lazyReattachIfAttached(); | 426 lazyReattachIfAttached(); |
| 425 | 427 |
| 426 m_inputType = newType; | 428 m_inputType = newType; |
| 427 m_inputTypeView = m_inputType->createView(); | 429 m_inputTypeView = m_inputType->createView(); |
| 428 m_inputTypeView->createShadowSubtree(); | 430 m_inputTypeView->createShadowSubtree(); |
| 429 | 431 |
| 430 setNeedsWillValidateCheck(); | 432 setNeedsWillValidateCheck(); |
| 431 | 433 |
| 432 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); | 434 bool willStoreValue = m_inputType->valueMode() == ValueMode::kValue || |
| 435 m_inputType->valueMode() == ValueMode::kFilename; |
| 433 | 436 |
| 434 // https://html.spec.whatwg.org/multipage/forms.html#input-type-change | 437 // https://html.spec.whatwg.org/multipage/forms.html#input-type-change |
| 435 // | 438 // |
| 436 // 1. If the previous state of the element's type attribute put the value IDL | 439 // 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 | 440 // 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 | 441 // 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 | 442 // 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. | 443 // the element's value content attribute to the element's value. |
| 441 if (didStoreValue && !willStoreValue && hasDirtyValue()) { | 444 if (didStoreValue && !willStoreValue && hasDirtyValue()) { |
| 442 setAttribute(valueAttr, AtomicString(m_valueIfDirty)); | 445 setAttribute(valueAttr, AtomicString(m_valueIfDirty)); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 void HTMLInputElement::appendToFormData(FormData& formData) { | 870 void HTMLInputElement::appendToFormData(FormData& formData) { |
| 868 if (m_inputType->isFormDataAppendable()) | 871 if (m_inputType->isFormDataAppendable()) |
| 869 m_inputType->appendToFormData(formData); | 872 m_inputType->appendToFormData(formData); |
| 870 } | 873 } |
| 871 | 874 |
| 872 String HTMLInputElement::resultForDialogSubmit() { | 875 String HTMLInputElement::resultForDialogSubmit() { |
| 873 return m_inputType->resultForDialogSubmit(); | 876 return m_inputType->resultForDialogSubmit(); |
| 874 } | 877 } |
| 875 | 878 |
| 876 void HTMLInputElement::resetImpl() { | 879 void HTMLInputElement::resetImpl() { |
| 877 if (m_inputType->storesValueSeparateFromAttribute()) { | 880 if (m_inputType->valueMode() == ValueMode::kValue || |
| 881 m_inputType->valueMode() == ValueMode::kFilename) { |
| 878 setValue(String()); | 882 setValue(String()); |
| 879 setNeedsValidityCheck(); | 883 setNeedsValidityCheck(); |
| 880 } | 884 } |
| 881 | 885 |
| 882 setChecked(hasAttribute(checkedAttr)); | 886 setChecked(hasAttribute(checkedAttr)); |
| 883 m_dirtyCheckedness = false; | 887 m_dirtyCheckedness = false; |
| 884 } | 888 } |
| 885 | 889 |
| 886 bool HTMLInputElement::isTextField() const { | 890 bool HTMLInputElement::isTextField() const { |
| 887 return m_inputType->isTextField(); | 891 return m_inputType->isTextField(); |
| (...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 | 1931 |
| 1928 bool HTMLInputElement::hasFallbackContent() const { | 1932 bool HTMLInputElement::hasFallbackContent() const { |
| 1929 return m_inputTypeView->hasFallbackContent(); | 1933 return m_inputTypeView->hasFallbackContent(); |
| 1930 } | 1934 } |
| 1931 | 1935 |
| 1932 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) { | 1936 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) { |
| 1933 return m_inputType->setFilesFromPaths(paths); | 1937 return m_inputType->setFilesFromPaths(paths); |
| 1934 } | 1938 } |
| 1935 | 1939 |
| 1936 } // namespace blink | 1940 } // namespace blink |
| OLD | NEW |