Chromium Code Reviews| 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 bool res = g_prevent_layout ? element.hasNonEmptyLayoutSize() |
|
vabr (Chromium)
2017/03/23 20:14:09
I don't know whether hasNonEmptyLayoutSize can tri
kolos1
2017/03/28 09:34:30
Added a comment here. Please review.
| |
| 1338 // if the node takes up space in the layout. Does it want to check opacity, | 1338 : element.isFocusable(); |
| 1339 // transform, and visibility too? | 1339 return res; |
| 1340 if (!node.isElementNode()) | |
| 1341 return false; | |
| 1342 const WebElement element = node.toConst<WebElement>(); | |
| 1343 return element.hasNonEmptyLayoutSize(); | |
| 1344 } | 1340 } |
| 1345 | 1341 |
| 1346 std::vector<blink::WebFormControlElement> ExtractAutofillableElementsFromSet( | 1342 std::vector<blink::WebFormControlElement> ExtractAutofillableElementsFromSet( |
| 1347 const WebVector<WebFormControlElement>& control_elements) { | 1343 const WebVector<WebFormControlElement>& control_elements) { |
| 1348 std::vector<blink::WebFormControlElement> autofillable_elements; | 1344 std::vector<blink::WebFormControlElement> autofillable_elements; |
| 1349 for (size_t i = 0; i < control_elements.size(); ++i) { | 1345 for (size_t i = 0; i < control_elements.size(); ++i) { |
| 1350 WebFormControlElement element = control_elements[i]; | 1346 WebFormControlElement element = control_elements[i]; |
| 1351 if (!IsAutofillableElement(element)) | 1347 if (!IsAutofillableElement(element)) |
| 1352 continue; | 1348 continue; |
| 1353 | 1349 |
| (...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 | 1812 // Zero selection start is for password manager, which can show usernames |
| 1817 // that do not begin with the user input value. | 1813 // that do not begin with the user input value. |
| 1818 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1814 selection_start = (offset == base::string16::npos) ? 0 : offset; |
| 1819 } | 1815 } |
| 1820 | 1816 |
| 1821 input_element->setSelectionRange(selection_start, suggestion.length()); | 1817 input_element->setSelectionRange(selection_start, suggestion.length()); |
| 1822 } | 1818 } |
| 1823 | 1819 |
| 1824 } // namespace form_util | 1820 } // namespace form_util |
| 1825 } // namespace autofill | 1821 } // namespace autofill |
| OLD | NEW |