Allow ports to override text track rendering style
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Oct 2012 21:57:04 +0000 (21:57 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Oct 2012 21:57:04 +0000 (21:57 +0000)
commitd87e3ea1e8943b9b69cf95795db8e4126ea198df
tree38c0ff0c74ae2e5331296a056382eaa02db64ff8
parent88c8178fe5d35bb39627888723155854bcae49c9
Allow ports to override text track rendering style
https://bugs.webkit.org/show_bug.cgi?id=97800
<rdar://problem/12044964>

Patch by Eric Carlson <eric.carlson@apple.com> on 2012-10-04
Reviewed by Silvia Pfeiffer.

Source/WebCore:

* WebCore.exp.in: Export new WebkitSystemInterface functions.
* WebCore.xcodeproj/project.pbxproj: Add CaptionPreferencesChangedListener.h.

* css/mediaControls.css: Rearrange the caption CSS so it is possible to style the cue window,
    background, and text independently.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Initialize m_disableCaptions with theme->userPrefersCaptions().
(WebCore::HTMLMediaElement::attach): Register for caption preferences change callbacks.
(WebCore::HTMLMediaElement::detach): Unregister for caption preferences change callbacks.
(WebCore::HTMLMediaElement::userPrefersCaptions): Return theme->userPrefersCaptions().
(WebCore::HTMLMediaElement::userIsInterestedInThisTrackKind): Consider userPrefersCaptions().
(WebCore::HTMLMediaElement::setClosedCaptionsVisible): Move the code that marks all tracks as
    un-configured to markCaptionAndSubtitleTracksAsUnconfigured so it can be reused.
(WebCore::HTMLMediaElement::captionPreferencesChanged): New, force a reevaluation of all text tracks.
(WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): New, code moved from
    setClosedCaptionsVisible
* html/HTMLMediaElement.h: Inherit from CaptionPreferencesChangedListener.

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::userCaptionPreferencesChanged): New, if theme
    has a captions style sheet override, inject it into the current page group, otherwise
    remove injected sheet.
(WebCore::MediaControlTextTrackContainerElement::updateSizes): Get rid of unnecessary member
    variable. Get caption font scale from theme instead of hard coding.
* html/shadow/MediaControlElements.h:

* html/shadow/MediaControlRootElement.cpp:
(WebCore::MediaControlRootElement::userCaptionPreferencesChanged): New.
(WebCore::MediaControlRootElement::updateTextTrackDisplay):
* html/shadow/MediaControlRootElement.h: Add userCaptionPreferencesChanged, minor cleanup.

* html/shadow/MediaControls.h:
(WebCore::MediaControls::userCaptionPreferencesChanged): New.

* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCueBox::TextTrackCueBox): Set the shadow pseudo id.
(WebCore::TextTrackCueBox::textTrackCueBoxShadowPseudoId): New, class method to return the
    shadow pseudo id so it can be used elsewhere.
(WebCore::TextTrackCueBox::shadowPseudoId): Call textTrackCueBoxShadowPseudoId.
(WebCore::TextTrackCue::pastNodesShadowPseudoId): New, class method to return the
    shadow pseudo id so it can be used elsewhere.
(WebCore::TextTrackCue::futureNodesShadowPseudoId): Ditto.
(WebCore::TextTrackCue::updateDisplayTree):
* html/track/TextTrackCue.h:

* platform/mac/WebCoreSystemInterface.h: Updated.
* platform/mac/WebCoreSystemInterface.mm: Ditto.

* rendering/CaptionPreferencesChangedListener.h: Added.

* rendering/RenderTheme.h:
(WebCore::RenderTheme::userPrefersCaptions): New, default do-nothing implementation.
(WebCore::RenderTheme::userHasCaptionPreferences): Ditto.
(WebCore::RenderTheme::captionFontSizeScale): Ditto.
(WebCore::RenderTheme::captionsStyleSheetOverride): Ditto.
(WebCore::RenderTheme::registerForCaptionPreferencesChangedCallbacks): Ditto.
(WebCore::RenderTheme::unregisterForCaptionPreferencesChangedCallbacks): Ditto.

* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::userCaptionPreferencesChangedNotificationCallback): New, receives preference changed notifications.
(WebCore::RenderThemeMac::RenderThemeMac): Initialize m_listeningForCaptionPreferenceNotifications.
(WebCore::RenderThemeMac::~RenderThemeMac): Unregister for notifications if necessary.
(WebCore::RenderThemeMac::userHasCaptionPreferences): New, passthrough to WKSI function.
(WebCore::RenderThemeMac::userPrefersCaptions): Ditto.
(WebCore::RenderThemeMac::captionsWindowColor): Return Color with user's caption window color preference.
(WebCore::RenderThemeMac::captionsBackgroundColor): Return Color with user's caption
    background color preference.
(WebCore::RenderThemeMac::captionsTextColor): Return Color with user's caption text color preference.
(WebCore::RenderThemeMac::captionsEdgeColorForTextColor): Return Color for text edge effect.
(WebCore::RenderThemeMac::cssPropertyWithTextEdgeColor): Return String with CSS to set a text-shadow
    or webkit-text-stroke property.
(WebCore::RenderThemeMac::cssColorProperty): Return a String with css to set a property
    with a color value.
(WebCore::RenderThemeMac::captionsTextEdgeStyle): Return a String with css to style caption
    text with the user's preferred text edge stye.
(WebCore::RenderThemeMac::captionsDefaultFont): Return a String with css to style caption
    text with the user's preferred font.
(WebCore::RenderThemeMac::captionsStyleSheetOverride): Return a String with css to style captions
    with the user's preferred style.
(WebCore::RenderThemeMac::captionFontSizeScale): Return the user's preferred caption font scale.
(WebCore::RenderThemeMac::captionPreferencesChanged): Notify listeners of caption preference change.
(WebCore::RenderThemeMac::registerForCaptionPreferencesChangedCallbacks): Add a caption preferences
    changes listener.
(WebCore::RenderThemeMac::unregisterForCaptionPreferencesChangedCallbacks): Remove a caption preferences
    changes listener.

Source/WebKit/mac:

Add WCSI support for new WKSI caption functions.

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Initialize new WKSI function pointers.

Source/WebKit2:

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Initialize new WKSI function pointers.

WebKitLibraries:

Update WKSI header with SPI for getting the user caption appearance preferences.

* WebKitSystemInterface.h:

LayoutTests:

* media/track/track-cue-rendering-expected.txt: Update results for caption css changes.
* media/track/track-cue-rendering.html:
* platform/chromium/TestExpectations: Skip tests that need to be rebaselined.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130556 268f45cc-cd09-0410-ab3c-d52691b4dbfc
31 files changed:
LayoutTests/ChangeLog
LayoutTests/media/track/track-cue-rendering-expected.txt
LayoutTests/media/track/track-cue-rendering.html
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/mediaControls.css
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControlElements.h
Source/WebCore/html/shadow/MediaControlRootElement.cpp
Source/WebCore/html/shadow/MediaControlRootElement.h
Source/WebCore/html/shadow/MediaControls.h
Source/WebCore/html/track/TextTrack.cpp
Source/WebCore/html/track/TextTrack.h
Source/WebCore/html/track/TextTrackCue.cpp
Source/WebCore/html/track/TextTrackCue.h
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/rendering/CaptionPreferencesChangedListener.h [new file with mode: 0644]
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h