RESOLVED FIXED 68382
Add settings to control the availability of the Web Audio API to WebKit and WebKit2.
https://bugs.webkit.org/show_bug.cgi?id=68382
Summary Add settings to control the availability of the Web Audio API to WebKit and W...
Jer Noble
Reported 2011-09-19 13:19:40 PDT
Add settings to control the availability of the Web Audio API to WebKit and WebKit2.
Attachments
Patch (7.33 KB, patch)
2011-09-19 13:26 PDT, Jer Noble
no flags
Updated patch to address Darin's comment about the many lines of code dedicated to null-checks. (7.40 KB, patch)
2011-09-20 09:02 PDT, Jer Noble
no flags
Patch (7.38 KB, patch)
2011-09-20 10:16 PDT, Jer Noble
darin: review+
Jer Noble
Comment 1 2011-09-19 13:26:24 PDT
Darin Adler
Comment 2 2011-09-19 18:16:08 PDT
Comment on attachment 107908 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=107908&action=review > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:616 > #if ENABLE(WEB_AUDIO) > JSValue JSDOMWindow::webkitAudioContext(ExecState* exec) const > { > + Frame* frame = impl()->frame(); > + if (!frame) > + return jsUndefined(); > + Settings* settings = frame->settings(); > + if (!settings || !settings->webAudioEnabled()) > + return jsUndefined(); > return getDOMConstructor<JSAudioContextConstructor>(exec, this); > } > #endif I wish there was a tighter way to implement this so the null checks didn’t take so many lines of code. Does the webkitAudioContext property still show up if you iterate properties?
Jer Noble
Comment 3 2011-09-19 23:34:59 PDT
(In reply to comment #2) > (From update of attachment 107908 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=107908&action=review > > > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:616 > > #if ENABLE(WEB_AUDIO) > > JSValue JSDOMWindow::webkitAudioContext(ExecState* exec) const > > { > > + Frame* frame = impl()->frame(); > > + if (!frame) > > + return jsUndefined(); > > + Settings* settings = frame->settings(); > > + if (!settings || !settings->webAudioEnabled()) > > + return jsUndefined(); > > return getDOMConstructor<JSAudioContextConstructor>(exec, this); > > } > > #endif > > I wish there was a tighter way to implement this so the null checks didn’t take so many lines of code. I do as well. This same pattern is used a couple of other places in this file; perhaps it could be pulled out into a file-static helper function? I'll see what I can do. > Does the webkitAudioContext property still show up if you iterate properties? Just checked, and yes it still does. I used the same pattern as we're using for the WebGL setting, and the WebGL properties still appear on Window as well.
Jer Noble
Comment 4 2011-09-20 09:02:56 PDT
Created attachment 108009 [details] Updated patch to address Darin's comment about the many lines of code dedicated to null-checks.
Jer Noble
Comment 5 2011-09-20 10:09:21 PDT
Comment on attachment 108009 [details] Updated patch to address Darin's comment about the many lines of code dedicated to null-checks. Whoops, this will never work. Uploading a new patch soon.
Jer Noble
Comment 6 2011-09-20 10:16:48 PDT
Created attachment 108015 [details] Patch More LOC than the previous updated patch, but now with 100% fewer compile errors.
Darin Adler
Comment 7 2011-09-20 10:20:50 PDT
Comment on attachment 108015 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=108015&action=review I think this version of runtime-enabled properties is not good. The feature will still seem to be there for people who use best practices such as: if (webkitAudioContext in window) I think that needs to be resolved. I believe V8 currently has a better version of runtime-enabled features. > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:610 > + Frame* frame = impl()->frame(); > + Settings* settings = frame ? frame->settings() : 0; We could make a helper function to get settings and so remove one line of code from all of these.
Jer Noble
Comment 8 2011-09-20 10:48:16 PDT
(In reply to comment #7) > (From update of attachment 108015 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=108015&action=review > > I think this version of runtime-enabled properties is not good. The feature will still seem to be there for people who use best practices such as: > > if (webkitAudioContext in window) > > I think that needs to be resolved. I believe V8 currently has a better version of runtime-enabled features. Indeed. I think the only way to do this is to manually handle each runtime-enabled property in JSDOMWindow::getOwnPropertySlot(). But I think Sam might have an idea about this; I'll talk to him. > > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:610 > > + Frame* frame = impl()->frame(); > > + Settings* settings = frame ? frame->settings() : 0; > > We could make a helper function to get settings and so remove one line of code from all of these. Will do. Thanks!
Jer Noble
Comment 9 2011-09-21 16:05:52 PDT
Adam Roben (:aroben)
Comment 10 2011-09-21 16:09:13 PDT
What about WebKit1 on Windows?
Jer Noble
Comment 11 2011-09-21 16:17:10 PDT
(In reply to comment #10) > What about WebKit1 on Windows? Chris Rogers has already added a WebKit1 API for controlling this setting.
Note You need to log in before you can comment on or make changes to this bug.