Changeset 277257 in webkit
- Timestamp:
- May 10, 2021 12:16:13 AM (15 months ago)
- Location:
- trunk
- Files:
-
- 4 added
- 26 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/request-submit-activation-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/request-submit-activation.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit-autofocus-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit-autofocus.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit-expected.txt (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit.html (modified) (1 diff)
-
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt (modified) (2 diffs)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLButtonElement.cpp (modified) (2 diffs)
-
Source/WebCore/html/HTMLButtonElement.h (modified) (1 diff)
-
Source/WebCore/html/HTMLFormControlElement.h (modified) (1 diff)
-
Source/WebCore/html/HTMLFormElement.cpp (modified) (14 diffs)
-
Source/WebCore/html/HTMLFormElement.h (modified) (4 diffs)
-
Source/WebCore/html/HTMLFormElement.idl (modified) (1 diff)
-
Source/WebCore/html/HTMLInputElement.h (modified) (1 diff)
-
Source/WebCore/html/ImageInputType.cpp (modified) (1 diff)
-
Source/WebCore/html/ImageInputType.h (modified) (1 diff)
-
Source/WebCore/html/InputType.h (modified) (1 diff)
-
Source/WebCore/html/SubmitInputType.cpp (modified) (1 diff)
-
Source/WebCore/loader/FormSubmission.cpp (modified) (2 diffs)
-
Source/WebCore/loader/FormSubmission.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r277230 r277257 1 2021-05-10 Rob Buis <rbuis@igalia.com> 2 3 Implement <form>.requestSubmit() 4 https://bugs.webkit.org/show_bug.cgi?id=197958 5 6 Reviewed by Darin Adler. 7 8 Update improved test results. 9 10 * platform/gtk/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt: 11 * platform/ios-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt: 12 * platform/mac-wk1/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt: 13 * platform/mac-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt: 14 * platform/wpe/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt: 15 1 16 2021-05-08 Ricky Mondello <rmondello@apple.com> 2 17 -
trunk/LayoutTests/imported/w3c/ChangeLog
r277160 r277257 1 2021-05-10 Rob Buis <rbuis@igalia.com> 2 3 Implement <form>.requestSubmit() 4 https://bugs.webkit.org/show_bug.cgi?id=197958 5 6 Reviewed by Darin Adler. 7 8 Update improved test results and import requestSubmit tests. 9 10 * web-platform-tests/html/dom/idlharness.https-expected.txt: 11 * web-platform-tests/html/semantics/forms/form-submission-0/request-submit-activation-expected.txt: Added. 12 * web-platform-tests/html/semantics/forms/form-submission-0/request-submit-activation.html: Added. 13 * web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit-autofocus-expected.txt: Added. 14 * web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit-autofocus.html: Added. 15 * web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit-expected.txt: 16 * web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit.html: 17 1 18 2021-05-06 Tim Nguyen <ntim@apple.com> 2 19 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt
r276777 r277257 1699 1699 PASS HTMLFormElement interface: attribute length 1700 1700 PASS HTMLFormElement interface: operation submit() 1701 FAIL HTMLFormElement interface: operation requestSubmit(HTMLElement) assert_own_property: interface prototype object missing non-static operation expected property "requestSubmit" missing 1701 PASS HTMLFormElement interface: operation requestSubmit(HTMLElement) 1702 1702 PASS HTMLFormElement interface: operation reset() 1703 1703 PASS HTMLFormElement interface: operation checkValidity() … … 1719 1719 PASS HTMLFormElement interface: document.createElement("form") must inherit property "length" with the proper type 1720 1720 PASS HTMLFormElement interface: document.createElement("form") must inherit property "submit()" with the proper type 1721 FAIL HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(HTMLElement)" with the proper type assert_inherits: property "requestSubmit" not found in prototype chain 1722 FAIL HTMLFormElement interface: calling requestSubmit(HTMLElement) on document.createElement("form") with too few arguments must throw TypeError assert_inherits: property "requestSubmit" not found in prototype chain 1721 PASS HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(HTMLElement)" with the proper type 1722 PASS HTMLFormElement interface: calling requestSubmit(HTMLElement) on document.createElement("form") with too few arguments must throw TypeError 1723 1723 PASS HTMLFormElement interface: document.createElement("form") must inherit property "reset()" with the proper type 1724 1724 PASS HTMLFormElement interface: document.createElement("form") must inherit property "checkValidity()" with the proper type -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit-expected.txt
r267646 r277257 1 2 1 3 2 4 … … 10 12 11 13 PASS Passing an element which is not a submit button should throw 12 FAIL Passing a submit button not owned by the context object should throw assert_throws_dom: function "() => { 13 form.requestSubmit(submitButton); 14 }" threw object "TypeError: form.requestSubmit is not a function. (In 'form.requestSubmit(submitButton)', 'form.requestSubmit' is undefined)" that is not a DOMException NotFoundError: property "code" is equal to undefined, expected 8 15 FAIL requestSubmit() should accept button[type=submit], input[type=submit], and input[type=image] form.requestSubmit is not a function. (In 'form.requestSubmit(control)', 'form.requestSubmit' is undefined) 16 FAIL requestSubmit() should trigger interactive form validation form.requestSubmit is not a function. (In 'form.requestSubmit()', 'form.requestSubmit' is undefined) 17 FAIL requestSubmit() doesn't run form submission reentrantly form.requestSubmit is not a function. (In 'form.requestSubmit()', 'form.requestSubmit' is undefined) 18 FAIL requestSubmit() doesn't run interactive validation reentrantly form.requestSubmit is not a function. (In 'form.requestSubmit()', 'form.requestSubmit' is undefined) 19 FAIL requestSubmit() for a disconnected form should not submit the form form.requestSubmit is not a function. (In 'form.requestSubmit()', 'form.requestSubmit' is undefined) 20 FAIL The value of the submitter should be appended, and form* attributes of the submitter should be handled. form.requestSubmit is not a function. (In 'form.requestSubmit(form.querySelector('[type=submit]'))', 'form.requestSubmit' is undefined) 14 PASS Passing a submit button not owned by the context object should throw 15 PASS requestSubmit() should accept button[type=submit], input[type=submit], and input[type=image] 16 PASS requestSubmit() should trigger interactive form validation 17 PASS requestSubmit() doesn't run form submission reentrantly 18 PASS requestSubmit() doesn't run interactive validation reentrantly 19 PASS requestSubmit() for a disconnected form should not submit the form 20 PASS The value of the submitter should be appended, and form* attributes of the submitter should be handled. 21 PASS The constructed FormData object should not contain an entry for the submit button that was used to submit the form. 22 PASS Using requestSubmit on a disabled button (via disabled attribute) should trigger submit but not be visible in FormData 21 23 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit.html
r263987 r277257 174 174 }, 'The value of the submitter should be appended, and form* ' + 175 175 'attributes of the submitter should be handled.'); 176 177 test(() => { 178 document.body.insertAdjacentHTML('afterbegin', `<form> 179 <input name="n1" value="v1"> 180 <button type="submit" name="n2" value="v2"></button> 181 </form> 182 <form id="form2"></form>`); 183 let form = document.querySelector('form'); 184 let formDataInEvent = null; 185 let submitter = form.querySelector('button[type=submit]'); 186 form.addEventListener('submit', e => { 187 e.preventDefault(); 188 formDataInEvent = new FormData(e.target); 189 }); 190 191 form.requestSubmit(submitter); 192 assert_equals(formDataInEvent.get('n1'), 'v1'); 193 assert_false(formDataInEvent.has('n2')); 194 }, 'The constructed FormData object should not contain an entry for the submit button that was used to submit the form.'); 195 196 async_test(t => { 197 document.body.insertAdjacentHTML('afterbegin', `<form> 198 <button type="submit" name="n1" value="v1" disabled=""></button> 199 </form>`); 200 let form = document.querySelector('form'); 201 let formDataInEvent = null; 202 let submitter = form.querySelector('button[type=submit]'); 203 204 form.addEventListener("submit", t.step_func_done(ev => { 205 ev.preventDefault(); 206 formDataInEvent = new FormData(ev.target); 207 assert_false(formDataInEvent.has('n1')); 208 assert_equals(ev.target, form); 209 })); 210 211 form.requestSubmit(submitter); 212 213 }, "Using requestSubmit on a disabled button (via disabled attribute) should trigger submit but not be visible in FormData"); 214 176 215 </script> -
trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt
r276777 r277257 1848 1848 PASS HTMLFormElement interface: attribute length 1849 1849 PASS HTMLFormElement interface: operation submit() 1850 FAIL HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) assert_own_property: interface prototype object missing non-static operation expected property "requestSubmit" missing 1850 PASS HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) 1851 1851 PASS HTMLFormElement interface: operation reset() 1852 1852 PASS HTMLFormElement interface: operation checkValidity() … … 1868 1868 PASS HTMLFormElement interface: document.createElement("form") must inherit property "length" with the proper type 1869 1869 PASS HTMLFormElement interface: document.createElement("form") must inherit property "submit()" with the proper type 1870 FAIL HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type assert_inherits: property "requestSubmit" not found in prototype chain 1871 FAIL HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError assert_inherits: property "requestSubmit" not found in prototype chain 1870 PASS HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type 1871 PASS HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError 1872 1872 PASS HTMLFormElement interface: document.createElement("form") must inherit property "reset()" with the proper type 1873 1873 PASS HTMLFormElement interface: document.createElement("form") must inherit property "checkValidity()" with the proper type -
trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt
r276777 r277257 1838 1838 PASS HTMLFormElement interface: attribute length 1839 1839 PASS HTMLFormElement interface: operation submit() 1840 FAIL HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) assert_own_property: interface prototype object missing non-static operation expected property "requestSubmit" missing 1840 PASS HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) 1841 1841 PASS HTMLFormElement interface: operation reset() 1842 1842 PASS HTMLFormElement interface: operation checkValidity() … … 1858 1858 PASS HTMLFormElement interface: document.createElement("form") must inherit property "length" with the proper type 1859 1859 PASS HTMLFormElement interface: document.createElement("form") must inherit property "submit()" with the proper type 1860 FAIL HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type assert_inherits: property "requestSubmit" not found in prototype chain 1861 FAIL HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError assert_inherits: property "requestSubmit" not found in prototype chain 1860 PASS HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type 1861 PASS HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError 1862 1862 PASS HTMLFormElement interface: document.createElement("form") must inherit property "reset()" with the proper type 1863 1863 PASS HTMLFormElement interface: document.createElement("form") must inherit property "checkValidity()" with the proper type -
trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt
r276777 r277257 1848 1848 PASS HTMLFormElement interface: attribute length 1849 1849 PASS HTMLFormElement interface: operation submit() 1850 FAIL HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) assert_own_property: interface prototype object missing non-static operation expected property "requestSubmit" missing 1850 PASS HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) 1851 1851 PASS HTMLFormElement interface: operation reset() 1852 1852 PASS HTMLFormElement interface: operation checkValidity() … … 1868 1868 PASS HTMLFormElement interface: document.createElement("form") must inherit property "length" with the proper type 1869 1869 PASS HTMLFormElement interface: document.createElement("form") must inherit property "submit()" with the proper type 1870 FAIL HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type assert_inherits: property "requestSubmit" not found in prototype chain 1871 FAIL HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError assert_inherits: property "requestSubmit" not found in prototype chain 1870 PASS HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type 1871 PASS HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError 1872 1872 PASS HTMLFormElement interface: document.createElement("form") must inherit property "reset()" with the proper type 1873 1873 PASS HTMLFormElement interface: document.createElement("form") must inherit property "checkValidity()" with the proper type -
trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt
r276777 r277257 1848 1848 PASS HTMLFormElement interface: attribute length 1849 1849 PASS HTMLFormElement interface: operation submit() 1850 FAIL HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) assert_own_property: interface prototype object missing non-static operation expected property "requestSubmit" missing 1850 PASS HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) 1851 1851 PASS HTMLFormElement interface: operation reset() 1852 1852 PASS HTMLFormElement interface: operation checkValidity() … … 1868 1868 PASS HTMLFormElement interface: document.createElement("form") must inherit property "length" with the proper type 1869 1869 PASS HTMLFormElement interface: document.createElement("form") must inherit property "submit()" with the proper type 1870 FAIL HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type assert_inherits: property "requestSubmit" not found in prototype chain 1871 FAIL HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError assert_inherits: property "requestSubmit" not found in prototype chain 1870 PASS HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type 1871 PASS HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError 1872 1872 PASS HTMLFormElement interface: document.createElement("form") must inherit property "reset()" with the proper type 1873 1873 PASS HTMLFormElement interface: document.createElement("form") must inherit property "checkValidity()" with the proper type -
trunk/LayoutTests/platform/wpe/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt
r276777 r277257 1848 1848 PASS HTMLFormElement interface: attribute length 1849 1849 PASS HTMLFormElement interface: operation submit() 1850 FAIL HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) assert_own_property: interface prototype object missing non-static operation expected property "requestSubmit" missing 1850 PASS HTMLFormElement interface: operation requestSubmit(optional HTMLElement?) 1851 1851 PASS HTMLFormElement interface: operation reset() 1852 1852 PASS HTMLFormElement interface: operation checkValidity() … … 1868 1868 PASS HTMLFormElement interface: document.createElement("form") must inherit property "length" with the proper type 1869 1869 PASS HTMLFormElement interface: document.createElement("form") must inherit property "submit()" with the proper type 1870 FAIL HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type assert_inherits: property "requestSubmit" not found in prototype chain 1871 FAIL HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError assert_inherits: property "requestSubmit" not found in prototype chain 1870 PASS HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(optional HTMLElement?)" with the proper type 1871 PASS HTMLFormElement interface: calling requestSubmit(optional HTMLElement?) on document.createElement("form") with too few arguments must throw TypeError 1872 1872 PASS HTMLFormElement interface: document.createElement("form") must inherit property "reset()" with the proper type 1873 1873 PASS HTMLFormElement interface: document.createElement("form") must inherit property "checkValidity()" with the proper type -
trunk/Source/WTF/ChangeLog
r277245 r277257 1 2021-05-10 Rob Buis <rbuis@igalia.com> 2 3 Implement <form>.requestSubmit() 4 https://bugs.webkit.org/show_bug.cgi?id=197958 5 6 Reviewed by Darin Adler. 7 8 Add requestSubmit as experimental feature, disabled by default. 9 10 * Scripts/Preferences/WebPreferencesExperimental.yaml: 11 1 12 2021-05-09 Darin Adler <darin@apple.com> 2 13 -
trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml
r277024 r277257 865 865 default: false 866 866 867 RequestSubmitEnabled: 868 type: bool 869 humanReadableName: "Form requestSubmit" 870 humanReadableDescription: "Form requestSubmit method" 871 defaultValue: 872 WebKitLegacy: 873 default: false 874 WebKit: 875 default: false 876 WebCore: 877 default: false 878 867 879 # FIXME: This is on by default in WebKit2. Perhaps we should consider turning it on for WebKitLegacy as well. 868 880 ResizeObserverEnabled: -
trunk/Source/WebCore/ChangeLog
r277255 r277257 1 2021-05-10 Rob Buis <rbuis@igalia.com> 2 3 Implement <form>.requestSubmit() 4 https://bugs.webkit.org/show_bug.cgi?id=197958 5 6 Reviewed by Darin Adler. 7 8 Implement the requestSubmit method as defined here [1]. 9 10 Behavior matches Chrome and Firefox. 11 12 [1] https://html.spec.whatwg.org/multipage/forms.html#dom-form-requestsubmit 13 14 Tests: imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit.html 15 imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/request-submit-activation.html 16 imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit-autofocus.html 17 18 * html/HTMLButtonElement.cpp: 19 (WebCore::HTMLButtonElement::defaultEventHandler): 20 (WebCore::HTMLButtonElement::isSubmitButton const): 21 * html/HTMLButtonElement.h: 22 * html/HTMLFormControlElement.h: 23 (WebCore::HTMLFormControlElement::isSubmitButton const): 24 * html/HTMLFormElement.cpp: 25 (WebCore::HTMLFormElement::submitImplicitly): 26 (WebCore::HTMLFormElement::submitIfPossible): 27 (WebCore::HTMLFormElement::requestSubmit): 28 (WebCore::HTMLFormElement::findSubmitButton): 29 (WebCore::HTMLFormElement::submit): 30 (WebCore::HTMLFormElement::effectiveTarget const): 31 (WebCore::HTMLFormElement::findSubmitter const): 32 (WebCore::HTMLFormElement::reportValidity): 33 (WebCore::HTMLFormElement::prepareForSubmission): Deleted. 34 (WebCore::HTMLFormElement::findSubmitButton const): Deleted. 35 * html/HTMLFormElement.h: 36 * html/HTMLFormElement.idl: 37 * html/HTMLInputElement.h: 38 * html/ImageInputType.cpp: 39 (WebCore::ImageInputType::handleDOMActivateEvent): 40 * html/ImageInputType.h: 41 * html/InputType.h: 42 (WebCore::InputType::isSubmitButton const): 43 * html/SubmitInputType.cpp: 44 (WebCore::SubmitInputType::handleDOMActivateEvent): 45 * loader/FormSubmission.cpp: 46 (WebCore::FormSubmission::create): 47 * loader/FormSubmission.h: 48 1 49 2021-05-09 Sam Weinig <weinig@apple.com> 2 50 -
trunk/Source/WebCore/html/HTMLButtonElement.cpp
r272247 r277257 139 139 if (m_type == SUBMIT) { 140 140 SetForScope<bool> activatedSubmitState(m_isActivatedSubmit, true); 141 currentForm-> prepareForSubmission(event);141 currentForm->submitIfPossible(&event); 142 142 } 143 143 … … 238 238 } 239 239 240 bool HTMLButtonElement::isSubmitButton() const 241 { 242 return m_type == SUBMIT; 243 } 244 240 245 } // namespace -
trunk/Source/WebCore/html/HTMLButtonElement.h
r259687 r277257 77 77 bool computeWillValidate() const final; 78 78 79 bool isSubmitButton() const final; 80 79 81 Type m_type; 80 82 bool m_isActivatedSubmit; -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r274029 r277257 127 127 WEBCORE_EXPORT AutofillData autofillData() const; 128 128 129 virtual bool isSubmitButton() const { return false; } 130 129 131 using Node::ref; 130 132 using Node::deref; -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r275103 r277257 46 46 #include "HTMLParserIdioms.h" 47 47 #include "HTMLTableElement.h" 48 #include "InputTypeNames.h" 48 49 #include "MIMETypeRegistry.h" 49 50 #include "MixedContentChecker.h" … … 211 212 // Older iOS apps using WebViews expect the behavior of auto submitting multi-input forms. 212 213 if (fromImplicitSubmissionTrigger && (submissionTriggerCount == 1 || document().settings().allowMultiElementImplicitSubmission())) 213 prepareForSubmission(event);214 submitIfPossible(&event); 214 215 } 215 216 … … 254 255 } 255 256 256 void HTMLFormElement:: prepareForSubmission(Event& event)257 void HTMLFormElement::submitIfPossible(Event* event, HTMLFormControlElement* submitter, FormSubmissionTrigger trigger) 257 258 { 258 259 if (!isConnected()) … … 269 270 270 271 if (shouldValidate) { 271 auto submitElement = findSubmitButton(&event);272 auto submitElement = makeRefPtr(submitter ? submitter : findSubmitter(event)); 272 273 if (submitElement && submitElement->formNoValidate()) 273 274 shouldValidate = false; … … 280 281 } 281 282 282 auto targetFrame = frame->loader().findFrameForNavigation(effectiveTarget( &event), &document());283 auto targetFrame = frame->loader().findFrameForNavigation(effectiveTarget(event, submitter), &document()); 283 284 if (!targetFrame) 284 285 targetFrame = frame.get(); … … 298 299 299 300 if (m_shouldSubmit) 300 submit( &event, true, true, NotSubmittedByJavaScript);301 submit(event, true, !submitter, trigger, submitter); 301 302 } 302 303 … … 309 310 { 310 311 submit(nullptr, false, UserGestureIndicator::processingUserGesture(), SubmittedByJavaScript); 312 } 313 314 ExceptionOr<void> HTMLFormElement::requestSubmit(HTMLElement* submitter) 315 { 316 // Update layout before processing form actions in case the style changes 317 // the form or button relationships. 318 document().updateLayoutIgnorePendingStylesheets(); 319 320 RefPtr<HTMLFormControlElement> control; 321 if (submitter) { 322 // https://html.spec.whatwg.org/multipage/forms.html#dom-form-requestsubmit 323 if (!is<HTMLFormControlElement>(submitter)) 324 return Exception { TypeError }; 325 control = downcast<HTMLFormControlElement>(submitter); 326 if (!control->isSubmitButton()) 327 return Exception { TypeError }; 328 if (control->form() != this) 329 return Exception { NotFoundError }; 330 } 331 332 submitIfPossible(nullptr, control.get(), SubmittedByJavaScript); 333 return { }; 311 334 } 312 335 … … 327 350 } 328 351 329 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger formSubmissionTrigger) 330 { 331 // The prepareForSubmission function also does this check, but we need to do it here 352 RefPtr<HTMLFormControlElement> HTMLFormElement::findSubmitButton(HTMLFormControlElement* submitter, bool needButtonActivation) 353 { 354 if (submitter) 355 return submitter; 356 if (!needButtonActivation) 357 return nullptr; 358 RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton; 359 for (auto& associatedElement : m_associatedElements) { 360 if (!is<HTMLFormControlElement>(*associatedElement)) 361 continue; 362 auto& control = downcast<HTMLFormControlElement>(*associatedElement); 363 if (control.isActivatedSubmit()) 364 return nullptr; 365 if (!firstSuccessfulSubmitButton && control.isSuccessfulSubmitButton()) 366 firstSuccessfulSubmitButton = &control; 367 } 368 return firstSuccessfulSubmitButton; 369 } 370 371 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger trigger, HTMLFormControlElement* submitter) 372 { 373 // The submitIfPossible function also does this check, but we need to do it here 332 374 // too, since there are some code paths that bypass that function. 333 375 if (!isConnected()) … … 347 389 m_wasUserSubmitted = processingUserGesture; 348 390 349 RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton; 350 bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button? 351 352 for (auto& associatedElement : m_associatedElements) { 353 if (!is<HTMLFormControlElement>(*associatedElement)) 354 continue; 355 if (needButtonActivation) { 356 HTMLFormControlElement& control = downcast<HTMLFormControlElement>(*associatedElement); 357 if (control.isActivatedSubmit()) 358 needButtonActivation = false; 359 else if (!firstSuccessfulSubmitButton && control.isSuccessfulSubmitButton()) 360 firstSuccessfulSubmitButton = &control; 361 } 362 } 363 364 if (needButtonActivation && firstSuccessfulSubmitButton) 391 auto firstSuccessfulSubmitButton = findSubmitButton(submitter, activateSubmitButton); 392 if (firstSuccessfulSubmitButton) 365 393 firstSuccessfulSubmitButton->setActivatedSubmit(true); 366 394 … … 368 396 369 397 auto shouldLockHistory = processingUserGesture ? LockHistory::No : LockHistory::Yes; 370 auto formSubmission = FormSubmission::create(*this, m_attributes, event, shouldLockHistory, formSubmissionTrigger);398 auto formSubmission = FormSubmission::create(*this, submitter, m_attributes, event, shouldLockHistory, trigger); 371 399 if (m_plannedFormSubmission) 372 400 m_plannedFormSubmission->cancel(); … … 386 414 frame->loader().submitForm(WTFMove(formSubmission)); 387 415 388 if ( needButtonActivation &&firstSuccessfulSubmitButton)416 if (firstSuccessfulSubmitButton) 389 417 firstSuccessfulSubmitButton->setActivatedSubmit(false); 390 418 … … 683 711 } 684 712 685 String HTMLFormElement::effectiveTarget(const Event* event ) const686 { 687 if (auto * submitButton = findSubmitButton(event)) {688 auto targetValue = submit Button->attributeWithoutSynchronization(formtargetAttr);713 String HTMLFormElement::effectiveTarget(const Event* event, HTMLFormControlElement* overrideSubmitter) const 714 { 715 if (auto submitter = makeRefPtr(overrideSubmitter ? overrideSubmitter : findSubmitter(event))) { 716 auto targetValue = submitter->attributeWithoutSynchronization(formtargetAttr); 689 717 if (!targetValue.isNull()) 690 718 return targetValue; … … 703 731 } 704 732 705 HTMLFormControlElement* HTMLFormElement::findSubmit Button(const Event* event) const733 HTMLFormControlElement* HTMLFormElement::findSubmitter(const Event* event) const 706 734 { 707 735 if (!event || !is<Node>(event->target())) … … 777 805 778 806 // Update layout before processing form actions in case the style changes 779 // the Form or button relationships.807 // the form or button relationships. 780 808 document().updateLayoutIgnorePendingStylesheets(); 781 809 -
trunk/Source/WebCore/html/HTMLFormElement.h
r273622 r277257 78 78 void removeImgElement(HTMLImageElement*); 79 79 80 void prepareForSubmission(Event&); // FIXME: This function doesn't only prepare, it sometimes calls submit() itself.80 void submitIfPossible(Event*, HTMLFormControlElement* = nullptr, FormSubmissionTrigger = NotSubmittedByJavaScript); 81 81 WEBCORE_EXPORT void submit(); 82 82 void submitFromJavaScript(); 83 ExceptionOr<void> requestSubmit(HTMLElement* submitter); 83 84 WEBCORE_EXPORT void reset(); 84 85 … … 102 103 103 104 String target() const final; 104 String effectiveTarget(const Event* ) const;105 String effectiveTarget(const Event*, HTMLFormControlElement* submitter) const; 105 106 106 107 bool wasUserSubmitted() const; 107 108 108 HTMLFormControlElement* findSubmit Button(const Event*) const;109 HTMLFormControlElement* findSubmitter(const Event*) const; 109 110 110 111 HTMLFormControlElement* defaultButton() const; … … 141 142 void copyNonAttributePropertiesFromElement(const Element&) final; 142 143 143 void submit(Event*, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger );144 void submit(Event*, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger, HTMLFormControlElement* submitter = nullptr); 144 145 145 146 unsigned formElementIndexWithFormAttribute(Element*, unsigned rangeStart, unsigned rangeEnd); … … 164 165 165 166 void resetAssociatedFormControlElements(); 167 168 RefPtr<HTMLFormControlElement> findSubmitButton(HTMLFormControlElement* submitter, bool needButtonActivation); 166 169 167 170 FormSubmission::Attributes m_attributes; -
trunk/Source/WebCore/html/HTMLFormElement.idl
r267813 r277257 41 41 42 42 [ImplementedAs=submitFromJavaScript] undefined submit(); 43 [EnabledBySetting=RequestSubmit] undefined requestSubmit(optional HTMLElement? submitter); 43 44 [CEReactions=NotNeeded] undefined reset(); 44 45 boolean checkValidity(); -
trunk/Source/WebCore/html/HTMLInputElement.h
r277001 r277257 123 123 bool isImageButton() const; 124 124 WEBCORE_EXPORT bool isNumberField() const; 125 bool isSubmitButton() const ;125 bool isSubmitButton() const final; 126 126 WEBCORE_EXPORT bool isTelephoneField() const; 127 127 WEBCORE_EXPORT bool isURLField() const; -
trunk/Source/WebCore/html/ImageInputType.cpp
r272180 r277257 104 104 105 105 if (auto currentForm = protectedElement->form()) 106 currentForm-> prepareForSubmission(event); // Event handlers can run.106 currentForm->submitIfPossible(&event); // Event handlers can run. 107 107 108 108 protectedElement->setActivatedSubmit(false); -
trunk/Source/WebCore/html/ImageInputType.h
r272180 r277257 57 57 unsigned width() const final; 58 58 59 IntPoint m_clickLocation; // Valid only during HTMLFormElement:: prepareForSubmission().59 IntPoint m_clickLocation; // Valid only during HTMLFormElement::submitIfPossible(). 60 60 }; 61 61 -
trunk/Source/WebCore/html/InputType.h
r273049 r277257 178 178 bool isRangeControl() const { return m_type == Type::Range; } 179 179 bool isSearchField() const { return m_type == Type::Search; } 180 bool isSubmitButton() const { return m_type == Type::Submit ; }180 bool isSubmitButton() const { return m_type == Type::Submit || m_type == Type::Image; } 181 181 bool isTelephoneField() const { return m_type == Type::Telephone; } 182 182 bool isTimeField() const { return m_type == Type::Time; } -
trunk/Source/WebCore/html/SubmitInputType.cpp
r272097 r277257 75 75 76 76 protectedElement->setActivatedSubmit(true); 77 if (auto currentForm = protectedElement->form())78 currentForm-> prepareForSubmission(event); // Event handlers can run.77 if (auto currentForm = makeRefPtr(protectedElement->form())) 78 currentForm->submitIfPossible(&event); // Event handlers can run. 79 79 protectedElement->setActivatedSubmit(false); 80 80 event.setDefaultHandled(); -
trunk/Source/WebCore/loader/FormSubmission.cpp
r261036 r277257 143 143 } 144 144 145 Ref<FormSubmission> FormSubmission::create(HTMLFormElement& form, const Attributes& attributes, Event* event, LockHistory lockHistory, FormSubmissionTrigger trigger)145 Ref<FormSubmission> FormSubmission::create(HTMLFormElement& form, HTMLFormControlElement* overrideSubmitter, const Attributes& attributes, Event* event, LockHistory lockHistory, FormSubmissionTrigger trigger) 146 146 { 147 147 auto copiedAttributes = attributes; 148 148 149 if (auto* submitButton = form.findSubmitButton(event)) { 149 auto submitter = makeRefPtr(overrideSubmitter ? overrideSubmitter : form.findSubmitter(event)); 150 if (submitter) { 150 151 AtomString attributeValue; 151 if (!(attributeValue = submit Button->attributeWithoutSynchronization(formactionAttr)).isNull())152 if (!(attributeValue = submitter->attributeWithoutSynchronization(formactionAttr)).isNull()) 152 153 copiedAttributes.parseAction(attributeValue); 153 if (!(attributeValue = submit Button->attributeWithoutSynchronization(formenctypeAttr)).isNull())154 if (!(attributeValue = submitter->attributeWithoutSynchronization(formenctypeAttr)).isNull()) 154 155 copiedAttributes.updateEncodingType(attributeValue); 155 if (!(attributeValue = submit Button->attributeWithoutSynchronization(formmethodAttr)).isNull())156 if (!(attributeValue = submitter->attributeWithoutSynchronization(formmethodAttr)).isNull()) 156 157 copiedAttributes.updateMethodType(attributeValue); 157 if (!(attributeValue = submit Button->attributeWithoutSynchronization(formtargetAttr)).isNull())158 if (!(attributeValue = submitter->attributeWithoutSynchronization(formtargetAttr)).isNull()) 158 159 copiedAttributes.setTarget(attributeValue); 159 160 } … … 215 216 auto formState = FormState::create(form, WTFMove(formValues), document, trigger); 216 217 217 return adoptRef(*new FormSubmission(copiedAttributes.method(), actionURL, form.effectiveTarget(event ), encodingType, WTFMove(formState), formData.releaseNonNull(), boundary, lockHistory, event));218 return adoptRef(*new FormSubmission(copiedAttributes.method(), actionURL, form.effectiveTarget(event, submitter.get()), encodingType, WTFMove(formState), formData.releaseNonNull(), boundary, lockHistory, event)); 218 219 } 219 220 -
trunk/Source/WebCore/loader/FormSubmission.h
r253799 r277257 41 41 class FormData; 42 42 class FrameLoadRequest; 43 class HTMLFormControlElement; 43 44 44 45 class FormSubmission : public RefCounted<FormSubmission>, public CanMakeWeakPtr<FormSubmission> { … … 76 77 }; 77 78 78 static Ref<FormSubmission> create(HTMLFormElement&, const Attributes&, Event*, LockHistory, FormSubmissionTrigger);79 static Ref<FormSubmission> create(HTMLFormElement&, HTMLFormControlElement* overrideSubmitter, const Attributes&, Event*, LockHistory, FormSubmissionTrigger); 79 80 80 81 void populateFrameLoadRequest(FrameLoadRequest&);
Note: See TracChangeset
for help on using the changeset viewer.