Changeset 163073 in webkit


Ignore:
Timestamp:
Jan 29, 2014, 11:42:07 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r163048.
http://trac.webkit.org/changeset/163048
https://bugs.webkit.org/show_bug.cgi?id=127890

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

  • Modules/mediacontrols/MediaControlsHost.cpp:

(WebCore::MediaControlsHost::sortedTrackListForMenu):
(WebCore::MediaControlsHost::displayNameForTrack):
(WebCore::MediaControlsHost::captionDisplayMode):

  • WebCore.exp.in:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj:
  • css/DocumentRuleSets.cpp:

(WebCore::DocumentRuleSets::initUserStyle):

  • css/InspectorCSSOMWrappers.cpp:

(WebCore::InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection):

  • dom/Document.cpp:

(WebCore::Document::setCompatibilityMode):
(WebCore::Document::registerForCaptionPreferencesChangedCallbacks):
(WebCore::Document::captionPreferencesChanged):

  • dom/DocumentStyleSheetCollection.cpp:
  • dom/DocumentStyleSheetCollection.h:
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::parseAttribute):

  • html/shadow/MediaControlElements.cpp:

(WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay):
(WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
(WebCore::MediaControlTextTrackContainerElement::updateTimerFired):

  • page/CaptionStyleSheetMediaAF.cpp: Removed.
  • page/CaptionStyleSheetMediaAF.h: Removed.
  • page/CaptionUserPreferences.cpp:

(WebCore::CaptionUserPreferences::CaptionUserPreferences):
(WebCore::CaptionUserPreferences::notify):
(WebCore::CaptionUserPreferences::setCaptionDisplayMode):
(WebCore::CaptionUserPreferences::userPrefersCaptions):
(WebCore::CaptionUserPreferences::setUserPrefersCaptions):
(WebCore::CaptionUserPreferences::userPrefersSubtitles):
(WebCore::CaptionUserPreferences::setUserPrefersSubtitles):
(WebCore::CaptionUserPreferences::userPrefersTextDescriptions):
(WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions):
(WebCore::CaptionUserPreferences::captionPreferencesChanged):
(WebCore::CaptionUserPreferences::textTrackSelectionScore):
(WebCore::CaptionUserPreferences::setCaptionsStyleSheetOverride):
(WebCore::CaptionUserPreferences::updateCaptionStyleSheetOveride):

  • page/CaptionUserPreferences.h:

(WebCore::CaptionUserPreferences::captionsStyleSheetOverride):
(WebCore::CaptionUserPreferences::setInterestedInCaptionPreferenceChanges):
(WebCore::CaptionUserPreferences::testingMode):
(WebCore::CaptionUserPreferences::setTestingMode):
(WebCore::CaptionUserPreferences::pageGroup):

  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::userCaptionPreferencesChangedNotificationCallback):
(WebCore::CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF):
(WebCore::CaptionUserPreferencesMediaAF::userPrefersCaptions):
(WebCore::CaptionUserPreferencesMediaAF::userPrefersSubtitles):
(WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges):
(WebCore::CaptionUserPreferencesMediaAF::captionPreferencesChanged):
(WebCore::CaptionUserPreferencesMediaAF::captionsWindowCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsBackgroundCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsTextColor):
(WebCore::CaptionUserPreferencesMediaAF::captionsTextColorCSS):
(WebCore::CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsEdgeColorForTextColor):
(WebCore::CaptionUserPreferencesMediaAF::cssPropertyWithTextEdgeColor):
(WebCore::CaptionUserPreferencesMediaAF::colorPropertyCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsTextEdgeCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS):
(WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride):
(WebCore::CaptionUserPreferencesMediaAF::textTrackSelectionScore):
(WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):

  • page/CaptionUserPreferencesMediaAF.h:
  • page/Page.cpp:
  • page/Page.h:
  • page/PageGroup.cpp:

(WebCore::PageGroup::captionPreferencesChanged):
(WebCore::PageGroup::captionPreferences):

  • page/PageGroup.h:
  • testing/InternalSettings.cpp:

(WebCore::InternalSettings::setShouldDisplayTrackKind):
(WebCore::InternalSettings::shouldDisplayTrackKind):

  • testing/Internals.cpp:

(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::Internals):
(WebCore::Internals::captionsStyleSheetOverride):
(WebCore::Internals::setCaptionsStyleSheetOverride):
(WebCore::Internals::setPrimaryAudioTrackLanguageOverride):
(WebCore::Internals::setCaptionDisplayMode):

Location:
trunk/Source/WebCore
Files:
2 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r163072 r163073  
     12014-01-29  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r163048.
     4        http://trac.webkit.org/changeset/163048
     5        https://bugs.webkit.org/show_bug.cgi?id=127890
     6
     7        Caused many crashes, detected by EWS prior to landing
     8        (Requested by ap on #webkit).
     9
     10        * Modules/mediacontrols/MediaControlsHost.cpp:
     11        (WebCore::MediaControlsHost::sortedTrackListForMenu):
     12        (WebCore::MediaControlsHost::displayNameForTrack):
     13        (WebCore::MediaControlsHost::captionDisplayMode):
     14        * WebCore.exp.in:
     15        * WebCore.vcxproj/WebCore.vcxproj:
     16        * WebCore.vcxproj/WebCore.vcxproj.filters:
     17        * WebCore.xcodeproj/project.pbxproj:
     18        * css/DocumentRuleSets.cpp:
     19        (WebCore::DocumentRuleSets::initUserStyle):
     20        * css/InspectorCSSOMWrappers.cpp:
     21        (WebCore::InspectorCSSOMWrappers::collectFromDocumentStyleSheetCollection):
     22        * dom/Document.cpp:
     23        (WebCore::Document::setCompatibilityMode):
     24        (WebCore::Document::registerForCaptionPreferencesChangedCallbacks):
     25        (WebCore::Document::captionPreferencesChanged):
     26        * dom/DocumentStyleSheetCollection.cpp:
     27        * dom/DocumentStyleSheetCollection.h:
     28        * html/HTMLMediaElement.cpp:
     29        (WebCore::HTMLMediaElement::HTMLMediaElement):
     30        (WebCore::HTMLMediaElement::parseAttribute):
     31        * html/shadow/MediaControlElements.cpp:
     32        (WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay):
     33        (WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
     34        (WebCore::MediaControlTextTrackContainerElement::updateTimerFired):
     35        * page/CaptionStyleSheetMediaAF.cpp: Removed.
     36        * page/CaptionStyleSheetMediaAF.h: Removed.
     37        * page/CaptionUserPreferences.cpp:
     38        (WebCore::CaptionUserPreferences::CaptionUserPreferences):
     39        (WebCore::CaptionUserPreferences::notify):
     40        (WebCore::CaptionUserPreferences::setCaptionDisplayMode):
     41        (WebCore::CaptionUserPreferences::userPrefersCaptions):
     42        (WebCore::CaptionUserPreferences::setUserPrefersCaptions):
     43        (WebCore::CaptionUserPreferences::userPrefersSubtitles):
     44        (WebCore::CaptionUserPreferences::setUserPrefersSubtitles):
     45        (WebCore::CaptionUserPreferences::userPrefersTextDescriptions):
     46        (WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions):
     47        (WebCore::CaptionUserPreferences::captionPreferencesChanged):
     48        (WebCore::CaptionUserPreferences::textTrackSelectionScore):
     49        (WebCore::CaptionUserPreferences::setCaptionsStyleSheetOverride):
     50        (WebCore::CaptionUserPreferences::updateCaptionStyleSheetOveride):
     51        * page/CaptionUserPreferences.h:
     52        (WebCore::CaptionUserPreferences::captionsStyleSheetOverride):
     53        (WebCore::CaptionUserPreferences::setInterestedInCaptionPreferenceChanges):
     54        (WebCore::CaptionUserPreferences::testingMode):
     55        (WebCore::CaptionUserPreferences::setTestingMode):
     56        (WebCore::CaptionUserPreferences::pageGroup):
     57        * page/CaptionUserPreferencesMediaAF.cpp:
     58        (WebCore::userCaptionPreferencesChangedNotificationCallback):
     59        (WebCore::CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF):
     60        (WebCore::CaptionUserPreferencesMediaAF::userPrefersCaptions):
     61        (WebCore::CaptionUserPreferencesMediaAF::userPrefersSubtitles):
     62        (WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges):
     63        (WebCore::CaptionUserPreferencesMediaAF::captionPreferencesChanged):
     64        (WebCore::CaptionUserPreferencesMediaAF::captionsWindowCSS):
     65        (WebCore::CaptionUserPreferencesMediaAF::captionsBackgroundCSS):
     66        (WebCore::CaptionUserPreferencesMediaAF::captionsTextColor):
     67        (WebCore::CaptionUserPreferencesMediaAF::captionsTextColorCSS):
     68        (WebCore::CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS):
     69        (WebCore::CaptionUserPreferencesMediaAF::captionsEdgeColorForTextColor):
     70        (WebCore::CaptionUserPreferencesMediaAF::cssPropertyWithTextEdgeColor):
     71        (WebCore::CaptionUserPreferencesMediaAF::colorPropertyCSS):
     72        (WebCore::CaptionUserPreferencesMediaAF::captionsTextEdgeCSS):
     73        (WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS):
     74        (WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride):
     75        (WebCore::CaptionUserPreferencesMediaAF::textTrackSelectionScore):
     76        (WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu):
     77        * page/CaptionUserPreferencesMediaAF.h:
     78        * page/Page.cpp:
     79        * page/Page.h:
     80        * page/PageGroup.cpp:
     81        (WebCore::PageGroup::captionPreferencesChanged):
     82        (WebCore::PageGroup::captionPreferences):
     83        * page/PageGroup.h:
     84        * testing/InternalSettings.cpp:
     85        (WebCore::InternalSettings::setShouldDisplayTrackKind):
     86        (WebCore::InternalSettings::shouldDisplayTrackKind):
     87        * testing/Internals.cpp:
     88        (WebCore::Internals::resetToConsistentState):
     89        (WebCore::Internals::Internals):
     90        (WebCore::Internals::captionsStyleSheetOverride):
     91        (WebCore::Internals::setCaptionsStyleSheetOverride):
     92        (WebCore::Internals::setPrimaryAudioTrackLanguageOverride):
     93        (WebCore::Internals::setCaptionDisplayMode):
     94
    1952014-01-29  Csaba Osztrogonác  <ossy@webkit.org>
    296
  • trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp

    r163048 r163073  
    8383        return Vector<RefPtr<TextTrack>>();
    8484
    85     return page->captionPreferences().sortedTrackListForMenu(trackList);
     85    CaptionUserPreferences* captionPreferences = page->group().captionPreferences();
     86    return captionPreferences->sortedTrackListForMenu(trackList);
    8687}
    8788
     
    9596        return emptyString();
    9697
    97     return page->captionPreferences().displayNameForTrack(track);
     98    CaptionUserPreferences* captionPreferences = page->group().captionPreferences();
     99    return captionPreferences->displayNameForTrack(track);
    98100}
    99101
     
    114116        return emptyAtom;
    115117
    116     switch (page->captionPreferences().captionDisplayMode()) {
     118    switch (page->group().captionPreferences()->captionDisplayMode()) {
    117119    case CaptionUserPreferences::Automatic:
    118120        return automaticKeyword();
  • trunk/Source/WebCore/WebCore.exp.in

    r163048 r163073  
    30643064
    30653065#if ENABLE(VIDEO_TRACK)
    3066 __ZN7WebCore22CaptionUserPreferences29setCaptionsStyleSheetOverrideERKN3WTF6StringE
    3067 __ZN7WebCore4Page18captionPreferencesEv
    3068 __ZNK7WebCore22CaptionUserPreferences26captionsStyleSheetOverrideEv
     3066__ZN7WebCore9PageGroup18captionPreferencesEv
    30693067#endif
    30703068
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r163048 r163073  
    69856985    <ClCompile Include="..\page\AutoscrollController.cpp" />
    69866986    <ClCompile Include="..\page\BarProp.cpp" />
    6987     <ClCompile Include="..\page\CaptionStyleSheetMediaAF.cpp">
    6988       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
    6989       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
    6990       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
    6991       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
    6992     </ClCompile>
    69936987    <ClCompile Include="..\page\CaptionUserPreferences.cpp" />
    69946988    <ClCompile Include="..\page\CaptionUserPreferencesMediaAF.cpp">
     
    1876618760    <ClInclude Include="..\page\AutoscrollController.h" />
    1876718761    <ClInclude Include="..\page\BarProp.h" />
    18768     <ClInclude Include="..\page\CaptionStyleSheetMediaAF.h" />
    1876918762    <ClInclude Include="..\page\CaptionUserPreferences.h" />
    1877018763    <ClInclude Include="..\page\CaptionUserPreferencesMediaAF.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r163048 r163073  
    67256725      <Filter>platform\graphics\opengl</Filter>
    67266726    </ClCompile>
    6727     <ClCompile Include="..\page\CaptionStyleSheetMediaAF.cpp">
    6728       <Filter>page</Filter>
    6729     </ClCompile>
    67306727    <ClCompile Include="..\page\CaptionUserPreferencesMediaAF.cpp">
    67316728      <Filter>page</Filter>
     
    1450314500    <ClInclude Include="..\platform\graphics\opengl\GLPlatformSurface.h">
    1450414501      <Filter>platform\graphics\opengl</Filter>
    14505     </ClInclude>
    14506     <ClInclude Include="..\page\CaptionStyleSheetMediaAF.h">
    14507       <Filter>page</Filter>
    1450814502    </ClInclude>
    1450914503    <ClInclude Include="..\page\CaptionUserPreferences.h">
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r163048 r163073  
    22942294                7CE6CBFB187F370700D46BF5 /* FormatConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE6CBFA187F370700D46BF5 /* FormatConverter.h */; };
    22952295                7CE6CBFD187F394900D46BF5 /* FormatConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */; };
    2296                 7CFC30591895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFC30571895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp */; };
    2297                 7CFC305A1895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CFC30581895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h */; };
    22982296                7D741BDA177226AA00859170 /* CSSValueKeywords.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 6565814809D13043000E61D7 /* CSSValueKeywords.h */; };
    22992297                7E33CD01127F340D00BE8F17 /* PurgePriority.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E33CD00127F340D00BE8F17 /* PurgePriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    92379235                7CE6CBFA187F370700D46BF5 /* FormatConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatConverter.h; sourceTree = "<group>"; };
    92389236                7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatConverter.cpp; sourceTree = "<group>"; };
    9239                 7CFC30571895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CaptionStyleSheetMediaAF.cpp; sourceTree = "<group>"; };
    9240                 7CFC30581895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CaptionStyleSheetMediaAF.h; sourceTree = "<group>"; };
    92419237                7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = "<group>"; };
    92429238                7E37EF2D1339208800B29250 /* SubresourceLoaderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SubresourceLoaderCF.cpp; path = cf/SubresourceLoaderCF.cpp; sourceTree = "<group>"; };
     
    1603716033                                079D086A162F21F900DB8658 /* CaptionUserPreferencesMediaAF.cpp */,
    1603816034                                079D0869162F21F900DB8658 /* CaptionUserPreferencesMediaAF.h */,
    16039                                 7CFC30571895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp */,
    16040                                 7CFC30581895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h */,
    1604116035                                14D8238A0AF92DF60004F057 /* Chrome.cpp */,
    1604216036                                14D823500AF92A790004F057 /* Chrome.h */,
     
    2260622600                                9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */,
    2260722601                                FE4AADEE16D2C37400026FFC /* AbstractSQLStatement.h in Headers */,
    22608                                 7CFC305A1895EFAD00E8F43F /* CaptionStyleSheetMediaAF.h in Headers */,
    2260922602                                6E84E9E117668BF100815B68 /* RasterShape.h in Headers */,
    2261022603                                FE4AADEF16D2C37400026FFC /* AbstractSQLStatementBackend.h in Headers */,
     
    2712627119                                A8EA79FC0A1916DF00A8EF5F /* HTMLLIElement.cpp in Sources */,
    2712727120                                A871DC210A15205700B12A68 /* HTMLLinkElement.cpp in Sources */,
    27128                                 7CFC30591895EFAD00E8F43F /* CaptionStyleSheetMediaAF.cpp in Sources */,
    2712927121                                A8EA7D320A19385500A8EF5F /* HTMLMapElement.cpp in Sources */,
    2713027122                                A8EA7CAC0A192B9C00A8EF5F /* HTMLMarqueeElement.cpp in Sources */,
  • trunk/Source/WebCore/css/DocumentRuleSets.cpp

    r163048 r163073  
    5252    if (CSSStyleSheet* pageUserSheet = styleSheetCollection.pageUserSheet())
    5353        tempUserStyle->addRulesFromSheet(&pageUserSheet->contents(), medium, &resolver);
    54     if (CSSStyleSheet* captionsStyleSheet = styleSheetCollection.captionsStyleSheet())
    55         tempUserStyle->addRulesFromSheet(&captionsStyleSheet->contents(), medium, &resolver);
    5654    collectRulesFromUserStyleSheets(styleSheetCollection.injectedUserStyleSheets(), *tempUserStyle, medium, resolver);
    5755    collectRulesFromUserStyleSheets(styleSheetCollection.documentUserStyleSheets(), *tempUserStyle, medium, resolver);
  • trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp

    r163048 r163073  
    108108    collectFromStyleSheets(styleSheetCollection.activeAuthorStyleSheets());
    109109    collect(styleSheetCollection.pageUserSheet());
    110     collect(styleSheetCollection.captionsStyleSheet());
    111110    collectFromStyleSheets(styleSheetCollection.injectedUserStyleSheets());
    112111    collectFromStyleSheets(styleSheetCollection.documentUserStyleSheets());
  • trunk/Source/WebCore/dom/Document.cpp

    r163048 r163073  
    749749        // All user stylesheets have to reparse using the different mode.
    750750        m_styleSheetCollection.clearPageUserSheet();
    751         m_styleSheetCollection.invalidateCaptionsStyleSheet();
    752751        m_styleSheetCollection.invalidateInjectedStyleSheetCache();
    753752    }
     
    41734172void Document::registerForCaptionPreferencesChangedCallbacks(Element* e)
    41744173{
     4174    if (page())
     4175        page()->group().captionPreferences()->setInterestedInCaptionPreferenceChanges();
     4176
    41754177    m_captionPreferencesChangedElements.add(e);
    41764178}
     
    41834185void Document::captionPreferencesChanged()
    41844186{
    4185     m_styleSheetCollection.invalidateCaptionsStyleSheet();
    4186     styleResolverChanged(DeferRecalcStyle);
    4187 
    4188     for (auto* element : m_captionPreferencesChangedElements)
    4189         element->captionPreferencesChanged();
     4187    HashSet<Element*>::iterator end = m_captionPreferencesChangedElements.end();
     4188    for (HashSet<Element*>::iterator it = m_captionPreferencesChangedElements.begin(); it != end; ++it)
     4189        (*it)->captionPreferencesChanged();
    41904190}
    41914191#endif
  • trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp

    r163048 r163073  
    3030
    3131#include "CSSStyleSheet.h"
    32 #include "CaptionUserPreferences.h"
    3332#include "Element.h"
    3433#include "HTMLIFrameElement.h"
     
    118117    if (pageUserSheet())
    119118        m_document.styleResolverChanged(RecalcStyleImmediately);
    120 }
    121 
    122 CSSStyleSheet* DocumentStyleSheetCollection::captionsStyleSheet()
    123 {
    124     updateCaptionsStyleSheet();
    125     return m_captionsStyleSheet.get();
    126 }
    127 
    128 void DocumentStyleSheetCollection::updateCaptionsStyleSheet()
    129 {
    130     // Identify our override style sheet with a unique URL - a new scheme and a UUID.
    131     DEFINE_STATIC_LOCAL(URL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"));
    132 
    133     if (m_captionsStyleSheet)
    134         return;
    135 
    136     Page* owningPage = m_document.page();
    137     if (!owningPage)
    138         return;
    139    
    140     String captionsStyleSheetText = owningPage->captionPreferences().captionsStyleSheet();
    141     if (captionsStyleSheetText.isEmpty())
    142         return;
    143 
    144     // Parse the sheet and cache it.
    145     m_captionsStyleSheet = CSSStyleSheet::createInline(m_document, captionsStyleSheetURL);
    146     m_captionsStyleSheet->contents().parseString(captionsStyleSheetText);
    147 }
    148 
    149 void DocumentStyleSheetCollection::invalidateCaptionsStyleSheet()
    150 {
    151     if (m_captionsStyleSheet) {
    152         m_captionsStyleSheet = nullptr;
    153         m_document.styleResolverChanged(DeferRecalcStyle);
    154     }
    155119}
    156120
  • trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h

    r163048 r163073  
    5454
    5555    CSSStyleSheet* pageUserSheet();
    56     CSSStyleSheet* captionsStyleSheet();
    5756    const Vector<RefPtr<CSSStyleSheet>>& documentUserStyleSheets() const { return m_userStyleSheets; }
    5857    const Vector<RefPtr<CSSStyleSheet>>& documentAuthorStyleSheets() const { return m_authorStyleSheets; }
     
    6564    void clearPageUserSheet();
    6665    void updatePageUserSheet();
    67    
    68     void invalidateCaptionsStyleSheet();
    69     void updateCaptionsStyleSheet();
    70 
    7166    void invalidateInjectedStyleSheetCache();
    7267    void updateInjectedStyleSheetCache() const;
     
    147142
    148143    RefPtr<CSSStyleSheet> m_pageUserSheet;
    149     RefPtr<CSSStyleSheet> m_captionsStyleSheet;
    150144
    151145    mutable Vector<RefPtr<CSSStyleSheet>> m_injectedUserStyleSheets;
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r163048 r163073  
    380380    document.registerForCaptionPreferencesChangedCallbacks(this);
    381381    if (document.page())
    382         m_captionDisplayMode = document.page()->captionPreferences().captionDisplayMode();
     382        m_captionDisplayMode = document.page()->group().captionPreferences()->captionDisplayMode();
    383383#endif
    384384}
     
    34253425
    34263426    Page* page = document().page();
    3427     CaptionUserPreferences* captionPreferences = page ? &page->captionPreferences() : nullptr;
     3427    CaptionUserPreferences* captionPreferences = page? page->group().captionPreferences() : 0;
    34283428    CaptionUserPreferences::CaptionDisplayMode displayMode = captionPreferences ? captionPreferences->captionDisplayMode() : CaptionUserPreferences::Automatic;
    34293429
     
    35353535    }
    35363536
    3537     if (!document().page())
    3538         return;
    3539 
    3540     CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
     3537    CaptionUserPreferences* captionPreferences = document().page() ? document().page()->group().captionPreferences() : 0;
     3538    if (!captionPreferences)
     3539        return;
     3540
     3541    CaptionUserPreferences::CaptionDisplayMode displayMode = captionPreferences->captionDisplayMode();
    35413542    if (trackToSelect == TextTrack::captionMenuOffItem())
    35423543        displayMode = CaptionUserPreferences::ForcedOnly;
     
    35463547        displayMode = CaptionUserPreferences::AlwaysOn;
    35473548        if (trackToSelect->language().length())
    3548             document().page()->captionPreferences().setPreferredLanguage(trackToSelect->language());
     3549            captionPreferences->setPreferredLanguage(trackToSelect->language());
    35493550       
    35503551        // Set m_captionDisplayMode here so we don't reconfigure again when the preference changed notification comes through.
     
    35523553    }
    35533554
    3554     document().page()->captionPreferences().setCaptionDisplayMode(displayMode);
     3555    captionPreferences->setCaptionDisplayMode(displayMode);
    35553556}
    35563557
     
    52565257    if (!document().page())
    52575258        return;
    5258    
    5259     CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
     5259
     5260    CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->group().captionPreferences()->captionDisplayMode();
    52605261    if (m_captionDisplayMode == displayMode)
    52615262        return;
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r163048 r163073  
    821821    if (!document().page())
    822822        return;
    823     CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->captionPreferences().captionDisplayMode();
     823    CaptionUserPreferences::CaptionDisplayMode displayMode = document().page()->group().captionPreferences()->captionDisplayMode();
    824824
    825825    HTMLMediaElement* mediaElement = parentMediaElement(this);
     
    897897    if (!document().page())
    898898        return;
    899 
    900     CaptionUserPreferences& captionPreferences = document().page()->captionPreferences();
    901     Vector<RefPtr<TextTrack>> tracksForMenu = captionPreferences.sortedTrackListForMenu(trackList);
     899    CaptionUserPreferences* captionPreferences = document().page()->group().captionPreferences();
     900    Vector<RefPtr<TextTrack>> tracksForMenu = captionPreferences->sortedTrackListForMenu(trackList);
    902901
    903902    RefPtr<Element> captionsHeader = document().createElement(h3Tag, ASSERT_NO_EXCEPTION);
     
    909908        RefPtr<TextTrack> textTrack = tracksForMenu[i];
    910909        RefPtr<Element> menuItem = document().createElement(liTag, ASSERT_NO_EXCEPTION);
    911         menuItem->appendChild(document().createTextNode(captionPreferences.displayNameForTrack(textTrack.get())));
     910        menuItem->appendChild(document().createTextNode(captionPreferences->displayNameForTrack(textTrack.get())));
    912911        captionsMenuList->appendChild(menuItem);
    913912        m_menuItems.append(menuItem);
     
    13331332
    13341333    float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
    1335     float fontScale = document().page()->captionPreferences().captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
     1334    float fontScale = document().page()->group().captionPreferences()->captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
    13361335    m_fontSize = lroundf(smallestDimension * fontScale);
    13371336   
  • trunk/Source/WebCore/page/CaptionUserPreferences.cpp

    r163048 r163073  
    2929
    3030#include "CaptionUserPreferences.h"
    31 
    32 #include "HTMLMediaElement.h"
     31#include "DOMWrapperWorld.h"
    3332#include "Page.h"
    34 #include "PageCache.h"
     33#include "PageGroup.h"
    3534#include "Settings.h"
    3635#include "TextTrackList.h"
     36#include "UserStyleSheetTypes.h"
    3737
    3838namespace WebCore {
    3939
    40 CaptionUserPreferences::CaptionUserPreferences()
    41     : m_timer(this, &CaptionUserPreferences::timerFired)
     40CaptionUserPreferences::CaptionUserPreferences(PageGroup& group)
     41    : m_pageGroup(group)
    4242    , m_displayMode(ForcedOnly)
     43    , m_timer(this, &CaptionUserPreferences::timerFired)
    4344    , m_testingMode(false)
     45    , m_havePreferences(false)
    4446{
    4547}
     
    5658void CaptionUserPreferences::notify()
    5759{
     60    m_havePreferences = true;
    5861    if (!m_timer.isActive())
    5962        m_timer.startOneShot(0);
     
    6871{
    6972    m_displayMode = mode;
    70     notify();
    71 }
    72 
    73 bool CaptionUserPreferences::userPrefersCaptions(Document& document) const
    74 {
    75     Settings* settings = document.settings();
    76     if (!settings)
     73    if (m_testingMode && mode != AlwaysOn) {
     74        setUserPrefersCaptions(false);
     75        setUserPrefersSubtitles(false);
     76    }
     77    notify();
     78}
     79
     80bool CaptionUserPreferences::userPrefersCaptions() const
     81{
     82    Page* page = *(m_pageGroup.pages().begin());
     83    if (!page)
    7784        return false;
    7885
    79     return settings->shouldDisplayCaptions();
    80 }
    81 
    82 bool CaptionUserPreferences::userPrefersSubtitles(Document& document) const
    83 {
    84     Settings* settings = document.settings();
    85     if (!settings)
     86    return page->settings().shouldDisplayCaptions();
     87}
     88
     89void CaptionUserPreferences::setUserPrefersCaptions(bool preference)
     90{
     91    Page* page = *(m_pageGroup.pages().begin());
     92    if (!page)
     93        return;
     94
     95    page->settings().setShouldDisplayCaptions(preference);
     96    notify();
     97}
     98
     99bool CaptionUserPreferences::userPrefersSubtitles() const
     100{
     101    Page* page = *(pageGroup().pages().begin());
     102    if (!page)
    86103        return false;
    87104
    88     return settings->shouldDisplaySubtitles();
    89 }
    90 
    91 bool CaptionUserPreferences::userPrefersTextDescriptions(Document& document) const
    92 {
    93     Settings* settings = document.settings();
    94     if (!settings)
     105    return page->settings().shouldDisplaySubtitles();
     106}
     107
     108void CaptionUserPreferences::setUserPrefersSubtitles(bool preference)
     109{
     110    Page* page = *(m_pageGroup.pages().begin());
     111    if (!page)
     112        return;
     113
     114    page->settings().setShouldDisplaySubtitles(preference);
     115    notify();
     116}
     117
     118bool CaptionUserPreferences::userPrefersTextDescriptions() const
     119{
     120    Page* page = *(m_pageGroup.pages().begin());
     121    if (!page)
    95122        return false;
    96 
    97     return settings->shouldDisplayTextDescriptions();
     123   
     124    return page->settings().shouldDisplayTextDescriptions();
     125}
     126
     127void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference)
     128{
     129    Page* page = *(m_pageGroup.pages().begin());
     130    if (!page)
     131        return;
     132   
     133    page->settings().setShouldDisplayTextDescriptions(preference);
     134    notify();
     135}
     136
     137void CaptionUserPreferences::captionPreferencesChanged()
     138{
     139    m_pageGroup.captionPreferencesChanged();
    98140}
    99141
     
    155197}
    156198
    157 int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement* element) const
     199int CaptionUserPreferences::textTrackSelectionScore(TextTrack* track, HTMLMediaElement*) const
    158200{
    159201    int trackScore = 0;
     
    162204        return trackScore;
    163205   
    164     if (!userPrefersSubtitles(element->document()) && !userPrefersCaptions(element->document()))
     206    if (!userPrefersSubtitles() && !userPrefersCaptions())
    165207        return trackScore;
    166208   
    167     if (track->kind() == TextTrack::subtitlesKeyword() && userPrefersSubtitles(element->document()))
     209    if (track->kind() == TextTrack::subtitlesKeyword() && userPrefersSubtitles())
    168210        trackScore = 1;
    169     else if (track->kind() == TextTrack::captionsKeyword() && userPrefersCaptions(element->document()))
     211    else if (track->kind() == TextTrack::captionsKeyword() && userPrefersCaptions())
    170212        trackScore = 1;
    171213   
     
    187229}
    188230
    189 String CaptionUserPreferences::captionsStyleSheet()
    190 {
    191     if (!m_captionsStyleSheetOverride.isEmpty() || testingMode())
    192         return m_captionsStyleSheetOverride;
    193 
    194     return platformCaptionsStyleSheet();
    195 }
    196 
    197231void CaptionUserPreferences::setCaptionsStyleSheetOverride(const String& override)
    198232{
    199233    m_captionsStyleSheetOverride = override;
    200     captionPreferencesChanged();
    201 }
    202 
    203 String CaptionUserPreferences::captionsStyleSheetOverride() const
    204 {
    205     return m_captionsStyleSheetOverride;
     234    updateCaptionStyleSheetOveride();
     235}
     236
     237void CaptionUserPreferences::updateCaptionStyleSheetOveride()
     238{
     239    // Identify our override style sheet with a unique URL - a new scheme and a UUID.
     240    DEFINE_STATIC_LOCAL(URL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"));
     241
     242    m_pageGroup.removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL);
     243
     244    String captionsOverrideStyleSheet = captionsStyleSheetOverride();
     245    if (captionsOverrideStyleSheet.isEmpty())
     246        return;
     247
     248    m_pageGroup.addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, Vector<String>(),
     249        Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments);
    206250}
    207251
     
    212256    return defaultLanguage();
    213257}
    214 
    215 void CaptionUserPreferences::captionPreferencesChanged()
    216 {
    217     Page::updateStyleForAllPagesForCaptionPreferencesChanged();
    218     pageCache()->markPagesForCaptionPreferencesChanged();
    219 }
    220 
    221 } // namespace WebCore
     258   
     259}
    222260
    223261#endif // ENABLE(VIDEO_TRACK)
  • trunk/Source/WebCore/page/CaptionUserPreferences.h

    r163048 r163073  
    4444class CaptionUserPreferences {
    4545public:
    46     CaptionUserPreferences();
     46    CaptionUserPreferences(PageGroup&);
    4747    virtual ~CaptionUserPreferences();
    48 
    49     String captionsStyleSheet();
    5048
    5149    enum CaptionDisplayMode {
     
    5452        AlwaysOn
    5553    };
    56 
    5754    virtual CaptionDisplayMode captionDisplayMode() const;
    5855    virtual void setCaptionDisplayMode(CaptionDisplayMode);
     
    6057    virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const;
    6158    virtual int textTrackLanguageSelectionScore(TextTrack*, const Vector<String>&) const;
    62     virtual bool userPrefersCaptions(Document&) const;
    63     virtual bool userPrefersSubtitles(Document&) const;
    64     virtual bool userPrefersTextDescriptions(Document&) const;
     59
     60    virtual bool userPrefersCaptions() const;
     61    virtual void setUserPrefersCaptions(bool);
     62
     63    virtual bool userPrefersSubtitles() const;
     64    virtual void setUserPrefersSubtitles(bool preference);
     65   
     66    virtual bool userPrefersTextDescriptions() const;
     67    virtual void setUserPrefersTextDescriptions(bool preference);
    6568
    6669    virtual float captionFontSizeScaleAndImportance(bool& important) const { important = false; return 0.05f; }
     70
     71    virtual String captionsStyleSheetOverride() const { return m_captionsStyleSheetOverride; }
     72    virtual void setCaptionsStyleSheetOverride(const String&);
     73
     74    virtual void setInterestedInCaptionPreferenceChanges() { }
     75
     76    virtual void captionPreferencesChanged();
    6777
    6878    virtual void setPreferredLanguage(const String&);
     
    7282    virtual Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*);
    7383
    74     void captionPreferencesChanged();
    75 
    76     // These are used for testing mode only.
    77     void setCaptionsStyleSheetOverride(const String&);
    78     String captionsStyleSheetOverride() const;
    7984    void setPrimaryAudioTrackLanguageOverride(const String& language) { m_primaryAudioTrackLanguageOverride = language;  }
    8085    String primaryAudioTrackLanguageOverride() const;
    81     void setTestingMode(bool override) { m_testingMode = override; }
    82     bool testingMode() const { return m_testingMode; }
     86
     87    virtual bool testingMode() const { return m_testingMode; }
     88    virtual void setTestingMode(bool override) { m_testingMode = override; }
    8389   
     90    PageGroup& pageGroup() const { return m_pageGroup; }
     91
     92protected:
     93    void updateCaptionStyleSheetOveride();
     94
    8495private:
    8596    void timerFired(Timer<CaptionUserPreferences>&);
    8697    void notify();
    8798
    88     virtual String platformCaptionsStyleSheet() { return String(); }
    89 
     99    PageGroup& m_pageGroup;
     100    CaptionDisplayMode m_displayMode;
    90101    Timer<CaptionUserPreferences> m_timer;
    91 
    92     // These are used for testing mode only.
    93     CaptionDisplayMode m_displayMode;
    94102    String m_userPreferredLanguage;
    95103    String m_captionsStyleSheetOverride;
    96104    String m_primaryAudioTrackLanguageOverride;
    97105    bool m_testingMode;
     106    bool m_havePreferences;
    98107};
    99 
     108   
    100109}
    101110#endif
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r163048 r163073  
    3030#include "CaptionUserPreferencesMediaAF.h"
    3131
    32 #include "CaptionStyleSheetMediaAF.h"
     32#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     33#include "CoreText/CoreText.h"
     34#endif
    3335#include "FloatConversion.h"
    3436#include "HTMLMediaElement.h"
     
    4143#include "TextTrackCue.h"
    4244#include "TextTrackList.h"
     45#include "UserStyleSheetTypes.h"
    4346#include <wtf/RetainPtr.h>
    4447#include <wtf/text/CString.h>
     
    7477
    7578SOFT_LINK_AVF_FRAMEWORK(MediaAccessibility)
     79SOFT_LINK_AVF_FRAMEWORK(CoreText)
    7680
    7781SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetDisplayType, MACaptionAppearanceDisplayType, (MACaptionAppearanceDomain domain), (domain))
    7882SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceSetDisplayType, void, (MACaptionAppearanceDomain domain, MACaptionAppearanceDisplayType displayType), (domain, displayType))
     83SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyForegroundColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     84SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyBackgroundColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     85SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyWindowColor, CGColorRef, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     86SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetForegroundOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     87SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetBackgroundOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     88SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetWindowOpacity, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     89SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetWindowRoundedCornerRadius, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     90SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyFontDescriptorForStyle, CTFontDescriptorRef, (MACaptionAppearanceDomain domain,  MACaptionAppearanceBehavior *behavior, MACaptionAppearanceFontStyle fontStyle), (domain, behavior, fontStyle))
     91SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetRelativeCharacterSize, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     92SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetTextEdgeStyle, MACaptionAppearanceTextEdgeStyle, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
    7993SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceAddSelectedLanguage, bool, (MACaptionAppearanceDomain domain, CFStringRef language), (domain, language));
    8094SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopySelectedLanguages, CFArrayRef, (MACaptionAppearanceDomain domain), (domain));
    8195SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics,  CFArrayRef, (MACaptionAppearanceDomain domain), (domain));
    82 SOFT_LINK_AVF_FRAMEWORK_IMPORT(MediaAccessibility, MACaptionAppearanceGetRelativeCharacterSize, CGFloat, (MACaptionAppearanceDomain domain, MACaptionAppearanceBehavior *behavior), (domain, behavior))
     96
     97SOFT_LINK_AVF_FRAMEWORK_IMPORT(CoreText, CTFontDescriptorCopyAttribute,  CFTypeRef, (CTFontDescriptorRef descriptor, CFStringRef attribute), (descriptor, attribute));
    8398
    8499#if PLATFORM(WIN)
     
    86101#define MACaptionAppearanceGetDisplayType softLink_MACaptionAppearanceGetDisplayType
    87102#define MACaptionAppearanceSetDisplayType softLink_MACaptionAppearanceSetDisplayType
     103#define MACaptionAppearanceCopyForegroundColor softLink_MACaptionAppearanceCopyForegroundColor
     104#define MACaptionAppearanceCopyBackgroundColor softLink_MACaptionAppearanceCopyBackgroundColor
     105#define MACaptionAppearanceCopyWindowColor softLink_MACaptionAppearanceCopyWindowColor
     106#define MACaptionAppearanceGetForegroundOpacity softLink_MACaptionAppearanceGetForegroundOpacity
     107#define MACaptionAppearanceGetBackgroundOpacity softLink_MACaptionAppearanceGetBackgroundOpacity
     108#define MACaptionAppearanceGetWindowOpacity softLink_MACaptionAppearanceGetWindowOpacity
     109#define MACaptionAppearanceGetWindowRoundedCornerRadius softLink_MACaptionAppearanceGetWindowRoundedCornerRadius
     110#define MACaptionAppearanceCopyFontDescriptorForStyle softLink_MACaptionAppearanceCopyFontDescriptorForStyle
     111#define MACaptionAppearanceGetRelativeCharacterSize softLink_MACaptionAppearanceGetRelativeCharacterSize
     112#define MACaptionAppearanceGetTextEdgeStyle softLink_MACaptionAppearanceGetTextEdgeStyle
    88113#define MACaptionAppearanceAddSelectedLanguage softLink_MACaptionAppearanceAddSelectedLanguage
    89114#define MACaptionAppearanceCopySelectedLanguages softLink_MACaptionAppearanceCopySelectedLanguages
    90115#define MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics softLink_MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics
    91 #define MACaptionAppearanceGetRelativeCharacterSize softLink_MACaptionAppearanceGetRelativeCharacterSize
     116#define CTFontDescriptorCopyAttribute softLink_CTFontDescriptorCopyAttribute
    92117#endif
    93118
     
    95120#define kMAXCaptionAppearanceSettingsChangedNotification getkMAXCaptionAppearanceSettingsChangedNotification()
    96121
    97 #endif
    98 
     122SOFT_LINK_AVF_POINTER(CoreText, kCTFontNameAttribute, CFStringRef)
     123#define kCTFontNameAttribute getkCTFontNameAttribute()
     124#endif
    99125
    100126namespace WebCore {
     
    104130{
    105131#if !PLATFORM(IOS)
    106     static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionApperenceChanged();
     132    static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionPreferencesChanged();
    107133#else
    108134    WebThreadRun(^{
    109         static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionApperenceChanged();
     135        static_cast<CaptionUserPreferencesMediaAF*>(observer)->captionPreferencesChanged();
    110136    });
    111137#endif
     
    113139#endif
    114140
    115 CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF()
    116 {
     141CaptionUserPreferencesMediaAF::CaptionUserPreferencesMediaAF(PageGroup& group)
     142    : CaptionUserPreferences(group)
    117143#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
    118     if (MediaAccessibilityLibrary() && kMAXCaptionAppearanceSettingsChangedNotification)
    119         CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, 0, CFNotificationSuspensionBehaviorCoalesce);
    120 #endif
     144    , m_listeningForPreferenceChanges(false)
     145#endif
     146{
    121147}
    122148
     
    130156
    131157#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
    132 
    133 void CaptionUserPreferencesMediaAF::captionApperenceChanged()
    134 {
    135     // Invalidate the caption style sheet.
    136     m_captionStyleSheet = String();
    137 
    138     // Tell the base class to invalidate all the uses of it.
    139     captionPreferencesChanged();
    140 }
    141158
    142159CaptionUserPreferences::CaptionDisplayMode CaptionUserPreferencesMediaAF::captionDisplayMode() const
     
    190207}
    191208
    192 bool CaptionUserPreferencesMediaAF::userPrefersCaptions(Document& document) const
    193 {
    194     bool captionSetting = CaptionUserPreferences::userPrefersCaptions(document);
     209bool CaptionUserPreferencesMediaAF::userPrefersCaptions() const
     210{
     211    bool captionSetting = CaptionUserPreferences::userPrefersCaptions();
    195212    if (captionSetting || testingMode() || !MediaAccessibilityLibrary())
    196213        return captionSetting;
     
    200217}
    201218
    202 bool CaptionUserPreferencesMediaAF::userPrefersSubtitles(Document& document) const
    203 {
    204     bool subtitlesSetting = CaptionUserPreferences::userPrefersSubtitles(document);
     219bool CaptionUserPreferencesMediaAF::userPrefersSubtitles() const
     220{
     221    bool subtitlesSetting = CaptionUserPreferences::userPrefersSubtitles();
    205222    if (subtitlesSetting || testingMode() || !MediaAccessibilityLibrary())
    206223        return subtitlesSetting;
     
    208225    RetainPtr<CFArrayRef> captioningMediaCharacteristics = adoptCF(MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics(kMACaptionAppearanceDomainUser));
    209226    return !(captioningMediaCharacteristics && CFArrayGetCount(captioningMediaCharacteristics.get()));
     227}
     228
     229void CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges()
     230{
     231    if (!MediaAccessibilityLibrary())
     232        return;
     233
     234    if (!kMAXCaptionAppearanceSettingsChangedNotification)
     235        return;
     236
     237    if (!m_listeningForPreferenceChanges) {
     238        m_listeningForPreferenceChanges = true;
     239        CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, 0, CFNotificationSuspensionBehaviorCoalesce);
     240        updateCaptionStyleSheetOveride();
     241    }
     242}
     243
     244void CaptionUserPreferencesMediaAF::captionPreferencesChanged()
     245{
     246    if (m_listeningForPreferenceChanges)
     247        updateCaptionStyleSheetOveride();
     248
     249    CaptionUserPreferences::captionPreferencesChanged();
     250}
     251
     252String CaptionUserPreferencesMediaAF::captionsWindowCSS() const
     253{
     254    MACaptionAppearanceBehavior behavior;
     255    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyWindowColor(kMACaptionAppearanceDomainUser, &behavior));
     256
     257    Color windowColor(color.get());
     258    if (!windowColor.isValid())
     259        windowColor = Color::transparent;
     260
     261    bool important = behavior == kMACaptionAppearanceBehaviorUseValue;
     262    CGFloat opacity = MACaptionAppearanceGetWindowOpacity(kMACaptionAppearanceDomainUser, &behavior);
     263    if (!important)
     264        important = behavior == kMACaptionAppearanceBehaviorUseValue;
     265    String windowStyle = colorPropertyCSS(CSSPropertyBackgroundColor, Color(windowColor.red(), windowColor.green(), windowColor.blue(), static_cast<int>(opacity * 255)), important);
     266
     267    if (!opacity)
     268        return windowStyle;
     269
     270    StringBuilder builder;
     271    builder.append(windowStyle);
     272    builder.append(getPropertyNameString(CSSPropertyPadding));
     273    builder.append(": .4em !important;");
     274
     275    return builder.toString();
     276}
     277
     278String CaptionUserPreferencesMediaAF::captionsBackgroundCSS() const
     279{
     280    // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-past-nodes
     281    // and webkit-media-text-track-future-nodes.
     282    DEFINE_STATIC_LOCAL(Color, defaultBackgroundColor, (Color(0, 0, 0, 0.8 * 255)));
     283
     284    MACaptionAppearanceBehavior behavior;
     285
     286    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyBackgroundColor(kMACaptionAppearanceDomainUser, &behavior));
     287    Color backgroundColor(color.get());
     288    if (!backgroundColor.isValid())
     289        backgroundColor = defaultBackgroundColor;
     290
     291    bool important = behavior == kMACaptionAppearanceBehaviorUseValue;
     292    CGFloat opacity = MACaptionAppearanceGetBackgroundOpacity(kMACaptionAppearanceDomainUser, &behavior);
     293    if (!important)
     294        important = behavior == kMACaptionAppearanceBehaviorUseValue;
     295    return colorPropertyCSS(CSSPropertyBackgroundColor, Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), static_cast<int>(opacity * 255)), important);
     296}
     297
     298Color CaptionUserPreferencesMediaAF::captionsTextColor(bool& important) const
     299{
     300    MACaptionAppearanceBehavior behavior;
     301    RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyForegroundColor(kMACaptionAppearanceDomainUser, &behavior));
     302    Color textColor(color.get());
     303    if (!textColor.isValid())
     304        // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-container.
     305        textColor = Color::white;
     306   
     307    important = behavior == kMACaptionAppearanceBehaviorUseValue;
     308    CGFloat opacity = MACaptionAppearanceGetForegroundOpacity(kMACaptionAppearanceDomainUser, &behavior);
     309    if (!important)
     310        important = behavior == kMACaptionAppearanceBehaviorUseValue;
     311    return Color(textColor.red(), textColor.green(), textColor.blue(), static_cast<int>(opacity * 255));
     312}
     313   
     314String CaptionUserPreferencesMediaAF::captionsTextColorCSS() const
     315{
     316    bool important;
     317    Color textColor = captionsTextColor(important);
     318
     319    if (!textColor.isValid())
     320        return emptyString();
     321
     322    return colorPropertyCSS(CSSPropertyColor, textColor, important);
     323}
     324   
     325String CaptionUserPreferencesMediaAF::windowRoundedCornerRadiusCSS() const
     326{
     327    MACaptionAppearanceBehavior behavior;
     328    CGFloat radius = MACaptionAppearanceGetWindowRoundedCornerRadius(kMACaptionAppearanceDomainUser, &behavior);
     329    if (!radius)
     330        return emptyString();
     331
     332    StringBuilder builder;
     333    builder.append(getPropertyNameString(CSSPropertyBorderRadius));
     334    builder.append(String::format(":%.02fpx", radius));
     335    if (behavior == kMACaptionAppearanceBehaviorUseValue)
     336        builder.append(" !important");
     337    builder.append(';');
     338
     339    return builder.toString();
     340}
     341   
     342Color CaptionUserPreferencesMediaAF::captionsEdgeColorForTextColor(const Color& textColor) const
     343{
     344    int distanceFromWhite = differenceSquared(textColor, Color::white);
     345    int distanceFromBlack = differenceSquared(textColor, Color::black);
     346   
     347    if (distanceFromWhite < distanceFromBlack)
     348        return textColor.dark();
     349   
     350    return textColor.light();
     351}
     352
     353String CaptionUserPreferencesMediaAF::cssPropertyWithTextEdgeColor(CSSPropertyID id, const String& value, const Color& textColor, bool important) const
     354{
     355    StringBuilder builder;
     356   
     357    builder.append(getPropertyNameString(id));
     358    builder.append(':');
     359    builder.append(value);
     360    builder.append(' ');
     361    builder.append(captionsEdgeColorForTextColor(textColor).serialized());
     362    if (important)
     363        builder.append(" !important");
     364    builder.append(';');
     365   
     366    return builder.toString();
     367}
     368
     369String CaptionUserPreferencesMediaAF::colorPropertyCSS(CSSPropertyID id, const Color& color, bool important) const
     370{
     371    StringBuilder builder;
     372   
     373    builder.append(getPropertyNameString(id));
     374    builder.append(':');
     375    builder.append(color.serialized());
     376    if (important)
     377        builder.append(" !important");
     378    builder.append(';');
     379   
     380    return builder.toString();
     381}
     382
     383String CaptionUserPreferencesMediaAF::captionsTextEdgeCSS() const
     384{
     385    DEFINE_STATIC_LOCAL(const String, edgeStyleRaised, (" -.05em -.05em 0 ", String::ConstructFromLiteral));
     386    DEFINE_STATIC_LOCAL(const String, edgeStyleDepressed, (" .05em .05em 0 ", String::ConstructFromLiteral));
     387    DEFINE_STATIC_LOCAL(const String, edgeStyleDropShadow, (" .075em .075em 0 ", String::ConstructFromLiteral));
     388    DEFINE_STATIC_LOCAL(const String, edgeStyleUniform, (" .03em ", String::ConstructFromLiteral));
     389
     390    bool unused;
     391    Color color = captionsTextColor(unused);
     392    if (!color.isValid())
     393        color.setNamedColor("black");
     394    color = captionsEdgeColorForTextColor(color);
     395
     396    MACaptionAppearanceBehavior behavior;
     397    MACaptionAppearanceTextEdgeStyle textEdgeStyle = MACaptionAppearanceGetTextEdgeStyle(kMACaptionAppearanceDomainUser, &behavior);
     398    switch (textEdgeStyle) {
     399    case kMACaptionAppearanceTextEdgeStyleUndefined:
     400    case kMACaptionAppearanceTextEdgeStyleNone:
     401        return emptyString();
     402           
     403    case kMACaptionAppearanceTextEdgeStyleRaised:
     404        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleRaised, color, behavior == kMACaptionAppearanceBehaviorUseValue);
     405    case kMACaptionAppearanceTextEdgeStyleDepressed:
     406        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDepressed, color, behavior == kMACaptionAppearanceBehaviorUseValue);
     407    case kMACaptionAppearanceTextEdgeStyleDropShadow:
     408        return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDropShadow, color, behavior == kMACaptionAppearanceBehaviorUseValue);
     409    case kMACaptionAppearanceTextEdgeStyleUniform:
     410        return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, edgeStyleUniform, color, behavior == kMACaptionAppearanceBehaviorUseValue);
     411           
     412    default:
     413        ASSERT_NOT_REACHED();
     414        break;
     415    }
     416   
     417    return emptyString();
     418}
     419
     420String CaptionUserPreferencesMediaAF::captionsDefaultFontCSS() const
     421{
     422    MACaptionAppearanceBehavior behavior;
     423   
     424    RetainPtr<CTFontDescriptorRef> font = adoptCF(MACaptionAppearanceCopyFontDescriptorForStyle(kMACaptionAppearanceDomainUser, &behavior, kMACaptionAppearanceFontStyleDefault));
     425    if (!font)
     426        return emptyString();
     427
     428    RetainPtr<CFTypeRef> name = adoptCF(CTFontDescriptorCopyAttribute(font.get(), kCTFontNameAttribute));
     429    if (!name)
     430        return emptyString();
     431   
     432    StringBuilder builder;
     433   
     434    builder.append(getPropertyNameString(CSSPropertyFontFamily));
     435    builder.append(": \"");
     436    builder.append(static_cast<CFStringRef>(name.get()));
     437    builder.append('"');
     438    if (behavior == kMACaptionAppearanceBehaviorUseValue)
     439        builder.append(" !important");
     440    builder.append(';');
     441   
     442    return builder.toString();
    210443}
    211444
     
    275508#endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
    276509
     510String CaptionUserPreferencesMediaAF::captionsStyleSheetOverride() const
     511{
     512    if (testingMode())
     513        return CaptionUserPreferences::captionsStyleSheetOverride();
     514   
     515    StringBuilder captionsOverrideStyleSheet;
     516
     517#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     518    if (!MediaAccessibilityLibrary())
     519        return CaptionUserPreferences::captionsStyleSheetOverride();
     520   
     521    String captionsColor = captionsTextColorCSS();
     522    String edgeStyle = captionsTextEdgeCSS();
     523    String fontName = captionsDefaultFontCSS();
     524    String background = captionsBackgroundCSS();
     525    if (!background.isEmpty() || !captionsColor.isEmpty() || !edgeStyle.isEmpty() || !fontName.isEmpty()) {
     526        captionsOverrideStyleSheet.append(" video::");
     527        captionsOverrideStyleSheet.append(TextTrackCue::cueShadowPseudoId());
     528        captionsOverrideStyleSheet.append('{');
     529       
     530        if (!background.isEmpty())
     531            captionsOverrideStyleSheet.append(background);
     532        if (!captionsColor.isEmpty())
     533            captionsOverrideStyleSheet.append(captionsColor);
     534        if (!edgeStyle.isEmpty())
     535            captionsOverrideStyleSheet.append(edgeStyle);
     536        if (!fontName.isEmpty())
     537            captionsOverrideStyleSheet.append(fontName);
     538       
     539        captionsOverrideStyleSheet.append('}');
     540    }
     541   
     542    String windowColor = captionsWindowCSS();
     543    String windowCornerRadius = windowRoundedCornerRadiusCSS();
     544    if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
     545        captionsOverrideStyleSheet.append(" video::");
     546        captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
     547        captionsOverrideStyleSheet.append('{');
     548       
     549        if (!windowColor.isEmpty())
     550            captionsOverrideStyleSheet.append(windowColor);
     551        if (!windowCornerRadius.isEmpty())
     552            captionsOverrideStyleSheet.append(windowCornerRadius);
     553       
     554        captionsOverrideStyleSheet.append('}');
     555    }
     556#endif // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     557
     558    LOG(Media, "CaptionUserPreferencesMediaAF::captionsStyleSheetOverrideSetting sytle to:\n%s", captionsOverrideStyleSheet.toString().utf8().data());
     559
     560    return captionsOverrideStyleSheet.toString();
     561}
    277562
    278563static String languageIdentifier(const String& languageCode)
     
    351636}
    352637
    353 String CaptionUserPreferencesMediaAF::platformCaptionsStyleSheet()
    354 {
    355     if (!m_captionStyleSheet)
    356         m_captionStyleSheet = defaultCaptionsStyleSheet();
    357 
    358     return m_captionStyleSheet;
    359 }
    360 
    361638String CaptionUserPreferencesMediaAF::displayNameForTrack(TextTrack* track) const
    362639{
     
    368645    CaptionDisplayMode displayMode = captionDisplayMode();
    369646    bool legacyOverride = mediaElement->webkitClosedCaptionsVisible();
    370     if (displayMode == AlwaysOn && (!userPrefersSubtitles(mediaElement->document()) && !userPrefersCaptions(mediaElement->document()) && !legacyOverride))
     647    if (displayMode == AlwaysOn && (!userPrefersSubtitles() && !userPrefersCaptions() && !legacyOverride))
    371648        return 0;
    372649    if (track->kind() != TextTrack::captionsKeyword() && track->kind() != TextTrack::subtitlesKeyword() && track->kind() != TextTrack::forcedKeyword())
     
    428705    int trackScore = 0;
    429706
    430     if (userPrefersCaptions(mediaElement->document())) {
     707    if (userPrefersCaptions()) {
    431708        // When the user prefers accessiblity tracks, rank is SDH, then CC, then subtitles.
    432709        if (track->kind() == track->subtitlesKeyword())
     
    490767    Vector<RefPtr<TextTrack>> tracksForMenu;
    491768    HashSet<String> languagesIncluded;
    492     bool prefersAccessibilityTracks = userPrefersCaptions(trackList->mediaElement()->document());
     769    bool prefersAccessibilityTracks = userPrefersCaptions();
    493770    bool filterTrackList = shouldFilterTrackMenu();
    494771
     
    572849    return tracksForMenu;
    573850}
    574 
     851   
    575852}
    576853
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.h

    r163048 r163073  
    3838class CaptionUserPreferencesMediaAF : public CaptionUserPreferences {
    3939public:
    40     CaptionUserPreferencesMediaAF();
     40    CaptionUserPreferencesMediaAF(PageGroup&);
    4141    virtual ~CaptionUserPreferencesMediaAF();
    4242
    4343#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
    44     void captionApperenceChanged();
    45 
    4644    virtual CaptionDisplayMode captionDisplayMode() const override;
    4745    virtual void setCaptionDisplayMode(CaptionDisplayMode) override;
    4846
    49     virtual bool userPrefersCaptions(Document&) const override;
    50     virtual bool userPrefersSubtitles(Document&) const override;
     47    virtual bool userPrefersCaptions() const override;
     48    virtual bool userPrefersSubtitles() const override;
    5149
    5250    virtual float captionFontSizeScaleAndImportance(bool&) const override;
    5351
     52    virtual void setInterestedInCaptionPreferenceChanges() override;
     53
    5454    virtual void setPreferredLanguage(const String&) override;
    5555    virtual Vector<String> preferredLanguages() const override;
     56
     57    virtual void captionPreferencesChanged() override;
    5658
    5759    bool shouldFilterTrackMenu() const { return true; }
     
    6062#endif
    6163
    62     virtual String platformCaptionsStyleSheet() override;
     64    virtual String captionsStyleSheetOverride() const override;
    6365    virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const override;
    6466    virtual Vector<RefPtr<TextTrack>> sortedTrackListForMenu(TextTrackList*) override;
     
    6668
    6769private:
    68     String m_captionStyleSheet;
     70#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     71    String captionsWindowCSS() const;
     72    String captionsBackgroundCSS() const;
     73    String captionsTextColorCSS() const;
     74    Color captionsTextColor(bool&) const;
     75    String captionsDefaultFontCSS() const;
     76    Color captionsEdgeColorForTextColor(const Color&) const;
     77    String windowRoundedCornerRadiusCSS() const;
     78    String captionsTextEdgeCSS() const;
     79    String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&, bool) const;
     80    String colorPropertyCSS(CSSPropertyID, const Color&, bool) const;
     81
     82    bool m_listeningForPreferenceChanges;
     83#endif
    6984};
    7085
  • trunk/Source/WebCore/page/Page.cpp

    r163048 r163073  
    9393#include <wtf/text/StringHash.h>
    9494
    95 #if ENABLE(VIDEO_TRACK)
    96 #if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
    97 #include "CaptionUserPreferencesMediaAF.h"
    98 #else
    99 #include "CaptionUserPreferences.h"
    100 #endif
    101 #endif
    102 
    10395namespace WebCore {
    10496
     
    15021494
    15031495#if ENABLE(VIDEO_TRACK)
    1504 CaptionUserPreferences& Page::captionPreferences()
    1505 {
    1506     // FIXME: This should not be a singleton.
    1507 #if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
    1508     static NeverDestroyed<CaptionUserPreferencesMediaAF> preferences;
    1509 #else
    1510     static NeverDestroyed<CaptionUserPreferences> preferences;
    1511 #endif
    1512 
    1513     return preferences;
    1514 }
    1515 
    1516 void Page::updateStyleForAllPagesForCaptionPreferencesChanged()
    1517 {
    1518     if (!allPages)
    1519         return;
    1520 
    1521     for (auto page : *allPages)
    1522         page->captionPreferencesChanged();
    1523 }
    1524 
    1525 
    15261496void Page::captionPreferencesChanged()
    15271497{
  • trunk/Source/WebCore/page/Page.h

    r163048 r163073  
    6262class BackForwardController;
    6363class BackForwardClient;
    64 class CaptionUserPreferences;
    6564class Chrome;
    6665class ChromeClient;
     
    404403
    405404#if ENABLE(VIDEO_TRACK)
    406     static void updateStyleForAllPagesForCaptionPreferencesChanged();
    407     CaptionUserPreferences& captionPreferences();
    408405    void captionPreferencesChanged();
    409406#endif
  • trunk/Source/WebCore/page/PageGroup.cpp

    r163048 r163073  
    4343#include <wtf/StdLibExtras.h>
    4444
     45#if ENABLE(VIDEO_TRACK)
     46#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     47#include "CaptionUserPreferencesMediaAF.h"
     48#else
     49#include "CaptionUserPreferences.h"
     50#endif
     51#endif
     52
    4553namespace WebCore {
    4654
     
    303311}
    304312
     313#if ENABLE(VIDEO_TRACK)
     314void PageGroup::captionPreferencesChanged()
     315{
     316    for (auto it = m_pages.begin(), end = m_pages.end(); it != end; ++it)
     317        (*it)->captionPreferencesChanged();
     318    pageCache()->markPagesForCaptionPreferencesChanged();
     319}
     320
     321CaptionUserPreferences* PageGroup::captionPreferences()
     322{
     323    if (!m_captionPreferences) {
     324#if (PLATFORM(MAC) && !PLATFORM(IOS)) || HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     325        m_captionPreferences = std::make_unique<CaptionUserPreferencesMediaAF>(*this);
     326#else
     327        m_captionPreferences = std::make_unique<CaptionUserPreferences>(*this);
     328#endif
     329    }
     330
     331    return m_captionPreferences.get();
     332}
     333#endif
     334
    305335} // namespace WebCore
  • trunk/Source/WebCore/page/PageGroup.h

    r163048 r163073  
    4545    class VisitedLinkProvider;
    4646    class UserContentController;
     47
     48#if ENABLE(VIDEO_TRACK)
     49    class CaptionPreferencesChangedListener;
     50    class CaptionUserPreferences;
     51#endif
    4752
    4853    class PageGroup : public Supplementable<PageGroup> {
     
    99104        GroupSettings& groupSettings() const { return *m_groupSettings; }
    100105
     106#if ENABLE(VIDEO_TRACK)
     107        void captionPreferencesChanged();
     108        CaptionUserPreferences* captionPreferences();
     109#endif
     110
    101111    private:
    102112        void addVisitedLink(LinkHash);
     
    117127
    118128        const std::unique_ptr<GroupSettings> m_groupSettings;
     129
     130#if ENABLE(VIDEO_TRACK)
     131        std::unique_ptr<CaptionUserPreferences> m_captionPreferences;
     132#endif
    119133    };
    120134
  • trunk/Source/WebCore/testing/InternalSettings.cpp

    r163048 r163073  
    414414
    415415#if ENABLE(VIDEO_TRACK)
     416    if (!page())
     417        return;
     418    CaptionUserPreferences* captionPreferences = page()->group().captionPreferences();
     419
    416420    if (equalIgnoringCase(kind, "Subtitles"))
    417         settings()->setShouldDisplaySubtitles(enabled);
     421        captionPreferences->setUserPrefersSubtitles(enabled);
    418422    else if (equalIgnoringCase(kind, "Captions"))
    419         settings()->setShouldDisplayCaptions(enabled);
     423        captionPreferences->setUserPrefersCaptions(enabled);
    420424    else if (equalIgnoringCase(kind, "TextDescriptions"))
    421         settings()->setShouldDisplayTextDescriptions(enabled);
     425        captionPreferences->setUserPrefersTextDescriptions(enabled);
    422426    else
    423427        ec = SYNTAX_ERR;
     
    433437
    434438#if ENABLE(VIDEO_TRACK)
     439    if (!page())
     440        return false;
     441    CaptionUserPreferences* captionPreferences = page()->group().captionPreferences();
     442
    435443    if (equalIgnoringCase(kind, "Subtitles"))
    436         return settings()->shouldDisplaySubtitles();
     444        return captionPreferences->userPrefersSubtitles();
    437445    if (equalIgnoringCase(kind, "Captions"))
    438         return settings()->shouldDisplayCaptions();
     446        return captionPreferences->userPrefersCaptions();
    439447    if (equalIgnoringCase(kind, "TextDescriptions"))
    440         return settings()->shouldDisplayTextDescriptions();
     448        return captionPreferences->userPrefersTextDescriptions();
    441449
    442450    ec = SYNTAX_ERR;
  • trunk/Source/WebCore/testing/Internals.cpp

    r163048 r163073  
    282282#endif
    283283#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
    284     page->captionPreferences().setCaptionsStyleSheetOverride(emptyString());
    285     page->captionPreferences().setTestingMode(false);
     284    page->group().captionPreferences()->setCaptionsStyleSheetOverride(emptyString());
     285    page->group().captionPreferences()->setTestingMode(false);
    286286#endif
    287287    if (!page->mainFrame().editor().isContinuousSpellCheckingEnabled())
     
    303303#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
    304304    if (document && document->page())
    305         document->page()->captionPreferences().setTestingMode(true);
     305        document->page()->group().captionPreferences()->setTestingMode(true);
    306306#endif
    307307
     
    20522052
    20532053#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
    2054     return document->page()->captionPreferences().captionsStyleSheetOverride();
     2054    return document->page()->group().captionPreferences()->captionsStyleSheetOverride();
    20552055#else
    20562056    return emptyString();
     
    20672067
    20682068#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
    2069     document->page()->captionPreferences().setCaptionsStyleSheetOverride(override);
     2069    document->page()->group().captionPreferences()->setCaptionsStyleSheetOverride(override);
    20702070#else
    20712071    UNUSED_PARAM(override);
     
    20822082
    20832083#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
    2084     document->page()->captionPreferences().setPrimaryAudioTrackLanguageOverride(language);
     2084    document->page()->group().captionPreferences()->setPrimaryAudioTrackLanguageOverride(language);
    20852085#else
    20862086    UNUSED_PARAM(language);
     
    20972097   
    20982098#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
    2099     CaptionUserPreferences& captionPreferences = document->page()->captionPreferences();
     2099    CaptionUserPreferences* captionPreferences = document->page()->group().captionPreferences();
    21002100   
    2101     if (equalIgnoringCase(mode, "Automatic")) {
    2102         captionPreferences.setCaptionDisplayMode(CaptionUserPreferences::Automatic);
    2103         document->page()->settings().setShouldDisplayCaptions(false);
    2104         document->page()->settings().setShouldDisplaySubtitles(false);
    2105     } else if (equalIgnoringCase(mode, "ForcedOnly")) {
    2106         captionPreferences.setCaptionDisplayMode(CaptionUserPreferences::ForcedOnly);
    2107         document->page()->settings().setShouldDisplayCaptions(false);
    2108         document->page()->settings().setShouldDisplaySubtitles(false);
    2109     } else if (equalIgnoringCase(mode, "AlwaysOn"))
    2110         captionPreferences.setCaptionDisplayMode(CaptionUserPreferences::AlwaysOn);
     2101    if (equalIgnoringCase(mode, "Automatic"))
     2102        captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::Automatic);
     2103    else if (equalIgnoringCase(mode, "ForcedOnly"))
     2104        captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::ForcedOnly);
     2105    else if (equalIgnoringCase(mode, "AlwaysOn"))
     2106        captionPreferences->setCaptionDisplayMode(CaptionUserPreferences::AlwaysOn);
    21112107    else
    21122108        ec = SYNTAX_ERR;
Note: See TracChangeset for help on using the changeset viewer.