[Swfdec] 9 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_html_parser.c libswfdec/swfdec_style_sheet.c libswfdec/swfdec_style_sheet.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

Pekka Lampila
Tue, 23 Oct 2007 11:28:12 -0000

libswfdec/swfdec_as_strings.c          |    2 +
 libswfdec/swfdec_html_parser.c         |   41 ++++++++++++++++++++---
 libswfdec/swfdec_style_sheet.c         |   47 +++++++++++++++++++++++++++
 libswfdec/swfdec_style_sheet.h         |    6 +++
 libswfdec/swfdec_text_field_movie.c    |   24 +++++++++++--
 libswfdec/swfdec_text_field_movie.h    |    2 +
 libswfdec/swfdec_text_field_movie_as.c |   57 ++++++++++++++++++++++++++++-----
 libswfdec/swfdec_text_format.c         |    5 ++
 8 files changed, 166 insertions(+), 18 deletions(-)

New commits:
commit 0f2289cf2e49a0c3ec695e77b4310964ccccbc75
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Oct 23 14:16:53 2007 +0300

    Don't set kerning and letterSpacing in TextFormat's set_defaults
when v < 8

diff --git a/libswfdec/swfdec_text_format.c b/libswfdec/swfdec_text_format.c
index 63c0849..8a86d18 100644
--- a/libswfdec/swfdec_text_format.c
+++ b/libswfdec/swfdec_text_format.c
@@ -1100,6 +1100,11 @@ swfdec_text_format_set_defaults (SwfdecTextFormat
*format)
   format->underline = FALSE;

   format->values_set = (1 << PROP_TOTAL) - 1;
+
+  if (SWFDEC_AS_OBJECT (format)->context->version < 8) {
+    swfdec_text_format_mark_unset (format, PROP_KERNING);
+    swfdec_text_format_mark_unset (format, PROP_LETTER_SPACING);
+  }
 }

 static void
commit 502907d3286e9f7c3c8f24a86fed5ccfd4d92d9d
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Oct 23 13:57:50 2007 +0300

    Implement swfdec_style_sheet_get_format

diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index a6b7d6f..b0a9e28 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -423,5 +423,6 @@ const char swfdec_as_strings[]    SWFDEC_AS_CONSTANT_STRING
("textWidth")
   SWFDEC_AS_CONSTANT_STRING ("onScroller")
   SWFDEC_AS_CONSTANT_STRING ("styleSheet")
+  SWFDEC_AS_CONSTANT_STRING ("_styles")
   /* add more here */
 ;
diff --git a/libswfdec/swfdec_style_sheet.c b/libswfdec/swfdec_style_sheet.c
index a899335..47e7efe 100644
--- a/libswfdec/swfdec_style_sheet.c
+++ b/libswfdec/swfdec_style_sheet.c
@@ -28,6 +28,7 @@
 #include "swfdec_as_array.h"
 #include "swfdec_as_object.h"
 #include "swfdec_as_strings.h"
+#include "swfdec_text_format.h"
 #include "swfdec_debug.h"
 #include "swfdec_internal.h"
 #include "swfdec_as_internal.h"
@@ -297,10 +298,25 @@ swfdec_style_sheet_construct (SwfdecAsContext *cx,
SwfdecAsObject *object,
 static SwfdecTextFormat *
 swfdec_style_sheet_get_format (SwfdecStyleSheet *style, const char *name)
 {
+  SwfdecAsObject *styles;
+  SwfdecAsValue val;
+
   g_return_val_if_fail (SWFDEC_IS_STYLESHEET (style), NULL);
   g_return_val_if_fail (name != NULL, NULL);

-  return NULL;
+  swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (style),
+      SWFDEC_AS_STR__styles, &val);
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+    return NULL;
+  styles = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+  swfdec_as_object_get_variable (styles, name, &val);
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+    return NULL;
+  if (!SWFDEC_IS_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&val)))
+    return NULL;
+
+  return SWFDEC_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&val));
 }

 SwfdecTextFormat *
commit a892034491b858340e93f5625447d293018974a8
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Oct 23 13:52:14 2007 +0300

    Implement getting and setting TextField's styleSheet property

diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index 8a940d5..a6b7d6f 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -422,5 +422,6 @@ const char swfdec_as_strings[]    SWFDEC_AS_CONSTANT_STRING
("textHeight")
   SWFDEC_AS_CONSTANT_STRING ("textWidth")
   SWFDEC_AS_CONSTANT_STRING ("onScroller")
+  SWFDEC_AS_CONSTANT_STRING ("styleSheet")
   /* add more here */
 ;
diff --git a/libswfdec/swfdec_text_field_movie_as.c
b/libswfdec/swfdec_text_field_movie_as.c
index f5ae979..ee79706 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -868,6 +868,45 @@ swfdec_text_field_movie_set_embedFonts (SwfdecAsContext
*cx,
 }

 static void
+swfdec_text_field_movie_get_styleSheet (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+  if (text->style_sheet != NULL) {
+    SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (text->style_sheet));
+  } else {
+    SWFDEC_AS_VALUE_SET_NULL (ret);
+  }
+}
+
+static void
+swfdec_text_field_movie_set_styleSheet (SwfdecAsContext *cx,
+    SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+    SwfdecAsValue *ret)
+{
+  SwfdecTextFieldMovie *text;
+  SwfdecAsObject *value;
+
+  SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "o",
&value);
+
+  swfdec_as_value_to_number (cx, &argv[0]);
+
+  if (!SWFDEC_IS_STYLESHEET (value))
+    return;
+
+  if (text->style_sheet == SWFDEC_STYLESHEET (value))
+    return;
+
+  text->style_sheet = SWFDEC_STYLESHEET (value);
+  if (text->style_sheet_input)
+    swfdec_text_field_movie_set_text (text, text->style_sheet_input, TRUE);
+}
+
+static void
 swfdec_text_field_movie_get_textColor (SwfdecAsContext *cx,
     SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
     SwfdecAsValue *ret)
@@ -1307,9 +1346,9 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext
*cx)
   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_styleSheet,
+  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_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);
commit d27c58746986d9c077697512cdaad56ce838a3a6
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Oct 23 13:45:59 2007 +0300

    More work on styleSheet support for TextField

    Save the input if styleSheet is set and return it for htmlText
    Don't allow modifications if styleSheet was set when setting the text
    Always parse text as HTML if styleSheet is set (no matter what html property
    says or whether text or htmlText was used to set the text)

diff --git a/libswfdec/swfdec_text_field_movie.c
b/libswfdec/swfdec_text_field_movie.c
index b56466d..15b945f 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -893,6 +893,8 @@ swfdec_text_field_movie_mark (SwfdecAsObject *object)
   swfdec_as_object_mark (SWFDEC_AS_OBJECT (text->format_new));
   if (text->style_sheet != NULL)
     swfdec_as_object_mark (SWFDEC_AS_OBJECT (text->style_sheet));
+  if (text->style_sheet_input != NULL)
+    swfdec_as_string_mark (text->style_sheet_input);
   if (text->restrict_ != NULL)
     swfdec_as_string_mark (text->restrict_);

@@ -1551,6 +1553,11 @@ swfdec_text_field_movie_replace_text
(SwfdecTextFieldMovie *text,
   g_return_if_fail (start_index <= end_index);
   g_return_if_fail (str != NULL);

+  /* if there was a style sheet set when setting the text, modifications are
+   * not allowed */
+  if (text->style_sheet_input)
+    return;
+
   text->input = g_string_erase (text->input,
       g_utf8_offset_to_pointer (text->input->str, start_index) -
       text->input->str,
@@ -1631,10 +1638,17 @@ swfdec_text_field_movie_set_text (SwfdecTextFieldMovie
*text, const char *str,
   text->formats = g_slist_prepend (text->formats, block);

   text->input_html = html;
-  if (html) {
+
+  if (text->style_sheet) {
+    text->style_sheet_input = str;
     swfdec_text_field_movie_html_parse (text, str);
   } else {
-    text->input = g_string_assign (text->input, str);
+    text->style_sheet_input = NULL;
+    if (html) {
+      swfdec_text_field_movie_html_parse (text, str);
+    } else {
+      text->input = g_string_assign (text->input, str);
+    }
   }

   swfdec_movie_invalidate (SWFDEC_MOVIE (text));
diff --git a/libswfdec/swfdec_text_field_movie.h
b/libswfdec/swfdec_text_field_movie.h
index fc7371d..fd02f04 100644
--- a/libswfdec/swfdec_text_field_movie.h
+++ b/libswfdec/swfdec_text_field_movie.h
@@ -90,7 +90,9 @@ struct _SwfdecTextFieldMovie {

   gboolean		condense_white;
   gboolean		embed_fonts;
+
   SwfdecStyleSheet *	style_sheet;
+  const char *		style_sheet_input; /* saved input, so it can be used to apply
stylesheet again */

   gboolean		scroll_changed; /* if any of the scroll attributes have changed and
we haven't fired the event yet */
   int			scroll;
diff --git a/libswfdec/swfdec_text_field_movie_as.c
b/libswfdec/swfdec_text_field_movie_as.c
index 86ca221..f5ae979 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -135,7 +135,9 @@ swfdec_text_field_movie_get_htmlText (SwfdecAsContext *cx,

   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");

-  if (text->text->html) {
+  if (text->style_sheet_input) {
+    SWFDEC_AS_VALUE_SET_STRING (ret, text->style_sheet_input);
+  } else if (text->text->html) {
     SWFDEC_AS_VALUE_SET_STRING (ret,
 	swfdec_text_field_movie_get_html_text (text));
   } else {
commit 1b8a955b52338eae25699ff76227fc283769b2ca
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Oct 23 13:35:29 2007 +0300

    Allow using class on span tags too

diff --git a/libswfdec/swfdec_html_parser.c b/libswfdec/swfdec_html_parser.c
index eac7282..9ca6dfd 100644
--- a/libswfdec/swfdec_html_parser.c
+++ b/libswfdec/swfdec_html_parser.c
@@ -190,6 +190,7 @@ swfdec_text_field_movie_html_tag_set_attribute (ParserData
*data,

   if (data->style_sheet &&
       ((tag->name_length == 2 && !g_strncasecmp (tag->name,
"li", 2)) ||
+      (tag->name_length == 4 && !g_strncasecmp (tag->name,
"span", 4)) ||
       (tag->name_length == 1 && !g_strncasecmp (tag->name,
"p", 1))))
   {
     if (name_length == 5 && !g_strncasecmp (name, "class",
5)) {
commit 862c71b7e55a13aca48bd81e1a5f809b61630f58
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Oct 23 13:30:32 2007 +0300

    Make TextField's HTML parser set styles from styleSheet

diff --git a/libswfdec/swfdec_html_parser.c b/libswfdec/swfdec_html_parser.c
index 00c085c..eac7282 100644
--- a/libswfdec/swfdec_html_parser.c
+++ b/libswfdec/swfdec_html_parser.c
@@ -26,6 +26,7 @@

 #include "swfdec_text_field_movie.h"
 #include "swfdec_as_strings.h"
+#include "swfdec_style_sheet.h"
 #include "swfdec_xml.h"
 #include "swfdec_debug.h"

@@ -41,6 +42,7 @@ typedef struct {
   SwfdecAsContext	*cx;
   gboolean		multiline;
   gboolean		condense_white;
+  SwfdecStyleSheet	*style_sheet;
   GString *		text;
   GSList *		tags_open;
   GSList *		tags_closed;
@@ -97,8 +99,9 @@ swfdec_text_field_movie_html_parse_comment (ParserData *data,
const char *p)
 }

 static void
-swfdec_text_field_movie_html_tag_set_attribute (ParserTag *tag,
-    const char *name, int name_length, const char *value, int value_length)
+swfdec_text_field_movie_html_tag_set_attribute (ParserData *data,
+    ParserTag *tag, const char *name, int name_length, const char *value,
+    int value_length)
 {
   SwfdecAsValue val;
   SwfdecAsObject *object;
@@ -184,10 +187,24 @@ swfdec_text_field_movie_html_tag_set_attribute (ParserTag
*tag,
       swfdec_as_object_set_variable (object, SWFDEC_AS_STR_target, &val);
     }
   }
+
+  if (data->style_sheet &&
+      ((tag->name_length == 2 && !g_strncasecmp (tag->name,
"li", 2)) ||
+      (tag->name_length == 1 && !g_strncasecmp (tag->name,
"p", 1))))
+  {
+    if (name_length == 5 && !g_strncasecmp (name, "class",
5)) {
+      SwfdecTextFormat *format = swfdec_style_sheet_get_class_format (
+	  data->style_sheet, swfdec_as_context_give_string (data->cx,
+	      g_strndup (value, value_length)));
+      if (format != NULL)
+	swfdec_text_format_add (tag->format, format);
+    }
+  }
 }

 static const char *
-swfdec_text_field_movie_html_parse_attribute (ParserTag *tag, const char *p)
+swfdec_text_field_movie_html_parse_attribute (ParserData *data, ParserTag *tag,
+    const char *p)
 {
   const char *end, *name, *value;
   int name_length, value_length;
@@ -222,8 +239,8 @@ swfdec_text_field_movie_html_parse_attribute (ParserTag
*tag, const char *p)
   value_length = end - (p + 1);

   if (tag != NULL) {
-    swfdec_text_field_movie_html_tag_set_attribute (tag, name, name_length,
-	value, value_length);
+    swfdec_text_field_movie_html_tag_set_attribute (data, tag, name,
+	name_length, value, value_length);
   }

   g_return_val_if_fail (end + 1 > p, NULL);
@@ -333,12 +350,22 @@ swfdec_text_field_movie_html_parse_tag (ParserData *data,
const char *p)
       {
 	SWFDEC_FIXME ("IMG tag support for TextField's HTML input
missing");
       }
+
+      if (data->style_sheet &&
+	  ((tag->name_length == 2 && !g_strncasecmp (tag->name,
"li", 2)) ||
+	  (tag->name_length == 1 && !g_strncasecmp (tag->name,
"p", 1)))) {
+	SwfdecTextFormat *format = swfdec_style_sheet_get_tag_format (
+	    data->style_sheet, swfdec_as_context_give_string (data->cx,
+		g_strndup (tag->name, tag->name_length)));
+	if (format != NULL)
+	  swfdec_text_format_add (tag->format, format);
+      }
     }

     // parse attributes
     end = end + strspn (end, " \r\n\t");
     while (*end != '\0' && *end != '>' &&
(*end != '/' || *(end + 1) != '>')) {
-      end = swfdec_text_field_movie_html_parse_attribute (tag, end);
+      end = swfdec_text_field_movie_html_parse_attribute (data, tag, end);
       if (end == NULL)
 	break;
       end = end + strspn (end, " \r\n\t");
@@ -404,6 +431,7 @@ swfdec_text_field_movie_html_parse (SwfdecTextFieldMovie
*text, const char *str)
   data.cx = SWFDEC_AS_OBJECT (text)->context;
   data.multiline = (data.cx->version < 7 || text->text->multiline);
   data.condense_white = text->condense_white;
+  data.style_sheet = text->style_sheet;
   data.text = text->input;
   data.tags_open = NULL;
   data.tags_closed = NULL;
commit 79121e1a94f46bbb713e386747bcdbc7a01464b0
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Tue Oct 23 13:29:49 2007 +0300

    Add dummy swfdec_style_sheet_get_tag_format and ...get_class_format
functions

diff --git a/libswfdec/swfdec_style_sheet.c b/libswfdec/swfdec_style_sheet.c
index 8115c74..a899335 100644
--- a/libswfdec/swfdec_style_sheet.c
+++ b/libswfdec/swfdec_style_sheet.c
@@ -293,3 +293,34 @@ swfdec_style_sheet_construct (SwfdecAsContext *cx,
SwfdecAsObject *object,

   g_assert (SWFDEC_IS_STYLESHEET (object));
 }
+
+static SwfdecTextFormat *
+swfdec_style_sheet_get_format (SwfdecStyleSheet *style, const char *name)
+{
+  g_return_val_if_fail (SWFDEC_IS_STYLESHEET (style), NULL);
+  g_return_val_if_fail (name != NULL, NULL);
+
+  return NULL;
+}
+
+SwfdecTextFormat *
+swfdec_style_sheet_get_tag_format (SwfdecStyleSheet *style, const char *name)
+{
+  return swfdec_style_sheet_get_format (style, name);
+}
+
+SwfdecTextFormat *
+swfdec_style_sheet_get_class_format (SwfdecStyleSheet *style, const char *name)
+{
+  char *name_full;
+
+  g_return_val_if_fail (SWFDEC_IS_STYLESHEET (style), NULL);
+  g_return_val_if_fail (name != NULL, NULL);
+
+  name_full = g_malloc (1 + strlen (name) + 1);
+  name_full[0] = '.';
+  memcpy (name_full + 1, name, strlen (name) + 1);
+
+  return swfdec_style_sheet_get_format (style, swfdec_as_context_give_string (
+	SWFDEC_AS_OBJECT (style)->context, name_full));
+}
diff --git a/libswfdec/swfdec_style_sheet.h b/libswfdec/swfdec_style_sheet.h
index 17deefe..e8993bd 100644
--- a/libswfdec/swfdec_style_sheet.h
+++ b/libswfdec/swfdec_style_sheet.h
@@ -24,6 +24,7 @@
 #include <libswfdec/swfdec_as_object.h>
 #include <libswfdec/swfdec_types.h>
 #include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_text_format.h>

 G_BEGIN_DECLS

@@ -47,5 +48,10 @@ struct _SwfdecStyleSheetClass {

 GType		swfdec_style_sheet_get_type	(void);

+SwfdecTextFormat *swfdec_style_sheet_get_tag_format	(SwfdecStyleSheet *	style,
+							 const char *		name);
+SwfdecTextFormat *swfdec_style_sheet_get_class_format	(SwfdecStyleSheet *
style,
+							 const char *		name);
+
 G_END_DECLS
 #endif
commit 1d1ac45509805af4e0debc7d85d9474de4375ad1
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 22 22:50:11 2007 +0300

    Border line width is 1 twip

diff --git a/libswfdec/swfdec_text_field_movie.c
b/libswfdec/swfdec_text_field_movie.c
index c071666..b56466d 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -611,7 +611,7 @@ swfdec_text_field_movie_render (SwfdecMovie *movie, cairo_t
*cr,
 	movie->original_extents.y1);
     color = swfdec_color_apply_transform (text_movie->border_color, trans);
     swfdec_color_set_source (cr, color);
-    cairo_set_line_width (cr, 20.0); // FIXME: Is this correct?
+    cairo_set_line_width (cr, SWFDEC_DOUBLE_TO_TWIPS (1));
     cairo_stroke (cr);
   }

commit c7c15478f857113ff9dcf28a5f976f4583d4ec40
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 22 22:36:17 2007 +0300

    Fix TextField's background and border displaying, by keeping alpha bits
at 255

diff --git a/libswfdec/swfdec_text_field_movie.c
b/libswfdec/swfdec_text_field_movie.c
index bf3edce..c071666 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -935,8 +935,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, 0);
-  text->background_color = SWFDEC_COLOR_COMBINE (255, 255, 255, 0);
+  text->border_color = SWFDEC_COLOR_COMBINE (0, 0, 0, 255);
+  text->background_color = SWFDEC_COLOR_COMBINE (255, 255, 255, 255);

   // 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 bef2ca6..86ca221 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -481,7 +481,7 @@ swfdec_text_field_movie_get_backgroundColor (SwfdecAsContext
*cx,

   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");

-  SWFDEC_AS_VALUE_SET_NUMBER (ret, text->background_color);
+  SWFDEC_AS_VALUE_SET_NUMBER (ret, text->background_color & 0xffffff);
 }

 static void
@@ -495,7 +495,8 @@ swfdec_text_field_movie_set_backgroundColor (SwfdecAsContext
*cx,

   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i",
&value);

-  color = swfdec_text_field_movie_int_to_color (cx, value);
+  color = (swfdec_text_field_movie_int_to_color (cx, value) & 0xffffff) +
+    (255 << 24);
   if (text->background_color != color) {
     text->background_color = color;
     swfdec_movie_invalidate (SWFDEC_MOVIE (text));
@@ -541,7 +542,7 @@ swfdec_text_field_movie_get_borderColor (SwfdecAsContext
*cx,

   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");

-  SWFDEC_AS_VALUE_SET_NUMBER (ret, text->border_color);
+  SWFDEC_AS_VALUE_SET_NUMBER (ret, text->border_color & 0xffffff);
 }

 static void
@@ -555,7 +556,8 @@ swfdec_text_field_movie_set_borderColor (SwfdecAsContext
*cx,

   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i",
&value);

-  color = swfdec_text_field_movie_int_to_color (cx, value);
+  color = (swfdec_text_field_movie_int_to_color (cx, value) & 0xffffff) +
+    (255 << 24);
   if (text->border_color != color) {
     text->border_color = color;
     swfdec_movie_invalidate (SWFDEC_MOVIE (text));