OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/autofill/form_autofill_util.h" | 5 #include "chrome/renderer/autofill/form_autofill_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 return element->isTextField() && !element->isPasswordField(); | 567 return element->isTextField() && !element->isPasswordField(); |
568 } | 568 } |
569 | 569 |
570 bool IsSelectElement(const WebFormControlElement& element) { | 570 bool IsSelectElement(const WebFormControlElement& element) { |
571 // Is static for improving performance. | 571 // Is static for improving performance. |
572 CR_DEFINE_STATIC_LOCAL(WebString, kSelectOne, ("select-one")); | 572 CR_DEFINE_STATIC_LOCAL(WebString, kSelectOne, ("select-one")); |
573 return element.formControlType() == kSelectOne; | 573 return element.formControlType() == kSelectOne; |
574 } | 574 } |
575 | 575 |
576 bool IsCheckableElement(const WebInputElement* element) { | 576 bool IsCheckableElement(const WebInputElement* element) { |
577 // Is static for improving performance. | |
578 CR_DEFINE_STATIC_LOCAL(WebString, kRadio, ("radio")); | |
579 CR_DEFINE_STATIC_LOCAL(WebString, kCheckbox, ("checkbox")); | |
580 | |
581 if (!element) | 577 if (!element) |
582 return false; | 578 return false; |
583 | 579 |
584 WebString formControlType = element->formControlType(); | 580 return element->isCheckbox() || element->isRadioButton(); |
585 return formControlType == kCheckbox || formControlType == kRadio; | |
586 } | 581 } |
587 | 582 |
588 bool IsAutofillableInputElement(const WebInputElement* element) { | 583 bool IsAutofillableInputElement(const WebInputElement* element) { |
589 // TODO(ramankk): Uncomment IsCheckableElement part once we have solution | 584 return IsTextInput(element) || IsCheckableElement(element); |
590 // for the observed performance regression. | |
591 return IsTextInput(element); // || IsCheckableElement(element); | |
592 } | 585 } |
593 | 586 |
594 const string16 GetFormIdentifier(const WebFormElement& form) { | 587 const string16 GetFormIdentifier(const WebFormElement& form) { |
595 string16 identifier = form.name(); | 588 string16 identifier = form.name(); |
596 if (identifier.empty()) | 589 if (identifier.empty()) |
597 identifier = form.getAttribute(WebString("id")); | 590 identifier = form.getAttribute(WebString("id")); |
598 | 591 |
599 return identifier; | 592 return identifier; |
600 } | 593 } |
601 | 594 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 continue; | 980 continue; |
988 | 981 |
989 if (input_element->isAutofilled()) | 982 if (input_element->isAutofilled()) |
990 return true; | 983 return true; |
991 } | 984 } |
992 | 985 |
993 return false; | 986 return false; |
994 } | 987 } |
995 | 988 |
996 } // namespace autofill | 989 } // namespace autofill |
OLD | NEW |