- From: Brendan Long <self@brendanlong.com>
- Date: Mon, 10 Feb 2014 15:31:39 -0600
- To: public-html@w3.org
- Message-ID: <1392067899.2647.13.camel@blong-desktop>
I've been working on implementing the DataCue interface in WebKit, and I have some questions. According to this, .text can be null: > The text attribute, on getting, must return UTF-16 text converted from > data of the text track cue that the TextTrackCue object represents. If > a conversion of the content in data is not possible, e.g. because the > UA is unable to identify the encoding, it must return null. So shouldn't the WebIDL say "DOMString?" with a question mark to indicate that it's nullable? The other question is, is there a general rule where we take a copy of objects in constructors? Otherwise we get weird behavior like this: > > buf = new ArrayBuffer(4) > < ArrayBuffer > > > bufView = new Uint16Array(buf) > < [0, 0] > > bufView[0] = "hi".charCodeAt(0=) > < 104 > > bufView[1] = "hi".charCodeAt(1) > < 105 > > > cue = new DataCue(1, 2, buf) > < DataCue > > > cue.text > < "hi" > > bufView[0] = "no".charCodeAt(0) > < 110 > > bufView[1] = "no".charCodeAt(1) > < 111 > > cue.text > < "no" I'm not sure if I was implementing this wrong, or if we need to change the spec to specify that .data is a copy of the ArrayBuffer we give it. --=-Pm3MARjRlI6QoBeTpxVc Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8"> <META NAME="GENERATOR" CONTENT="GtkHTML/4.6.6"> </HEAD> <BODY> I've been working on implementing the <A HREF="http://www.w3.org/html/wg/drafts/html/CR/embedded-content-0.html">DataCue interface</A> in WebKit, and I have some questions.<BR> <BR> According to this, .text can be null:<BR> <BLOCKQUOTE TYPE=CITE> The <TT>text</TT> attribute, on getting, must return UTF-16 text converted from <TT><A HREF="http://www.w3.org/html/wg/drafts/html/CR/text-level-semantics.html#the-data-element">data</A></TT> of the <A HREF="http://www.w3.org/html/wg/drafts/html/CR/embedded-content-0.html#text-track-cue">text track cue</A> that the <TT><A HREF="http://www.w3.org/html/wg/drafts/html/CR/embedded-content-0.html#texttrackcue">TextTrackCue</A></TT> object represents. If a conversion of the content in <TT><A HREF="http://www.w3.org/html/wg/drafts/html/CR/text-level-semantics.html#the-data-element">data</A></TT> is not possible, e.g. because the UA is unable to identify the encoding, it must return null.<BR> </BLOCKQUOTE> So shouldn't the WebIDL say "DOMString?" with a question mark <A HREF="http://www.w3.org/TR/WebIDL/">to indicate that it's nullable</A>?<BR> <BR> The other question is, is there a general rule where we take a copy of objects in constructors? Otherwise we get weird behavior like this: <BLOCKQUOTE TYPE=CITE> <PRE> > buf = new ArrayBuffer(4) < ArrayBuffer > bufView = new Uint16Array(buf) < [0, 0] > bufView[0] = "hi".charCodeAt(0=) < 104 > bufView[1] = "hi".charCodeAt(1) < 105 > cue = new DataCue(1, 2, buf) < DataCue > cue.text < "hi" > bufView[0] = "no".charCodeAt(0) < 110 > bufView[1] = "no".charCodeAt(1) < 111 > cue.text < "no" </PRE> </BLOCKQUOTE> I'm not sure if I was implementing this wrong, or if we need to change the spec to specify that .data is a copy of the ArrayBuffer we give it. </BODY> </HTML> --=-Pm3MARjRlI6QoBeTpxVc--
Received on Monday, 10 February 2014 21:32:17 UTC