Bug 73466 - HTMLTrackElement.readyState should return TextTrack "readiness state".
Summary: HTMLTrackElement.readyState should return TextTrack "readiness state".
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:
 
Reported: 2011-11-30 10:37 PST by Eric Carlson
Modified: 2011-12-01 08:48 PST (History)
2 users (show)

See Also:


Attachments
Proposed patch (4.79 KB, patch)
2011-11-30 11:01 PST, Eric Carlson
darin: 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-30 10:37:31 PST
r101213 (72553) moved the text track 'readyState' attribute from TextTrack to HTMLTrackElement. The attribute and constants do belong on the element, but all types of text tracks - in-band, out of band, and those created with addTextTrack() - must maintain a "text track readiness state" as well. Additionally, HTMLTrackElement.readyState is supposed to return the readiness state of the track element's TextTrack:

  The readyState attribute must return the numeric value corresponding to the text track 
  readiness state of the track element's text track [1]

[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-track-readystate
Comment 1 Radar WebKit Bug Importer 2011-11-30 10:38:06 PST
<rdar://problem/10504834>
Comment 2 Eric Carlson 2011-11-30 11:01:01 PST
Created attachment 117225 [details]
Proposed patch
Comment 3 Darin Adler 2011-11-30 17:23:55 PST
Comment on attachment 117225 [details]
Proposed patch

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

This code is OK but I am not happy about having two enums that have to always match. Can we fix that?

> Source/WebCore/html/HTMLTrackElement.cpp:223
> +    ensureTrack()->setReadinessState(static_cast<TextTrack::ReadinessState>(state));

This cast isn’t safe if we ever change one of the two enums without the other. There’s not even a comment to guarantee we keep them in sync.

> Source/WebCore/html/HTMLTrackElement.cpp:230
> +    return static_cast<HTMLTrackElement::ReadyState>(ensureTrack()->readinessState());

No need here for HTMLTrackElement:: prefix.

This cast isn’t safe if we ever change one of the two enums without the other. There’s not even a comment to guarantee we keep them in sync.

> Source/WebCore/html/TextTrack.h:113
> +    TextTrack::ReadinessState m_readinessState;

There is no need for TextTrack:: prefix here.
Comment 4 Eric Carlson 2011-12-01 08:47:55 PST
(In reply to comment #3)
> (From update of attachment 117225 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=117225&action=review
> 
> This code is OK but I am not happy about having two enums that have to always match. Can we fix that?
> 
> > Source/WebCore/html/HTMLTrackElement.cpp:223
> > +    ensureTrack()->setReadinessState(static_cast<TextTrack::ReadinessState>(state));
> 
> This cast isn’t safe if we ever change one of the two enums without the other. There’s not even a comment to guarantee we keep them in sync.
> 
I couldn't come up with a clean way to have just one enum because the enum in HTMLTrackElement.h is visible to JavaScript, and HTMLTrackElement.h has to include TextTrack.h, but I added COMPILE_ASSERTs for all values so HTMLTrackElement.cpp will fail to compile if the two enums ever get out of sync.

> > Source/WebCore/html/HTMLTrackElement.cpp:230
> > +    return static_cast<HTMLTrackElement::ReadyState>(ensureTrack()->readinessState());
> 
> No need here for HTMLTrackElement:: prefix.
> 
Fixed.

> > Source/WebCore/html/TextTrack.h:113
> > +    TextTrack::ReadinessState m_readinessState;
> 
> There is no need for TextTrack:: prefix here.
>
Fixed.
Comment 5 Eric Carlson 2011-12-01 08:48:14 PST
http://trac.webkit.org/changeset/101673