Allow ports to override text track rendering style
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Oct 2012 14:24:43 +0000 (14:24 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Oct 2012 14:24:43 +0000 (14:24 +0000)
commitd588f0a8456189a33535071062fff91d8abc0944
tree81b514110ae632af7edc7bf4b52f70f0a9e70de6
parent2f5d29450e2e0c6ea5069b63de5871270f8bce4f
Allow ports to override text track rendering style
https://bugs.webkit.org/show_bug.cgi?id=97800
<rdar://problem/12044964>

Reviewed by Maciej Stachowiak.

Source/WebCore:

* WebCore.exp.in: Export new WebkitSystemInterface functions.
* WebCore.xcodeproj/project.pbxproj: Add CaptionUserPreferences.h, CaptionUserPreferencesMac.mm,
    and CaptionUserPreferencesMac.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::updateSizes): Get rid of unnecessary member
    variable. Get caption font scale from theme instead of hard coding.
* html/shadow/MediaControlElements.h:

* html/track/TextTrack.cpp:
(WebCore::TextTrack::TextTrack): Change attributes from String to AtomicString.
(WebCore::TextTrack::isValidKindKeyword): Ditto.
(WebCore::TextTrack::setKind): Ditto.
(WebCore::TextTrack::setMode): Ditto.
(WebCore::TextTrack::mode): Ditto.
* html/track/TextTrack.h:
(WebCore::TextTrack::create): Ditto.
(WebCore::TextTrack::kind): Ditto.
(WebCore::TextTrack::label): Ditto.
(WebCore::TextTrack::setLabel): Ditto.
(WebCore::TextTrack::language): Ditto.
(WebCore::TextTrack::setLanguage): Ditto.

* 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:

* page/CaptionUserPreferences.h: Added.
* page/CaptionUserPreferencesMac.h: Added.
* page/CaptionUserPreferencesMac.mm: Added.
(WebCore::userCaptionPreferencesChangedNotificationCallback):
(WebCore::CaptionUserPreferencesMac::CaptionUserPreferencesMac):
(WebCore::CaptionUserPreferencesMac::~CaptionUserPreferencesMac):
(WebCore::CaptionUserPreferencesMac::userHasCaptionPreferences): New, passthrough to WKSI function.
(WebCore::CaptionUserPreferencesMac::userPrefersCaptions): Ditto.
(WebCore::CaptionUserPreferencesMac::captionsWindowColor): Return Color with user's caption window color preference.
(WebCore::CaptionUserPreferencesMac::captionsBackgroundColor): Return Color with user's caption
    background color preference.
(WebCore::CaptionUserPreferencesMac::captionsTextColor): Return Color with user's caption text color preference.
(WebCore::CaptionUserPreferencesMac::captionsEdgeColorForTextColor): Return Color for text edge effect.
(WebCore::CaptionUserPreferencesMac::cssPropertyWithTextEdgeColor): Return String with CSS to set a text-shadow
    or webkit-text-stroke property.
(WebCore::CaptionUserPreferencesMac::cssColorProperty): Return a String with css to set a property
    with a color value.
(WebCore::CaptionUserPreferencesMac::captionsTextEdgeStyle): Return a String with css to style caption
    text with the user's preferred text edge stye.
(WebCore::CaptionUserPreferencesMac::captionsDefaultFont): Return a String with css to style caption
    text with the user's preferred font.
(WebCore::CaptionUserPreferencesMac::captionsStyleSheetOverride): Return a String with css to style captions
    with the user's preferred style.
(WebCore::CaptionUserPreferencesMac::captionFontSizeScale): Return the user's preferred caption font scale.
(WebCore::CaptionUserPreferencesMac::captionPreferencesChanged): Notify listeners of caption preference change.
(WebCore::CaptionUserPreferencesMac::registerForCaptionPreferencesChangedCallbacks): Add a caption preferences
    changes listener.
(WebCore::CaptionUserPreferencesMac::unregisterForCaptionPreferencesChangedCallbacks): Remove a caption preferences
    changes listener.
(WebCore::CaptionUserPreferencesMac::updateCaptionStyleSheetOveride): New, if theme has a captions style sheet override,
    inject it into the current page group, otherwise remove injected sheet.

* page/PageGroup.cpp:
(WebCore::PageGroup::captionPreferences):
(WebCore::PageGroup::registerForCaptionPreferencesChangedCallbacks): New, passthrough to platform specific function
    of the same name.
(WebCore::PageGroup::unregisterForCaptionPreferencesChangedCallbacks): Ditto.
(WebCore::PageGroup::userPrefersCaptions): Ditto.
(WebCore::PageGroup::userHasCaptionPreferences): Ditto.
(WebCore::PageGroup::captionFontSizeScale): Ditto.
* page/PageGroup.h:

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

Source/WebKit/mac:

* 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@132349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 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/track/TextTrack.cpp
Source/WebCore/html/track/TextTrack.h
Source/WebCore/html/track/TextTrackCue.cpp
Source/WebCore/html/track/TextTrackCue.h
Source/WebCore/page/CaptionUserPreferences.h [new file with mode: 0644]
Source/WebCore/page/CaptionUserPreferencesMac.h [new file with mode: 0644]
Source/WebCore/page/CaptionUserPreferencesMac.mm [new file with mode: 0644]
Source/WebCore/page/PageGroup.cpp
Source/WebCore/page/PageGroup.h
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.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