<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[163048] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163048">163048</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2014-01-29 16:35:31 -0800 (Wed, 29 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>CaptionUserPreferences should not be on the PageGroup if they are not really per-PageGroup (Part 1)
https://bugs.webkit.org/show_bug.cgi?id=127666
Reviewed by Eric Carlson.
This patch:
- Makes CaptionUserPreferences a singleton (temporary) that is accessed
via Page.
- Simplifies overriding system preferences by requiring that a Document be
be passed so the correct Settings object can be obtained (and not just a
random one).
- Stops using UserStyleSheets for captions style injection, and instead
adds a new style sheet to the DocumentStyleSheetCollection.
- Move caption style sheet creation into its own file - CaptionStyleSheetMediaAF.h/cpp
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
Add new files.
* WebCore.exp.in:
Update exports.
* css/DocumentRuleSets.cpp:
* css/InspectorCSSOMWrappers.cpp:
* dom/Document.cpp:
* dom/DocumentStyleSheetCollection.cpp:
* dom/DocumentStyleSheetCollection.h:
Switch from using the user style sheet mechanism, which is meant for, you guessed it, users,
to an explicit caption style sheet.
* Modules/mediacontrols/MediaControlsHost.cpp:
* html/HTMLMediaElement.cpp:
* html/shadow/MediaControlElements.cpp:
Get the CaptionUserPreferences via the Page.
* page/CaptionStyleSheetMediaAF.cpp: Added.
* page/CaptionStyleSheetMediaAF.h: Added.
Move caption style sheet creation here. If the global style changes, the sheet is invalidated
and this is called again.
* page/CaptionUserPreferences.cpp:
* page/CaptionUserPreferences.h:
- Removes unused m_havePreferences member.
- Change userPrefersFoo() functions to take a Document&. Use it to check its Settings.
- Remove setUserPrefersFoo() functions and just set the Settings directly.
- Move all the testing only pieces together.
* page/CaptionUserPreferencesMediaAF.cpp:
* page/CaptionUserPreferencesMediaAF.h:
- Extract caption style sheet creation into CaptionStyleSheetMediaAF.h/cpp
- Stop waiting for an interested party, and just register for appearance change
notifications right away. Media elements are common enough that this should not
make a difference.
* page/Page.cpp:
(WebCore::Page::updateStyleForAllPagesForCaptionPreferencesChanged):
Add helper to call captionPreferencesChanged() on all the Pages.
(WebCore::Page::captionPreferences):
Add accessor for the CaptionUserPreferences. Currently this returns a singleton, but I plan
to extract the singleton aspects of it into another class, and leave the per-Page parts here.
* page/Page.h:
* page/PageGroup.cpp:
* page/PageGroup.h:
Remove CaptionUserPreferences from here.
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setShouldDisplayTrackKind):
(WebCore::InternalSettings::shouldDisplayTrackKind):
Override the settings for the page directly.
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::Internals):
(WebCore::Internals::captionsStyleSheetOverride):
(WebCore::Internals::setCaptionsStyleSheetOverride):
(WebCore::Internals::setPrimaryAudioTrackLanguageOverride):
(WebCore::Internals::setCaptionDisplayMode):
Get the CaptionUserPreferences via the Page.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediacontrolsMediaControlsHostcpp">trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorecssDocumentRuleSetscpp">trunk/Source/WebCore/css/DocumentRuleSets.cpp</a></li>
<li><a href="#trunkSourceWebCorecssInspectorCSSOMWrapperscpp">trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentStyleSheetCollectioncpp">trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentStyleSheetCollectionh">trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowMediaControlElementscpp">trunk/Source/WebCore/html/shadow/MediaControlElements.cpp</a></li>
<li><a href="#trunkSourceWebCorepageCaptionUserPreferencescpp">trunk/Source/WebCore/page/CaptionUserPreferences.cpp</a></li>
<li><a href="#trunkSourceWebCorepageCaptionUserPreferencesh">trunk/Source/WebCore/page/CaptionUserPreferences.h</a></li>
<li><a href="#trunkSourceWebCorepageCaptionUserPreferencesMediaAFcpp">trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp</a></li>
<li><a href="#trunkSourceWebCorepageCaptionUserPreferencesMediaAFh">trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.h</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebCorepagePageGroupcpp">trunk/Source/WebCore/page/PageGroup.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageGrouph">trunk/Source/WebCore/page/PageGroup.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalSettingscpp">trunk/Source/WebCore/testing/InternalSettings.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepageCaptionStyleSheetMediaAFcpp">trunk/Source/WebCore/page/CaptionStyleSheetMediaAF.cpp</a></li>
<li><a href="#trunkSourceWebCorepageCaptionStyleSheetMediaAFh">trunk/Source/WebCore/page/CaptionStyleSheetMediaAF.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/ChangeLog        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -1,3 +1,87 @@
</span><ins>+2014-01-26 Sam Weinig <sam@webkit.org>
+
+ CaptionUserPreferences should not be on the PageGroup if they are not really per-PageGroup (Part 1)
+ https://bugs.webkit.org/show_bug.cgi?id=127666
+
+ Reviewed by Eric Carlson.
+
+ This patch:
+ - Makes CaptionUserPreferences a singleton (temporary) that is accessed
+ via Page.
+ - Simplifies overriding system preferences by requiring that a Document be
+ be passed so the correct Settings object can be obtained (and not just a
+ random one).
+ - Stops using UserStyleSheets for captions style injection, and instead
+ adds a new style sheet to the DocumentStyleSheetCollection.
+ - Move caption style sheet creation into its own file - CaptionStyleSheetMediaAF.h/cpp
+
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new files.
+
+ * WebCore.exp.in:
+ Update exports.
+
+ * css/DocumentRuleSets.cpp:
+ * css/InspectorCSSOMWrappers.cpp:
+ * dom/Document.cpp:
+ * dom/DocumentStyleSheetCollection.cpp:
+ * dom/DocumentStyleSheetCollection.h:
+ Switch from using the user style sheet mechanism, which is meant for, you guessed it, users,
+ to an explicit caption style sheet.
+
+ * Modules/mediacontrols/MediaControlsHost.cpp:
+ * html/HTMLMediaElement.cpp:
+ * html/shadow/MediaControlElements.cpp:
+ Get the CaptionUserPreferences via the Page.
+
+ * page/CaptionStyleSheetMediaAF.cpp: Added.
+ * page/CaptionStyleSheetMediaAF.h: Added.
+ Move caption style sheet creation here. If the global style changes, the sheet is invalidated
+ and this is called again.
+
+ * page/CaptionUserPreferences.cpp:
+ * page/CaptionUserPreferences.h:
+ - Removes unused m_havePreferences member.
+ - Change userPrefersFoo() functions to take a Document&. Use it to check its Settings.
+ - Remove setUserPrefersFoo() functions and just set the Settings directly.
+ - Move all the testing only pieces together.
+
+ * page/CaptionUserPreferencesMediaAF.cpp:
+ * page/CaptionUserPreferencesMediaAF.h:
+ - Extract caption style sheet creation into CaptionStyleSheetMediaAF.h/cpp
+ - Stop waiting for an interested party, and just register for appearance change
+ notifications right away. Media elements are common enough that this should not
+ make a difference.
+
+ * page/Page.cpp:
+ (WebCore::Page::updateStyleForAllPagesForCaptionPreferencesChanged):
+ Add helper to call captionPreferencesChanged() on all the Pages.
+
+ (WebCore::Page::captionPreferences):
+ Add accessor for the CaptionUserPreferences. Currently this returns a singleton, but I plan
+ to extract the singleton aspects of it into another class, and leave the per-Page parts here.
+
+ * page/Page.h:
+ * page/PageGroup.cpp:
+ * page/PageGroup.h:
+ Remove CaptionUserPreferences from here.
+
+ * testing/InternalSettings.cpp:
+ (WebCore::InternalSettings::setShouldDisplayTrackKind):
+ (WebCore::InternalSettings::shouldDisplayTrackKind):
+ Override the settings for the page directly.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::resetToConsistentState):
+ (WebCore::Internals::Internals):
+ (WebCore::Internals::captionsStyleSheetOverride):
+ (WebCore::Internals::setCaptionsStyleSheetOverride):
+ (WebCore::Internals::setPrimaryAudioTrackLanguageOverride):
+ (WebCore::Internals::setCaptionDisplayMode):
+ Get the CaptionUserPreferences via the Page.
+
</ins><span class="cx"> 2014-01-29 Jer Noble <jer.noble@apple.com>
</span><span class="cx">
</span><span class="cx"> [MSE][Mac] In SourceBufferPrivateAVFObjC, only include those headers actually necessary to compile.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediacontrolsMediaControlsHostcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -82,8 +82,7 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> return Vector<RefPtr<TextTrack>>();
</span><span class="cx">
</span><del>- CaptionUserPreferences* captionPreferences = page->group().captionPreferences();
- return captionPreferences->sortedTrackListForMenu(trackList);
</del><ins>+ return page->captionPreferences().sortedTrackListForMenu(trackList);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String MediaControlsHost::displayNameForTrack(TextTrack* track)
</span><span class="lines">@@ -95,8 +94,7 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> return emptyString();
</span><span class="cx">
</span><del>- CaptionUserPreferences* captionPreferences = page->group().captionPreferences();
- return captionPreferences->displayNameForTrack(track);
</del><ins>+ return page->captionPreferences().displayNameForTrack(track);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TextTrack* MediaControlsHost::captionMenuOffItem()
</span><span class="lines">@@ -115,7 +113,7 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> return emptyAtom;
</span><span class="cx">
</span><del>- switch (page->group().captionPreferences()->captionDisplayMode()) {
</del><ins>+ switch (page->captionPreferences().captionDisplayMode()) {
</ins><span class="cx"> case CaptionUserPreferences::Automatic:
</span><span class="cx"> return automaticKeyword();
</span><span class="cx"> case CaptionUserPreferences::ForcedOnly:
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -3063,7 +3063,9 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><del>-__ZN7WebCore9PageGroup18captionPreferencesEv
</del><ins>+__ZN7WebCore22CaptionUserPreferences29setCaptionsStyleSheetOverrideERKN3WTF6StringE
+__ZN7WebCore4Page18captionPreferencesEv
+__ZNK7WebCore22CaptionUserPreferences26captionsStyleSheetOverrideEv
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO)
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -6984,6 +6984,12 @@
</span><span class="cx"> <ClCompile Include="..\page\animation\AnimationController.cpp" />
</span><span class="cx"> <ClCompile Include="..\page\AutoscrollController.cpp" />
</span><span class="cx"> <ClCompile Include="..\page\BarProp.cpp" />
</span><ins>+ <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>
</ins><span class="cx"> <ClCompile Include="..\page\CaptionUserPreferences.cpp" />
</span><span class="cx"> <ClCompile Include="..\page\CaptionUserPreferencesMediaAF.cpp">
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
</span><span class="lines">@@ -18759,6 +18765,7 @@
</span><span class="cx"> <ClInclude Include="..\page\animation\AnimationControllerPrivate.h" />
</span><span class="cx"> <ClInclude Include="..\page\AutoscrollController.h" />
</span><span class="cx"> <ClInclude Include="..\page\BarProp.h" />
</span><ins>+ <ClInclude Include="..\page\CaptionStyleSheetMediaAF.h" />
</ins><span class="cx"> <ClInclude Include="..\page\CaptionUserPreferences.h" />
</span><span class="cx"> <ClInclude Include="..\page\CaptionUserPreferencesMediaAF.h" />
</span><span class="cx"> <ClInclude Include="..\page\Chrome.h" />
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -6724,6 +6724,9 @@
</span><span class="cx"> <ClCompile Include="..\platform\graphics\opengl\TemporaryOpenGLSetting.cpp">
</span><span class="cx"> <Filter>platform\graphics\opengl</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\page\CaptionStyleSheetMediaAF.cpp">
+ <Filter>page</Filter>
+ </ClCompile>
</ins><span class="cx"> <ClCompile Include="..\page\CaptionUserPreferencesMediaAF.cpp">
</span><span class="cx"> <Filter>page</Filter>
</span><span class="cx"> </ClCompile>
</span><span class="lines">@@ -14500,6 +14503,9 @@
</span><span class="cx"> <ClInclude Include="..\platform\graphics\opengl\GLPlatformSurface.h">
</span><span class="cx"> <Filter>platform\graphics\opengl</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\page\CaptionStyleSheetMediaAF.h">
+ <Filter>page</Filter>
+ </ClInclude>
</ins><span class="cx"> <ClInclude Include="..\page\CaptionUserPreferences.h">
</span><span class="cx"> <Filter>page</Filter>
</span><span class="cx"> </ClInclude>
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -2293,6 +2293,8 @@
</span><span class="cx">                 7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
</span><span class="cx">                 7CE6CBFB187F370700D46BF5 /* FormatConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE6CBFA187F370700D46BF5 /* FormatConverter.h */; };
</span><span class="cx">                 7CE6CBFD187F394900D46BF5 /* FormatConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */; };
</span><ins>+                7CFC30591895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFC30571895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp */; };
+                7CFC305A1895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CFC30581895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h */; };
</ins><span class="cx">                 7D741BDA177226AA00859170 /* CSSValueKeywords.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 6565814809D13043000E61D7 /* CSSValueKeywords.h */; };
</span><span class="cx">                 7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E33CD00127F340D00BE8F17 /* PurgePriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 7E37EF2E1339208800B29250 /* SubresourceLoaderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E37EF2D1339208800B29250 /* SubresourceLoaderCF.cpp */; };
</span><span class="lines">@@ -9234,6 +9236,8 @@
</span><span class="cx">                 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDNScriptWhiteList.txt; sourceTree = "<group>"; };
</span><span class="cx">                 7CE6CBFA187F370700D46BF5 /* FormatConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatConverter.h; sourceTree = "<group>"; };
</span><span class="cx">                 7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatConverter.cpp; sourceTree = "<group>"; };
</span><ins>+                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>"; };
</ins><span class="cx">                 7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = "<group>"; };
</span><span class="cx">                 7E37EF2D1339208800B29250 /* SubresourceLoaderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SubresourceLoaderCF.cpp; path = cf/SubresourceLoaderCF.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7E428CE413E3407F003B661C /* ResourceHandleIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceHandleIOS.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -16032,6 +16036,8 @@
</span><span class="cx">                                 079D0867162F20E800DB8658 /* CaptionUserPreferences.h */,
</span><span class="cx">                                 079D086A162F21F900DB8658 /* CaptionUserPreferencesMediaAF.cpp */,
</span><span class="cx">                                 079D0869162F21F900DB8658 /* CaptionUserPreferencesMediaAF.h */,
</span><ins>+                                7CFC30571895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp */,
+                                7CFC30581895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h */,
</ins><span class="cx">                                 14D8238A0AF92DF60004F057 /* Chrome.cpp */,
</span><span class="cx">                                 14D823500AF92A790004F057 /* Chrome.h */,
</span><span class="cx">                                 14D824060AF93AEB0004F057 /* ChromeClient.h */,
</span><span class="lines">@@ -22599,6 +22605,7 @@
</span><span class="cx">                                 FE115FAB167988CD00249134 /* AbstractDatabaseServer.h in Headers */,
</span><span class="cx">                                 9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */,
</span><span class="cx">                                 FE4AADEE16D2C37400026FFC /* AbstractSQLStatement.h in Headers */,
</span><ins>+                                7CFC305A1895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h in Headers */,
</ins><span class="cx">                                 6E84E9E117668BF100815B68 /* RasterShape.h in Headers */,
</span><span class="cx">                                 FE4AADEF16D2C37400026FFC /* AbstractSQLStatementBackend.h in Headers */,
</span><span class="cx">                                 41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
</span><span class="lines">@@ -27118,6 +27125,7 @@
</span><span class="cx">                                 A81369E1097374F600D74463 /* HTMLLegendElement.cpp in Sources */,
</span><span class="cx">                                 A8EA79FC0A1916DF00A8EF5F /* HTMLLIElement.cpp in Sources */,
</span><span class="cx">                                 A871DC210A15205700B12A68 /* HTMLLinkElement.cpp in Sources */,
</span><ins>+                                7CFC30591895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp in Sources */,
</ins><span class="cx">                                 A8EA7D320A19385500A8EF5F /* HTMLMapElement.cpp in Sources */,
</span><span class="cx">                                 A8EA7CAC0A192B9C00A8EF5F /* HTMLMarqueeElement.cpp in Sources */,
</span><span class="cx">                                 E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorecssDocumentRuleSetscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/DocumentRuleSets.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/DocumentRuleSets.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/css/DocumentRuleSets.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -51,6 +51,8 @@
</span><span class="cx"> OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
</span><span class="cx"> if (CSSStyleSheet* pageUserSheet = styleSheetCollection.pageUserSheet())
</span><span class="cx"> tempUserStyle->addRulesFromSheet(&pageUserSheet->contents(), medium, &resolver);
</span><ins>+ if (CSSStyleSheet* captionsStyleSheet = styleSheetCollection.captionsStyleSheet())
+ tempUserStyle->addRulesFromSheet(&captionsStyleSheet->contents(), medium, &resolver);
</ins><span class="cx"> collectRulesFromUserStyleSheets(styleSheetCollection.injectedUserStyleSheets(), *tempUserStyle, medium, resolver);
</span><span class="cx"> collectRulesFromUserStyleSheets(styleSheetCollection.documentUserStyleSheets(), *tempUserStyle, medium, resolver);
</span><span class="cx"> if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0)
</span></span></pre></div>
<a id="trunkSourceWebCorecssInspectorCSSOMWrapperscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -107,6 +107,7 @@
</span><span class="cx"> {
</span><span class="cx"> collectFromStyleSheets(styleSheetCollection.activeAuthorStyleSheets());
</span><span class="cx"> collect(styleSheetCollection.pageUserSheet());
</span><ins>+ collect(styleSheetCollection.captionsStyleSheet());
</ins><span class="cx"> collectFromStyleSheets(styleSheetCollection.injectedUserStyleSheets());
</span><span class="cx"> collectFromStyleSheets(styleSheetCollection.documentUserStyleSheets());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/dom/Document.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -748,6 +748,7 @@
</span><span class="cx"> if (inQuirksMode() != wasInQuirksMode) {
</span><span class="cx"> // All user stylesheets have to reparse using the different mode.
</span><span class="cx"> m_styleSheetCollection.clearPageUserSheet();
</span><ins>+ m_styleSheetCollection.invalidateCaptionsStyleSheet();
</ins><span class="cx"> m_styleSheetCollection.invalidateInjectedStyleSheetCache();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -4171,9 +4172,6 @@
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx"> void Document::registerForCaptionPreferencesChangedCallbacks(Element* e)
</span><span class="cx"> {
</span><del>- if (page())
- page()->group().captionPreferences()->setInterestedInCaptionPreferenceChanges();
-
</del><span class="cx"> m_captionPreferencesChangedElements.add(e);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4184,9 +4182,11 @@
</span><span class="cx">
</span><span class="cx"> void Document::captionPreferencesChanged()
</span><span class="cx"> {
</span><del>- HashSet<Element*>::iterator end = m_captionPreferencesChangedElements.end();
- for (HashSet<Element*>::iterator it = m_captionPreferencesChangedElements.begin(); it != end; ++it)
- (*it)->captionPreferencesChanged();
</del><ins>+ m_styleSheetCollection.invalidateCaptionsStyleSheet();
+ styleResolverChanged(DeferRecalcStyle);
+
+ for (auto* element : m_captionPreferencesChangedElements)
+ element->captionPreferencesChanged();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentStyleSheetCollectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include "DocumentStyleSheetCollection.h"
</span><span class="cx">
</span><span class="cx"> #include "CSSStyleSheet.h"
</span><ins>+#include "CaptionUserPreferences.h"
</ins><span class="cx"> #include "Element.h"
</span><span class="cx"> #include "HTMLIFrameElement.h"
</span><span class="cx"> #include "HTMLLinkElement.h"
</span><span class="lines">@@ -118,6 +119,41 @@
</span><span class="cx"> m_document.styleResolverChanged(RecalcStyleImmediately);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+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);
+ }
+}
+
</ins><span class="cx"> const Vector<RefPtr<CSSStyleSheet>>& DocumentStyleSheetCollection::injectedUserStyleSheets() const
</span><span class="cx"> {
</span><span class="cx"> updateInjectedStyleSheetCache();
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentStyleSheetCollectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> const Vector<RefPtr<CSSStyleSheet>>& activeAuthorStyleSheets() const { return m_activeAuthorStyleSheets; }
</span><span class="cx">
</span><span class="cx"> CSSStyleSheet* pageUserSheet();
</span><ins>+ CSSStyleSheet* captionsStyleSheet();
</ins><span class="cx"> const Vector<RefPtr<CSSStyleSheet>>& documentUserStyleSheets() const { return m_userStyleSheets; }
</span><span class="cx"> const Vector<RefPtr<CSSStyleSheet>>& documentAuthorStyleSheets() const { return m_authorStyleSheets; }
</span><span class="cx"> const Vector<RefPtr<CSSStyleSheet>>& injectedUserStyleSheets() const;
</span><span class="lines">@@ -63,6 +64,10 @@
</span><span class="cx">
</span><span class="cx"> void clearPageUserSheet();
</span><span class="cx"> void updatePageUserSheet();
</span><ins>+
+ void invalidateCaptionsStyleSheet();
+ void updateCaptionsStyleSheet();
+
</ins><span class="cx"> void invalidateInjectedStyleSheetCache();
</span><span class="cx"> void updateInjectedStyleSheetCache() const;
</span><span class="cx">
</span><span class="lines">@@ -141,6 +146,7 @@
</span><span class="cx"> int m_pendingStylesheets;
</span><span class="cx">
</span><span class="cx"> RefPtr<CSSStyleSheet> m_pageUserSheet;
</span><ins>+ RefPtr<CSSStyleSheet> m_captionsStyleSheet;
</ins><span class="cx">
</span><span class="cx"> mutable Vector<RefPtr<CSSStyleSheet>> m_injectedUserStyleSheets;
</span><span class="cx"> mutable Vector<RefPtr<CSSStyleSheet>> m_injectedAuthorStyleSheets;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -379,7 +379,7 @@
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx"> document.registerForCaptionPreferencesChangedCallbacks(this);
</span><span class="cx"> if (document.page())
</span><del>- m_captionDisplayMode = document.page()->group().captionPreferences()->captionDisplayMode();
</del><ins>+ m_captionDisplayMode = document.page()->captionPreferences().captionDisplayMode();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3424,7 +3424,7 @@
</span><span class="cx"> LOG(Media, "HTMLMediaElement::configureTextTrackGroup");
</span><span class="cx">
</span><span class="cx"> Page* page = document().page();
</span><del>- CaptionUserPreferences* captionPreferences = page? page->group().captionPreferences() : 0;
</del><ins>+ CaptionUserPreferences* captionPreferences = page ? &page->captionPreferences() : nullptr;
</ins><span class="cx"> CaptionUserPreferences::CaptionDisplayMode displayMode = captionPreferences ? captionPreferences->captionDisplayMode() : CaptionUserPreferences::Automatic;
</span><span class="cx">
</span><span class="cx"> // First, find the track in the group that should be enabled (if any).
</span><span class="lines">@@ -3534,11 +3534,10 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- CaptionUserPreferences* captionPreferences = document().page() ? document().page()->group().captionPreferences() : 0;
- if (!captionPreferences)
</del><ins>+ if (!document().page())
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- CaptionUserPreferences::CaptionDisplayMode displayMode = captionPreferences->captionDisplayMode();
</del><ins>+ CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
</ins><span class="cx"> if (trackToSelect == TextTrack::captionMenuOffItem())
</span><span class="cx"> displayMode = CaptionUserPreferences::ForcedOnly;
</span><span class="cx"> else if (trackToSelect == TextTrack::captionMenuAutomaticItem())
</span><span class="lines">@@ -3546,13 +3545,13 @@
</span><span class="cx"> else {
</span><span class="cx"> displayMode = CaptionUserPreferences::AlwaysOn;
</span><span class="cx"> if (trackToSelect->language().length())
</span><del>- captionPreferences->setPreferredLanguage(trackToSelect->language());
</del><ins>+ document().page()->captionPreferences().setPreferredLanguage(trackToSelect->language());
</ins><span class="cx">
</span><span class="cx"> // Set m_captionDisplayMode here so we don't reconfigure again when the preference changed notification comes through.
</span><span class="cx"> m_captionDisplayMode = displayMode;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- captionPreferences->setCaptionDisplayMode(displayMode);
</del><ins>+ document().page()->captionPreferences().setCaptionDisplayMode(displayMode);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::configureTextTracks()
</span><span class="lines">@@ -5256,8 +5255,8 @@
</span><span class="cx">
</span><span class="cx"> if (!document().page())
</span><span class="cx"> return;
</span><del>-
- CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->group().captionPreferences()->captionDisplayMode();
</del><ins>+
+ CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
</ins><span class="cx"> if (m_captionDisplayMode == displayMode)
</span><span class="cx"> return;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowMediaControlElementscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -820,7 +820,7 @@
</span><span class="cx">
</span><span class="cx"> if (!document().page())
</span><span class="cx"> return;
</span><del>- CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->group().captionPreferences()->captionDisplayMode();
</del><ins>+ CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
</ins><span class="cx">
</span><span class="cx"> HTMLMediaElement* mediaElement = parentMediaElement(this);
</span><span class="cx"> if (!mediaElement)
</span><span class="lines">@@ -896,9 +896,10 @@
</span><span class="cx">
</span><span class="cx"> if (!document().page())
</span><span class="cx"> return;
</span><del>- CaptionUserPreferences* captionPreferences = document().page()->group().captionPreferences();
- Vector<RefPtr<TextTrack>> tracksForMenu = captionPreferences->sortedTrackListForMenu(trackList);
</del><span class="cx">
</span><ins>+ CaptionUserPreferences& captionPreferences = document().page()->captionPreferences();
+ Vector<RefPtr<TextTrack>> tracksForMenu = captionPreferences.sortedTrackListForMenu(trackList);
+
</ins><span class="cx"> RefPtr<Element> captionsHeader = document().createElement(h3Tag, ASSERT_NO_EXCEPTION);
</span><span class="cx"> captionsHeader->appendChild(document().createTextNode(textTrackSubtitlesText()));
</span><span class="cx"> appendChild(captionsHeader);
</span><span class="lines">@@ -907,7 +908,7 @@
</span><span class="cx"> for (unsigned i = 0, length = tracksForMenu.size(); i < length; ++i) {
</span><span class="cx"> RefPtr<TextTrack> textTrack = tracksForMenu[i];
</span><span class="cx"> RefPtr<Element> menuItem = document().createElement(liTag, ASSERT_NO_EXCEPTION);
</span><del>- menuItem->appendChild(document().createTextNode(captionPreferences->displayNameForTrack(textTrack.get())));
</del><ins>+ menuItem->appendChild(document().createTextNode(captionPreferences.displayNameForTrack(textTrack.get())));
</ins><span class="cx"> captionsMenuList->appendChild(menuItem);
</span><span class="cx"> m_menuItems.append(menuItem);
</span><span class="cx"> m_menuToTrackMap.add(menuItem, textTrack);
</span><span class="lines">@@ -1331,7 +1332,7 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
</span><del>- float fontScale = document().page()->group().captionPreferences()->captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
</del><ins>+ float fontScale = document().page()->captionPreferences().captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
</ins><span class="cx"> m_fontSize = lroundf(smallestDimension * fontScale);
</span><span class="cx">
</span><span class="cx"> CueList activeCues = mediaElement->currentlyActiveCues();
</span></span></pre></div>
<a id="trunkSourceWebCorepageCaptionStyleSheetMediaAFcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/CaptionStyleSheetMediaAF.cpp (0 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/CaptionStyleSheetMediaAF.cpp         (rev 0)
+++ trunk/Source/WebCore/page/CaptionStyleSheetMediaAF.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -0,0 +1,364 @@
</span><ins>+/*
+ * 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)
</ins></span></pre></div>
<a id="trunkSourceWebCorepageCaptionStyleSheetMediaAFh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/CaptionStyleSheetMediaAF.h (0 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/CaptionStyleSheetMediaAF.h         (rev 0)
+++ trunk/Source/WebCore/page/CaptionStyleSheetMediaAF.h        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * 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
</ins></span></pre></div>
<a id="trunkSourceWebCorepageCaptionUserPreferencescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/CaptionUserPreferences.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/CaptionUserPreferences.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/page/CaptionUserPreferences.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -28,21 +28,19 @@
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">
</span><span class="cx"> #include "CaptionUserPreferences.h"
</span><del>-#include "DOMWrapperWorld.h"
</del><ins>+
+#include "HTMLMediaElement.h"
</ins><span class="cx"> #include "Page.h"
</span><del>-#include "PageGroup.h"
</del><ins>+#include "PageCache.h"
</ins><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "TextTrackList.h"
</span><del>-#include "UserStyleSheetTypes.h"
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-CaptionUserPreferences::CaptionUserPreferences(PageGroup& group)
- : m_pageGroup(group)
</del><ins>+CaptionUserPreferences::CaptionUserPreferences()
+ : m_timer(this, &CaptionUserPreferences::timerFired)
</ins><span class="cx"> , m_displayMode(ForcedOnly)
</span><del>- , m_timer(this, &CaptionUserPreferences::timerFired)
</del><span class="cx"> , m_testingMode(false)
</span><del>- , m_havePreferences(false)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -57,7 +55,6 @@
</span><span class="cx">
</span><span class="cx"> void CaptionUserPreferences::notify()
</span><span class="cx"> {
</span><del>- m_havePreferences = true;
</del><span class="cx"> if (!m_timer.isActive())
</span><span class="cx"> m_timer.startOneShot(0);
</span><span class="cx"> }
</span><span class="lines">@@ -70,75 +67,36 @@
</span><span class="cx"> void CaptionUserPreferences::setCaptionDisplayMode(CaptionUserPreferences::CaptionDisplayMode mode)
</span><span class="cx"> {
</span><span class="cx"> m_displayMode = mode;
</span><del>- if (m_testingMode && mode != AlwaysOn) {
- setUserPrefersCaptions(false);
- setUserPrefersSubtitles(false);
- }
</del><span class="cx"> notify();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool CaptionUserPreferences::userPrefersCaptions() const
</del><ins>+bool CaptionUserPreferences::userPrefersCaptions(Document& document) const
</ins><span class="cx"> {
</span><del>- Page* page = *(m_pageGroup.pages().begin());
- if (!page)
</del><ins>+ Settings* settings = document.settings();
+ if (!settings)
</ins><span class="cx"> return false;
</span><span class="cx">
</span><del>- return page->settings().shouldDisplayCaptions();
</del><ins>+ return settings->shouldDisplayCaptions();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void CaptionUserPreferences::setUserPrefersCaptions(bool preference)
</del><ins>+bool CaptionUserPreferences::userPrefersSubtitles(Document& document) const
</ins><span class="cx"> {
</span><del>- 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)
</del><ins>+ Settings* settings = document.settings();
+ if (!settings)
</ins><span class="cx"> return false;
</span><span class="cx">
</span><del>- return page->settings().shouldDisplaySubtitles();
</del><ins>+ return settings->shouldDisplaySubtitles();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void CaptionUserPreferences::setUserPrefersSubtitles(bool preference)
</del><ins>+bool CaptionUserPreferences::userPrefersTextDescriptions(Document& document) const
</ins><span class="cx"> {
</span><del>- 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)
</del><ins>+ Settings* settings = document.settings();
+ if (!settings)
</ins><span class="cx"> return false;
</span><del>-
- return page->settings().shouldDisplayTextDescriptions();
-}
</del><span class="cx">
</span><del>-void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference)
-{
- Page* page = *(m_pageGroup.pages().begin());
- if (!page)
- return;
-
- page->settings().setShouldDisplayTextDescriptions(preference);
- notify();
</del><ins>+ return settings->shouldDisplayTextDescriptions();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void CaptionUserPreferences::captionPreferencesChanged()
-{
- m_pageGroup.captionPreferencesChanged();
-}
-
</del><span class="cx"> Vector<String> CaptionUserPreferences::preferredLanguages() const
</span><span class="cx"> {
</span><span class="cx"> Vector<String> languages = userPreferredLanguages();
</span><span class="lines">@@ -196,19 +154,19 @@
</span><span class="cx"> return tracksForMenu;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement*) const
</del><ins>+int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement* element) const
</ins><span class="cx"> {
</span><span class="cx"> int trackScore = 0;
</span><span class="cx">
</span><span class="cx"> if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword())
</span><span class="cx"> return trackScore;
</span><span class="cx">
</span><del>- if (!userPrefersSubtitles() && !userPrefersCaptions())
</del><ins>+ if (!userPrefersSubtitles(element->document()) && !userPrefersCaptions(element->document()))
</ins><span class="cx"> return trackScore;
</span><span class="cx">
</span><del>- if (track->kind() == TextTrack::subtitlesKeyword() && userPrefersSubtitles())
</del><ins>+ if (track->kind() == TextTrack::subtitlesKeyword() && userPrefersSubtitles(element->document()))
</ins><span class="cx"> trackScore = 1;
</span><del>- else if (track->kind() == TextTrack::captionsKeyword() && userPrefersCaptions())
</del><ins>+ else if (track->kind() == TextTrack::captionsKeyword() && userPrefersCaptions(element->document()))
</ins><span class="cx"> trackScore = 1;
</span><span class="cx">
</span><span class="cx"> return trackScore + textTrackLanguageSelectionScore(track, preferredLanguages());
</span><span class="lines">@@ -228,25 +186,23 @@
</span><span class="cx"> return (preferredLanguages.size() - languageMatchIndex) * 10;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+String CaptionUserPreferences::captionsStyleSheet()
+{
+ if (!m_captionsStyleSheetOverride.isEmpty() || testingMode())
+ return m_captionsStyleSheetOverride;
+
+ return platformCaptionsStyleSheet();
+}
+
</ins><span class="cx"> void CaptionUserPreferences::setCaptionsStyleSheetOverride(const String& override)
</span><span class="cx"> {
</span><span class="cx"> m_captionsStyleSheetOverride = override;
</span><del>- updateCaptionStyleSheetOveride();
</del><ins>+ captionPreferencesChanged();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void CaptionUserPreferences::updateCaptionStyleSheetOveride()
</del><ins>+String CaptionUserPreferences::captionsStyleSheetOverride() const
</ins><span class="cx"> {
</span><del>- // 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);
</del><ins>+ return m_captionsStyleSheetOverride;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String CaptionUserPreferences::primaryAudioTrackLanguageOverride() const
</span><span class="lines">@@ -255,7 +211,13 @@
</span><span class="cx"> return m_primaryAudioTrackLanguageOverride;
</span><span class="cx"> return defaultLanguage();
</span><span class="cx"> }
</span><del>-
</del><ins>+
+void CaptionUserPreferences::captionPreferencesChanged()
+{
+ Page::updateStyleForAllPagesForCaptionPreferencesChanged();
+ pageCache()->markPagesForCaptionPreferencesChanged();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+} // namespace WebCore
+
</ins><span class="cx"> #endif // ENABLE(VIDEO_TRACK)
</span></span></pre></div>
<a id="trunkSourceWebCorepageCaptionUserPreferencesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/CaptionUserPreferences.h (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/CaptionUserPreferences.h        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/page/CaptionUserPreferences.h        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -43,69 +43,60 @@
</span><span class="cx">
</span><span class="cx"> class CaptionUserPreferences {
</span><span class="cx"> public:
</span><del>- CaptionUserPreferences(PageGroup&);
</del><ins>+ CaptionUserPreferences();
</ins><span class="cx"> virtual ~CaptionUserPreferences();
</span><span class="cx">
</span><ins>+ String captionsStyleSheet();
+
</ins><span class="cx"> enum CaptionDisplayMode {
</span><span class="cx"> Automatic,
</span><span class="cx"> ForcedOnly,
</span><span class="cx"> AlwaysOn
</span><span class="cx"> };
</span><ins>+
</ins><span class="cx"> virtual CaptionDisplayMode captionDisplayMode() const;
</span><span class="cx"> virtual void setCaptionDisplayMode(CaptionDisplayMode);
</span><span class="cx">
</span><span class="cx"> virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const;
</span><span class="cx"> virtual int textTrackLanguageSelectionScore(TextTrack*, const Vector<String>&) const;
</span><ins>+ virtual bool userPrefersCaptions(Document&) const;
+ virtual bool userPrefersSubtitles(Document&) const;
+ virtual bool userPrefersTextDescriptions(Document&) const;
</ins><span class="cx">
</span><del>- 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);
-
</del><span class="cx"> virtual float captionFontSizeScaleAndImportance(bool& important) const { important = false; return 0.05f; }
</span><span class="cx">
</span><del>- virtual String captionsStyleSheetOverride() const { return m_captionsStyleSheetOverride; }
- virtual void setCaptionsStyleSheetOverride(const String&);
-
- virtual void setInterestedInCaptionPreferenceChanges() { }
-
- virtual void captionPreferencesChanged();
-
</del><span class="cx"> virtual void setPreferredLanguage(const String&);
</span><span class="cx"> virtual Vector<String> preferredLanguages() const;
</span><span class="cx">
</span><span class="cx"> virtual String displayNameForTrack(TextTrack*) const;
</span><span class="cx"> virtual Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*);
</span><span class="cx">
</span><ins>+ void captionPreferencesChanged();
+
+ // These are used for testing mode only.
+ void setCaptionsStyleSheetOverride(const String&);
+ String captionsStyleSheetOverride() const;
</ins><span class="cx"> void setPrimaryAudioTrackLanguageOverride(const String& language) { m_primaryAudioTrackLanguageOverride = language; }
</span><span class="cx"> String primaryAudioTrackLanguageOverride() const;
</span><del>-
- virtual bool testingMode() const { return m_testingMode; }
- virtual void setTestingMode(bool override) { m_testingMode = override; }
</del><ins>+ void setTestingMode(bool override) { m_testingMode = override; }
+ bool testingMode() const { return m_testingMode; }
</ins><span class="cx">
</span><del>- PageGroup& pageGroup() const { return m_pageGroup; }
-
-protected:
- void updateCaptionStyleSheetOveride();
-
</del><span class="cx"> private:
</span><span class="cx"> void timerFired(Timer<CaptionUserPreferences>&);
</span><span class="cx"> void notify();
</span><span class="cx">
</span><del>- PageGroup& m_pageGroup;
- CaptionDisplayMode m_displayMode;
</del><ins>+ virtual String platformCaptionsStyleSheet() { return String(); }
+
</ins><span class="cx"> Timer<CaptionUserPreferences> m_timer;
</span><ins>+
+ // These are used for testing mode only.
+ CaptionDisplayMode m_displayMode;
</ins><span class="cx"> String m_userPreferredLanguage;
</span><span class="cx"> String m_captionsStyleSheetOverride;
</span><span class="cx"> String m_primaryAudioTrackLanguageOverride;
</span><span class="cx"> bool m_testingMode;
</span><del>- bool m_havePreferences;
</del><span class="cx"> };
</span><del>-
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepageCaptionUserPreferencesMediaAFcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -29,9 +29,7 @@
</span><span class="cx">
</span><span class="cx"> #include "CaptionUserPreferencesMediaAF.h"
</span><span class="cx">
</span><del>-#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-#include "CoreText/CoreText.h"
-#endif
</del><ins>+#include "CaptionStyleSheetMediaAF.h"
</ins><span class="cx"> #include "FloatConversion.h"
</span><span class="cx"> #include "HTMLMediaElement.h"
</span><span class="cx"> #include "URL.h"
</span><span class="lines">@@ -42,7 +40,6 @@
</span><span class="cx"> #include "SoftLinking.h"
</span><span class="cx"> #include "TextTrackCue.h"
</span><span class="cx"> #include "TextTrackList.h"
</span><del>-#include "UserStyleSheetTypes.h"
</del><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx"> #include <wtf/text/StringBuilder.h>
</span><span class="lines">@@ -76,74 +73,51 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> SOFT_LINK_AVF_FRAMEWORK(MediaAccessibility)
</span><del>-SOFT_LINK_AVF_FRAMEWORK(CoreText)
</del><span class="cx">
</span><span class="cx"> SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetDisplayType, MACaptionAppearanceDisplayType, (MACaptionAppearanceDomain domain), (domain))
</span><span class="cx"> SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceSetDisplayType, void, (MACaptionAppearanceDomain domain, MACaptionAppearanceDisplayType displayType), (domain, displayType))
</span><del>-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))
</del><span class="cx"> SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceAddSelectedLanguage, bool, (MACaptionAppearanceDomain domain, CFStringRef language), (domain, language));
</span><span class="cx"> SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopySelectedLanguages, CFArrayRef, (MACaptionAppearanceDomain domain), (domain));
</span><span class="cx"> SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics, CFArrayRef, (MACaptionAppearanceDomain domain), (domain));
</span><ins>+SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetRelativeCharacterSize, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
</ins><span class="cx">
</span><del>-SOFT_LINK_AVF_FRAMEWORK_IMPORT(CoreText, CTFontDescriptorCopyAttribute, CFTypeRef, (CTFontDescriptorRef descriptor, CFStringRef attribute), (descriptor, attribute));
-
</del><span class="cx"> #if PLATFORM(WIN)
</span><span class="cx"> // These are needed on Windows due to the way DLLs work. We do not need them on other platforms
</span><span class="cx"> #define MACaptionAppearanceGetDisplayType softLink_MACaptionAppearanceGetDisplayType
</span><span class="cx"> #define MACaptionAppearanceSetDisplayType softLink_MACaptionAppearanceSetDisplayType
</span><del>-#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
</del><span class="cx"> #define MACaptionAppearanceAddSelectedLanguage softLink_MACaptionAppearanceAddSelectedLanguage
</span><span class="cx"> #define MACaptionAppearanceCopySelectedLanguages softLink_MACaptionAppearanceCopySelectedLanguages
</span><span class="cx"> #define MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics softLink_MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics
</span><del>-#define CTFontDescriptorCopyAttribute softLink_CTFontDescriptorCopyAttribute
</del><ins>+#define MACaptionAppearanceGetRelativeCharacterSize softLink_MACaptionAppearanceGetRelativeCharacterSize
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> SOFT_LINK_AVF_POINTER(MediaAccessibility, kMAXCaptionAppearanceSettingsChangedNotification, CFStringRef)
</span><span class="cx"> #define kMAXCaptionAppearanceSettingsChangedNotification getkMAXCaptionAppearanceSettingsChangedNotification()
</span><span class="cx">
</span><del>-SOFT_LINK_AVF_POINTER(CoreText, kCTFontNameAttribute, CFStringRef)
-#define kCTFontNameAttribute getkCTFontNameAttribute()
</del><span class="cx"> #endif
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
</span><span class="cx"> static void userCaptionPreferencesChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void *, CFDictionaryRef)
</span><span class="cx"> {
</span><span class="cx"> #if !PLATFORM(IOS)
</span><del>- static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionPreferencesChanged();
</del><ins>+ static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionApperenceChanged();
</ins><span class="cx"> #else
</span><span class="cx"> WebThreadRun(^{
</span><del>- static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionPreferencesChanged();
</del><ins>+ static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionApperenceChanged();
</ins><span class="cx"> });
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF(PageGroup& group)
- : CaptionUserPreferences(group)
</del><ins>+CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF()
+{
</ins><span class="cx"> #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
</span><del>- , m_listeningForPreferenceChanges(false)
</del><ins>+ if (MediaAccessibilityLibrary() && kMAXCaptionAppearanceSettingsChangedNotification)
+ CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, 0, CFNotificationSuspensionBehaviorCoalesce);
</ins><span class="cx"> #endif
</span><del>-{
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> CaptionUserPreferencesMediaAF::~CaptionUserPreferencesMediaAF()
</span><span class="lines">@@ -156,6 +130,15 @@
</span><span class="cx">
</span><span class="cx"> #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
</span><span class="cx">
</span><ins>+void CaptionUserPreferencesMediaAF::captionApperenceChanged()
+{
+ // Invalidate the caption style sheet.
+ m_captionStyleSheet = String();
+
+ // Tell the base class to invalidate all the uses of it.
+ captionPreferencesChanged();
+}
+
</ins><span class="cx"> CaptionUserPreferences::CaptionDisplayMode CaptionUserPreferencesMediaAF::captionDisplayMode() const
</span><span class="cx"> {
</span><span class="cx"> if (testingMode() || !MediaAccessibilityLibrary())
</span><span class="lines">@@ -206,9 +189,9 @@
</span><span class="cx"> MACaptionAppearanceSetDisplayType(kMACaptionAppearanceDomainUser, displayType);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool CaptionUserPreferencesMediaAF::userPrefersCaptions() const
</del><ins>+bool CaptionUserPreferencesMediaAF::userPrefersCaptions(Document& document) const
</ins><span class="cx"> {
</span><del>- bool captionSetting = CaptionUserPreferences::userPrefersCaptions();
</del><ins>+ bool captionSetting = CaptionUserPreferences::userPrefersCaptions(document);
</ins><span class="cx"> if (captionSetting || testingMode() || !MediaAccessibilityLibrary())
</span><span class="cx"> return captionSetting;
</span><span class="cx">
</span><span class="lines">@@ -216,9 +199,9 @@
</span><span class="cx"> return captioningMediaCharacteristics && CFArrayGetCount(captioningMediaCharacteristics.get());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool CaptionUserPreferencesMediaAF::userPrefersSubtitles() const
</del><ins>+bool CaptionUserPreferencesMediaAF::userPrefersSubtitles(Document& document) const
</ins><span class="cx"> {
</span><del>- bool subtitlesSetting = CaptionUserPreferences::userPrefersSubtitles();
</del><ins>+ bool subtitlesSetting = CaptionUserPreferences::userPrefersSubtitles(document);
</ins><span class="cx"> if (subtitlesSetting || testingMode() || !MediaAccessibilityLibrary())
</span><span class="cx"> return subtitlesSetting;
</span><span class="cx">
</span><span class="lines">@@ -226,222 +209,6 @@
</span><span class="cx"> return !(captioningMediaCharacteristics && CFArrayGetCount(captioningMediaCharacteristics.get()));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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();
-}
-
</del><span class="cx"> float CaptionUserPreferencesMediaAF::captionFontSizeScaleAndImportance(bool& important) const
</span><span class="cx"> {
</span><span class="cx"> if (testingMode() || !MediaAccessibilityLibrary())
</span><span class="lines">@@ -507,59 +274,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
</span><span class="cx">
</span><del>-String CaptionUserPreferencesMediaAF::captionsStyleSheetOverride() const
-{
- if (testingMode())
- return CaptionUserPreferences::captionsStyleSheetOverride();
-
- StringBuilder captionsOverrideStyleSheet;
</del><span class="cx">
</span><del>-#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();
-}
-
</del><span class="cx"> static String languageIdentifier(const String& languageCode)
</span><span class="cx"> {
</span><span class="cx"> if (languageCode.isEmpty())
</span><span class="lines">@@ -635,6 +350,14 @@
</span><span class="cx"> return displayName.toString();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+String CaptionUserPreferencesMediaAF::platformCaptionsStyleSheet()
+{
+ if (!m_captionStyleSheet)
+ m_captionStyleSheet = defaultCaptionsStyleSheet();
+
+ return m_captionStyleSheet;
+}
+
</ins><span class="cx"> String CaptionUserPreferencesMediaAF::displayNameForTrack(TextTrack* track) const
</span><span class="cx"> {
</span><span class="cx"> return trackDisplayName(track);
</span><span class="lines">@@ -644,7 +367,7 @@
</span><span class="cx"> {
</span><span class="cx"> CaptionDisplayMode displayMode = captionDisplayMode();
</span><span class="cx"> bool legacyOverride = mediaElement->webkitClosedCaptionsVisible();
</span><del>- if (displayMode == AlwaysOn && (!userPrefersSubtitles() && !userPrefersCaptions() && !legacyOverride))
</del><ins>+ if (displayMode == AlwaysOn && (!userPrefersSubtitles(mediaElement->document()) && !userPrefersCaptions(mediaElement->document()) && !legacyOverride))
</ins><span class="cx"> return 0;
</span><span class="cx"> if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword() && track->kind() != TextTrack::forcedKeyword())
</span><span class="cx"> return 0;
</span><span class="lines">@@ -704,7 +427,7 @@
</span><span class="cx">
</span><span class="cx"> int trackScore = 0;
</span><span class="cx">
</span><del>- if (userPrefersCaptions()) {
</del><ins>+ if (userPrefersCaptions(mediaElement->document())) {
</ins><span class="cx"> // When the user prefers accessiblity tracks, rank is SDH, then CC, then subtitles.
</span><span class="cx"> if (track->kind() == track->subtitlesKeyword())
</span><span class="cx"> trackScore = 1;
</span><span class="lines">@@ -766,7 +489,7 @@
</span><span class="cx">
</span><span class="cx"> Vector<RefPtr<TextTrack>> tracksForMenu;
</span><span class="cx"> HashSet<String> languagesIncluded;
</span><del>- bool prefersAccessibilityTracks = userPrefersCaptions();
</del><ins>+ bool prefersAccessibilityTracks = userPrefersCaptions(trackList->mediaElement()->document());
</ins><span class="cx"> bool filterTrackList = shouldFilterTrackMenu();
</span><span class="cx">
</span><span class="cx"> for (unsigned i = 0, length = trackList->length(); i < length; ++i) {
</span><span class="lines">@@ -848,7 +571,7 @@
</span><span class="cx">
</span><span class="cx"> return tracksForMenu;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(VIDEO_TRACK)
</span></span></pre></div>
<a id="trunkSourceWebCorepageCaptionUserPreferencesMediaAFh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.h (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.h        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.h        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -37,50 +37,35 @@
</span><span class="cx">
</span><span class="cx"> class CaptionUserPreferencesMediaAF : public CaptionUserPreferences {
</span><span class="cx"> public:
</span><del>- CaptionUserPreferencesMediaAF(PageGroup&);
</del><ins>+ CaptionUserPreferencesMediaAF();
</ins><span class="cx"> virtual ~CaptionUserPreferencesMediaAF();
</span><span class="cx">
</span><span class="cx"> #if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
</span><ins>+ void captionApperenceChanged();
+
</ins><span class="cx"> virtual CaptionDisplayMode captionDisplayMode() const override;
</span><span class="cx"> virtual void setCaptionDisplayMode(CaptionDisplayMode) override;
</span><span class="cx">
</span><del>- virtual bool userPrefersCaptions() const override;
- virtual bool userPrefersSubtitles() const override;
</del><ins>+ virtual bool userPrefersCaptions(Document&) const override;
+ virtual bool userPrefersSubtitles(Document&) const override;
</ins><span class="cx">
</span><span class="cx"> virtual float captionFontSizeScaleAndImportance(bool&) const override;
</span><span class="cx">
</span><del>- virtual void setInterestedInCaptionPreferenceChanges() override;
-
</del><span class="cx"> virtual void setPreferredLanguage(const String&) override;
</span><span class="cx"> virtual Vector<String> preferredLanguages() const override;
</span><span class="cx">
</span><del>- virtual void captionPreferencesChanged() override;
-
</del><span class="cx"> bool shouldFilterTrackMenu() const { return true; }
</span><span class="cx"> #else
</span><span class="cx"> bool shouldFilterTrackMenu() const { return false; }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- virtual String captionsStyleSheetOverride() const override;
</del><ins>+ virtual String platformCaptionsStyleSheet() override;
</ins><span class="cx"> virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const override;
</span><span class="cx"> virtual Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*) override;
</span><span class="cx"> virtual String displayNameForTrack(TextTrack*) const override;
</span><span class="cx">
</span><span class="cx"> private:
</span><del>-#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
</del><ins>+ String m_captionStyleSheet;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/page/Page.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -92,6 +92,14 @@
</span><span class="cx"> #include <wtf/text/Base64.h>
</span><span class="cx"> #include <wtf/text/StringHash.h>
</span><span class="cx">
</span><ins>+#if ENABLE(VIDEO_TRACK)
+#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
+#include "CaptionUserPreferencesMediaAF.h"
+#else
+#include "CaptionUserPreferences.h"
+#endif
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> static HashSet<Page*>* allPages;
</span><span class="lines">@@ -1493,6 +1501,28 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><ins>+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();
+}
+
+
</ins><span class="cx"> void Page::captionPreferencesChanged()
</span><span class="cx"> {
</span><span class="cx"> for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/page/Page.h        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> class AlternativeTextClient;
</span><span class="cx"> class BackForwardController;
</span><span class="cx"> class BackForwardClient;
</span><ins>+class CaptionUserPreferences;
</ins><span class="cx"> class Chrome;
</span><span class="cx"> class ChromeClient;
</span><span class="cx"> class ClientRectList;
</span><span class="lines">@@ -402,6 +403,8 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><ins>+ static void updateStyleForAllPagesForCaptionPreferencesChanged();
+ CaptionUserPreferences& captionPreferences();
</ins><span class="cx"> void captionPreferencesChanged();
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageGroupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageGroup.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageGroup.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/page/PageGroup.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -42,14 +42,6 @@
</span><span class="cx"> #include "VisitedLinkProvider.h"
</span><span class="cx"> #include <wtf/StdLibExtras.h>
</span><span class="cx">
</span><del>-#if ENABLE(VIDEO_TRACK)
-#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
-#include "CaptionUserPreferencesMediaAF.h"
-#else
-#include "CaptionUserPreferences.h"
-#endif
-#endif
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> static unsigned getUniqueIdentifier()
</span><span class="lines">@@ -310,26 +302,4 @@
</span><span class="cx"> m_userContentController->removeAllUserContent();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#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
-
</del><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageGrouph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageGroup.h (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageGroup.h        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/page/PageGroup.h        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -45,11 +45,6 @@
</span><span class="cx"> class VisitedLinkProvider;
</span><span class="cx"> class UserContentController;
</span><span class="cx">
</span><del>-#if ENABLE(VIDEO_TRACK)
- class CaptionPreferencesChangedListener;
- class CaptionUserPreferences;
-#endif
-
</del><span class="cx"> class PageGroup : public Supplementable<PageGroup> {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(PageGroup); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="lines">@@ -103,11 +98,6 @@
</span><span class="cx">
</span><span class="cx"> GroupSettings& groupSettings() const { return *m_groupSettings; }
</span><span class="cx">
</span><del>-#if ENABLE(VIDEO_TRACK)
- void captionPreferencesChanged();
- CaptionUserPreferences* captionPreferences();
-#endif
-
</del><span class="cx"> private:
</span><span class="cx"> void addVisitedLink(LinkHash);
</span><span class="cx">
</span><span class="lines">@@ -126,10 +116,6 @@
</span><span class="cx"> RefPtr<UserContentController> m_userContentController;
</span><span class="cx">
</span><span class="cx"> const std::unique_ptr<GroupSettings> m_groupSettings;
</span><del>-
-#if ENABLE(VIDEO_TRACK)
- std::unique_ptr<CaptionUserPreferences> m_captionPreferences;
-#endif
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/InternalSettings.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -413,16 +413,12 @@
</span><span class="cx"> InternalSettingsGuardForSettings();
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><del>- if (!page())
- return;
- CaptionUserPreferences* captionPreferences = page()->group().captionPreferences();
-
</del><span class="cx"> if (equalIgnoringCase(kind, "Subtitles"))
</span><del>- captionPreferences->setUserPrefersSubtitles(enabled);
</del><ins>+ settings()->setShouldDisplaySubtitles(enabled);
</ins><span class="cx"> else if (equalIgnoringCase(kind, "Captions"))
</span><del>- captionPreferences->setUserPrefersCaptions(enabled);
</del><ins>+ settings()->setShouldDisplayCaptions(enabled);
</ins><span class="cx"> else if (equalIgnoringCase(kind, "TextDescriptions"))
</span><del>- captionPreferences->setUserPrefersTextDescriptions(enabled);
</del><ins>+ settings()->setShouldDisplayTextDescriptions(enabled);
</ins><span class="cx"> else
</span><span class="cx"> ec = SYNTAX_ERR;
</span><span class="cx"> #else
</span><span class="lines">@@ -436,16 +432,12 @@
</span><span class="cx"> InternalSettingsGuardForSettingsReturn(false);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><del>- if (!page())
- return false;
- CaptionUserPreferences* captionPreferences = page()->group().captionPreferences();
-
</del><span class="cx"> if (equalIgnoringCase(kind, "Subtitles"))
</span><del>- return captionPreferences->userPrefersSubtitles();
</del><ins>+ return settings()->shouldDisplaySubtitles();
</ins><span class="cx"> if (equalIgnoringCase(kind, "Captions"))
</span><del>- return captionPreferences->userPrefersCaptions();
</del><ins>+ return settings()->shouldDisplayCaptions();
</ins><span class="cx"> if (equalIgnoringCase(kind, "TextDescriptions"))
</span><del>- return captionPreferences->userPrefersTextDescriptions();
</del><ins>+ return settings()->shouldDisplayTextDescriptions();
</ins><span class="cx">
</span><span class="cx"> ec = SYNTAX_ERR;
</span><span class="cx"> return false;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (163047 => 163048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2014-01-30 00:31:05 UTC (rev 163047)
+++ trunk/Source/WebCore/testing/Internals.cpp        2014-01-30 00:35:31 UTC (rev 163048)
</span><span class="lines">@@ -281,8 +281,8 @@
</span><span class="cx"> page->inspectorController().setProfilerEnabled(false);
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
</span><del>- page->group().captionPreferences()->setCaptionsStyleSheetOverride(emptyString());
- page->group().captionPreferences()->setTestingMode(false);
</del><ins>+ page->captionPreferences().setCaptionsStyleSheetOverride(emptyString());
+ page->captionPreferences().setTestingMode(false);
</ins><span class="cx"> #endif
</span><span class="cx"> if (!page->mainFrame().editor().isContinuousSpellCheckingEnabled())
</span><span class="cx"> page->mainFrame().editor().toggleContinuousSpellChecking();
</span><span class="lines">@@ -302,7 +302,7 @@
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
</span><span class="cx"> if (document && document->page())
</span><del>- document->page()->group().captionPreferences()->setTestingMode(true);
</del><ins>+ document->page()->captionPreferences().setTestingMode(true);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="lines">@@ -2051,7 +2051,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
</span><del>- return document->page()->group().captionPreferences()->captionsStyleSheetOverride();
</del><ins>+ return document->page()->captionPreferences().captionsStyleSheetOverride();
</ins><span class="cx"> #else
</span><span class="cx"> return emptyString();
</span><span class="cx"> #endif
</span><span class="lines">@@ -2066,7 +2066,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
</span><del>- document->page()->group().captionPreferences()->setCaptionsStyleSheetOverride(override);
</del><ins>+ document->page()->captionPreferences().setCaptionsStyleSheetOverride(override);
</ins><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(override);
</span><span class="cx"> #endif
</span><span class="lines">@@ -2081,7 +2081,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
</span><del>- document->page()->group().captionPreferences()->setPrimaryAudioTrackLanguageOverride(language);
</del><ins>+ document->page()->captionPreferences().setPrimaryAudioTrackLanguageOverride(language);
</ins><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(language);
</span><span class="cx"> #endif
</span><span class="lines">@@ -2096,14 +2096,18 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
</span><del>- CaptionUserPreferences* captionPreferences = document->page()->group().captionPreferences();
</del><ins>+ CaptionUserPreferences& captionPreferences = document->page()->captionPreferences();
</ins><span class="cx">
</span><del>- 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);
</del><ins>+ 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);
</ins><span class="cx"> else
</span><span class="cx"> ec = SYNTAX_ERR;
</span><span class="cx"> #else
</span></span></pre>
</div>
</div>
</body>
</html>