Changeset 147355 in webkit


Ignore:
Timestamp:
Apr 1, 2013 1:10:48 PM (11 years ago)
Author:
vcarbune@chromium.org
Message:

TextTrackCue Extension for WebVTT Regions
https://bugs.webkit.org/show_bug.cgi?id=109821

Reviewed by Eric Carlson.

Source/WebCore:

The TextTrackCue gets a new attribute and setting, regionId, which specifies
to which region the cue belongs to. The attribute is guarded by WEBVTT_REGIONS
and is by default disabled in ports.

Test: media/track/regions-webvtt/text-track-cue-region-attribute.html

  • html/track/TextTrackCue.cpp:

(WebCore::TextTrackCue::TextTrackCue): Added member variable for the regionId attribute.
(WebCore):
(WebCore::TextTrackCue::setRegionId): Setter for the regionId attribute.
(WebCore::TextTrackCue::settingName): Added RegionId setting name.
(WebCore::TextTrackCue::setCueSettings): Parsed the "region:" cue setting.

  • html/track/TextTrackCue.h:

(TextTrackCue):
(WebCore::TextTrackCue::regionId): Getter for the regionId attribute.

  • html/track/TextTrackCue.idl: Updated to match the WebVTT Regions Extension.

LayoutTests:

  • media/track/captions-webvtt/header-regions.vtt: Updated to include cues with

settings for which the "region:" setting should be ignored (for backwards compatibility
regarding WebVTT rendering rules).

  • media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt: Added.
  • media/track/regions-webvtt/text-track-cue-region-attribute.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r147351 r147355  
     12013-04-01  Victor Carbune  <vcarbune@chromium.org>
     2
     3        TextTrackCue Extension for WebVTT Regions
     4        https://bugs.webkit.org/show_bug.cgi?id=109821
     5
     6        Reviewed by Eric Carlson.
     7
     8        * media/track/captions-webvtt/header-regions.vtt: Updated to include cues with
     9        settings for which the "region:" setting should be ignored (for backwards compatibility
     10        regarding WebVTT rendering rules).
     11        * media/track/regions-webvtt/text-track-cue-region-attribute-expected.txt: Added.
     12        * media/track/regions-webvtt/text-track-cue-region-attribute.html: Added.
     13
    1142013-04-01  Nate Chapin  <japhet@chromium.org>
    215
  • trunk/LayoutTests/media/track/captions-webvtt/header-regions.vtt

    r147325 r147355  
    99
    10101
    11 00:00:00.000 --> 00:00:02.500
     1100:00:00.000 --> 00:00:02.500 region:someregionattributeid
    1212We are in New York City
     13
     142
     1500:00:00.000 --> 00:00:02.500 line:5 region:ignored_attribute_value
     16Line is specified, Region should be ignored.
     17
     183
     1900:00:00.000 --> 00:00:02.500 size:10% region:ignored_attribute_value
     20Size is specified, Region should be ignored.
     21
     224
     2300:00:00.000 --> 00:00:02.500 vertical:lr region:ignored_attribute_value
     24Vertical is specified, Region should be ignored.
  • trunk/Source/WebCore/ChangeLog

    r147354 r147355  
     12013-04-01  Victor Carbune  <vcarbune@chromium.org>
     2
     3        TextTrackCue Extension for WebVTT Regions
     4        https://bugs.webkit.org/show_bug.cgi?id=109821
     5
     6        Reviewed by Eric Carlson.
     7
     8        The TextTrackCue gets a new attribute and setting, regionId, which specifies
     9        to which region the cue belongs to. The attribute is guarded by WEBVTT_REGIONS
     10        and is by default disabled in ports.
     11
     12        Test: media/track/regions-webvtt/text-track-cue-region-attribute.html
     13
     14        * html/track/TextTrackCue.cpp:
     15        (WebCore::TextTrackCue::TextTrackCue): Added member variable for the regionId attribute.
     16        (WebCore):
     17        (WebCore::TextTrackCue::setRegionId): Setter for the regionId attribute.
     18        (WebCore::TextTrackCue::settingName): Added RegionId setting name.
     19        (WebCore::TextTrackCue::setCueSettings): Parsed the "region:" cue setting.
     20        * html/track/TextTrackCue.h:
     21        (TextTrackCue):
     22        (WebCore::TextTrackCue::regionId): Getter for the regionId attribute.
     23        * html/track/TextTrackCue.idl: Updated to match the WebVTT Regions Extension.
     24
    1252013-03-05  Anders Carlsson  <andersca@apple.com>
    226
  • trunk/Source/WebCore/html/track/TextTrackCue.cpp

    r146128 r147355  
    535535}
    536536
     537#if ENABLE(WEBVTT_REGIONS)
     538void TextTrackCue::setRegionId(const String& regionId)
     539{
     540    if (m_regionId == regionId)
     541        return;
     542
     543    cueWillChange();
     544    m_regionId = regionId;
     545    cueDidChange();
     546}
     547#endif
     548
    537549bool TextTrackCue::isActive()
    538550{
     
    863875    DEFINE_STATIC_LOCAL(const String, sizeKeyword, (ASCIILiteral("size")));
    864876    DEFINE_STATIC_LOCAL(const String, alignKeyword, (ASCIILiteral("align")));
     877#if ENABLE(WEBVTT_REGIONS)
     878    DEFINE_STATIC_LOCAL(const String, regionIdKeyword, (ASCIILiteral("region")));
     879#endif
    865880
    866881    if (name == verticalKeyword)
     
    874889    else if (name == alignKeyword)
    875890        return Align;
     891#if ENABLE(WEBVTT_REGIONS)
     892    else if (name == regionIdKeyword)
     893        return RegionId;
     894#endif
    876895
    877896    return None;
     
    10671086            }
    10681087            break;
     1088#if ENABLE(WEBVTT_REGIONS)
     1089        case RegionId:
     1090            m_regionId = WebVTTParser::collectWord(input, &position);
     1091            break;
     1092#endif
    10691093        case None:
    10701094            break;
     
    10741098        position = endOfSetting;
    10751099    }
     1100#if ENABLE(WEBVTT_REGIONS)
     1101    // If cue's line position is not auto or cue's size is not 100 or cue's
     1102    // writing direction is not horizontal, but cue's region identifier is not
     1103    // the empty string, let cue's region identifier be the empty string.
     1104    if (m_regionId.isEmpty())
     1105        return;
     1106
     1107    if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDirection != Horizontal)
     1108        m_regionId = emptyString();
     1109#endif
    10761110}
    10771111
  • trunk/Source/WebCore/html/track/TextTrackCue.h

    r146140 r147355  
    136136    virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE;
    137137
     138#if ENABLE(WEBVTT_REGIONS)
     139    const String& regionId() const { return m_regionId; }
     140    void setRegionId(const String&);
     141#endif
     142
    138143    bool isActive();
    139144    void setIsActive(bool);
     
    205210
    206211private:
     212    void createWebVTTNodeTree();
     213    void copyWebVTTNodeToDOMTree(ContainerNode* WebVTTNode, ContainerNode* root);
     214
    207215    std::pair<double, double> getPositionCoordinates() const;
    208216    void parseSettings(const String&);
     
    217225    virtual void derefEventTarget() { deref(); }
    218226
    219     enum CueSetting { None, Vertical, Line, Position, Size, Align };
     227    enum CueSetting {
     228        None,
     229        Vertical,
     230        Line,
     231        Position,
     232        Size,
     233        Align,
     234#if ENABLE(WEBVTT_REGIONS)
     235        RegionId
     236#endif
     237    };
    220238    CueSetting settingName(const String&);
    221239
     
    258276
    259277    std::pair<float, float> m_displayPosition;
    260 
    261     void createWebVTTNodeTree();
    262     void copyWebVTTNodeToDOMTree(ContainerNode* WebVTTNode, ContainerNode* root);
     278#if ENABLE(WEBVTT_REGIONS)
     279    String m_regionId;
     280#endif
    263281};
    264282
  • trunk/Source/WebCore/html/track/TextTrackCue.idl

    r141034 r147355  
    5858    attribute DOMString text;
    5959    DocumentFragment getCueAsHTML();
    60    
     60
    6161    attribute EventListener onenter;
    6262    attribute EventListener onexit;
    63    
     63
    6464    // EventTarget interface
    6565    void addEventListener(in DOMString type,
     
    7171    boolean dispatchEvent(in Event evt)
    7272        raises(EventException);
     73
     74#if defined(ENABLE_WEBVTT_REGIONS) && ENABLE_WEBVTT_REGIONS
     75    attribute DOMString regionId;
     76#endif
    7377};
    7478
Note: See TracChangeset for help on using the changeset viewer.