| OLD | NEW |
| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 unwrap<HTMLFormControlElement>()->setAutofilled(autofilled); | 78 unwrap<HTMLFormControlElement>()->setAutofilled(autofilled); |
| 79 } | 79 } |
| 80 | 80 |
| 81 WebString WebFormControlElement::nameForAutofill() const | 81 WebString WebFormControlElement::nameForAutofill() const |
| 82 { | 82 { |
| 83 return constUnwrap<HTMLFormControlElement>()->nameForAutofill(); | 83 return constUnwrap<HTMLFormControlElement>()->nameForAutofill(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool WebFormControlElement::autoComplete() const | 86 bool WebFormControlElement::autoComplete() const |
| 87 { | 87 { |
| 88 if (m_private->hasTagName(HTMLNames::inputTag)) | 88 if (isHTMLInputElement(*m_private)) |
| 89 return constUnwrap<HTMLInputElement>()->shouldAutocomplete(); | 89 return constUnwrap<HTMLInputElement>()->shouldAutocomplete(); |
| 90 if (m_private->hasTagName(HTMLNames::textareaTag)) | 90 if (isHTMLTextAreaElement(*m_private)) |
| 91 return constUnwrap<HTMLTextAreaElement>()->shouldAutocomplete(); | 91 return constUnwrap<HTMLTextAreaElement>()->shouldAutocomplete(); |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void WebFormControlElement::setValue(const WebString& value, bool sendChangeEven
t) | 95 void WebFormControlElement::setValue(const WebString& value, bool sendChangeEven
t) |
| 96 { | 96 { |
| 97 if (m_private->hasTagName(HTMLNames::inputTag)) | 97 if (isHTMLInputElement(*m_private)) |
| 98 unwrap<HTMLInputElement>()->setValue(value, sendChangeEvent ? DispatchCh
angeEvent : DispatchNoEvent); | 98 unwrap<HTMLInputElement>()->setValue(value, sendChangeEvent ? DispatchCh
angeEvent : DispatchNoEvent); |
| 99 if (m_private->hasTagName(HTMLNames::textareaTag)) | 99 if (isHTMLTextAreaElement(*m_private)) |
| 100 unwrap<HTMLTextAreaElement>()->setValue(value); | 100 unwrap<HTMLTextAreaElement>()->setValue(value); |
| 101 if (m_private->hasTagName(HTMLNames::selectTag)) | 101 if (isHTMLSelectElement(*m_private)) |
| 102 unwrap<HTMLSelectElement>()->setValue(value); | 102 unwrap<HTMLSelectElement>()->setValue(value); |
| 103 } | 103 } |
| 104 | 104 |
| 105 WebString WebFormControlElement::value() const | 105 WebString WebFormControlElement::value() const |
| 106 { | 106 { |
| 107 if (m_private->hasTagName(HTMLNames::inputTag)) | 107 if (isHTMLInputElement(*m_private)) |
| 108 return constUnwrap<HTMLInputElement>()->value(); | 108 return constUnwrap<HTMLInputElement>()->value(); |
| 109 if (m_private->hasTagName(HTMLNames::textareaTag)) | 109 if (isHTMLTextAreaElement(*m_private)) |
| 110 return constUnwrap<HTMLTextAreaElement>()->value(); | 110 return constUnwrap<HTMLTextAreaElement>()->value(); |
| 111 if (m_private->hasTagName(HTMLNames::selectTag)) | 111 if (isHTMLSelectElement(*m_private)) |
| 112 return constUnwrap<HTMLSelectElement>()->value(); | 112 return constUnwrap<HTMLSelectElement>()->value(); |
| 113 return WebString(); | 113 return WebString(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void WebFormControlElement::setSuggestedValue(const WebString& value) | 116 void WebFormControlElement::setSuggestedValue(const WebString& value) |
| 117 { | 117 { |
| 118 if (m_private->hasTagName(HTMLNames::inputTag)) | 118 if (isHTMLInputElement(*m_private)) |
| 119 unwrap<HTMLInputElement>()->setSuggestedValue(value); | 119 unwrap<HTMLInputElement>()->setSuggestedValue(value); |
| 120 if (m_private->hasTagName(HTMLNames::textareaTag)) | 120 if (isHTMLTextAreaElement(*m_private)) |
| 121 unwrap<HTMLTextAreaElement>()->setSuggestedValue(value); | 121 unwrap<HTMLTextAreaElement>()->setSuggestedValue(value); |
| 122 } | 122 } |
| 123 | 123 |
| 124 WebString WebFormControlElement::suggestedValue() const | 124 WebString WebFormControlElement::suggestedValue() const |
| 125 { | 125 { |
| 126 if (m_private->hasTagName(HTMLNames::inputTag)) | 126 if (isHTMLInputElement(*m_private)) |
| 127 return constUnwrap<HTMLInputElement>()->suggestedValue(); | 127 return constUnwrap<HTMLInputElement>()->suggestedValue(); |
| 128 if (m_private->hasTagName(HTMLNames::textareaTag)) | 128 if (isHTMLTextAreaElement(*m_private)) |
| 129 return constUnwrap<HTMLTextAreaElement>()->suggestedValue(); | 129 return constUnwrap<HTMLTextAreaElement>()->suggestedValue(); |
| 130 return WebString(); | 130 return WebString(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 WebString WebFormControlElement::editingValue() const | 133 WebString WebFormControlElement::editingValue() const |
| 134 { | 134 { |
| 135 if (m_private->hasTagName(HTMLNames::inputTag)) | 135 if (isHTMLInputElement(*m_private)) |
| 136 return constUnwrap<HTMLInputElement>()->innerTextValue(); | 136 return constUnwrap<HTMLInputElement>()->innerTextValue(); |
| 137 if (m_private->hasTagName(HTMLNames::textareaTag)) | 137 if (isHTMLTextAreaElement(*m_private)) |
| 138 return constUnwrap<HTMLTextAreaElement>()->innerTextValue(); | 138 return constUnwrap<HTMLTextAreaElement>()->innerTextValue(); |
| 139 return WebString(); | 139 return WebString(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void WebFormControlElement::setSelectionRange(int start, int end) | 142 void WebFormControlElement::setSelectionRange(int start, int end) |
| 143 { | 143 { |
| 144 if (m_private->hasTagName(HTMLNames::inputTag)) | 144 if (isHTMLInputElement(*m_private)) |
| 145 unwrap<HTMLInputElement>()->setSelectionRange(start, end); | 145 unwrap<HTMLInputElement>()->setSelectionRange(start, end); |
| 146 if (m_private->hasTagName(HTMLNames::textareaTag)) | 146 if (isHTMLTextAreaElement(*m_private)) |
| 147 unwrap<HTMLTextAreaElement>()->setSelectionRange(start, end); | 147 unwrap<HTMLTextAreaElement>()->setSelectionRange(start, end); |
| 148 } | 148 } |
| 149 | 149 |
| 150 int WebFormControlElement::selectionStart() const | 150 int WebFormControlElement::selectionStart() const |
| 151 { | 151 { |
| 152 if (m_private->hasTagName(HTMLNames::inputTag)) | 152 if (isHTMLInputElement(*m_private)) |
| 153 return constUnwrap<HTMLInputElement>()->selectionStart(); | 153 return constUnwrap<HTMLInputElement>()->selectionStart(); |
| 154 if (m_private->hasTagName(HTMLNames::textareaTag)) | 154 if (isHTMLTextAreaElement(*m_private)) |
| 155 return constUnwrap<HTMLTextAreaElement>()->selectionStart(); | 155 return constUnwrap<HTMLTextAreaElement>()->selectionStart(); |
| 156 return 0; | 156 return 0; |
| 157 } | 157 } |
| 158 | 158 |
| 159 int WebFormControlElement::selectionEnd() const | 159 int WebFormControlElement::selectionEnd() const |
| 160 { | 160 { |
| 161 if (m_private->hasTagName(HTMLNames::inputTag)) | 161 if (isHTMLInputElement(*m_private)) |
| 162 return constUnwrap<HTMLInputElement>()->selectionEnd(); | 162 return constUnwrap<HTMLInputElement>()->selectionEnd(); |
| 163 if (m_private->hasTagName(HTMLNames::textareaTag)) | 163 if (isHTMLTextAreaElement(*m_private)) |
| 164 return constUnwrap<HTMLTextAreaElement>()->selectionEnd(); | 164 return constUnwrap<HTMLTextAreaElement>()->selectionEnd(); |
| 165 return 0; | 165 return 0; |
| 166 } | 166 } |
| 167 | 167 |
| 168 WebString WebFormControlElement::directionForFormData() const | 168 WebString WebFormControlElement::directionForFormData() const |
| 169 { | 169 { |
| 170 if (m_private->hasTagName(HTMLNames::inputTag)) | 170 if (isHTMLInputElement(*m_private)) |
| 171 return constUnwrap<HTMLInputElement>()->directionForFormData(); | 171 return constUnwrap<HTMLInputElement>()->directionForFormData(); |
| 172 if (m_private->hasTagName(HTMLNames::textareaTag)) | 172 if (isHTMLTextAreaElement(*m_private)) |
| 173 return constUnwrap<HTMLTextAreaElement>()->directionForFormData(); | 173 return constUnwrap<HTMLTextAreaElement>()->directionForFormData(); |
| 174 return WebString(); | 174 return WebString(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 WebFormElement WebFormControlElement::form() const | 177 WebFormElement WebFormControlElement::form() const |
| 178 { | 178 { |
| 179 return WebFormElement(constUnwrap<HTMLFormControlElement>()->form()); | 179 return WebFormElement(constUnwrap<HTMLFormControlElement>()->form()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 WebFormControlElement::WebFormControlElement(const PassRefPtr<HTMLFormControlEle
ment>& elem) | 182 WebFormControlElement::WebFormControlElement(const PassRefPtr<HTMLFormControlEle
ment>& elem) |
| 183 : WebElement(elem) | 183 : WebElement(elem) |
| 184 { | 184 { |
| 185 } | 185 } |
| 186 | 186 |
| 187 WebFormControlElement& WebFormControlElement::operator=(const PassRefPtr<HTMLFor
mControlElement>& elem) | 187 WebFormControlElement& WebFormControlElement::operator=(const PassRefPtr<HTMLFor
mControlElement>& elem) |
| 188 { | 188 { |
| 189 m_private = elem; | 189 m_private = elem; |
| 190 return *this; | 190 return *this; |
| 191 } | 191 } |
| 192 | 192 |
| 193 WebFormControlElement::operator PassRefPtr<HTMLFormControlElement>() const | 193 WebFormControlElement::operator PassRefPtr<HTMLFormControlElement>() const |
| 194 { | 194 { |
| 195 return toHTMLFormControlElement(m_private.get()); | 195 return toHTMLFormControlElement(m_private.get()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace blink | 198 } // namespace blink |
| OLD | NEW |