Changeset 241203 in webkit


Ignore:
Timestamp:
Feb 8, 2019 11:48:04 AM (5 years ago)
Author:
pvollan@apple.com
Message:

[WebVTT] Inline WebVTT styles should start with '::cue'
https://bugs.webkit.org/show_bug.cgi?id=194227
<rdar://problem/47791087>

Reviewed by Eric Carlson.

Source/WebCore:

Check that the CSS string starts with '::cue' and is successfully parsed before adding it
to the CSS stylesheet list. Also, the caption preferences CSS string should start with
'::cue', since it is added inside the video shadow root element.

Test: media/track/track-cue-css.html

  • html/track/WebVTTParser.cpp:

(WebCore::WebVTTParser::checkAndStoreStyleSheet):

  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride const):

LayoutTests:

  • media/track/captions-webvtt/css-styling.vtt:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r241200 r241203  
     12019-02-08  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [WebVTT] Inline WebVTT styles should start with '::cue'
     4        https://bugs.webkit.org/show_bug.cgi?id=194227
     5        <rdar://problem/47791087>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * media/track/captions-webvtt/css-styling.vtt:
     10
    1112019-02-08  Youenn Fablet  <youenn@apple.com>
    212
  • trunk/LayoutTests/media/track/captions-webvtt/css-styling.vtt

    r239181 r241203  
    1313
    1414STYLE
    15 video::cue {
     15::cue {
    1616color: green;
    1717font-size: 15px;
     18}
     19
     20NOTE the following style block has a syntax error.
     21
     22STYLE
     23::cue {
     24color: blue
     25font-size: 25px;
     26}
     27
     28STYLE
     29video::cue {
     30color: blue;
     31font-size: 25px;
    1832}
    1933
  • trunk/Source/WebCore/ChangeLog

    r241200 r241203  
     12019-02-08  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [WebVTT] Inline WebVTT styles should start with '::cue'
     4        https://bugs.webkit.org/show_bug.cgi?id=194227
     5        <rdar://problem/47791087>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Check that the CSS string starts with '::cue' and is successfully parsed before adding it
     10        to the CSS stylesheet list. Also, the caption preferences CSS string should start with
     11        '::cue', since it is added inside the video shadow root element.
     12
     13        Test: media/track/track-cue-css.html
     14
     15        * html/track/WebVTTParser.cpp:
     16        (WebCore::WebVTTParser::checkAndStoreStyleSheet):
     17        * page/CaptionUserPreferencesMediaAF.cpp:
     18        (WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride const):
     19
    1202019-02-08  Youenn Fablet  <youenn@apple.com>
    221
  • trunk/Source/WebCore/html/track/WebVTTParser.cpp

    r239535 r241203  
    4040#include "ISOVTTCue.h"
    4141#include "ProcessingInstruction.h"
     42#include "StyleSheetContents.h"
    4243#include "Text.h"
    4344#include "VTTScanner.h"
     
    368369    if (!line.isEmpty() && !line.contains("-->"))
    369370        return false;
     371   
     372    auto styleSheet = m_currentStyleSheet.stripWhiteSpace();
     373   
     374    // Inline VTT styles must start with ::cue.
     375    if (!styleSheet.startsWith("::cue")) {
     376        m_currentStyleSheet = emptyString();
     377        return true;
     378    }
     379
     380    auto contents = StyleSheetContents::create();
     381    if (!contents->parseString(styleSheet)) {
     382        m_currentStyleSheet = emptyString();
     383        return true;
     384    }
    370385   
    371386    m_styleSheets.append(WTFMove(m_currentStyleSheet));
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r240892 r241203  
    568568    String background = captionsBackgroundCSS();
    569569    if (!background.isEmpty() || !captionsColor.isEmpty() || !edgeStyle.isEmpty() || !fontName.isEmpty()) {
    570         captionsOverrideStyleSheet.appendLiteral(" video::");
     570        captionsOverrideStyleSheet.appendLiteral(" ::");
    571571        captionsOverrideStyleSheet.append(TextTrackCue::cueShadowPseudoId());
    572572        captionsOverrideStyleSheet.append('{');
     
    587587    String windowCornerRadius = windowRoundedCornerRadiusCSS();
    588588    if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
    589         captionsOverrideStyleSheet.appendLiteral(" video::");
     589        captionsOverrideStyleSheet.appendLiteral(" ::");
    590590        captionsOverrideStyleSheet.append(VTTCue::cueBackdropShadowPseudoId());
    591591        captionsOverrideStyleSheet.append('{');
Note: See TracChangeset for help on using the changeset viewer.