Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1080)

Side by Side Diff: components/autofill/content/renderer/form_autofill_util.cc

Issue 531873002: Prospective fix for autofill crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 } 635 }
636 return false; 636 return false;
637 } 637 }
638 638
639 } // namespace 639 } // namespace
640 640
641 const size_t kMaxParseableFields = 200; 641 const size_t kMaxParseableFields = 200;
642 642
643 bool IsMonthInput(const WebInputElement* element) { 643 bool IsMonthInput(const WebInputElement* element) {
644 CR_DEFINE_STATIC_LOCAL(WebString, kMonth, ("month")); 644 CR_DEFINE_STATIC_LOCAL(WebString, kMonth, ("month"));
645 return element && element->formControlType() == kMonth; 645 return element && !element->isNull() && element->formControlType() == kMonth;
646 } 646 }
647 647
648 // All text fields, including password fields, should be extracted. 648 // All text fields, including password fields, should be extracted.
649 bool IsTextInput(const WebInputElement* element) { 649 bool IsTextInput(const WebInputElement* element) {
650 return element && element->isTextField(); 650 return element && !element->isNull() && element->isTextField();
651 } 651 }
652 652
653 bool IsSelectElement(const WebFormControlElement& element) { 653 bool IsSelectElement(const WebFormControlElement& element) {
654 // Static for improved performance. 654 // Static for improved performance.
655 CR_DEFINE_STATIC_LOCAL(WebString, kSelectOne, ("select-one")); 655 CR_DEFINE_STATIC_LOCAL(WebString, kSelectOne, ("select-one"));
656 return element.formControlType() == kSelectOne; 656 return !element.isNull() && element.formControlType() == kSelectOne;
657 } 657 }
658 658
659 bool IsTextAreaElement(const WebFormControlElement& element) { 659 bool IsTextAreaElement(const WebFormControlElement& element) {
660 // Static for improved performance. 660 // Static for improved performance.
661 CR_DEFINE_STATIC_LOCAL(WebString, kTextArea, ("textarea")); 661 CR_DEFINE_STATIC_LOCAL(WebString, kTextArea, ("textarea"));
662 return element.formControlType() == kTextArea; 662 return !element.isNull() && element.formControlType() == kTextArea;
663 } 663 }
664 664
665 bool IsCheckableElement(const WebInputElement* element) { 665 bool IsCheckableElement(const WebInputElement* element) {
666 if (!element) 666 if (!element || element->isNull())
667 return false; 667 return false;
668 668
669 return element->isCheckbox() || element->isRadioButton(); 669 return element->isCheckbox() || element->isRadioButton();
670 } 670 }
671 671
672 bool IsAutofillableInputElement(const WebInputElement* element) { 672 bool IsAutofillableInputElement(const WebInputElement* element) {
673 return IsTextInput(element) || 673 return IsTextInput(element) ||
674 IsMonthInput(element) || 674 IsMonthInput(element) ||
675 IsCheckableElement(element); 675 IsCheckableElement(element);
676 } 676 }
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 1181
1182 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { 1182 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) {
1183 gfx::Rect bounding_box(element->boundsInViewportSpace()); 1183 gfx::Rect bounding_box(element->boundsInViewportSpace());
1184 return gfx::RectF(bounding_box.x() * scale, 1184 return gfx::RectF(bounding_box.x() * scale,
1185 bounding_box.y() * scale, 1185 bounding_box.y() * scale,
1186 bounding_box.width() * scale, 1186 bounding_box.width() * scale,
1187 bounding_box.height() * scale); 1187 bounding_box.height() * scale);
1188 } 1188 }
1189 1189
1190 } // namespace autofill 1190 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698