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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "WebFormControlElement.h" | 32 #include "WebFormControlElement.h" |
33 | 33 |
34 #include "core/html/HTMLFormControlElement.h" | 34 #include "core/html/HTMLFormControlElement.h" |
35 #include "core/html/HTMLFormElement.h" | 35 #include "core/html/HTMLFormElement.h" |
36 #include "core/html/HTMLInputElement.h" | 36 #include "core/html/HTMLInputElement.h" |
| 37 #include "core/html/HTMLSelectElement.h" |
37 #include "core/html/HTMLTextAreaElement.h" | 38 #include "core/html/HTMLTextAreaElement.h" |
38 | 39 |
39 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
40 | 41 |
41 using namespace WebCore; | 42 using namespace WebCore; |
42 | 43 |
43 namespace blink { | 44 namespace blink { |
44 | 45 |
45 bool WebFormControlElement::isEnabled() const | 46 bool WebFormControlElement::isEnabled() const |
46 { | 47 { |
(...skipping 28 matching lines...) Expand all Loading... |
75 void WebFormControlElement::setAutofilled(bool autofilled) | 76 void WebFormControlElement::setAutofilled(bool autofilled) |
76 { | 77 { |
77 unwrap<HTMLFormControlElement>()->setAutofilled(autofilled); | 78 unwrap<HTMLFormControlElement>()->setAutofilled(autofilled); |
78 } | 79 } |
79 | 80 |
80 WebString WebFormControlElement::nameForAutofill() const | 81 WebString WebFormControlElement::nameForAutofill() const |
81 { | 82 { |
82 return constUnwrap<HTMLFormControlElement>()->nameForAutofill(); | 83 return constUnwrap<HTMLFormControlElement>()->nameForAutofill(); |
83 } | 84 } |
84 | 85 |
| 86 bool WebFormControlElement::autoComplete() const |
| 87 { |
| 88 if (m_private->hasTagName(HTMLNames::inputTag)) |
| 89 return constUnwrap<HTMLInputElement>()->shouldAutocomplete(); |
| 90 if (m_private->hasTagName(HTMLNames::textareaTag)) |
| 91 return constUnwrap<HTMLTextAreaElement>()->shouldAutocomplete(); |
| 92 return false; |
| 93 } |
| 94 |
| 95 void WebFormControlElement::setValue(const WebString& value, bool sendChangeEven
t) |
| 96 { |
| 97 if (m_private->hasTagName(HTMLNames::inputTag)) |
| 98 unwrap<HTMLInputElement>()->setValue(value, sendChangeEvent ? DispatchCh
angeEvent : DispatchNoEvent); |
| 99 if (m_private->hasTagName(HTMLNames::textareaTag)) |
| 100 unwrap<HTMLTextAreaElement>()->setValue(value); |
| 101 if (m_private->hasTagName(HTMLNames::selectTag)) |
| 102 unwrap<HTMLSelectElement>()->setValue(value); |
| 103 } |
| 104 |
| 105 WebString WebFormControlElement::value() const |
| 106 { |
| 107 if (m_private->hasTagName(HTMLNames::inputTag)) |
| 108 return constUnwrap<HTMLInputElement>()->value(); |
| 109 if (m_private->hasTagName(HTMLNames::textareaTag)) |
| 110 return constUnwrap<HTMLTextAreaElement>()->value(); |
| 111 if (m_private->hasTagName(HTMLNames::selectTag)) |
| 112 return constUnwrap<HTMLSelectElement>()->value(); |
| 113 return WebString(); |
| 114 } |
| 115 |
| 116 void WebFormControlElement::setSuggestedValue(const WebString& value) |
| 117 { |
| 118 if (m_private->hasTagName(HTMLNames::inputTag)) |
| 119 unwrap<HTMLInputElement>()->setSuggestedValue(value); |
| 120 if (m_private->hasTagName(HTMLNames::textareaTag)) |
| 121 unwrap<HTMLTextAreaElement>()->setSuggestedValue(value); |
| 122 } |
| 123 |
| 124 WebString WebFormControlElement::suggestedValue() const |
| 125 { |
| 126 if (m_private->hasTagName(HTMLNames::inputTag)) |
| 127 return constUnwrap<HTMLInputElement>()->suggestedValue(); |
| 128 if (m_private->hasTagName(HTMLNames::textareaTag)) |
| 129 return constUnwrap<HTMLTextAreaElement>()->suggestedValue(); |
| 130 return WebString(); |
| 131 } |
| 132 |
85 WebString WebFormControlElement::editingValue() const | 133 WebString WebFormControlElement::editingValue() const |
86 { | 134 { |
87 if (m_private->hasTagName(HTMLNames::inputTag)) | 135 if (m_private->hasTagName(HTMLNames::inputTag)) |
88 return constUnwrap<HTMLInputElement>()->innerTextValue(); | 136 return constUnwrap<HTMLInputElement>()->innerTextValue(); |
89 if (m_private->hasTagName(HTMLNames::textareaTag)) | 137 if (m_private->hasTagName(HTMLNames::textareaTag)) |
90 return constUnwrap<HTMLTextAreaElement>()->innerTextValue(); | 138 return constUnwrap<HTMLTextAreaElement>()->innerTextValue(); |
91 return WebString(); | 139 return WebString(); |
92 } | 140 } |
93 | 141 |
| 142 void WebFormControlElement::setSelectionRange(int start, int end) |
| 143 { |
| 144 if (m_private->hasTagName(HTMLNames::inputTag)) |
| 145 unwrap<HTMLInputElement>()->setSelectionRange(start, end); |
| 146 if (m_private->hasTagName(HTMLNames::textareaTag)) |
| 147 unwrap<HTMLTextAreaElement>()->setSelectionRange(start, end); |
| 148 } |
| 149 |
94 int WebFormControlElement::selectionStart() const | 150 int WebFormControlElement::selectionStart() const |
95 { | 151 { |
96 if (m_private->hasTagName(HTMLNames::inputTag)) | 152 if (m_private->hasTagName(HTMLNames::inputTag)) |
97 return constUnwrap<HTMLInputElement>()->selectionStart(); | 153 return constUnwrap<HTMLInputElement>()->selectionStart(); |
98 if (m_private->hasTagName(HTMLNames::textareaTag)) | 154 if (m_private->hasTagName(HTMLNames::textareaTag)) |
99 return constUnwrap<HTMLTextAreaElement>()->selectionStart(); | 155 return constUnwrap<HTMLTextAreaElement>()->selectionStart(); |
100 return 0; | 156 return 0; |
101 } | 157 } |
102 | 158 |
103 int WebFormControlElement::selectionEnd() const | 159 int WebFormControlElement::selectionEnd() const |
104 { | 160 { |
105 if (m_private->hasTagName(HTMLNames::inputTag)) | 161 if (m_private->hasTagName(HTMLNames::inputTag)) |
106 return constUnwrap<HTMLInputElement>()->selectionEnd(); | 162 return constUnwrap<HTMLInputElement>()->selectionEnd(); |
107 if (m_private->hasTagName(HTMLNames::textareaTag)) | 163 if (m_private->hasTagName(HTMLNames::textareaTag)) |
108 return constUnwrap<HTMLTextAreaElement>()->selectionEnd(); | 164 return constUnwrap<HTMLTextAreaElement>()->selectionEnd(); |
109 return 0; | 165 return 0; |
110 } | 166 } |
111 | 167 |
| 168 WebString WebFormControlElement::directionForFormData() const |
| 169 { |
| 170 if (m_private->hasTagName(HTMLNames::inputTag)) |
| 171 return constUnwrap<HTMLInputElement>()->directionForFormData(); |
| 172 if (m_private->hasTagName(HTMLNames::textareaTag)) |
| 173 return constUnwrap<HTMLTextAreaElement>()->directionForFormData(); |
| 174 return WebString(); |
| 175 } |
| 176 |
112 WebFormElement WebFormControlElement::form() const | 177 WebFormElement WebFormControlElement::form() const |
113 { | 178 { |
114 return WebFormElement(constUnwrap<HTMLFormControlElement>()->form()); | 179 return WebFormElement(constUnwrap<HTMLFormControlElement>()->form()); |
115 } | 180 } |
116 | 181 |
117 WebFormControlElement::WebFormControlElement(const PassRefPtr<HTMLFormControlEle
ment>& elem) | 182 WebFormControlElement::WebFormControlElement(const PassRefPtr<HTMLFormControlEle
ment>& elem) |
118 : WebElement(elem) | 183 : WebElement(elem) |
119 { | 184 { |
120 } | 185 } |
121 | 186 |
122 WebFormControlElement& WebFormControlElement::operator=(const PassRefPtr<HTMLFor
mControlElement>& elem) | 187 WebFormControlElement& WebFormControlElement::operator=(const PassRefPtr<HTMLFor
mControlElement>& elem) |
123 { | 188 { |
124 m_private = elem; | 189 m_private = elem; |
125 return *this; | 190 return *this; |
126 } | 191 } |
127 | 192 |
128 WebFormControlElement::operator PassRefPtr<HTMLFormControlElement>() const | 193 WebFormControlElement::operator PassRefPtr<HTMLFormControlElement>() const |
129 { | 194 { |
130 return toHTMLFormControlElement(m_private.get()); | 195 return toHTMLFormControlElement(m_private.get()); |
131 } | 196 } |
132 | 197 |
133 } // namespace blink | 198 } // namespace blink |
OLD | NEW |