RESOLVED FIXED 226172
Implement form[method=dialog]
https://bugs.webkit.org/show_bug.cgi?id=226172
Summary Implement form[method=dialog]
Attachments
Patch (19.07 KB, patch)
2021-06-29 10:40 PDT, Tim Nguyen (:ntim)
no flags
Patch (15.07 KB, patch)
2021-06-29 11:55 PDT, Tim Nguyen (:ntim)
no flags
Patch (19.35 KB, patch)
2021-06-29 12:02 PDT, Tim Nguyen (:ntim)
no flags
Patch (19.33 KB, patch)
2021-06-29 12:05 PDT, Tim Nguyen (:ntim)
ews-feeder: commit-queue-
Patch (47.82 KB, patch)
2021-06-29 13:51 PDT, Tim Nguyen (:ntim)
no flags
Patch (49.21 KB, patch)
2021-06-29 14:02 PDT, Tim Nguyen (:ntim)
no flags
Patch (15.33 KB, patch)
2021-06-29 14:12 PDT, Tim Nguyen (:ntim)
no flags
Patch (49.50 KB, patch)
2021-06-29 14:16 PDT, Tim Nguyen (:ntim)
no flags
Patch (49.51 KB, patch)
2021-06-29 21:42 PDT, Tim Nguyen (:ntim)
no flags
Radar WebKit Bug Importer
Comment 1 2021-05-31 03:12:15 PDT
Tim Nguyen (:ntim)
Comment 2 2021-06-29 10:40:55 PDT
Chris Dumez
Comment 3 2021-06-29 10:54:19 PDT
Comment on attachment 432499 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432499&action=review > Source/WebCore/html/HTMLFormElement.cpp:421 > + HTMLDialogElement* dialog = ancestorsOfType<HTMLDialogElement>(*this).first(); Ref dialog = ancestorsOfType<HTMLDialogElement>(*this).first(); would be safer. > Source/WebCore/html/ImageInputType.cpp:220 > + return String::number(m_clickLocation.x()) + "," + String::number(m_clickLocation.y()); You probably want: return makeString(m_clickLocation.x(), ',', m_clickLocation.y()); for better perf. You'll likely need to include <wtf/text/StringConcatenateNumbers.h> > Source/WebCore/loader/FormSubmission.cpp:266 > + frameRequest.resourceRequest().setHTTPBody(WTFMove(m_formData)); Assuming m_formData can be used later on, you probably should use std::exchange(), not WTFMove(). Also, is it really OK to consume m_formData? Cannot populateFrameLoadRequest() be called several times? > Source/WebCore/loader/FormSubmission.h:48 > + enum class Method : int { Get, Post, Dialog }; int -> uint8_t > Source/WebCore/loader/FormSubmission.h:96 > + FormData& data() const { return *m_formData; } This looks dangerous, why is it safe?
Tim Nguyen (:ntim)
Comment 4 2021-06-29 11:22:58 PDT
(In reply to Chris Dumez from comment #3) > Comment on attachment 432499 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=432499&action=review > > > Source/WebCore/html/HTMLFormElement.cpp:421 > > + HTMLDialogElement* dialog = ancestorsOfType<HTMLDialogElement>(*this).first(); > > Ref dialog = ancestorsOfType<HTMLDialogElement>(*this).first(); > > would be safer. I've used RefPtr, since this can be null (when there are no ancestors), there's a check just below handling that case. > > Source/WebCore/html/ImageInputType.cpp:220 > > + return String::number(m_clickLocation.x()) + "," + String::number(m_clickLocation.y()); > > You probably want: > return makeString(m_clickLocation.x(), ',', m_clickLocation.y()); > > for better perf. > > You'll likely need to include <wtf/text/StringConcatenateNumbers.h> Done, thanks. > > Source/WebCore/loader/FormSubmission.h:48 > > + enum class Method : int { Get, Post, Dialog }; > > int -> uint8_t > Done. > > Source/WebCore/loader/FormSubmission.cpp:266 > > + frameRequest.resourceRequest().setHTTPBody(WTFMove(m_formData)); > > Assuming m_formData can be used later on, you probably should use > std::exchange(), not WTFMove(). > > Also, is it really OK to consume m_formData? Cannot > populateFrameLoadRequest() be called several times? > > > > Source/WebCore/loader/FormSubmission.h:96 > > + FormData& data() const { return *m_formData; } > > This looks dangerous, why is it safe? I mostly changed these bits because I needed m_formData to be optional to construct, I thought of using std::optional<Ref<>>, but it's not much cleaner. Happy to take any suggestions.
Tim Nguyen (:ntim)
Comment 5 2021-06-29 11:55:50 PDT
Chris Dumez
Comment 6 2021-06-29 12:02:39 PDT
Comment on attachment 432506 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432506&action=review r=me with changes. > Source/WebCore/html/HTMLFormElement.cpp:421 > + RefPtr<HTMLDialogElement> dialog = ancestorsOfType<HTMLDialogElement>(*this).first(); RefPtr<HTMLDialogElement> -> RefPtr > Source/WebCore/html/ImageInputType.cpp:220 > + return String::number(m_clickLocation.x()) + "," + String::number(m_clickLocation.y()); As mentioned earlier, this is inefficient and should be using makeString(), NOT String::number().
Tim Nguyen (:ntim)
Comment 7 2021-06-29 12:02:55 PDT
Chris Dumez
Comment 8 2021-06-29 12:04:42 PDT
Comment on attachment 432507 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432507&action=review > Source/WebCore/html/HTMLFormElement.cpp:421 > + RefPtr<HTMLDialogElement> dialog = ancestorsOfType<HTMLDialogElement>(*this).first(); nit: RefPtr<HTMLDialogElement> -> RefPtr (with C++17, the compiler should be able to deduce the type).
Tim Nguyen (:ntim)
Comment 9 2021-06-29 12:05:42 PDT
Chris Dumez
Comment 10 2021-06-29 12:08:03 PDT
Comment on attachment 432509 [details] Patch Let's make sure the bots are happy before landing.
Chris Dumez
Comment 11 2021-06-29 12:57:56 PDT
Looks like imported/w3c/web-platform-tests/html/dom/reflection-forms.html needs rebaselining.
Darin Adler
Comment 12 2021-06-29 13:03:43 PDT
Comment on attachment 432509 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432509&action=review > Source/WebCore/loader/FormSubmission.cpp:184 > + String returnValue = submitter ? submitter->resultForDialogSubmit() : ""; emptyString() is more efficient than “” when passing a String. Null string is even more efficient if it’s acceptable. > Source/WebCore/loader/FormSubmission.h:55 > + static ASCIILiteral methodString(Method method) When function body becomes multi-line like this we prefer to put the inline function definition outside the class definition, at the namespace level to preserve readability of the class definition.
Tim Nguyen (:ntim)
Comment 13 2021-06-29 13:51:46 PDT
Chris Dumez
Comment 14 2021-06-29 13:53:21 PDT
Comment on attachment 432521 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=432521&action=review > Source/WebCore/loader/FormSubmission.cpp:184 > + String returnValue = submitter ? submitter->resultForDialogSubmit() : ""; Darin recommended: String returnValue = submitter ? submitter->resultForDialogSubmit() : emptyString(); As it is more efficient. > Source/WebCore/loader/FormSubmission.h:55 > + static ASCIILiteral methodString(Method method) Ditto, please see Darin's feedback about moving this outside the class.
Tim Nguyen (:ntim)
Comment 15 2021-06-29 14:02:50 PDT
Chris Dumez
Comment 16 2021-06-29 14:11:48 PDT
Comment on attachment 432524 [details] Patch Doesn't address Darin's feedback.
Tim Nguyen (:ntim)
Comment 17 2021-06-29 14:12:17 PDT
Tim Nguyen (:ntim)
Comment 18 2021-06-29 14:16:11 PDT
Chris Dumez
Comment 19 2021-06-29 19:28:55 PDT
Comment on attachment 432531 [details] Patch Looks like the baseline for imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-form-submission.html on iOS-wk2 is missing a blank line, causing a failure on iOS-EWS.
Tim Nguyen (:ntim)
Comment 20 2021-06-29 21:42:54 PDT
EWS
Comment 21 2021-06-29 22:38:03 PDT
Committed r279401 (239266@main): <https://commits.webkit.org/239266@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 432566 [details].
Note You need to log in before you can comment on or make changes to this bug.