[Swfdec] 6 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_codec_audio.c libswfdec/swfdec_codec_video.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_field_movie.h libswfdec/swfdec_text_format.c libswfdec/swfdec_text_format.h

Pekka Lampila medar at kemper.freedesktop.org
Mon Oct 15 02:33:54 PDT 2007


 libswfdec/swfdec_as_strings.c          |    8 +
 libswfdec/swfdec_codec_audio.c         |    1 
 libswfdec/swfdec_codec_video.c         |    1 
 libswfdec/swfdec_text_field.c          |   74 +++++----
 libswfdec/swfdec_text_field.h          |    5 
 libswfdec/swfdec_text_field_movie.c    |  140 +++++++++++++++---
 libswfdec/swfdec_text_field_movie.h    |   26 ---
 libswfdec/swfdec_text_field_movie_as.c |  247 ++++++++++++++++++++++++++++-----
 libswfdec/swfdec_text_format.c         |   67 ++++++++
 libswfdec/swfdec_text_format.h         |    4 
 10 files changed, 464 insertions(+), 109 deletions(-)

New commits:
commit d964fa7f3b9b06dc6af4bb62cd64ff473714c543
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 15 12:33:43 2007 +0300

    Fix compile warnings in swfdec_video_decoder_new and swfdec_audio_decoder_new

diff --git a/libswfdec/swfdec_codec_audio.c b/libswfdec/swfdec_codec_audio.c
index bdf33f3..7c4ab8a 100644
--- a/libswfdec/swfdec_codec_audio.c
+++ b/libswfdec/swfdec_codec_audio.c
@@ -160,6 +160,7 @@ swfdec_audio_decoder_new (SwfdecAudioCodec codec, SwfdecAudioFormat format)
     list = g_getenv ("SWFDEC_CODEC");
   if (list == NULL) {
     guint i;
+    ret = NULL;
     for (i = 0; audio_codecs[i].name != NULL; i++) {
       ret = audio_codecs[i].func (codec, format);
       if (ret)
diff --git a/libswfdec/swfdec_codec_video.c b/libswfdec/swfdec_codec_video.c
index bdcce56..291c24d 100644
--- a/libswfdec/swfdec_codec_video.c
+++ b/libswfdec/swfdec_codec_video.c
@@ -73,6 +73,7 @@ swfdec_video_decoder_new (SwfdecVideoCodec codec)
     list = g_getenv ("SWFDEC_CODEC");
   if (list == NULL) {
     guint i;
+    ret = NULL;
     for (i = 0; video_codecs[i].name != NULL; i++) {
       ret = video_codecs[i].func (codec);
       if (ret)
commit 3247196e467bdeafa5414229bdfd4722ac071ce9
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 15 12:30:58 2007 +0300

    Make TextField setTextFormat merge any styles that become equal

diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index d6e89e9..e40001f 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -686,7 +686,7 @@ void
 swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text,
     SwfdecTextFormat *format, guint start_index, guint end_index)
 {
-  SwfdecFormatIndex *findex, *findex_new;
+  SwfdecFormatIndex *findex, *findex_new, *findex_prev;
   guint findex_end_index;
   GSList *iter, *next;
 
@@ -698,10 +698,13 @@ swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text,
   g_assert (text->formats != NULL);
   g_assert (text->formats->data != NULL);
   g_assert (((SwfdecFormatIndex *)text->formats->data)->index == 0);
+
+  findex = NULL;
   for (iter = text->formats; iter != NULL &&
       ((SwfdecFormatIndex *)iter->data)->index < end_index;
       iter = next)
   {
+    findex_prev = findex;
     next = iter->next;
     findex = iter->data;
     if (iter->next != NULL) {
@@ -714,6 +717,9 @@ swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text,
     if (findex_end_index < start_index)
       continue;
 
+    if (swfdec_text_format_equal_or_undefined (findex->format, format))
+      continue;
+
     if (findex_end_index > end_index) {
       findex_new = g_new (SwfdecFormatIndex, 1);
       findex_new->index = end_index;
@@ -729,8 +735,25 @@ swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text,
       swfdec_text_format_add (findex_new->format, format);
 
       iter = g_slist_insert (iter, findex_new, 1);
+      findex = findex_new;
     } else {
       swfdec_text_format_add (findex->format, format);
+
+      // if current format now equals previous one, remove current
+      if (findex_prev != NULL &&
+	  swfdec_text_format_equal (findex->format, findex_prev->format)) {
+	text->formats = g_slist_remove (text->formats, findex);
+	findex = findex_prev;
+      }
+    }
+
+    // if current format now equals the next one, remove current
+    if (findex_end_index <= end_index && next != NULL &&
+	swfdec_text_format_equal (findex->format,
+	  ((SwfdecFormatIndex *)next->data)->format))
+    {
+      text->formats = g_slist_remove (text->formats, findex);
+      findex = findex_prev;
     }
   }
 
diff --git a/libswfdec/swfdec_text_format.c b/libswfdec/swfdec_text_format.c
index f507b86..3a12605 100644
--- a/libswfdec/swfdec_text_format.c
+++ b/libswfdec/swfdec_text_format.c
@@ -947,6 +947,73 @@ swfdec_text_format_add (SwfdecTextFormat *format, const SwfdecTextFormat *from)
   format->values_set |= from->values_set;
 }
 
+gboolean
+swfdec_text_format_equal_or_undefined (const SwfdecTextFormat *a,
+    const SwfdecTextFormat *b)
+{
+  int set;
+
+  set = a->values_set & b->values_set;
+
+  g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (a), FALSE);
+  g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (b), FALSE);
+
+  if (set & (1 << PROP_ALIGN) && a->align != b->align)
+    return FALSE;
+  if (set & (1 << PROP_BLOCK_INDENT) && a->block_indent != b->block_indent)
+    return FALSE;
+  if (set & (1 << PROP_BOLD) && a->bold != b->bold)
+    return FALSE;
+  if (set & (1 << PROP_BULLET) && a->bullet != b->bullet)
+    return FALSE;
+  if (set & (1 << PROP_COLOR) && a->color != b->color)
+    return FALSE;
+  if (set & (1 << PROP_DISPLAY) && a->display != b->display)
+    return FALSE;
+  if (set & (1 << PROP_FONT) && a->font != b->font)
+    return FALSE;
+  if (set & (1 << PROP_INDENT) && a->indent != b->indent)
+    return FALSE;
+  if (set & (1 << PROP_ITALIC) && a->italic != b->italic)
+    return FALSE;
+  if (set & (1 << PROP_KERNING) && a->kerning != b->kerning)
+    return FALSE;
+  if (set & (1 << PROP_LEADING) && a->leading != b->leading)
+    return FALSE;
+  if (set & (1 << PROP_LEFT_MARGIN) && a->left_margin != b->left_margin)
+    return FALSE;
+  if (set & (1 << PROP_LETTER_SPACING) &&
+      a->letter_spacing != b->letter_spacing) {
+    return FALSE;
+  }
+  if (set & (1 << PROP_RIGHT_MARGIN) && a->right_margin != b->right_margin)
+    return FALSE;
+  if (set & (1 << PROP_SIZE) && a->size != b->size)
+    return FALSE;
+  if (set & (1 << PROP_TAB_STOPS) && a->tab_stops != b->tab_stops)
+    return FALSE;
+  if (set & (1 << PROP_TARGET) && a->target != b->target)
+    return FALSE;
+  if (set & (1 << PROP_UNDERLINE) && a->underline != b->underline)
+    return FALSE;
+  if (set & (1 << PROP_URL) && a->url != b->url)
+    return FALSE;
+
+  return TRUE;
+}
+
+gboolean
+swfdec_text_format_equal (const SwfdecTextFormat *a, const SwfdecTextFormat *b)
+{
+  g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (a), FALSE);
+  g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (b), FALSE);
+
+  if (a->values_set != b->values_set)
+    return FALSE;
+
+  return swfdec_text_format_equal_or_undefined (a, b);
+}
+
 void
 swfdec_text_format_set_defaults (SwfdecTextFormat *format)
 {
diff --git a/libswfdec/swfdec_text_format.h b/libswfdec/swfdec_text_format.h
index 9fc7cee..6726b43 100644
--- a/libswfdec/swfdec_text_format.h
+++ b/libswfdec/swfdec_text_format.h
@@ -89,6 +89,10 @@ void		swfdec_text_format_set_defaults	(SwfdecTextFormat *	format);
 SwfdecTextFormat * swfdec_text_format_copy	(const SwfdecTextFormat *copy_from);
 void		swfdec_text_format_add		(SwfdecTextFormat *	format,
 						 const SwfdecTextFormat *from);
+gboolean	swfdec_text_format_equal	(const SwfdecTextFormat *a,
+						 const SwfdecTextFormat *b);
+gboolean	swfdec_text_format_equal_or_undefined	(const SwfdecTextFormat *a,
+						 const SwfdecTextFormat *b);
 
 G_END_DECLS
 #endif
commit 5dbe5e92642672a4514158331785204edfc619d9
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 15 12:18:19 2007 +0300

    TextField: Render first visible line, even if it doesn't fit completely

diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
index e848c90..a594bbd 100644
--- a/libswfdec/swfdec_text_field.c
+++ b/libswfdec/swfdec_text_field.c
@@ -276,6 +276,7 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
   SwfdecRect limit;
   SwfdecColor color;
   int i, y, x, linenum;
+  gboolean first;
 
   g_return_if_fail (SWFDEC_IS_TEXT_FIELD (text));
   g_return_if_fail (cr != NULL);
@@ -308,6 +309,7 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
   layouts = swfdec_text_field_generate_layouts (text, cr, paragraphs, trans,
       inval, NULL);
 
+  first = TRUE;
   linenum = 0;
   x = SWFDEC_GRAPHIC (text)->extents.x0;
   y = SWFDEC_GRAPHIC (text)->extents.y0 + 1;
@@ -334,10 +336,15 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
       if (linenum == text->scroll)
 	skipped = rect.y;
 
-      if (y + rect.y > limit.y1 ||
+      if (!first &&
 	  y + rect.y + rect.height > SWFDEC_GRAPHIC (text)->extents.y1)
 	break;
 
+      first = FALSE;
+
+      if (y + rect.y > limit.y1)
+	break;
+
       if (y + rect.y + rect.height < limit.y0 ||
 	  x + layout->render_offset_x + rect.x > limit.x1 ||
 	  x + layout->render_offset_x + rect.x + rect.width < limit.x0)
commit 971e4423bd5d8656d1be8b8d6ba70a15a325a1d6
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 15 11:07:28 2007 +0300

    More TextField code cleanup

diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index 11540ba..d6e89e9 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -364,9 +364,6 @@ swfdec_text_field_movie_free_paragraphs (SwfdecTextFieldMovie *text)
   }
 }
 
-static cairo_surface_t *surface = NULL;
-static cairo_t *cr = NULL;
-
 static SwfdecLayout *
 swfdec_text_field_movie_get_layouts (SwfdecTextFieldMovie *text, int *num)
 {
@@ -375,14 +372,7 @@ swfdec_text_field_movie_get_layouts (SwfdecTextFieldMovie *text, int *num)
   if (text->paragraphs == NULL)
     swfdec_text_field_movie_generate_paragraphs (text);
 
-  // FIXME: Temporary using image surface, until there is a way to get cairo_t
-  // outside the rendering functions
-  g_assert (surface == NULL);
-  g_assert (cr == NULL);
-  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
-  cr = cairo_create (surface);
-
-  return swfdec_text_field_generate_layouts (text->text, cr,
+  return swfdec_text_field_generate_layouts (text->text, text->cr,
       text->paragraphs, NULL, NULL, num);
 }
 
@@ -398,14 +388,6 @@ swfdec_text_field_movie_free_layouts (SwfdecLayout *layouts)
   }
 
   g_free (layouts);
-
-  g_assert (cr != NULL);
-  g_assert (surface != NULL);
-
-  cairo_destroy (cr);
-  cr = NULL;
-  cairo_surface_destroy (surface);
-  surface = NULL;
 }
 
 void
@@ -551,6 +533,9 @@ swfdec_text_field_movie_dispose (GObject *object)
   }
   g_slist_free (text->formats);
 
+  cairo_destroy (text->cr);
+  cairo_surface_destroy (text->surface);
+
   G_OBJECT_CLASS (swfdec_text_field_movie_parent_class)->dispose (object);
 }
 
@@ -693,6 +678,8 @@ swfdec_text_field_movie_class_init (SwfdecTextFieldMovieClass * g_class)
 static void
 swfdec_text_field_movie_init (SwfdecTextFieldMovie *text)
 {
+  text->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+  text->cr = cairo_create (text->surface);
 }
 
 void
diff --git a/libswfdec/swfdec_text_field_movie.h b/libswfdec/swfdec_text_field_movie.h
index f394747..d7bbb03 100644
--- a/libswfdec/swfdec_text_field_movie.h
+++ b/libswfdec/swfdec_text_field_movie.h
@@ -63,6 +63,11 @@ struct _SwfdecTextFieldMovie {
   SwfdecColor		border_color;
   SwfdecColor		background_color;
 
+  // FIXME: Temporary using image surface, until there is a way to get cairo_t
+  // outside the rendering functions
+  cairo_surface_t *	surface;
+  cairo_t *		cr;
+
   /* for rendering */
   SwfdecParagraph *	paragraphs;
 };
commit 251eb0e0a313a7ebf017e4f17105b96fedf77e4a
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 15 10:59:29 2007 +0300

    Cleaned up some TextField code. Added and fixed properties
    
    Added properties: multiline, type, scroll
    Fixed length property to work with UTF strings correctly
    Changed the handling of PangoLayouts somewhat (WIP)
    Removed some cruft from swfdec_text_field_movie.h

diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index a58a1e8..957f484 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -400,5 +400,10 @@ const char swfdec_as_strings[] =
   SWFDEC_AS_CONSTANT_STRING ("background")
   SWFDEC_AS_CONSTANT_STRING ("backgroundColor")
   SWFDEC_AS_CONSTANT_STRING ("borderColor")
+  SWFDEC_AS_CONSTANT_STRING ("multiline")
+  SWFDEC_AS_CONSTANT_STRING ("type")
+  SWFDEC_AS_CONSTANT_STRING ("input")
+  SWFDEC_AS_CONSTANT_STRING ("dynamic")
+  SWFDEC_AS_CONSTANT_STRING ("scroll")
   /* add more here */
 ;
diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
index 214e338..e848c90 100644
--- a/libswfdec/swfdec_text_field.c
+++ b/libswfdec/swfdec_text_field.c
@@ -82,25 +82,24 @@ swfdec_text_field_class_init (SwfdecTextFieldClass * g_class)
 static void
 swfdec_text_field_init (SwfdecTextField * text)
 {
+  text->scroll = 1;
   text->max_length = G_MAXUINT;
 }
 
-GList *
+SwfdecLayout *
 swfdec_text_field_generate_layouts (SwfdecTextField *text, cairo_t *cr,
     const SwfdecParagraph *paragraphs, const SwfdecColorTransform *trans,
-    const SwfdecRect *inval)
+    const SwfdecRect *inval, int *num)
 {
-  GList *layouts;
+  GArray *layouts;
   guint i;
 
   g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD (text), NULL);
   g_return_val_if_fail (cr != NULL, NULL);
   g_return_val_if_fail (paragraphs != NULL, NULL);
 
-  if (paragraphs[0].text == NULL)
-    return NULL;
+  layouts = g_array_new (TRUE, TRUE, sizeof (SwfdecLayout));
 
-  layouts = NULL;
   for (i = 0; paragraphs[i].text != NULL; i++)
   {
     GList *iter;
@@ -109,7 +108,7 @@ swfdec_text_field_generate_layouts (SwfdecTextField *text, cairo_t *cr,
     skip = 0;
     for (iter = paragraphs[i].blocks; iter != NULL; iter = iter->next)
     {
-      SwfdecLayout *layout;
+      SwfdecLayout layout;
       PangoLayout *playout;
       int width;
       guint length;
@@ -129,12 +128,10 @@ swfdec_text_field_generate_layouts (SwfdecTextField *text, cairo_t *cr,
       }
 
       // create layout
-      layout = g_new0 (SwfdecLayout, 1);
-      playout = layout->layout = pango_cairo_create_layout (cr);
-      layouts = g_list_append (layouts, layout);
+      playout = layout.layout = pango_cairo_create_layout (cr);
 
       // set rendering position
-      layout->render_offset_x = block->left_margin + block->block_indent;
+      layout.render_offset_x = block->left_margin + block->block_indent;
       width = SWFDEC_GRAPHIC (text)->extents.x1 -
 	SWFDEC_GRAPHIC (text)->extents.x0 - block->left_margin -
 	block->right_margin - block->block_indent;
@@ -143,7 +140,7 @@ swfdec_text_field_generate_layouts (SwfdecTextField *text, cairo_t *cr,
 	// limit negative indent to not go over leftMargin + blockIndent
 	int indent = MAX (paragraphs[i].indent / PANGO_SCALE,
 	    -(block->left_margin + block->block_indent));
-	layout->render_offset_x += indent;
+	layout.render_offset_x += indent;
 	width += -indent;
       }
 
@@ -240,9 +237,9 @@ swfdec_text_field_generate_layouts (SwfdecTextField *text, cairo_t *cr,
 	  pango_layout_get_pixel_size (playout, &line_width, 0);
 	  if (line_width < width) {
 	    if (block->align == PANGO_ALIGN_RIGHT) {
-	      layout->render_offset_x += width - line_width;
+	      layout.render_offset_x += width - line_width;
 	    } else if (block->align == PANGO_ALIGN_CENTER) {
-	      layout->render_offset_x += (width - line_width) / 2;
+	      layout.render_offset_x += (width - line_width) / 2;
 	    } else {
 	      g_assert_not_reached ();
 	    }
@@ -252,16 +249,21 @@ swfdec_text_field_generate_layouts (SwfdecTextField *text, cairo_t *cr,
 	skip = 0;
       }
 
-      pango_layout_get_pixel_size (playout, &layout->width, &layout->height);
-      layout->width += layout->render_offset_x + block->right_margin;
-      layout->height += block->leading / PANGO_SCALE;
+      pango_layout_get_pixel_size (playout, &layout.width, &layout.height);
+      layout.width += layout.render_offset_x + block->right_margin;
+      layout.height += block->leading / PANGO_SCALE;
+
+      layouts = g_array_append_val (layouts, layout);
 
       if (!text->word_wrap)
 	break;
     }
   }
 
-  return layouts;
+  if (num != NULL)
+    *num = layouts->len;
+
+  return (SwfdecLayout *)g_array_free (layouts, FALSE);
 }
 
 void
@@ -270,10 +272,10 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
     SwfdecColor background_color, const SwfdecColorTransform *trans,
     const SwfdecRect *inval)
 {
-  GList *layouts, *iter;
+  SwfdecLayout *layouts;
   SwfdecRect limit;
   SwfdecColor color;
-  int y, x, linenum;
+  int i, y, x, linenum;
 
   g_return_if_fail (SWFDEC_IS_TEXT_FIELD (text));
   g_return_if_fail (cr != NULL);
@@ -304,16 +306,16 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
   }
 
   layouts = swfdec_text_field_generate_layouts (text, cr, paragraphs, trans,
-      inval);
+      inval, NULL);
 
   linenum = 0;
   x = SWFDEC_GRAPHIC (text)->extents.x0;
   y = SWFDEC_GRAPHIC (text)->extents.y0 + 1;
   cairo_move_to (cr, x, y);
 
-  for (iter = layouts; iter != NULL && y < limit.y1; iter = iter->next)
+  for (i = 0; layouts[i].layout != NULL && y < limit.y1; i++)
   {
-    SwfdecLayout *layout = (SwfdecLayout *)iter->data;
+    SwfdecLayout *layout = &layouts[i];
     PangoLayoutIter *iter_line;
     PangoLayoutLine *line;
     PangoRectangle rect;
@@ -323,13 +325,13 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
 
     skipped = 0;
     do {
-      if (++linenum < text->scroll + 1)
+      if (++linenum < text->scroll)
 	continue;
 
       pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
       pango_extents_to_pixels (NULL, &rect);
 
-      if (linenum == text->scroll + 1)
+      if (linenum == text->scroll)
 	skipped = rect.y;
 
       if (y + rect.y > limit.y1 ||
@@ -349,23 +351,18 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
 	  -(pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE - skipped));
     } while (pango_layout_iter_next_line (iter_line));
 
-    if (linenum >= text->scroll + 1) {
+    if (linenum >= text->scroll) {
       cairo_rel_move_to (cr, 0, layout->height - skipped);
       y += layout->height - skipped;
       skipped = 0;
     }
   }
 
-  for (iter = layouts; iter != NULL; iter = iter->next)
-  {
-    SwfdecLayout *layout = (SwfdecLayout *)iter->data;
-
-    g_object_unref (layout->layout);
-    g_free (layout);
-    iter->data = NULL;
+  for (i = 0; layouts[i].layout != NULL; i++) {
+    g_object_unref (layouts[i].layout);
   }
 
-  g_list_free (layouts);
+  g_free (layouts);
 }
 
 
diff --git a/libswfdec/swfdec_text_field.h b/libswfdec/swfdec_text_field.h
index 938dbfd..1609a52 100644
--- a/libswfdec/swfdec_text_field.h
+++ b/libswfdec/swfdec_text_field.h
@@ -123,11 +123,12 @@ GType			swfdec_text_field_get_type	(void);
 int			tag_func_define_edit_text	(SwfdecSwfDecoder *	s,
 							 guint			tag);
 
-GList *			swfdec_text_field_generate_layouts	(SwfdecTextField *	text,
+SwfdecLayout *		swfdec_text_field_generate_layouts	(SwfdecTextField *	text,
 							 cairo_t *			cr,
 							 const SwfdecParagraph *	paragraphs,
 							 const SwfdecColorTransform *	trans,
-							 const SwfdecRect *		inval);
+							 const SwfdecRect *		inval,
+							 int *				num);
 void			swfdec_text_field_render		(SwfdecTextField *	text,
 							 cairo_t *		cr,
 							 const SwfdecParagraph *	paragraphs,
diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index 3fe67ea..11540ba 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -364,14 +364,107 @@ swfdec_text_field_movie_free_paragraphs (SwfdecTextFieldMovie *text)
   }
 }
 
+static cairo_surface_t *surface = NULL;
+static cairo_t *cr = NULL;
+
+static SwfdecLayout *
+swfdec_text_field_movie_get_layouts (SwfdecTextFieldMovie *text, int *num)
+{
+  g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), NULL);
+
+  if (text->paragraphs == NULL)
+    swfdec_text_field_movie_generate_paragraphs (text);
+
+  // FIXME: Temporary using image surface, until there is a way to get cairo_t
+  // outside the rendering functions
+  g_assert (surface == NULL);
+  g_assert (cr == NULL);
+  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+  cr = cairo_create (surface);
+
+  return swfdec_text_field_generate_layouts (text->text, cr,
+      text->paragraphs, NULL, NULL, num);
+}
+
+static void
+swfdec_text_field_movie_free_layouts (SwfdecLayout *layouts)
+{
+  int i;
+
+  g_return_if_fail (layouts != NULL);
+
+  for (i = 0; layouts[i].layout != NULL; i++) {
+    g_object_unref (layouts[i].layout);
+  }
+
+  g_free (layouts);
+
+  g_assert (cr != NULL);
+  g_assert (surface != NULL);
+
+  cairo_destroy (cr);
+  cr = NULL;
+  cairo_surface_destroy (surface);
+  surface = NULL;
+}
+
+void
+swfdec_text_field_movie_set_scroll (SwfdecTextFieldMovie *text, int value)
+{
+  SwfdecLayout *layouts;
+  int i, num, y, visible, all, height;
+
+  g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+
+  layouts = swfdec_text_field_movie_get_layouts (text, &num);
+
+  height = SWFDEC_GRAPHIC (text->text)->extents.y1 -
+    SWFDEC_GRAPHIC (text->text)->extents.y0;
+  y = 0;
+  all = 0;
+  visible = 0;
+
+  for (i = num - 1; i >= 0; i--)
+  {
+    SwfdecLayout *layout = &layouts[i];
+    PangoLayoutIter *iter_line;
+    PangoRectangle rect;
+
+    y += layout->height;
+
+    iter_line = pango_layout_get_iter (layout->layout);
+
+    do {
+      pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
+      pango_extents_to_pixels (NULL, &rect);
+
+      if (y - rect.y <= height)
+	visible++;
+
+      all++;
+    } while (pango_layout_iter_next_line (iter_line));
+  }
+
+  swfdec_text_field_movie_free_layouts (layouts);
+
+  if (value < 1) {
+    value = 1;
+  } else if (value > all - visible + 1) {
+    value = all - visible + 1;
+  }
+
+  if (text->text->scroll != value) {
+    text->text->scroll = value;
+    swfdec_movie_invalidate (SWFDEC_MOVIE (text));
+  }
+}
+
 static gboolean
 swfdec_text_field_movie_auto_size (SwfdecTextFieldMovie *text)
 {
-  cairo_surface_t *surface;
-  cairo_t *cr;
-  GList *layouts, *iter;
+  SwfdecLayout *layouts;
   guint height;
-  int width, diff;
+  int i, width, diff;
   gboolean changed;
 
   g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), FALSE);
@@ -379,30 +472,21 @@ swfdec_text_field_movie_auto_size (SwfdecTextFieldMovie *text)
   if (text->text->auto_size == SWFDEC_AUTO_SIZE_NONE)
     return FALSE;
 
-  if (text->paragraphs == NULL)
-    swfdec_text_field_movie_generate_paragraphs (text);
-
-  // FIXME: Temporary using image surface, until there is a way to get cairo_t
-  // outside the rendering functions
-  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
-  cr = cairo_create (surface);
-
-  layouts = swfdec_text_field_generate_layouts (text->text, cr,
-      text->paragraphs, NULL, NULL);
+  layouts = swfdec_text_field_movie_get_layouts (text, NULL);
 
   width = 0;
   height = 3;
-  for (iter = layouts; iter != NULL; iter = iter->next) {
-    SwfdecLayout *layout = (SwfdecLayout *)iter->data;
-
+  for (i = 0; layouts[i].layout != NULL; i++) {
     if (!text->text->word_wrap) {
-      if (layout->width > width)
-	width = layout->width;
+      if (layouts[i].width > width)
+	width = layouts[i].width;
     }
 
-    height += layout->height;
+    height += layouts[i].height;
   }
 
+  swfdec_text_field_movie_free_layouts (layouts);
+
   if (!text->text->word_wrap && SWFDEC_GRAPHIC (text->text)->extents.x1 -
       SWFDEC_GRAPHIC (text->text)->extents.x0 != width)
   {
diff --git a/libswfdec/swfdec_text_field_movie.h b/libswfdec/swfdec_text_field_movie.h
index 2ade6e2..f394747 100644
--- a/libswfdec/swfdec_text_field_movie.h
+++ b/libswfdec/swfdec_text_field_movie.h
@@ -43,17 +43,6 @@ typedef struct {
   SwfdecTextFormat *	format;
 } SwfdecFormatIndex;
 
-typedef enum {
-  SWFDEC_ANTI_ALIAS_TYPE_NORMAL,
-  SWFDEC_ANTI_ALIAS_TYPE_ADVANCED
-} SwfdecAntiAliasType;
-
-typedef enum {
-  SWFDEC_GRID_FIT_TYPE_NONE,
-  SWFDEC_GRID_FIT_TYPE_PIXEL,
-  SWFDEC_GRID_FIT_TYPE_SUBPIXEL
-} SwfdecGridFitType;
-
 struct _SwfdecTextFieldMovie {
   SwfdecMovie		movie;
 
@@ -67,17 +56,9 @@ struct _SwfdecTextFieldMovie {
   SwfdecTextFormat *	format_new;
   GSList *		formats;
 
-  SwfdecAntiAliasType	anti_alias_type;
   gboolean		condense_white;
   gboolean		embed_fonts;
-  SwfdecGridFitType	grid_fit_type;
-  guint			hscroll;
-  gboolean		mouse_wheel_enabled;
-  const char *		restrict_;
-  guint			scroll;
-  int			sharpness;
   SwfdecStyleSheet *	style_sheet;
-  int			thickness;
 
   SwfdecColor		border_color;
   SwfdecColor		background_color;
@@ -100,6 +81,8 @@ void		swfdec_text_field_movie_set_text_format	(SwfdecTextFieldMovie *	text,
 							 SwfdecTextFormat *	format,
 							 guint			start_index,
 							 guint			end_index);
+void		swfdec_text_field_movie_set_scroll	(SwfdecTextFieldMovie *	text,
+							 int			value);
 
 /* implemented in swfdec_text_field_movie_as.c */
 void		swfdec_text_field_movie_init_properties	(SwfdecAsContext *	cx);
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index 19aabd6..7e8e20e 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -420,7 +420,7 @@ swfdec_text_field_movie_get_length (SwfdecAsContext *cx, SwfdecAsObject *object,
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
 
-  SWFDEC_AS_VALUE_SET_INT (ret, strlen (text->text_display));
+  SWFDEC_AS_VALUE_SET_INT (ret, g_utf8_strlen (text->text_display, -1));
 }
 
 /*
@@ -453,6 +453,69 @@ swfdec_text_field_movie_set_condenseWhite (SwfdecAsContext *cx,
   text->condense_white = value;
 }
 
+static void
+swfdec_text_field_movie_get_multiline (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+  SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->multiline);
+}
+
+static void
+swfdec_text_field_movie_set_multiline (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+  gboolean value;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+  swfdec_as_value_to_number (cx, &argv[0]);
+
+  text->text->multiline = value;
+}
+
+static void
+swfdec_text_field_movie_do_get_type (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+  if (text->text->input) {
+    SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_input);
+  } else {
+    SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_dynamic);
+  }
+}
+
+static void
+swfdec_text_field_movie_do_set_type (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+  const char *value;
+
+  if (argc > 0)
+    swfdec_as_value_to_number (cx, &argv[0]);
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
+
+  if (!g_strcasecmp (value, SWFDEC_AS_STR_input)) {
+    text->text->input = TRUE;
+  } else if (!g_strcasecmp (value, SWFDEC_AS_STR_dynamic)) {
+    text->text->input = FALSE;
+  }
+}
+
 /*
  * Native properties: Background & border
  */
@@ -577,6 +640,34 @@ swfdec_text_field_movie_set_borderColor (SwfdecAsContext *cx,
 }
 
 /*
+ * Native properties: Scrolling
+ */
+static void
+swfdec_text_field_movie_do_get_scroll (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+  SWFDEC_AS_VALUE_SET_NUMBER (ret, text->text->scroll);
+}
+
+static void
+swfdec_text_field_movie_do_set_scroll (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+  int value;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
+
+  swfdec_text_field_movie_set_scroll (text, value);
+}
+
+/*
  * Native properties: Display
  */
 static void
@@ -938,6 +1029,8 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
   proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
 
   // text
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_text,
+      swfdec_text_field_movie_get_text, swfdec_text_field_movie_do_set_text);
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_html,
       swfdec_text_field_movie_get_html, swfdec_text_field_movie_set_html);
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_htmlText,
@@ -946,8 +1039,6 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_length,
       swfdec_text_field_movie_get_length,
       swfdec_text_field_movie_set_readonly);
-  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_text,
-      swfdec_text_field_movie_get_text, swfdec_text_field_movie_do_set_text);
 
   // input
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_condenseWhite,
@@ -956,17 +1047,18 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_maxChars,
       swfdec_text_field_movie_get_maxChars,
       swfdec_text_field_movie_set_maxChars);*/
-  /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_multiline,
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_multiline,
       swfdec_text_field_movie_get_multiline,
-      swfdec_text_field_movie_set_multiline);*/
+      swfdec_text_field_movie_set_multiline);
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_restrict,
       swfdec_text_field_movie_get_restrict,
       swfdec_text_field_movie_set_restrict);*/
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_selectable,
       swfdec_text_field_movie_get_selectable,
       swfdec_text_field_movie_set_selectable);*/
-  /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_type,
-      swfdec_text_field_movie_get_type, swfdec_text_field_movie_set_type);*/
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_type,
+      swfdec_text_field_movie_do_get_type,
+      swfdec_text_field_movie_do_set_type);
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_variable,
       swfdec_text_field_movie_get_variable,
       swfdec_text_field_movie_set_variable);*/
@@ -1008,8 +1100,9 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_mouseWheelEnabled,
       swfdec_text_field_movie_get_mouseWheelEnabled,
       swfdec_text_field_movie_set_mouseWheelEnabled);*/
-  /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_scroll,
-      swfdec_text_field_movie_get_scroll, swfdec_text_field_movie_set_scroll);*/
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_scroll,
+      swfdec_text_field_movie_do_get_scroll,
+      swfdec_text_field_movie_do_set_scroll);
 
   // display
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_autoSize,
@@ -1025,25 +1118,25 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
   // format
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_antiAliasType,
       swfdec_text_field_movie_get_antiAliasType,
-      swfdec_text_field_movie_set_antiAliasType);
-  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_gridFitType,
-      swfdec_text_field_movie_get_gridFitType,
-      swfdec_text_field_movie_set_gridFitType);*/
+      swfdec_text_field_movie_set_antiAliasType);*/
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_embedFonts,
       swfdec_text_field_movie_get_embedFonts,
       swfdec_text_field_movie_set_embedFonts);
+  /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_gridFitType,
+      swfdec_text_field_movie_get_gridFitType,
+      swfdec_text_field_movie_set_gridFitType);*/
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_sharpness,
       swfdec_text_field_movie_get_sharpness,
-      swfdec_text_field_movie_set_sharpness);
-  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_thickness,
-      swfdec_text_field_movie_get_thickness,
-      swfdec_text_field_movie_set_thickness);*/
+      swfdec_text_field_movie_set_sharpness);*/
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_styleSheet,
       swfdec_text_field_movie_get_styleSheet,
       swfdec_text_field_movie_set_styleSheet);*/
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_textColor,
       swfdec_text_field_movie_get_textColor,
       swfdec_text_field_movie_set_textColor);
+  /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_thickness,
+      swfdec_text_field_movie_get_thickness,
+      swfdec_text_field_movie_set_thickness);*/
 
   // TODO: filters, menu, tabEnabled, tabIndex
 }
commit e4ff7ba9cd0945885fb8bc2b67455f3c87fffe7a
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sun Oct 14 19:53:06 2007 +0300

    Implement background, backgroundColor and borderColor properties for TextField

diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index 1477395..a58a1e8 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -397,5 +397,8 @@ const char swfdec_as_strings[] =
   SWFDEC_AS_CONSTANT_STRING ("wordWrap")
   SWFDEC_AS_CONSTANT_STRING ("border")
   SWFDEC_AS_CONSTANT_STRING ("Key")
+  SWFDEC_AS_CONSTANT_STRING ("background")
+  SWFDEC_AS_CONSTANT_STRING ("backgroundColor")
+  SWFDEC_AS_CONSTANT_STRING ("borderColor")
   /* add more here */
 ;
diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index 69a7a68..3fe67ea 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -552,8 +552,8 @@ swfdec_text_field_movie_init_movie (SwfdecMovie *movie)
   text->format_new->indent = text->text->indent / 20;
   text->format_new->leading = text->text->leading / 20;
 
-  text->border_color = SWFDEC_COLOR_COMBINE (0, 0, 0, 255);
-  text->background_color = SWFDEC_COLOR_COMBINE (255, 255, 255, 255);
+  text->border_color = SWFDEC_COLOR_COMBINE (0, 0, 0, 0);
+  text->background_color = SWFDEC_COLOR_COMBINE (255, 255, 255, 0);
 
   // text
   if (text->text->text_input != NULL) {
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index 121fefc..19aabd6 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -36,6 +36,16 @@
 #include "swfdec_internal.h"
 #include "swfdec_player_internal.h"
 
+static SwfdecColor
+swfdec_text_field_movie_int_to_color (SwfdecAsContext *cx, int value)
+{
+  if (value < 0) {
+    return 16777216 + value % 16777216;
+  } else {
+    return value % 16777216;
+  }
+}
+
 // does nothing but calls valueOf
 static void
 swfdec_text_field_movie_set_readonly (SwfdecAsContext *cx,
@@ -447,6 +457,66 @@ swfdec_text_field_movie_set_condenseWhite (SwfdecAsContext *cx,
  * Native properties: Background & border
  */
 static void
+swfdec_text_field_movie_get_background (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+  SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->background);
+}
+
+static void
+swfdec_text_field_movie_set_background (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+  gboolean value;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+  swfdec_as_value_to_number (cx, &argv[0]);
+
+  if (text->text->background != value) {
+    text->text->background = value;
+    swfdec_movie_invalidate (SWFDEC_MOVIE (text));
+  }
+}
+
+static void
+swfdec_text_field_movie_get_backgroundColor (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+  SWFDEC_AS_VALUE_SET_NUMBER (ret, text->background_color);
+}
+
+static void
+swfdec_text_field_movie_set_backgroundColor (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+  int value;
+  SwfdecColor color;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
+
+  color = swfdec_text_field_movie_int_to_color (cx, value);
+  if (text->background_color != color) {
+    text->background_color = color;
+    swfdec_movie_invalidate (SWFDEC_MOVIE (text));
+  }
+}
+
+static void
 swfdec_text_field_movie_get_border (SwfdecAsContext *cx,
     SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
     SwfdecAsValue *ret)
@@ -476,6 +546,36 @@ swfdec_text_field_movie_set_border (SwfdecAsContext *cx,
   }
 }
 
+static void
+swfdec_text_field_movie_get_borderColor (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+  SWFDEC_AS_VALUE_SET_NUMBER (ret, text->border_color);
+}
+
+static void
+swfdec_text_field_movie_set_borderColor (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+  int value;
+  SwfdecColor color;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
+
+  color = swfdec_text_field_movie_int_to_color (cx, value);
+  if (text->border_color != color) {
+    text->border_color = color;
+    swfdec_movie_invalidate (SWFDEC_MOVIE (text));
+  }
+}
+
 /*
  * Native properties: Display
  */
@@ -633,13 +733,7 @@ swfdec_text_field_movie_set_textColor (SwfdecAsContext *cx,
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
 
-  if (value < 0) {
-    value =  16777216 + value % 16777216;
-  } else {
-    value = value % 16777216;
-  }
-
-  text->format_new->color = value;
+  text->format_new->color = swfdec_text_field_movie_int_to_color (cx, value);
 }
 
 /*
@@ -886,17 +980,17 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
       swfdec_text_field_movie_set_readonly);*/
 
   // border & background
-  /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_background,
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_background,
       swfdec_text_field_movie_get_background,
-      swfdec_text_field_movie_set_background);*/
-  /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_backgroundColor,
+      swfdec_text_field_movie_set_background);
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_backgroundColor,
       swfdec_text_field_movie_get_backgroundColor,
-      swfdec_text_field_movie_set_backgroundColor);*/
+      swfdec_text_field_movie_set_backgroundColor);
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_border,
       swfdec_text_field_movie_get_border, swfdec_text_field_movie_set_border);
-  /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_borderColor,
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_borderColor,
       swfdec_text_field_movie_get_borderColor,
-      swfdec_text_field_movie_set_borderColor);*/
+      swfdec_text_field_movie_set_borderColor);
 
   // scrolling
   /*swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_bottomScroll,


More information about the Swfdec mailing list