Changeset 130556 in webkit
- Timestamp:
- Oct 5, 2012 2:57:04 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r130555 r130556 1 2012-10-04 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports to override text track rendering style 4 https://bugs.webkit.org/show_bug.cgi?id=97800 5 <rdar://problem/12044964> 6 7 Reviewed by Silvia Pfeiffer. 8 9 * media/track/track-cue-rendering-expected.txt: Update results for caption css changes. 10 * media/track/track-cue-rendering.html: 11 * platform/chromium/TestExpectations: Skip tests that need to be rebaselined. 12 1 13 2012-10-05 Takashi Sakamoto <tasak@google.com> 2 14 -
trunk/LayoutTests/media/track/track-cue-rendering-expected.txt
r122694 r130556 50 50 51 51 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontFamily == 'sans-serif') OK 52 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).color == 'rgb a(255, 255, 255, 0)') OK52 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).color == 'rgb(255, 255, 255)') OK 53 53 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor == 'rgba(0, 0, 0, 0.796875)'), OBSERVED 'rgba(0, 0, 0, 0.8)' FAIL 54 54 END OF TEST -
trunk/LayoutTests/media/track/track-cue-rendering.html
r114760 r130556 33 33 34 34 testExpected("getComputedStyle(textTrackDisplayElement(video)).fontFamily", "sans-serif"); 35 testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgb a(255, 255, 255, 0)");35 testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgb(255, 255, 255)"); 36 36 testExpected("getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor", "rgba(0, 0, 0, 0.796875)"); 37 37 -
trunk/LayoutTests/platform/chromium/TestExpectations
r130542 r130556 3790 3790 webkit.org/b/98545 [ Mac ] fast/text/international/text-spliced-font.html [ Failure ] 3791 3791 webkit.org/b/98545 [ Mac ] fast/writing-mode/Kusa-Makura-background-canvas.html [ Failure ] 3792 3793 # Need to be updated after webkit.org/b/97800 3794 webkit.org/b/89167 media/track/track-cue-rendering-horizontal.html [ Failure ] 3795 webkit.org/b/89167 media/track/track-cue-rendering-vertical.html [ Failure ] 3796 webkit.org/b/89167 media/track/track-cue-rendering.html [ Failure ] 3797 -
trunk/Source/WebCore/ChangeLog
r130555 r130556 1 2012-10-04 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports to override text track rendering style 4 https://bugs.webkit.org/show_bug.cgi?id=97800 5 <rdar://problem/12044964> 6 7 Reviewed by Silvia Pfeiffer. 8 9 * WebCore.exp.in: Export new WebkitSystemInterface functions. 10 * WebCore.xcodeproj/project.pbxproj: Add CaptionPreferencesChangedListener.h. 11 12 * css/mediaControls.css: Rearrange the caption CSS so it is possible to style the cue window, 13 background, and text independently. 14 15 * html/HTMLMediaElement.cpp: 16 (WebCore::HTMLMediaElement::HTMLMediaElement): Initialize m_disableCaptions with theme->userPrefersCaptions(). 17 (WebCore::HTMLMediaElement::attach): Register for caption preferences change callbacks. 18 (WebCore::HTMLMediaElement::detach): Unregister for caption preferences change callbacks. 19 (WebCore::HTMLMediaElement::userPrefersCaptions): Return theme->userPrefersCaptions(). 20 (WebCore::HTMLMediaElement::userIsInterestedInThisTrackKind): Consider userPrefersCaptions(). 21 (WebCore::HTMLMediaElement::setClosedCaptionsVisible): Move the code that marks all tracks as 22 un-configured to markCaptionAndSubtitleTracksAsUnconfigured so it can be reused. 23 (WebCore::HTMLMediaElement::captionPreferencesChanged): New, force a reevaluation of all text tracks. 24 (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): New, code moved from 25 setClosedCaptionsVisible 26 * html/HTMLMediaElement.h: Inherit from CaptionPreferencesChangedListener. 27 28 * html/shadow/MediaControlElements.cpp: 29 (WebCore::MediaControlTextTrackContainerElement::userCaptionPreferencesChanged): New, if theme 30 has a captions style sheet override, inject it into the current page group, otherwise 31 remove injected sheet. 32 (WebCore::MediaControlTextTrackContainerElement::updateSizes): Get rid of unnecessary member 33 variable. Get caption font scale from theme instead of hard coding. 34 * html/shadow/MediaControlElements.h: 35 36 * html/shadow/MediaControlRootElement.cpp: 37 (WebCore::MediaControlRootElement::userCaptionPreferencesChanged): New. 38 (WebCore::MediaControlRootElement::updateTextTrackDisplay): 39 * html/shadow/MediaControlRootElement.h: Add userCaptionPreferencesChanged, minor cleanup. 40 41 * html/shadow/MediaControls.h: 42 (WebCore::MediaControls::userCaptionPreferencesChanged): New. 43 44 * html/track/TextTrackCue.cpp: 45 (WebCore::TextTrackCueBox::TextTrackCueBox): Set the shadow pseudo id. 46 (WebCore::TextTrackCueBox::textTrackCueBoxShadowPseudoId): New, class method to return the 47 shadow pseudo id so it can be used elsewhere. 48 (WebCore::TextTrackCueBox::shadowPseudoId): Call textTrackCueBoxShadowPseudoId. 49 (WebCore::TextTrackCue::pastNodesShadowPseudoId): New, class method to return the 50 shadow pseudo id so it can be used elsewhere. 51 (WebCore::TextTrackCue::futureNodesShadowPseudoId): Ditto. 52 (WebCore::TextTrackCue::updateDisplayTree): 53 * html/track/TextTrackCue.h: 54 55 * platform/mac/WebCoreSystemInterface.h: Updated. 56 * platform/mac/WebCoreSystemInterface.mm: Ditto. 57 58 * rendering/CaptionPreferencesChangedListener.h: Added. 59 60 * rendering/RenderTheme.h: 61 (WebCore::RenderTheme::userPrefersCaptions): New, default do-nothing implementation. 62 (WebCore::RenderTheme::userHasCaptionPreferences): Ditto. 63 (WebCore::RenderTheme::captionFontSizeScale): Ditto. 64 (WebCore::RenderTheme::captionsStyleSheetOverride): Ditto. 65 (WebCore::RenderTheme::registerForCaptionPreferencesChangedCallbacks): Ditto. 66 (WebCore::RenderTheme::unregisterForCaptionPreferencesChangedCallbacks): Ditto. 67 68 * rendering/RenderThemeMac.h: 69 * rendering/RenderThemeMac.mm: 70 (WebCore::userCaptionPreferencesChangedNotificationCallback): New, receives preference changed notifications. 71 (WebCore::RenderThemeMac::RenderThemeMac): Initialize m_listeningForCaptionPreferenceNotifications. 72 (WebCore::RenderThemeMac::~RenderThemeMac): Unregister for notifications if necessary. 73 (WebCore::RenderThemeMac::userHasCaptionPreferences): New, passthrough to WKSI function. 74 (WebCore::RenderThemeMac::userPrefersCaptions): Ditto. 75 (WebCore::RenderThemeMac::captionsWindowColor): Return Color with user's caption window color preference. 76 (WebCore::RenderThemeMac::captionsBackgroundColor): Return Color with user's caption 77 background color preference. 78 (WebCore::RenderThemeMac::captionsTextColor): Return Color with user's caption text color preference. 79 (WebCore::RenderThemeMac::captionsEdgeColorForTextColor): Return Color for text edge effect. 80 (WebCore::RenderThemeMac::cssPropertyWithTextEdgeColor): Return String with CSS to set a text-shadow 81 or webkit-text-stroke property. 82 (WebCore::RenderThemeMac::cssColorProperty): Return a String with css to set a property 83 with a color value. 84 (WebCore::RenderThemeMac::captionsTextEdgeStyle): Return a String with css to style caption 85 text with the user's preferred text edge stye. 86 (WebCore::RenderThemeMac::captionsDefaultFont): Return a String with css to style caption 87 text with the user's preferred font. 88 (WebCore::RenderThemeMac::captionsStyleSheetOverride): Return a String with css to style captions 89 with the user's preferred style. 90 (WebCore::RenderThemeMac::captionFontSizeScale): Return the user's preferred caption font scale. 91 (WebCore::RenderThemeMac::captionPreferencesChanged): Notify listeners of caption preference change. 92 (WebCore::RenderThemeMac::registerForCaptionPreferencesChangedCallbacks): Add a caption preferences 93 changes listener. 94 (WebCore::RenderThemeMac::unregisterForCaptionPreferencesChangedCallbacks): Remove a caption preferences 95 changes listener. 96 1 97 2012-10-05 Takashi Sakamoto <tasak@google.com> 2 98 -
trunk/Source/WebCore/WebCore.exp.in
r130400 r130556 2583 2583 __ZN7WebCore32collectDictationTextAlternativesEP18NSAttributedStringRN3WTF6VectorINS_24TextAlternativeWithRangeELm0EEE 2584 2584 #endif 2585 2586 #if ENABLE(VIDEO_TRACK) 2587 _wkCaptionAppearanceHasUserPreferences 2588 _wkCaptionAppearanceShowCaptionsWhenAvailable 2589 _wkCaptionAppearanceCopyForegroundColor 2590 _wkCaptionAppearanceCopyBackgroundColor 2591 _wkCaptionAppearanceCopyWindowColor 2592 _wkCaptionAppearanceGetForegroundOpacity 2593 _wkCaptionAppearanceGetBackgroundOpacity 2594 _wkCaptionAppearanceGetWindowOpacity 2595 _wkCaptionAppearanceCopyFontForStyle 2596 _wkCaptionAppearanceGetRelativeCharacterSize 2597 _wkCaptionAppearanceGetTextEdgeStyle 2598 _wkCaptionAppearanceGetSettingsChangedNotification 2599 #endif -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r130471 r130556 5857 5857 CD127DED14F3097D00E84779 /* WebCoreFullScreenWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD127DEB14F3097900E84779 /* WebCoreFullScreenWindow.mm */; }; 5858 5858 CD127DEE14F3098400E84779 /* WebCoreFullScreenWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5859 CD2565BA161E46A90055634D /* CaptionPreferencesChangedListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EC38B816154C1A00E8146D /* CaptionPreferencesChangedListener.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5859 5860 CD27F6E51457685A0078207D /* JSMediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E2145767580078207D /* JSMediaController.cpp */; }; 5860 5861 CD27F6E7145770D30078207D /* MediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E6145770D30078207D /* MediaController.cpp */; }; … … 7148 7149 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCueCustom.cpp; sourceTree = "<group>"; }; 7149 7150 07E38A0B148FCF0C006E1ECC /* JSTextTrackCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCustom.h; sourceTree = "<group>"; }; 7151 07EC38B816154C1A00E8146D /* CaptionPreferencesChangedListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CaptionPreferencesChangedListener.h; sourceTree = "<group>"; }; 7150 7152 0806E57912893045007CED32 /* SVGMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMatrix.h; sourceTree = "<group>"; }; 7151 7153 080E49211255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextLayoutEngineBaseline.cpp; sourceTree = "<group>"; }; … … 21306 21308 BCEA4815097D93020094C9E4 /* break_lines.cpp */, 21307 21309 BCEA4816097D93020094C9E4 /* break_lines.h */, 21310 07EC38B816154C1A00E8146D /* CaptionPreferencesChangedListener.h */, 21308 21311 BCDD454D1236C95C009A7985 /* ColumnInfo.h */, 21309 21312 9392F14F0AD1862300691BD4 /* CounterNode.cpp */, … … 25538 25541 931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */, 25539 25542 931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */, 25543 CD2565BA161E46A90055634D /* CaptionPreferencesChangedListener.h in Headers */, 25540 25544 ); 25541 25545 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/css/mediaControls.css
r126372 r130556 217 217 font-family: sans-serif; 218 218 text-align: center; 219 color: rgba(255, 255, 255, 0);219 color: rgba(255, 255, 255, 1); 220 220 221 221 letter-spacing: normal; … … 235 235 background-color: rgba(0, 0, 0, 0.8); 236 236 padding: 2px 2px; 237 238 white-space: pre-wrap;239 237 } 240 238 … … 247 245 margin-left: -2px; 248 246 padding: 2px 2px 2px 0px; 249 250 white-space: pre-wrap;251 247 } 252 248 253 249 video::-webkit-media-text-track-display { 254 250 position: absolute; 255 color: rgba(255, 255, 255, 1); 256 } 251 overflow: hidden; 252 white-space: pre-wrap; 253 } -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r130084 r130556 70 70 #include "NodeRenderingContext.h" 71 71 #include "Page.h" 72 #include "RenderTheme.h" 72 73 #include "RenderVideo.h" 73 74 #include "RenderView.h" … … 282 283 setHasCustomCallbacks(); 283 284 addElementToDocumentMap(this, document); 285 286 #if ENABLE(VIDEO_TRACK) 287 if (document->page()) { 288 RenderTheme* theme = document->page()->theme(); 289 if (theme->userHasCaptionPreferences()) 290 m_disableCaptions = !theme->userPrefersCaptions(); 291 } 292 #endif 284 293 } 285 294 … … 542 551 } 543 552 #endif 553 554 #if ENABLE(VIDEO_TRACK) 555 if (document()->page()) 556 document()->page()->theme()->registerForCaptionPreferencesChangedCallbacks(this); 557 #endif 558 } 559 560 void HTMLMediaElement::detach() 561 { 562 #if ENABLE(VIDEO_TRACK) 563 if (document()->page()) 564 document()->page()->theme()->unregisterForCaptionPreferencesChangedCallbacks(this); 565 #endif 566 HTMLElement::detach(); 544 567 } 545 568 … … 2784 2807 } 2785 2808 2786 bool HTMLMediaElement::userIsInterestedInThisLanguage(const String&) const 2787 { 2788 // FIXME: check the user's language preference - bugs.webkit.org/show_bug.cgi?id=74121 2789 return true; 2809 bool HTMLMediaElement::userPrefersCaptions() const 2810 { 2811 Page* page = document()->page(); 2812 if (!page) 2813 return false; 2814 2815 RenderTheme* theme = page->theme(); 2816 return theme->userHasCaptionPreferences() && theme->userPrefersCaptions(); 2790 2817 } 2791 2818 2792 2819 bool HTMLMediaElement::userIsInterestedInThisTrackKind(String kind) const 2793 2820 { 2794 // If ... the user has indicated an interest in having a track with this text track kind, text track language, ...2795 2821 if (m_disableCaptions) 2796 2822 return false; 2797 2823 2798 2824 Settings* settings = document()->settings(); 2799 if (!settings) 2800 return false; 2825 bool userPrefersCaptionsOrSubtitles = m_closedCaptionsVisible || userPrefersCaptions(); 2801 2826 2802 2827 if (kind == TextTrack::subtitlesKeyword()) 2803 return settings->shouldDisplaySubtitles() || m_closedCaptionsVisible;2828 return (settings && settings->shouldDisplaySubtitles()) || userPrefersCaptionsOrSubtitles; 2804 2829 if (kind == TextTrack::captionsKeyword()) 2805 return settings->shouldDisplayCaptions() || m_closedCaptionsVisible;2830 return (settings && settings->shouldDisplayCaptions()) || userPrefersCaptionsOrSubtitles; 2806 2831 if (kind == TextTrack::descriptionsKeyword()) 2807 return settings ->shouldDisplayTextDescriptions() || m_closedCaptionsVisible;2832 return settings && settings->shouldDisplayTextDescriptions(); 2808 2833 2809 2834 return false; … … 3970 3995 if (RuntimeEnabledFeatures::webkitVideoTrackEnabled()) { 3971 3996 m_disableCaptions = !m_closedCaptionsVisible; 3972 3973 // Mark all track elements as not "configured" so that configureTextTracks() 3974 // will reconsider which tracks to display in light of new user preferences 3975 // (e.g. default tracks should not be displayed if the user has turned off 3976 // captions and non-default tracks should be displayed based on language 3977 // preferences if the user has turned captions on). 3978 for (Node* node = firstChild(); node; node = node->nextSibling()) { 3979 if (!node->hasTagName(trackTag)) 3980 continue; 3981 HTMLTrackElement* trackElement = static_cast<HTMLTrackElement*>(node); 3982 if (trackElement->kind() == TextTrack::captionsKeyword() 3983 || trackElement->kind() == TextTrack::subtitlesKeyword()) 3984 trackElement->setHasBeenConfigured(false); 3985 } 3986 3997 3998 markCaptionAndSubtitleTracksAsUnconfigured(); 3987 3999 configureTextTracks(); 4000 4001 if (!m_disableCaptions && (hasMediaControls() || createMediaControls())) 4002 mediaControls()->userCaptionPreferencesChanged(); 3988 4003 } 3989 4004 #else … … 4173 4188 } 4174 4189 } 4190 4191 void HTMLMediaElement::captionPreferencesChanged() 4192 { 4193 if (!isVideo()) 4194 return; 4195 4196 markCaptionAndSubtitleTracksAsUnconfigured(); 4197 configureTextTracks(); 4198 4199 if (!hasMediaControls() && !createMediaControls()) 4200 return; 4201 mediaControls()->userCaptionPreferencesChanged(); 4202 } 4203 4204 void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() 4205 { 4206 // Mark all track elements as not "configured" so that configureTextTracks() 4207 // will reconsider which tracks to display in light of new user preferences 4208 // (e.g. default tracks should not be displayed if the user has turned off 4209 // captions and non-default tracks should be displayed based on language 4210 // preferences if the user has turned captions on). 4211 for (RefPtr<Node> node = firstChild(); node; node = node->nextSibling()) { 4212 if (!node->hasTagName(trackTag)) 4213 continue; 4214 4215 HTMLTrackElement* trackElement = static_cast<HTMLTrackElement*>(node.get()); 4216 RefPtr<TextTrack> textTrack = trackElement->track(); 4217 if (!textTrack) 4218 continue; 4219 4220 String kind = textTrack->kind(); 4221 4222 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captionsKeyword()) 4223 trackElement->setHasBeenConfigured(false); 4224 } 4225 } 4226 4175 4227 #endif 4176 4228 -
trunk/Source/WebCore/html/HTMLMediaElement.h
r128323 r130556 31 31 #include "HTMLElement.h" 32 32 #include "ActiveDOMObject.h" 33 #include "CaptionPreferencesChangedListener.h" 33 34 #include "GenericEventQueue.h" 34 35 #include "MediaCanStartListener.h" … … 79 80 class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, public MediaPlayerSupportsTypeClient, private MediaCanStartListener, public ActiveDOMObject, public MediaControllerInterface 80 81 #if ENABLE(VIDEO_TRACK) 81 , private TextTrackClient 82 , private TextTrackClient, private CaptionPreferencesChangedListener 82 83 #endif 83 84 { … … 241 242 void configureTextTrackGroup(const TrackGroup&) const; 242 243 244 bool userPrefersCaptions() const; 243 245 bool userIsInterestedInThisTrackKind(String) const; 244 246 bool textTracksAreReady() const; … … 326 328 virtual void finishParsingChildren(); 327 329 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 328 virtual void attach(); 330 virtual void attach() OVERRIDE; 331 virtual void detach() OVERRIDE; 329 332 330 333 virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE; … … 475 478 #if ENABLE(VIDEO_TRACK) 476 479 void updateActiveTextTrackCues(float); 477 bool userIsInterestedInThisLanguage(const String&) const;478 480 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; 479 481 … … 481 483 void beginIgnoringTrackDisplayUpdateRequests() { ++m_ignoreTrackDisplayUpdate; } 482 484 void endIgnoringTrackDisplayUpdateRequests() { ASSERT(m_ignoreTrackDisplayUpdate); --m_ignoreTrackDisplayUpdate; } 485 486 void markCaptionAndSubtitleTracksAsUnconfigured(); 487 virtual void captionPreferencesChanged() OVERRIDE; 483 488 #endif 484 489 -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r126372 r130556 46 46 #include "LayoutRepainter.h" 47 47 #include "LocalizedStrings.h" 48 #include "MediaControlRootElement.h" 48 49 #include "MediaControls.h" 49 50 #include "MouseEvent.h" 50 51 #include "Page.h" 52 #include "PageGroup.h" 51 53 #include "RenderDeprecatedFlexibleBox.h" 52 54 #include "RenderInline.h" … … 1311 1313 } 1312 1314 1315 void MediaControlTextTrackContainerElement::userCaptionPreferencesChanged() 1316 { 1317 DEFINE_STATIC_LOCAL(KURL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23")); 1318 1319 Page* page = document()->page(); 1320 if (!page) 1321 return; 1322 1323 RenderTheme* theme = page->theme(); 1324 HTMLMediaElement* mediaElement = toParentMediaElement(this); 1325 1326 mediaElement->setNeedsStyleRecalc(); 1327 1328 page->group().removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL); 1329 1330 if (!mediaElement->closedCaptionsVisible() && !theme->userHasCaptionPreferences()) 1331 return; 1332 1333 String captionsOverrideStyleSheet = theme->captionsStyleSheetOverride(); 1334 if (captionsOverrideStyleSheet.isEmpty()) 1335 return; 1336 1337 page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, adoptPtr(new Vector<String>), adoptPtr(new Vector<String>), 1338 InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments); 1339 } 1340 1313 1341 void MediaControlTextTrackContainerElement::updateDisplay() 1314 1342 { … … 1377 1405 } 1378 1406 1379 static const float mimimumFontSize = 16;1380 static const float videoHeightFontSizePercentage = .05;1381 static const float trackBottomMultiplier = .9;1382 1383 1407 void MediaControlTextTrackContainerElement::updateSizes() 1384 1408 { … … 1387 1411 return; 1388 1412 1413 if (!document()->page()) 1414 return; 1415 1389 1416 IntRect videoBox = toRenderVideo(mediaElement->renderer())->videoBox(); 1390 if (m_videoDisplaySize == videoBox) 1391 return; 1392 m_videoDisplaySize = videoBox; 1393 1394 float fontSize = m_videoDisplaySize.size().height() * videoHeightFontSizePercentage; 1417 1418 float fontSize = videoBox.size().height() * (document()->page()->theme()->captionFontSizeScale()); 1395 1419 if (fontSize != m_fontSize) { 1396 1420 m_fontSize = fontSize; -
trunk/Source/WebCore/html/shadow/MediaControlElements.h
r124022 r130556 538 538 static PassRefPtr<MediaControlTextTrackContainerElement> create(Document*); 539 539 540 void userCaptionPreferencesChanged(); 540 541 void updateDisplay(); 541 542 void updateSizes(); … … 548 549 virtual const AtomicString& shadowPseudoId() const; 549 550 550 IntRect m_videoDisplaySize; 551 void updateCaptionAppearance(); 552 551 553 float m_fontSize; 552 554 }; -
trunk/Source/WebCore/html/shadow/MediaControlRootElement.cpp
r125590 r130556 631 631 } 632 632 633 void MediaControlRootElement::userCaptionPreferencesChanged() 634 { 635 if (m_textDisplayContainer) 636 m_textDisplayContainer->userCaptionPreferencesChanged(); 637 } 638 633 639 void MediaControlRootElement::showTextTrackDisplay() 634 640 { … … 651 657 652 658 m_textDisplayContainer->updateDisplay(); 653 654 659 } 655 660 #endif -
trunk/Source/WebCore/html/shadow/MediaControlRootElement.h
r126477 r130556 106 106 #if ENABLE(VIDEO_TRACK) 107 107 void createTextTrackDisplay(); 108 void showTextTrackDisplay(); 109 void hideTextTrackDisplay(); 110 void updateTextTrackDisplay(); 108 virtual void userCaptionPreferencesChanged() OVERRIDE; 109 virtual void showTextTrackDisplay() OVERRIDE; 110 virtual void hideTextTrackDisplay() OVERRIDE; 111 virtual void updateTextTrackDisplay() OVERRIDE; 111 112 #endif 112 113 -
trunk/Source/WebCore/html/shadow/MediaControls.h
r104658 r130556 74 74 75 75 #if ENABLE(VIDEO_TRACK) 76 virtual void userCaptionPreferencesChanged() { }; 76 77 virtual void showTextTrackDisplay() = 0; 77 78 virtual void hideTextTrackDisplay() = 0; -
trunk/Source/WebCore/html/track/TextTrack.cpp
r126786 r130556 95 95 } 96 96 97 TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, const String& kind, const String& label, constString& language, TextTrackType type)97 TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType type) 98 98 : TrackBase(context, TrackBase::TextTrack) 99 99 , m_cues(0) … … 118 118 } 119 119 120 bool TextTrack::isValidKindKeyword(const String& value)120 bool TextTrack::isValidKindKeyword(const AtomicString& value) 121 121 { 122 122 if (equalIgnoringCase(value, subtitlesKeyword())) … … 134 134 } 135 135 136 void TextTrack::setKind(const String& kind)136 void TextTrack::setKind(const AtomicString& kind) 137 137 { 138 138 String oldKind = m_kind; … … 147 147 } 148 148 149 void TextTrack::setMode(const String& mode)149 void TextTrack::setMode(const AtomicString& mode) 150 150 { 151 151 // On setting, if the new value isn't equal to what the attribute would currently … … 175 175 } 176 176 177 String TextTrack::mode() const177 AtomicString TextTrack::mode() const 178 178 { 179 179 // The text track "showing" and "showing by default" modes return the string "showing". -
trunk/Source/WebCore/html/track/TextTrack.h
r126786 r130556 55 55 class TextTrack : public TrackBase { 56 56 public: 57 static PassRefPtr<TextTrack> create(ScriptExecutionContext* context, TextTrackClient* client, const String& kind, const String& label, constString& language)57 static PassRefPtr<TextTrack> create(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& label, const AtomicString& language) 58 58 { 59 59 return adoptRef(new TextTrack(context, client, kind, label, language, AddTrack)); … … 64 64 HTMLMediaElement* mediaElement() { return m_mediaElement; } 65 65 66 String kind() const { return m_kind; }67 void setKind(const String&);66 AtomicString kind() const { return m_kind; } 67 void setKind(const AtomicString&); 68 68 69 69 static const AtomicString& subtitlesKeyword(); … … 72 72 static const AtomicString& chaptersKeyword(); 73 73 static const AtomicString& metadataKeyword(); 74 static bool isValidKindKeyword(const String&);74 static bool isValidKindKeyword(const AtomicString&); 75 75 76 String label() const { return m_label; }77 void setLabel(const String& label) { m_label = label; }76 AtomicString label() const { return m_label; } 77 void setLabel(const AtomicString& label) { m_label = label; } 78 78 79 String language() const { return m_language; }80 void setLanguage(const String& language) { m_language = language; }79 AtomicString language() const { return m_language; } 80 void setLanguage(const AtomicString& language) { m_language = language; } 81 81 82 82 static const AtomicString& disabledKeyword(); … … 84 84 static const AtomicString& showingKeyword(); 85 85 86 String mode() const;87 void setMode(const String&);86 AtomicString mode() const; 87 void setMode(const AtomicString&); 88 88 89 89 bool showingByDefault() const { return m_showingByDefault; } … … 117 117 118 118 protected: 119 TextTrack(ScriptExecutionContext*, TextTrackClient*, const String& kind, const String& label, constString& language, TextTrackType);119 TextTrack(ScriptExecutionContext*, TextTrackClient*, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType); 120 120 121 121 RefPtr<TextTrackCueList> m_cues; … … 124 124 TextTrackCueList* ensureTextTrackCueList(); 125 125 HTMLMediaElement* m_mediaElement; 126 String m_kind;127 String m_label;128 String m_language;129 String m_mode;126 AtomicString m_kind; 127 AtomicString m_label; 128 AtomicString m_language; 129 AtomicString m_mode; 130 130 TextTrackClient* m_client; 131 131 TextTrackType m_trackType; -
trunk/Source/WebCore/html/track/TextTrackCue.cpp
r129400 r130556 96 96 , m_cue(cue) 97 97 { 98 setShadowPseudoId(shadowPseudoId()); 98 99 } 99 100 … … 168 169 } 169 170 170 const AtomicString& TextTrackCueBox:: shadowPseudoId() const171 const AtomicString& TextTrackCueBox::textTrackCueBoxShadowPseudoId() 171 172 { 172 173 DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display")); … … 174 175 } 175 176 177 const AtomicString& TextTrackCueBox::shadowPseudoId() const 178 { 179 return textTrackCueBoxShadowPseudoId(); 180 } 181 176 182 RenderObject* TextTrackCueBox::createRenderer(RenderArena* arena, RenderStyle*) 177 183 { … … 180 186 181 187 // ---------------------------- 188 189 const AtomicString& TextTrackCue::pastNodesShadowPseudoId() 190 { 191 DEFINE_STATIC_LOCAL(const AtomicString, subtitles, ("-webkit-media-text-track-past-nodes", AtomicString::ConstructFromLiteral)); 192 return subtitles; 193 } 194 195 const AtomicString& TextTrackCue::futureNodesShadowPseudoId() 196 { 197 DEFINE_STATIC_LOCAL(const AtomicString, subtitles, ("-webkit-media-text-track-future-nodes", AtomicString::ConstructFromLiteral)); 198 return subtitles; 199 } 182 200 183 201 TextTrackCue::TextTrackCue(ScriptExecutionContext* context, double start, double end, const String& content) … … 653 671 DEFINE_STATIC_LOCAL(const String, timestampTag, (ASCIILiteral("timestamp"))); 654 672 655 DEFINE_STATIC_LOCAL(const AtomicString, trackPastNodesShadowPseudoId, ("-webkit-media-text-track-past-nodes"));656 DEFINE_STATIC_LOCAL(const AtomicString, trackFutureNodesShadowPseudoId, ("-webkit-media-text-track-future-nodes"));657 658 673 if (!track()->isRendered()) 659 674 return; … … 663 678 // Clear the contents of the two sets. 664 679 m_futureDocumentNodes->removeChildren(); 665 m_futureDocumentNodes->setShadowPseudoId( trackFutureNodesShadowPseudoId);680 m_futureDocumentNodes->setShadowPseudoId(futureNodesShadowPseudoId()); 666 681 667 682 m_pastDocumentNodes->removeChildren(); 668 m_pastDocumentNodes->setShadowPseudoId( trackPastNodesShadowPseudoId);683 m_pastDocumentNodes->setShadowPseudoId(pastNodesShadowPseudoId()); 669 684 670 685 // Update the two sets containing past and future WebVTT objects. -
trunk/Source/WebCore/html/track/TextTrackCue.h
r126372 r130556 61 61 62 62 virtual const AtomicString& shadowPseudoId() const OVERRIDE; 63 static const AtomicString& textTrackCueBoxShadowPseudoId(); 63 64 64 65 private: … … 80 81 81 82 virtual ~TextTrackCue(); 83 84 static const AtomicString& pastNodesShadowPseudoId(); 85 static const AtomicString& futureNodesShadowPseudoId(); 82 86 83 87 TextTrack* track() const; -
trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h
r129566 r130556 331 331 #endif 332 332 333 typedef enum { 334 wkCaptionFontStyleDefault = 0, 335 wkCaptionFontStyleMonospacedWithSerif, 336 wkCaptionFontStyleProportionalWithSerif, 337 wkCaptionFontStyleMonospacedWithoutSerif, 338 wkCaptionFontStyleProportionalWithoutSerif, 339 wkCaptionFontStyleCasual, 340 wkCaptionFontStyleCursive, 341 wkCaptionFontStyleSmallCapital, 342 wkCaptionFontStyleMax 343 } wkCaptionFontStyle; 344 345 typedef enum { 346 wkCaptionTextEdgeStyleUndefined = 0, 347 wkCaptionTextEdgeStyleNone, 348 wkCaptionTextEdgeStyleRaised, 349 wkCaptionTextEdgeStyleDepressed, 350 wkCaptionTextEdgeStyleUniform, 351 wkCaptionTextEdgeStyleDropShadow, 352 wkCaptionTextEdgeStyleMax 353 } wkCaptionTextEdgeStyle; 354 355 extern bool (*wkCaptionAppearanceHasUserPreferences)(void); 356 extern bool (*wkCaptionAppearanceShowCaptionsWhenAvailable)(void); 357 extern CGColorRef(*wkCaptionAppearanceCopyForegroundColor)(void); 358 extern CGColorRef(*wkCaptionAppearanceCopyBackgroundColor)(void); 359 extern CGColorRef(*wkCaptionAppearanceCopyWindowColor)(void); 360 extern bool(*wkCaptionAppearanceGetForegroundOpacity)(CGFloat*); 361 extern bool(*wkCaptionAppearanceGetBackgroundOpacity)(CGFloat*); 362 extern bool(*wkCaptionAppearanceGetWindowOpacity)(CGFloat*); 363 extern CGFontRef(*wkCaptionAppearanceCopyFontForStyle)(int); 364 extern bool(*wkCaptionAppearanceGetRelativeCharacterSize)(CGFloat*); 365 extern int(*wkCaptionAppearanceGetTextEdgeStyle)(void); 366 extern CFStringRef(*wkCaptionAppearanceGetSettingsChangedNotification)(void); 333 367 } 334 368 -
trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm
r129566 r130556 210 210 #endif 211 211 212 bool (*wkCaptionAppearanceHasUserPreferences)(void); 213 bool (*wkCaptionAppearanceShowCaptionsWhenAvailable)(void); 214 CGColorRef(*wkCaptionAppearanceCopyForegroundColor)(void); 215 CGColorRef(*wkCaptionAppearanceCopyBackgroundColor)(void); 216 CGColorRef(*wkCaptionAppearanceCopyWindowColor)(void); 217 bool(*wkCaptionAppearanceGetForegroundOpacity)(CGFloat*); 218 bool(*wkCaptionAppearanceGetBackgroundOpacity)(CGFloat*); 219 bool(*wkCaptionAppearanceGetWindowOpacity)(CGFloat*); 220 CGFontRef(*wkCaptionAppearanceCopyFontForStyle)(int); 221 bool(*wkCaptionAppearanceGetRelativeCharacterSize)(CGFloat*); 222 int(*wkCaptionAppearanceGetTextEdgeStyle)(void); 223 CFStringRef(*wkCaptionAppearanceGetSettingsChangedNotification)(void); -
trunk/Source/WebCore/rendering/RenderTheme.h
r130369 r130556 46 46 #if ENABLE(PROGRESS_ELEMENT) 47 47 class RenderProgress; 48 #endif 49 #if ENABLE(VIDEO_TRACK) 50 class CaptionPreferencesChangedListener; 48 51 #endif 49 52 class CSSStyleSheet; … … 229 232 virtual int sliderTickOffsetFromTrackCenter() const = 0; 230 233 void paintSliderTicks(RenderObject*, const PaintInfo&, const IntRect&); 234 #endif 235 236 #if ENABLE(VIDEO_TRACK) 237 virtual bool userPrefersCaptions() const { return false; } 238 virtual bool userHasCaptionPreferences() const { return false; } 239 virtual float captionFontSizeScale() const { return 0.05; } 240 virtual String captionsStyleSheetOverride() const { return emptyString(); } 241 virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) { } 242 virtual void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) { } 231 243 #endif 232 244 -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r123300 r130556 102 102 // A view associated to the contained document. Subclasses may not have such a view and return a fake. 103 103 virtual NSView* documentViewFor(RenderObject*) const; 104 105 #if ENABLE(VIDEO_TRACK) 106 void captionPreferencesChanged(); 107 #endif 108 104 109 protected: 105 110 RenderThemeMac(); … … 179 184 virtual IntPoint volumeSliderOffsetFromMuteButton(RenderBox*, const IntSize&) const OVERRIDE; 180 185 #endif 186 187 #if ENABLE(VIDEO_TRACK) 188 virtual bool userPrefersCaptions() const OVERRIDE; 189 virtual bool userHasCaptionPreferences() const OVERRIDE; 190 virtual float captionFontSizeScale() const OVERRIDE; 191 virtual String captionsStyleSheetOverride() const OVERRIDE; 192 virtual void registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE; 193 virtual void unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener*) OVERRIDE; 194 #endif 181 195 182 196 virtual bool shouldShowPlaceholderWhenFocused() const; … … 238 252 #endif 239 253 254 #if ENABLE(VIDEO_TRACK) 255 Color captionsWindowColor() const; 256 Color captionsBackgroundColor() const; 257 Color captionsTextColor() const; 258 String captionsDefaultFont() const; 259 Color captionsEdgeColorForTextColor(const Color&) const; 260 String captionsTextEdgeStyle() const; 261 String cssPropertyWithTextEdgeColor(CSSPropertyID, const String&, const Color&) const; 262 String cssColorProperty(CSSPropertyID, const Color&) const; 263 #endif 264 240 265 private: 241 266 mutable RetainPtr<NSPopUpButtonCell> m_popupButton; … … 253 278 254 279 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; 280 281 #if ENABLE(VIDEO_TRACK) 282 HashSet<CaptionPreferencesChangedListener*> m_captionPreferenceChangeListeners; 283 bool m_listeningForCaptionPreferenceNotifications; 284 #endif 255 285 }; 256 286 -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r126926 r130556 28 28 #import "Element.h" 29 29 #import "FileList.h" 30 #import "FloatConversion.h" 30 31 #import "FrameView.h" 31 32 #import "GraphicsContextCG.h" … … 152 153 #endif 153 154 155 static void userCaptionPreferencesChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void *, CFDictionaryRef) 156 { 157 static_cast<RenderThemeMac*>(observer)->captionPreferencesChanged(); 158 } 159 154 160 PassRefPtr<RenderTheme> RenderThemeMac::create() 155 161 { … … 161 167 , m_isSliderThumbVerticalPressed(false) 162 168 , m_notificationObserver(AdoptNS, [[WebCoreRenderThemeNotificationObserver alloc] initWithTheme:this]) 169 #if ENABLE(VIDEO_TRACK) 170 , m_listeningForCaptionPreferenceNotifications(false) 171 #endif 163 172 { 164 173 [[NSNotificationCenter defaultCenter] addObserver:m_notificationObserver.get() … … 171 180 { 172 181 [[NSNotificationCenter defaultCenter] removeObserver:m_notificationObserver.get()]; 182 183 #if ENABLE(VIDEO_TRACK) 184 if (m_listeningForCaptionPreferenceNotifications) 185 CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, wkCaptionAppearanceGetSettingsChangedNotification(), NULL); 186 #endif 173 187 } 174 188 … … 2129 2143 } 2130 2144 2145 #if ENABLE(VIDEO_TRACK) 2146 bool RenderThemeMac::userHasCaptionPreferences() const 2147 { 2148 return wkCaptionAppearanceHasUserPreferences(); 2149 } 2150 2151 bool RenderThemeMac::userPrefersCaptions() const 2152 { 2153 return wkCaptionAppearanceShowCaptionsWhenAvailable(); 2154 } 2155 2156 Color RenderThemeMac::captionsWindowColor() const 2157 { 2158 RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyWindowColor()); 2159 Color windowColor(color.get()); 2160 if (!windowColor.isValid()) 2161 windowColor = Color::transparent; 2162 2163 CGFloat opacity; 2164 if (wkCaptionAppearanceGetWindowOpacity(&opacity)) 2165 return Color(windowColor.red(), windowColor.green(), windowColor.blue(), opacity * 255); 2166 2167 if (!color) 2168 return Color(); 2169 2170 return windowColor; 2171 } 2172 2173 Color RenderThemeMac::captionsBackgroundColor() const 2174 { 2175 // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-past-nodes 2176 // and webkit-media-text-track-future-nodes. 2177 DEFINE_STATIC_LOCAL(Color, defaultBackgroundColor, (Color(0, 0, 0, 0.8 * 255))); 2178 2179 RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyBackgroundColor()); 2180 Color backgroundColor(color.get()); 2181 if (!backgroundColor.isValid()) { 2182 backgroundColor = defaultBackgroundColor; 2183 } 2184 2185 CGFloat opacity; 2186 if (wkCaptionAppearanceGetBackgroundOpacity(&opacity)) 2187 return Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), opacity * 255); 2188 2189 if (!color) 2190 return Color(); 2191 2192 return backgroundColor; 2193 } 2194 2195 Color RenderThemeMac::captionsTextColor() const 2196 { 2197 RetainPtr<CGColorRef> color(AdoptCF, wkCaptionAppearanceCopyForegroundColor()); 2198 Color textColor(color.get()); 2199 if (!textColor.isValid()) { 2200 // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-container. 2201 textColor = Color::white; 2202 } 2203 2204 CGFloat opacity; 2205 if (wkCaptionAppearanceGetForegroundOpacity(&opacity)) 2206 return Color(textColor.red(), textColor.green(), textColor.blue(), opacity * 255); 2207 2208 if (!color) 2209 return Color(); 2210 2211 return textColor; 2212 } 2213 2214 Color RenderThemeMac::captionsEdgeColorForTextColor(const Color& textColor) const 2215 { 2216 int distanceFromWhite = differenceSquared(textColor, Color::white); 2217 int distanceFromBlack = differenceSquared(textColor, Color::black); 2218 2219 if (distanceFromWhite < distanceFromBlack) 2220 return textColor.dark(); 2221 2222 return textColor.light(); 2223 } 2224 2225 String RenderThemeMac::cssPropertyWithTextEdgeColor(CSSPropertyID id, const String& value, const Color& textColor) const 2226 { 2227 StringBuilder builder; 2228 2229 builder.append(getPropertyNameString(id)); 2230 builder.append(':'); 2231 builder.append(value); 2232 builder.append(' '); 2233 builder.append(captionsEdgeColorForTextColor(textColor).serialized()); 2234 builder.append(';'); 2235 2236 return builder.toString(); 2237 } 2238 2239 String RenderThemeMac::cssColorProperty(CSSPropertyID id, const Color& color) const 2240 { 2241 StringBuilder builder; 2242 2243 builder.append(getPropertyNameString(id)); 2244 builder.append(':'); 2245 builder.append(color.serialized()); 2246 builder.append(';'); 2247 2248 return builder.toString(); 2249 } 2250 2251 String RenderThemeMac::captionsTextEdgeStyle() const 2252 { 2253 DEFINE_STATIC_LOCAL(const String, edgeStyleRaised, (" -.05em -.05em 0 ", String::ConstructFromLiteral)); 2254 DEFINE_STATIC_LOCAL(const String, edgeStyleDepressed, (" .05em .05em 0 ", String::ConstructFromLiteral)); 2255 DEFINE_STATIC_LOCAL(const String, edgeStyleDropShadow, (" .075em .075em 0 ", String::ConstructFromLiteral)); 2256 DEFINE_STATIC_LOCAL(const String, edgeStyleUniform, (" .03em ", String::ConstructFromLiteral)); 2257 2258 Color color = captionsTextColor(); 2259 if (!color.isValid()) 2260 color.setNamedColor("black"); 2261 color = captionsEdgeColorForTextColor(color); 2262 2263 wkCaptionTextEdgeStyle textEdgeStyle = static_cast<wkCaptionTextEdgeStyle>(wkCaptionAppearanceGetTextEdgeStyle()); 2264 switch (textEdgeStyle) { 2265 case wkCaptionTextEdgeStyleUndefined: 2266 case wkCaptionTextEdgeStyleNone: 2267 return emptyString(); 2268 2269 case wkCaptionTextEdgeStyleRaised: 2270 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleRaised, color); 2271 case wkCaptionTextEdgeStyleDepressed: 2272 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDepressed, color); 2273 case wkCaptionTextEdgeStyleDropShadow: 2274 return cssPropertyWithTextEdgeColor(CSSPropertyTextShadow, edgeStyleDropShadow, color); 2275 case wkCaptionTextEdgeStyleUniform: 2276 return cssPropertyWithTextEdgeColor(CSSPropertyWebkitTextStroke, edgeStyleUniform, color); 2277 2278 case wkCaptionTextEdgeStyleMax: 2279 ASSERT_NOT_REACHED(); 2280 default: 2281 ASSERT_NOT_REACHED(); 2282 break; 2283 } 2284 2285 return emptyString(); 2286 } 2287 2288 String RenderThemeMac::captionsDefaultFont() const 2289 { 2290 RetainPtr<CGFontRef> font(AdoptCF, wkCaptionAppearanceCopyFontForStyle(wkCaptionFontStyleDefault)); 2291 if (!font) 2292 return emptyString(); 2293 2294 RetainPtr<CFStringRef> name(AdoptCF, CGFontCopyPostScriptName(font.get())); 2295 if (!name) 2296 return emptyString(); 2297 2298 StringBuilder builder; 2299 2300 builder.append(getPropertyNameString(CSSPropertyFontFamily)); 2301 builder.append(": \""); 2302 builder.append(name.get()); 2303 builder.append("\";"); 2304 2305 return builder.toString(); 2306 } 2307 2308 String RenderThemeMac::captionsStyleSheetOverride() const 2309 { 2310 StringBuilder captionsOverrideStyleSheet; 2311 2312 Color color = captionsBackgroundColor(); 2313 if (color.isValid()) { 2314 captionsOverrideStyleSheet.append(" video::"); 2315 captionsOverrideStyleSheet.append(TextTrackCue::pastNodesShadowPseudoId()); 2316 captionsOverrideStyleSheet.append('{'); 2317 captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyBackgroundColor, color)); 2318 captionsOverrideStyleSheet.append('}'); 2319 2320 captionsOverrideStyleSheet.append(" video::"); 2321 captionsOverrideStyleSheet.append(TextTrackCue::futureNodesShadowPseudoId()); 2322 captionsOverrideStyleSheet.append('{'); 2323 captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyBackgroundColor, color)); 2324 captionsOverrideStyleSheet.append('}'); 2325 } 2326 2327 color = captionsWindowColor(); 2328 if (color.isValid()) { 2329 captionsOverrideStyleSheet.append(" video::"); 2330 captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId()); 2331 captionsOverrideStyleSheet.append('{'); 2332 captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyBackgroundColor, color)); 2333 captionsOverrideStyleSheet.append('}'); 2334 } 2335 2336 color = captionsTextColor(); 2337 String edgeStyle = captionsTextEdgeStyle(); 2338 String fontName = captionsDefaultFont(); 2339 if (color.isValid() || !edgeStyle.isEmpty() || !fontName.isEmpty()) { 2340 captionsOverrideStyleSheet.append(" video::"); 2341 captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId()); 2342 captionsOverrideStyleSheet.append('{'); 2343 2344 if (color.isValid()) 2345 captionsOverrideStyleSheet.append(cssColorProperty(CSSPropertyColor, color)); 2346 if (!edgeStyle.isEmpty()) 2347 captionsOverrideStyleSheet.append(edgeStyle); 2348 if (!fontName.isEmpty()) 2349 captionsOverrideStyleSheet.append(fontName); 2350 2351 captionsOverrideStyleSheet.append('}'); 2352 } 2353 2354 return captionsOverrideStyleSheet.toString(); 2355 } 2356 2357 float RenderThemeMac::captionFontSizeScale() const 2358 { 2359 CGFloat characterScale = RenderTheme::captionFontSizeScale(); 2360 CGFloat scaleAdjustment; 2361 2362 if (!wkCaptionAppearanceGetRelativeCharacterSize(&scaleAdjustment)) 2363 return characterScale; 2364 2365 return narrowPrecisionToFloat(scaleAdjustment * characterScale); 2366 } 2367 2368 void RenderThemeMac::captionPreferencesChanged() 2369 { 2370 for (HashSet<CaptionPreferencesChangedListener*>::iterator i = m_captionPreferenceChangeListeners.begin(); i != m_captionPreferenceChangeListeners.end(); ++i) 2371 (*i)->captionPreferencesChanged(); 2372 } 2373 2374 void RenderThemeMac::registerForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener) 2375 { 2376 if (!wkCaptionAppearanceGetSettingsChangedNotification()) 2377 return; 2378 2379 if (!m_listeningForCaptionPreferenceNotifications) { 2380 m_listeningForCaptionPreferenceNotifications = true; 2381 CFNotificationCenterAddObserver (CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, wkCaptionAppearanceGetSettingsChangedNotification(), NULL, CFNotificationSuspensionBehaviorCoalesce); 2382 } 2383 2384 m_captionPreferenceChangeListeners.add(listener); 2385 } 2386 2387 void RenderThemeMac::unregisterForCaptionPreferencesChangedCallbacks(CaptionPreferencesChangedListener* listener) 2388 { 2389 if (wkCaptionAppearanceGetSettingsChangedNotification()) 2390 m_captionPreferenceChangeListeners.remove(listener); 2391 } 2392 #endif // ENABLE(VIDEO_TRACK) 2393 2131 2394 #endif // ENABLE(VIDEO) 2132 2395 -
trunk/Source/WebKit/mac/ChangeLog
r130523 r130556 1 2012-10-04 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports to override text track rendering style 4 https://bugs.webkit.org/show_bug.cgi?id=97800 5 <rdar://problem/12044964> 6 7 Reviewed by Silvia Pfeiffer. 8 9 Add WCSI support for new WKSI caption functions. 10 11 * WebCoreSupport/WebSystemInterface.mm: 12 (InitWebCoreSystemInterface): Initialize new WKSI function pointers. 13 1 14 2012-10-04 Jon Lee <jonlee@apple.com> 2 15 -
trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
r129566 r130556 206 206 #endif 207 207 208 INIT(CaptionAppearanceHasUserPreferences); 209 INIT(CaptionAppearanceShowCaptionsWhenAvailable); 210 INIT(CaptionAppearanceCopyForegroundColor); 211 INIT(CaptionAppearanceCopyBackgroundColor); 212 INIT(CaptionAppearanceCopyWindowColor); 213 INIT(CaptionAppearanceGetForegroundOpacity); 214 INIT(CaptionAppearanceGetBackgroundOpacity); 215 INIT(CaptionAppearanceGetWindowOpacity); 216 INIT(CaptionAppearanceCopyFontForStyle); 217 INIT(CaptionAppearanceGetRelativeCharacterSize); 218 INIT(CaptionAppearanceGetTextEdgeStyle); 219 INIT(CaptionAppearanceGetSettingsChangedNotification); 220 208 221 #endif 209 222 didInit = true; -
trunk/Source/WebKit2/ChangeLog
r130525 r130556 1 2012-10-04 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports to override text track rendering style 4 https://bugs.webkit.org/show_bug.cgi?id=97800 5 <rdar://problem/12044964> 6 7 Reviewed by Silvia Pfeiffer. 8 9 * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: 10 (InitWebCoreSystemInterface): Initialize new WKSI function pointers. 11 1 12 2012-10-05 José Dapena Paz <jdapena@igalia.com> 2 13 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
r129566 r130556 187 187 #endif 188 188 189 INIT(CaptionAppearanceHasUserPreferences); 190 INIT(CaptionAppearanceShowCaptionsWhenAvailable); 191 INIT(CaptionAppearanceCopyForegroundColor); 192 INIT(CaptionAppearanceCopyBackgroundColor); 193 INIT(CaptionAppearanceCopyWindowColor); 194 INIT(CaptionAppearanceGetForegroundOpacity); 195 INIT(CaptionAppearanceGetBackgroundOpacity); 196 INIT(CaptionAppearanceGetWindowOpacity); 197 INIT(CaptionAppearanceCopyFontForStyle); 198 INIT(CaptionAppearanceGetRelativeCharacterSize); 199 INIT(CaptionAppearanceGetTextEdgeStyle); 200 INIT(CaptionAppearanceGetSettingsChangedNotification); 189 201 }); 190 202 } -
trunk/WebKitLibraries/ChangeLog
r129917 r130556 1 2012-10-04 Eric Carlson <eric.carlson@apple.com> 2 3 Allow ports to override text track rendering style 4 https://bugs.webkit.org/show_bug.cgi?id=97800 5 <rdar://problem/12044964> 6 7 Reviewed by Silvia Pfeiffer. 8 9 Update WKSI header with SPI for getting the user caption appearance preferences. 10 11 * WebKitSystemInterface.h: 12 1 13 2012-09-28 Eric Carlson <eric.carlson@apple.com> 2 14 -
trunk/WebKitLibraries/WebKitSystemInterface.h
r129565 r130556 1 1 /* 2 2 WebKitSystemInterface.h 3 Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.3 Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 4 5 5 Public header file. … … 510 510 #endif 511 511 512 typedef enum { 513 WKCaptionFontStyleDefault = 0, 514 WKCaptionFontStyleMonospacedWithSerif, 515 WKCaptionFontStyleProportionalWithSerif, 516 WKCaptionFontStyleMonospacedWithoutSerif, 517 WKCaptionFontStyleProportionalWithoutSerif, 518 WKCaptionFontStyleCasual, 519 WKCaptionFontStyleCursive, 520 WKCaptionFontStyleSmallCapital, 521 WKCaptionFontStyleMax 522 } WKCaptionFontStyle; 523 524 typedef enum { 525 WKCaptionTextEdgeStyleUndefined = 0, 526 WKCaptionTextEdgeStyleNone, 527 WKCaptionTextEdgeStyleRaised, 528 WKCaptionTextEdgeStyleDepressed, 529 WKCaptionTextEdgeStyleUniform, 530 WKCaptionTextEdgeStyleDropShadow, 531 WKCaptionTextEdgeStyleMax 532 } WKCaptionTextEdgeStyle; 533 534 bool WKCaptionAppearanceHasUserPreferences(void); 535 bool WKCaptionAppearanceShowCaptionsWhenAvailable(void); 536 CGColorRef WKCaptionAppearanceCopyForegroundColor(void); 537 CGColorRef WKCaptionAppearanceCopyBackgroundColor(void); 538 CGColorRef WKCaptionAppearanceCopyWindowColor(void); 539 bool WKCaptionAppearanceGetForegroundOpacity(CGFloat*); 540 bool WKCaptionAppearanceGetBackgroundOpacity(CGFloat*); 541 bool WKCaptionAppearanceGetWindowOpacity(CGFloat*); 542 CGFontRef WKCaptionAppearanceCopyFontForStyle(int fontStyle); 543 bool WKCaptionAppearanceGetRelativeCharacterSize(CGFloat*); 544 int WKCaptionAppearanceGetTextEdgeStyle(void); 545 CFStringRef WKCaptionAppearanceGetSettingsChangedNotification(void); 546 512 547 #ifdef __cplusplus 513 548 }
Note: See TracChangeset
for help on using the changeset viewer.