[Swfdec-commits] 10 commits - swfdec/swfdec_text_field_movie_as.c swfdec/swfdec_text_field_movie.c swfdec/swfdec_text_field_movie.h swfdec/swfdec_text_layout.c test/image test/trace

Benjamin Otte company at kemper.freedesktop.org
Tue Jun 24 04:47:01 PDT 2008


 swfdec/swfdec_text_field_movie.c                         |   91 +++++++++------
 swfdec/swfdec_text_field_movie.h                         |   18 +-
 swfdec/swfdec_text_field_movie_as.c                      |   33 +++--
 swfdec/swfdec_text_layout.c                              |   15 --
 test/image/gradient-beginGradientFill-6.swf.png          |binary
 test/image/gradient-beginGradientFill-7.swf.png          |binary
 test/image/gradient-beginGradientFill-8.swf.png          |binary
 test/image/gradient-ratios.swf.png                       |binary
 test/image/image-jpeg-alpha.swf.png                      |binary
 test/trace/Makefile.am                                   |    9 +
 test/trace/text-field-autosize-layout-update-5.swf       |binary
 test/trace/text-field-autosize-layout-update-5.swf.trace |    4 
 test/trace/text-field-autosize-layout-update-6.swf       |binary
 test/trace/text-field-autosize-layout-update-6.swf.trace |    4 
 test/trace/text-field-autosize-layout-update-7.swf       |binary
 test/trace/text-field-autosize-layout-update-7.swf.trace |    4 
 test/trace/text-field-autosize-layout-update-8.swf       |binary
 test/trace/text-field-autosize-layout-update-8.swf.trace |    4 
 test/trace/text-field-autosize-layout-update.as          |   24 +++
 test/trace/text-field-scroll-5.swf                       |binary
 test/trace/text-field-scroll-5.swf.trace                 |   54 ++++----
 test/trace/text-field-scroll-6.swf                       |binary
 test/trace/text-field-scroll-6.swf.trace                 |   50 ++++----
 test/trace/text-field-scroll-7.swf                       |binary
 test/trace/text-field-scroll-7.swf.trace                 |   56 ++++-----
 test/trace/text-field-scroll-8.swf                       |binary
 test/trace/text-field-scroll-8.swf.trace                 |   56 ++++-----
 test/trace/text-field-scroll.as                          |   13 +-
 28 files changed, 250 insertions(+), 185 deletions(-)

New commits:
commit 74981e63e73288ea53dfb9d921dd9897735a7c91
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 13:45:34 2008 +0200

    update this test
    
    - use Bitstream Vera Sas no matter what
    - don't do lame > comparison, make the real values work

diff --git a/test/trace/text-field-scroll-5.swf b/test/trace/text-field-scroll-5.swf
index 8b8d562..650378c 100644
Binary files a/test/trace/text-field-scroll-5.swf and b/test/trace/text-field-scroll-5.swf differ
diff --git a/test/trace/text-field-scroll-5.swf.trace b/test/trace/text-field-scroll-5.swf.trace
index 6746940..91239a2 100644
--- a/test/trace/text-field-scroll-5.swf.trace
+++ b/test/trace/text-field-scroll-5.swf.trace
@@ -1,54 +1,54 @@
 # EMPTY
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 
 # WITH TEXT
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 3
 # WITH WORD WRAP
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 3
 # WITHOUT WORD WRAP
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 3
 # WITH WORD WRAP - SCROLL RESET
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 3
 # WITH WORD WRAP - FORMAT RESET
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 3
 # WITH WORD WRAP - TEXT RESET
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 3
 # WITHOUT WORD WRAP - FORMAT RESET
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 30
 # WITHOUT WORD WRAP - TEXT RESET
-bottomScroll > scroll: false
+bottomScroll: 
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: false
+maxhscroll: 
+maxscroll: 
 scroll: 30
diff --git a/test/trace/text-field-scroll-6.swf b/test/trace/text-field-scroll-6.swf
index 30bcc38..450e942 100644
Binary files a/test/trace/text-field-scroll-6.swf and b/test/trace/text-field-scroll-6.swf differ
diff --git a/test/trace/text-field-scroll-6.swf.trace b/test/trace/text-field-scroll-6.swf.trace
index 6dc3dc5..0448ddb 100644
--- a/test/trace/text-field-scroll-6.swf.trace
+++ b/test/trace/text-field-scroll-6.swf.trace
@@ -1,48 +1,48 @@
 # EMPTY
-bottomScroll > scroll: false
+bottomScroll: 1
 hscroll: 0
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 1
 scroll: 1
 # WITH TEXT
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 16
 scroll: 3
 # WITHOUT WORD WRAP
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP - SCROLL RESET
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP - TEXT RESET
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 0
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 100
 scroll: 3
 # WITHOUT WORD WRAP - FORMAT RESET
-bottomScroll > scroll: false
+bottomScroll: 30
 hscroll: 0
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 30
 # WITHOUT WORD WRAP - TEXT RESET
-bottomScroll > scroll: true
+bottomScroll: 16
 hscroll: 0
-maxhscroll > 0: true
-maxscroll > 0: true
-scroll: 11
+maxhscroll: 704
+maxscroll: 16
+scroll: 16
diff --git a/test/trace/text-field-scroll-7.swf b/test/trace/text-field-scroll-7.swf
index 7c47d65..2541129 100644
Binary files a/test/trace/text-field-scroll-7.swf and b/test/trace/text-field-scroll-7.swf differ
diff --git a/test/trace/text-field-scroll-7.swf.trace b/test/trace/text-field-scroll-7.swf.trace
index 6cd8b93..eb6dfee 100644
--- a/test/trace/text-field-scroll-7.swf.trace
+++ b/test/trace/text-field-scroll-7.swf.trace
@@ -1,54 +1,54 @@
 # EMPTY
-bottomScroll > scroll: false
+bottomScroll: 1
 hscroll: 0
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 1
 scroll: 1
 # WITH TEXT
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 16
 scroll: 3
 # WITHOUT WORD WRAP
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP - SCROLL RESET
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP - FORMAT RESET
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 100
 scroll: 3
 # WITH WORD WRAP - TEXT RESET
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 0
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 100
 scroll: 3
 # WITHOUT WORD WRAP - FORMAT RESET
-bottomScroll > scroll: false
+bottomScroll: 30
 hscroll: 0
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 30
 # WITHOUT WORD WRAP - TEXT RESET
-bottomScroll > scroll: true
+bottomScroll: 16
 hscroll: 0
-maxhscroll > 0: true
-maxscroll > 0: true
-scroll: 11
+maxhscroll: 704
+maxscroll: 16
+scroll: 16
diff --git a/test/trace/text-field-scroll-8.swf b/test/trace/text-field-scroll-8.swf
index 5fb8e80..b6a3f1d 100644
Binary files a/test/trace/text-field-scroll-8.swf and b/test/trace/text-field-scroll-8.swf differ
diff --git a/test/trace/text-field-scroll-8.swf.trace b/test/trace/text-field-scroll-8.swf.trace
index 6cd8b93..eb6dfee 100644
--- a/test/trace/text-field-scroll-8.swf.trace
+++ b/test/trace/text-field-scroll-8.swf.trace
@@ -1,54 +1,54 @@
 # EMPTY
-bottomScroll > scroll: false
+bottomScroll: 1
 hscroll: 0
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 1
 scroll: 1
 # WITH TEXT
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 16
 scroll: 3
 # WITHOUT WORD WRAP
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP - SCROLL RESET
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 16
 scroll: 3
 # WITH WORD WRAP - FORMAT RESET
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 200
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 100
 scroll: 3
 # WITH WORD WRAP - TEXT RESET
-bottomScroll > scroll: true
+bottomScroll: 3
 hscroll: 0
-maxhscroll > 0: false
-maxscroll > 0: true
+maxhscroll: 0
+maxscroll: 100
 scroll: 3
 # WITHOUT WORD WRAP - FORMAT RESET
-bottomScroll > scroll: false
+bottomScroll: 30
 hscroll: 0
-maxhscroll > 0: true
-maxscroll > 0: true
+maxhscroll: 704
+maxscroll: 16
 scroll: 30
 # WITHOUT WORD WRAP - TEXT RESET
-bottomScroll > scroll: true
+bottomScroll: 16
 hscroll: 0
-maxhscroll > 0: true
-maxscroll > 0: true
-scroll: 11
+maxhscroll: 704
+maxscroll: 16
+scroll: 16
diff --git a/test/trace/text-field-scroll.as b/test/trace/text-field-scroll.as
index a375f29..fbf2d43 100644
--- a/test/trace/text-field-scroll.as
+++ b/test/trace/text-field-scroll.as
@@ -1,17 +1,18 @@
 // makeswf -v 7 -r 1 -o test-7.swf test.as
 
 function trace_scroll_properties () {
-  trace ("bottomScroll > scroll: " + (t.bottomScroll > t.scroll));
+  trace ("bottomScroll: " + t.bottomScroll);
   trace ("hscroll: " + t.hscroll);
-  trace ("maxhscroll > 0: " + (t.maxhscroll > 0));
-  trace ("maxscroll > 0: " + (t.maxscroll > 0));
+  trace ("maxhscroll: " + t.maxhscroll);
+  trace ("maxscroll: " + t.maxscroll);
   trace ("scroll: " + t.scroll);
 }
 
-this.createTextField ("t", 1, 0, 0, 100, 100);
+this.createTextField ("t", 1, 0, 0, 100, 25);
 
 var fmt = new TextFormat ();
 fmt.size = 14;
+fmt.font = "Bitstream Vera Sans";
 t.setNewTextFormat (fmt);
 
 trace ("# EMPTY");
@@ -50,6 +51,7 @@ trace_scroll_properties ();
 trace ("# WITH WORD WRAP - FORMAT RESET");
 
 var fmt = new TextFormat ();
+fmt.font = "Bitstream Vera Sans";
 t.setTextFormat (fmt);
 
 trace_scroll_properties ();
@@ -67,6 +69,7 @@ trace ("# WITHOUT WORD WRAP - FORMAT RESET");
 
 t.wordWrap = false;
 var fmt = new TextFormat ();
+fmt.font = "Bitstream Vera Sans";
 t.setTextFormat (fmt);
 
 trace_scroll_properties ();
@@ -77,4 +80,4 @@ t.text = t.text;
 
 trace_scroll_properties ();
 
-loadMovie ("FSCommand:quit", "");
+getURL ("FSCommand:quit", "");
commit e6f33c9554fe4090a4179b77e79c935fb012ce22
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 13:44:29 2008 +0200

    readd _update_layout() special casing in setTextFormat

diff --git a/swfdec/swfdec_text_field_movie_as.c b/swfdec/swfdec_text_field_movie_as.c
index 6e84717..24a6061 100644
--- a/swfdec/swfdec_text_field_movie_as.c
+++ b/swfdec/swfdec_text_field_movie_as.c
@@ -1149,8 +1149,14 @@ swfdec_text_field_movie_setTextFormat (SwfdecAsContext *cx,
       &format->attr, format->values_set);
 
   swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
-  // special case: update the max values, not the current values
-  // swfdec_text_field_movie_update_scroll (text, FALSE);
+  /* special case: update the max values, not the current values */
+  /* swfdec_text_field_movie_update_layout (text); */
+  /* FIXME: emit onScroller? */
+  text->layout_width = swfdec_text_layout_get_width (text->layout);
+  text->layout_height = swfdec_text_layout_get_height (text->layout);
+  text->scroll_max = swfdec_text_layout_get_n_rows (text->layout)
+    - swfdec_text_layout_get_visible_rows_end (text->layout, 
+	text->layout_area.height);
 }
 
 SWFDEC_AS_NATIVE (104, 101, swfdec_text_field_movie_getTextFormat)
commit 21d6f1d87c3625ae4f30b70a7578801a97ce1fc6
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 13:44:11 2008 +0200

    no hscroll when word wrapping is in effect

diff --git a/swfdec/swfdec_text_field_movie.c b/swfdec/swfdec_text_field_movie.c
index b4ccd91..0782e64 100644
--- a/swfdec/swfdec_text_field_movie.c
+++ b/swfdec/swfdec_text_field_movie.c
@@ -1129,7 +1129,8 @@ swfdec_text_field_movie_get_hscroll_max (SwfdecTextFieldMovie *text)
 {
   g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), 0);
 
-  if ((guint) text->layout_area.width >= text->layout_width)
+  if ((guint) text->layout_area.width >= text->layout_width ||
+      swfdec_text_layout_get_word_wrap (text->layout))
     return 0;
   else
     return text->layout_width - text->layout_area.width;
commit de38ac3e913329a07ab378866e75178f8b9d3379
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 13:41:38 2008 +0200

    revert 5a3d5f09e9c115fcc81cc8a6056f6ee256a3d066
    
    Flash does do character wrapping

diff --git a/swfdec/swfdec_text_layout.c b/swfdec/swfdec_text_layout.c
index c2be876..405f1cf 100644
--- a/swfdec/swfdec_text_layout.c
+++ b/swfdec/swfdec_text_layout.c
@@ -162,7 +162,7 @@ swfdec_text_block_new (PangoContext *context)
 
   block = g_slice_new0 (SwfdecTextBlock);
   block->layout = pango_layout_new (context);
-  pango_layout_set_wrap (block->layout, PANGO_WRAP_WORD);
+  pango_layout_set_wrap (block->layout, PANGO_WRAP_WORD_CHAR);
 
   return block;
 }
commit baa2751ee58956fb8d10e27de9116fcf984f8359
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 13:17:35 2008 +0200

    add swfdec_text_field_movie_emit_onScroller() to handle the madness that is onScroller

diff --git a/swfdec/swfdec_text_field_movie.c b/swfdec/swfdec_text_field_movie.c
index e4d149a..b4ccd91 100644
--- a/swfdec/swfdec_text_field_movie.c
+++ b/swfdec/swfdec_text_field_movie.c
@@ -321,13 +321,26 @@ swfdec_text_field_movie_mark (SwfdecAsObject *object)
   SWFDEC_AS_OBJECT_CLASS (swfdec_text_field_movie_parent_class)->mark (object);
 }
 
-/* NB: can be run with unlocked player */
+void
+swfdec_text_field_movie_emit_onScroller (SwfdecTextFieldMovie *text)
+{
+  g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+
+  if (!text->onScroller_emitted && swfdec_movie_get_version (SWFDEC_MOVIE (text)) > 6) {
+    swfdec_player_add_action (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (text)->context), 
+	SWFDEC_ACTOR (text), SWFDEC_EVENT_SCROLL, 0, SWFDEC_PLAYER_ACTION_QUEUE_NORMAL);
+  }
+  text->onScroller_emitted = TRUE;
+}
+
 void
 swfdec_text_field_movie_update_layout (SwfdecTextFieldMovie *text)
 {
   guint scroll_max, lines_visible, rows, height, max;
   gboolean scroll_changed = FALSE;
 
+  g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+
   text->layout_width = swfdec_text_layout_get_width (text->layout);
   text->layout_height = swfdec_text_layout_get_height (text->layout);
 
@@ -355,11 +368,8 @@ swfdec_text_field_movie_update_layout (SwfdecTextFieldMovie *text)
     scroll_changed = TRUE;
   }
 
-  if (scroll_changed && !text->onScroller_emitted) {
-    swfdec_player_add_action (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (text)->context), 
-	SWFDEC_ACTOR (text), SWFDEC_EVENT_SCROLL, 0, SWFDEC_PLAYER_ACTION_QUEUE_NORMAL);
-    text->onScroller_emitted = TRUE;
-  }
+  if (scroll_changed)
+    swfdec_text_field_movie_emit_onScroller (text);
 }
 
 static void
@@ -445,7 +455,8 @@ swfdec_text_field_movie_init_movie (SwfdecMovie *movie)
   /* don't emit onScroller here, plz */
   text->onScroller_emitted = TRUE;
   swfdec_text_field_movie_update_layout (text);
-  text->onScroller_emitted = FALSE;
+  if (swfdec_movie_get_version (movie) > 6)
+    text->onScroller_emitted = FALSE;
   swfdec_text_field_movie_update_area (text);
 }
 
@@ -475,6 +486,10 @@ swfdec_text_field_movie_iterate (SwfdecActor *actor)
     text->changed--;
   }
 
+  if (text->onScroller_emitted && swfdec_movie_get_version (SWFDEC_MOVIE (text)) <= 6) {
+    swfdec_player_add_action (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (text)->context), 
+	SWFDEC_ACTOR (text), SWFDEC_EVENT_SCROLL, 0, SWFDEC_PLAYER_ACTION_QUEUE_NORMAL);
+  }
   text->onScroller_emitted = FALSE;
 }
 
diff --git a/swfdec/swfdec_text_field_movie.h b/swfdec/swfdec_text_field_movie.h
index cbb70c6..dd1b65b 100644
--- a/swfdec/swfdec_text_field_movie.h
+++ b/swfdec/swfdec_text_field_movie.h
@@ -104,6 +104,7 @@ void		swfdec_text_field_movie_set_text	(SwfdecTextFieldMovie *	movie,
 							 gboolean		html);
 void		swfdec_text_field_movie_autosize	(SwfdecTextFieldMovie *	text);
 void		swfdec_text_field_movie_update_layout	(SwfdecTextFieldMovie * text);
+void		swfdec_text_field_movie_emit_onScroller (SwfdecTextFieldMovie *	text);
 const char *	swfdec_text_field_movie_get_text	(SwfdecTextFieldMovie *	text);
 void		swfdec_text_field_movie_set_listen_variable 
 							(SwfdecTextFieldMovie *	text,
diff --git a/swfdec/swfdec_text_field_movie_as.c b/swfdec/swfdec_text_field_movie_as.c
index 79bca49..6e84717 100644
--- a/swfdec/swfdec_text_field_movie_as.c
+++ b/swfdec/swfdec_text_field_movie_as.c
@@ -620,11 +620,7 @@ swfdec_text_field_movie_do_set_hscroll (SwfdecAsContext *cx,
   if ((guint) value != text->hscroll) {
     swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
     text->hscroll = value;
-    if (!text->onScroller_emitted) {
-      swfdec_player_add_action (SWFDEC_PLAYER (cx), SWFDEC_ACTOR (text), 
-	  SWFDEC_EVENT_SCROLL, 0, SWFDEC_PLAYER_ACTION_QUEUE_NORMAL);
-      text->onScroller_emitted = TRUE;
-    }
+    swfdec_text_field_movie_emit_onScroller (text);
   }
 }
 
@@ -706,11 +702,7 @@ swfdec_text_field_movie_do_set_scroll (SwfdecAsContext *cx,
     value = CLAMP (value - 1, 0, (int) text->scroll_max);
     text->scroll = value;
     swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
-    if (!text->onScroller_emitted) {
-      swfdec_player_add_action (SWFDEC_PLAYER (cx), SWFDEC_ACTOR (text), 
-	  SWFDEC_EVENT_SCROLL, 0, SWFDEC_PLAYER_ACTION_QUEUE_NORMAL);
-      text->onScroller_emitted = TRUE;
-    }
+    swfdec_text_field_movie_emit_onScroller (text);
   }
 }
 
commit 5633e132e7ef8391be933194da252549b69ab741
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 11:36:59 2008 +0200

    add test that checks auto-sizing updates the layout

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 1083b42..fe4ac51 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -3542,6 +3542,15 @@ EXTRA_DIST = \
 	targetpath-6.swf.trace \
 	targetpath-7.swf \
 	targetpath-7.swf.trace \
+	text-field-autosize-layout-update-5.swf \
+	text-field-autosize-layout-update-5.swf.trace \
+	text-field-autosize-layout-update-6.swf \
+	text-field-autosize-layout-update-6.swf.trace \
+	text-field-autosize-layout-update-7.swf \
+	text-field-autosize-layout-update-7.swf.trace \
+	text-field-autosize-layout-update-8.swf \
+	text-field-autosize-layout-update-8.swf.trace \
+	text-field-autosize-layout-update.as \
 	text-field-get-text-format.as \
 	text-field-get-text-format-5.swf \
 	text-field-get-text-format-5.swf.trace \
diff --git a/test/trace/text-field-autosize-layout-update-5.swf b/test/trace/text-field-autosize-layout-update-5.swf
new file mode 100644
index 0000000..52dac1f
Binary files /dev/null and b/test/trace/text-field-autosize-layout-update-5.swf differ
diff --git a/test/trace/text-field-autosize-layout-update-5.swf.trace b/test/trace/text-field-autosize-layout-update-5.swf.trace
new file mode 100644
index 0000000..487b116
--- /dev/null
+++ b/test/trace/text-field-autosize-layout-update-5.swf.trace
@@ -0,0 +1,4 @@
+2
+2
+2
+2
diff --git a/test/trace/text-field-autosize-layout-update-6.swf b/test/trace/text-field-autosize-layout-update-6.swf
new file mode 100644
index 0000000..624dc66
Binary files /dev/null and b/test/trace/text-field-autosize-layout-update-6.swf differ
diff --git a/test/trace/text-field-autosize-layout-update-6.swf.trace b/test/trace/text-field-autosize-layout-update-6.swf.trace
new file mode 100644
index 0000000..5b3c1b7
--- /dev/null
+++ b/test/trace/text-field-autosize-layout-update-6.swf.trace
@@ -0,0 +1,4 @@
+2
+2
+2
+1
diff --git a/test/trace/text-field-autosize-layout-update-7.swf b/test/trace/text-field-autosize-layout-update-7.swf
new file mode 100644
index 0000000..0aef6da
Binary files /dev/null and b/test/trace/text-field-autosize-layout-update-7.swf differ
diff --git a/test/trace/text-field-autosize-layout-update-7.swf.trace b/test/trace/text-field-autosize-layout-update-7.swf.trace
new file mode 100644
index 0000000..5b3c1b7
--- /dev/null
+++ b/test/trace/text-field-autosize-layout-update-7.swf.trace
@@ -0,0 +1,4 @@
+2
+2
+2
+1
diff --git a/test/trace/text-field-autosize-layout-update-8.swf b/test/trace/text-field-autosize-layout-update-8.swf
new file mode 100644
index 0000000..1d6f4f3
Binary files /dev/null and b/test/trace/text-field-autosize-layout-update-8.swf differ
diff --git a/test/trace/text-field-autosize-layout-update-8.swf.trace b/test/trace/text-field-autosize-layout-update-8.swf.trace
new file mode 100644
index 0000000..5b3c1b7
--- /dev/null
+++ b/test/trace/text-field-autosize-layout-update-8.swf.trace
@@ -0,0 +1,4 @@
+2
+2
+2
+1
diff --git a/test/trace/text-field-autosize-layout-update.as b/test/trace/text-field-autosize-layout-update.as
new file mode 100644
index 0000000..0f6ecbb
--- /dev/null
+++ b/test/trace/text-field-autosize-layout-update.as
@@ -0,0 +1,24 @@
+// makeswf -v 7 -s 200x150 -r 1 -o text-field-autosize-layout-update.swf text-field-autosize-layout-update.as
+
+var tf = new TextFormat ();
+tf.font = "Bitstream Vera Sans";
+
+for (i = 0; i < 4; i++) {
+  createTextField ("t", 0, 0, 0, 50, 25);
+  t.setNewTextFormat (tf);
+  t.border = true;
+  t.wordWrap = true;
+  t.text = "Hello World";
+  t.scroll = 2;
+  t.wordWrap = false;
+  if (i % 2)
+    t.autoSize = true;
+  if (i >> 1)
+    var tmp = t._x;
+  t.autoSize = false;
+  t.wordWrap = true;
+  trace (t.scroll);
+};
+
+getURL ("fscommand:quit", "");
+
commit be1f2f94e1814f8b4558338c3d2777aad12ad9af
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 11:27:07 2008 +0200

    no signals anymore, we update ourselves now

diff --git a/swfdec/swfdec_text_layout.c b/swfdec/swfdec_text_layout.c
index 1fea5fa..c2be876 100644
--- a/swfdec/swfdec_text_layout.c
+++ b/swfdec/swfdec_text_layout.c
@@ -32,13 +32,6 @@
 
 #define BULLET_MARGIN 36
 
-enum {
-  CHANGED,
-  LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0, };
-
 static void
 swfdec_text_attribute_apply_bold (SwfdecTextLayout *layout, const SwfdecTextAttributes *attr,
     PangoFontDescription *desc)
@@ -446,8 +439,6 @@ swfdec_text_layout_invalidate (SwfdecTextLayout *layout)
   g_sequence_remove_range (g_sequence_get_begin_iter (layout->blocks),
     g_sequence_get_end_iter (layout->blocks));
   layout->layout_width = 0;
-
-  g_signal_emit (layout, signals[CHANGED], 0);
 }
 
 /*** LAYOUT ***/
@@ -478,10 +469,6 @@ swfdec_text_layout_class_init (SwfdecTextLayoutClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->dispose = swfdec_text_layout_dispose;
-
-  signals[CHANGED] = g_signal_new ("changed", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
-      G_TYPE_NONE, 0);
 }
 
 static void
commit e2ad8a7c4c6808582d72a337fe6711acc9167eb9
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 11:26:34 2008 +0200

    update variables from layout only sometimes
    
    This allows proper emission of onScroller and keeping variables like they are

diff --git a/swfdec/swfdec_text_field_movie.c b/swfdec/swfdec_text_field_movie.c
index 7b663c1..e4d149a 100644
--- a/swfdec/swfdec_text_field_movie.c
+++ b/swfdec/swfdec_text_field_movie.c
@@ -130,8 +130,9 @@ swfdec_text_field_movie_autosize (SwfdecTextFieldMovie *text)
   if (text->auto_size == SWFDEC_AUTO_SIZE_NONE)
     return;
 
-  x1 = swfdec_text_layout_get_width (text->layout);
-  z1 = swfdec_text_layout_get_height (text->layout);
+  swfdec_text_field_movie_update_layout (text);
+  x1 = text->layout_width;
+  z1 = text->layout_height;
   cairo_matrix_transform_distance (&text->from_layout, &x1, &z1);
   x1 += (BORDER_LEFT + BORDER_RIGHT) * SWFDEC_TWIPS_SCALE_FACTOR;
   z1 += (BORDER_TOP + BORDER_BOTTOM) * SWFDEC_TWIPS_SCALE_FACTOR;
@@ -292,8 +293,6 @@ swfdec_text_field_movie_dispose (GObject *object)
     text->text = NULL;
   }
   if (text->layout) {
-    g_signal_handlers_disconnect_matched (text->layout, G_SIGNAL_MATCH_DATA,
-	0, 0, NULL, NULL, text);
     g_object_unref (text->layout);
     text->layout = NULL;
   }
@@ -324,45 +323,42 @@ swfdec_text_field_movie_mark (SwfdecAsObject *object)
 
 /* NB: can be run with unlocked player */
 void
-swfdec_text_field_movie_update_scroll (SwfdecTextFieldMovie *text)
+swfdec_text_field_movie_update_layout (SwfdecTextFieldMovie *text)
 {
-  guint scroll_max, lines_visible, rows, height;
+  guint scroll_max, lines_visible, rows, height, max;
+  gboolean scroll_changed = FALSE;
+
+  text->layout_width = swfdec_text_layout_get_width (text->layout);
+  text->layout_height = swfdec_text_layout_get_height (text->layout);
 
   height = text->layout_area.height;
   rows = swfdec_text_layout_get_n_rows (text->layout);
   scroll_max = rows - swfdec_text_layout_get_visible_rows_end (text->layout, height);
   if (scroll_max != text->scroll_max) {
     text->scroll_max = scroll_max;
-    text->scroll_changed = TRUE;
+    scroll_changed = TRUE;
   }
   if (scroll_max < text->scroll) {
     text->scroll = scroll_max;
-    text->scroll_changed = TRUE;
+    scroll_changed = TRUE;
   }
   lines_visible = swfdec_text_layout_get_visible_rows (text->layout,
       text->scroll, height);
   if (lines_visible != text->lines_visible) {
     text->lines_visible = lines_visible;
-    text->scroll_changed = TRUE;
+    scroll_changed = TRUE;
   }
-}
-
-/* NB: This signal can happen without a locked player */
-static void
-swfdec_text_field_movie_layout_changed (SwfdecTextLayout *layout,
-    SwfdecTextFieldMovie *text)
-{
-  guint max;
-
-  if (swfdec_player_is_locked (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (text)->context)))
-    swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
-
-  swfdec_text_field_movie_update_scroll (text);
 
   max = swfdec_text_field_movie_get_hscroll_max (text);
   if (text->hscroll > max) {
     text->hscroll = max;
-    text->scroll_changed = TRUE;
+    scroll_changed = TRUE;
+  }
+
+  if (scroll_changed && !text->onScroller_emitted) {
+    swfdec_player_add_action (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (text)->context), 
+	SWFDEC_ACTOR (text), SWFDEC_EVENT_SCROLL, 0, SWFDEC_PLAYER_ACTION_QUEUE_NORMAL);
+    text->onScroller_emitted = TRUE;
   }
 }
 
@@ -446,8 +442,11 @@ swfdec_text_field_movie_init_movie (SwfdecMovie *movie)
 	G_CALLBACK (swfdec_text_field_movie_update_area), movie);
     parent = parent->parent;
   }
+  /* don't emit onScroller here, plz */
+  text->onScroller_emitted = TRUE;
+  swfdec_text_field_movie_update_layout (text);
+  text->onScroller_emitted = FALSE;
   swfdec_text_field_movie_update_area (text);
-  swfdec_text_field_movie_layout_changed (text->layout, text);
 }
 
 static void
@@ -475,10 +474,8 @@ swfdec_text_field_movie_iterate (SwfdecActor *actor)
     swfdec_actor_queue_script (actor, SWFDEC_EVENT_CHANGED);
     text->changed--;
   }
-  if (text->scroll_changed) {
-    swfdec_actor_queue_script (actor, SWFDEC_EVENT_SCROLL);
-    text->scroll_changed = FALSE;
-  }
+
+  text->onScroller_emitted = FALSE;
 }
 
 static SwfdecMovie *
@@ -886,8 +883,6 @@ swfdec_text_field_movie_init (SwfdecTextFieldMovie *text)
       G_CALLBACK (swfdec_text_field_movie_text_changed), text);
 
   text->layout = swfdec_text_layout_new (text->text);
-  g_signal_connect (text->layout, "changed",
-      G_CALLBACK (swfdec_text_field_movie_layout_changed), text);
 
   text->mouse_wheel_enabled = TRUE;
   text->character_pressed = -1;
@@ -1117,14 +1112,11 @@ swfdec_text_field_movie_set_text (SwfdecTextFieldMovie *text, const char *str,
 guint
 swfdec_text_field_movie_get_hscroll_max (SwfdecTextFieldMovie *text)
 {
-  guint width;
-
   g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), 0);
 
-  width = swfdec_text_layout_get_width (text->layout);
-  if ((guint) text->layout_area.width >= width)
+  if ((guint) text->layout_area.width >= text->layout_width)
     return 0;
   else
-    return width - text->layout_area.width;
+    return text->layout_width - text->layout_area.width;
 }
 
diff --git a/swfdec/swfdec_text_field_movie.h b/swfdec/swfdec_text_field_movie.h
index 226ae47..cbb70c6 100644
--- a/swfdec/swfdec_text_field_movie.h
+++ b/swfdec/swfdec_text_field_movie.h
@@ -62,8 +62,14 @@ struct _SwfdecTextFieldMovie {
   gboolean		background;
  
   SwfdecTextBuffer *	text;			/* the text + formatting */
-
   SwfdecTextLayout *	layout;			/* the layouted text */
+  /* cached values from the layout (updated sometimes via swfdec_text_field_movie_update_layout()) */
+  guint			layout_width;		/* width of the layout */
+  guint			layout_height;		/* height of the layout */
+  guint			scroll;			/* current scroll offset in lines (0-indexed) */
+  guint			scroll_max;		/* scroll must be smaller than this value */
+  guint			lines_visible;		/* number of lines currently visible */
+  guint			hscroll;		/* horizontal scrolling offset in pixels */
 
   const char *		variable;
 
@@ -74,13 +80,8 @@ struct _SwfdecTextFieldMovie {
   SwfdecAsObject *	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 */
+  gboolean		onScroller_emitted;	/* if any of the scroll attributes have changed and we haven't fired the event yet */
   guint			changed;		/* number of onChanged events we have to emit */
-  /* scroll variables */
-  guint			scroll;			/* current scroll offset in lines (0-indexed) */
-  guint			scroll_max;		/* scroll must be smaller than this value */
-  guint			lines_visible;		/* number of lines currently visible */
-  guint			hscroll;		/* horizontal scrolling offset in pixels */
   gboolean		mouse_wheel_enabled;
 
   const char *		restrict_;
@@ -102,7 +103,7 @@ void		swfdec_text_field_movie_set_text	(SwfdecTextFieldMovie *	movie,
 							 const char *		str,
 							 gboolean		html);
 void		swfdec_text_field_movie_autosize	(SwfdecTextFieldMovie *	text);
-void		swfdec_text_field_movie_update_scroll	(SwfdecTextFieldMovie * text);
+void		swfdec_text_field_movie_update_layout	(SwfdecTextFieldMovie * text);
 const char *	swfdec_text_field_movie_get_text	(SwfdecTextFieldMovie *	text);
 void		swfdec_text_field_movie_set_listen_variable 
 							(SwfdecTextFieldMovie *	text,
diff --git a/swfdec/swfdec_text_field_movie_as.c b/swfdec/swfdec_text_field_movie_as.c
index 9202b3d..79bca49 100644
--- a/swfdec/swfdec_text_field_movie_as.c
+++ b/swfdec/swfdec_text_field_movie_as.c
@@ -91,6 +91,7 @@ swfdec_text_field_movie_do_set_text (SwfdecAsContext *cx,
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
 
   swfdec_text_field_movie_set_text (text, value, FALSE);
+  swfdec_text_field_movie_update_layout (text);
 
   if (text->variable != NULL) {
     if (text->html) {
@@ -424,13 +425,12 @@ swfdec_text_field_movie_get_textHeight (SwfdecAsContext *cx,
     SwfdecAsValue *ret)
 {
   SwfdecTextFieldMovie *text;
-  guint height;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
 
   swfdec_movie_update (SWFDEC_MOVIE (text));
-  height = swfdec_text_layout_get_height (text->layout);
-  SWFDEC_AS_VALUE_SET_INT (ret, floor (height * 
+  swfdec_text_field_movie_update_layout (text);
+  SWFDEC_AS_VALUE_SET_INT (ret, floor (text->layout_height * 
 	text->from_layout.yy / SWFDEC_TWIPS_SCALE_FACTOR));
 }
 
@@ -440,13 +440,12 @@ swfdec_text_field_movie_get_textWidth (SwfdecAsContext *cx,
     SwfdecAsValue *ret)
 {
   SwfdecTextFieldMovie *text;
-  double width;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
 
   swfdec_movie_update (SWFDEC_MOVIE (text));
-  width = swfdec_text_layout_get_width (text->layout);
-  SWFDEC_AS_VALUE_SET_INT (ret, floor (width *
+  swfdec_text_field_movie_update_layout (text);
+  SWFDEC_AS_VALUE_SET_INT (ret, floor (text->layout_width *
 	text->from_layout.xx / SWFDEC_TWIPS_SCALE_FACTOR));
 }
 
@@ -619,9 +618,13 @@ swfdec_text_field_movie_do_set_hscroll (SwfdecAsContext *cx,
 
   value = CLAMP (value, 0, (int) swfdec_text_field_movie_get_hscroll_max (text));
   if ((guint) value != text->hscroll) {
-    text->hscroll = value;
-    text->scroll_changed = TRUE;
     swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+    text->hscroll = value;
+    if (!text->onScroller_emitted) {
+      swfdec_player_add_action (SWFDEC_PLAYER (cx), SWFDEC_ACTOR (text), 
+	  SWFDEC_EVENT_SCROLL, 0, SWFDEC_PLAYER_ACTION_QUEUE_NORMAL);
+      text->onScroller_emitted = TRUE;
+    }
   }
 }
 
@@ -698,12 +701,16 @@ swfdec_text_field_movie_do_set_scroll (SwfdecAsContext *cx,
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
 
-  value = CLAMP (value - 1, 0, (int) text->scroll_max);
-  if ((guint) value != text->scroll) {
+  if ((guint) value != text->scroll + 1) {
+    swfdec_text_field_movie_update_layout (text);
+    value = CLAMP (value - 1, 0, (int) text->scroll_max);
     text->scroll = value;
-    text->scroll_changed = TRUE;
-    swfdec_text_field_movie_update_scroll (text);
     swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+    if (!text->onScroller_emitted) {
+      swfdec_player_add_action (SWFDEC_PLAYER (cx), SWFDEC_ACTOR (text), 
+	  SWFDEC_EVENT_SCROLL, 0, SWFDEC_PLAYER_ACTION_QUEUE_NORMAL);
+      text->onScroller_emitted = TRUE;
+    }
   }
 }
 
commit dd1b7517658e2d249121eec6470db7326f42e20b
Author: Benjamin Otte <otte at gnome.org>
Date:   Tue Jun 24 11:25:59 2008 +0200

    create a _listeners variable for new TextFields

diff --git a/swfdec/swfdec_text_field_movie.c b/swfdec/swfdec_text_field_movie.c
index cc889f7..7b663c1 100644
--- a/swfdec/swfdec_text_field_movie.c
+++ b/swfdec/swfdec_text_field_movie.c
@@ -374,6 +374,7 @@ swfdec_text_field_movie_init_movie (SwfdecMovie *movie)
   SwfdecAsContext *cx;
   SwfdecAsValue val;
   SwfdecMovie *parent;
+  SwfdecAsObject *array;
   gboolean needs_unuse;
 
   needs_unuse = swfdec_sandbox_try_use (movie->resource->sandbox);
@@ -388,7 +389,17 @@ swfdec_text_field_movie_init_movie (SwfdecMovie *movie)
 	SWFDEC_AS_VALUE_GET_OBJECT (&val));
   }
 
-  // listen self
+  /* create _listeners array */
+  array = swfdec_as_array_new (cx);
+  if (array == NULL)
+    return;
+  SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (movie));
+  swfdec_as_array_push (SWFDEC_AS_ARRAY (array), &val);
+  SWFDEC_AS_VALUE_SET_OBJECT (&val, array);
+  swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_STR__listeners, 
+      &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+
+  /* add self to listeners */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (movie));
   swfdec_as_object_call (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_STR_addListener,
       1, &val, NULL);
commit 85efb99f0d227c5c9ead8a95e1482f42b800aa9b
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Jun 22 18:17:28 2008 +0200

    update reference images for cairo 1.7-git

diff --git a/test/image/gradient-beginGradientFill-6.swf.png b/test/image/gradient-beginGradientFill-6.swf.png
index da39a7f..77393ca 100644
Binary files a/test/image/gradient-beginGradientFill-6.swf.png and b/test/image/gradient-beginGradientFill-6.swf.png differ
diff --git a/test/image/gradient-beginGradientFill-7.swf.png b/test/image/gradient-beginGradientFill-7.swf.png
index da39a7f..77393ca 100644
Binary files a/test/image/gradient-beginGradientFill-7.swf.png and b/test/image/gradient-beginGradientFill-7.swf.png differ
diff --git a/test/image/gradient-beginGradientFill-8.swf.png b/test/image/gradient-beginGradientFill-8.swf.png
index da39a7f..f43f00e 100644
Binary files a/test/image/gradient-beginGradientFill-8.swf.png and b/test/image/gradient-beginGradientFill-8.swf.png differ
diff --git a/test/image/gradient-ratios.swf.png b/test/image/gradient-ratios.swf.png
index 855eba3..8d74a7b 100644
Binary files a/test/image/gradient-ratios.swf.png and b/test/image/gradient-ratios.swf.png differ
diff --git a/test/image/image-jpeg-alpha.swf.png b/test/image/image-jpeg-alpha.swf.png
index 83a422b..ec9c168 100644
Binary files a/test/image/image-jpeg-alpha.swf.png and b/test/image/image-jpeg-alpha.swf.png differ


More information about the Swfdec-commits mailing list