Unreviewed, rolling out r163048.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jan 2014 07:42:07 +0000 (07:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jan 2014 07:42:07 +0000 (07:42 +0000)
http://trac.webkit.org/changeset/163048
https://bugs.webkit.org/show_bug.cgi?id=127890

Caused many crashes, detected by EWS prior to landing
(Requested by ap on #webkit).

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::sortedTrackListForMenu):
(WebCore::MediaControlsHost::displayNameForTrack):
(WebCore::MediaControlsHost::captionDisplayMode):
* WebCore.exp.in:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/DocumentRuleSets.cpp:
(WebCore::DocumentRuleSets::initUserStyle):
* css/InspectorCSSOMWrappers.cpp:
(WebCore::InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection):
* dom/Document.cpp:
(WebCore::Document::setCompatibilityMode):
(WebCore::Document::registerForCaptionPreferencesChangedCallbacks):
(WebCore::Document::captionPreferencesChanged):
* dom/DocumentStyleSheetCollection.cpp:
* dom/DocumentStyleSheetCollection.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::parseAttribute):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay):
(WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
(WebCore::MediaControlTextTrackContainerElement::updateTimerFired):
* page/CaptionStyleSheetMediaAF.cpp: Removed.
* page/CaptionStyleSheetMediaAF.h: Removed.
* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::CaptionUserPreferences):
(WebCore::CaptionUserPreferences::notify):
(WebCore::CaptionUserPreferences::setCaptionDisplayMode):
(WebCore::CaptionUserPreferences::userPrefersCaptions):
(WebCore::CaptionUserPreferences::setUserPrefersCaptions):
(WebCore::CaptionUserPreferences::userPrefersSubtitles):
(WebCore::CaptionUserPreferences::setUserPrefersSubtitles):
(WebCore::CaptionUserPreferences::userPrefersTextDescriptions):
(WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions):
(WebCore::CaptionUserPreferences::captionPreferencesChanged):
(WebCore::CaptionUserPreferences::textTrackSelectionScore):
(WebCore::CaptionUserPreferences::setCaptionsStyleSheetOverride):
(WebCore::CaptionUserPreferences::updateCaptionStyleSheetOveride):
* page/CaptionUserPreferences.h:
(WebCore::CaptionUserPreferences::captionsStyleSheetOverride):
(WebCore::CaptionUserPreferences::setInterestedInCaptionPreferenceChanges):
(WebCore::CaptionUserPreferences::testingMode):
(WebCore::CaptionUserPreferences::setTestingMode):
(WebCore::CaptionUserPreferences::pageGroup):
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::userCaptionPreferencesChangedNotificationCallback):
(WebCore::CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF):
(WebCore::CaptionUserPreferencesMediaAF::userPrefersCaptions):
(WebCore::CaptionUserPreferencesMediaAF::userPrefersSubtitles):
(WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges):
(WebCore::CaptionUserPreferencesMediaAF::captionPreferencesChanged):
(WebCore::CaptionUserPreferencesMediaAF::captionsWindowCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsBackgroundCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsTextColor):
(WebCore::CaptionUserPreferencesMediaAF::captionsTextColorCSS):
(WebCore::CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsEdgeColorForTextColor):
(WebCore::CaptionUserPreferencesMediaAF::cssPropertyWithTextEdgeColor):
(WebCore::CaptionUserPreferencesMediaAF::colorPropertyCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsTextEdgeCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride):
(WebCore::CaptionUserPreferencesMediaAF::textTrackSelectionScore):
(WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):
* page/CaptionUserPreferencesMediaAF.h:
* page/Page.cpp:
* page/Page.h:
* page/PageGroup.cpp:
(WebCore::PageGroup::captionPreferencesChanged):
(WebCore::PageGroup::captionPreferences):
* page/PageGroup.h:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setShouldDisplayTrackKind):
(WebCore::InternalSettings::shouldDisplayTrackKind):
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::Internals):
(WebCore::Internals::captionsStyleSheetOverride):
(WebCore::Internals::setCaptionsStyleSheetOverride):
(WebCore::Internals::setPrimaryAudioTrackLanguageOverride):
(WebCore::Internals::setCaptionDisplayMode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163073 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/DocumentRuleSets.cpp
Source/WebCore/css/InspectorCSSOMWrappers.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentStyleSheetCollection.cpp
Source/WebCore/dom/DocumentStyleSheetCollection.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/page/CaptionStyleSheetMediaAF.cpp [deleted file]
Source/WebCore/page/CaptionStyleSheetMediaAF.h [deleted file]
Source/WebCore/page/CaptionUserPreferences.cpp
Source/WebCore/page/CaptionUserPreferences.h
Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp
Source/WebCore/page/CaptionUserPreferencesMediaAF.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PageGroup.cpp
Source/WebCore/page/PageGroup.h
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/Internals.cpp

index 3968c15..473f251 100644 (file)
@@ -1,3 +1,97 @@
+2014-01-29  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r163048.
+        http://trac.webkit.org/changeset/163048
+        https://bugs.webkit.org/show_bug.cgi?id=127890
+
+        Caused many crashes, detected by EWS prior to landing
+        (Requested by ap on #webkit).
+
+        * Modules/mediacontrols/MediaControlsHost.cpp:
+        (WebCore::MediaControlsHost::sortedTrackListForMenu):
+        (WebCore::MediaControlsHost::displayNameForTrack):
+        (WebCore::MediaControlsHost::captionDisplayMode):
+        * WebCore.exp.in:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/DocumentRuleSets.cpp:
+        (WebCore::DocumentRuleSets::initUserStyle):
+        * css/InspectorCSSOMWrappers.cpp:
+        (WebCore::InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection):
+        * dom/Document.cpp:
+        (WebCore::Document::setCompatibilityMode):
+        (WebCore::Document::registerForCaptionPreferencesChangedCallbacks):
+        (WebCore::Document::captionPreferencesChanged):
+        * dom/DocumentStyleSheetCollection.cpp:
+        * dom/DocumentStyleSheetCollection.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+        (WebCore::HTMLMediaElement::parseAttribute):
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay):
+        (WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
+        (WebCore::MediaControlTextTrackContainerElement::updateTimerFired):
+        * page/CaptionStyleSheetMediaAF.cpp: Removed.
+        * page/CaptionStyleSheetMediaAF.h: Removed.
+        * page/CaptionUserPreferences.cpp:
+        (WebCore::CaptionUserPreferences::CaptionUserPreferences):
+        (WebCore::CaptionUserPreferences::notify):
+        (WebCore::CaptionUserPreferences::setCaptionDisplayMode):
+        (WebCore::CaptionUserPreferences::userPrefersCaptions):
+        (WebCore::CaptionUserPreferences::setUserPrefersCaptions):
+        (WebCore::CaptionUserPreferences::userPrefersSubtitles):
+        (WebCore::CaptionUserPreferences::setUserPrefersSubtitles):
+        (WebCore::CaptionUserPreferences::userPrefersTextDescriptions):
+        (WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions):
+        (WebCore::CaptionUserPreferences::captionPreferencesChanged):
+        (WebCore::CaptionUserPreferences::textTrackSelectionScore):
+        (WebCore::CaptionUserPreferences::setCaptionsStyleSheetOverride):
+        (WebCore::CaptionUserPreferences::updateCaptionStyleSheetOveride):
+        * page/CaptionUserPreferences.h:
+        (WebCore::CaptionUserPreferences::captionsStyleSheetOverride):
+        (WebCore::CaptionUserPreferences::setInterestedInCaptionPreferenceChanges):
+        (WebCore::CaptionUserPreferences::testingMode):
+        (WebCore::CaptionUserPreferences::setTestingMode):
+        (WebCore::CaptionUserPreferences::pageGroup):
+        * page/CaptionUserPreferencesMediaAF.cpp:
+        (WebCore::userCaptionPreferencesChangedNotificationCallback):
+        (WebCore::CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF):
+        (WebCore::CaptionUserPreferencesMediaAF::userPrefersCaptions):
+        (WebCore::CaptionUserPreferencesMediaAF::userPrefersSubtitles):
+        (WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges):
+        (WebCore::CaptionUserPreferencesMediaAF::captionPreferencesChanged):
+        (WebCore::CaptionUserPreferencesMediaAF::captionsWindowCSS):
+        (WebCore::CaptionUserPreferencesMediaAF::captionsBackgroundCSS):
+        (WebCore::CaptionUserPreferencesMediaAF::captionsTextColor):
+        (WebCore::CaptionUserPreferencesMediaAF::captionsTextColorCSS):
+        (WebCore::CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS):
+        (WebCore::CaptionUserPreferencesMediaAF::captionsEdgeColorForTextColor):
+        (WebCore::CaptionUserPreferencesMediaAF::cssPropertyWithTextEdgeColor):
+        (WebCore::CaptionUserPreferencesMediaAF::colorPropertyCSS):
+        (WebCore::CaptionUserPreferencesMediaAF::captionsTextEdgeCSS):
+        (WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS):
+        (WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride):
+        (WebCore::CaptionUserPreferencesMediaAF::textTrackSelectionScore):
+        (WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):
+        * page/CaptionUserPreferencesMediaAF.h:
+        * page/Page.cpp:
+        * page/Page.h:
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::captionPreferencesChanged):
+        (WebCore::PageGroup::captionPreferences):
+        * page/PageGroup.h:
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::setShouldDisplayTrackKind):
+        (WebCore::InternalSettings::shouldDisplayTrackKind):
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+        (WebCore::Internals::Internals):
+        (WebCore::Internals::captionsStyleSheetOverride):
+        (WebCore::Internals::setCaptionsStyleSheetOverride):
+        (WebCore::Internals::setPrimaryAudioTrackLanguageOverride):
+        (WebCore::Internals::setCaptionDisplayMode):
+
 2014-01-29  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Remove ENABLE(JAVASCRIPT_DEBUGGER) leftovers
index f6223e8..8de80c1 100644 (file)
@@ -82,7 +82,8 @@ Vector<RefPtr<TextTrack>> MediaControlsHost::sortedTrackListForMenu(TextTrackLis
     if (!page)
         return Vector<RefPtr<TextTrack>>();
 
-    return page->captionPreferences().sortedTrackListForMenu(trackList);
+    CaptionUserPreferences* captionPreferences = page->group().captionPreferences();
+    return captionPreferences->sortedTrackListForMenu(trackList);
 }
 
 String MediaControlsHost::displayNameForTrack(TextTrack* track)
@@ -94,7 +95,8 @@ String MediaControlsHost::displayNameForTrack(TextTrack* track)
     if (!page)
         return emptyString();
 
-    return page->captionPreferences().displayNameForTrack(track);
+    CaptionUserPreferences* captionPreferences = page->group().captionPreferences();
+    return captionPreferences->displayNameForTrack(track);
 }
 
 TextTrack* MediaControlsHost::captionMenuOffItem()
@@ -113,7 +115,7 @@ AtomicString MediaControlsHost::captionDisplayMode()
     if (!page)
         return emptyAtom;
 
-    switch (page->captionPreferences().captionDisplayMode()) {
+    switch (page->group().captionPreferences()->captionDisplayMode()) {
     case CaptionUserPreferences::Automatic:
         return automaticKeyword();
     case CaptionUserPreferences::ForcedOnly:
index 281790f..4cc438d 100644 (file)
@@ -3063,9 +3063,7 @@ __ZN7WebCore4Page11setViewModeENS0_8ViewModeE
 #endif
 
 #if ENABLE(VIDEO_TRACK)
-__ZN7WebCore22CaptionUserPreferences29setCaptionsStyleSheetOverrideERKN3WTF6StringE
-__ZN7WebCore4Page18captionPreferencesEv
-__ZNK7WebCore22CaptionUserPreferences26captionsStyleSheetOverrideEv
+__ZN7WebCore9PageGroup18captionPreferencesEv
 #endif
 
 #if ENABLE(VIDEO)
index 53a240f..48a507f 100644 (file)
     <ClCompile Include="..\page\animation\AnimationController.cpp" />
     <ClCompile Include="..\page\AutoscrollController.cpp" />
     <ClCompile Include="..\page\BarProp.cpp" />
-    <ClCompile Include="..\page\CaptionStyleSheetMediaAF.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
-    </ClCompile>
     <ClCompile Include="..\page\CaptionUserPreferences.cpp" />
     <ClCompile Include="..\page\CaptionUserPreferencesMediaAF.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
     <ClInclude Include="..\page\animation\AnimationControllerPrivate.h" />
     <ClInclude Include="..\page\AutoscrollController.h" />
     <ClInclude Include="..\page\BarProp.h" />
-    <ClInclude Include="..\page\CaptionStyleSheetMediaAF.h" />
     <ClInclude Include="..\page\CaptionUserPreferences.h" />
     <ClInclude Include="..\page\CaptionUserPreferencesMediaAF.h" />
     <ClInclude Include="..\page\Chrome.h" />
index 47a0028..0daff3b 100644 (file)
     <ClCompile Include="..\platform\graphics\opengl\TemporaryOpenGLSetting.cpp">
       <Filter>platform\graphics\opengl</Filter>
     </ClCompile>
-    <ClCompile Include="..\page\CaptionStyleSheetMediaAF.cpp">
-      <Filter>page</Filter>
-    </ClCompile>
     <ClCompile Include="..\page\CaptionUserPreferencesMediaAF.cpp">
       <Filter>page</Filter>
     </ClCompile>
     <ClInclude Include="..\platform\graphics\opengl\GLPlatformSurface.h">
       <Filter>platform\graphics\opengl</Filter>
     </ClInclude>
-    <ClInclude Include="..\page\CaptionStyleSheetMediaAF.h">
-      <Filter>page</Filter>
-    </ClInclude>
     <ClInclude Include="..\page\CaptionUserPreferences.h">
       <Filter>page</Filter>
     </ClInclude>
index 0c0eb49..941f726 100644 (file)
                7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
                7CE6CBFB187F370700D46BF5 /* FormatConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE6CBFA187F370700D46BF5 /* FormatConverter.h */; };
                7CE6CBFD187F394900D46BF5 /* FormatConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */; };
-               7CFC30591895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFC30571895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp */; };
-               7CFC305A1895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CFC30581895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h */; };
                7D741BDA177226AA00859170 /* CSSValueKeywords.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 6565814809D13043000E61D7 /* CSSValueKeywords.h */; };
                7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E33CD00127F340D00BE8F17 /* PurgePriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7E37EF2E1339208800B29250 /* SubresourceLoaderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E37EF2D1339208800B29250 /* SubresourceLoaderCF.cpp */; };
                7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDNScriptWhiteList.txt; sourceTree = "<group>"; };
                7CE6CBFA187F370700D46BF5 /* FormatConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatConverter.h; sourceTree = "<group>"; };
                7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatConverter.cpp; sourceTree = "<group>"; };
-               7CFC30571895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CaptionStyleSheetMediaAF.cpp; sourceTree = "<group>"; };
-               7CFC30581895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CaptionStyleSheetMediaAF.h; sourceTree = "<group>"; };
                7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = "<group>"; };
                7E37EF2D1339208800B29250 /* SubresourceLoaderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SubresourceLoaderCF.cpp; path = cf/SubresourceLoaderCF.cpp; sourceTree = "<group>"; };
                7E428CE413E3407F003B661C /* ResourceHandleIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceHandleIOS.mm; sourceTree = "<group>"; };
                                079D0867162F20E800DB8658 /* CaptionUserPreferences.h */,
                                079D086A162F21F900DB8658 /* CaptionUserPreferencesMediaAF.cpp */,
                                079D0869162F21F900DB8658 /* CaptionUserPreferencesMediaAF.h */,
-                               7CFC30571895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp */,
-                               7CFC30581895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h */,
                                14D8238A0AF92DF60004F057 /* Chrome.cpp */,
                                14D823500AF92A790004F057 /* Chrome.h */,
                                14D824060AF93AEB0004F057 /* ChromeClient.h */,
                                FE115FAB167988CD00249134 /* AbstractDatabaseServer.h in Headers */,
                                9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */,
                                FE4AADEE16D2C37400026FFC /* AbstractSQLStatement.h in Headers */,
-                               7CFC305A1895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h in Headers */,
                                6E84E9E117668BF100815B68 /* RasterShape.h in Headers */,
                                FE4AADEF16D2C37400026FFC /* AbstractSQLStatementBackend.h in Headers */,
                                41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
                                A81369E1097374F600D74463 /* HTMLLegendElement.cpp in Sources */,
                                A8EA79FC0A1916DF00A8EF5F /* HTMLLIElement.cpp in Sources */,
                                A871DC210A15205700B12A68 /* HTMLLinkElement.cpp in Sources */,
-                               7CFC30591895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp in Sources */,
                                A8EA7D320A19385500A8EF5F /* HTMLMapElement.cpp in Sources */,
                                A8EA7CAC0A192B9C00A8EF5F /* HTMLMarqueeElement.cpp in Sources */,
                                E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */,
index 7b58992..d0dd374 100644 (file)
@@ -51,8 +51,6 @@ void DocumentRuleSets::initUserStyle(DocumentStyleSheetCollection& styleSheetCol
     OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
     if (CSSStyleSheet* pageUserSheet = styleSheetCollection.pageUserSheet())
         tempUserStyle->addRulesFromSheet(&pageUserSheet->contents(), medium, &resolver);
-    if (CSSStyleSheet* captionsStyleSheet = styleSheetCollection.captionsStyleSheet())
-        tempUserStyle->addRulesFromSheet(&captionsStyleSheet->contents(), medium, &resolver);
     collectRulesFromUserStyleSheets(styleSheetCollection.injectedUserStyleSheets(), *tempUserStyle, medium, resolver);
     collectRulesFromUserStyleSheets(styleSheetCollection.documentUserStyleSheets(), *tempUserStyle, medium, resolver);
     if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0)
index 4d5c9e4..042e44e 100644 (file)
@@ -107,7 +107,6 @@ void InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection(DocumentSty
 {
     collectFromStyleSheets(styleSheetCollection.activeAuthorStyleSheets());
     collect(styleSheetCollection.pageUserSheet());
-    collect(styleSheetCollection.captionsStyleSheet());
     collectFromStyleSheets(styleSheetCollection.injectedUserStyleSheets());
     collectFromStyleSheets(styleSheetCollection.documentUserStyleSheets());
 }
index 045a483..9c28c6b 100644 (file)
@@ -748,7 +748,6 @@ void Document::setCompatibilityMode(CompatibilityMode mode)
     if (inQuirksMode() != wasInQuirksMode) {
         // All user stylesheets have to reparse using the different mode.
         m_styleSheetCollection.clearPageUserSheet();
-        m_styleSheetCollection.invalidateCaptionsStyleSheet();
         m_styleSheetCollection.invalidateInjectedStyleSheetCache();
     }
 }
@@ -4172,6 +4171,9 @@ void Document::unregisterForPrivateBrowsingStateChangedCallbacks(Element* e)
 #if ENABLE(VIDEO_TRACK)
 void Document::registerForCaptionPreferencesChangedCallbacks(Element* e)
 {
+    if (page())
+        page()->group().captionPreferences()->setInterestedInCaptionPreferenceChanges();
+
     m_captionPreferencesChangedElements.add(e);
 }
 
@@ -4182,11 +4184,9 @@ void Document::unregisterForCaptionPreferencesChangedCallbacks(Element* e)
 
 void Document::captionPreferencesChanged()
 {
-    m_styleSheetCollection.invalidateCaptionsStyleSheet();
-    styleResolverChanged(DeferRecalcStyle);
-
-    for (auto* element : m_captionPreferencesChangedElements)
-        element->captionPreferencesChanged();
+    HashSet<Element*>::iterator end = m_captionPreferencesChangedElements.end();
+    for (HashSet<Element*>::iterator it = m_captionPreferencesChangedElements.begin(); it != end; ++it)
+        (*it)->captionPreferencesChanged();
 }
 #endif
 
index c1fa682..a83731d 100644 (file)
@@ -29,7 +29,6 @@
 #include "DocumentStyleSheetCollection.h"
 
 #include "CSSStyleSheet.h"
-#include "CaptionUserPreferences.h"
 #include "Element.h"
 #include "HTMLIFrameElement.h"
 #include "HTMLLinkElement.h"
@@ -119,41 +118,6 @@ void DocumentStyleSheetCollection::updatePageUserSheet()
         m_document.styleResolverChanged(RecalcStyleImmediately);
 }
 
-CSSStyleSheet* DocumentStyleSheetCollection::captionsStyleSheet()
-{
-    updateCaptionsStyleSheet();
-    return m_captionsStyleSheet.get();
-}
-
-void DocumentStyleSheetCollection::updateCaptionsStyleSheet()
-{
-    // Identify our override style sheet with a unique URL - a new scheme and a UUID.
-    DEFINE_STATIC_LOCAL(URL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"));
-
-    if (m_captionsStyleSheet)
-        return;
-
-    Page* owningPage = m_document.page();
-    if (!owningPage)
-        return;
-    
-    String captionsStyleSheetText = owningPage->captionPreferences().captionsStyleSheet();
-    if (captionsStyleSheetText.isEmpty())
-        return;
-
-    // Parse the sheet and cache it.
-    m_captionsStyleSheet = CSSStyleSheet::createInline(m_document, captionsStyleSheetURL);
-    m_captionsStyleSheet->contents().parseString(captionsStyleSheetText);
-}
-
-void DocumentStyleSheetCollection::invalidateCaptionsStyleSheet()
-{
-    if (m_captionsStyleSheet) {
-        m_captionsStyleSheet = nullptr;
-        m_document.styleResolverChanged(DeferRecalcStyle);
-    }
-}
-
 const Vector<RefPtr<CSSStyleSheet>>& DocumentStyleSheetCollection::injectedUserStyleSheets() const
 {
     updateInjectedStyleSheetCache();
index 21ffef9..dcec209 100644 (file)
@@ -53,7 +53,6 @@ public:
     const Vector<RefPtr<CSSStyleSheet>>& activeAuthorStyleSheets() const { return m_activeAuthorStyleSheets; }
 
     CSSStyleSheet* pageUserSheet();
-    CSSStyleSheet* captionsStyleSheet();
     const Vector<RefPtr<CSSStyleSheet>>& documentUserStyleSheets() const { return m_userStyleSheets; }
     const Vector<RefPtr<CSSStyleSheet>>& documentAuthorStyleSheets() const { return m_authorStyleSheets; }
     const Vector<RefPtr<CSSStyleSheet>>& injectedUserStyleSheets() const;
@@ -64,10 +63,6 @@ public:
 
     void clearPageUserSheet();
     void updatePageUserSheet();
-    
-    void invalidateCaptionsStyleSheet();
-    void updateCaptionsStyleSheet();
-
     void invalidateInjectedStyleSheetCache();
     void updateInjectedStyleSheetCache() const;
 
@@ -146,7 +141,6 @@ private:
     int m_pendingStylesheets;
 
     RefPtr<CSSStyleSheet> m_pageUserSheet;
-    RefPtr<CSSStyleSheet> m_captionsStyleSheet;
 
     mutable Vector<RefPtr<CSSStyleSheet>> m_injectedUserStyleSheets;
     mutable Vector<RefPtr<CSSStyleSheet>> m_injectedAuthorStyleSheets;
index c660b66..35f0047 100644 (file)
@@ -379,7 +379,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
 #if ENABLE(VIDEO_TRACK)
     document.registerForCaptionPreferencesChangedCallbacks(this);
     if (document.page())
-        m_captionDisplayMode = document.page()->captionPreferences().captionDisplayMode();
+        m_captionDisplayMode = document.page()->group().captionPreferences()->captionDisplayMode();
 #endif
 }
 
@@ -3424,7 +3424,7 @@ void HTMLMediaElement::configureTextTrackGroup(const TrackGroup& group)
     LOG(Media, "HTMLMediaElement::configureTextTrackGroup");
 
     Page* page = document().page();
-    CaptionUserPreferences* captionPreferences = page ? &page->captionPreferences() : nullptr;
+    CaptionUserPreferences* captionPreferences = page? page->group().captionPreferences() : 0;
     CaptionUserPreferences::CaptionDisplayMode displayMode = captionPreferences ? captionPreferences->captionDisplayMode() : CaptionUserPreferences::Automatic;
 
     // First, find the track in the group that should be enabled (if any).
@@ -3534,10 +3534,11 @@ void HTMLMediaElement::setSelectedTextTrack(TextTrack* trackToSelect)
         }
     }
 
-    if (!document().page())
+    CaptionUserPreferences* captionPreferences = document().page() ? document().page()->group().captionPreferences() : 0;
+    if (!captionPreferences)
         return;
 
-    CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
+    CaptionUserPreferences::CaptionDisplayMode displayMode = captionPreferences->captionDisplayMode();
     if (trackToSelect == TextTrack::captionMenuOffItem())
         displayMode = CaptionUserPreferences::ForcedOnly;
     else if (trackToSelect == TextTrack::captionMenuAutomaticItem())
@@ -3545,13 +3546,13 @@ void HTMLMediaElement::setSelectedTextTrack(TextTrack* trackToSelect)
     else {
         displayMode = CaptionUserPreferences::AlwaysOn;
         if (trackToSelect->language().length())
-            document().page()->captionPreferences().setPreferredLanguage(trackToSelect->language());
+            captionPreferences->setPreferredLanguage(trackToSelect->language());
         
         // Set m_captionDisplayMode here so we don't reconfigure again when the preference changed notification comes through.
         m_captionDisplayMode = displayMode;
     }
 
-    document().page()->captionPreferences().setCaptionDisplayMode(displayMode);
+    captionPreferences->setCaptionDisplayMode(displayMode);
 }
 
 void HTMLMediaElement::configureTextTracks()
@@ -5255,8 +5256,8 @@ void HTMLMediaElement::captionPreferencesChanged()
 
     if (!document().page())
         return;
-    
-    CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
+
+    CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->group().captionPreferences()->captionDisplayMode();
     if (m_captionDisplayMode == displayMode)
         return;
 
index 0bd386a..91df2d9 100644 (file)
@@ -820,7 +820,7 @@ void MediaControlClosedCaptionsTrackListElement::updateDisplay()
 
     if (!document().page())
         return;
-    CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
+    CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->group().captionPreferences()->captionDisplayMode();
 
     HTMLMediaElement* mediaElement = parentMediaElement(this);
     if (!mediaElement)
@@ -896,9 +896,8 @@ void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu()
 
     if (!document().page())
         return;
-
-    CaptionUserPreferences& captionPreferences = document().page()->captionPreferences();
-    Vector<RefPtr<TextTrack>> tracksForMenu = captionPreferences.sortedTrackListForMenu(trackList);
+    CaptionUserPreferences* captionPreferences = document().page()->group().captionPreferences();
+    Vector<RefPtr<TextTrack>> tracksForMenu = captionPreferences->sortedTrackListForMenu(trackList);
 
     RefPtr<Element> captionsHeader = document().createElement(h3Tag, ASSERT_NO_EXCEPTION);
     captionsHeader->appendChild(document().createTextNode(textTrackSubtitlesText()));
@@ -908,7 +907,7 @@ void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu()
     for (unsigned i = 0, length = tracksForMenu.size(); i < length; ++i) {
         RefPtr<TextTrack> textTrack = tracksForMenu[i];
         RefPtr<Element> menuItem = document().createElement(liTag, ASSERT_NO_EXCEPTION);
-        menuItem->appendChild(document().createTextNode(captionPreferences.displayNameForTrack(textTrack.get())));
+        menuItem->appendChild(document().createTextNode(captionPreferences->displayNameForTrack(textTrack.get())));
         captionsMenuList->appendChild(menuItem);
         m_menuItems.append(menuItem);
         m_menuToTrackMap.add(menuItem, textTrack);
@@ -1332,7 +1331,7 @@ void MediaControlTextTrackContainerElement::updateTimerFired(Timer<MediaControlT
         return;
 
     float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
-    float fontScale = document().page()->captionPreferences().captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
+    float fontScale = document().page()->group().captionPreferences()->captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
     m_fontSize = lroundf(smallestDimension * fontScale);
     
     CueList activeCues = mediaElement->currentlyActiveCues();
diff --git a/Source/WebCore/page/CaptionStyleSheetMediaAF.cpp b/Source/WebCore/page/CaptionStyleSheetMediaAF.cpp
deleted file mode 100644 (file)
index e6f8700..0000000
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (C) 2014 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. AND ITS CONTRIBUTORS ``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 ITS 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.
- */
-
-#include "config.h"
-#include "CaptionStyleSheetMediaAF.h"
-
-#if ENABLE(VIDEO_TRACK)
-
-#include "CSSPropertyNames.h"
-#include "Color.h"
-#include "Logging.h"
-#include "SoftLinking.h"
-#include "TextTrackCue.h"
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
-
-#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-#include "CoreText/CoreText.h"
-#include <MediaAccessibility/MediaAccessibility.h>
-#endif
-
-#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-
-#if !PLATFORM(WIN)
-#define SOFT_LINK_AVF_FRAMEWORK(Lib) SOFT_LINK_FRAMEWORK_OPTIONAL(Lib)
-#define SOFT_LINK_AVF(Lib, Name, Type) SOFT_LINK(Lib, Name, Type)
-#define SOFT_LINK_AVF_POINTER(Lib, Name, Type) SOFT_LINK_POINTER_OPTIONAL(Lib, Name, Type)
-#define SOFT_LINK_AVF_FRAMEWORK_IMPORT(Lib, Fun, ReturnType, Arguments, Signature) SOFT_LINK(Lib, Fun, ReturnType, Arguments, Signature)
-#else
-
-#ifdef DEBUG_ALL
-#define SOFT_LINK_AVF_FRAMEWORK(Lib) SOFT_LINK_DEBUG_LIBRARY(Lib)
-#else
-#define SOFT_LINK_AVF_FRAMEWORK(Lib) SOFT_LINK_LIBRARY(Lib)
-#endif
-
-#define SOFT_LINK_AVF(Lib, Name, Type) SOFT_LINK_DLL_IMPORT(Lib, Name, Type)
-#define SOFT_LINK_AVF_POINTER(Lib, Name, Type) SOFT_LINK_VARIABLE_DLL_IMPORT_OPTIONAL(Lib, Name, Type)
-#define SOFT_LINK_AVF_FRAMEWORK_IMPORT(Lib, Fun, ReturnType, Arguments, Signature) SOFT_LINK_DLL_IMPORT(Lib, Fun, ReturnType, __cdecl, Arguments, Signature)
-#endif
-
-SOFT_LINK_AVF_FRAMEWORK(MediaAccessibility)
-SOFT_LINK_AVF_FRAMEWORK(CoreText)
-
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyForegroundColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyBackgroundColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyWindowColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetForegroundOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetBackgroundOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetWindowOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetWindowRoundedCornerRadius, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyFontDescriptorForStyle, CTFontDescriptorRef, (MACaptionAppearanceDomain domain,  MACaptionAppearanceBehavior *behavior, MACaptionAppearanceFontStyle fontStyle), (domain, behavior, fontStyle))
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetTextEdgeStyle, MACaptionAppearanceTextEdgeStyle, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
-
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(CoreText, CTFontDescriptorCopyAttribute,  CFTypeRef, (CTFontDescriptorRef descriptor, CFStringRef attribute), (descriptor, attribute));
-
-#if PLATFORM(WIN)
-// These are needed on Windows due to the way DLLs work. We do not need them on other platforms
-#define MACaptionAppearanceCopyForegroundColor softLink_MACaptionAppearanceCopyForegroundColor
-#define MACaptionAppearanceCopyBackgroundColor softLink_MACaptionAppearanceCopyBackgroundColor
-#define MACaptionAppearanceCopyWindowColor softLink_MACaptionAppearanceCopyWindowColor
-#define MACaptionAppearanceGetForegroundOpacity softLink_MACaptionAppearanceGetForegroundOpacity
-#define MACaptionAppearanceGetBackgroundOpacity softLink_MACaptionAppearanceGetBackgroundOpacity
-#define MACaptionAppearanceGetWindowOpacity softLink_MACaptionAppearanceGetWindowOpacity
-#define MACaptionAppearanceGetWindowRoundedCornerRadius softLink_MACaptionAppearanceGetWindowRoundedCornerRadius
-#define MACaptionAppearanceCopyFontDescriptorForStyle softLink_MACaptionAppearanceCopyFontDescriptorForStyle
-#define MACaptionAppearanceGetTextEdgeStyle softLink_MACaptionAppearanceGetTextEdgeStyle
-#define CTFontDescriptorCopyAttribute softLink_CTFontDescriptorCopyAttribute
-#endif
-
-SOFT_LINK_AVF_POINTER(CoreText, kCTFontNameAttribute, CFStringRef)
-#define kCTFontNameAttribute getkCTFontNameAttribute()
-#endif
-
-namespace WebCore {
-
-#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-
-static String captionsWindowCSS();
-static String captionsBackgroundCSS();
-static String captionsTextColorCSS();
-static Color captionsTextColor(bool&);
-static String captionsDefaultFontCSS();
-static Color captionsEdgeColorForTextColor(const Color&);
-static String windowRoundedCornerRadiusCSS();
-static String captionsTextEdgeCSS();
-static String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&, bool);
-static String colorPropertyCSS(CSSPropertyID, const Color&, bool);
-
-#endif
-
-String defaultCaptionsStyleSheet()
-{
-    StringBuilder captionsOverrideStyleSheet;
-
-#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-    if (!MediaAccessibilityLibrary())
-        return String();
-    
-    String captionsColor = captionsTextColorCSS();
-    String edgeStyle = captionsTextEdgeCSS();
-    String fontName = captionsDefaultFontCSS();
-    String background = captionsBackgroundCSS();
-    if (!background.isEmpty() || !captionsColor.isEmpty() || !edgeStyle.isEmpty() || !fontName.isEmpty()) {
-        captionsOverrideStyleSheet.append(" video::");
-        captionsOverrideStyleSheet.append(TextTrackCue::cueShadowPseudoId());
-        captionsOverrideStyleSheet.append('{');
-        
-        if (!background.isEmpty())
-            captionsOverrideStyleSheet.append(background);
-        if (!captionsColor.isEmpty())
-            captionsOverrideStyleSheet.append(captionsColor);
-        if (!edgeStyle.isEmpty())
-            captionsOverrideStyleSheet.append(edgeStyle);
-        if (!fontName.isEmpty())
-            captionsOverrideStyleSheet.append(fontName);
-        
-        captionsOverrideStyleSheet.append('}');
-    }
-    
-    String windowColor = captionsWindowCSS();
-    String windowCornerRadius = windowRoundedCornerRadiusCSS();
-    if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
-        captionsOverrideStyleSheet.append(" video::");
-        captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
-        captionsOverrideStyleSheet.append('{');
-        
-        if (!windowColor.isEmpty())
-            captionsOverrideStyleSheet.append(windowColor);
-        if (!windowCornerRadius.isEmpty())
-            captionsOverrideStyleSheet.append(windowCornerRadius);
-        
-        captionsOverrideStyleSheet.append('}');
-    }
-#endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-
-    LOG(Media, "CaptionUserPreferencesMediaAF::captionsStyleSheetOverrideSetting sytle to:\n%s", captionsOverrideStyleSheet.toString().utf8().data());
-
-    return captionsOverrideStyleSheet.toString();
-}
-
-#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-
-String captionsWindowCSS()
-{
-    MACaptionAppearanceBehavior behavior;
-    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyWindowColor(kMACaptionAppearanceDomainUser, &behavior));
-
-    Color windowColor(color.get());
-    if (!windowColor.isValid())
-        windowColor = Color::transparent;
-
-    bool important = behavior == kMACaptionAppearanceBehaviorUseValue;
-    CGFloat opacity = MACaptionAppearanceGetWindowOpacity(kMACaptionAppearanceDomainUser, &behavior);
-    if (!important)
-        important = behavior == kMACaptionAppearanceBehaviorUseValue;
-    String windowStyle = colorPropertyCSS(CSSPropertyBackgroundColor, Color(windowColor.red(), windowColor.green(), windowColor.blue(), static_cast<int>(opacity * 255)), important);
-
-    if (!opacity)
-        return windowStyle;
-
-    StringBuilder builder;
-    builder.append(windowStyle);
-    builder.append(getPropertyNameString(CSSPropertyPadding));
-    builder.append(": .4em !important;");
-
-    return builder.toString();
-}
-
-String captionsBackgroundCSS()
-{
-    // 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)));
-
-    MACaptionAppearanceBehavior behavior;
-
-    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyBackgroundColor(kMACaptionAppearanceDomainUser, &behavior));
-    Color backgroundColor(color.get());
-    if (!backgroundColor.isValid())
-        backgroundColor = defaultBackgroundColor;
-
-    bool important = behavior == kMACaptionAppearanceBehaviorUseValue;
-    CGFloat opacity = MACaptionAppearanceGetBackgroundOpacity(kMACaptionAppearanceDomainUser, &behavior);
-    if (!important)
-        important = behavior == kMACaptionAppearanceBehaviorUseValue;
-    return colorPropertyCSS(CSSPropertyBackgroundColor, Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), static_cast<int>(opacity * 255)), important);
-}
-
-Color captionsTextColor(bool& important)
-{
-    MACaptionAppearanceBehavior behavior;
-    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyForegroundColor(kMACaptionAppearanceDomainUser, &behavior));
-    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;
-    
-    important = behavior == kMACaptionAppearanceBehaviorUseValue;
-    CGFloat opacity = MACaptionAppearanceGetForegroundOpacity(kMACaptionAppearanceDomainUser, &behavior);
-    if (!important)
-        important = behavior == kMACaptionAppearanceBehaviorUseValue;
-    return Color(textColor.red(), textColor.green(), textColor.blue(), static_cast<int>(opacity * 255));
-}
-    
-String captionsTextColorCSS()
-{
-    bool important;
-    Color textColor = captionsTextColor(important);
-
-    if (!textColor.isValid())
-        return emptyString();
-
-    return colorPropertyCSS(CSSPropertyColor, textColor, important);
-}
-    
-String windowRoundedCornerRadiusCSS()
-{
-    MACaptionAppearanceBehavior behavior;
-    CGFloat radius = MACaptionAppearanceGetWindowRoundedCornerRadius(kMACaptionAppearanceDomainUser, &behavior);
-    if (!radius)
-        return emptyString();
-
-    StringBuilder builder;
-    builder.append(getPropertyNameString(CSSPropertyBorderRadius));
-    builder.append(String::format(":%.02fpx", radius));
-    if (behavior == kMACaptionAppearanceBehaviorUseValue)
-        builder.append(" !important");
-    builder.append(';');
-
-    return builder.toString();
-}
-    
-Color captionsEdgeColorForTextColor(const Color& textColor)
-{
-    int distanceFromWhite = differenceSquared(textColor, Color::white);
-    int distanceFromBlack = differenceSquared(textColor, Color::black);
-    
-    if (distanceFromWhite < distanceFromBlack)
-        return textColor.dark();
-    
-    return textColor.light();
-}
-
-String cssPropertyWithTextEdgeColor(CSSPropertyID id, const String& value, const Color& textColor, bool important)
-{
-    StringBuilder builder;
-    
-    builder.append(getPropertyNameString(id));
-    builder.append(':');
-    builder.append(value);
-    builder.append(' ');
-    builder.append(captionsEdgeColorForTextColor(textColor).serialized());
-    if (important)
-        builder.append(" !important");
-    builder.append(';');
-    
-    return builder.toString();
-}
-
-String colorPropertyCSS(CSSPropertyID id, const Color& color, bool important)
-{
-    StringBuilder builder;
-    
-    builder.append(getPropertyNameString(id));
-    builder.append(':');
-    builder.append(color.serialized());
-    if (important)
-        builder.append(" !important");
-    builder.append(';');
-    
-    return builder.toString();
-}
-
-String captionsTextEdgeCSS()
-{
-    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));
-
-    bool unused;
-    Color color = captionsTextColor(unused);
-    if (!color.isValid())
-        color.setNamedColor("black");
-    color = captionsEdgeColorForTextColor(color);
-
-    MACaptionAppearanceBehavior behavior;
-    MACaptionAppearanceTextEdgeStyle textEdgeStyle = MACaptionAppearanceGetTextEdgeStyle(kMACaptionAppearanceDomainUser, &behavior);
-    switch (textEdgeStyle) {
-    case kMACaptionAppearanceTextEdgeStyleUndefined:
-    case kMACaptionAppearanceTextEdgeStyleNone:
-        return emptyString();
-            
-    case kMACaptionAppearanceTextEdgeStyleRaised:
-        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleRaised, color, behavior == kMACaptionAppearanceBehaviorUseValue);
-    case kMACaptionAppearanceTextEdgeStyleDepressed:
-        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDepressed, color, behavior == kMACaptionAppearanceBehaviorUseValue);
-    case kMACaptionAppearanceTextEdgeStyleDropShadow:
-        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDropShadow, color, behavior == kMACaptionAppearanceBehaviorUseValue);
-    case kMACaptionAppearanceTextEdgeStyleUniform:
-        return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, edgeStyleUniform, color, behavior == kMACaptionAppearanceBehaviorUseValue);
-            
-    default:
-        ASSERT_NOT_REACHED();
-        break;
-    }
-    
-    return emptyString();
-}
-
-String captionsDefaultFontCSS()
-{
-    MACaptionAppearanceBehavior behavior;
-    
-    RetainPtr<CTFontDescriptorRef> font = adoptCF(MACaptionAppearanceCopyFontDescriptorForStyle(kMACaptionAppearanceDomainUser, &behavior, kMACaptionAppearanceFontStyleDefault));
-    if (!font)
-        return emptyString();
-
-    RetainPtr<CFTypeRef> name = adoptCF(CTFontDescriptorCopyAttribute(font.get(), kCTFontNameAttribute));
-    if (!name)
-        return emptyString();
-    
-    StringBuilder builder;
-    
-    builder.append(getPropertyNameString(CSSPropertyFontFamily));
-    builder.append(": \"");
-    builder.append(static_cast<CFStringRef>(name.get()));
-    builder.append('"');
-    if (behavior == kMACaptionAppearanceBehaviorUseValue)
-        builder.append(" !important");
-    builder.append(';');
-    
-    return builder.toString();
-}
-
-#endif
-
-} // namespace WebCore
-
-#endif // ENABLE(VIDEO_TRACK)
diff --git a/Source/WebCore/page/CaptionStyleSheetMediaAF.h b/Source/WebCore/page/CaptionStyleSheetMediaAF.h
deleted file mode 100644 (file)
index 148fb10..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2014 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. AND ITS CONTRIBUTORS ``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 ITS 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 CaptionStyleSheetMediaAF_h
-#define CaptionStyleSheetMediaAF_h
-
-#if ENABLE(VIDEO_TRACK)
-
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-String defaultCaptionsStyleSheet();
-
-}
-
-#endif // ENABLE(VIDEO_TRACK)
-#endif // CaptionStyleSheetMediaAF_h
index 4dc6998..adb570e 100644 (file)
 #if ENABLE(VIDEO_TRACK)
 
 #include "CaptionUserPreferences.h"
-
-#include "HTMLMediaElement.h"
+#include "DOMWrapperWorld.h"
 #include "Page.h"
-#include "PageCache.h"
+#include "PageGroup.h"
 #include "Settings.h"
 #include "TextTrackList.h"
+#include "UserStyleSheetTypes.h"
 
 namespace WebCore {
 
-CaptionUserPreferences::CaptionUserPreferences()
-    : m_timer(this, &CaptionUserPreferences::timerFired)
+CaptionUserPreferences::CaptionUserPreferences(PageGroup& group)
+    : m_pageGroup(group)
     , m_displayMode(ForcedOnly)
+    , m_timer(this, &CaptionUserPreferences::timerFired)
     , m_testingMode(false)
+    , m_havePreferences(false)
 {
 }
 
@@ -55,6 +57,7 @@ void CaptionUserPreferences::timerFired(Timer<CaptionUserPreferences>&)
 
 void CaptionUserPreferences::notify()
 {
+    m_havePreferences = true;
     if (!m_timer.isActive())
         m_timer.startOneShot(0);
 }
@@ -67,34 +70,73 @@ CaptionUserPreferences::CaptionDisplayMode CaptionUserPreferences::captionDispla
 void CaptionUserPreferences::setCaptionDisplayMode(CaptionUserPreferences::CaptionDisplayMode mode)
 {
     m_displayMode = mode;
+    if (m_testingMode && mode != AlwaysOn) {
+        setUserPrefersCaptions(false);
+        setUserPrefersSubtitles(false);
+    }
     notify();
 }
 
-bool CaptionUserPreferences::userPrefersCaptions(Document& document) const
+bool CaptionUserPreferences::userPrefersCaptions() const
 {
-    Settings* settings = document.settings();
-    if (!settings)
+    Page* page = *(m_pageGroup.pages().begin());
+    if (!page)
         return false;
 
-    return settings->shouldDisplayCaptions();
+    return page->settings().shouldDisplayCaptions();
 }
 
-bool CaptionUserPreferences::userPrefersSubtitles(Document& document) const
+void CaptionUserPreferences::setUserPrefersCaptions(bool preference)
 {
-    Settings* settings = document.settings();
-    if (!settings)
+    Page* page = *(m_pageGroup.pages().begin());
+    if (!page)
+        return;
+
+    page->settings().setShouldDisplayCaptions(preference);
+    notify();
+}
+
+bool CaptionUserPreferences::userPrefersSubtitles() const
+{
+    Page* page = *(pageGroup().pages().begin());
+    if (!page)
         return false;
 
-    return settings->shouldDisplaySubtitles();
+    return page->settings().shouldDisplaySubtitles();
 }
 
-bool CaptionUserPreferences::userPrefersTextDescriptions(Document& document) const
+void CaptionUserPreferences::setUserPrefersSubtitles(bool preference)
 {
-    Settings* settings = document.settings();
-    if (!settings)
+    Page* page = *(m_pageGroup.pages().begin());
+    if (!page)
+        return;
+
+    page->settings().setShouldDisplaySubtitles(preference);
+    notify();
+}
+
+bool CaptionUserPreferences::userPrefersTextDescriptions() const
+{
+    Page* page = *(m_pageGroup.pages().begin());
+    if (!page)
         return false;
+    
+    return page->settings().shouldDisplayTextDescriptions();
+}
+
+void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference)
+{
+    Page* page = *(m_pageGroup.pages().begin());
+    if (!page)
+        return;
+    
+    page->settings().setShouldDisplayTextDescriptions(preference);
+    notify();
+}
 
-    return settings->shouldDisplayTextDescriptions();
+void CaptionUserPreferences::captionPreferencesChanged()
+{
+    m_pageGroup.captionPreferencesChanged();
 }
 
 Vector<String> CaptionUserPreferences::preferredLanguages() const
@@ -154,19 +196,19 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferences::sortedTrackListForMenu(TextTra
     return tracksForMenu;
 }
 
-int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement* element) const
+int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement*) const
 {
     int trackScore = 0;
 
     if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword())
         return trackScore;
     
-    if (!userPrefersSubtitles(element->document()) && !userPrefersCaptions(element->document()))
+    if (!userPrefersSubtitles() && !userPrefersCaptions())
         return trackScore;
     
-    if (track->kind() == TextTrack::subtitlesKeyword() && userPrefersSubtitles(element->document()))
+    if (track->kind() == TextTrack::subtitlesKeyword() && userPrefersSubtitles())
         trackScore = 1;
-    else if (track->kind() == TextTrack::captionsKeyword() && userPrefersCaptions(element->document()))
+    else if (track->kind() == TextTrack::captionsKeyword() && userPrefersCaptions())
         trackScore = 1;
     
     return trackScore + textTrackLanguageSelectionScore(track, preferredLanguages());
@@ -186,23 +228,25 @@ int CaptionUserPreferences::textTrackLanguageSelectionScore(TextTrack* track, co
     return (preferredLanguages.size() - languageMatchIndex) * 10;
 }
 
-String CaptionUserPreferences::captionsStyleSheet()
-{
-    if (!m_captionsStyleSheetOverride.isEmpty() || testingMode())
-        return m_captionsStyleSheetOverride;
-
-    return platformCaptionsStyleSheet();
-}
-
 void CaptionUserPreferences::setCaptionsStyleSheetOverride(const String& override)
 {
     m_captionsStyleSheetOverride = override;
-    captionPreferencesChanged();
+    updateCaptionStyleSheetOveride();
 }
 
-String CaptionUserPreferences::captionsStyleSheetOverride() const
+void CaptionUserPreferences::updateCaptionStyleSheetOveride()
 {
-    return m_captionsStyleSheetOverride;
+    // Identify our override style sheet with a unique URL - a new scheme and a UUID.
+    DEFINE_STATIC_LOCAL(URL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"));
+
+    m_pageGroup.removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL);
+
+    String captionsOverrideStyleSheet = captionsStyleSheetOverride();
+    if (captionsOverrideStyleSheet.isEmpty())
+        return;
+
+    m_pageGroup.addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, Vector<String>(),
+        Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments);
 }
 
 String CaptionUserPreferences::primaryAudioTrackLanguageOverride() const
@@ -211,13 +255,7 @@ String CaptionUserPreferences::primaryAudioTrackLanguageOverride() const
         return m_primaryAudioTrackLanguageOverride;
     return defaultLanguage();
 }
-
-void CaptionUserPreferences::captionPreferencesChanged()
-{
-    Page::updateStyleForAllPagesForCaptionPreferencesChanged();
-    pageCache()->markPagesForCaptionPreferencesChanged();
+    
 }
 
-} // namespace WebCore
-
 #endif // ENABLE(VIDEO_TRACK)
index 9698219..3e5a3b9 100644 (file)
@@ -43,60 +43,69 @@ class TextTrackList;
 
 class CaptionUserPreferences {
 public:
-    CaptionUserPreferences();
+    CaptionUserPreferences(PageGroup&);
     virtual ~CaptionUserPreferences();
 
-    String captionsStyleSheet();
-
     enum CaptionDisplayMode {
         Automatic,
         ForcedOnly,
         AlwaysOn
     };
-
     virtual CaptionDisplayMode captionDisplayMode() const;
     virtual void setCaptionDisplayMode(CaptionDisplayMode);
 
     virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const;
     virtual int textTrackLanguageSelectionScore(TextTrack*, const Vector<String>&) const;
-    virtual bool userPrefersCaptions(Document&) const;
-    virtual bool userPrefersSubtitles(Document&) const;
-    virtual bool userPrefersTextDescriptions(Document&) const;
+
+    virtual bool userPrefersCaptions() const;
+    virtual void setUserPrefersCaptions(bool);
+
+    virtual bool userPrefersSubtitles() const;
+    virtual void setUserPrefersSubtitles(bool preference);
+    
+    virtual bool userPrefersTextDescriptions() const;
+    virtual void setUserPrefersTextDescriptions(bool preference);
 
     virtual float captionFontSizeScaleAndImportance(bool& important) const { important = false; return 0.05f; }
 
+    virtual String captionsStyleSheetOverride() const { return m_captionsStyleSheetOverride; }
+    virtual void setCaptionsStyleSheetOverride(const String&);
+
+    virtual void setInterestedInCaptionPreferenceChanges() { }
+
+    virtual void captionPreferencesChanged();
+
     virtual void setPreferredLanguage(const String&);
     virtual Vector<String> preferredLanguages() const;
 
     virtual String displayNameForTrack(TextTrack*) const;
     virtual Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*);
 
-    void captionPreferencesChanged();
-
-    // These are used for testing mode only.
-    void setCaptionsStyleSheetOverride(const String&);
-    String captionsStyleSheetOverride() const;
     void setPrimaryAudioTrackLanguageOverride(const String& language) { m_primaryAudioTrackLanguageOverride = language;  }
     String primaryAudioTrackLanguageOverride() const;
-    void setTestingMode(bool override) { m_testingMode = override; }
-    bool testingMode() const { return m_testingMode; }
+
+    virtual bool testingMode() const { return m_testingMode; }
+    virtual void setTestingMode(bool override) { m_testingMode = override; }
     
+    PageGroup& pageGroup() const { return m_pageGroup; }
+
+protected:
+    void updateCaptionStyleSheetOveride();
+
 private:
     void timerFired(Timer<CaptionUserPreferences>&);
     void notify();
 
-    virtual String platformCaptionsStyleSheet() { return String(); }
-
-    Timer<CaptionUserPreferences> m_timer;
-
-    // These are used for testing mode only.
+    PageGroup& m_pageGroup;
     CaptionDisplayMode m_displayMode;
+    Timer<CaptionUserPreferences> m_timer;
     String m_userPreferredLanguage;
     String m_captionsStyleSheetOverride;
     String m_primaryAudioTrackLanguageOverride;
     bool m_testingMode;
+    bool m_havePreferences;
 };
-
+    
 }
 #endif
 
index e92815e..55026d3 100644 (file)
@@ -29,7 +29,9 @@
 
 #include "CaptionUserPreferencesMediaAF.h"
 
-#include "CaptionStyleSheetMediaAF.h"
+#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+#include "CoreText/CoreText.h"
+#endif
 #include "FloatConversion.h"
 #include "HTMLMediaElement.h"
 #include "URL.h"
@@ -40,6 +42,7 @@
 #include "SoftLinking.h"
 #include "TextTrackCue.h"
 #include "TextTrackList.h"
+#include "UserStyleSheetTypes.h"
 #include <wtf/RetainPtr.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 #endif
 
 SOFT_LINK_AVF_FRAMEWORK(MediaAccessibility)
+SOFT_LINK_AVF_FRAMEWORK(CoreText)
 
 SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetDisplayType, MACaptionAppearanceDisplayType, (MACaptionAppearanceDomain domain), (domain))
 SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceSetDisplayType, void, (MACaptionAppearanceDomain domain, MACaptionAppearanceDisplayType displayType), (domain, displayType))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyForegroundColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyBackgroundColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyWindowColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetForegroundOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetBackgroundOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetWindowOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetWindowRoundedCornerRadius, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyFontDescriptorForStyle, CTFontDescriptorRef, (MACaptionAppearanceDomain domain,  MACaptionAppearanceBehavior *behavior, MACaptionAppearanceFontStyle fontStyle), (domain, behavior, fontStyle))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetRelativeCharacterSize, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetTextEdgeStyle, MACaptionAppearanceTextEdgeStyle, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
 SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceAddSelectedLanguage, bool, (MACaptionAppearanceDomain domain, CFStringRef language), (domain, language));
 SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopySelectedLanguages, CFArrayRef, (MACaptionAppearanceDomain domain), (domain));
 SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics,  CFArrayRef, (MACaptionAppearanceDomain domain), (domain));
-SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetRelativeCharacterSize, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
+
+SOFT_LINK_AVF_FRAMEWORK_IMPORT(CoreText, CTFontDescriptorCopyAttribute,  CFTypeRef, (CTFontDescriptorRef descriptor, CFStringRef attribute), (descriptor, attribute));
 
 #if PLATFORM(WIN)
 // These are needed on Windows due to the way DLLs work. We do not need them on other platforms
 #define MACaptionAppearanceGetDisplayType softLink_MACaptionAppearanceGetDisplayType
 #define MACaptionAppearanceSetDisplayType softLink_MACaptionAppearanceSetDisplayType
+#define MACaptionAppearanceCopyForegroundColor softLink_MACaptionAppearanceCopyForegroundColor
+#define MACaptionAppearanceCopyBackgroundColor softLink_MACaptionAppearanceCopyBackgroundColor
+#define MACaptionAppearanceCopyWindowColor softLink_MACaptionAppearanceCopyWindowColor
+#define MACaptionAppearanceGetForegroundOpacity softLink_MACaptionAppearanceGetForegroundOpacity
+#define MACaptionAppearanceGetBackgroundOpacity softLink_MACaptionAppearanceGetBackgroundOpacity
+#define MACaptionAppearanceGetWindowOpacity softLink_MACaptionAppearanceGetWindowOpacity
+#define MACaptionAppearanceGetWindowRoundedCornerRadius softLink_MACaptionAppearanceGetWindowRoundedCornerRadius
+#define MACaptionAppearanceCopyFontDescriptorForStyle softLink_MACaptionAppearanceCopyFontDescriptorForStyle
+#define MACaptionAppearanceGetRelativeCharacterSize softLink_MACaptionAppearanceGetRelativeCharacterSize
+#define MACaptionAppearanceGetTextEdgeStyle softLink_MACaptionAppearanceGetTextEdgeStyle
 #define MACaptionAppearanceAddSelectedLanguage softLink_MACaptionAppearanceAddSelectedLanguage
 #define MACaptionAppearanceCopySelectedLanguages softLink_MACaptionAppearanceCopySelectedLanguages
 #define MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics softLink_MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics
-#define MACaptionAppearanceGetRelativeCharacterSize softLink_MACaptionAppearanceGetRelativeCharacterSize
+#define CTFontDescriptorCopyAttribute softLink_CTFontDescriptorCopyAttribute
 #endif
 
 SOFT_LINK_AVF_POINTER(MediaAccessibility, kMAXCaptionAppearanceSettingsChangedNotification, CFStringRef)
 #define kMAXCaptionAppearanceSettingsChangedNotification getkMAXCaptionAppearanceSettingsChangedNotification()
 
+SOFT_LINK_AVF_POINTER(CoreText, kCTFontNameAttribute, CFStringRef)
+#define kCTFontNameAttribute getkCTFontNameAttribute()
 #endif
 
-
 namespace WebCore {
 
 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
 static void userCaptionPreferencesChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void *, CFDictionaryRef)
 {
 #if !PLATFORM(IOS)
-    static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionApperenceChanged();
+    static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionPreferencesChanged();
 #else
     WebThreadRun(^{
-        static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionApperenceChanged();
+        static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionPreferencesChanged();
     });
 #endif
 }
 #endif
 
-CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF()
-{
+CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF(PageGroup& group)
+    : CaptionUserPreferences(group)
 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-    if (MediaAccessibilityLibrary() && kMAXCaptionAppearanceSettingsChangedNotification)
-        CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, 0, CFNotificationSuspensionBehaviorCoalesce);
+    , m_listeningForPreferenceChanges(false)
 #endif
+{
 }
 
 CaptionUserPreferencesMediaAF::~CaptionUserPreferencesMediaAF()
@@ -130,15 +156,6 @@ CaptionUserPreferencesMediaAF::~CaptionUserPreferencesMediaAF()
 
 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
 
-void CaptionUserPreferencesMediaAF::captionApperenceChanged()
-{
-    // Invalidate the caption style sheet.
-    m_captionStyleSheet = String();
-
-    // Tell the base class to invalidate all the uses of it.
-    captionPreferencesChanged();
-}
-
 CaptionUserPreferences::CaptionDisplayMode CaptionUserPreferencesMediaAF::captionDisplayMode() const
 {
     if (testingMode() || !MediaAccessibilityLibrary())
@@ -189,9 +206,9 @@ void CaptionUserPreferencesMediaAF::setCaptionDisplayMode(CaptionUserPreferences
     MACaptionAppearanceSetDisplayType(kMACaptionAppearanceDomainUser, displayType);
 }
 
-bool CaptionUserPreferencesMediaAF::userPrefersCaptions(Document& document) const
+bool CaptionUserPreferencesMediaAF::userPrefersCaptions() const
 {
-    bool captionSetting = CaptionUserPreferences::userPrefersCaptions(document);
+    bool captionSetting = CaptionUserPreferences::userPrefersCaptions();
     if (captionSetting || testingMode() || !MediaAccessibilityLibrary())
         return captionSetting;
     
@@ -199,9 +216,9 @@ bool CaptionUserPreferencesMediaAF::userPrefersCaptions(Document& document) cons
     return captioningMediaCharacteristics && CFArrayGetCount(captioningMediaCharacteristics.get());
 }
 
-bool CaptionUserPreferencesMediaAF::userPrefersSubtitles(Document& document) const
+bool CaptionUserPreferencesMediaAF::userPrefersSubtitles() const
 {
-    bool subtitlesSetting = CaptionUserPreferences::userPrefersSubtitles(document);
+    bool subtitlesSetting = CaptionUserPreferences::userPrefersSubtitles();
     if (subtitlesSetting || testingMode() || !MediaAccessibilityLibrary())
         return subtitlesSetting;
     
@@ -209,6 +226,222 @@ bool CaptionUserPreferencesMediaAF::userPrefersSubtitles(Document& document) con
     return !(captioningMediaCharacteristics && CFArrayGetCount(captioningMediaCharacteristics.get()));
 }
 
+void CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges()
+{
+    if (!MediaAccessibilityLibrary())
+        return;
+
+    if (!kMAXCaptionAppearanceSettingsChangedNotification)
+        return;
+
+    if (!m_listeningForPreferenceChanges) {
+        m_listeningForPreferenceChanges = true;
+        CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, 0, CFNotificationSuspensionBehaviorCoalesce);
+        updateCaptionStyleSheetOveride();
+    }
+}
+
+void CaptionUserPreferencesMediaAF::captionPreferencesChanged()
+{
+    if (m_listeningForPreferenceChanges)
+        updateCaptionStyleSheetOveride();
+
+    CaptionUserPreferences::captionPreferencesChanged();
+}
+
+String CaptionUserPreferencesMediaAF::captionsWindowCSS() const
+{
+    MACaptionAppearanceBehavior behavior;
+    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyWindowColor(kMACaptionAppearanceDomainUser, &behavior));
+
+    Color windowColor(color.get());
+    if (!windowColor.isValid())
+        windowColor = Color::transparent;
+
+    bool important = behavior == kMACaptionAppearanceBehaviorUseValue;
+    CGFloat opacity = MACaptionAppearanceGetWindowOpacity(kMACaptionAppearanceDomainUser, &behavior);
+    if (!important)
+        important = behavior == kMACaptionAppearanceBehaviorUseValue;
+    String windowStyle = colorPropertyCSS(CSSPropertyBackgroundColor, Color(windowColor.red(), windowColor.green(), windowColor.blue(), static_cast<int>(opacity * 255)), important);
+
+    if (!opacity)
+        return windowStyle;
+
+    StringBuilder builder;
+    builder.append(windowStyle);
+    builder.append(getPropertyNameString(CSSPropertyPadding));
+    builder.append(": .4em !important;");
+
+    return builder.toString();
+}
+
+String CaptionUserPreferencesMediaAF::captionsBackgroundCSS() 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)));
+
+    MACaptionAppearanceBehavior behavior;
+
+    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyBackgroundColor(kMACaptionAppearanceDomainUser, &behavior));
+    Color backgroundColor(color.get());
+    if (!backgroundColor.isValid())
+        backgroundColor = defaultBackgroundColor;
+
+    bool important = behavior == kMACaptionAppearanceBehaviorUseValue;
+    CGFloat opacity = MACaptionAppearanceGetBackgroundOpacity(kMACaptionAppearanceDomainUser, &behavior);
+    if (!important)
+        important = behavior == kMACaptionAppearanceBehaviorUseValue;
+    return colorPropertyCSS(CSSPropertyBackgroundColor, Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), static_cast<int>(opacity * 255)), important);
+}
+
+Color CaptionUserPreferencesMediaAF::captionsTextColor(bool& important) const
+{
+    MACaptionAppearanceBehavior behavior;
+    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyForegroundColor(kMACaptionAppearanceDomainUser, &behavior));
+    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;
+    
+    important = behavior == kMACaptionAppearanceBehaviorUseValue;
+    CGFloat opacity = MACaptionAppearanceGetForegroundOpacity(kMACaptionAppearanceDomainUser, &behavior);
+    if (!important)
+        important = behavior == kMACaptionAppearanceBehaviorUseValue;
+    return Color(textColor.red(), textColor.green(), textColor.blue(), static_cast<int>(opacity * 255));
+}
+    
+String CaptionUserPreferencesMediaAF::captionsTextColorCSS() const
+{
+    bool important;
+    Color textColor = captionsTextColor(important);
+
+    if (!textColor.isValid())
+        return emptyString();
+
+    return colorPropertyCSS(CSSPropertyColor, textColor, important);
+}
+    
+String CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS() const
+{
+    MACaptionAppearanceBehavior behavior;
+    CGFloat radius = MACaptionAppearanceGetWindowRoundedCornerRadius(kMACaptionAppearanceDomainUser, &behavior);
+    if (!radius)
+        return emptyString();
+
+    StringBuilder builder;
+    builder.append(getPropertyNameString(CSSPropertyBorderRadius));
+    builder.append(String::format(":%.02fpx", radius));
+    if (behavior == kMACaptionAppearanceBehaviorUseValue)
+        builder.append(" !important");
+    builder.append(';');
+
+    return builder.toString();
+}
+    
+Color CaptionUserPreferencesMediaAF::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 CaptionUserPreferencesMediaAF::cssPropertyWithTextEdgeColor(CSSPropertyID id, const String& value, const Color& textColor, bool important) const
+{
+    StringBuilder builder;
+    
+    builder.append(getPropertyNameString(id));
+    builder.append(':');
+    builder.append(value);
+    builder.append(' ');
+    builder.append(captionsEdgeColorForTextColor(textColor).serialized());
+    if (important)
+        builder.append(" !important");
+    builder.append(';');
+    
+    return builder.toString();
+}
+
+String CaptionUserPreferencesMediaAF::colorPropertyCSS(CSSPropertyID id, const Color& color, bool important) const
+{
+    StringBuilder builder;
+    
+    builder.append(getPropertyNameString(id));
+    builder.append(':');
+    builder.append(color.serialized());
+    if (important)
+        builder.append(" !important");
+    builder.append(';');
+    
+    return builder.toString();
+}
+
+String CaptionUserPreferencesMediaAF::captionsTextEdgeCSS() 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));
+
+    bool unused;
+    Color color = captionsTextColor(unused);
+    if (!color.isValid())
+        color.setNamedColor("black");
+    color = captionsEdgeColorForTextColor(color);
+
+    MACaptionAppearanceBehavior behavior;
+    MACaptionAppearanceTextEdgeStyle textEdgeStyle = MACaptionAppearanceGetTextEdgeStyle(kMACaptionAppearanceDomainUser, &behavior);
+    switch (textEdgeStyle) {
+    case kMACaptionAppearanceTextEdgeStyleUndefined:
+    case kMACaptionAppearanceTextEdgeStyleNone:
+        return emptyString();
+            
+    case kMACaptionAppearanceTextEdgeStyleRaised:
+        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleRaised, color, behavior == kMACaptionAppearanceBehaviorUseValue);
+    case kMACaptionAppearanceTextEdgeStyleDepressed:
+        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDepressed, color, behavior == kMACaptionAppearanceBehaviorUseValue);
+    case kMACaptionAppearanceTextEdgeStyleDropShadow:
+        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDropShadow, color, behavior == kMACaptionAppearanceBehaviorUseValue);
+    case kMACaptionAppearanceTextEdgeStyleUniform:
+        return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, edgeStyleUniform, color, behavior == kMACaptionAppearanceBehaviorUseValue);
+            
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+    
+    return emptyString();
+}
+
+String CaptionUserPreferencesMediaAF::captionsDefaultFontCSS() const
+{
+    MACaptionAppearanceBehavior behavior;
+    
+    RetainPtr<CTFontDescriptorRef> font = adoptCF(MACaptionAppearanceCopyFontDescriptorForStyle(kMACaptionAppearanceDomainUser, &behavior, kMACaptionAppearanceFontStyleDefault));
+    if (!font)
+        return emptyString();
+
+    RetainPtr<CFTypeRef> name = adoptCF(CTFontDescriptorCopyAttribute(font.get(), kCTFontNameAttribute));
+    if (!name)
+        return emptyString();
+    
+    StringBuilder builder;
+    
+    builder.append(getPropertyNameString(CSSPropertyFontFamily));
+    builder.append(": \"");
+    builder.append(static_cast<CFStringRef>(name.get()));
+    builder.append('"');
+    if (behavior == kMACaptionAppearanceBehaviorUseValue)
+        builder.append(" !important");
+    builder.append(';');
+    
+    return builder.toString();
+}
+
 float CaptionUserPreferencesMediaAF::captionFontSizeScaleAndImportance(bool& important) const
 {
     if (testingMode() || !MediaAccessibilityLibrary())
@@ -274,6 +507,58 @@ Vector<String> CaptionUserPreferencesMediaAF::preferredLanguages() const
 }
 #endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
 
+String CaptionUserPreferencesMediaAF::captionsStyleSheetOverride() const
+{
+    if (testingMode())
+        return CaptionUserPreferences::captionsStyleSheetOverride();
+    
+    StringBuilder captionsOverrideStyleSheet;
+
+#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+    if (!MediaAccessibilityLibrary())
+        return CaptionUserPreferences::captionsStyleSheetOverride();
+    
+    String captionsColor = captionsTextColorCSS();
+    String edgeStyle = captionsTextEdgeCSS();
+    String fontName = captionsDefaultFontCSS();
+    String background = captionsBackgroundCSS();
+    if (!background.isEmpty() || !captionsColor.isEmpty() || !edgeStyle.isEmpty() || !fontName.isEmpty()) {
+        captionsOverrideStyleSheet.append(" video::");
+        captionsOverrideStyleSheet.append(TextTrackCue::cueShadowPseudoId());
+        captionsOverrideStyleSheet.append('{');
+        
+        if (!background.isEmpty())
+            captionsOverrideStyleSheet.append(background);
+        if (!captionsColor.isEmpty())
+            captionsOverrideStyleSheet.append(captionsColor);
+        if (!edgeStyle.isEmpty())
+            captionsOverrideStyleSheet.append(edgeStyle);
+        if (!fontName.isEmpty())
+            captionsOverrideStyleSheet.append(fontName);
+        
+        captionsOverrideStyleSheet.append('}');
+    }
+    
+    String windowColor = captionsWindowCSS();
+    String windowCornerRadius = windowRoundedCornerRadiusCSS();
+    if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
+        captionsOverrideStyleSheet.append(" video::");
+        captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
+        captionsOverrideStyleSheet.append('{');
+        
+        if (!windowColor.isEmpty())
+            captionsOverrideStyleSheet.append(windowColor);
+        if (!windowCornerRadius.isEmpty())
+            captionsOverrideStyleSheet.append(windowCornerRadius);
+        
+        captionsOverrideStyleSheet.append('}');
+    }
+#endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+
+    LOG(Media, "CaptionUserPreferencesMediaAF::captionsStyleSheetOverrideSetting sytle to:\n%s", captionsOverrideStyleSheet.toString().utf8().data());
+
+    return captionsOverrideStyleSheet.toString();
+}
 
 static String languageIdentifier(const String& languageCode)
 {
@@ -350,14 +635,6 @@ static String trackDisplayName(TextTrack* track)
     return displayName.toString();
 }
 
-String CaptionUserPreferencesMediaAF::platformCaptionsStyleSheet()
-{
-    if (!m_captionStyleSheet)
-        m_captionStyleSheet = defaultCaptionsStyleSheet();
-
-    return m_captionStyleSheet;
-}
-
 String CaptionUserPreferencesMediaAF::displayNameForTrack(TextTrack* track) const
 {
     return trackDisplayName(track);
@@ -367,7 +644,7 @@ int CaptionUserPreferencesMediaAF::textTrackSelectionScore(TextTrack* track, HTM
 {
     CaptionDisplayMode displayMode = captionDisplayMode();
     bool legacyOverride = mediaElement->webkitClosedCaptionsVisible();
-    if (displayMode == AlwaysOn && (!userPrefersSubtitles(mediaElement->document()) && !userPrefersCaptions(mediaElement->document()) && !legacyOverride))
+    if (displayMode == AlwaysOn && (!userPrefersSubtitles() && !userPrefersCaptions() && !legacyOverride))
         return 0;
     if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword() && track->kind() != TextTrack::forcedKeyword())
         return 0;
@@ -427,7 +704,7 @@ int CaptionUserPreferencesMediaAF::textTrackSelectionScore(TextTrack* track, HTM
 
     int trackScore = 0;
 
-    if (userPrefersCaptions(mediaElement->document())) {
+    if (userPrefersCaptions()) {
         // When the user prefers accessiblity tracks, rank is SDH, then CC, then subtitles.
         if (track->kind() == track->subtitlesKeyword())
             trackScore = 1;
@@ -489,7 +766,7 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferencesMediaAF::sortedTrackListForMenu(
 
     Vector<RefPtr<TextTrack>> tracksForMenu;
     HashSet<String> languagesIncluded;
-    bool prefersAccessibilityTracks = userPrefersCaptions(trackList->mediaElement()->document());
+    bool prefersAccessibilityTracks = userPrefersCaptions();
     bool filterTrackList = shouldFilterTrackMenu();
 
     for (unsigned i = 0, length = trackList->length(); i < length; ++i) {
@@ -571,7 +848,7 @@ Vector<RefPtr<TextTrack>> CaptionUserPreferencesMediaAF::sortedTrackListForMenu(
 
     return tracksForMenu;
 }
-
+    
 }
 
 #endif // ENABLE(VIDEO_TRACK)
index 13a3869..823f8aa 100644 (file)
@@ -37,35 +37,50 @@ namespace WebCore {
 
 class CaptionUserPreferencesMediaAF : public CaptionUserPreferences {
 public:
-    CaptionUserPreferencesMediaAF();
+    CaptionUserPreferencesMediaAF(PageGroup&);
     virtual ~CaptionUserPreferencesMediaAF();
 
 #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-    void captionApperenceChanged();
-
     virtual CaptionDisplayMode captionDisplayMode() const override;
     virtual void setCaptionDisplayMode(CaptionDisplayMode) override;
 
-    virtual bool userPrefersCaptions(Document&) const override;
-    virtual bool userPrefersSubtitles(Document&) const override;
+    virtual bool userPrefersCaptions() const override;
+    virtual bool userPrefersSubtitles() const override;
 
     virtual float captionFontSizeScaleAndImportance(bool&) const override;
 
+    virtual void setInterestedInCaptionPreferenceChanges() override;
+
     virtual void setPreferredLanguage(const String&) override;
     virtual Vector<String> preferredLanguages() const override;
 
+    virtual void captionPreferencesChanged() override;
+
     bool shouldFilterTrackMenu() const { return true; }
 #else
     bool shouldFilterTrackMenu() const { return false; }
 #endif
 
-    virtual String platformCaptionsStyleSheet() override;
+    virtual String captionsStyleSheetOverride() const override;
     virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const override;
     virtual Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*) override;
     virtual String displayNameForTrack(TextTrack*) const override;
 
 private:
-    String m_captionStyleSheet;
+#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+    String captionsWindowCSS() const;
+    String captionsBackgroundCSS() const;
+    String captionsTextColorCSS() const;
+    Color captionsTextColor(bool&) const;
+    String captionsDefaultFontCSS() const;
+    Color captionsEdgeColorForTextColor(const Color&) const;
+    String windowRoundedCornerRadiusCSS() const;
+    String captionsTextEdgeCSS() const;
+    String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&, bool) const;
+    String colorPropertyCSS(CSSPropertyID, const Color&, bool) const;
+
+    bool m_listeningForPreferenceChanges;
+#endif
 };
 
 }
index 8e757c3..d4638e9 100644 (file)
 #include <wtf/text/Base64.h>
 #include <wtf/text/StringHash.h>
 
-#if ENABLE(VIDEO_TRACK)
-#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-#include "CaptionUserPreferencesMediaAF.h"
-#else
-#include "CaptionUserPreferences.h"
-#endif
-#endif
-
 namespace WebCore {
 
 static HashSet<Page*>* allPages;
@@ -1501,28 +1493,6 @@ void Page::hiddenPageCSSAnimationSuspensionStateChanged()
 #endif
 
 #if ENABLE(VIDEO_TRACK)
-CaptionUserPreferences& Page::captionPreferences()
-{
-    // FIXME: This should not be a singleton.
-#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-    static NeverDestroyed<CaptionUserPreferencesMediaAF> preferences;
-#else
-    static NeverDestroyed<CaptionUserPreferences> preferences;
-#endif
-
-    return preferences;
-}
-
-void Page::updateStyleForAllPagesForCaptionPreferencesChanged()
-{
-    if (!allPages)
-        return;
-
-    for (auto page : *allPages)
-        page->captionPreferencesChanged();
-}
-
-
 void Page::captionPreferencesChanged()
 {
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
index e5b5070..f0b3317 100644 (file)
@@ -61,7 +61,6 @@ namespace WebCore {
 class AlternativeTextClient;
 class BackForwardController;
 class BackForwardClient;
-class CaptionUserPreferences;
 class Chrome;
 class ChromeClient;
 class ClientRectList;
@@ -403,8 +402,6 @@ public:
 #endif
 
 #if ENABLE(VIDEO_TRACK)
-    static void updateStyleForAllPagesForCaptionPreferencesChanged();
-    CaptionUserPreferences& captionPreferences();
     void captionPreferencesChanged();
 #endif
 
index 709a6ba..8a1cd20 100644 (file)
 #include "VisitedLinkProvider.h"
 #include <wtf/StdLibExtras.h>
 
+#if ENABLE(VIDEO_TRACK)
+#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+#include "CaptionUserPreferencesMediaAF.h"
+#else
+#include "CaptionUserPreferences.h"
+#endif
+#endif
+
 namespace WebCore {
 
 static unsigned getUniqueIdentifier()
@@ -302,4 +310,26 @@ void PageGroup::removeAllUserContent()
     m_userContentController->removeAllUserContent();
 }
 
+#if ENABLE(VIDEO_TRACK)
+void PageGroup::captionPreferencesChanged()
+{
+    for (auto it = m_pages.begin(), end = m_pages.end(); it != end; ++it)
+        (*it)->captionPreferencesChanged();
+    pageCache()->markPagesForCaptionPreferencesChanged();
+}
+
+CaptionUserPreferences* PageGroup::captionPreferences()
+{
+    if (!m_captionPreferences) {
+#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+        m_captionPreferences = std::make_unique<CaptionUserPreferencesMediaAF>(*this);
+#else
+        m_captionPreferences = std::make_unique<CaptionUserPreferences>(*this);
+#endif
+    }
+
+    return m_captionPreferences.get();
+}
+#endif
+
 } // namespace WebCore
index 06cb2e9..01f2e33 100644 (file)
@@ -45,6 +45,11 @@ namespace WebCore {
     class VisitedLinkProvider;
     class UserContentController;
 
+#if ENABLE(VIDEO_TRACK)
+    class CaptionPreferencesChangedListener;
+    class CaptionUserPreferences;
+#endif
+
     class PageGroup : public Supplementable<PageGroup> {
         WTF_MAKE_NONCOPYABLE(PageGroup); WTF_MAKE_FAST_ALLOCATED;
     public:
@@ -98,6 +103,11 @@ namespace WebCore {
 
         GroupSettings& groupSettings() const { return *m_groupSettings; }
 
+#if ENABLE(VIDEO_TRACK)
+        void captionPreferencesChanged();
+        CaptionUserPreferences* captionPreferences();
+#endif
+
     private:
         void addVisitedLink(LinkHash);
 
@@ -116,6 +126,10 @@ namespace WebCore {
         RefPtr<UserContentController> m_userContentController;
 
         const std::unique_ptr<GroupSettings> m_groupSettings;
+
+#if ENABLE(VIDEO_TRACK)
+        std::unique_ptr<CaptionUserPreferences> m_captionPreferences;
+#endif
     };
 
 } // namespace WebCore
index 69c67d2..dc7da1e 100644 (file)
@@ -413,12 +413,16 @@ void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enable
     InternalSettingsGuardForSettings();
 
 #if ENABLE(VIDEO_TRACK)
+    if (!page())
+        return;
+    CaptionUserPreferences* captionPreferences = page()->group().captionPreferences();
+
     if (equalIgnoringCase(kind, "Subtitles"))
-        settings()->setShouldDisplaySubtitles(enabled);
+        captionPreferences->setUserPrefersSubtitles(enabled);
     else if (equalIgnoringCase(kind, "Captions"))
-        settings()->setShouldDisplayCaptions(enabled);
+        captionPreferences->setUserPrefersCaptions(enabled);
     else if (equalIgnoringCase(kind, "TextDescriptions"))
-        settings()->setShouldDisplayTextDescriptions(enabled);
+        captionPreferences->setUserPrefersTextDescriptions(enabled);
     else
         ec = SYNTAX_ERR;
 #else
@@ -432,12 +436,16 @@ bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode&
     InternalSettingsGuardForSettingsReturn(false);
 
 #if ENABLE(VIDEO_TRACK)
+    if (!page())
+        return false;
+    CaptionUserPreferences* captionPreferences = page()->group().captionPreferences();
+
     if (equalIgnoringCase(kind, "Subtitles"))
-        return settings()->shouldDisplaySubtitles();
+        return captionPreferences->userPrefersSubtitles();
     if (equalIgnoringCase(kind, "Captions"))
-        return settings()->shouldDisplayCaptions();
+        return captionPreferences->userPrefersCaptions();
     if (equalIgnoringCase(kind, "TextDescriptions"))
-        return settings()->shouldDisplayTextDescriptions();
+        return captionPreferences->userPrefersTextDescriptions();
 
     ec = SYNTAX_ERR;
     return false;
index 2617d62..5f46239 100644 (file)
@@ -281,8 +281,8 @@ void Internals::resetToConsistentState(Page* page)
     page->inspectorController().setProfilerEnabled(false);
 #endif
 #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
-    page->captionPreferences().setCaptionsStyleSheetOverride(emptyString());
-    page->captionPreferences().setTestingMode(false);
+    page->group().captionPreferences()->setCaptionsStyleSheetOverride(emptyString());
+    page->group().captionPreferences()->setTestingMode(false);
 #endif
     if (!page->mainFrame().editor().isContinuousSpellCheckingEnabled())
         page->mainFrame().editor().toggleContinuousSpellChecking();
@@ -302,7 +302,7 @@ Internals::Internals(Document* document)
 {
 #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
     if (document && document->page())
-        document->page()->captionPreferences().setTestingMode(true);
+        document->page()->group().captionPreferences()->setTestingMode(true);
 #endif
 
 #if ENABLE(MEDIA_STREAM)
@@ -2051,7 +2051,7 @@ String Internals::captionsStyleSheetOverride(ExceptionCode& ec)
     }
 
 #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
-    return document->page()->captionPreferences().captionsStyleSheetOverride();
+    return document->page()->group().captionPreferences()->captionsStyleSheetOverride();
 #else
     return emptyString();
 #endif
@@ -2066,7 +2066,7 @@ void Internals::setCaptionsStyleSheetOverride(const String& override, ExceptionC
     }
 
 #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
-    document->page()->captionPreferences().setCaptionsStyleSheetOverride(override);
+    document->page()->group().captionPreferences()->setCaptionsStyleSheetOverride(override);
 #else
     UNUSED_PARAM(override);
 #endif
@@ -2081,7 +2081,7 @@ void Internals::setPrimaryAudioTrackLanguageOverride(const String& language, Exc
     }
 
 #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
-    document->page()->captionPreferences().setPrimaryAudioTrackLanguageOverride(language);
+    document->page()->group().captionPreferences()->setPrimaryAudioTrackLanguageOverride(language);
 #else
     UNUSED_PARAM(language);
 #endif
@@ -2096,18 +2096,14 @@ void Internals::setCaptionDisplayMode(const String& mode, ExceptionCode& ec)
     }
     
 #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
-    CaptionUserPreferences& captionPreferences = document->page()->captionPreferences();
+    CaptionUserPreferences* captionPreferences = document->page()->group().captionPreferences();
     
-    if (equalIgnoringCase(mode, "Automatic")) {
-        captionPreferences.setCaptionDisplayMode(CaptionUserPreferences::Automatic);
-        document->page()->settings().setShouldDisplayCaptions(false);
-        document->page()->settings().setShouldDisplaySubtitles(false);
-    } else if (equalIgnoringCase(mode, "ForcedOnly")) {
-        captionPreferences.setCaptionDisplayMode(CaptionUserPreferences::ForcedOnly);
-        document->page()->settings().setShouldDisplayCaptions(false);
-        document->page()->settings().setShouldDisplaySubtitles(false);
-    } else if (equalIgnoringCase(mode, "AlwaysOn"))
-        captionPreferences.setCaptionDisplayMode(CaptionUserPreferences::AlwaysOn);
+    if (equalIgnoringCase(mode, "Automatic"))
+        captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::Automatic);
+    else if (equalIgnoringCase(mode, "ForcedOnly"))
+        captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::ForcedOnly);
+    else if (equalIgnoringCase(mode, "AlwaysOn"))
+        captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::AlwaysOn);
     else
         ec = SYNTAX_ERR;
 #else