[Swfdec] 10 commits - libswfdec/swfdec_as_strings.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c

Pekka Lampila medar at kemper.freedesktop.org
Sun Oct 14 01:50:55 PDT 2007


 libswfdec/swfdec_as_strings.c          |    2 
 libswfdec/swfdec_text_field.c          |   66 +++++++++++++++++++++++-----
 libswfdec/swfdec_text_field_movie.c    |    5 +-
 libswfdec/swfdec_text_field_movie_as.c |   77 ++++++++++++++++++++++++++++++---
 4 files changed, 132 insertions(+), 18 deletions(-)

New commits:
commit a165608df6751cf46561b570db61ff309f5b7244
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sun Oct 14 02:26:48 2007 +0300

    Don't render lines that are not horizontally inside invalid area

diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
index 6adbe8a..867b30d 100644
--- a/libswfdec/swfdec_text_field.c
+++ b/libswfdec/swfdec_text_field.c
@@ -254,7 +254,7 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
   GList *layouts, *iter;
   SwfdecRect limit;
   SwfdecColor color;
-  int y, linenum;
+  int y, x, linenum;
 
   g_return_if_fail (SWFDEC_IS_TEXT_FIELD (text));
   g_return_if_fail (cr != NULL);
@@ -285,8 +285,9 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
       inval);
 
   linenum = 0;
+  x = SWFDEC_GRAPHIC (text)->extents.x0;
   y = SWFDEC_GRAPHIC (text)->extents.y0 + 1;
-  cairo_move_to (cr, SWFDEC_GRAPHIC (text)->extents.x0, y);
+  cairo_move_to (cr, x, y);
 
   for (iter = layouts; iter != NULL && y < limit.y1; iter = iter->next)
   {
@@ -307,18 +308,20 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
       pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
       pango_extents_to_pixels (NULL, &rect);
 
-      if (y + rect.y + rect.height < limit.y0)
-	continue;
-
       if (y + rect.y > limit.y1 ||
 	  y + rect.y + rect.height > SWFDEC_GRAPHIC (text)->extents.y1)
 	break;
 
-      cairo_rel_move_to (cr, layout->render_offset_x,
+      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)
+	continue;
+
+      cairo_rel_move_to (cr, layout->render_offset_x + rect.x,
 	  pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE);
       line = pango_layout_iter_get_line_readonly (iter_line);
       pango_cairo_show_layout_line (cr, line);
-      cairo_rel_move_to (cr, -layout->render_offset_x,
+      cairo_rel_move_to (cr, -(layout->render_offset_x + rect.x),
 	  -pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE);
     } while (pango_layout_iter_next_line (iter_line));
 
commit 1af25e1c21f6aeb02fe5f95384fc94b63d1504af
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sun Oct 14 02:20:09 2007 +0300

    Cleanup TextField's rendering code

diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
index d991be6..6adbe8a 100644
--- a/libswfdec/swfdec_text_field.c
+++ b/libswfdec/swfdec_text_field.c
@@ -254,7 +254,7 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
   GList *layouts, *iter;
   SwfdecRect limit;
   SwfdecColor color;
-  int y;
+  int y, linenum;
 
   g_return_if_fail (SWFDEC_IS_TEXT_FIELD (text));
   g_return_if_fail (cr != NULL);
@@ -284,68 +284,46 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
   layouts = swfdec_text_field_generate_layouts (text, cr, paragraphs, trans,
       inval);
 
+  linenum = 0;
   y = SWFDEC_GRAPHIC (text)->extents.y0 + 1;
   cairo_move_to (cr, SWFDEC_GRAPHIC (text)->extents.x0, y);
 
-  for (iter = layouts; iter != NULL; iter = iter->next)
+  for (iter = layouts; iter != NULL && y < limit.y1; iter = iter->next)
   {
     SwfdecLayout *layout = (SwfdecLayout *)iter->data;
+    PangoLayoutIter *iter_line;
+    PangoLayoutLine *line;
+    PangoRectangle rect;
 
-    if (y + layout->height < limit.y0) {
-      // no need to render
-      cairo_rel_move_to (cr, 0, layout->height);
-      y += layout->height;
-    } else if (y < limit.y0 || y + layout->height > limit.y1) {
-      // possibly skip some lines
-      PangoLayoutIter *iter_line;
-      PangoLayoutLine *line;
-      PangoRectangle rect;
-
-      cairo_rel_move_to (cr, layout->render_offset_x, 0);
+    iter_line = pango_layout_get_iter (layout->layout);
 
-      iter_line = pango_layout_get_iter (layout->layout);
+    do {
+      /*if (++linenum < text->text->scroll) {
+	cairo_rel_move_to (cr, 0, -rect.height);
+	y -= rect.height;
+	continue;
+      }*/
 
       pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
       pango_extents_to_pixels (NULL, &rect);
-      while (y + rect.y + rect.height < limit.y0)
-      {
-	if (!pango_layout_iter_next_line (iter_line))
-	  g_assert_not_reached ();
-	pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
-	pango_extents_to_pixels (NULL, &rect);
-      }
 
-      while (y + rect.y <= limit.y1 &&
-	  y + rect.y + rect.height <= SWFDEC_GRAPHIC (text)->extents.y1)
-      {
-	cairo_rel_move_to (cr, 0,
-	    pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE);
-	line = pango_layout_iter_get_line_readonly (iter_line);
-	pango_cairo_show_layout_line (cr, line);
-	cairo_rel_move_to (cr, 0,
-	    -pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE);
-
-	if (!pango_layout_iter_next_line (iter_line))
-	  break;
-
-	pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
-	pango_extents_to_pixels (NULL, &rect);
-      }
+      if (y + rect.y + rect.height < limit.y0)
+	continue;
 
-      pango_layout_iter_free (iter_line);
+      if (y + rect.y > limit.y1 ||
+	  y + rect.y + rect.height > SWFDEC_GRAPHIC (text)->extents.y1)
+	break;
 
-      cairo_rel_move_to (cr, -layout->render_offset_x, layout->height);
-      y += layout->height;
+      cairo_rel_move_to (cr, layout->render_offset_x,
+	  pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE);
+      line = pango_layout_iter_get_line_readonly (iter_line);
+      pango_cairo_show_layout_line (cr, line);
+      cairo_rel_move_to (cr, -layout->render_offset_x,
+	  -pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE);
+    } while (pango_layout_iter_next_line (iter_line));
 
-      if (y > limit.y1)
-	break;
-    } else {
-      // render the whole layout
-      cairo_rel_move_to (cr, layout->render_offset_x, 0);
-      pango_cairo_show_layout (cr, layout->layout);
-      cairo_rel_move_to (cr, -layout->render_offset_x, layout->height);
-      y += layout->height;
-    }
+    cairo_rel_move_to (cr, 0, layout->height);
+    y += layout->height;
   }
 
   for (iter = layouts; iter != NULL; iter = iter->next)
commit a7bee586fb6061e74b16cb598fed3535eb7e48e5
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sun Oct 14 01:55:11 2007 +0300

    Limit rendering of TextField's background based on invalid area

diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
index 177462d..d991be6 100644
--- a/libswfdec/swfdec_text_field.c
+++ b/libswfdec/swfdec_text_field.c
@@ -252,8 +252,9 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
     const SwfdecRect *inval)
 {
   GList *layouts, *iter;
+  SwfdecRect limit;
   SwfdecColor color;
-  int y, y_min, y_max;
+  int y;
 
   g_return_if_fail (SWFDEC_IS_TEXT_FIELD (text));
   g_return_if_fail (cr != NULL);
@@ -261,10 +262,10 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
   g_return_if_fail (trans != NULL);
   g_return_if_fail (inval != NULL);
 
+  swfdec_rect_intersect (&limit, &SWFDEC_GRAPHIC (text)->extents, inval);
+
   if (text->background) {
-    cairo_rectangle (cr, SWFDEC_GRAPHIC (text)->extents.x0,
-	SWFDEC_GRAPHIC (text)->extents.y0, SWFDEC_GRAPHIC (text)->extents.x1,
-	SWFDEC_GRAPHIC (text)->extents.y1);
+    cairo_rectangle (cr, limit.x0, limit.y0, limit.x1, limit.y1);
     color = swfdec_color_apply_transform (background_color, trans);
     swfdec_color_set_source (cr, color);
     cairo_fill (cr);
@@ -284,20 +285,17 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
       inval);
 
   y = SWFDEC_GRAPHIC (text)->extents.y0 + 1;
-  y_min = MAX (SWFDEC_GRAPHIC (text)->extents.y0, inval->y0);
-  y_max = MIN (SWFDEC_GRAPHIC (text)->extents.y1, inval->y1);
-
   cairo_move_to (cr, SWFDEC_GRAPHIC (text)->extents.x0, y);
 
   for (iter = layouts; iter != NULL; iter = iter->next)
   {
     SwfdecLayout *layout = (SwfdecLayout *)iter->data;
 
-    if (y + layout->height < y_min) {
+    if (y + layout->height < limit.y0) {
       // no need to render
       cairo_rel_move_to (cr, 0, layout->height);
       y += layout->height;
-    } else if (y < y_min || y + layout->height > y_max) {
+    } else if (y < limit.y0 || y + layout->height > limit.y1) {
       // possibly skip some lines
       PangoLayoutIter *iter_line;
       PangoLayoutLine *line;
@@ -309,7 +307,7 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
 
       pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
       pango_extents_to_pixels (NULL, &rect);
-      while (y + rect.y + rect.height < y_min)
+      while (y + rect.y + rect.height < limit.y0)
       {
 	if (!pango_layout_iter_next_line (iter_line))
 	  g_assert_not_reached ();
@@ -317,7 +315,7 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
 	pango_extents_to_pixels (NULL, &rect);
       }
 
-      while (y + rect.y <= y_max &&
+      while (y + rect.y <= limit.y1 &&
 	  y + rect.y + rect.height <= SWFDEC_GRAPHIC (text)->extents.y1)
       {
 	cairo_rel_move_to (cr, 0,
@@ -339,7 +337,7 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
       cairo_rel_move_to (cr, -layout->render_offset_x, layout->height);
       y += layout->height;
 
-      if (y > y_max)
+      if (y > limit.y1)
 	break;
     } else {
       // render the whole layout
commit a1d953be60647fa04985138c4a88e62b889aaf9c
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sun Oct 14 01:49:51 2007 +0300

    Don't render TextField text over it's extents in verticald direction
    
    Also limit rendering of lines based on the invalid area

diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
index 98383bd..177462d 100644
--- a/libswfdec/swfdec_text_field.c
+++ b/libswfdec/swfdec_text_field.c
@@ -24,6 +24,7 @@
 
 #include <pango/pangocairo.h>
 #include <string.h>
+
 #include "swfdec_text_field.h"
 #include "swfdec_debug.h"
 #include "swfdec_text_field_movie.h"
@@ -252,6 +253,7 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
 {
   GList *layouts, *iter;
   SwfdecColor color;
+  int y, y_min, y_max;
 
   g_return_if_fail (SWFDEC_IS_TEXT_FIELD (text));
   g_return_if_fail (cr != NULL);
@@ -281,19 +283,76 @@ swfdec_text_field_render (SwfdecTextField *text, cairo_t *cr,
   layouts = swfdec_text_field_generate_layouts (text, cr, paragraphs, trans,
       inval);
 
-  cairo_move_to (cr, SWFDEC_GRAPHIC (text)->extents.x0,
-      SWFDEC_GRAPHIC (text)->extents.y0 + 1);
+  y = SWFDEC_GRAPHIC (text)->extents.y0 + 1;
+  y_min = MAX (SWFDEC_GRAPHIC (text)->extents.y0, inval->y0);
+  y_max = MIN (SWFDEC_GRAPHIC (text)->extents.y1, inval->y1);
+
+  cairo_move_to (cr, SWFDEC_GRAPHIC (text)->extents.x0, y);
 
-  for (iter = layouts; iter != NULL; iter = iter->next) {
+  for (iter = layouts; iter != NULL; iter = iter->next)
+  {
     SwfdecLayout *layout = (SwfdecLayout *)iter->data;
 
-    cairo_rel_move_to (cr, layout->render_offset_x, 0);
+    if (y + layout->height < y_min) {
+      // no need to render
+      cairo_rel_move_to (cr, 0, layout->height);
+      y += layout->height;
+    } else if (y < y_min || y + layout->height > y_max) {
+      // possibly skip some lines
+      PangoLayoutIter *iter_line;
+      PangoLayoutLine *line;
+      PangoRectangle rect;
+
+      cairo_rel_move_to (cr, layout->render_offset_x, 0);
+
+      iter_line = pango_layout_get_iter (layout->layout);
+
+      pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
+      pango_extents_to_pixels (NULL, &rect);
+      while (y + rect.y + rect.height < y_min)
+      {
+	if (!pango_layout_iter_next_line (iter_line))
+	  g_assert_not_reached ();
+	pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
+	pango_extents_to_pixels (NULL, &rect);
+      }
+
+      while (y + rect.y <= y_max &&
+	  y + rect.y + rect.height <= SWFDEC_GRAPHIC (text)->extents.y1)
+      {
+	cairo_rel_move_to (cr, 0,
+	    pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE);
+	line = pango_layout_iter_get_line_readonly (iter_line);
+	pango_cairo_show_layout_line (cr, line);
+	cairo_rel_move_to (cr, 0,
+	    -pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE);
+
+	if (!pango_layout_iter_next_line (iter_line))
+	  break;
+
+	pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
+	pango_extents_to_pixels (NULL, &rect);
+      }
 
-    pango_layout_context_changed (layout->layout);
+      pango_layout_iter_free (iter_line);
 
-    pango_cairo_show_layout (cr, layout->layout);
+      cairo_rel_move_to (cr, -layout->render_offset_x, layout->height);
+      y += layout->height;
 
-    cairo_rel_move_to (cr, -layout->render_offset_x, layout->height);
+      if (y > y_max)
+	break;
+    } else {
+      // render the whole layout
+      cairo_rel_move_to (cr, layout->render_offset_x, 0);
+      pango_cairo_show_layout (cr, layout->layout);
+      cairo_rel_move_to (cr, -layout->render_offset_x, layout->height);
+      y += layout->height;
+    }
+  }
+
+  for (iter = layouts; iter != NULL; iter = iter->next)
+  {
+    SwfdecLayout *layout = (SwfdecLayout *)iter->data;
 
     g_object_unref (layout->layout);
     g_free (layout);
commit ab8ff2313cb6c57a11c00eef9b03afcc96abca48
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 21:44:29 2007 +0300

    Add border property for TextField

diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index a2d7cc8..d9b85cc 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -395,6 +395,7 @@ const char swfdec_as_strings[] =
   SWFDEC_AS_CONSTANT_STRING ("embedFonts")
   SWFDEC_AS_CONSTANT_STRING ("autoSize")
   SWFDEC_AS_CONSTANT_STRING ("wordWrap")
+  SWFDEC_AS_CONSTANT_STRING ("border")
   /* add more here */
 ;
 
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index 32ce75e..77c2652 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -598,6 +598,36 @@ swfdec_text_field_movie_set_wordWrap (SwfdecAsContext *cx,
   }
 }
 
+static void
+swfdec_text_field_movie_get_border (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->border);
+}
+
+static void
+swfdec_text_field_movie_set_border (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->border != value) {
+    text->text->border = value;
+    swfdec_movie_invalidate (SWFDEC_MOVIE (text));
+  }
+}
+
 SWFDEC_AS_NATIVE (104, 104, swfdec_text_field_movie_getNewTextFormat)
 void
 swfdec_text_field_movie_getNewTextFormat (SwfdecAsContext *cx,
@@ -818,6 +848,8 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_wordWrap,
       swfdec_text_field_movie_get_wordWrap,
       swfdec_text_field_movie_set_wordWrap);
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_border,
+      swfdec_text_field_movie_get_border, swfdec_text_field_movie_set_border);
 }
 
 SWFDEC_AS_CONSTRUCTOR (104, 0, swfdec_text_field_movie_construct, swfdec_text_field_movie_get_type)
commit 7be9e44642a66fe9b4c6f14c4e96d61386c14ad4
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 19:27:43 2007 +0300

    Fix setNewTextFormat to add the defined values to the existing style
    
    This fixes a crash

diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index a40d456..32ce75e 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -626,7 +626,7 @@ swfdec_text_field_movie_setNewTextFormat (SwfdecAsContext *cx,
   if (!SWFDEC_IS_TEXT_FORMAT (obj))
     return;
 
-  text->format_new = swfdec_text_format_copy (SWFDEC_TEXT_FORMAT (obj));
+  swfdec_text_format_add (text->format_new, SWFDEC_TEXT_FORMAT (obj));
 }
 
 SWFDEC_AS_NATIVE (104, 102, swfdec_text_field_movie_setTextFormat)
commit a207c0002748a1a42151252db7b0ba319798bb37
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 19:02:36 2007 +0300

    Set PANGO_WRAP_WORD_CHAR to wrap on non-word boundaries if necessary

diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
index 485d3b2..98383bd 100644
--- a/libswfdec/swfdec_text_field.c
+++ b/libswfdec/swfdec_text_field.c
@@ -141,8 +141,12 @@ swfdec_text_field_generate_layouts (SwfdecTextField *text, cairo_t *cr,
 	width += -paragraphs[i].indent / PANGO_SCALE;
       }
 
-      pango_layout_set_width (playout,
-	  (text->word_wrap ? width * PANGO_SCALE : -1));
+      if (text->word_wrap) {
+	pango_layout_set_wrap (playout, PANGO_WRAP_WORD_CHAR);
+	pango_layout_set_width (playout, width * PANGO_SCALE);
+      } else {
+	pango_layout_set_width (playout, -1);
+      }
 
       // set paragraph styles
       if (block->index_ == 0) {
commit d28d42632fac41c643492693f1b0bdf9bf87c4e6
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 18:57:03 2007 +0300

    Add wordWrap property for TextField

diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index 0ff4d4c..a2d7cc8 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -394,6 +394,7 @@ const char swfdec_as_strings[] =
   SWFDEC_AS_CONSTANT_STRING ("textColor")
   SWFDEC_AS_CONSTANT_STRING ("embedFonts")
   SWFDEC_AS_CONSTANT_STRING ("autoSize")
+  SWFDEC_AS_CONSTANT_STRING ("wordWrap")
   /* add more here */
 ;
 
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index 8a08dd2..a40d456 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -568,6 +568,36 @@ swfdec_text_field_movie_set_autoSize (SwfdecAsContext *cx,
     swfdec_text_field_movie_format_changed (text);
 }
 
+static void
+swfdec_text_field_movie_get_wordWrap (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->word_wrap);
+}
+
+static void
+swfdec_text_field_movie_set_wordWrap (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->word_wrap != value) {
+    text->text->word_wrap = value;
+    swfdec_text_field_movie_format_changed (text);
+  }
+}
+
 SWFDEC_AS_NATIVE (104, 104, swfdec_text_field_movie_getNewTextFormat)
 void
 swfdec_text_field_movie_getNewTextFormat (SwfdecAsContext *cx,
@@ -785,6 +815,9 @@ swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
   swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_autoSize,
       swfdec_text_field_movie_get_autoSize,
       swfdec_text_field_movie_set_autoSize);
+  swfdec_text_field_movie_add_variable (proto, SWFDEC_AS_STR_wordWrap,
+      swfdec_text_field_movie_get_wordWrap,
+      swfdec_text_field_movie_set_wordWrap);
 }
 
 SWFDEC_AS_CONSTRUCTOR (104, 0, swfdec_text_field_movie_construct, swfdec_text_field_movie_get_type)
commit 198e1a25ca3debd97e6534c5291143258b5d8919
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 18:54:31 2007 +0300

    Fix a crash in TextField for empty paragraphs

diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index 21e9a79..304e8e8 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -112,7 +112,7 @@ swfdec_text_field_movie_generate_paragraph (SwfdecTextFieldMovie *text,
 
   g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
   g_assert (paragraph != NULL);
-  g_assert (start_index < end_index);
+  g_assert (start_index <= end_index);
   g_assert (end_index <= strlen (text->text_display));
 
   paragraph->text = text->text_display + start_index;
@@ -122,6 +122,9 @@ swfdec_text_field_movie_generate_paragraph (SwfdecTextFieldMovie *text,
   paragraph->attrs = NULL;
   paragraph->attrs_list = pango_attr_list_new ();
 
+  if (paragraph->text_length == 0)
+    return;
+
   g_assert (text->formats != NULL);
   for (iter = text->formats; iter->next != NULL &&
       ((SwfdecFormatIndex *)(iter->next->data))->index <= start_index;
commit b12359a1bb3a12b72aed6561ab2d1b1ee225eb26
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Oct 13 15:53:14 2007 +0300

    Convert the x, y, width and height units correctly in createTextField

diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index 8d7389a..8a08dd2 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -677,10 +677,12 @@ swfdec_text_field_movie_createTextField (SwfdecAsContext *cx,
   edittext->indent = 0;
   edittext->leading = 0;
 
-  edittext->graphic.extents.x0 = x;
-  edittext->graphic.extents.x1 = x + width;
-  edittext->graphic.extents.y0 = y;
-  edittext->graphic.extents.y1 = y + height;
+  edittext->graphic.extents.x0 = SWFDEC_DOUBLE_TO_TWIPS (x);
+  edittext->graphic.extents.x1 =
+    edittext->graphic.extents.x0 + SWFDEC_DOUBLE_TO_TWIPS (width);
+  edittext->graphic.extents.y0 = SWFDEC_DOUBLE_TO_TWIPS (y);
+  edittext->graphic.extents.y1 =
+    edittext->graphic.extents.y0 + SWFDEC_DOUBLE_TO_TWIPS (height);
 
   movie = swfdec_movie_find (parent, depth);
   if (movie)


More information about the Swfdec mailing list