gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] TextField implementation improvements


From: Benjamin Wolsey
Subject: [Gnash-commit] TextField implementation improvements
Date: Fri, 31 Jul 2009 12:39:25 +0200

Some things that would be easy to implement in TextField:

> === modified file 'testsuite/actionscript.all/TextField.as'
> --- a/testsuite/actionscript.all/TextField.as 2009-07-09 09:40:13 +0000
> +++ b/testsuite/actionscript.all/TextField.as 2009-07-31 05:37:51 +0000
> @@ -504,14 +504,34 @@
>  
>  xcheck_equals(typeof(tf.restrict), 'null');
>  check(!tf.hasOwnProperty('restrict'));
> +xcheck_equals(typeof(tf.restrict), 'null');

restrict is null until it's set, and can also be reset to null. If it's
set to an empty string, it returns an empty string, not null (other
properties *do* return null in this case).

> === modified file 'testsuite/actionscript.all/TextFieldHTML.as'
> --- a/testsuite/actionscript.all/TextFieldHTML.as     2009-07-30 08:31:32 
> +0000
> +++ b/testsuite/actionscript.all/TextFieldHTML.as     2009-07-31 05:23:22 
> +0000
> @@ -88,38 +88,35 @@
>  // WARNING!! The disabled code crashes Gnash at the moment.
>  // When that's fixed, this code can be reenabled to get the totals() pass,
>  // and the failures in this section (only!) can be expected.
> -#if 0

If getTextFormat returned the correct text colour here, this test would
be more useful. Currently Gnash will still get the wrong colour values
for many of these tests, but handling the corner cases only requires a
few minor changes to the current code. I was nice and added comments to
the test. 

>  
>   // A color string that is this short doesn't change the color.
>   tf.htmlText = '<font color="#ff">too short</font>';
> - check_equals(tf.text, "too short");
> + xcheck_equals(tf.text, "too short");
>   format = tf.getTextFormat(1, 4);
> - check_equals(format.color, 0x0000ff);
> + xcheck_equals(format.color, 0x0000ff);
>  
>   // When it's three characters it does change the color.
>   tf.htmlText = '<font color="#ff0">a bit short</font>';
> - check_equals(tf.text, "a bit short");
> + xcheck_equals(tf.text, "a bit short");
>   format = tf.getTextFormat(1, 4);
> - check_equals(format.color, 0x000ff0);
> + xcheck_equals(format.color, 0x000ff0);
>   
>   // Without a hash it sets the color to black.
>   tf.htmlText = '<font color="ff00ff">no hash</font>';
> - check_equals(tf.text, "no hash");
> + xcheck_equals(tf.text, "no hash");
>   format = tf.getTextFormat(1, 4);
>   check_equals(format.color, 0);
>  
>   tf.htmlText = '<font color="hi">no hash 2</font>';
> - check_equals(tf.text, "no hash 2");
> + xcheck_equals(tf.text, "no hash 2");
>   format = tf.getTextFormat(1, 4);
>   check_equals(format.color, 0);
>  
>   tf.htmlText = '<font color="">empty</font>';
> - check_equals(tf.text, "empty");
> + xcheck_equals(tf.text, "empty");
>   format = tf.getTextFormat(1, 4);
>   check_equals(format.color, 0);
>  

Things like: if there's no hash (including if the string is empty), the
colour seems always to be set to black. If the string is shorter than
hash + three characters, the colour is left as it was before.

>   // Extra long strings are truncated, but the end counts, not the beginning.
>   tf.htmlText = '<font color="#ff00ffffee">long</font>';
>   xcheck_equals(tf.text, "long");

The current code reads from the beginning of the string; it should
apparently take the last 6 characters.

There are more things to learn from the other tests in that file.
Perhaps most importantly, setting the TextField.text property never gets
parsed as HTML. HTML is *only* parsed when the html property is true
*and* the text is set using htmlText.

bwy

--
The current release of Gnash is 0.8.5
http://www.gnu.org/software/gnash/

Benjamin Wolsey, Software Developer - http://benjaminwolsey.de

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


reply via email to

[Prev in Thread] Current Thread [Next in Thread]