RESOLVED WONTFIX56497
Add client callback on seeing and audio and video tags
https://bugs.webkit.org/show_bug.cgi?id=56497
Summary Add client callback on seeing and audio and video tags
Shishir Agrawal
Reported 2011-03-16 16:05:20 PDT
Proposal: Add client callbacks when <audio> and <video> tags are encountered while parsing a page. This could be useful in multiple cases, and right now we would like to use for the pre-rendering use case in chrome.
Attachments
Patch (5.56 KB, patch)
2011-03-16 16:21 PDT, Shishir Agrawal
no flags
Patch (5.58 KB, patch)
2011-03-16 16:31 PDT, Shishir Agrawal
eric: review-
Patch (6.25 KB, patch)
2011-03-22 15:41 PDT, Shishir Agrawal
no flags
Patch (6.26 KB, patch)
2011-03-22 15:44 PDT, Shishir Agrawal
eric: review-
Shishir Agrawal
Comment 1 2011-03-16 16:21:53 PDT
WebKit Review Bot
Comment 2 2011-03-16 16:23:31 PDT
Attachment 85995 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebKit/chromium/ChangeLog:13: Line contains tab character. [whitespace/tab] [5] Source/WebKit/chromium/ChangeLog:15: Line contains tab character. [whitespace/tab] [5] Source/WebCore/ChangeLog:14: Line contains tab character. [whitespace/tab] [5] Source/WebCore/ChangeLog:16: Line contains tab character. [whitespace/tab] [5] Total errors found: 4 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
Shishir Agrawal
Comment 3 2011-03-16 16:31:10 PDT
Created attachment 85997 [details] Patch Fixing the tabs that showed up in the ChangeLog files causing style check failures.
Alexey Proskuryakov
Comment 4 2011-03-16 22:53:16 PDT
This doesn't sound good to me. What exactly do you need to do from such a callback? What's so special about audio and video that they need callbacks that other elements don't?
Eric Seidel (no email)
Comment 5 2011-03-17 04:16:55 PDT
Comment on attachment 85997 [details] Patch r- per alexey. Can't you ask the page via getElementsByTagName?
Shishir Agrawal
Comment 6 2011-03-17 11:59:58 PDT
The proposed change is to let the FrameLoaderClient know that the parser has encountered an audio / video tag (as against it being a javascript callback). We want to handle the audio and video case separately while prerendering because we dont want the audio / video to start playing until the page is visible to the user.
Eric Seidel (no email)
Comment 7 2011-03-17 12:07:27 PDT
There is a bool which is passed to elements during parsing (or at least was) called createdByParser. Would that be sufficient for your needs here? Are <audio> <video> really started immediately after parse? SVG animation, for example, is started when the containing </svg> close tag is seen and the SVGLoad event is fired IIRC.
Shishir Agrawal
Comment 8 2011-03-17 12:39:44 PDT
In the prerendering case, we want to be able to either cancel prerendering or pause media till a a prerendered tab is visible, if a page has an audio or video tag. Whether the tag is created by the parser or script is not important for us. Which also indicates that the patch does not cover the case where the elements are created by js. So I need to perhaps move the calls from the HTMLTreeBuilder to the Video element constructor. Also we would definitely like to know about the presence of such tags before the playback begins.
Shishir Agrawal
Comment 9 2011-03-22 15:41:45 PDT
Created attachment 86527 [details] Patch The callback will now happen for audio/video tags inserted by script too.
WebKit Review Bot
Comment 10 2011-03-22 15:44:28 PDT
Attachment 86527 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebCore/ChangeLog:11: Line contains tab character. [whitespace/tab] [5] Source/WebCore/ChangeLog:13: Line contains tab character. [whitespace/tab] [5] Total errors found: 2 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Shishir Agrawal
Comment 11 2011-03-22 15:44:28 PDT
Created attachment 86528 [details] Patch Fixing tab issue.
Alexey Proskuryakov
Comment 12 2011-03-22 16:10:33 PDT
It still feels hugely wrong to me to make client callbacks during normal parsing. If anything, you care about loading and playback here, not about parsing.
Eric Seidel (no email)
Comment 13 2011-03-22 16:10:48 PDT
Comment on attachment 86528 [details] Patch I still dont' understand why this is the right approach. Why do you need to tell the client that you saw specifically a video or audio tag? Why can't we just disconnect the media system while parsing or something?
Eric Seidel (no email)
Comment 14 2011-03-22 16:11:27 PDT
Comment on attachment 86528 [details] Patch This design just totally feels wrong.
James Robinson
Comment 15 2011-03-22 16:15:30 PDT
I have to agree - prerendering should perhaps interact with the media engines to tell them not to play video or audio, but there definitely shouldn't be any interaction with parsing or inserting tags into the DOM.
Shishir Agrawal
Comment 16 2011-04-13 10:50:45 PDT
Closing this bug, since we managed to get around it in the chrome codebase.
Note You need to log in before you can comment on or make changes to this bug.