OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 24 matching lines...) Expand all Loading... |
35 #include "core/dom/shadow/ElementShadow.h" | 35 #include "core/dom/shadow/ElementShadow.h" |
36 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
37 #include "core/html/HTMLDataListElement.h" | 37 #include "core/html/HTMLDataListElement.h" |
38 #include "core/html/HTMLDataListOptionsCollection.h" | 38 #include "core/html/HTMLDataListOptionsCollection.h" |
39 #include "core/html/HTMLInputElement.h" | 39 #include "core/html/HTMLInputElement.h" |
40 #include "core/html/shadow/ShadowElementNames.h" | 40 #include "core/html/shadow/ShadowElementNames.h" |
41 #include "core/html/shadow/TextControlInnerElements.h" | 41 #include "core/html/shadow/TextControlInnerElements.h" |
42 #include "platform/RuntimeEnabledFeatures.h" | 42 #include "platform/RuntimeEnabledFeatures.h" |
43 #include "public/platform/WebString.h" | 43 #include "public/platform/WebString.h" |
44 #include "public/web/WebElementCollection.h" | 44 #include "public/web/WebElementCollection.h" |
| 45 #include "public/web/WebOptionElement.h" |
45 #include "wtf/PassRefPtr.h" | 46 #include "wtf/PassRefPtr.h" |
46 | 47 |
47 namespace blink { | 48 namespace blink { |
48 | 49 |
49 bool WebInputElement::isTextField() const | 50 bool WebInputElement::isTextField() const |
50 { | 51 { |
51 return constUnwrap<HTMLInputElement>()->isTextField(); | 52 return constUnwrap<HTMLInputElement>()->isTextField(); |
52 } | 53 } |
53 | 54 |
54 bool WebInputElement::isText() const | 55 bool WebInputElement::isText() const |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 bool WebInputElement::isChecked() const | 116 bool WebInputElement::isChecked() const |
116 { | 117 { |
117 return constUnwrap<HTMLInputElement>()->checked(); | 118 return constUnwrap<HTMLInputElement>()->checked(); |
118 } | 119 } |
119 | 120 |
120 bool WebInputElement::isMultiple() const | 121 bool WebInputElement::isMultiple() const |
121 { | 122 { |
122 return constUnwrap<HTMLInputElement>()->multiple(); | 123 return constUnwrap<HTMLInputElement>()->multiple(); |
123 } | 124 } |
124 | 125 |
125 WebElementCollection WebInputElement::dataListOptions() const | 126 WebVector<WebOptionElement> WebInputElement::filteredDataListOptions() const |
126 { | 127 { |
127 if (HTMLDataListElement* dataList = toHTMLDataListElement(constUnwrap<HTMLIn
putElement>()->list())) | 128 const HTMLInputElement* input = constUnwrap<HTMLInputElement>(); |
128 return WebElementCollection(dataList->options()); | 129 Vector<WebOptionElement> filtered; |
129 return WebElementCollection(); | 130 HTMLDataListElement* dataList = input->dataList(); |
| 131 if (!dataList) |
| 132 return filtered; |
| 133 |
| 134 String prefix = input->innerEditorValue(); |
| 135 if (input->multiple() && input->type() == InputTypeNames::email) { |
| 136 Vector<String> emails; |
| 137 prefix.split(',', true, emails); |
| 138 if (!emails.isEmpty()) |
| 139 prefix = emails.last().stripWhiteSpace(); |
| 140 } |
| 141 |
| 142 HTMLDataListOptionsCollection* options = dataList->options(); |
| 143 filtered.reserveCapacity(options->length()); |
| 144 prefix = prefix.lower(); |
| 145 for (unsigned i = 0; i < options->length(); ++i) { |
| 146 HTMLOptionElement* option = options->item(i); |
| 147 DCHECK(option); |
| 148 if (!option->value().lower().startsWith(prefix) || !input->isValidValue(
option->value())) |
| 149 continue; |
| 150 filtered.append(WebOptionElement(option)); |
| 151 } |
| 152 return filtered; |
130 } | 153 } |
131 | 154 |
132 WebString WebInputElement::localizeValue(const WebString& proposedValue) const | 155 WebString WebInputElement::localizeValue(const WebString& proposedValue) const |
133 { | 156 { |
134 return constUnwrap<HTMLInputElement>()->localizeValue(proposedValue); | 157 return constUnwrap<HTMLInputElement>()->localizeValue(proposedValue); |
135 } | 158 } |
136 | 159 |
137 int WebInputElement::defaultMaxLength() | 160 int WebInputElement::defaultMaxLength() |
138 { | 161 { |
139 return HTMLInputElement::maximumLength; | 162 return HTMLInputElement::maximumLength; |
(...skipping 23 matching lines...) Expand all Loading... |
163 } | 186 } |
164 | 187 |
165 WebInputElement* toWebInputElement(WebElement* webElement) | 188 WebInputElement* toWebInputElement(WebElement* webElement) |
166 { | 189 { |
167 if (!isHTMLInputElement(*webElement->unwrap<Element>())) | 190 if (!isHTMLInputElement(*webElement->unwrap<Element>())) |
168 return 0; | 191 return 0; |
169 | 192 |
170 return static_cast<WebInputElement*>(webElement); | 193 return static_cast<WebInputElement*>(webElement); |
171 } | 194 } |
172 } // namespace blink | 195 } // namespace blink |
OLD | NEW |