RESOLVED FIXED 97800
Allow ports to override text track rendering style
https://bugs.webkit.org/show_bug.cgi?id=97800
Summary Allow ports to override text track rendering style
Eric Carlson
Reported 2012-09-27 10:00:30 PDT
Ports should be able to modify the style used when rendering captions and subtitles.
Attachments
Proposed patch (52.16 KB, patch)
2012-09-27 14:58 PDT, Eric Carlson
buildbot: commit-queue-
Updated patch (59.23 KB, patch)
2012-09-27 20:46 PDT, Eric Carlson
buildbot: commit-queue-
YAP (59.09 KB, patch)
2012-09-28 12:21 PDT, Eric Carlson
no flags
Patch (66.06 KB, patch)
2012-10-04 15:40 PDT, Jer Noble
no flags
Patch (66.19 KB, patch)
2012-10-05 17:07 PDT, Jer Noble
sam: review-
Updated patch (66.76 KB, patch)
2012-10-17 22:01 PDT, Eric Carlson
no flags
Updated patch (66.59 KB, patch)
2012-10-18 13:59 PDT, Eric Carlson
no flags
Another updated patch (66.56 KB, patch)
2012-10-18 15:04 PDT, Eric Carlson
no flags
Radar WebKit Bug Importer
Comment 1 2012-09-27 10:01:00 PDT
Eric Carlson
Comment 2 2012-09-27 14:58:20 PDT
Created attachment 166067 [details] Proposed patch
WebKit Review Bot
Comment 3 2012-09-27 15:00:21 PDT
Attachment 166067 [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/html/HTMLMediaElement.cpp:4193: Missing space before ( in if( [whitespace/parens] [5] Source/WebCore/rendering/RenderTheme.h:237: Missing space inside { }. [whitespace/braces] [5] Source/WebCore/rendering/RenderTheme.h:238: Missing space inside { }. [whitespace/braces] [5] Source/WebCore/html/shadow/MediaControlElements.cpp:49: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 4 in 24 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 4 2012-09-27 15:05:00 PDT
Comment on attachment 166067 [details] Proposed patch Attachment 166067 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/14031996
Early Warning System Bot
Comment 5 2012-09-27 15:05:26 PDT
Comment on attachment 166067 [details] Proposed patch Attachment 166067 [details] did not pass qt-ews (qt): Output: http://queues.webkit.org/results/14032968
Early Warning System Bot
Comment 6 2012-09-27 15:05:29 PDT
Comment on attachment 166067 [details] Proposed patch Attachment 166067 [details] did not pass qt-wk2-ews (qt): Output: http://queues.webkit.org/results/14035959
Build Bot
Comment 7 2012-09-27 15:23:54 PDT
Comment on attachment 166067 [details] Proposed patch Attachment 166067 [details] did not pass win-ews (win): Output: http://queues.webkit.org/results/14043674
WebKit Review Bot
Comment 8 2012-09-27 16:48:40 PDT
Comment on attachment 166067 [details] Proposed patch Attachment 166067 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/14059072 New failing tests: media/track/track-cue-rendering-horizontal.html media/track/track-cue-rendering-vertical.html media/track/track-cue-rendering.html
Eric Carlson
Comment 9 2012-09-27 20:46:41 PDT
Created attachment 166134 [details] Updated patch
Build Bot
Comment 10 2012-09-27 21:11:47 PDT
Comment on attachment 166134 [details] Updated patch Attachment 166134 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/14043799
Eric Carlson
Comment 11 2012-09-27 22:29:20 PDT
(In reply to comment #10) > (From update of attachment 166134 [details]) > Attachment 166134 [details] did not pass mac-ews (mac): > Output: http://queues.webkit.org/results/14043799 This is failing because the updated WKSI libraries aren't in the patch because they pushed it well beyond the maximum size.
Eric Carlson
Comment 12 2012-09-28 12:21:21 PDT
Jer Noble
Comment 13 2012-10-02 08:50:59 PDT
LGTM. Unofficial r+.
Anders Carlsson
Comment 14 2012-10-02 17:30:33 PDT
Comment on attachment 166291 [details] YAP View in context: https://bugs.webkit.org/attachment.cgi?id=166291&action=review > Source/WebCore/html/shadow/MediaControlElements.cpp:1340 > +void MediaControlTextTrackContainerElement::userCaptionPreferencesChanged() > +{ > + Page* page = document()->page(); > + if (!page) > + return; > + > + DEFINE_STATIC_LOCAL(KURL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23")); > + > + RenderTheme* theme = page->theme(); > + HTMLMediaElement* mediaElement = toParentMediaElement(this); > + > + mediaElement->setNeedsStyleRecalc(); > + > + page->group().removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL); > + > + if (!mediaElement->closedCaptionsVisible() && !theme->userHasCaptionPreferences()) > + return; > + > + String captionsOverrideStyleSheet = theme->captionsStyleSheetOverride(); > + if (captionsOverrideStyleSheet.isEmpty()) > + return; > + > + page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, adoptPtr(new Vector<String>), adoptPtr(new Vector<String>), > + InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments); > +} > + Not sure about the user style sheet code here. I'd prefer if someone familiar with that code would take a look at this. > Source/WebCore/html/shadow/MediaControlElements.cpp:1415 > + float fontSize = videoBox.size().height() * (document()->page()->theme()->captionFontSizeScale()); Can page be null here?
Sam Weinig
Comment 15 2012-10-02 17:31:07 PDT
Comment on attachment 166291 [details] YAP View in context: https://bugs.webkit.org/attachment.cgi?id=166291&action=review > Source/WebCore/html/HTMLMediaElement.cpp:4210 > + for (Node* node = firstChild(); node; node = node->nextSibling()) { It might be slightly safer to make node a RefPtr<Node> here. > Source/WebCore/html/HTMLMediaElement.cpp:4222 > + String kind = textTrack->kind(); > + > + if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captionsKeyword()) > + trackElement->setHasBeenConfigured(false); Should these be AtomicStrings? > Source/WebCore/html/shadow/MediaControlElements.cpp:1321 > + DEFINE_STATIC_LOCAL(KURL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23")); This would read slightly nicer at the top of the function. > Source/WebCore/rendering/RenderTheme.h:37 > > + > namespace WebCore { Unnecessary whitespace.
Jer Noble
Comment 16 2012-10-04 14:21:21 PDT
Since Eric is on vacation, I'll take his patch and make the suggested improvements by Anders and Sam below.
Jer Noble
Comment 17 2012-10-04 15:40:58 PDT
Silvia Pfeiffer
Comment 18 2012-10-04 18:34:21 PDT
Comment on attachment 167190 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=167190&action=review > Source/WebKit/mac/ChangeLog:25 > +2012-10-04 Eric Carlson <eric.carlson@apple.com> > + > + Allow ports to override text track rendering style > + https://bugs.webkit.org/show_bug.cgi?id=97800 > + <rdar://problem/12044964> > + > + Reviewed by NOBODY (OOPS!). > + > + Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!). > + > + * WebCoreSupport/WebSystemInterface.mm: > + (InitWebCoreSystemInterface): Initialize new WKSI function pointers. > + > +2012-09-27 Eric Carlson <eric.carlson@apple.com> > + > + Need a short description (OOPS!). > + Need the bug URL (OOPS!). > + > + Reviewed by NOBODY (OOPS!). > + > + Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!). > + > + * WebCoreSupport/WebSystemInterface.mm: > + (InitWebCoreSystemInterface): > + Two entries? You might want to clean up this ChangeLog. > Source/WebCore/html/HTMLMediaElement.cpp:3999 > configureTextTracks(); You might want to remove this, since markCaptionAndSubtitleTracksAsUnconfigured is already doing this as its last action.
Jer Noble
Comment 19 2012-10-05 14:56:53 PDT
WebKit Review Bot
Comment 20 2012-10-05 16:21:21 PDT
Re-opened since this is blocked by bug 98572
Julien Chaffraix
Comment 21 2012-10-05 16:31:33 PDT
Comment on attachment 167190 [details] Patch Looks like this change broke several platforms (not sure why none of the bots complained): * Most Mac ones (andersca fixed them in http://trac.webkit.org/changeset/130564) * Windows, here is the warning: 26>..\..\WebCore\rendering\RenderTheme.h(239): error C2220: warning treated as error - no 'object' file generated 26>..\..\WebCore\rendering\RenderTheme.h(239): warning C4305: 'return' : truncation from 'double' to 'float' This comes from this line: virtual float captionFontSizeScale() const { return 0.05; } Mostly the patch was landed with an r+ from a non-reviewer which was the reason for rolling out instead of fixing the build.
Jer Noble
Comment 22 2012-10-05 16:31:59 PDT
Comment on attachment 167190 [details] Patch Moving back to review? as I don't think Sylvia is technically a reviewer.
Jer Noble
Comment 23 2012-10-05 16:32:53 PDT
(In reply to comment #22) > (From update of attachment 167190 [details]) > Moving back to review? as I don't think Sylvia is technically a reviewer. I(In reply to comment #21) > (From update of attachment 167190 [details]) > Looks like this change broke several platforms (not sure why none of the bots complained): > > * Most Mac ones (andersca fixed them in http://trac.webkit.org/changeset/130564) > * Windows, here is the warning: > > 26>..\..\WebCore\rendering\RenderTheme.h(239): error C2220: warning treated as error - no 'object' file generated > 26>..\..\WebCore\rendering\RenderTheme.h(239): warning C4305: 'return' : truncation from 'double' to 'float' > > This comes from this line: > > virtual float captionFontSizeScale() const { return 0.05; } > I'll fix these and reupload for review.
Silvia Pfeiffer
Comment 24 2012-10-05 16:40:05 PDT
Oops, sorry. I was under the impression it already had an r+. No, I am not a reviewer yet.
Jer Noble
Comment 25 2012-10-05 17:07:49 PDT
Sam Weinig
Comment 26 2012-10-08 23:26:03 PDT
Comment on attachment 167418 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=167418&action=review > Source/WebKit/mac/ChangeLog:24 > +2012-10-05 Eric Carlson <eric.carlson@apple.com> > + > + Allow ports to override text track rendering style > + https://bugs.webkit.org/show_bug.cgi?id=97800 > + <rdar://problem/12044964> > + > + Reviewed by NOBODY (OOPS!). > + > + Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!). > + > + * WebCoreSupport/WebSystemInterface.mm: > + (InitWebCoreSystemInterface): Initialize new WKSI function pointers. > + > +2012-09-27 Eric Carlson <eric.carlson@apple.com> > + > + Need a short description (OOPS!). > + Need the bug URL (OOPS!). > + > + Reviewed by NOBODY (OOPS!). > + > + Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!). > + > + * WebCoreSupport/WebSystemInterface.mm: > + (InitWebCoreSystemInterface): Double Changelog! > Source/WebCore/html/HTMLMediaElement.cpp:557 > +#if ENABLE(VIDEO_TRACK) > + if (document()->page()) > + document()->page()->theme()->registerForCaptionPreferencesChangedCallbacks(this); > +#endif Are caption preferences only observable when in the render tree? In other words, why is attach the right place for this, rather than say, insertedIntoDocument()? > Source/WebCore/html/shadow/MediaControlElements.cpp:1315 > +void MediaControlTextTrackContainerElement::userCaptionPreferencesChanged() Does this change captions for all pages in the page group? If so, why does this need to be down in MediaControlTextTrackContainerElement. Should it be up in PageGroup instead? > Source/WebCore/html/shadow/MediaControlElements.cpp:1317 > + DEFINE_STATIC_LOCAL(KURL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23")); I think a comment explaining the weird URL would be useful.
Jer Noble
Comment 27 2012-10-09 09:01:19 PDT
Comment on attachment 167418 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=167418&action=review >> Source/WebKit/mac/ChangeLog:24 >> + (InitWebCoreSystemInterface): > > Double Changelog! Whoops, removed. >> Source/WebCore/html/HTMLMediaElement.cpp:557 >> +#endif > > Are caption preferences only observable when in the render tree? In other words, why is attach the right place for this, rather than say, insertedIntoDocument()? Changing preferences results in a new set of CSS style rules being applied to the captions. So yes, changes to the caption preferences only result in observable changes when the media element is in a render tree. >> Source/WebCore/html/shadow/MediaControlElements.cpp:1315 >> +void MediaControlTextTrackContainerElement::userCaptionPreferencesChanged() > > Does this change captions for all pages in the page group? If so, why does this need to be down in MediaControlTextTrackContainerElement. Should it be up in PageGroup instead? I don't know. It seems that way. But then again, that could get complicated, as the page group may media elements to register with it, so it can query whether or not the element's captions are visible, and so it can mark those media elements as setNeedsStyleRecalc(). However it does appear that there's no reason for this to be in MediaControlTextTrackContainerElement rather than HTMLMediaElement. >> Source/WebCore/html/shadow/MediaControlElements.cpp:1317 >> + DEFINE_STATIC_LOCAL(KURL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23")); > > I think a comment explaining the weird URL would be useful. Sho nuff.
Eric Carlson
Comment 28 2012-10-17 22:01:43 PDT
Created attachment 169339 [details] Updated patch
Silvia Pfeiffer
Comment 29 2012-10-17 23:57:39 PDT
I still think that in Source/WebCore/html/HTMLMediaElement.cpp, > void HTMLMediaElement::setClosedCaptions .. > markCaptionAndSubtitleTracksAsUnconfigured(); > configureTextTracks(); that configureTextTracks() call is surplus because markCaptionAndSubtitleTracksAsUnconfigured() already calls that function as its last action.
Eric Carlson
Comment 30 2012-10-18 07:41:22 PDT
(In reply to comment #29) > I still think that in Source/WebCore/html/HTMLMediaElement.cpp, > > > void HTMLMediaElement::setClosedCaptions > .. > > markCaptionAndSubtitleTracksAsUnconfigured(); > > configureTextTracks(); > > that configureTextTracks() call is surplus because markCaptionAndSubtitleTracksAsUnconfigured() already calls that function as its last action. Good point. Sorry, I overlooked your earlier comment.
Eric Carlson
Comment 31 2012-10-18 13:59:57 PDT
Created attachment 169469 [details] Updated patch Updated to fix the problem Silvia noted. Also includes the changes Sam suggested: the PageGroup now listens for notifications of user preference changes and updates the CSS override, and a media element registers with the PageGroup for preference notifications so it can re-evaluate which tracks should be enabled.
WebKit Review Bot
Comment 32 2012-10-18 14:06:05 PDT
Attachment 169469 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/medi..." exit_code: 1 Source/WebCore/page/CaptionUserPreferences.h:26: #ifndef header guard has wrong style, please use: CaptionUserPreferences_h [build/header_guard] [5] Source/WebCore/page/PageGroup.h:40: Code inside a namespace should not be indented. [whitespace/indent] [4] Source/WebCore/page/CaptionUserPreferencesMac.h:32: Alphabetical sorting problem. [build/include_order] [4] Source/WebCore/page/CaptionUserPreferencesMac.h:53: The parameter name "group" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 4 in 28 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eric Carlson
Comment 33 2012-10-18 15:04:03 PDT
Created attachment 169480 [details] Another updated patch Fixed the style-nits in my new code. This will fail the style-bot because the indentation in PageGroup.h is still wrong, but I just used the same indentation the file already has.
WebKit Review Bot
Comment 34 2012-10-18 15:06:38 PDT
Attachment 169480 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/medi..." exit_code: 1 Source/WebCore/page/PageGroup.h:40: Code inside a namespace should not be indented. [whitespace/indent] [4] Total errors found: 1 in 28 files If any of these errors are false positives, please file a bug against check-webkit-style.
Maciej Stachowiak
Comment 35 2012-10-23 03:00:09 PDT
Comment on attachment 169480 [details] Another updated patch Comments have been address afaict. r=me
WebKit Review Bot
Comment 36 2012-10-24 07:24:57 PDT
Comment on attachment 169480 [details] Another updated patch Clearing flags on attachment: 169480 Committed r132349: <http://trac.webkit.org/changeset/132349>
WebKit Review Bot
Comment 37 2012-10-24 07:25:04 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.