| OLD | NEW |
| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 LocalFrame* frame = document().frame(); | 295 LocalFrame* frame = document().frame(); |
| 296 if (!frame || m_isSubmitting || m_inUserJSSubmitEvent) | 296 if (!frame || m_isSubmitting || m_inUserJSSubmitEvent) |
| 297 return; | 297 return; |
| 298 | 298 |
| 299 if (document().isSandboxed(SandboxForms)) { | 299 if (document().isSandboxed(SandboxForms)) { |
| 300 document().addConsoleMessage(ConsoleMessage::create(SecurityMessageSourc
e, ErrorMessageLevel, "Blocked form submission to '" + m_attributes.action() + "
' because the form's frame is sandboxed and the 'allow-forms' permission is not
set.")); | 300 document().addConsoleMessage(ConsoleMessage::create(SecurityMessageSourc
e, ErrorMessageLevel, "Blocked form submission to '" + m_attributes.action() + "
' because the form's frame is sandboxed and the 'allow-forms' permission is not
set.")); |
| 301 return; | 301 return; |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool skipValidation = !document().page() || noValidate(); | 304 bool skipValidation = !document().page() || noValidate(); |
| 305 ASSERT(event); | 305 DCHECK(event); |
| 306 HTMLFormControlElement* submitElement = submitElementFromEvent(event); | 306 HTMLFormControlElement* submitElement = submitElementFromEvent(event); |
| 307 if (submitElement && submitElement->formNoValidate()) | 307 if (submitElement && submitElement->formNoValidate()) |
| 308 skipValidation = true; | 308 skipValidation = true; |
| 309 | 309 |
| 310 UseCounter::count(document(), UseCounter::FormSubmissionStarted); | 310 UseCounter::count(document(), UseCounter::FormSubmissionStarted); |
| 311 // Interactive validation must be done before dispatching the submit event. | 311 // Interactive validation must be done before dispatching the submit event. |
| 312 if (!skipValidation && !validateInteractively()) | 312 if (!skipValidation && !validateInteractively()) |
| 313 return; | 313 return; |
| 314 | 314 |
| 315 { | 315 { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 388 } |
| 389 | 389 |
| 390 if (needButtonActivation && firstSuccessfulSubmitButton) | 390 if (needButtonActivation && firstSuccessfulSubmitButton) |
| 391 firstSuccessfulSubmitButton->setActivatedSubmit(false); | 391 firstSuccessfulSubmitButton->setActivatedSubmit(false); |
| 392 | 392 |
| 393 m_shouldSubmit = false; | 393 m_shouldSubmit = false; |
| 394 } | 394 } |
| 395 | 395 |
| 396 void HTMLFormElement::scheduleFormSubmission(FormSubmission* submission) | 396 void HTMLFormElement::scheduleFormSubmission(FormSubmission* submission) |
| 397 { | 397 { |
| 398 ASSERT(submission->method() == FormSubmission::PostMethod || submission->met
hod() == FormSubmission::GetMethod); | 398 DCHECK(submission->method() == FormSubmission::PostMethod || submission->met
hod() == FormSubmission::GetMethod); |
| 399 ASSERT(submission->data()); | 399 DCHECK(submission->data()); |
| 400 ASSERT(submission->form()); | 400 DCHECK(submission->form()); |
| 401 if (submission->action().isEmpty()) | 401 if (submission->action().isEmpty()) |
| 402 return; | 402 return; |
| 403 if (document().isSandboxed(SandboxForms)) { | 403 if (document().isSandboxed(SandboxForms)) { |
| 404 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 404 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
| 405 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.")); | 405 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.")); |
| 406 return; | 406 return; |
| 407 } | 407 } |
| 408 | 408 |
| 409 if (protocolIsJavaScript(submission->action())) { | 409 if (protocolIsJavaScript(submission->action())) { |
| 410 if (!document().contentSecurityPolicy()->allowFormAction(submission->act
ion())) | 410 if (!document().contentSecurityPolicy()->allowFormAction(submission->act
ion())) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 const FormAssociatedElement::List& HTMLFormElement::associatedElements() const | 559 const FormAssociatedElement::List& HTMLFormElement::associatedElements() const |
| 560 { | 560 { |
| 561 if (!m_associatedElementsAreDirty) | 561 if (!m_associatedElementsAreDirty) |
| 562 return m_associatedElements; | 562 return m_associatedElements; |
| 563 HTMLFormElement* mutableThis = const_cast<HTMLFormElement*>(this); | 563 HTMLFormElement* mutableThis = const_cast<HTMLFormElement*>(this); |
| 564 Node* scope = mutableThis; | 564 Node* scope = mutableThis; |
| 565 if (m_hasElementsAssociatedByParser) | 565 if (m_hasElementsAssociatedByParser) |
| 566 scope = &NodeTraversal::highestAncestorOrSelf(*mutableThis); | 566 scope = &NodeTraversal::highestAncestorOrSelf(*mutableThis); |
| 567 if (isConnected() && m_hasElementsAssociatedByFormAttribute) | 567 if (isConnected() && m_hasElementsAssociatedByFormAttribute) |
| 568 scope = &treeScope().rootNode(); | 568 scope = &treeScope().rootNode(); |
| 569 ASSERT(scope); | 569 DCHECK(scope); |
| 570 collectAssociatedElements(*scope, mutableThis->m_associatedElements); | 570 collectAssociatedElements(*scope, mutableThis->m_associatedElements); |
| 571 mutableThis->m_associatedElementsAreDirty = false; | 571 mutableThis->m_associatedElementsAreDirty = false; |
| 572 return m_associatedElements; | 572 return m_associatedElements; |
| 573 } | 573 } |
| 574 | 574 |
| 575 void HTMLFormElement::collectImageElements(Node& root, HeapVector<Member<HTMLIma
geElement>>& elements) | 575 void HTMLFormElement::collectImageElements(Node& root, HeapVector<Member<HTMLIma
geElement>>& elements) |
| 576 { | 576 { |
| 577 elements.clear(); | 577 elements.clear(); |
| 578 for (HTMLImageElement& image : Traversal<HTMLImageElement>::startsAfter(root
)) { | 578 for (HTMLImageElement& image : Traversal<HTMLImageElement>::startsAfter(root
)) { |
| 579 if (image.formOwner() == this) | 579 if (image.formOwner() == this) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 bool HTMLFormElement::reportValidity() | 666 bool HTMLFormElement::reportValidity() |
| 667 { | 667 { |
| 668 return validateInteractively(); | 668 return validateInteractively(); |
| 669 } | 669 } |
| 670 | 670 |
| 671 Element* HTMLFormElement::elementFromPastNamesMap(const AtomicString& pastName) | 671 Element* HTMLFormElement::elementFromPastNamesMap(const AtomicString& pastName) |
| 672 { | 672 { |
| 673 if (pastName.isEmpty() || !m_pastNamesMap) | 673 if (pastName.isEmpty() || !m_pastNamesMap) |
| 674 return 0; | 674 return 0; |
| 675 Element* element = m_pastNamesMap->get(pastName); | 675 Element* element = m_pastNamesMap->get(pastName); |
| 676 #if ENABLE(ASSERT) | 676 #if DCHECK_IS_ON() |
| 677 if (!element) | 677 if (!element) |
| 678 return 0; | 678 return 0; |
| 679 ASSERT_WITH_SECURITY_IMPLICATION(toHTMLElement(element)->formOwner() == this
); | 679 SECURITY_DCHECK(toHTMLElement(element)->formOwner() == this); |
| 680 if (isHTMLImageElement(*element)) { | 680 if (isHTMLImageElement(*element)) { |
| 681 ASSERT_WITH_SECURITY_IMPLICATION(imageElements().find(element) != kNotFo
und); | 681 SECURITY_DCHECK(imageElements().find(element) != kNotFound); |
| 682 } else if (isHTMLObjectElement(*element)) { | 682 } else if (isHTMLObjectElement(*element)) { |
| 683 ASSERT_WITH_SECURITY_IMPLICATION(associatedElements().find(toHTMLObjectE
lement(element)) != kNotFound); | 683 SECURITY_DCHECK(associatedElements().find(toHTMLObjectElement(element))
!= kNotFound); |
| 684 } else { | 684 } else { |
| 685 ASSERT_WITH_SECURITY_IMPLICATION(associatedElements().find(toHTMLFormCon
trolElement(element)) != kNotFound); | 685 SECURITY_DCHECK(associatedElements().find(toHTMLFormControlElement(eleme
nt)) != kNotFound); |
| 686 } | 686 } |
| 687 #endif | 687 #endif |
| 688 return element; | 688 return element; |
| 689 } | 689 } |
| 690 | 690 |
| 691 void HTMLFormElement::addToPastNamesMap(Element* element, const AtomicString& pa
stName) | 691 void HTMLFormElement::addToPastNamesMap(Element* element, const AtomicString& pa
stName) |
| 692 { | 692 { |
| 693 if (pastName.isEmpty()) | 693 if (pastName.isEmpty()) |
| 694 return; | 694 return; |
| 695 if (!m_pastNamesMap) | 695 if (!m_pastNamesMap) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 HeapVector<Member<Element>> elements; | 750 HeapVector<Member<Element>> elements; |
| 751 getNamedElements(name, elements); | 751 getNamedElements(name, elements); |
| 752 if (elements.isEmpty()) | 752 if (elements.isEmpty()) |
| 753 return; | 753 return; |
| 754 } | 754 } |
| 755 | 755 |
| 756 // Second call may return different results from the first call, | 756 // Second call may return different results from the first call, |
| 757 // but if the first the size cannot be zero. | 757 // but if the first the size cannot be zero. |
| 758 HeapVector<Member<Element>> elements; | 758 HeapVector<Member<Element>> elements; |
| 759 getNamedElements(name, elements); | 759 getNamedElements(name, elements); |
| 760 ASSERT(!elements.isEmpty()); | 760 DCHECK(!elements.isEmpty()); |
| 761 | 761 |
| 762 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs
t()); | 762 bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.firs
t()); |
| 763 if (onlyMatchImg) { | 763 if (onlyMatchImg) { |
| 764 UseCounter::count(document(), UseCounter::FormNameAccessForImageElement)
; | 764 UseCounter::count(document(), UseCounter::FormNameAccessForImageElement)
; |
| 765 // The following code has performance impact, but it should be small | 765 // The following code has performance impact, but it should be small |
| 766 // because <img> access via <form> name getter is rarely used. | 766 // because <img> access via <form> name getter is rarely used. |
| 767 for (auto& element : elements) { | 767 for (auto& element : elements) { |
| 768 if (isHTMLImageElement(*element) && !element->isDescendantOf(this))
{ | 768 if (isHTMLImageElement(*element) && !element->isDescendantOf(this))
{ |
| 769 UseCounter::count(document(), UseCounter::FormNameAccessForNonDe
scendantImageElement); | 769 UseCounter::count(document(), UseCounter::FormNameAccessForNonDe
scendantImageElement); |
| 770 break; | 770 break; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 790 { | 790 { |
| 791 for (const auto& control : associatedElements()) { | 791 for (const auto& control : associatedElements()) { |
| 792 if (!control->isFormControlElement()) | 792 if (!control->isFormControlElement()) |
| 793 continue; | 793 continue; |
| 794 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton()) | 794 if (toHTMLFormControlElement(control)->canBeSuccessfulSubmitButton()) |
| 795 toHTMLFormControlElement(control)->pseudoStateChanged(CSSSelector::P
seudoDefault); | 795 toHTMLFormControlElement(control)->pseudoStateChanged(CSSSelector::P
seudoDefault); |
| 796 } | 796 } |
| 797 } | 797 } |
| 798 | 798 |
| 799 } // namespace blink | 799 } // namespace blink |
| OLD | NEW |