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

Side by Side Diff: webkit/glue/dom_operations.cc

Issue 50038: Fix for autofill bug 8627 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/dom_operations.h ('k') | webkit/glue/editor_client_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "config.h" 5 #include "config.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 8
9 MSVC_PUSH_WARNING_LEVEL(0); 9 MSVC_PUSH_WARNING_LEVEL(0);
10 #include "AnimationController.h" 10 #include "AnimationController.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 it->second->onChange(); 305 it->second->onChange();
306 } 306 }
307 307
308 if (submit && submit_found) { 308 if (submit && submit_found) {
309 fe->form_element->submit(); 309 fe->form_element->submit();
310 return true; 310 return true;
311 } 311 }
312 return false; 312 return false;
313 } 313 }
314 314
315 // Helper function to cast a Node as an HTMLInputElement.
316 static WebCore::HTMLInputElement* GetNodeAsInputElement(WebCore::Node* node) {
317 DCHECK(node->nodeType() == WebCore::Node::ELEMENT_NODE);
318 DCHECK(static_cast<WebCore::Element*>(node)->hasTagName(
319 WebCore::HTMLNames::inputTag));
320 return static_cast<WebCore::HTMLInputElement*>(node);
321 }
322
323 // Helper to search the given form element for the specified input elements 315 // Helper to search the given form element for the specified input elements
324 // in |data|, and add results to |result|. 316 // in |data|, and add results to |result|.
325 static bool FindFormInputElements(WebCore::HTMLFormElement* fe, 317 static bool FindFormInputElements(WebCore::HTMLFormElement* fe,
326 const FormData& data, 318 const FormData& data,
327 FormElements* result) { 319 FormElements* result) {
328 Vector<RefPtr<WebCore::Node> > temp_elements; 320 Vector<RefPtr<WebCore::Node> > temp_elements;
329 // Loop through the list of elements we need to find on the form in 321 // Loop through the list of elements we need to find on the form in
330 // order to autofill it. If we don't find any one of them, abort 322 // order to autofill it. If we don't find any one of them, abort
331 // processing this form; it can't be the right one. 323 // processing this form; it can't be the right one.
332 for (size_t j = 0; j < data.elements.size(); j++, temp_elements.clear()) { 324 for (size_t j = 0; j < data.elements.size(); j++, temp_elements.clear()) {
333 fe->getNamedElements(StdWStringToString(data.elements[j]), 325 fe->getNamedElements(StdWStringToString(data.elements[j]),
334 temp_elements); 326 temp_elements);
335 if (temp_elements.isEmpty()) { 327 if (temp_elements.isEmpty()) {
336 // We didn't find a required element. This is not the right form. 328 // We didn't find a required element. This is not the right form.
337 // Make sure no input elements from a partially matched form 329 // Make sure no input elements from a partially matched form
338 // in this iteration remain in the result set. 330 // in this iteration remain in the result set.
339 // Note: clear will remove a reference from each InputElement. 331 // Note: clear will remove a reference from each InputElement.
340 result->input_elements.clear(); 332 result->input_elements.clear();
341 return false; 333 return false;
342 } 334 }
343 // This element matched, add it to our temporary result. It's possible 335 // This element matched, add it to our temporary result. It's possible
344 // there are multiple matches, but for purposes of identifying the form 336 // there are multiple matches, but for purposes of identifying the form
345 // one suffices and if some function needs to deal with multiple 337 // one suffices and if some function needs to deal with multiple
346 // matching elements it can get at them through the FormElement*. 338 // matching elements it can get at them through the FormElement*.
347 // Note: This assignment adds a reference to the InputElement. 339 // Note: This assignment adds a reference to the InputElement.
348 result->input_elements[data.elements[j]] = 340 result->input_elements[data.elements[j]] =
349 GetNodeAsInputElement(temp_elements[0].get()); 341 NodeToHTMLInputElement(temp_elements[0].get());
342 DCHECK(result->input_elements[data.elements[j]].get());
350 } 343 }
351 return true; 344 return true;
352 } 345 }
353 346
354 // Helper to locate form elements identified by |data|. 347 // Helper to locate form elements identified by |data|.
355 static void FindFormElements(WebView* view, 348 static void FindFormElements(WebView* view,
356 const FormData& data, 349 const FormData& data,
357 FormElementsList* results) { 350 FormElementsList* results) {
358 DCHECK(view); 351 DCHECK(view);
359 DCHECK(results); 352 DCHECK(results);
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 return -1; 860 return -1;
868 861
869 WebCore::Frame* frame = static_cast<WebFrameImpl*>(web_frame)->frame(); 862 WebCore::Frame* frame = static_cast<WebFrameImpl*>(web_frame)->frame();
870 WebCore::AnimationController* controller = frame->animation(); 863 WebCore::AnimationController* controller = frame->animation();
871 if (!controller) 864 if (!controller)
872 return -1; 865 return -1;
873 866
874 return controller->numberOfActiveAnimations(); 867 return controller->numberOfActiveAnimations();
875 } 868 }
876 869
870 WebCore::HTMLInputElement* ElementToHTMLInputElement(
871 WebCore::Element* element) {
872 if (!element->hasLocalName(WebCore::HTMLNames::inputTag))
873 return NULL;
874 return static_cast<WebCore::HTMLInputElement*>(element);
875 }
876
877 WebCore::HTMLInputElement* NodeToHTMLInputElement(WebCore::Node* node) {
878 if (node->nodeType() != WebCore::Node::ELEMENT_NODE)
879 return NULL;
880 return ElementToHTMLInputElement(static_cast<WebCore::Element*>(node));
881 }
882
877 } // webkit_glue 883 } // webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/dom_operations.h ('k') | webkit/glue/editor_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698