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

Unified Diff: Source/web/WebSearchableFormData.cpp

Issue 200723002: Use new is*Element() helper functions more in web/ code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use same assertion as in operator->() Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/WebPasswordFormUtils.cpp ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebSearchableFormData.cpp
diff --git a/Source/web/WebSearchableFormData.cpp b/Source/web/WebSearchableFormData.cpp
index acb3a88fd6d74f93f210b74a1b4872f8975340a8..f4c9855e8c286bc3aaccb4a51f36d65fc8199a20 100644
--- a/Source/web/WebSearchableFormData.cpp
+++ b/Source/web/WebSearchableFormData.cpp
@@ -135,11 +135,12 @@ bool IsSelectInDefaultState(HTMLSelectElement* select)
// in its default state if the checked state matches the state of the checked attribute.
bool IsInDefaultState(HTMLFormControlElement* formElement)
{
- if (formElement->hasTagName(HTMLNames::inputTag)) {
- const HTMLInputElement* inputElement = toHTMLInputElement(formElement);
- if (inputElement->isCheckbox() || inputElement->isRadioButton())
- return inputElement->checked() == inputElement->hasAttribute(checkedAttr);
- } else if (formElement->hasTagName(HTMLNames::selectTag)) {
+ ASSERT(formElement);
+ if (isHTMLInputElement(*formElement)) {
+ const HTMLInputElement& inputElement = toHTMLInputElement(*formElement);
+ if (inputElement.isCheckbox() || inputElement.isRadioButton())
+ return inputElement.checked() == inputElement.hasAttribute(checkedAttr);
+ } else if (isHTMLSelectElement(*formElement)) {
return IsSelectInDefaultState(toHTMLSelectElement(formElement));
}
return true;
@@ -164,17 +165,17 @@ HTMLInputElement* findSuitableSearchInputElement(const HTMLFormElement* form)
if (control->isDisabledFormControl() || control->name().isNull())
continue;
- if (!IsInDefaultState(control) || control->hasTagName(textareaTag))
+ if (!IsInDefaultState(control) || isHTMLTextAreaElement(*control))
return 0;
- if (control->hasTagName(HTMLNames::inputTag) && control->willValidate()) {
- const HTMLInputElement* input = toHTMLInputElement(control);
+ if (isHTMLInputElement(*control) && control->willValidate()) {
+ const HTMLInputElement& input = toHTMLInputElement(*control);
// Return nothing if a file upload field or a password field are found.
- if (input->isFileUpload() || input->isPasswordField())
+ if (input.isFileUpload() || input.isPasswordField())
return 0;
- if (input->isTextField()) {
+ if (input.isTextField()) {
if (textElement) {
// The auto-complete bar only knows how to fill in one value.
// This form has multiple fields; don't treat it as searchable.
« no previous file with comments | « Source/web/WebPasswordFormUtils.cpp ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698