Bug 71915 - addTrack() must throw an exception if 'kind' is unknown
Summary: addTrack() must throw an exception if 'kind' is unknown
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks: 43668
  Show dependency treegraph
 
Reported: 2011-11-09 07:29 PST by Eric Carlson
Modified: 2011-12-02 09:48 PST (History)
7 users (show)

See Also:


Attachments
Proposed patch (27.28 KB, patch)
2011-11-15 18:33 PST, Eric Carlson
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
Patch (27.36 KB, patch)
2011-11-15 20:42 PST, Eric Carlson
pnormand: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2011-11-09 07:29:42 PST
http://dev.w3.org/html5/spec/the-iframe-element.html#dom-media-addtexttrack says: "If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps"
Comment 1 Radar WebKit Bug Importer 2011-11-09 07:30:17 PST
<rdar://problem/10419196>
Comment 2 Eric Carlson 2011-11-15 18:33:58 PST
Created attachment 115292 [details]
Proposed patch
Comment 3 WebKit Review Bot 2011-11-15 18:54:33 PST
Comment on attachment 115292 [details]
Proposed patch

Attachment 115292 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/10494001
Comment 4 Eric Carlson 2011-11-15 20:42:28 PST
Created attachment 115311 [details]
Patch
Comment 5 Philippe Normand 2011-11-16 07:57:57 PST
Comment on attachment 115311 [details]
Patch

Nice patch, thanks Eric!
Comment 6 Eric Carlson 2011-11-16 08:06:52 PST
http://trac.webkit.org/changeset/100453
Comment 7 Darin Adler 2011-12-01 16:02:28 PST
Comment on attachment 115292 [details]
Proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=115292&action=review

> Source/WebCore/html/HTMLMediaElement.cpp:2099
> -TextTrackList* HTMLMediaElement::textTracks() const 
> +TextTrackList* HTMLMediaElement::textTracks() 

Left a trailing space on there.

> Source/WebCore/html/HTMLTrackElement.cpp:106
> +    } else if (attrName == kindAttr)
> +        track()->setKind(attr->value());
> +    else if (attrName == labelAttr)
> +        track()->setLabel(attr->value());
> +    else if (attrName == srclangAttr)
> +        track()->setLanguage(attr->value());

I’m not sure why this is in attributeChanged rather than parseMappedAttribute.

> Source/WebCore/html/HTMLTrackElement.cpp:109
>  KURL HTMLTrackElement::src() const

I don’t understand why this doesn’t just use [Reflect]. Why do we need a custom function for this? And for any of these other attributes.

> Source/WebCore/html/HTMLTrackElement.cpp:122
>  String HTMLTrackElement::kind() const
>  {
> -    return getAttribute(kindAttr);
> +    return track()->kind();
>  }

I don’t understand this change. How can these two get out of sync?

> Source/WebCore/html/HTMLTrackElement.cpp:166
> +        String kind = getAttribute(kindAttr);

Should be fastGetAttribute.

> Source/WebCore/html/HTMLTrackElement.h:-51
>      KURL src() const;
> +    void setSrc(const String&);
> +
>      String kind() const;
> +    void setKind(const String&);
> +
>      String srclang() const;
> +    void setSrclang(const String&);
> +
>      String label() const;
> +    void setLabel(const String&);
>  
>      bool isDefault() const;
> -    void setKind(const String&);
> -    void setSrc(const String&);
> -    void setSrclang(const String&);
> -    void setLabel(const String&);

This seems like an unneeded change.

> Source/WebCore/html/TextTrack.h:70
> +    static const AtomicString& subtitlesKeyword();
> +    static const AtomicString& captionsKeyword();
> +    static const AtomicString& descriptionsKeyword();
> +    static const AtomicString& chaptersKeyword();
> +    static const AtomicString& metadataKeyword();

Do these need to be member functions?
Comment 8 Eric Carlson 2011-12-02 09:48:22 PST
(In reply to comment #7)
> (From update of attachment 115292 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=115292&action=review
> 
> > Source/WebCore/html/HTMLMediaElement.cpp:2099
> > -TextTrackList* HTMLMediaElement::textTracks() const 
> > +TextTrackList* HTMLMediaElement::textTracks() 
> 
> Left a trailing space on there.
> 
I will fix that.

> > Source/WebCore/html/HTMLTrackElement.cpp:106
> > +    } else if (attrName == kindAttr)
> > +        track()->setKind(attr->value());
> > +    else if (attrName == labelAttr)
> > +        track()->setLabel(attr->value());
> > +    else if (attrName == srclangAttr)
> > +        track()->setLanguage(attr->value());
> 
> I’m not sure why this is in attributeChanged rather than parseMappedAttribute.
> 
No good reason, I will fix this.

> > Source/WebCore/html/HTMLTrackElement.cpp:109
> >  KURL HTMLTrackElement::src() const
> 
> I don’t understand why this doesn’t just use [Reflect]. Why do we need a custom function for this? And for any of these other attributes.
> 
Good point.

> > Source/WebCore/html/HTMLTrackElement.cpp:122
> >  String HTMLTrackElement::kind() const
> >  {
> > -    return getAttribute(kindAttr);
> > +    return track()->kind();
> >  }
> 
> I don’t understand this change. How can these two get out of sync?
> 
The kind IDL attribute must "reflect the content attribute of the same name, limited to only known values". I decided to put the knowledge about what kind values are allowed in TextTrack because it also applies to tracks created with HTMLMediaElement::addTrack(). I will add a comment to this function.

> > Source/WebCore/html/HTMLTrackElement.cpp:166
> > +        String kind = getAttribute(kindAttr);
> 
> Should be fastGetAttribute.
> 
Good point, I will fix this.

> > Source/WebCore/html/HTMLTrackElement.h:-51
> >      KURL src() const;
> > +    void setSrc(const String&);
> > +
> >      String kind() const;
> > +    void setKind(const String&);
> > +
> >      String srclang() const;
> > +    void setSrclang(const String&);
> > +
> >      String label() const;
> > +    void setLabel(const String&);
> >  
> >      bool isDefault() const;
> > -    void setKind(const String&);
> > -    void setSrc(const String&);
> > -    void setSrclang(const String&);
> > -    void setLabel(const String&);
> 
> This seems like an unneeded change.
> 
It was just drive-by cleanup.

> > Source/WebCore/html/TextTrack.h:70
> > +    static const AtomicString& subtitlesKeyword();
> > +    static const AtomicString& captionsKeyword();
> > +    static const AtomicString& descriptionsKeyword();
> > +    static const AtomicString& chaptersKeyword();
> > +    static const AtomicString& metadataKeyword();
> 
> Do these need to be member functions?
>
Not necessarily. They are also used by HTMLMediaElement and HTMLTrackElement so I thought it would be helpful to give them class scope.

Thanks for the feedback!