Bug 79368 - Update TextTrackCue API
Summary: Update TextTrackCue API
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: 2012-02-23 08:46 PST by Eric Carlson
Modified: 2012-02-24 16:59 PST (History)
7 users (show)

See Also:


Attachments
Proposed patch (53.60 KB, patch)
2012-02-23 12:00 PST, Eric Carlson
no flags Details | Formatted Diff | Diff
Updated patch. (53.72 KB, patch)
2012-02-24 11:47 PST, Eric Carlson
no flags Details | Formatted Diff | Diff
Updated patch. (55.39 KB, patch)
2012-02-24 13:51 PST, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2012-02-23 08:46:22 PST
https://www.w3.org/Bugs/Public/show_bug.cgi?id=14929 changed TextTrackCue.alignment to .align, TextTrackCue.linePosition and .textPosition to .line
and .position, and TextTrackCue.direction to .vertical.
Comment 1 Radar WebKit Bug Importer 2012-02-23 08:46:57 PST
<rdar://problem/10918891>
Comment 2 Eric Carlson 2012-02-23 10:55:53 PST
And the possible values for direction changed as well: "horizontal" -> "","vertical" - > "rl", "vertical-lr" -> "lr"
Comment 3 Eric Carlson 2012-02-23 12:00:06 PST
Created attachment 128526 [details]
Proposed patch
Comment 4 Adam Barth 2012-02-24 10:02:28 PST
Comment on attachment 128526 [details]
Proposed patch

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

> Source/WebCore/html/track/TextTrackCue.cpp:70
> -    DEFINE_STATIC_LOCAL(const AtomicString, horizontal, ("horizontal"));
> +    DEFINE_STATIC_LOCAL(const AtomicString, horizontal, (""));
>      return horizontal;

Why not just use emptyString() ?  There's already a global static for the empty string.
Comment 5 Eric Carlson 2012-02-24 11:38:27 PST
(In reply to comment #4)
> (From update of attachment 128526 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=128526&action=review
> 
> > Source/WebCore/html/track/TextTrackCue.cpp:70
> > -    DEFINE_STATIC_LOCAL(const AtomicString, horizontal, ("horizontal"));
> > +    DEFINE_STATIC_LOCAL(const AtomicString, horizontal, (""));
> >      return horizontal;
> 
> Why not just use emptyString() ?  There's already a global static for the empty string.

I initially tried to just "return emptyString()", but that doesn't work:

error: returning reference to local temporary object [-Werror,-Wreturn-stack-address]
    return emptyString();
           ^~~~~~~~~~~~~
1 error generated.

If you mean I should initialize my static with emptyString(), I can do that.
Comment 6 Adam Barth 2012-02-24 11:45:00 PST
From WTFString.cpp:

const String& emptyString()
{
    DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty()));
    return emptyString;
}
Comment 7 Adam Barth 2012-02-24 11:45:47 PST
Comment on attachment 128526 [details]
Proposed patch

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

> Source/WebCore/html/track/TextTrackCue.cpp:67
>  static const AtomicString& horizontalKeyword()

Ah, the problem is that you're returning an AtomicString rather than a String.  Do we have an emptyAtomicString() ?
Comment 8 Eric Carlson 2012-02-24 11:47:01 PST
Created attachment 128777 [details]
Updated patch.
Comment 9 Eric Seidel (no email) 2012-02-24 11:47:15 PST
Comment on attachment 128526 [details]
Proposed patch

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

> Source/WebCore/html/track/TextTrackCue.cpp:67
>  static const AtomicString& horizontalKeyword()

The two uses in this patch use this as a String& instead of an AtomicString&.  Doesn't really matter, but it's possible that those uses would want to be AtomicStrings themselves to get the benifit of AtomicString.

> Source/WebCore/html/track/TextTrackCue.cpp:210
>      if (value == horizontalKeyword())
>          direction = Horizontal;

So now the value must be empty to mean horizongal?  Does it ignore leading/trailing spaces?
Comment 10 Eric Carlson 2012-02-24 13:51:43 PST
Created attachment 128800 [details]
Updated patch.
Comment 11 Eric Carlson 2012-02-24 13:55:24 PST
(In reply to comment #9)
> (From update of attachment 128526 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=128526&action=review
> 
> > Source/WebCore/html/track/TextTrackCue.cpp:67
> >  static const AtomicString& horizontalKeyword()
> 
> The two uses in this patch use this as a String& instead of an AtomicString&.  Doesn't really matter, but it's possible that those uses would want to be AtomicStrings themselves to get the benifit of AtomicString.
> 
Good point, I updated the static functions to all return Strings.


> > Source/WebCore/html/track/TextTrackCue.cpp:210
> >      if (value == horizontalKeyword())
> >          direction = Horizontal;
> 
> So now the value must be empty to mean horizongal?  Does it ignore leading/trailing spaces?

The spec says [1]:

On setting, the text track cue writing direction must be set to the value given in the first cell of the row in the table above whose second cell is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception. 

The second cell in the table is: "" (the empty string)

[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical
Comment 12 Eric Seidel (no email) 2012-02-24 13:59:53 PST
Comment on attachment 128800 [details]
Updated patch.

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

I feel a bit under-informed on this effort, so I fear I'm just picking at nits.  I'm comfortable rubber-stamping this change though, I trust your awareness of the spec.

> Source/WebCore/html/track/TextTrackCue.cpp:423
> +            if (writingDirection == verticalKeywordOLD())

We've historically used deprecated() for this sort of thing, but it's not clear (to me at least) what the proper replacement function is.  Will we always have these OLD() functions around?
Comment 13 Eric Carlson 2012-02-24 14:56:57 PST
(In reply to comment #12)
> (From update of attachment 128800 [details])
> > Source/WebCore/html/track/TextTrackCue.cpp:423
> > +            if (writingDirection == verticalKeywordOLD())
> 
> We've historically used deprecated() for this sort of thing, but it's not clear (to me at least) what the proper replacement function is.  Will we always have these OLD() functions around?

No, the implementation of those functions both have this comment:

// FIXME: remove this once https://bugs.webkit.org/show_bug.cgi?id=78706 has been fixed.

Thanks for the review!
Comment 14 WebKit Review Bot 2012-02-24 16:59:11 PST
Comment on attachment 128800 [details]
Updated patch.

Clearing flags on attachment: 128800

Committed r108872: <http://trac.webkit.org/changeset/108872>
Comment 15 WebKit Review Bot 2012-02-24 16:59:16 PST
All reviewed patches have been landed.  Closing bug.