| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/content/renderer/form_autofill_util.h" | 5 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 } | 1251 } |
| 1252 } | 1252 } |
| 1253 } | 1253 } |
| 1254 | 1254 |
| 1255 return false; | 1255 return false; |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 bool IsSomeControlElementVisible( | 1258 bool IsSomeControlElementVisible( |
| 1259 const WebVector<WebFormControlElement>& control_elements) { | 1259 const WebVector<WebFormControlElement>& control_elements) { |
| 1260 for (const WebFormControlElement& control_element : control_elements) { | 1260 for (const WebFormControlElement& control_element : control_elements) { |
| 1261 if (IsWebNodeVisible(control_element)) | 1261 if (IsWebElementVisible(control_element)) |
| 1262 return true; | 1262 return true; |
| 1263 } | 1263 } |
| 1264 return false; | 1264 return false; |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 bool AreFormContentsVisible(const WebFormElement& form) { | 1267 bool AreFormContentsVisible(const WebFormElement& form) { |
| 1268 WebVector<WebFormControlElement> control_elements; | 1268 WebVector<WebFormControlElement> control_elements; |
| 1269 form.getFormControlElements(control_elements); | 1269 form.getFormControlElements(control_elements); |
| 1270 return IsSomeControlElementVisible(control_elements); | 1270 return IsSomeControlElementVisible(control_elements); |
| 1271 } | 1271 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 | 1326 |
| 1327 const base::string16 GetFormIdentifier(const WebFormElement& form) { | 1327 const base::string16 GetFormIdentifier(const WebFormElement& form) { |
| 1328 base::string16 identifier = form.name().utf16(); | 1328 base::string16 identifier = form.name().utf16(); |
| 1329 CR_DEFINE_STATIC_LOCAL(WebString, kId, ("id")); | 1329 CR_DEFINE_STATIC_LOCAL(WebString, kId, ("id")); |
| 1330 if (identifier.empty()) | 1330 if (identifier.empty()) |
| 1331 identifier = form.getAttribute(kId).utf16(); | 1331 identifier = form.getAttribute(kId).utf16(); |
| 1332 | 1332 |
| 1333 return identifier; | 1333 return identifier; |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 bool IsWebNodeVisible(const blink::WebNode& node) { | 1336 bool IsWebElementVisible(const blink::WebElement& element) { |
| 1337 // TODO(esprehn): This code doesn't really check if the node is visible, just | 1337 // hasNonEmptyLayoutSize might trigger layout, but it didn't cause problems so |
| 1338 // if the node takes up space in the layout. Does it want to check opacity, | 1338 // far. If the layout is prohibited, hasNonEmptyLayoutSize is still used. See |
| 1339 // transform, and visibility too? | 1339 // details in crbug.com/595078. |
| 1340 if (!node.isElementNode()) | 1340 bool res = g_prevent_layout ? element.hasNonEmptyLayoutSize() |
| 1341 return false; | 1341 : element.isFocusable(); |
| 1342 const WebElement element = node.toConst<WebElement>(); | 1342 return res; |
| 1343 return element.hasNonEmptyLayoutSize(); | |
| 1344 } | 1343 } |
| 1345 | 1344 |
| 1346 std::vector<blink::WebFormControlElement> ExtractAutofillableElementsFromSet( | 1345 std::vector<blink::WebFormControlElement> ExtractAutofillableElementsFromSet( |
| 1347 const WebVector<WebFormControlElement>& control_elements) { | 1346 const WebVector<WebFormControlElement>& control_elements) { |
| 1348 std::vector<blink::WebFormControlElement> autofillable_elements; | 1347 std::vector<blink::WebFormControlElement> autofillable_elements; |
| 1349 for (size_t i = 0; i < control_elements.size(); ++i) { | 1348 for (size_t i = 0; i < control_elements.size(); ++i) { |
| 1350 WebFormControlElement element = control_elements[i]; | 1349 WebFormControlElement element = control_elements[i]; |
| 1351 if (!IsAutofillableElement(element)) | 1350 if (!IsAutofillableElement(element)) |
| 1352 continue; | 1351 continue; |
| 1353 | 1352 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 // Zero selection start is for password manager, which can show usernames | 1815 // Zero selection start is for password manager, which can show usernames |
| 1817 // that do not begin with the user input value. | 1816 // that do not begin with the user input value. |
| 1818 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1817 selection_start = (offset == base::string16::npos) ? 0 : offset; |
| 1819 } | 1818 } |
| 1820 | 1819 |
| 1821 input_element->setSelectionRange(selection_start, suggestion.length()); | 1820 input_element->setSelectionRange(selection_start, suggestion.length()); |
| 1822 } | 1821 } |
| 1823 | 1822 |
| 1824 } // namespace form_util | 1823 } // namespace form_util |
| 1825 } // namespace autofill | 1824 } // namespace autofill |
| OLD | NEW |