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)
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

index e7351df..4ffbeb3 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-24  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 Maciej Stachowiak.
+
+        * 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.
+
 2012-10-24  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Introduce workspace provider as a content providing backend for project.
index c06fbd0..36c7f47 100644 (file)
@@ -49,7 +49,7 @@ RUN(video.height = 1440)
 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '72px') OK
 
 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontFamily == 'sans-serif') OK
-EXPECTED (getComputedStyle(textTrackDisplayElement(video)).color == 'rgba(255, 255, 255, 0)') OK
+EXPECTED (getComputedStyle(textTrackDisplayElement(video)).color == 'rgb(255, 255, 255)') OK
 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor == 'rgba(0, 0, 0, 0.796875)'), OBSERVED 'rgba(0, 0, 0, 0.8)' FAIL
 END OF TEST
 
index 5a7e8e6..cdf1b08 100644 (file)
@@ -32,7 +32,7 @@
             testFontSize(2560, 1440);
 
             testExpected("getComputedStyle(textTrackDisplayElement(video)).fontFamily", "sans-serif");
-            testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgba(255, 255, 255, 0)");
+            testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgb(255, 255, 255)");
             testExpected("getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor", "rgba(0, 0, 0, 0.796875)");
 
             endTest();
index 2b22f7d..98d6b8d 100644 (file)
@@ -3984,6 +3984,11 @@ webkit.org/b/95121 fast/borders/border-image-side-reduction.html [ ImageOnlyFail
 # css3-conditionals support is not yet enabled.
 webkit.org/b/86146 css3/supports.html
 
+ # Require rebaselining after webkit.org/b/97800
+ webkit.org/b/89167 media/track/track-cue-rendering-horizontal.html [ Failure ]
+ webkit.org/b/89167 media/track/track-cue-rendering-vertical.html [ Failure ]
+ webkit.org/b/89167 media/track/track-cue-rendering.html [ Failure ]
+
 webkit.org/b/98686 editing/pasteboard/data-transfer-items.html [ Failure ]
 
 webkit.org/b/23166 [ Android Mac Win ] fast/css/background-clip-radius-values.html [ Pass ImageOnlyFailure ]
index 00201ed..da10ff3 100644 (file)
@@ -1,3 +1,106 @@
+2012-10-24  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 Maciej Stachowiak.
+
+        * 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.
+
 2012-10-24  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Introduce workspace provider as a content providing backend for project.
index 98bb48d..4619a25 100644 (file)
@@ -2625,3 +2625,18 @@ __ZN7WebCore27AlternativeTextUIController16showAlternativesEP6NSViewRKNS_9FloatR
 __ZN7WebCore24TextAlternativeWithRangeC1EP18NSTextAlternatives8_NSRange
 __ZN7WebCore32collectDictationTextAlternativesEP18NSAttributedStringRN3WTF6VectorINS_24TextAlternativeWithRangeELm0EEE
 #endif
+
+#if ENABLE(VIDEO_TRACK)
+_wkCaptionAppearanceHasUserPreferences
+_wkCaptionAppearanceShowCaptionsWhenAvailable
+_wkCaptionAppearanceCopyForegroundColor
+_wkCaptionAppearanceCopyBackgroundColor
+_wkCaptionAppearanceCopyWindowColor
+_wkCaptionAppearanceGetForegroundOpacity
+_wkCaptionAppearanceGetBackgroundOpacity
+_wkCaptionAppearanceGetWindowOpacity
+_wkCaptionAppearanceCopyFontForStyle
+_wkCaptionAppearanceGetRelativeCharacterSize
+_wkCaptionAppearanceGetTextEdgeStyle
+_wkCaptionAppearanceGetSettingsChangedNotification
+#endif
index 6c15856..ad3c0e5 100644 (file)
                07846342145B151A00A58DF1 /* JSTrackEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07846340145B151A00A58DF1 /* JSTrackEvent.cpp */; };
                07846343145B151A00A58DF1 /* JSTrackEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 07846341145B151A00A58DF1 /* JSTrackEvent.h */; };
                07846385145B1B8E00A58DF1 /* JSTrackCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 07846384145B1B8E00A58DF1 /* JSTrackCustom.h */; };
+               079D0868162F20E800DB8658 /* CaptionUserPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 079D0867162F20E800DB8658 /* CaptionUserPreferences.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               079D086B162F21F900DB8658 /* CaptionUserPreferencesMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 079D0869162F21F900DB8658 /* CaptionUserPreferencesMac.h */; };
+               079D086C162F21F900DB8658 /* CaptionUserPreferencesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 079D086A162F21F900DB8658 /* CaptionUserPreferencesMac.mm */; };
                07A6D1EB1491137700051D0C /* MediaFragmentURIParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A6D1E91491137700051D0C /* MediaFragmentURIParser.cpp */; };
                07A6D1EC1491137700051D0C /* MediaFragmentURIParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 07A6D1EA1491137700051D0C /* MediaFragmentURIParser.h */; };
                07B0113F1032242200FBDC33 /* AccessibilityMediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */; };
                07846340145B151A00A58DF1 /* JSTrackEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTrackEvent.cpp; sourceTree = "<group>"; };
                07846341145B151A00A58DF1 /* JSTrackEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTrackEvent.h; sourceTree = "<group>"; };
                07846384145B1B8E00A58DF1 /* JSTrackCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTrackCustom.h; sourceTree = "<group>"; };
+               079D0867162F20E800DB8658 /* CaptionUserPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CaptionUserPreferences.h; sourceTree = "<group>"; };
+               079D0869162F21F900DB8658 /* CaptionUserPreferencesMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CaptionUserPreferencesMac.h; sourceTree = "<group>"; };
+               079D086A162F21F900DB8658 /* CaptionUserPreferencesMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CaptionUserPreferencesMac.mm; sourceTree = "<group>"; };
                079F5E4B0F3BEBEA005E0782 /* MediaPlayerPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlayerPrivate.h; sourceTree = "<group>"; };
                07A6D1E91491137700051D0C /* MediaFragmentURIParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFragmentURIParser.cpp; sourceTree = "<group>"; };
                07A6D1EA1491137700051D0C /* MediaFragmentURIParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaFragmentURIParser.h; sourceTree = "<group>"; };
                                BC124EE40C2641CD009E2349 /* BarInfo.cpp */,
                                BC124EE50C2641CD009E2349 /* BarInfo.h */,
                                BC124EE60C2641CD009E2349 /* BarInfo.idl */,
+                               079D0867162F20E800DB8658 /* CaptionUserPreferences.h */,
+                               079D0869162F21F900DB8658 /* CaptionUserPreferencesMac.h */,
+                               079D086A162F21F900DB8658 /* CaptionUserPreferencesMac.mm */,
                                14D8238A0AF92DF60004F057 /* Chrome.cpp */,
                                14D823500AF92A790004F057 /* Chrome.h */,
                                14D824060AF93AEB0004F057 /* ChromeClient.h */,
                                49C7B9DD1042D32F0009D447 /* CanvasRenderingContext.h in Headers */,
                                49484FCB102CF23C00187DD3 /* CanvasRenderingContext2D.h in Headers */,
                                49484FCE102CF23C00187DD3 /* CanvasStyle.h in Headers */,
+                               079D0868162F20E800DB8658 /* CaptionUserPreferences.h in Headers */,
+                               079D086B162F21F900DB8658 /* CaptionUserPreferencesMac.h in Headers */,
                                6550B69E099DF0270090D781 /* CDATASection.h in Headers */,
                                97BC69DD1505F076001B74AC /* ChangeVersionWrapper.h in Headers */,
                                FD315FFF12B0267600C1A359 /* ChannelMergerNode.h in Headers */,
                                49C7B9DC1042D32F0009D447 /* CanvasRenderingContext.cpp in Sources */,
                                49484FCA102CF23C00187DD3 /* CanvasRenderingContext2D.cpp in Sources */,
                                49484FCD102CF23C00187DD3 /* CanvasStyle.cpp in Sources */,
+                               079D086C162F21F900DB8658 /* CaptionUserPreferencesMac.mm in Sources */,
                                6550B69D099DF0270090D781 /* CDATASection.cpp in Sources */,
                                97BC69DC1505F076001B74AC /* ChangeVersionWrapper.cpp in Sources */,
                                FD315FFE12B0267600C1A359 /* ChannelMergerNode.cpp in Sources */,
index 81b0e16..6df0340 100644 (file)
@@ -216,7 +216,7 @@ video::-webkit-media-text-track-container {
     font-size: 22px;
     font-family: sans-serif;
     text-align: center;
-    color: rgba(255, 255, 255, 0);
+    color: rgba(255, 255, 255, 1);
 
     letter-spacing: normal;
     word-spacing: normal;
@@ -234,8 +234,6 @@ video::-webkit-media-text-track-past-nodes {
 
     background-color: rgba(0, 0, 0, 0.8);
     padding: 2px 2px;
-
-    white-space: pre-wrap;
 }
 
 video::-webkit-media-text-track-future-nodes {
@@ -246,11 +244,10 @@ video::-webkit-media-text-track-future-nodes {
 
     margin-left: -2px;
     padding: 2px 2px 2px 0px;
-
-    white-space: pre-wrap;
 }
 
 video::-webkit-media-text-track-display {
     position: absolute;
-    color: rgba(255, 255, 255, 1);
+    overflow: hidden;
+    white-space: pre-wrap;
 }
index e7c3df5..97fe95b 100644 (file)
@@ -69,6 +69,7 @@
 #include "MIMETypeRegistry.h"
 #include "NodeRenderingContext.h"
 #include "Page.h"
+#include "PageGroup.h"
 #include "RenderVideo.h"
 #include "RenderView.h"
 #include "ScriptController.h"
@@ -281,6 +282,14 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
 
     setHasCustomCallbacks();
     addElementToDocumentMap(this, document);
+
+#if ENABLE(VIDEO_TRACK)
+    if (document->page()) {
+        PageGroup& group = document->page()->group();
+        if (group.userHasCaptionPreferences())
+            m_disableCaptions = !group.userPrefersCaptions();
+    }
+#endif
 }
 
 HTMLMediaElement::~HTMLMediaElement()
@@ -541,6 +550,20 @@ void HTMLMediaElement::attach()
             frame->loader()->client()->hideMediaPlayerProxyPlugin(m_proxyWidget.get());
     }
 #endif
+
+#if ENABLE(VIDEO_TRACK)
+    if (document()->page())
+        document()->page()->group().registerForCaptionPreferencesChangedCallbacks(this);
+#endif
+}
+
+void HTMLMediaElement::detach()
+{
+#if ENABLE(VIDEO_TRACK)
+    if (document()->page())
+        document()->page()->group().unregisterForCaptionPreferencesChangedCallbacks(this);
+#endif
+    HTMLElement::detach();
 }
 
 void HTMLMediaElement::didRecalcStyle(StyleChange)
@@ -2812,28 +2835,30 @@ void HTMLMediaElement::willRemoveTrack(HTMLTrackElement* trackElement)
         m_textTracksWhenResourceSelectionBegan.remove(index);
 }
 
-bool HTMLMediaElement::userIsInterestedInThisLanguage(const String&) const
+bool HTMLMediaElement::userPrefersCaptions() const
 {
-    // FIXME: check the user's language preference - bugs.webkit.org/show_bug.cgi?id=74121
-    return true;
+    Page* page = document()->page();
+    if (!page)
+        return false;
+
+    PageGroup& group = page->group();
+    return group.userHasCaptionPreferences() && group.userPrefersCaptions();
 }
 
 bool HTMLMediaElement::userIsInterestedInThisTrackKind(String kind) const
 {
-    // If ... the user has indicated an interest in having a track with this text track kind, text track language, ... 
     if (m_disableCaptions)
         return false;
 
     Settings* settings = document()->settings();
-    if (!settings)
-        return false;
+    bool userPrefersCaptionsOrSubtitles = m_closedCaptionsVisible || userPrefersCaptions();
 
     if (kind == TextTrack::subtitlesKeyword())
-        return settings->shouldDisplaySubtitles() || m_closedCaptionsVisible;
+        return (settings && settings->shouldDisplaySubtitles()) || userPrefersCaptionsOrSubtitles;
     if (kind == TextTrack::captionsKeyword())
-        return settings->shouldDisplayCaptions() || m_closedCaptionsVisible;
+        return (settings && settings->shouldDisplayCaptions()) || userPrefersCaptionsOrSubtitles;
     if (kind == TextTrack::descriptionsKeyword())
-        return settings->shouldDisplayTextDescriptions() || m_closedCaptionsVisible;
+        return settings && settings->shouldDisplayTextDescriptions();
 
     return false;
 }
@@ -3998,22 +4023,8 @@ void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
 #if ENABLE(VIDEO_TRACK)
     if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) {
         m_disableCaptions = !m_closedCaptionsVisible;
-        
-        // Mark all track elements as not "configured" so that configureTextTracks()
-        // will reconsider which tracks to display in light of new user preferences
-        // (e.g. default tracks should not be displayed if the user has turned off
-        // captions and non-default tracks should be displayed based on language
-        // preferences if the user has turned captions on).
-        for (Node* node = firstChild(); node; node = node->nextSibling()) {
-            if (!node->hasTagName(trackTag))
-                continue;
-            HTMLTrackElement* trackElement = static_cast<HTMLTrackElement*>(node);
-            if (trackElement->kind() == TextTrack::captionsKeyword()
-                || trackElement->kind() == TextTrack::subtitlesKeyword())
-                trackElement->setHasBeenConfigured(false);
-        }
 
-        configureTextTracks();
+        markCaptionAndSubtitleTracksAsUnconfigured();
     }
 #else
     if (hasMediaControls())
@@ -4201,6 +4212,39 @@ void HTMLMediaElement::updateClosedCaptionsControls()
             mediaControls()->updateTextTrackDisplay();
     }
 }
+
+void HTMLMediaElement::captionPreferencesChanged()
+{
+    if (!isVideo())
+        return;
+
+    markCaptionAndSubtitleTracksAsUnconfigured();
+}
+
+void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
+{
+    // Mark all track elements as not "configured" so that configureTextTracks()
+    // will reconsider which tracks to display in light of new user preferences
+    // (e.g. default tracks should not be displayed if the user has turned off
+    // captions and non-default tracks should be displayed based on language
+    // preferences if the user has turned captions on).
+    for (RefPtr<Node> node = firstChild(); node; node = node->nextSibling()) {
+        if (!node->hasTagName(trackTag))
+            continue;
+        
+        HTMLTrackElement* trackElement = static_cast<HTMLTrackElement*>(node.get());
+        RefPtr<TextTrack> textTrack = trackElement->track();
+        if (!textTrack)
+            continue;
+        
+        String kind = textTrack->kind();
+
+        if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captionsKeyword())
+            trackElement->setHasBeenConfigured(false);
+    }
+    configureTextTracks();
+}
+
 #endif
 
 void* HTMLMediaElement::preDispatchEventHandler(Event* event)
index b698c6b..c289fff 100644 (file)
@@ -40,6 +40,7 @@
 #endif
 
 #if ENABLE(VIDEO_TRACK)
+#include "CaptionUserPreferences.h"
 #include "PODIntervalTree.h"
 #include "TextTrack.h"
 #include "TextTrackCue.h"
@@ -78,7 +79,7 @@ typedef Vector<CueIntervalTree::IntervalType> CueList;
 
 class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, public MediaPlayerSupportsTypeClient, private MediaCanStartListener, public ActiveDOMObject, public MediaControllerInterface
 #if ENABLE(VIDEO_TRACK)
-    , private TextTrackClient
+    , private TextTrackClient, private CaptionPreferencesChangedListener
 #endif
 {
 public:
@@ -240,6 +241,7 @@ public:
     void configureTextTracks();
     void configureTextTrackGroup(const TrackGroup&) const;
 
+    bool userPrefersCaptions() const;
     bool userIsInterestedInThisTrackKind(String) const;
     bool textTracksAreReady() const;
     void configureTextTrackDisplay();
@@ -325,7 +327,8 @@ protected:
     virtual void parseAttribute(const Attribute&) OVERRIDE;
     virtual void finishParsingChildren();
     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
-    virtual void attach();
+    virtual void attach() OVERRIDE;
+    virtual void detach() OVERRIDE;
 
     virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE;
 
@@ -474,12 +477,14 @@ private:
 
 #if ENABLE(VIDEO_TRACK)
     void updateActiveTextTrackCues(float);
-    bool userIsInterestedInThisLanguage(const String&) const;
     HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const;
 
     bool ignoreTrackDisplayUpdateRequests() const { return m_ignoreTrackDisplayUpdate > 0; }
     void beginIgnoringTrackDisplayUpdateRequests() { ++m_ignoreTrackDisplayUpdate; }
     void endIgnoringTrackDisplayUpdateRequests() { ASSERT(m_ignoreTrackDisplayUpdate); --m_ignoreTrackDisplayUpdate; }
+
+    void markCaptionAndSubtitleTracksAsUnconfigured();
+    virtual void captionPreferencesChanged() OVERRIDE;
 #endif
 
     // These "internal" functions do not check user gesture restrictions.
index ae3b18b..9064660 100644 (file)
 #include "HTMLVideoElement.h"
 #include "LayoutRepainter.h"
 #include "LocalizedStrings.h"
+#include "MediaControlRootElement.h"
 #include "MediaControls.h"
 #include "MouseEvent.h"
 #include "Page.h"
+#include "PageGroup.h"
 #include "RenderDeprecatedFlexibleBox.h"
 #include "RenderInline.h"
 #include "RenderMedia.h"
@@ -1383,22 +1385,18 @@ void MediaControlTextTrackContainerElement::updateDisplay()
     hasChildNodes() ? show() : hide();
 }
 
-static const float mimimumFontSize = 16;
-static const float videoHeightFontSizePercentage = .05;
-static const float trackBottomMultiplier = .9;
-
 void MediaControlTextTrackContainerElement::updateSizes()
 {
     HTMLMediaElement* mediaElement = toParentMediaElement(this);
     if (!mediaElement || !mediaElement->renderer() || !mediaElement->renderer()->isVideo())
         return;
 
-    IntRect videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
-    if (m_videoDisplaySize == videoBox)
+    if (!document()->page())
         return;
-    m_videoDisplaySize = videoBox;
 
-    float fontSize = m_videoDisplaySize.size().height() * videoHeightFontSizePercentage;
+    IntRect videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
+
+    float fontSize = videoBox.size().height() * (document()->page()->group().captionFontSizeScale());
     if (fontSize != m_fontSize) {
         m_fontSize = fontSize;
         setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
index 120fce7..986a3f5 100644 (file)
@@ -94,7 +94,7 @@ const AtomicString& TextTrack::showingKeyword()
     return ended;
 }
 
-TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, const String& kind, const String& label, const String& language, TextTrackType type)
+TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType type)
     : TrackBase(context, TrackBase::TextTrack)
     , m_cues(0)
     , m_mediaElement(0)
@@ -117,7 +117,7 @@ TextTrack::~TextTrack()
     clearClient();
 }
 
-bool TextTrack::isValidKindKeyword(const String& value)
+bool TextTrack::isValidKindKeyword(const AtomicString& value)
 {
     if (equalIgnoringCase(value, subtitlesKeyword()))
         return true;
@@ -133,7 +133,7 @@ bool TextTrack::isValidKindKeyword(const String& value)
     return false;
 }
 
-void TextTrack::setKind(const String& kind)
+void TextTrack::setKind(const AtomicString& kind)
 {
     String oldKind = m_kind;
 
@@ -146,7 +146,7 @@ void TextTrack::setKind(const String& kind)
         m_client->textTrackKindChanged(this);
 }
 
-void TextTrack::setMode(const String& mode)
+void TextTrack::setMode(const AtomicString& mode)
 {
     // On setting, if the new value isn't equal to what the attribute would currently
     // return, the new value must be processed as follows ...
@@ -174,7 +174,7 @@ void TextTrack::setMode(const String& mode)
         m_client->textTrackModeChanged(this);
 }
 
-String TextTrack::mode() const
+AtomicString TextTrack::mode() const
 {
     // The text track "showing" and "showing by default" modes return the string "showing".
     if (m_showingByDefault)
index 2c799ed..3ba4d37 100644 (file)
@@ -54,7 +54,7 @@ public:
 
 class TextTrack : public TrackBase {
 public:
-    static PassRefPtr<TextTrack> create(ScriptExecutionContext* context, TextTrackClient* client, const String& kind, const String& label, const String& language)
+    static PassRefPtr<TextTrack> create(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& label, const AtomicString& language)
     {
         return adoptRef(new TextTrack(context, client, kind, label, language, AddTrack));
     }
@@ -63,28 +63,28 @@ public:
     void setMediaElement(HTMLMediaElement* element) { m_mediaElement = element; }
     HTMLMediaElement* mediaElement() { return m_mediaElement; }
 
-    String kind() const { return m_kind; }
-    void setKind(const String&);
+    AtomicString kind() const { return m_kind; }
+    void setKind(const AtomicString&);
 
     static const AtomicString& subtitlesKeyword();
     static const AtomicString& captionsKeyword();
     static const AtomicString& descriptionsKeyword();
     static const AtomicString& chaptersKeyword();
     static const AtomicString& metadataKeyword();
-    static bool isValidKindKeyword(const String&);
+    static bool isValidKindKeyword(const AtomicString&);
 
-    String label() const { return m_label; }
-    void setLabel(const String& label) { m_label = label; }
+    AtomicString label() const { return m_label; }
+    void setLabel(const AtomicString& label) { m_label = label; }
 
-    String language() const { return m_language; }
-    void setLanguage(const String& language) { m_language = language; }
+    AtomicString language() const { return m_language; }
+    void setLanguage(const AtomicString& language) { m_language = language; }
 
     static const AtomicString& disabledKeyword();
     static const AtomicString& hiddenKeyword();
     static const AtomicString& showingKeyword();
 
-    String mode() const;
-    void setMode(const String&);
+    AtomicString mode() const;
+    void setMode(const AtomicString&);
 
     bool showingByDefault() const { return m_showingByDefault; }
     void setShowingByDefault(bool showing) { m_showingByDefault = showing; }
@@ -116,17 +116,17 @@ public:
     bool isRendered();
 
 protected:
-    TextTrack(ScriptExecutionContext*, TextTrackClient*, const String& kind, const String& label, const String& language, TextTrackType);
+    TextTrack(ScriptExecutionContext*, TextTrackClient*, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType);
 
     RefPtr<TextTrackCueList> m_cues;
 
 private:
     TextTrackCueList* ensureTextTrackCueList();
     HTMLMediaElement* m_mediaElement;
-    String m_kind;
-    String m_label;
-    String m_language;
-    String m_mode;
+    AtomicString m_kind;
+    AtomicString m_label;
+    AtomicString m_language;
+    AtomicString m_mode;
     TextTrackClient* m_client;
     TextTrackType m_trackType;
     ReadinessState m_readinessState;
index 2fd4f1d..bb73445 100644 (file)
@@ -95,6 +95,7 @@ TextTrackCueBox::TextTrackCueBox(Document* document, TextTrackCue* cue)
     : HTMLElement(divTag, document)
     , m_cue(cue)
 {
+    setShadowPseudoId(shadowPseudoId());
 }
 
 TextTrackCue* TextTrackCueBox::getCue() const
@@ -167,12 +168,17 @@ void TextTrackCueBox::applyCSSProperties()
     }
 }
 
-const AtomicString& TextTrackCueBox::shadowPseudoId() const
+const AtomicString& TextTrackCueBox::textTrackCueBoxShadowPseudoId()
 {
     DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display"));
     return trackDisplayBoxShadowPseudoId;
 }
 
+const AtomicString& TextTrackCueBox::shadowPseudoId() const
+{
+    return textTrackCueBoxShadowPseudoId();
+}
+
 RenderObject* TextTrackCueBox::createRenderer(RenderArena* arena, RenderStyle*)
 {
     return new (arena) RenderTextTrackCue(this);
@@ -180,6 +186,18 @@ RenderObject* TextTrackCueBox::createRenderer(RenderArena* arena, RenderStyle*)
 
 // ----------------------------
 
+const AtomicString& TextTrackCue::pastNodesShadowPseudoId()
+{
+    DEFINE_STATIC_LOCAL(const AtomicString, subtitles, ("-webkit-media-text-track-past-nodes", AtomicString::ConstructFromLiteral));
+    return subtitles;
+}
+
+const AtomicString& TextTrackCue::futureNodesShadowPseudoId()
+{
+    DEFINE_STATIC_LOCAL(const AtomicString, subtitles, ("-webkit-media-text-track-future-nodes", AtomicString::ConstructFromLiteral));
+    return subtitles;
+}
+
 TextTrackCue::TextTrackCue(ScriptExecutionContext* context, double start, double end, const String& content)
     : m_startTime(start)
     , m_endTime(end)
@@ -652,9 +670,6 @@ void TextTrackCue::updateDisplayTree(float movieTime)
     // timestamps (processing instructions), along with displayable nodes.
     DEFINE_STATIC_LOCAL(const String, timestampTag, (ASCIILiteral("timestamp")));
 
-    DEFINE_STATIC_LOCAL(const AtomicString, trackPastNodesShadowPseudoId, ("-webkit-media-text-track-past-nodes"));
-    DEFINE_STATIC_LOCAL(const AtomicString, trackFutureNodesShadowPseudoId, ("-webkit-media-text-track-future-nodes"));
-
     if (!track()->isRendered())
       return;
 
@@ -662,10 +677,10 @@ void TextTrackCue::updateDisplayTree(float movieTime)
 
     // Clear the contents of the two sets.
     m_futureDocumentNodes->removeChildren();
-    m_futureDocumentNodes->setShadowPseudoId(trackFutureNodesShadowPseudoId);
+    m_futureDocumentNodes->setShadowPseudoId(futureNodesShadowPseudoId());
 
     m_pastDocumentNodes->removeChildren();
-    m_pastDocumentNodes->setShadowPseudoId(trackPastNodesShadowPseudoId);
+    m_pastDocumentNodes->setShadowPseudoId(pastNodesShadowPseudoId());
 
     // Update the two sets containing past and future WebVTT objects.
     RefPtr<DocumentFragment> referenceTree = getCueAsHTML();
index 115a868..3e29d1e 100644 (file)
@@ -60,6 +60,7 @@ public:
     void applyCSSProperties();
 
     virtual const AtomicString& shadowPseudoId() const OVERRIDE;
+    static const AtomicString& textTrackCueBoxShadowPseudoId();
 
 private:
     TextTrackCueBox(Document*, TextTrackCue*);
@@ -80,6 +81,9 @@ public:
 
     virtual ~TextTrackCue();
 
+    static const AtomicString& pastNodesShadowPseudoId();
+    static const AtomicString& futureNodesShadowPseudoId();
+
     TextTrack* track() const;
     void setTrack(PassRefPtr<TextTrack>);
 
diff --git a/Source/WebCore/page/CaptionUserPreferences.h b/Source/WebCore/page/CaptionUserPreferences.h
new file mode 100644 (file)
index 0000000..377f527
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef CaptionUserPreferences_h
+#define CaptionUserPreferences_h
+
+#if ENABLE(VIDEO_TRACK)
+
+#include <wtf/PassOwnPtr.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class PageGroup;
+
+class CaptionPreferencesChangedListener {
+public:
+    virtual void captionPreferencesChanged() = 0;
+protected:
+    virtual ~CaptionPreferencesChangedListener() { }
+};
+
+class CaptionUserPreferences {
+public:
+    static PassOwnPtr<CaptionUserPreferences> create(PageGroup* group) { return adoptPtr(new CaptionUserPreferences(group)); }
+    virtual ~CaptionUserPreferences() { }
+
+    virtual bool userPrefersCaptions() const { return false; }
+    virtual bool userHasCaptionPreferences() const { return false; }
+    virtual float captionFontSizeScale() const { return 0.05f; }
+    virtual String captionsStyleSheetOverride() const { return emptyString(); }
+    virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) { }
+    virtual void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) { }
+
+    PageGroup* pageGroup() { return m_pageGroup; }
+
+protected:
+    CaptionUserPreferences(PageGroup* group) : m_pageGroup(group) { }
+
+private:
+    PageGroup* m_pageGroup;
+};
+    
+}
+#endif
+
+#endif
diff --git a/Source/WebCore/page/CaptionUserPreferencesMac.h b/Source/WebCore/page/CaptionUserPreferencesMac.h
new file mode 100644 (file)
index 0000000..6cba2f1
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef CaptionUserPreferencesMac_h
+#define CaptionUserPreferencesMac_h
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "CSSPropertyNames.h"
+#include "CaptionUserPreferences.h"
+#include "Color.h"
+#include <wtf/HashSet.h>
+
+namespace WebCore {
+
+class CaptionUserPreferencesMac : public CaptionUserPreferences {
+public:
+    static PassOwnPtr<CaptionUserPreferencesMac> create(PageGroup* group) { return adoptPtr(new CaptionUserPreferencesMac(group)); }
+    virtual ~CaptionUserPreferencesMac();
+
+    virtual bool userPrefersCaptions() const OVERRIDE;
+    virtual bool userHasCaptionPreferences() const OVERRIDE;
+    virtual float captionFontSizeScale() const OVERRIDE;
+    virtual String captionsStyleSheetOverride() const OVERRIDE;
+    virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE;
+    virtual void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE;
+
+    void captionPreferencesChanged();
+
+private:
+    CaptionUserPreferencesMac(PageGroup*);
+
+    Color captionsWindowColor() const;
+    Color captionsBackgroundColor() const;
+    Color captionsTextColor() const;
+    String captionsDefaultFont() const;
+    Color captionsEdgeColorForTextColor(const Color&) const;
+    String captionsTextEdgeStyle() const;
+    String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&) const;
+    String cssColorProperty(CSSPropertyID, const Color&) const;
+
+    void updateCaptionStyleSheetOveride();
+
+    HashSet<CaptionPreferencesChangedListener*> m_captionPreferenceChangeListeners;
+    bool m_listeningForPreferenceChanges;
+};
+    
+}
+#endif
+
+#endif
diff --git a/Source/WebCore/page/CaptionUserPreferencesMac.mm b/Source/WebCore/page/CaptionUserPreferencesMac.mm
new file mode 100644 (file)
index 0000000..ded0151
--- /dev/null
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+
+#if ENABLE(VIDEO_TRACK)
+
+#import "CaptionUserPreferencesMac.h"
+
+#import "ColorMac.h"
+#import "DOMWrapperWorld.h"
+#import "FloatConversion.h"
+#import "KURL.h"
+#import "PageGroup.h"
+#import "TextTrackCue.h"
+#import "UserStyleSheetTypes.h"
+#import "WebCoreSystemInterface.h"
+#import <wtf/RetainPtr.h>
+#import <wtf/text/StringBuilder.h>
+
+using namespace std;
+
+namespace WebCore {
+
+static void userCaptionPreferencesChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void *, CFDictionaryRef)
+{
+    static_cast<CaptionUserPreferencesMac*>(observer)->captionPreferencesChanged();
+}
+
+
+CaptionUserPreferencesMac::CaptionUserPreferencesMac(PageGroup* group)
+    : CaptionUserPreferences(group)
+    , m_listeningForPreferenceChanges(false)
+{
+}
+
+CaptionUserPreferencesMac::~CaptionUserPreferencesMac()
+{
+    if (wkCaptionAppearanceGetSettingsChangedNotification())
+        CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, wkCaptionAppearanceGetSettingsChangedNotification(), NULL);
+}
+
+bool CaptionUserPreferencesMac::userHasCaptionPreferences() const
+{
+    return wkCaptionAppearanceHasUserPreferences();
+}
+
+bool CaptionUserPreferencesMac::userPrefersCaptions() const
+{
+    return wkCaptionAppearanceShowCaptionsWhenAvailable();
+}
+
+void CaptionUserPreferencesMac::registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener)
+{
+    ASSERT(!m_captionPreferenceChangeListeners.contains(listener));
+
+    if (!wkCaptionAppearanceGetSettingsChangedNotification())
+        return;
+    
+    if (!m_listeningForPreferenceChanges) {
+        m_listeningForPreferenceChanges = true;
+        CFNotificationCenterAddObserver (CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, wkCaptionAppearanceGetSettingsChangedNotification(), NULL, CFNotificationSuspensionBehaviorCoalesce);
+        updateCaptionStyleSheetOveride();
+    }
+    
+    m_captionPreferenceChangeListeners.add(listener);
+}
+
+void CaptionUserPreferencesMac::unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener)
+{
+    if (wkCaptionAppearanceGetSettingsChangedNotification())
+        m_captionPreferenceChangeListeners.remove(listener);
+}
+
+Color CaptionUserPreferencesMac::captionsWindowColor() const
+{
+    RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyWindowColor());
+    Color windowColor(color.get());
+    if (!windowColor.isValid())
+        windowColor = Color::transparent;
+    
+    CGFloat opacity;
+    if (wkCaptionAppearanceGetWindowOpacity(&opacity))
+        return Color(windowColor.red(), windowColor.green(), windowColor.blue(), static_cast<int>(opacity * 255));
+    
+    if (!color)
+        return Color();
+    
+    return windowColor;
+}
+
+Color CaptionUserPreferencesMac::captionsBackgroundColor() const
+{
+    // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-past-nodes
+    // and webkit-media-text-track-future-nodes.
+    DEFINE_STATIC_LOCAL(Color, defaultBackgroundColor, (Color(0, 0, 0, 0.8 * 255)));
+    
+    RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyBackgroundColor());
+    Color backgroundColor(color.get());
+    if (!backgroundColor.isValid()) {
+        backgroundColor = defaultBackgroundColor;
+    }
+    
+    CGFloat opacity;
+    if (wkCaptionAppearanceGetBackgroundOpacity(&opacity))
+        return Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), static_cast<int>(opacity * 255));
+    
+    if (!color)
+        return Color();
+    
+    return backgroundColor;
+}
+
+Color CaptionUserPreferencesMac::captionsTextColor() const
+{
+    RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyForegroundColor());
+    Color textColor(color.get());
+    if (!textColor.isValid()) {
+        // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-container.
+        textColor = Color::white;
+    }
+    
+    CGFloat opacity;
+    if (wkCaptionAppearanceGetForegroundOpacity(&opacity))
+        return Color(textColor.red(), textColor.green(), textColor.blue(), static_cast<int>(opacity * 255));
+    
+    if (!color)
+        return Color();
+    
+    return textColor;
+}
+
+Color CaptionUserPreferencesMac::captionsEdgeColorForTextColor(const Color& textColor) const
+{
+    int distanceFromWhite = differenceSquared(textColor, Color::white);
+    int distanceFromBlack = differenceSquared(textColor, Color::black);
+    
+    if (distanceFromWhite < distanceFromBlack)
+        return textColor.dark();
+    
+    return textColor.light();
+}
+
+String CaptionUserPreferencesMac::cssPropertyWithTextEdgeColor(CSSPropertyID id, const String& value, const Color& textColor) const
+{
+    StringBuilder builder;
+    
+    builder.append(getPropertyNameString(id));
+    builder.append(':');
+    builder.append(value);
+    builder.append(' ');
+    builder.append(captionsEdgeColorForTextColor(textColor).serialized());
+    builder.append(';');
+    
+    return builder.toString();
+}
+
+String CaptionUserPreferencesMac::cssColorProperty(CSSPropertyID id, const Color& color) const
+{
+    StringBuilder builder;
+    
+    builder.append(getPropertyNameString(id));
+    builder.append(':');
+    builder.append(color.serialized());
+    builder.append(';');
+    
+    return builder.toString();
+}
+
+String CaptionUserPreferencesMac::captionsTextEdgeStyle() const
+{
+    DEFINE_STATIC_LOCAL(const String, edgeStyleRaised, (" -.05em -.05em 0 ", String::ConstructFromLiteral));
+    DEFINE_STATIC_LOCAL(const String, edgeStyleDepressed, (" .05em .05em 0 ", String::ConstructFromLiteral));
+    DEFINE_STATIC_LOCAL(const String, edgeStyleDropShadow, (" .075em .075em 0 ", String::ConstructFromLiteral));
+    DEFINE_STATIC_LOCAL(const String, edgeStyleUniform, (" .03em ", String::ConstructFromLiteral));
+    
+    Color color = captionsTextColor();
+    if (!color.isValid())
+        color.setNamedColor("black");
+    color = captionsEdgeColorForTextColor(color);
+    
+    wkCaptionTextEdgeStyle textEdgeStyle = static_cast<wkCaptionTextEdgeStyle>(wkCaptionAppearanceGetTextEdgeStyle());
+    switch (textEdgeStyle) {
+        case wkCaptionTextEdgeStyleUndefined:
+        case wkCaptionTextEdgeStyleNone:
+            return emptyString();
+            
+        case wkCaptionTextEdgeStyleRaised:
+            return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleRaised, color);
+        case wkCaptionTextEdgeStyleDepressed:
+            return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDepressed, color);
+        case wkCaptionTextEdgeStyleDropShadow:
+            return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDropShadow, color);
+        case wkCaptionTextEdgeStyleUniform:
+            return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, edgeStyleUniform, color);
+            
+        case wkCaptionTextEdgeStyleMax:
+            ASSERT_NOT_REACHED();
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+    }
+    
+    return emptyString();
+}
+
+String CaptionUserPreferencesMac::captionsDefaultFont() const
+{
+    RetainPtr<CGFontRef> font(AdoptCF, wkCaptionAppearanceCopyFontForStyle(wkCaptionFontStyleDefault));
+    if (!font)
+        return emptyString();
+    
+    RetainPtr<CFStringRef> name(AdoptCF, CGFontCopyPostScriptName(font.get()));
+    if (!name)
+        return emptyString();
+    
+    StringBuilder builder;
+    
+    builder.append(getPropertyNameString(CSSPropertyFontFamily));
+    builder.append(": \"");
+    builder.append(name.get());
+    builder.append("\";");
+    
+    return builder.toString();
+}
+
+String CaptionUserPreferencesMac::captionsStyleSheetOverride() const
+{
+    StringBuilder captionsOverrideStyleSheet;
+    
+    Color color = captionsBackgroundColor();
+    if (color.isValid()) {
+        captionsOverrideStyleSheet.append(" video::");
+        captionsOverrideStyleSheet.append(TextTrackCue::pastNodesShadowPseudoId());
+        captionsOverrideStyleSheet.append('{');
+        captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyBackgroundColor, color));
+        captionsOverrideStyleSheet.append('}');
+        
+        captionsOverrideStyleSheet.append(" video::");
+        captionsOverrideStyleSheet.append(TextTrackCue::futureNodesShadowPseudoId());
+        captionsOverrideStyleSheet.append('{');
+        captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyBackgroundColor, color));
+        captionsOverrideStyleSheet.append('}');
+    }
+    
+    color = captionsWindowColor();
+    if (color.isValid()) {
+        captionsOverrideStyleSheet.append(" video::");
+        captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
+        captionsOverrideStyleSheet.append('{');
+        captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyBackgroundColor, color));
+        captionsOverrideStyleSheet.append('}');
+    }
+    
+    color = captionsTextColor();
+    String edgeStyle = captionsTextEdgeStyle();
+    String fontName = captionsDefaultFont();
+    if (color.isValid() || !edgeStyle.isEmpty() || !fontName.isEmpty()) {
+        captionsOverrideStyleSheet.append(" video::");
+        captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
+        captionsOverrideStyleSheet.append('{');
+        
+        if (color.isValid())
+            captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyColor, color));
+        if (!edgeStyle.isEmpty())
+            captionsOverrideStyleSheet.append(edgeStyle);
+        if (!fontName.isEmpty())
+            captionsOverrideStyleSheet.append(fontName);
+        
+        captionsOverrideStyleSheet.append('}');
+    }
+    
+    return captionsOverrideStyleSheet.toString();
+}
+
+float CaptionUserPreferencesMac::captionFontSizeScale() const
+{
+    CGFloat characterScale = CaptionUserPreferences::captionFontSizeScale();
+    CGFloat scaleAdjustment;
+    
+    if (!wkCaptionAppearanceGetRelativeCharacterSize(&scaleAdjustment))
+        return characterScale;
+    
+    return narrowPrecisionToFloat(scaleAdjustment * characterScale);
+}
+
+void CaptionUserPreferencesMac::captionPreferencesChanged()
+{
+    if (m_captionPreferenceChangeListeners.isEmpty())
+        return;
+
+    updateCaptionStyleSheetOveride();
+
+    for (HashSet<CaptionPreferencesChangedListener*>::iterator i = m_captionPreferenceChangeListeners.begin(); i != m_captionPreferenceChangeListeners.end(); ++i)
+        (*i)->captionPreferencesChanged();
+}
+
+void CaptionUserPreferencesMac::updateCaptionStyleSheetOveride()
+{
+    // Identify our override style sheet with a unique URL - a new scheme and a UUID.
+    DEFINE_STATIC_LOCAL(KURL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"));
+    
+    pageGroup()->removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL);
+    
+    if (!userHasCaptionPreferences())
+        return;
+    
+    String captionsOverrideStyleSheet = captionsStyleSheetOverride();
+    if (captionsOverrideStyleSheet.isEmpty())
+        return;
+    
+    pageGroup()->addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, Vector<String>(),
+             Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments);
+}
+
+}
+
+#endif // ENABLE(VIDEO_TRACK)
index 77928ce..3ad8bfb 100644 (file)
 #include "Settings.h"
 #include "StorageNamespace.h"
 
+#if ENABLE(VIDEO_TRACK)
+#if PLATFORM(MAC)
+#include "CaptionUserPreferencesMac.h"
+#else
+#include "CaptionUserPreferences.h"
+#endif
+#endif
+
 #if PLATFORM(CHROMIUM)
 #include "VisitedLinks.h"
 #endif
@@ -396,4 +404,46 @@ void PageGroup::resetUserStyleCacheInAllFrames()
     }
 }
 
+#if ENABLE(VIDEO_TRACK)
+CaptionUserPreferences* PageGroup::captionPreferences()
+{
+    if (!m_captionPreferences)
+#if PLATFORM(MAC)
+        m_captionPreferences = CaptionUserPreferencesMac::create(this);
+#else
+        m_captionPreferences = CaptionUserPreferences::create(this);
+#endif
+
+    return m_captionPreferences.get();
+}
+    
+void PageGroup::registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener)
+{
+    captionPreferences()->registerForCaptionPreferencesChangedCallbacks(listener);
+}
+
+void PageGroup::unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener)
+{
+    if (!m_captionPreferences)
+        return;
+    captionPreferences()->unregisterForCaptionPreferencesChangedCallbacks(listener);
+}
+    
+bool PageGroup::userPrefersCaptions()
+{
+    return captionPreferences()->userPrefersCaptions();
+}
+
+bool PageGroup::userHasCaptionPreferences()
+{
+    return captionPreferences()->userPrefersCaptions();
+}
+
+float PageGroup::captionFontSizeScale()
+{
+    return captionPreferences()->captionFontSizeScale();
+}
+
+#endif
+
 } // namespace WebCore
index 7d2ddfa..6614b65 100644 (file)
 
 namespace WebCore {
 
+#if ENABLE(VIDEO_TRACK)
+    class CaptionPreferencesChangedListener;
+    class CaptionUserPreferences;
+#endif
     class KURL;
     class GroupSettings;
     class IDBFactoryBackendInterface;
@@ -103,12 +107,23 @@ namespace WebCore {
 
         GroupSettings* groupSettings() const { return m_groupSettings.get(); }
 
+#if ENABLE(VIDEO_TRACK)
+        bool userPrefersCaptions();
+        bool userHasCaptionPreferences();
+        float captionFontSizeScale();
+        void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*);
+        void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*);
+#endif
+
     private:
         PageGroup(Page*);
 
         void addVisitedLink(LinkHash stringHash);
         void resetUserStyleCacheInAllFrames();
   
+#if ENABLE(VIDEO_TRACK)
+        CaptionUserPreferences* captionPreferences();
+#endif
         String m_name;
 
         HashSet<Page*> m_pages;
@@ -123,6 +138,10 @@ namespace WebCore {
         OwnPtr<UserStyleSheetMap> m_userStyleSheets;
 
         OwnPtr<GroupSettings> m_groupSettings;
+
+#if ENABLE(VIDEO_TRACK)
+        OwnPtr<CaptionUserPreferences> m_captionPreferences;
+#endif
     };
 
 } // namespace WebCore
index c5df5d1..b87dfe0 100644 (file)
@@ -344,6 +344,40 @@ extern CGFloat (*wkNSElasticDeltaForReboundDelta)(CGFloat delta);
 extern CGFloat (*wkNSReboundDeltaForElasticDelta)(CGFloat delta);
 #endif
 
+typedef enum {
+    wkCaptionFontStyleDefault = 0,
+    wkCaptionFontStyleMonospacedWithSerif,
+    wkCaptionFontStyleProportionalWithSerif,
+    wkCaptionFontStyleMonospacedWithoutSerif,
+    wkCaptionFontStyleProportionalWithoutSerif,
+    wkCaptionFontStyleCasual,
+    wkCaptionFontStyleCursive,
+    wkCaptionFontStyleSmallCapital,
+    wkCaptionFontStyleMax
+} wkCaptionFontStyle;
+
+typedef enum {
+    wkCaptionTextEdgeStyleUndefined = 0,
+    wkCaptionTextEdgeStyleNone,
+    wkCaptionTextEdgeStyleRaised,
+    wkCaptionTextEdgeStyleDepressed,
+    wkCaptionTextEdgeStyleUniform,
+    wkCaptionTextEdgeStyleDropShadow,
+    wkCaptionTextEdgeStyleMax
+} wkCaptionTextEdgeStyle;
+
+extern bool (*wkCaptionAppearanceHasUserPreferences)(void);
+extern bool (*wkCaptionAppearanceShowCaptionsWhenAvailable)(void);
+extern CGColorRef(*wkCaptionAppearanceCopyForegroundColor)(void);
+extern CGColorRef(*wkCaptionAppearanceCopyBackgroundColor)(void);
+extern CGColorRef(*wkCaptionAppearanceCopyWindowColor)(void);
+extern bool(*wkCaptionAppearanceGetForegroundOpacity)(CGFloat*);
+extern bool(*wkCaptionAppearanceGetBackgroundOpacity)(CGFloat*);
+extern bool(*wkCaptionAppearanceGetWindowOpacity)(CGFloat*);
+extern CGFontRef(*wkCaptionAppearanceCopyFontForStyle)(int);
+extern bool(*wkCaptionAppearanceGetRelativeCharacterSize)(CGFloat*);
+extern int(*wkCaptionAppearanceGetTextEdgeStyle)(void);
+extern CFStringRef(*wkCaptionAppearanceGetSettingsChangedNotification)(void);
 }
 
 #endif
index a467a4b..948d353 100644 (file)
@@ -216,3 +216,15 @@ CGFloat (*wkNSElasticDeltaForReboundDelta)(CGFloat delta);
 CGFloat (*wkNSReboundDeltaForElasticDelta)(CGFloat delta);
 #endif
 
+bool (*wkCaptionAppearanceHasUserPreferences)(void);
+bool (*wkCaptionAppearanceShowCaptionsWhenAvailable)(void);
+CGColorRef(*wkCaptionAppearanceCopyForegroundColor)(void);
+CGColorRef(*wkCaptionAppearanceCopyBackgroundColor)(void);
+CGColorRef(*wkCaptionAppearanceCopyWindowColor)(void);
+bool(*wkCaptionAppearanceGetForegroundOpacity)(CGFloat*);
+bool(*wkCaptionAppearanceGetBackgroundOpacity)(CGFloat*);
+bool(*wkCaptionAppearanceGetWindowOpacity)(CGFloat*);
+CGFontRef(*wkCaptionAppearanceCopyFontForStyle)(int);
+bool(*wkCaptionAppearanceGetRelativeCharacterSize)(CGFloat*);
+int(*wkCaptionAppearanceGetTextEdgeStyle)(void);
+CFStringRef(*wkCaptionAppearanceGetSettingsChangedNotification)(void);
index f996959..1e30ab0 100644 (file)
@@ -1,3 +1,14 @@
+2012-10-24  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 Maciej Stachowiak.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Initialize new WKSI function pointers.
+
 2012-10-23  Dan Bernstein  <mitz@apple.com>
 
         WebKit/mac part of <rdar://problem/2966974> [mac] Kerning and ligatures are not enabled by default
index a7dbd0c..367572d 100644 (file)
@@ -211,6 +211,19 @@ void InitWebCoreSystemInterface(void)
     INIT(NSReboundDeltaForElasticDelta);
 #endif
 
+    INIT(CaptionAppearanceHasUserPreferences);
+    INIT(CaptionAppearanceShowCaptionsWhenAvailable);
+    INIT(CaptionAppearanceCopyForegroundColor);
+    INIT(CaptionAppearanceCopyBackgroundColor);
+    INIT(CaptionAppearanceCopyWindowColor);
+    INIT(CaptionAppearanceGetForegroundOpacity);
+    INIT(CaptionAppearanceGetBackgroundOpacity);
+    INIT(CaptionAppearanceGetWindowOpacity);
+    INIT(CaptionAppearanceCopyFontForStyle);
+    INIT(CaptionAppearanceGetRelativeCharacterSize);
+    INIT(CaptionAppearanceGetTextEdgeStyle);
+    INIT(CaptionAppearanceGetSettingsChangedNotification);
+
 #endif
     didInit = true;
 }
index d11634c..5223e7e 100644 (file)
@@ -1,3 +1,14 @@
+2012-10-24  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 Maciej Stachowiak.
+
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Initialize new WKSI function pointers.
+
 2012-10-24  Allan Sandfeld Jensen  <allan.jensen@digia.com>
 
         [Qt] Expose useful WebCore::Settings
index aef59ca..e49a781 100644 (file)
@@ -192,5 +192,17 @@ void InitWebCoreSystemInterface(void)
         INIT(NSReboundDeltaForElasticDelta);
 #endif
 
+        INIT(CaptionAppearanceHasUserPreferences);
+        INIT(CaptionAppearanceShowCaptionsWhenAvailable);
+        INIT(CaptionAppearanceCopyForegroundColor);
+        INIT(CaptionAppearanceCopyBackgroundColor);
+        INIT(CaptionAppearanceCopyWindowColor);
+        INIT(CaptionAppearanceGetForegroundOpacity);
+        INIT(CaptionAppearanceGetBackgroundOpacity);
+        INIT(CaptionAppearanceGetWindowOpacity);
+        INIT(CaptionAppearanceCopyFontForStyle);
+        INIT(CaptionAppearanceGetRelativeCharacterSize);
+        INIT(CaptionAppearanceGetTextEdgeStyle);
+        INIT(CaptionAppearanceGetSettingsChangedNotification);
     });
 }
index 090e056..2b2e877 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-24  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 Maciej Stachowiak.
+
+        Update WKSI header with SPI for getting the user caption appearance preferences.
+
+        * WebKitSystemInterface.h:
+
 2012-10-19  Dongwoo Joshua Im  <dw.im@samsung.com>
 
         Rename ENABLE_CSS3_TEXT_DECORATION to ENABLE_CSS3_TEXT
index acf4061..47279f3 100644 (file)
@@ -1,6 +1,6 @@
 /*      
     WebKitSystemInterface.h
-    Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+    Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
 
     Public header file.
 */
@@ -513,6 +513,41 @@ CGFloat WKNSReboundDeltaForElasticDelta(CGFloat delta);
 Boolean WKJLIsRuntimeAndWebComponentsInstalled(void);
 #endif
 
+typedef enum {
+    WKCaptionFontStyleDefault = 0,
+    WKCaptionFontStyleMonospacedWithSerif,
+    WKCaptionFontStyleProportionalWithSerif,
+    WKCaptionFontStyleMonospacedWithoutSerif,
+    WKCaptionFontStyleProportionalWithoutSerif,
+    WKCaptionFontStyleCasual,
+    WKCaptionFontStyleCursive,
+    WKCaptionFontStyleSmallCapital,
+    WKCaptionFontStyleMax
+} WKCaptionFontStyle;
+
+typedef enum {
+    WKCaptionTextEdgeStyleUndefined = 0,
+    WKCaptionTextEdgeStyleNone,
+    WKCaptionTextEdgeStyleRaised,
+    WKCaptionTextEdgeStyleDepressed,
+    WKCaptionTextEdgeStyleUniform,
+    WKCaptionTextEdgeStyleDropShadow,
+    WKCaptionTextEdgeStyleMax
+} WKCaptionTextEdgeStyle;
+
+bool WKCaptionAppearanceHasUserPreferences(void);
+bool WKCaptionAppearanceShowCaptionsWhenAvailable(void);
+CGColorRef WKCaptionAppearanceCopyForegroundColor(void);
+CGColorRef WKCaptionAppearanceCopyBackgroundColor(void);
+CGColorRef WKCaptionAppearanceCopyWindowColor(void);
+bool WKCaptionAppearanceGetForegroundOpacity(CGFloat*);
+bool WKCaptionAppearanceGetBackgroundOpacity(CGFloat*);
+bool WKCaptionAppearanceGetWindowOpacity(CGFloat*);
+CGFontRef WKCaptionAppearanceCopyFontForStyle(int fontStyle);
+bool WKCaptionAppearanceGetRelativeCharacterSize(CGFloat*);
+int WKCaptionAppearanceGetTextEdgeStyle(void);
+CFStringRef WKCaptionAppearanceGetSettingsChangedNotification(void);
+
 #ifdef __cplusplus
 }
 #endif