RESOLVED FIXED174771
Make ExceptionCode a proper enumeration
https://bugs.webkit.org/show_bug.cgi?id=174771
Summary Make ExceptionCode a proper enumeration
Chris Dumez
Reported 2017-07-23 21:03:43 PDT
Make ExceptionCode a proper enumeration instead of a typedef to uint8_t.
Attachments
Patch (12.31 KB, patch)
2017-07-23 21:40 PDT, Chris Dumez
no flags
Patch (18.42 KB, patch)
2017-07-24 08:55 PDT, Chris Dumez
no flags
Patch (110.51 KB, patch)
2017-07-24 10:28 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2017-07-23 21:40:25 PDT
Sam Weinig
Comment 2 2017-07-23 21:59:21 PDT
Comment on attachment 316263 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=316263&action=review > Source/WebCore/Modules/fetch/FetchBody.h:52 > - void formData(FetchBodyOwner&, Ref<DeferredPromise>&& promise) { promise.get().reject(ExceptionCode { 0 }); } > + void formData(FetchBodyOwner&, Ref<DeferredPromise>&& promise) { promise.get().reject(NoException); } How about NOT_SUPPORTED_ERR instead? > Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:3574 > - ExceptionCode ec = 0; > + ExceptionCode ec = NoException; It would be nice to switch these to ExceptionOr<>. > Source/WebKitLegacy/win/DOMCoreClasses.cpp:824 > - WebCore::ExceptionCode ec = 0; > + WebCore::ExceptionCode ec = WebCore::NoException; Is this dead code? > Source/WebKitLegacy/win/WebView.cpp:6045 > - ExceptionCode ec = 0; > + ExceptionCode ec = NoException; Is this dead code?
Chris Dumez
Comment 3 2017-07-24 08:55:39 PDT
Darin Adler
Comment 4 2017-07-24 09:24:23 PDT
Comment on attachment 316292 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=316292&action=review > Source/WebCore/dom/Exception.h:29 > +#include "ExceptionCode.h" Because we added this include here we can remove includes of this file from tons of other places, perhaps almost everywhere else it is included. > Source/WebCore/dom/ExceptionCode.h:25 > +enum ExceptionCode { For future clean-up here: I don’t think any of the values in this enumeration need explicitly set values any more--no reason they need to match the legacy codes visible in JavaScript for example--although we do need to keep them in sync with the array inside DOMException.cpp. There’s no need for the 105, 106 thing, and no reason to leave empty slots where no-longer-used values were. I don’t think we need to include all these “introduced in xxx” comments either; not really important when they were introduced. I also think they should be in alphabetical order, not historical order. But we should still distinguish the ones that are web-exposed and the ones that are not. We should consider renaming each of these internal constants to use the style that matches the error names in the specification such as HierarchyRequestError rather than the legacy code name HIERARCHY_REQUEST_ERR. Once everything else is done I think we should consider getting rid of NoException and use optional instead when we need a null value.
Chris Dumez
Comment 5 2017-07-24 09:28:20 PDT
Comment on attachment 316292 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=316292&action=review >> Source/WebCore/dom/ExceptionCode.h:25 >> +enum ExceptionCode { > > For future clean-up here: > > I don’t think any of the values in this enumeration need explicitly set values any more--no reason they need to match the legacy codes visible in JavaScript for example--although we do need to keep them in sync with the array inside DOMException.cpp. There’s no need for the 105, 106 thing, and no reason to leave empty slots where no-longer-used values were. I don’t think we need to include all these “introduced in xxx” comments either; not really important when they were introduced. I also think they should be in alphabetical order, not historical order. But we should still distinguish the ones that are web-exposed and the ones that are not. > > We should consider renaming each of these internal constants to use the style that matches the error names in the specification such as HierarchyRequestError rather than the legacy code name HIERARCHY_REQUEST_ERR. > > Once everything else is done I think we should consider getting rid of NoException and use optional instead when we need a null value. > We should consider renaming each of these internal constants to use the style that matches the error names in the specification such as HierarchyRequestError rather than the legacy code name HIERARCHY_REQUEST_ERR. I had the same thought and this was my next patch :)
Chris Dumez
Comment 6 2017-07-24 10:28:36 PDT
Chris Dumez
Comment 7 2017-07-24 11:42:40 PDT
Comment on attachment 316302 [details] Patch Clearing flags on attachment: 316302 Committed r219831: <http://trac.webkit.org/changeset/219831>
Chris Dumez
Comment 8 2017-07-24 11:42:42 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.