Changeset 148050 in webkit


Ignore:
Timestamp:
Apr 9, 2013 1:56:27 PM (11 years ago)
Author:
eric.carlson@apple.com
Message:

[Mac] user caption styles not applied to correct element
https://bugs.webkit.org/show_bug.cgi?id=114230

Reviewed by Jer Noble.

Source/WebCore:

Test: media/track/track-css-user-override.html

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::updateActiveTextTrackCues): Drive by clean-up so we don't log excessively.

  • html/shadow/MediaControlElements.cpp:

(WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): Initialize

new member variables.

(WebCore::MediaControlTextTrackContainerElement::updateDisplay): Set cue font size when it is

inserted into the tree.

(WebCore::MediaControlTextTrackContainerElement::updateTimerFired): Update the font size of

all active cues.

(WebCore::MediaControlTextTrackContainerElement::updateSizes): Set size-relative CSS properties

after a time because this can be called during layout.

  • html/shadow/MediaControlElements.h:
  • html/shadow/MediaControls.cpp:

(WebCore::MediaControls::textTrackPreferencesChanged): Call closedCaptionTracksChanged before updateSizes.

  • html/track/TextTrackCue.cpp:

(WebCore::TextTrackCue::setFontSize): New, set the cue's font size.

  • html/track/TextTrackCue.h:
  • html/track/TextTrackCueGeneric.cpp:

(WebCore::TextTrackCueGenericBoxElement::applyCSSProperties): Set cue properties on the cue element

instead of on the cue box to match what we do for the "cue" pseudo element.

(WebCore::TextTrackCueGeneric::setFontSize): New, set the cue's font size.

  • html/track/TextTrackCueGeneric.h:
  • html/track/TextTrackList.cpp:

(TextTrackList::remove): Drive-by cleanup, don't ASSERT when the media element is NULL.

  • page/CaptionUserPreferences.cpp:

(WebCore::CaptionUserPreferences::setCaptionsStyleSheetOverride): New, allow user CSS overrides

to be tested in DRT.

(WebCore::CaptionUserPreferences::updateCaptionStyleSheetOveride): New, generate a user style

sheet override. Moved here from CaptionUserPreferencesMac.

  • page/CaptionUserPreferences.h:
  • page/CaptionUserPreferencesMac.h:
  • page/CaptionUserPreferencesMac.mm:

(WebCore::CaptionUserPreferencesMac::captionsBackgroundCSS): Don't ignore background color importance.
(WebCore::CaptionUserPreferencesMac::captionsStyleSheetOverride): Implement even when we don't

have the media accessibility framework so this can be tested in DRT. Apply all cue properties
to the element used for the "cue" pseudo element.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::didLoadingProgress): Drive-by cleanup, remove logging

because this method is called so frequently and the logging is not especially useful.

(WebCore::MediaPlayerPrivateAVFoundation::updateStates): Only log when the ready/network

state changes because this method is called so frequently.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::platformLayer): Drive-by cleanup, remove logging

because this method is called so frequently and the logging is not especially useful.

(WebCore::MediaPlayerPrivateAVFoundationObjC::setCurrentTrack): Make the logging more useful.

  • testing/Internals.cpp:

(WebCore::Internals::resetToConsistentState): Reset captions style sheet override.
(WebCore::Internals::captionsStyleSheetOverride): New, return the captions style sheet override.
(WebCore::Internals::setCaptionsStyleSheetOverride): New, override the captions style sheet override.

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

  • media/track/track-css-user-override-expected.txt: Added.
  • media/track/track-css-user-override.html: Added.
  • media/track/track-cue-container-rendering-position-expected.txt:
  • media/track/track-cue-container-rendering-position.html:
  • media/track/track-cue-rendering-expected.txt:
  • media/track/track-cue-rendering.html: Font size is not applied instantly when a video element is

resized, so check after a very short delay.

Location:
trunk
Files:
2 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r148049 r148050  
     12013-04-09  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [Mac] user caption styles not applied to correct element
     4        https://bugs.webkit.org/show_bug.cgi?id=114230
     5
     6        Reviewed by Jer Noble.
     7
     8        * media/track/track-css-user-override-expected.txt: Added.
     9        * media/track/track-css-user-override.html: Added.
     10        * media/track/track-cue-container-rendering-position-expected.txt:
     11        * media/track/track-cue-container-rendering-position.html:
     12        * media/track/track-cue-rendering-expected.txt:
     13        * media/track/track-cue-rendering.html: Font size is not applied instantly when a video element is
     14            resized, so check after a very short delay.
     15
    1162013-04-09  Simon Fraser  <simon.fraser@apple.com>
    217
  • trunk/LayoutTests/media/track/track-cue-container-rendering-position-expected.txt

    r134783 r148050  
    1 The top of the text track container should be in the bottom 25% of the video element.
     1The top of the text track container should be in the bottom 30% of the video element.
    22EVENT(canplaythrough)
    33
    4 EXPECTED (cueDisplayElement.offsetTop > (video.videoHeight * .75) == 'true') OK
     4EXPECTED (cueDisplayElement.offsetTop > (video.videoHeight * .70) == 'true') OK
    55END OF TEST
    66
  • trunk/LayoutTests/media/track/track-cue-container-rendering-position.html

    r147675 r148050  
    2121            consoleWrite("");
    2222            cueDisplayElement = textTrackDisplayElement(video, 'display', 0);
    23             testExpected("cueDisplayElement.offsetTop > (video.videoHeight * .75)", true);
     23            document.body.offsetTop;
     24            testExpected("cueDisplayElement.offsetTop > (video.videoHeight * .70)", true);
    2425            endTest();
    2526        }
     
    2728        function loaded()
    2829        {
    29             consoleWrite("The top of the text track container should be in the bottom 25% of the video element.");
     30            consoleWrite("The top of the text track container should be in the bottom 30% of the video element.");
    3031
    3132            findMediaElement();
  • trunk/LayoutTests/media/track/track-cue-rendering-expected.txt

    r132349 r148050  
    3535RUN(video.width = 320)
    3636RUN(video.height = 240)
    37 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '12px') OK
     37EXPECTED (getComputedStyle(currentCue).fontSize == '12px') OK
    3838
    3939RUN(video.width = 640)
    4040RUN(video.height = 480)
    41 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '24px') OK
     41EXPECTED (getComputedStyle(currentCue).fontSize == '24px') OK
     42
     43RUN(video.width = 960)
     44RUN(video.height = 720)
     45EXPECTED (getComputedStyle(currentCue).fontSize == '36px') OK
    4246
    4347RUN(video.width = 1280)
    4448RUN(video.height = 960)
    45 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '48px') OK
     49EXPECTED (getComputedStyle(currentCue).fontSize == '48px') OK
    4650
    47 RUN(video.width = 2560)
    48 RUN(video.height = 1440)
    49 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '72px') OK
     51EXPECTED (getComputedStyle(currentCue).fontFamily == 'sans-serif') OK
     52EXPECTED (getComputedStyle(currentCue).color == 'rgb(255, 255, 255)') OK
     53EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor == 'rgba(0, 0, 0, 0.8)') OK
    5054
    51 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontFamily == 'sans-serif') OK
    52 EXPECTED (getComputedStyle(textTrackDisplayElement(video)).color == 'rgb(255, 255, 255)') OK
    53 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor == 'rgba(0, 0, 0, 0.796875)'), OBSERVED 'rgba(0, 0, 0, 0.8)' FAIL
    5455END OF TEST
    5556
  • trunk/LayoutTests/media/track/track-cue-rendering.html

    r132349 r148050  
    1313        var testCueDisplayBox;
    1414        var seekedCount = 0;
     15        var resizeCount = 1;
    1516        var info = [ "Lorem", "ipsum", "dolor", "sit" ];
    1617
    17         function testFontSize(width, height)
     18        function setVideoSize(width, height)
    1819        {
    1920            run("video.width = " + width);
    2021            run("video.height = " + height);
     22        }
     23
     24        function resizeTest()
     25        {
    2126            document.body.offsetTop;
    22             testExpected("getComputedStyle(textTrackDisplayElement(video)).fontSize", parseInt(height * 0.05) + "px");
     27            currentCue = textTrackDisplayElement(video, 'cue');
     28            testExpected("getComputedStyle(currentCue).fontSize", parseInt(240 * resizeCount * 0.05) + "px");
    2329            consoleWrite("");
     30
     31            if (++resizeCount < 5) {
     32                setVideoSize(320 * resizeCount, 240 * resizeCount);
     33                setTimeout(resizeTest, 10);
     34                return
     35            }
     36
     37            testExpected("getComputedStyle(currentCue).fontFamily", "sans-serif");
     38            testExpected("getComputedStyle(currentCue).color", "rgb(255, 255, 255)");
     39            testExpected("getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor", "rgba(0, 0, 0, 0.8)");
     40
     41            consoleWrite("");
     42            endTest();
     43
     44            // Resize the video so it is easier to interact with it manually, if necessary.
     45            video.width = 320;
     46            video.height = 240;
    2447        }
    2548
     
    2750        {
    2851            consoleWrite("<br>Test the cue display colors and font.");
    29             testFontSize(320, 240);
    30             testFontSize(640, 480);
    31             testFontSize(1280, 960);
    32             testFontSize(2560, 1440);
    33 
    34             testExpected("getComputedStyle(textTrackDisplayElement(video)).fontFamily", "sans-serif");
    35             testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgb(255, 255, 255)");
    36             testExpected("getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor", "rgba(0, 0, 0, 0.796875)");
    37 
    38             endTest();
    39 
    40             // Resize the video so it is easier to interact with it manually, if necessary.
    41             video.width = 320;
    42             video.height = 240;
     52            setVideoSize(320, 240);
     53            setTimeout(resizeTest, 10);
    4354        }
    4455
  • trunk/Source/WebCore/ChangeLog

    r148049 r148050  
     12013-04-09  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [Mac] user caption styles not applied to correct element
     4        https://bugs.webkit.org/show_bug.cgi?id=114230
     5
     6        Reviewed by Jer Noble.
     7
     8        Test: media/track/track-css-user-override.html
     9
     10        * html/HTMLMediaElement.cpp:
     11        (WebCore::HTMLMediaElement::updateActiveTextTrackCues): Drive by clean-up so we don't log excessively.
     12
     13        * html/shadow/MediaControlElements.cpp:
     14        (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement): Initialize
     15            new member variables.
     16        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Set cue font size when it is
     17            inserted into the tree.
     18        (WebCore::MediaControlTextTrackContainerElement::updateTimerFired): Update the font size of
     19            all active cues.
     20        (WebCore::MediaControlTextTrackContainerElement::updateSizes): Set size-relative CSS properties
     21            after a time because this can be called during layout.
     22        * html/shadow/MediaControlElements.h:
     23
     24        * html/shadow/MediaControls.cpp:
     25        (WebCore::MediaControls::textTrackPreferencesChanged): Call closedCaptionTracksChanged before updateSizes.
     26
     27        * html/track/TextTrackCue.cpp:
     28        (WebCore::TextTrackCue::setFontSize): New, set the cue's font size.
     29        * html/track/TextTrackCue.h:
     30
     31        * html/track/TextTrackCueGeneric.cpp:
     32        (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties): Set cue properties on the cue element
     33            instead of on the cue box to match what we do for the "cue" pseudo element.
     34        (WebCore::TextTrackCueGeneric::setFontSize): New, set the cue's font size.
     35        * html/track/TextTrackCueGeneric.h:
     36
     37        * html/track/TextTrackList.cpp:
     38        (TextTrackList::remove): Drive-by cleanup, don't ASSERT when the media element is NULL.
     39
     40        * page/CaptionUserPreferences.cpp:
     41        (WebCore::CaptionUserPreferences::setCaptionsStyleSheetOverride): New, allow user CSS overrides
     42            to be tested in DRT.
     43        (WebCore::CaptionUserPreferences::updateCaptionStyleSheetOveride): New, generate a user style
     44            sheet override. Moved here from CaptionUserPreferencesMac.
     45        * page/CaptionUserPreferences.h:
     46
     47        * page/CaptionUserPreferencesMac.h:
     48        * page/CaptionUserPreferencesMac.mm:
     49        (WebCore::CaptionUserPreferencesMac::captionsBackgroundCSS): Don't ignore background color importance.
     50        (WebCore::CaptionUserPreferencesMac::captionsStyleSheetOverride): Implement even when we don't
     51            have the media accessibility framework so this can be tested in DRT. Apply all cue properties
     52            to the element used for the "cue" pseudo element.
     53
     54        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     55        (WebCore::MediaPlayerPrivateAVFoundation::didLoadingProgress): Drive-by cleanup, remove logging
     56            because this method is called so frequently and the logging is not especially useful.
     57        (WebCore::MediaPlayerPrivateAVFoundation::updateStates): Only log when the ready/network
     58            state changes because this method is called so frequently.
     59
     60        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     61        (WebCore::MediaPlayerPrivateAVFoundationObjC::platformLayer): Drive-by cleanup, remove logging
     62            because this method is called so frequently and the logging is not especially useful.
     63        (WebCore::MediaPlayerPrivateAVFoundationObjC::setCurrentTrack): Make the logging more useful.
     64
     65        * testing/Internals.cpp:
     66        (WebCore::Internals::resetToConsistentState): Reset captions style sheet override.
     67        (WebCore::Internals::captionsStyleSheetOverride): New, return the captions style sheet override.
     68        (WebCore::Internals::setCaptionsStyleSheetOverride): New, override the captions style sheet override.
     69        * testing/Internals.h:
     70        * testing/Internals.idl:
     71
    1722013-04-08  Simon Fraser  <simon.fraser@apple.com>
    273
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r147888 r148050  
    10821082void HTMLMediaElement::updateActiveTextTrackCues(float movieTime)
    10831083{
    1084     LOG(Media, "HTMLMediaElement::updateActiveTextTracks");
    1085 
    10861084    // 4.8.10.8 Playing the media resource
    10871085
     
    10911089    if (ignoreTrackDisplayUpdateRequests())
    10921090        return;
     1091
     1092    LOG(Media, "HTMLMediaElement::updateActiveTextTracks");
    10931093
    10941094    // 1 - Let current cues be a list of cues, initialized to contain all the
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r147675 r148050  
    11891189MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement(Document* document)
    11901190    : MediaControlDivElement(document, MediaTextTrackDisplayContainer)
     1191    , m_updateTimer(this, &MediaControlTextTrackContainerElement::updateTimerFired)
    11911192    , m_fontSize(0)
     1193    , m_fontSizeIsImportant(false)
    11921194{
    11931195}
     
    12761278
    12771279        RefPtr<TextTrackCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size());
    1278         if (displayBox->hasChildNodes() && !contains(static_cast<Node*>(displayBox.get())))
     1280        if (displayBox->hasChildNodes() && !contains(static_cast<Node*>(displayBox.get()))) {
    12791281            // Note: the display tree of a cue is removed when the active flag of the cue is unset.
    12801282            appendChild(displayBox, ASSERT_NO_EXCEPTION, AttachNow);
     1283            cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
     1284        }
    12811285    }
    12821286
     
    13021306        removeInlineStyleProperty(CSSPropertyWidth);
    13031307        removeInlineStyleProperty(CSSPropertyHeight);
     1308    }
     1309}
     1310
     1311void MediaControlTextTrackContainerElement::updateTimerFired(Timer<MediaControlTextTrackContainerElement>*)
     1312{
     1313    if (!document()->page())
     1314        return;
     1315
     1316    if (m_textTrackRepresentation) {
     1317        setInlineStyleProperty(CSSPropertyWidth, String::number(m_videoDisplaySize.size().width()) + "px");
     1318        setInlineStyleProperty(CSSPropertyHeight, String::number(m_videoDisplaySize.size().height()) + "px");
     1319    }
     1320   
     1321    HTMLMediaElement* mediaElement = toParentMediaElement(this);
     1322    if (!mediaElement)
     1323        return;
     1324
     1325    float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
     1326    float fontScale = document()->page()->group().captionPreferences()->captionFontSizeScaleAndImportance(m_fontSizeIsImportant);
     1327    m_fontSize = lrintf(smallestDimension * fontScale);
     1328   
     1329    CueList activeCues = mediaElement->currentlyActiveCues();
     1330    for (size_t i = 0; i < activeCues.size(); ++i) {
     1331        TextTrackCue* cue = activeCues[i].data();
     1332        cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
     1333       
    13041334    }
    13051335}
     
    13341364    m_videoDisplaySize = videoBox;
    13351365
    1336     if (m_textTrackRepresentation) {
    1337         setInlineStyleProperty(CSSPropertyWidth, String::number(m_videoDisplaySize.size().width()) + "px");
    1338         setInlineStyleProperty(CSSPropertyHeight, String::number(m_videoDisplaySize.size().height()) + "px");
    1339     }
    1340 
    1341     float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
    1342 
    1343     bool important;
    1344     float fontSize = smallestDimension * (document()->page()->group().captionPreferences()->captionFontSizeScale(important));
    1345     if (fontSize != m_fontSize) {
    1346         m_fontSize = fontSize;
    1347         setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px", important);
    1348     }
    1349 
    1350     CueList activeCues = mediaElement->currentlyActiveCues();
    1351     for (size_t i = 0; i < activeCues.size(); ++i) {
    1352         TextTrackCue* cue = activeCues[i].data();
    1353         cue->videoSizeDidChange(m_videoDisplaySize.size());
    1354     }
     1366    m_updateTimer.startOneShot(0);
    13551367}
    13561368
  • trunk/Source/WebCore/html/shadow/MediaControlElements.h

    r147675 r148050  
    449449
    450450private:
     451    void updateTimerFired(Timer<MediaControlTextTrackContainerElement>*);
     452
    451453    explicit MediaControlTextTrackContainerElement(Document*);
    452454    virtual const AtomicString& shadowPseudoId() const OVERRIDE;
     
    458460    OwnPtr<TextTrackRepresentation> m_textTrackRepresentation;
    459461
     462    Timer<MediaControlTextTrackContainerElement> m_updateTimer;
    460463    IntRect m_videoDisplaySize;
    461     float m_fontSize;
     464    int m_fontSize;
     465    bool m_fontSizeIsImportant;
    462466};
    463467
  • trunk/Source/WebCore/html/shadow/MediaControls.cpp

    r146380 r148050  
    410410void MediaControls::textTrackPreferencesChanged()
    411411{
     412    closedCaptionTracksChanged();
    412413    if (m_textDisplayContainer)
    413414        m_textDisplayContainer->updateSizes(true);
    414     closedCaptionTracksChanged();
    415415}
    416416#endif
  • trunk/Source/WebCore/html/track/TextTrackCue.cpp

    r147355 r148050  
    4343#include "HTMLMediaElement.h"
    4444#include "HTMLSpanElement.h"
     45#include "Logging.h"
    4546#include "NodeTraversal.h"
    4647#include "RenderTextTrackCue.h"
     
    11801181}
    11811182
     1183void TextTrackCue::setFontSize(int fontSize, const IntSize&, bool important)
     1184{
     1185    if (!hasDisplayTree() || !fontSize)
     1186        return;
     1187   
     1188    LOG(Media, "TextTrackCue::setFontSize - setting cue font size to %i", fontSize);
     1189
     1190    element()->setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px", important);
     1191}
     1192
    11821193} // namespace WebCore
    11831194
  • trunk/Source/WebCore/html/track/TextTrackCue.h

    r147355 r148050  
    178178    CueAlignment getAlignment() const { return m_cueAlignment; }
    179179
    180     virtual void videoSizeDidChange(const IntSize&) { }
     180    virtual void setFontSize(int, const IntSize&, bool important);
    181181
    182182    virtual bool operator==(const TextTrackCue&) const;
  • trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp

    r146140 r148050  
    3535#include "HTMLNames.h"
    3636#include "InbandTextTrackPrivateClient.h"
     37#include "Logging.h"
    3738#include "RenderObject.h"
    3839#include "RenderTextTrackCue.h"
     
    6667   
    6768    TextTrackCueGeneric* cue = static_cast<TextTrackCueGeneric*>(getCue());
     69    RefPtr<HTMLDivElement> cueElement = cue->element();
    6870
    6971    float size = static_cast<float>(cue->getCSSSize());
     
    8284
    8385    if (cue->foregroundColor().isValid())
    84         setInlineStyleProperty(CSSPropertyColor, cue->foregroundColor().serialized());
     86        cueElement->setInlineStyleProperty(CSSPropertyColor, cue->foregroundColor().serialized());
    8587   
    8688    if (cue->backgroundColor().isValid())
    87         cue->element()->setInlineStyleProperty(CSSPropertyBackgroundColor, cue->backgroundColor().serialized());
     89        cueElement->setInlineStyleProperty(CSSPropertyBackgroundColor, cue->backgroundColor().serialized());
    8890
    8991    if (cue->getWritingDirection() == TextTrackCue::Horizontal)
     
    9294        setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
    9395
    94     if (cue->baseFontSizeRelativeToVideoHeight()) {
    95         double fontSize = videoSize.height() * cue->baseFontSizeRelativeToVideoHeight() / 100;
    96         if (cue->fontSizeMultiplier())
    97             fontSize *= cue->fontSizeMultiplier() / 100;
    98         setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
    99     }
     96    if (cue->baseFontSizeRelativeToVideoHeight())
     97        cue->setFontSize(cue->baseFontSizeRelativeToVideoHeight(), videoSize, false);
    10098
    10199    if (cue->getAlignment() == TextTrackCue::Middle)
     
    136134}
    137135
    138 void TextTrackCueGeneric::videoSizeDidChange(const IntSize& videoSize)
     136void TextTrackCueGeneric::setFontSize(int fontSize, const IntSize& videoSize, bool important)
    139137{
    140     if (!hasDisplayTree())
     138    if (!hasDisplayTree() || !fontSize)
    141139        return;
    142 
    143     if (baseFontSizeRelativeToVideoHeight()) {
    144         double fontSize = videoSize.height() * baseFontSizeRelativeToVideoHeight() / 100;
    145         if (fontSizeMultiplier())
    146             fontSize *= fontSizeMultiplier() / 100;
    147         displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
     140   
     141    if (important || !baseFontSizeRelativeToVideoHeight()) {
     142        TextTrackCue::setFontSize(fontSize, videoSize, important);
     143        return;
    148144    }
    149145
     146    double size = videoSize.height() * baseFontSizeRelativeToVideoHeight() / 100;
     147    if (fontSizeMultiplier())
     148        size *= fontSizeMultiplier() / 100;
     149    element()->setInlineStyleProperty(CSSPropertyFontSize, String::number(lrintf(size)) + "px");
     150
     151    LOG(Media, "TextTrackCueGeneric::setFontSize - setting cue font size to %li", lrintf(size));
    150152}
    151 
     153   
    152154bool TextTrackCueGeneric::operator==(const TextTrackCue& cue) const
    153155{
  • trunk/Source/WebCore/html/track/TextTrackCueGeneric.h

    r146140 r148050  
    6969    void setBackgroundColor(RGBA32 color) { m_backgroundColor.setRGB(color); }
    7070
    71     virtual void videoSizeDidChange(const IntSize&);
     71    virtual void setFontSize(int, const IntSize&, bool important) OVERRIDE;
    7272
    7373    virtual bool operator==(const TextTrackCue&) const OVERRIDE;
  • trunk/Source/WebCore/html/track/TextTrackList.cpp

    r146380 r148050  
    206206    invalidateTrackIndexesAfterTrack(track);
    207207
    208     ASSERT(track->mediaElement() == m_owner);
     208    ASSERT(!track->mediaElement() || track->mediaElement() == m_owner);
    209209    track->setMediaElement(0);
    210210
  • trunk/Source/WebCore/page/CaptionUserPreferences.cpp

    r147675 r148050  
    2929
    3030#include "CaptionUserPreferences.h"
     31#include "DOMWrapperWorld.h"
    3132#include "Page.h"
    3233#include "PageGroup.h"
    3334#include "Settings.h"
    3435#include "TextTrackList.h"
     36#include "UserStyleSheetTypes.h"
    3537#include <wtf/NonCopyingSort.h>
    3638
     
    222224}
    223225
     226void CaptionUserPreferences::setCaptionsStyleSheetOverride(const String& override)
     227{
     228    m_captionsStyleSheetOverride = override;
     229    updateCaptionStyleSheetOveride();
     230}
     231
     232void CaptionUserPreferences::updateCaptionStyleSheetOveride()
     233{
     234    // Identify our override style sheet with a unique URL - a new scheme and a UUID.
     235    DEFINE_STATIC_LOCAL(KURL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"));
     236
     237    pageGroup()->removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL);
     238
     239    String captionsOverrideStyleSheet = captionsStyleSheetOverride();
     240    if (captionsOverrideStyleSheet.isEmpty())
     241        return;
     242
     243    pageGroup()->addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, Vector<String>(),
     244        Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments);
     245}
     246
     247   
    224248}
    225249
  • trunk/Source/WebCore/page/CaptionUserPreferences.h

    r147675 r148050  
    6767    virtual void setUserPrefersTextDescriptions(bool preference);
    6868
    69     virtual float captionFontSizeScale(bool& important) const { important = false; return 0.05f; }
    70     virtual String captionsStyleSheetOverride() const { return emptyString(); }
     69    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&);
    7173
    7274    virtual void setInterestedInCaptionPreferenceChanges() { }
     
    8789protected:
    8890    CaptionUserPreferences(PageGroup*);
     91    void updateCaptionStyleSheetOveride();
    8992
    9093private:
     
    9699    Timer<CaptionUserPreferences> m_timer;
    97100    String m_userPreferredLanguage;
     101    String m_captionsStyleSheetOverride;
    98102    bool m_testingMode;
    99103    bool m_havePreferences;
  • trunk/Source/WebCore/page/CaptionUserPreferencesMac.h

    r147675 r148050  
    4848    virtual bool userPrefersSubtitles() const OVERRIDE;
    4949   
    50     virtual float captionFontSizeScale(bool&) const OVERRIDE;
    51     virtual String captionsStyleSheetOverride() const OVERRIDE;
     50    virtual float captionFontSizeScaleAndImportance(bool&) const OVERRIDE;
    5251
    5352    virtual void setInterestedInCaptionPreferenceChanges() OVERRIDE;
     
    5756
    5857    virtual void captionPreferencesChanged() OVERRIDE;
    59 
    6058#endif
    6159
     60    virtual String captionsStyleSheetOverride() const OVERRIDE;
    6261    virtual int textTrackSelectionScore(TextTrack*, HTMLMediaElement*) const OVERRIDE;
    6362    virtual Vector<RefPtr<TextTrack> > sortedTrackListForMenu(TextTrackList*) OVERRIDE;
     
    7978    String colorPropertyCSS(CSSPropertyID, const Color&, bool) const;
    8079
    81     void updateCaptionStyleSheetOveride();
    82 
    8380    bool m_listeningForPreferenceChanges;
    8481#endif
  • trunk/Source/WebCore/page/CaptionUserPreferencesMac.mm

    r147675 r148050  
    251251
    252252    bool important = behavior == kMACaptionAppearanceBehaviorUseValue;
    253     CGFloat opacity = MACaptionAppearanceGetBackgroundOpacity(kMACaptionAppearanceDomainUser, 0);
     253    CGFloat opacity = MACaptionAppearanceGetBackgroundOpacity(kMACaptionAppearanceDomainUser, &behavior);
    254254    if (!important)
    255255        important = behavior == kMACaptionAppearanceBehaviorUseValue;
     
    417417}
    418418
    419 String CaptionUserPreferencesMac::captionsStyleSheetOverride() const
     419float CaptionUserPreferencesMac::captionFontSizeScaleAndImportance(bool& important) const
    420420{
    421421    if (testingMode() || !MediaAccessibilityLibrary())
    422         return CaptionUserPreferences::captionsStyleSheetOverride();
    423 
    424     StringBuilder captionsOverrideStyleSheet;
    425 
    426     String background = captionsBackgroundCSS();
    427     if (!background.isEmpty()) {
    428         captionsOverrideStyleSheet.append(" video::");
    429         captionsOverrideStyleSheet.append(TextTrackCue::cueShadowPseudoId());
    430         captionsOverrideStyleSheet.append('{');
    431         captionsOverrideStyleSheet.append(background);
    432         captionsOverrideStyleSheet.append('}');
    433     }
    434 
    435     String windowColor = captionsWindowCSS();
    436     String windowCornerRadius = windowRoundedCornerRadiusCSS();
    437     if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
    438         captionsOverrideStyleSheet.append(" video::");
    439         captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
    440         captionsOverrideStyleSheet.append('{');
    441 
    442         if (!windowColor.isEmpty())
    443             captionsOverrideStyleSheet.append(windowColor);
    444         if (!windowCornerRadius.isEmpty())
    445             captionsOverrideStyleSheet.append(windowCornerRadius);
    446 
    447         captionsOverrideStyleSheet.append('}');
    448     }
    449    
    450     String captionsColor = captionsTextColorCSS();
    451     String edgeStyle = captionsTextEdgeCSS();
    452     String fontName = captionsDefaultFontCSS();
    453     if (!captionsColor.isEmpty() || !edgeStyle.isEmpty() || !fontName.isEmpty()) {
    454         captionsOverrideStyleSheet.append(" video::");
    455         captionsOverrideStyleSheet.append(MediaControlTextTrackContainerElement::textTrackContainerElementShadowPseudoId());
    456         captionsOverrideStyleSheet.append('{');
    457 
    458         if (!captionsColor.isEmpty())
    459             captionsOverrideStyleSheet.append(captionsColor);
    460         if (!edgeStyle.isEmpty())
    461             captionsOverrideStyleSheet.append(edgeStyle);
    462         if (!fontName.isEmpty())
    463             captionsOverrideStyleSheet.append(fontName);
    464 
    465         captionsOverrideStyleSheet.append('}');
    466     }
    467    
    468     LOG(Media, "CaptionUserPreferencesMac::captionsStyleSheetOverrideSetting sytle to:\n%s", captionsOverrideStyleSheet.toString().utf8().data());
    469 
    470     return captionsOverrideStyleSheet.toString();
    471 }
    472 
    473 float CaptionUserPreferencesMac::captionFontSizeScale(bool& important) const
    474 {
    475     if (testingMode() || !MediaAccessibilityLibrary())
    476         return CaptionUserPreferences::captionFontSizeScale(important);
     422        return CaptionUserPreferences::captionFontSizeScaleAndImportance(important);
    477423
    478424    MACaptionAppearanceBehavior behavior;
    479     CGFloat characterScale = CaptionUserPreferences::captionFontSizeScale(important);
     425    CGFloat characterScale = CaptionUserPreferences::captionFontSizeScaleAndImportance(important);
    480426    CGFloat scaleAdjustment = MACaptionAppearanceGetRelativeCharacterSize(kMACaptionAppearanceDomainUser, &behavior);
    481427
     
    489435    return scaleAdjustment * characterScale;
    490436#endif
    491 }
    492 
    493 void CaptionUserPreferencesMac::updateCaptionStyleSheetOveride()
    494 {
    495     // Identify our override style sheet with a unique URL - a new scheme and a UUID.
    496     DEFINE_STATIC_LOCAL(KURL, captionsStyleSheetURL, (ParsedURLString, "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23"));
    497    
    498     pageGroup()->removeUserStyleSheetFromWorld(mainThreadNormalWorld(), captionsStyleSheetURL);
    499    
    500     String captionsOverrideStyleSheet = captionsStyleSheetOverride();
    501     if (captionsOverrideStyleSheet.isEmpty())
    502         return;
    503    
    504     pageGroup()->addUserStyleSheetToWorld(mainThreadNormalWorld(), captionsOverrideStyleSheet, captionsStyleSheetURL, Vector<String>(),
    505              Vector<String>(), InjectInAllFrames, UserStyleAuthorLevel, InjectInExistingDocuments);
    506437}
    507438
     
    550481}
    551482#endif  // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     483
     484String CaptionUserPreferencesMac::captionsStyleSheetOverride() const
     485{
     486    if (testingMode())
     487        return CaptionUserPreferences::captionsStyleSheetOverride();
     488   
     489    StringBuilder captionsOverrideStyleSheet;
     490
     491#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     492    if (!MediaAccessibilityLibrary())
     493        return CaptionUserPreferences::captionsStyleSheetOverride();
     494   
     495    String captionsColor = captionsTextColorCSS();
     496    String edgeStyle = captionsTextEdgeCSS();
     497    String fontName = captionsDefaultFontCSS();
     498    String background = captionsBackgroundCSS();
     499    if (!background.isEmpty() || !captionsColor.isEmpty() || !edgeStyle.isEmpty() || !fontName.isEmpty()) {
     500        captionsOverrideStyleSheet.append(" video::");
     501        captionsOverrideStyleSheet.append(TextTrackCue::cueShadowPseudoId());
     502        captionsOverrideStyleSheet.append('{');
     503       
     504        if (!background.isEmpty())
     505            captionsOverrideStyleSheet.append(background);
     506        if (!captionsColor.isEmpty())
     507            captionsOverrideStyleSheet.append(captionsColor);
     508        if (!edgeStyle.isEmpty())
     509            captionsOverrideStyleSheet.append(edgeStyle);
     510        if (!fontName.isEmpty())
     511            captionsOverrideStyleSheet.append(fontName);
     512       
     513        captionsOverrideStyleSheet.append('}');
     514    }
     515   
     516    String windowColor = captionsWindowCSS();
     517    String windowCornerRadius = windowRoundedCornerRadiusCSS();
     518    if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
     519        captionsOverrideStyleSheet.append(" video::");
     520        captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
     521        captionsOverrideStyleSheet.append('{');
     522       
     523        if (!windowColor.isEmpty())
     524            captionsOverrideStyleSheet.append(windowColor);
     525        if (!windowCornerRadius.isEmpty())
     526            captionsOverrideStyleSheet.append(windowCornerRadius);
     527       
     528        captionsOverrideStyleSheet.append('}');
     529    }
     530#endif  // HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
     531
     532    LOG(Media, "CaptionUserPreferencesMac::captionsStyleSheetOverrideSetting sytle to:\n%s", captionsOverrideStyleSheet.toString().utf8().data());
     533
     534    return captionsOverrideStyleSheet.toString();
     535}
    552536
    553537static String languageIdentifier(const String& languageCode)
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r144565 r148050  
    392392    bool didLoadingProgress = currentMaxTimeLoaded != m_maxTimeLoadedAtLastDidLoadingProgress;
    393393    m_maxTimeLoadedAtLastDidLoadingProgress = currentMaxTimeLoaded;
    394     LOG(Media, "MediaPlayerPrivateAVFoundation::didLoadingProgress(%p) - returning %d", this, didLoadingProgress);
     394
    395395    return didLoadingProgress;
    396396}
     
    433433    MediaPlayer::NetworkState oldNetworkState = m_networkState;
    434434    MediaPlayer::ReadyState oldReadyState = m_readyState;
    435 
    436     LOG(Media, "MediaPlayerPrivateAVFoundation::updateStates(%p) - entering with networkState = %i, readyState = %i",
    437         this, static_cast<int>(m_networkState), static_cast<int>(m_readyState));
    438435
    439436    if (m_loadingMetadata)
     
    523520    }
    524521
    525     LOG(Media, "MediaPlayerPrivateAVFoundation::updateStates(%p) - exiting with networkState = %i, readyState = %i",
    526         this, static_cast<int>(m_networkState), static_cast<int>(m_readyState));
     522#if !LOG_DISABLED
     523    if (m_networkState != oldNetworkState || oldReadyState != m_readyState) {
     524        LOG(Media, "MediaPlayerPrivateAVFoundation::updateStates(%p) - entered with networkState = %i, readyState = %i,  exiting with networkState = %i, readyState = %i",
     525            this, static_cast<int>(oldNetworkState), static_cast<int>(oldReadyState), static_cast<int>(m_networkState), static_cast<int>(m_readyState));
     526    }
     527#endif
    527528}
    528529
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r147675 r148050  
    530530PlatformLayer* MediaPlayerPrivateAVFoundationObjC::platformLayer() const
    531531{
    532     LOG(Media, "MediaPlayerPrivateAVFoundationObjC::platformLayer(%p)", this);
    533532    return m_videoLayer.get();
    534533}
     
    13681367    AVMediaSelectionOptionType *mediaSelectionOption = trackPrivate ? trackPrivate->mediaSelectionOption() : 0;
    13691368
    1370     LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(%p) - selecting media option %p", this, mediaSelectionOption);
     1369    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(%p) - selecting media option %p, language = %s", this, mediaSelectionOption, [[[mediaSelectionOption locale] localeIdentifier] UTF8String]);
    13711370
    13721371    [m_avPlayerItem.get() selectMediaOption:mediaSelectionOption inMediaSelectionGroup:[m_avAsset.get() mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible]];
  • trunk/Source/WebCore/testing/Internals.cpp

    r147888 r148050  
    274274#endif
    275275#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
     276    page->group().captionPreferences()->setCaptionsStyleSheetOverride(emptyString());
    276277    page->group().captionPreferences()->setTestingMode(false);
    277278#endif
     
    21082109}
    21092110
    2110 }
     2111String Internals::captionsStyleSheetOverride(ExceptionCode& ec)
     2112{
     2113    Document* document = contextDocument();
     2114    if (!document || !document->page()) {
     2115        ec = INVALID_ACCESS_ERR;
     2116        return emptyString();
     2117    }
     2118
     2119#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
     2120    return document->page()->group().captionPreferences()->captionsStyleSheetOverride();
     2121#else
     2122    return emptyString();
     2123#endif
     2124}
     2125
     2126void Internals::setCaptionsStyleSheetOverride(const String& override, ExceptionCode& ec)
     2127{
     2128    Document* document = contextDocument();
     2129    if (!document || !document->page()) {
     2130        ec = INVALID_ACCESS_ERR;
     2131        return;
     2132    }
     2133
     2134#if ENABLE(VIDEO_TRACK) && !PLATFORM(WIN)
     2135    document->page()->group().captionPreferences()->setCaptionsStyleSheetOverride(override);
     2136#endif
     2137}
     2138
     2139}
  • trunk/Source/WebCore/testing/Internals.h

    r147548 r148050  
    312312    bool isSelectPopupVisible(Node*);
    313313
     314    String captionsStyleSheetOverride(ExceptionCode&);
     315    void setCaptionsStyleSheetOverride(const String&, ExceptionCode&);
     316
    314317private:
    315318    explicit Internals(Document*);
  • trunk/Source/WebCore/testing/Internals.idl

    r147548 r148050  
    273273    DOMString getImageSourceURL(in Element element) raises(DOMException);
    274274
     275    [Conditional=VIDEO_TRACK] DOMString captionsStyleSheetOverride() raises (DOMException);
     276    [Conditional=VIDEO_TRACK] void setCaptionsStyleSheetOverride(in DOMString override) raises (DOMException);
     277
    275278    boolean isSelectPopupVisible(in Node node);
    276279};
Note: See TracChangeset for help on using the changeset viewer.