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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLFormElement.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 , m_hasElementsAssociatedByFormAttribute(false) 73 , m_hasElementsAssociatedByFormAttribute(false)
74 , m_didFinishParsingChildren(false) 74 , m_didFinishParsingChildren(false)
75 , m_isSubmittingOrInUserJSSubmitEvent(false) 75 , m_isSubmittingOrInUserJSSubmitEvent(false)
76 , m_shouldSubmit(false) 76 , m_shouldSubmit(false)
77 , m_isInResetFunction(false) 77 , m_isInResetFunction(false)
78 , m_wasDemoted(false) 78 , m_wasDemoted(false)
79 , m_pendingAutocompleteEventsQueue(GenericEventQueue::create(this)) 79 , m_pendingAutocompleteEventsQueue(GenericEventQueue::create(this))
80 { 80 {
81 } 81 }
82 82
83 PassRefPtrWillBeRawPtr<HTMLFormElement> HTMLFormElement::create(Document& docume nt) 83 RawPtr<HTMLFormElement> HTMLFormElement::create(Document& document)
84 { 84 {
85 UseCounter::count(document, UseCounter::FormElement); 85 UseCounter::count(document, UseCounter::FormElement);
86 return adoptRefWillBeNoop(new HTMLFormElement(document)); 86 return new HTMLFormElement(document);
87 } 87 }
88 88
89 HTMLFormElement::~HTMLFormElement() 89 HTMLFormElement::~HTMLFormElement()
90 { 90 {
91 #if !ENABLE(OILPAN) 91 #if !ENABLE(OILPAN)
92 // With Oilpan, either removedFrom is called or the document and 92 // With Oilpan, either removedFrom is called or the document and
93 // form controller are dead as well and there is no need to remove 93 // form controller are dead as well and there is no need to remove
94 // this form element from it. 94 // this form element from it.
95 document().formController().willDeleteForm(this); 95 document().formController().willDeleteForm(this);
96 #endif 96 #endif
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 notifyFormRemovedFromTree(elements, root); 174 notifyFormRemovedFromTree(elements, root);
175 } else { 175 } else {
176 FormAssociatedElement::List elements; 176 FormAssociatedElement::List elements;
177 collectAssociatedElements(NodeTraversal::highestAncestorOrSelf(*inse rtionPoint), elements); 177 collectAssociatedElements(NodeTraversal::highestAncestorOrSelf(*inse rtionPoint), elements);
178 notifyFormRemovedFromTree(elements, root); 178 notifyFormRemovedFromTree(elements, root);
179 collectAssociatedElements(root, elements); 179 collectAssociatedElements(root, elements);
180 notifyFormRemovedFromTree(elements, root); 180 notifyFormRemovedFromTree(elements, root);
181 } 181 }
182 182
183 if (!m_imageElementsAreDirty) { 183 if (!m_imageElementsAreDirty) {
184 WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>> images(imageE lements()); 184 HeapVector<Member<HTMLImageElement>> images(imageElements());
185 notifyFormRemovedFromTree(images, root); 185 notifyFormRemovedFromTree(images, root);
186 } else { 186 } else {
187 WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>> images; 187 HeapVector<Member<HTMLImageElement>> images;
188 collectImageElements(NodeTraversal::highestAncestorOrSelf(*insertion Point), images); 188 collectImageElements(NodeTraversal::highestAncestorOrSelf(*insertion Point), images);
189 notifyFormRemovedFromTree(images, root); 189 notifyFormRemovedFromTree(images, root);
190 collectImageElements(root, images); 190 collectImageElements(root, images);
191 notifyFormRemovedFromTree(images, root); 191 notifyFormRemovedFromTree(images, root);
192 } 192 }
193 } 193 }
194 #if ENABLE(OILPAN) 194 #if ENABLE(OILPAN)
195 document().formController().willDeleteForm(this); 195 document().formController().willDeleteForm(this);
196 #endif 196 #endif
197 HTMLElement::removedFrom(insertionPoint); 197 HTMLElement::removedFrom(insertionPoint);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 264
265 bool HTMLFormElement::validateInteractively() 265 bool HTMLFormElement::validateInteractively()
266 { 266 {
267 const FormAssociatedElement::List& elements = associatedElements(); 267 const FormAssociatedElement::List& elements = associatedElements();
268 for (unsigned i = 0; i < elements.size(); ++i) { 268 for (unsigned i = 0; i < elements.size(); ++i) {
269 if (elements[i]->isFormControlElement()) 269 if (elements[i]->isFormControlElement())
270 toHTMLFormControlElement(elements[i])->hideVisibleValidationMessage( ); 270 toHTMLFormControlElement(elements[i])->hideVisibleValidationMessage( );
271 } 271 }
272 272
273 WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement>> unhandledInvali dControls; 273 HeapVector<Member<HTMLFormControlElement>> unhandledInvalidControls;
274 if (!checkInvalidControlsAndCollectUnhandled(&unhandledInvalidControls, Chec kValidityDispatchInvalidEvent)) 274 if (!checkInvalidControlsAndCollectUnhandled(&unhandledInvalidControls, Chec kValidityDispatchInvalidEvent))
275 return true; 275 return true;
276 // Because the form has invalid controls, we abort the form submission and 276 // Because the form has invalid controls, we abort the form submission and
277 // show a validation message on a focusable form control. 277 // show a validation message on a focusable form control.
278 278
279 // Needs to update layout now because we'd like to call isFocusable(), which 279 // Needs to update layout now because we'd like to call isFocusable(), which
280 // has !layoutObject()->needsLayout() assertion. 280 // has !layoutObject()->needsLayout() assertion.
281 document().updateLayoutIgnorePendingStylesheets(); 281 document().updateLayoutIgnorePendingStylesheets();
282 282
283 RefPtrWillBeRawPtr<HTMLFormElement> protector(this); 283 RawPtr<HTMLFormElement> protector(this);
284 // Focus on the first focusable control and show a validation message. 284 // Focus on the first focusable control and show a validation message.
285 for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) { 285 for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) {
286 HTMLFormControlElement* unhandled = unhandledInvalidControls[i].get(); 286 HTMLFormControlElement* unhandled = unhandledInvalidControls[i].get();
287 if (unhandled->isFocusable()) { 287 if (unhandled->isFocusable()) {
288 unhandled->showValidationMessage(); 288 unhandled->showValidationMessage();
289 break; 289 break;
290 } 290 }
291 } 291 }
292 // Warn about all of unfocusable controls. 292 // Warn about all of unfocusable controls.
293 if (document().frame()) { 293 if (document().frame()) {
294 for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) { 294 for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) {
295 HTMLFormControlElement* unhandled = unhandledInvalidControls[i].get( ); 295 HTMLFormControlElement* unhandled = unhandledInvalidControls[i].get( );
296 if (unhandled->isFocusable()) 296 if (unhandled->isFocusable())
297 continue; 297 continue;
298 String message("An invalid form control with name='%name' is not foc usable."); 298 String message("An invalid form control with name='%name' is not foc usable.");
299 message.replace("%name", unhandled->name()); 299 message.replace("%name", unhandled->name());
300 document().addConsoleMessage(ConsoleMessage::create(RenderingMessage Source, ErrorMessageLevel, message)); 300 document().addConsoleMessage(ConsoleMessage::create(RenderingMessage Source, ErrorMessageLevel, message));
301 } 301 }
302 } 302 }
303 return false; 303 return false;
304 } 304 }
305 305
306 void HTMLFormElement::prepareForSubmission(Event* event) 306 void HTMLFormElement::prepareForSubmission(Event* event)
307 { 307 {
308 RefPtrWillBeRawPtr<HTMLFormElement> protector(this); 308 RawPtr<HTMLFormElement> protector(this);
309 LocalFrame* frame = document().frame(); 309 LocalFrame* frame = document().frame();
310 if (!frame || m_isSubmittingOrInUserJSSubmitEvent) 310 if (!frame || m_isSubmittingOrInUserJSSubmitEvent)
311 return; 311 return;
312 312
313 bool skipValidation = !document().page() || noValidate(); 313 bool skipValidation = !document().page() || noValidate();
314 ASSERT(event); 314 ASSERT(event);
315 HTMLFormControlElement* submitElement = submitElementFromEvent(event); 315 HTMLFormControlElement* submitElement = submitElementFromEvent(event);
316 if (submitElement && submitElement->formNoValidate()) 316 if (submitElement && submitElement->formNoValidate())
317 skipValidation = true; 317 skipValidation = true;
318 318
(...skipping 13 matching lines...) Expand all
332 332
333 if (m_shouldSubmit) 333 if (m_shouldSubmit)
334 submit(event, true); 334 submit(event, true);
335 } 335 }
336 336
337 void HTMLFormElement::submitFromJavaScript() 337 void HTMLFormElement::submitFromJavaScript()
338 { 338 {
339 submit(0, false); 339 submit(0, false);
340 } 340 }
341 341
342 void HTMLFormElement::submitDialog(PassRefPtrWillBeRawPtr<FormSubmission> formSu bmission) 342 void HTMLFormElement::submitDialog(RawPtr<FormSubmission> formSubmission)
343 { 343 {
344 for (Node* node = this; node; node = node->parentOrShadowHostNode()) { 344 for (Node* node = this; node; node = node->parentOrShadowHostNode()) {
345 if (isHTMLDialogElement(*node)) { 345 if (isHTMLDialogElement(*node)) {
346 toHTMLDialogElement(*node).closeDialog(formSubmission->result()); 346 toHTMLDialogElement(*node).closeDialog(formSubmission->result());
347 return; 347 return;
348 } 348 }
349 } 349 }
350 } 350 }
351 351
352 void HTMLFormElement::submit(Event* event, bool activateSubmitButton) 352 void HTMLFormElement::submit(Event* event, bool activateSubmitButton)
353 { 353 {
354 FrameView* view = document().view(); 354 FrameView* view = document().view();
355 LocalFrame* frame = document().frame(); 355 LocalFrame* frame = document().frame();
356 if (!view || !frame || !frame->page()) 356 if (!view || !frame || !frame->page())
357 return; 357 return;
358 358
359 if (m_isSubmittingOrInUserJSSubmitEvent) { 359 if (m_isSubmittingOrInUserJSSubmitEvent) {
360 m_shouldSubmit = true; 360 m_shouldSubmit = true;
361 return; 361 return;
362 } 362 }
363 363
364 m_isSubmittingOrInUserJSSubmitEvent = true; 364 m_isSubmittingOrInUserJSSubmitEvent = true;
365 365
366 RefPtrWillBeRawPtr<HTMLFormControlElement> firstSuccessfulSubmitButton = nul lptr; 366 RawPtr<HTMLFormControlElement> firstSuccessfulSubmitButton = nullptr;
367 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? 367 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button?
368 368
369 const FormAssociatedElement::List& elements = associatedElements(); 369 const FormAssociatedElement::List& elements = associatedElements();
370 for (unsigned i = 0; i < elements.size(); ++i) { 370 for (unsigned i = 0; i < elements.size(); ++i) {
371 FormAssociatedElement* associatedElement = elements[i]; 371 FormAssociatedElement* associatedElement = elements[i];
372 if (!associatedElement->isFormControlElement()) 372 if (!associatedElement->isFormControlElement())
373 continue; 373 continue;
374 if (needButtonActivation) { 374 if (needButtonActivation) {
375 HTMLFormControlElement* control = toHTMLFormControlElement(associate dElement); 375 HTMLFormControlElement* control = toHTMLFormControlElement(associate dElement);
376 if (control->isActivatedSubmit()) 376 if (control->isActivatedSubmit())
377 needButtonActivation = false; 377 needButtonActivation = false;
378 else if (firstSuccessfulSubmitButton == 0 && control->isSuccessfulSu bmitButton()) 378 else if (firstSuccessfulSubmitButton == 0 && control->isSuccessfulSu bmitButton())
379 firstSuccessfulSubmitButton = control; 379 firstSuccessfulSubmitButton = control;
380 } 380 }
381 } 381 }
382 382
383 if (needButtonActivation && firstSuccessfulSubmitButton) 383 if (needButtonActivation && firstSuccessfulSubmitButton)
384 firstSuccessfulSubmitButton->setActivatedSubmit(true); 384 firstSuccessfulSubmitButton->setActivatedSubmit(true);
385 385
386 RefPtrWillBeRawPtr<FormSubmission> formSubmission = FormSubmission::create(t his, m_attributes, event); 386 RawPtr<FormSubmission> formSubmission = FormSubmission::create(this, m_attri butes, event);
387 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog until done submitting. 387 EventQueueScope scopeForDialogClose; // Delay dispatching 'close' to dialog until done submitting.
388 if (formSubmission->method() == FormSubmission::DialogMethod) 388 if (formSubmission->method() == FormSubmission::DialogMethod)
389 submitDialog(formSubmission.release()); 389 submitDialog(formSubmission.release());
390 else 390 else
391 scheduleFormSubmission(formSubmission.release()); 391 scheduleFormSubmission(formSubmission.release());
392 392
393 if (needButtonActivation && firstSuccessfulSubmitButton) 393 if (needButtonActivation && firstSuccessfulSubmitButton)
394 firstSuccessfulSubmitButton->setActivatedSubmit(false); 394 firstSuccessfulSubmitButton->setActivatedSubmit(false);
395 395
396 m_shouldSubmit = false; 396 m_shouldSubmit = false;
397 m_isSubmittingOrInUserJSSubmitEvent = false; 397 m_isSubmittingOrInUserJSSubmitEvent = false;
398 } 398 }
399 399
400 void HTMLFormElement::scheduleFormSubmission(PassRefPtrWillBeRawPtr<FormSubmissi on> submission) 400 void HTMLFormElement::scheduleFormSubmission(RawPtr<FormSubmission> submission)
401 { 401 {
402 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met hod() == FormSubmission::GetMethod); 402 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met hod() == FormSubmission::GetMethod);
403 ASSERT(submission->data()); 403 ASSERT(submission->data());
404 ASSERT(submission->form()); 404 ASSERT(submission->form());
405 if (submission->action().isEmpty()) 405 if (submission->action().isEmpty())
406 return; 406 return;
407 if (document().isSandboxed(SandboxForms)) { 407 if (document().isSandboxed(SandboxForms)) {
408 // FIXME: This message should be moved off the console once a solution t o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. 408 // FIXME: This message should be moved off the console once a solution t o https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
409 document().addConsoleMessage(ConsoleMessage::create(SecurityMessageSourc e, ErrorMessageLevel, "Blocked form submission to '" + submission->action().elid edString() + "' because the form's frame is sandboxed and the 'allow-forms' perm ission is not set.")); 409 document().addConsoleMessage(ConsoleMessage::create(SecurityMessageSourc e, ErrorMessageLevel, "Blocked form submission to '" + submission->action().elid edString() + "' because the form's frame is sandboxed and the 'allow-forms' perm ission is not set."));
410 return; 410 return;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 if (!errorMessage.isEmpty()) { 473 if (!errorMessage.isEmpty()) {
474 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour ce, LogMessageLevel, errorMessage)); 474 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour ce, LogMessageLevel, errorMessage));
475 finishRequestAutocomplete(AutocompleteResultErrorDisabled); 475 finishRequestAutocomplete(AutocompleteResultErrorDisabled);
476 } else { 476 } else {
477 document().frame()->loader().client()->didRequestAutocomplete(this); 477 document().frame()->loader().client()->didRequestAutocomplete(this);
478 } 478 }
479 } 479 }
480 480
481 void HTMLFormElement::finishRequestAutocomplete(AutocompleteResult result) 481 void HTMLFormElement::finishRequestAutocomplete(AutocompleteResult result)
482 { 482 {
483 RefPtrWillBeRawPtr<Event> event = nullptr; 483 RawPtr<Event> event = nullptr;
484 if (result == AutocompleteResultSuccess) 484 if (result == AutocompleteResultSuccess)
485 event = Event::createBubble(EventTypeNames::autocomplete); 485 event = Event::createBubble(EventTypeNames::autocomplete);
486 else if (result == AutocompleteResultErrorDisabled) 486 else if (result == AutocompleteResultErrorDisabled)
487 event = AutocompleteErrorEvent::create("disabled"); 487 event = AutocompleteErrorEvent::create("disabled");
488 else if (result == AutocompleteResultErrorCancel) 488 else if (result == AutocompleteResultErrorCancel)
489 event = AutocompleteErrorEvent::create("cancel"); 489 event = AutocompleteErrorEvent::create("cancel");
490 else if (result == AutocompleteResultErrorInvalid) 490 else if (result == AutocompleteResultErrorInvalid)
491 event = AutocompleteErrorEvent::create("invalid"); 491 event = AutocompleteErrorEvent::create("invalid");
492 else 492 else
493 ASSERT_NOT_REACHED(); 493 ASSERT_NOT_REACHED();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 #endif 569 #endif
570 570
571 void HTMLFormElement::didAssociateByParser() 571 void HTMLFormElement::didAssociateByParser()
572 { 572 {
573 if (!m_didFinishParsingChildren) 573 if (!m_didFinishParsingChildren)
574 return; 574 return;
575 m_hasElementsAssociatedByParser = true; 575 m_hasElementsAssociatedByParser = true;
576 UseCounter::count(document(), UseCounter::FormAssociationByParser); 576 UseCounter::count(document(), UseCounter::FormAssociationByParser);
577 } 577 }
578 578
579 PassRefPtrWillBeRawPtr<HTMLFormControlsCollection> HTMLFormElement::elements() 579 RawPtr<HTMLFormControlsCollection> HTMLFormElement::elements()
580 { 580 {
581 return ensureCachedCollection<HTMLFormControlsCollection>(FormControls); 581 return ensureCachedCollection<HTMLFormControlsCollection>(FormControls);
582 } 582 }
583 583
584 void HTMLFormElement::collectAssociatedElements(Node& root, FormAssociatedElemen t::List& elements) const 584 void HTMLFormElement::collectAssociatedElements(Node& root, FormAssociatedElemen t::List& elements) const
585 { 585 {
586 elements.clear(); 586 elements.clear();
587 for (HTMLElement& element : Traversal<HTMLElement>::startsAfter(root)) { 587 for (HTMLElement& element : Traversal<HTMLElement>::startsAfter(root)) {
588 FormAssociatedElement* associatedElement = 0; 588 FormAssociatedElement* associatedElement = 0;
589 if (element.isFormControlElement()) 589 if (element.isFormControlElement())
(...skipping 18 matching lines...) Expand all
608 if (m_hasElementsAssociatedByParser) 608 if (m_hasElementsAssociatedByParser)
609 scope = &NodeTraversal::highestAncestorOrSelf(*mutableThis); 609 scope = &NodeTraversal::highestAncestorOrSelf(*mutableThis);
610 if (inDocument() && m_hasElementsAssociatedByFormAttribute) 610 if (inDocument() && m_hasElementsAssociatedByFormAttribute)
611 scope = &treeScope().rootNode(); 611 scope = &treeScope().rootNode();
612 ASSERT(scope); 612 ASSERT(scope);
613 collectAssociatedElements(*scope, mutableThis->m_associatedElements); 613 collectAssociatedElements(*scope, mutableThis->m_associatedElements);
614 mutableThis->m_associatedElementsAreDirty = false; 614 mutableThis->m_associatedElementsAreDirty = false;
615 return m_associatedElements; 615 return m_associatedElements;
616 } 616 }
617 617
618 void HTMLFormElement::collectImageElements(Node& root, WillBeHeapVector<RawPtrWi llBeMember<HTMLImageElement>>& elements) 618 void HTMLFormElement::collectImageElements(Node& root, HeapVector<Member<HTMLIma geElement>>& elements)
619 { 619 {
620 elements.clear(); 620 elements.clear();
621 for (HTMLImageElement& image : Traversal<HTMLImageElement>::startsAfter(root )) { 621 for (HTMLImageElement& image : Traversal<HTMLImageElement>::startsAfter(root )) {
622 if (image.formOwner() == this) 622 if (image.formOwner() == this)
623 elements.append(&image); 623 elements.append(&image);
624 } 624 }
625 } 625 }
626 626
627 const WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>>& HTMLFormElement::i mageElements() 627 const HeapVector<Member<HTMLImageElement>>& HTMLFormElement::imageElements()
628 { 628 {
629 if (!m_imageElementsAreDirty) 629 if (!m_imageElementsAreDirty)
630 return m_imageElements; 630 return m_imageElements;
631 collectImageElements(m_hasElementsAssociatedByParser ? NodeTraversal::highes tAncestorOrSelf(*this) : *this, m_imageElements); 631 collectImageElements(m_hasElementsAssociatedByParser ? NodeTraversal::highes tAncestorOrSelf(*this) : *this, m_imageElements);
632 m_imageElementsAreDirty = false; 632 m_imageElementsAreDirty = false;
633 return m_imageElements; 633 return m_imageElements;
634 } 634 }
635 635
636 String HTMLFormElement::name() const 636 String HTMLFormElement::name() const
637 { 637 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 return control; 676 return control;
677 } 677 }
678 return nullptr; 678 return nullptr;
679 } 679 }
680 680
681 bool HTMLFormElement::checkValidity() 681 bool HTMLFormElement::checkValidity()
682 { 682 {
683 return !checkInvalidControlsAndCollectUnhandled(0, CheckValidityDispatchInva lidEvent); 683 return !checkInvalidControlsAndCollectUnhandled(0, CheckValidityDispatchInva lidEvent);
684 } 684 }
685 685
686 bool HTMLFormElement::checkInvalidControlsAndCollectUnhandled(WillBeHeapVector<R efPtrWillBeMember<HTMLFormControlElement>>* unhandledInvalidControls, CheckValid ityEventBehavior eventBehavior) 686 bool HTMLFormElement::checkInvalidControlsAndCollectUnhandled(HeapVector<Member< HTMLFormControlElement>>* unhandledInvalidControls, CheckValidityEventBehavior e ventBehavior)
687 { 687 {
688 RefPtrWillBeRawPtr<HTMLFormElement> protector(this); 688 RawPtr<HTMLFormElement> protector(this);
689 // Copy associatedElements because event handlers called from 689 // Copy associatedElements because event handlers called from
690 // HTMLFormControlElement::checkValidity() might change associatedElements. 690 // HTMLFormControlElement::checkValidity() might change associatedElements.
691 const FormAssociatedElement::List& associatedElements = this->associatedElem ents(); 691 const FormAssociatedElement::List& associatedElements = this->associatedElem ents();
692 WillBeHeapVector<RefPtrWillBeMember<FormAssociatedElement>> elements; 692 HeapVector<Member<FormAssociatedElement>> elements;
693 elements.reserveCapacity(associatedElements.size()); 693 elements.reserveCapacity(associatedElements.size());
694 for (unsigned i = 0; i < associatedElements.size(); ++i) 694 for (unsigned i = 0; i < associatedElements.size(); ++i)
695 elements.append(associatedElements[i]); 695 elements.append(associatedElements[i]);
696 int invalidControlsCount = 0; 696 int invalidControlsCount = 0;
697 for (unsigned i = 0; i < elements.size(); ++i) { 697 for (unsigned i = 0; i < elements.size(); ++i) {
698 if (elements[i]->form() == this && elements[i]->isFormControlElement()) { 698 if (elements[i]->form() == this && elements[i]->isFormControlElement()) {
699 HTMLFormControlElement* control = toHTMLFormControlElement(elements[ i].get()); 699 HTMLFormControlElement* control = toHTMLFormControlElement(elements[ i].get());
700 if (control->isSubmittableElement() && !control->checkValidity(unhan dledInvalidControls, eventBehavior) && control->formOwner() == this) { 700 if (control->isSubmittableElement() && !control->checkValidity(unhan dledInvalidControls, eventBehavior) && control->formOwner() == this) {
701 ++invalidControlsCount; 701 ++invalidControlsCount;
702 if (!unhandledInvalidControls && eventBehavior == CheckValidityD ispatchNoEvent) 702 if (!unhandledInvalidControls && eventBehavior == CheckValidityD ispatchNoEvent)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 if (!m_pastNamesMap) 746 if (!m_pastNamesMap)
747 return; 747 return;
748 for (auto& it : *m_pastNamesMap) { 748 for (auto& it : *m_pastNamesMap) {
749 if (it.value == &element) { 749 if (it.value == &element) {
750 it.value = nullptr; 750 it.value = nullptr;
751 // Keep looping. Single element can have multiple names. 751 // Keep looping. Single element can have multiple names.
752 } 752 }
753 } 753 }
754 } 754 }
755 755
756 void HTMLFormElement::getNamedElements(const AtomicString& name, WillBeHeapVecto r<RefPtrWillBeMember<Element>>& namedItems) 756 void HTMLFormElement::getNamedElements(const AtomicString& name, HeapVector<Memb er<Element>>& namedItems)
757 { 757 {
758 // http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#do m-form-nameditem 758 // http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#do m-form-nameditem
759 elements()->namedItems(name, namedItems); 759 elements()->namedItems(name, namedItems);
760 760
761 Element* elementFromPast = elementFromPastNamesMap(name); 761 Element* elementFromPast = elementFromPastNamesMap(name);
762 if (namedItems.size() && namedItems.first() != elementFromPast) { 762 if (namedItems.size() && namedItems.first() != elementFromPast) {
763 addToPastNamesMap(namedItems.first().get(), name); 763 addToPastNamesMap(namedItems.first().get(), name);
764 } else if (elementFromPast && namedItems.isEmpty()) { 764 } else if (elementFromPast && namedItems.isEmpty()) {
765 namedItems.append(elementFromPast); 765 namedItems.append(elementFromPast);
766 UseCounter::count(document(), UseCounter::FormNameAccessForPastNamesMap) ; 766 UseCounter::count(document(), UseCounter::FormNameAccessForPastNamesMap) ;
(...skipping 17 matching lines...) Expand all
784 m_wasDemoted = static_cast<const HTMLFormElement&>(source).m_wasDemoted; 784 m_wasDemoted = static_cast<const HTMLFormElement&>(source).m_wasDemoted;
785 HTMLElement::copyNonAttributePropertiesFromElement(source); 785 HTMLElement::copyNonAttributePropertiesFromElement(source);
786 } 786 }
787 787
788 void HTMLFormElement::anonymousNamedGetter(const AtomicString& name, RadioNodeLi stOrElement& returnValue) 788 void HTMLFormElement::anonymousNamedGetter(const AtomicString& name, RadioNodeLi stOrElement& returnValue)
789 { 789 {
790 // Call getNamedElements twice, first time check if it has a value 790 // Call getNamedElements twice, first time check if it has a value
791 // and let HTMLFormElement update its cache. 791 // and let HTMLFormElement update its cache.
792 // See issue: 867404 792 // See issue: 867404
793 { 793 {
794 WillBeHeapVector<RefPtrWillBeMember<Element>> elements; 794 HeapVector<Member<Element>> elements;
795 getNamedElements(name, elements); 795 getNamedElements(name, elements);
796 if (elements.isEmpty()) 796 if (elements.isEmpty())
797 return; 797 return;
798 } 798 }
799 799
800 // Second call may return different results from the first call, 800 // Second call may return different results from the first call,
801 // but if the first the size cannot be zero. 801 // but if the first the size cannot be zero.
802 WillBeHeapVector<RefPtrWillBeMember<Element>> elements; 802 HeapVector<Member<Element>> elements;
803 getNamedElements(name, elements); 803 getNamedElements(name, elements);
804 ASSERT(!elements.isEmpty()); 804 ASSERT(!elements.isEmpty());
805 805
806 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs t()); 806 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs t());
807 if (onlyMatchImg) { 807 if (onlyMatchImg) {
808 UseCounter::count(document(), UseCounter::FormNameAccessForImageElement) ; 808 UseCounter::count(document(), UseCounter::FormNameAccessForImageElement) ;
809 // The following code has performance impact, but it should be small 809 // The following code has performance impact, but it should be small
810 // because <img> access via <form> name getter is rarely used. 810 // because <img> access via <form> name getter is rarely used.
811 for (auto& element : elements) { 811 for (auto& element : elements) {
812 if (isHTMLImageElement(*element) && !element->isDescendantOf(this)) { 812 if (isHTMLImageElement(*element) && !element->isDescendantOf(this)) {
(...skipping 21 matching lines...) Expand all
834 { 834 {
835 for (const auto& control : associatedElements()) { 835 for (const auto& control : associatedElements()) {
836 if (!control->isFormControlElement()) 836 if (!control->isFormControlElement())
837 continue; 837 continue;
838 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton()) 838 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton())
839 toHTMLFormControlElement(control)->pseudoStateChanged(CSSSelector::P seudoDefault); 839 toHTMLFormControlElement(control)->pseudoStateChanged(CSSSelector::P seudoDefault);
840 } 840 }
841 } 841 }
842 842
843 } // namespace blink 843 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormElement.h ('k') | third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698