| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "core/html/FormDataList.h" | 36 #include "core/html/FormDataList.h" |
| 37 #include "core/html/HTMLInputElement.h" | 37 #include "core/html/HTMLInputElement.h" |
| 38 #include "core/html/forms/FormController.h" | 38 #include "core/html/forms/FormController.h" |
| 39 #include "core/html/forms/InputTypeNames.h" | 39 #include "core/html/forms/InputTypeNames.h" |
| 40 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 using namespace HTMLNames; | 44 using namespace HTMLNames; |
| 45 | 45 |
| 46 PassRefPtr<InputType> HiddenInputType::create(HTMLInputElement* element) | 46 PassRefPtr<InputType> HiddenInputType::create(HTMLInputElement& element) |
| 47 { | 47 { |
| 48 return adoptRef(new HiddenInputType(element)); | 48 return adoptRef(new HiddenInputType(element)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 const AtomicString& HiddenInputType::formControlType() const | 51 const AtomicString& HiddenInputType::formControlType() const |
| 52 { | 52 { |
| 53 return InputTypeNames::hidden(); | 53 return InputTypeNames::hidden(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 FormControlState HiddenInputType::saveFormControlState() const | 56 FormControlState HiddenInputType::saveFormControlState() const |
| 57 { | 57 { |
| 58 // valueAttributeWasUpdatedAfterParsing() never be true for form | 58 // valueAttributeWasUpdatedAfterParsing() never be true for form |
| 59 // controls create by createElement() or cloneNode(). It's ok for | 59 // controls create by createElement() or cloneNode(). It's ok for |
| 60 // now because we restore values only to form controls created by | 60 // now because we restore values only to form controls created by |
| 61 // parsing. | 61 // parsing. |
| 62 return element()->valueAttributeWasUpdatedAfterParsing() ? FormControlState(
element()->value()) : FormControlState(); | 62 return element().valueAttributeWasUpdatedAfterParsing() ? FormControlState(e
lement().value()) : FormControlState(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void HiddenInputType::restoreFormControlState(const FormControlState& state) | 65 void HiddenInputType::restoreFormControlState(const FormControlState& state) |
| 66 { | 66 { |
| 67 element()->setAttribute(valueAttr, state[0]); | 67 element().setAttribute(valueAttr, state[0]); |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool HiddenInputType::supportsValidation() const | 70 bool HiddenInputType::supportsValidation() const |
| 71 { | 71 { |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 | 74 |
| 75 RenderObject* HiddenInputType::createRenderer(RenderStyle*) const | 75 RenderObject* HiddenInputType::createRenderer(RenderStyle*) const |
| 76 { | 76 { |
| 77 ASSERT_NOT_REACHED(); | 77 ASSERT_NOT_REACHED(); |
| 78 return 0; | 78 return 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 void HiddenInputType::accessKeyAction(bool) | 81 void HiddenInputType::accessKeyAction(bool) |
| 82 { | 82 { |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool HiddenInputType::rendererIsNeeded() | 85 bool HiddenInputType::rendererIsNeeded() |
| 86 { | 86 { |
| 87 return false; | 87 return false; |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool HiddenInputType::storesValueSeparateFromAttribute() | 90 bool HiddenInputType::storesValueSeparateFromAttribute() |
| 91 { | 91 { |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void HiddenInputType::setValue(const String& sanitizedValue, bool, TextFieldEven
tBehavior) | 95 void HiddenInputType::setValue(const String& sanitizedValue, bool, TextFieldEven
tBehavior) |
| 96 { | 96 { |
| 97 element()->setAttribute(valueAttr, sanitizedValue); | 97 element().setAttribute(valueAttr, sanitizedValue); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool HiddenInputType::isHiddenType() const | 100 bool HiddenInputType::isHiddenType() const |
| 101 { | 101 { |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool HiddenInputType::appendFormData(FormDataList& encoding, bool isMultipartFor
m) const | 105 bool HiddenInputType::appendFormData(FormDataList& encoding, bool isMultipartFor
m) const |
| 106 { | 106 { |
| 107 if (equalIgnoringCase(element()->name(), "_charset_")) { | 107 if (equalIgnoringCase(element().name(), "_charset_")) { |
| 108 encoding.appendData(element()->name(), String(encoding.encoding().name()
)); | 108 encoding.appendData(element().name(), String(encoding.encoding().name())
); |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 return InputType::appendFormData(encoding, isMultipartForm); | 111 return InputType::appendFormData(encoding, isMultipartForm); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool HiddenInputType::shouldRespectHeightAndWidthAttributes() | 114 bool HiddenInputType::shouldRespectHeightAndWidthAttributes() |
| 115 { | 115 { |
| 116 return true; | 116 return true; |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace WebCore | 119 } // namespace WebCore |
| OLD | NEW |