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

Side by Side Diff: Source/WebKit/chromium/src/WebSearchableFormData.cpp

Issue 16081007: Introduce toHTMLInputElement(Node*), and use it. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return !initialSelected || initialSelected->selected(); 131 return !initialSelected || initialSelected->selected();
132 } 132 }
133 133
134 // Returns true if the form element is in its default state, false otherwise. 134 // Returns true if the form element is in its default state, false otherwise.
135 // The default state is the state of the form element on initial load of the 135 // The default state is the state of the form element on initial load of the
136 // page, and varies depending upon the form element. For example, a checkbox is 136 // page, and varies depending upon the form element. For example, a checkbox is
137 // in its default state if the checked state matches the state of the checked at tribute. 137 // in its default state if the checked state matches the state of the checked at tribute.
138 bool IsInDefaultState(HTMLFormControlElement* formElement) 138 bool IsInDefaultState(HTMLFormControlElement* formElement)
139 { 139 {
140 if (formElement->hasTagName(HTMLNames::inputTag)) { 140 if (formElement->hasTagName(HTMLNames::inputTag)) {
141 const HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(fo rmElement); 141 const HTMLInputElement* inputElement = toHTMLInputElement(formElement);
142 if (inputElement->isCheckbox() || inputElement->isRadioButton()) 142 if (inputElement->isCheckbox() || inputElement->isRadioButton())
143 return inputElement->checked() == inputElement->hasAttribute(checked Attr); 143 return inputElement->checked() == inputElement->hasAttribute(checked Attr);
144 } else if (formElement->hasTagName(HTMLNames::selectTag)) 144 } else if (formElement->hasTagName(HTMLNames::selectTag))
145 return IsSelectInDefaultState(static_cast<HTMLSelectElement*>(formElemen t)); 145 return IsSelectInDefaultState(static_cast<HTMLSelectElement*>(formElemen t));
146 return true; 146 return true;
147 } 147 }
148 148
149 // Look for a suitable search text field in a given HTMLFormElement 149 // Look for a suitable search text field in a given HTMLFormElement
150 // Return nothing if one of those items are found: 150 // Return nothing if one of those items are found:
151 // - A text area field 151 // - A text area field
(...skipping 22 matching lines...) Expand all
174 // Return nothing if a file upload field or a password field are fou nd. 174 // Return nothing if a file upload field or a password field are fou nd.
175 if (input->isFileUpload() || input->isPasswordField()) 175 if (input->isFileUpload() || input->isPasswordField())
176 return 0; 176 return 0;
177 177
178 if (input->isTextField()) { 178 if (input->isTextField()) {
179 if (textElement) { 179 if (textElement) {
180 // The auto-complete bar only knows how to fill in one value . 180 // The auto-complete bar only knows how to fill in one value .
181 // This form has multiple fields; don't treat it as searchab le. 181 // This form has multiple fields; don't treat it as searchab le.
182 return 0; 182 return 0;
183 } 183 }
184 textElement = static_cast<HTMLInputElement*>(formElement); 184 textElement = toHTMLInputElement(formElement);
185 } 185 }
186 } 186 }
187 } 187 }
188 return textElement; 188 return textElement;
189 } 189 }
190 190
191 // Build a search string based on a given HTMLFormElement and HTMLInputElement 191 // Build a search string based on a given HTMLFormElement and HTMLInputElement
192 // 192 //
193 // Search string output example from www.google.com: 193 // Search string output example from www.google.com:
194 // "hl=en&source=hp&biw=1085&bih=854&q={searchTerms}&btnG=Google+Search&aq=f&aqi =&aql=&oq=" 194 // "hl=en&source=hp&biw=1085&bih=854&q={searchTerms}&btnG=Google+Search&aq=f&aqi =&aql=&oq="
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 String action(formElement->action()); 289 String action(formElement->action());
290 KURL url(formElement->document()->completeURL(action.isNull() ? "" : action) ); 290 KURL url(formElement->document()->completeURL(action.isNull() ? "" : action) );
291 RefPtr<FormData> formData = FormData::create(encodedString); 291 RefPtr<FormData> formData = FormData::create(encodedString);
292 url.setQuery(formData->flattenToString()); 292 url.setQuery(formData->flattenToString());
293 m_url = url; 293 m_url = url;
294 m_encoding = String(encoding.name()); 294 m_encoding = String(encoding.name());
295 } 295 }
296 296
297 } // namespace WebKit 297 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebPageSerializer.cpp ('k') | Source/WebKit/chromium/src/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698