[Swfdec] 4 commits - libswfdec/swfdec_as_object.c libswfdec/swfdec_movie.c libswfdec/swfdec_policy_loader.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_format.c
Pekka Lampila
medar at kemper.freedesktop.org
Wed Dec 5 04:56:15 PST 2007
libswfdec/swfdec_as_object.c | 3 +++
libswfdec/swfdec_movie.c | 4 +++-
libswfdec/swfdec_policy_loader.c | 19 ++++++++++++++-----
libswfdec/swfdec_text_field_movie.c | 35 ++++++++++++++++++-----------------
libswfdec/swfdec_text_format.c | 30 ++++++++++++++++--------------
5 files changed, 54 insertions(+), 37 deletions(-)
New commits:
commit ddc4d3c38d035cfa50fc37580e15fa34b5c1755b
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Wed Dec 5 14:19:07 2007 +0200
Fix an assert in policy loader with localWithNetwork files
diff --git a/libswfdec/swfdec_policy_loader.c b/libswfdec/swfdec_policy_loader.c
index 4158f27..983a034 100644
--- a/libswfdec/swfdec_policy_loader.c
+++ b/libswfdec/swfdec_policy_loader.c
@@ -61,7 +61,6 @@ swfdec_policy_loader_check (SwfdecAsContext *context, const char *text,
g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
g_return_val_if_fail (text != NULL, FALSE);
- g_return_val_if_fail (host != NULL, FALSE);
xml = swfdec_xml_new_no_properties (context, text, TRUE);
@@ -75,7 +74,11 @@ swfdec_policy_loader_check (SwfdecAsContext *context, const char *text,
return FALSE;
}
- host_lower = g_ascii_strdown (host, -1);
+ if (host != NULL) {
+ host_lower = g_ascii_strdown (host, -1);
+ } else {
+ host_lower = NULL;
+ }
for (i = 0; i < swfdec_xml_node_num_children (SWFDEC_XML_NODE (xml)); i++) {
SwfdecXmlNode *node_cdp =
@@ -90,6 +93,8 @@ swfdec_policy_loader_check (SwfdecAsContext *context, const char *text,
for (j = 0; j < swfdec_xml_node_num_children (node_cdp); j++) {
SwfdecXmlNode *node_aaf = swfdec_xml_node_get_child (node_cdp, j);
const char *value;
+ GPatternSpec *pattern;
+ char *value_lower;
if (node_aaf->type != SWFDEC_XML_NODE_ELEMENT)
continue;
@@ -100,10 +105,10 @@ swfdec_policy_loader_check (SwfdecAsContext *context, const char *text,
// FIXME: secure attribute?
value = swfdec_xml_node_get_attribute (node_aaf, SWFDEC_AS_STR_domain);
- if (value != NULL) {
- GPatternSpec *pattern;
- char *value_lower;
+ if (value == NULL)
+ continue;
+ if (host != NULL) {
// GPatternSpec uses ? as a wildcard character, but we won't
// And there can't be a host that has ? character
if (strchr (value, '?') != NULL)
@@ -120,6 +125,10 @@ swfdec_policy_loader_check (SwfdecAsContext *context, const char *text,
}
g_pattern_spec_free (pattern);
+ } else {
+ // in case we don't have a host name, only match asterisks
+ if (value[strspn (value, "*")] == '\0')
+ return TRUE;
}
}
}
commit c1896a147ad3aca9993a12957be9b51ecb6a17b1
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Wed Dec 5 13:10:52 2007 +0200
Fix handling of tab stops when creating of the array fails
diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index db37d98..3dba372 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -110,13 +110,17 @@ swfdec_text_paragraph_add_block (SwfdecParagraph *paragraph, int index_,
block->left_margin = format->left_margin * 20;
block->right_margin = format->right_margin * 20;
- length = swfdec_as_array_get_length (format->tab_stops);
- block->tab_stops = pango_tab_array_new (length, TRUE);
- for (i = 0; i < length; i++) {
- swfdec_as_array_get_value (format->tab_stops, i, &val);
- g_assert (SWFDEC_AS_VALUE_IS_NUMBER (&val));
- pango_tab_array_set_tab (block->tab_stops, i, PANGO_TAB_LEFT,
- SWFDEC_AS_VALUE_GET_NUMBER (&val) * 20);
+ if (format->tab_stops != NULL) {
+ length = swfdec_as_array_get_length (format->tab_stops);
+ block->tab_stops = pango_tab_array_new (length, TRUE);
+ for (i = 0; i < length; i++) {
+ swfdec_as_array_get_value (format->tab_stops, i, &val);
+ g_assert (SWFDEC_AS_VALUE_IS_NUMBER (&val));
+ pango_tab_array_set_tab (block->tab_stops, i, PANGO_TAB_LEFT,
+ SWFDEC_AS_VALUE_GET_NUMBER (&val) * 20);
+ }
+ } else {
+ block->tab_stops = NULL;
}
paragraph->blocks = g_slist_prepend (paragraph->blocks, block);
@@ -368,7 +372,8 @@ swfdec_text_field_movie_free_paragraphs (SwfdecParagraph *paragraphs)
for (i = 0; paragraphs[i].blocks != NULL; i++)
{
for (iter = paragraphs[i].blocks; iter != NULL; iter = iter->next) {
- pango_tab_array_free (((SwfdecBlock *)(iter->data))->tab_stops);
+ if (((SwfdecBlock *)(iter->data))->tab_stops)
+ pango_tab_array_free (((SwfdecBlock *)(iter->data))->tab_stops);
g_free (iter->data);
}
g_slist_free (paragraphs[i].blocks);
@@ -585,7 +590,8 @@ swfdec_text_field_movie_get_layouts (SwfdecTextFieldMovie *text, int *num,
// set block styles
pango_layout_set_spacing (playout, block->leading);
- pango_layout_set_tabs (playout, block->tab_stops);
+ if (block->tab_stops != NULL)
+ pango_layout_set_tabs (playout, block->tab_stops);
// set text attributes
attr_list = swfdec_text_field_movie_paragraph_get_attr_list (
diff --git a/libswfdec/swfdec_text_format.c b/libswfdec/swfdec_text_format.c
index f6485c4..79e82ee 100644
--- a/libswfdec/swfdec_text_format.c
+++ b/libswfdec/swfdec_text_format.c
@@ -737,8 +737,7 @@ swfdec_text_format_do_set_tab_stops (SwfdecAsContext *cx,
SWFDEC_AS_VALUE_IS_NULL (&argv[0]))
{
format->tab_stops = NULL;
- swfdec_text_format_mark_unset (format,
- PROP_TAB_STOPS);
+ swfdec_text_format_mark_unset (format, PROP_TAB_STOPS);
}
else if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) &&
SWFDEC_IS_AS_ARRAY (SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))
@@ -756,8 +755,9 @@ swfdec_text_format_do_set_tab_stops (SwfdecAsContext *cx,
if (len == 0)
return;
format->tab_stops = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- swfdec_text_format_mark_set (format,
- PROP_TAB_STOPS);
+ if (!format->tab_stops)
+ return;
+ swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
}
swfdec_as_array_set_length (format->tab_stops, 0);
@@ -782,23 +782,25 @@ swfdec_text_format_do_set_tab_stops (SwfdecAsContext *cx,
PROP_TAB_STOPS);
} else {
format->tab_stops = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- swfdec_text_format_mark_set (format,
- PROP_TAB_STOPS);
- if (cx->version >= 8) {
- SWFDEC_AS_VALUE_SET_INT (&val, -2147483648);
+ if (format->tab_stops != NULL) {
+ swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
+ if (cx->version >= 8) {
+ SWFDEC_AS_VALUE_SET_INT (&val, -2147483648);
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (&val, 0);
+ }
+ for (i = 0; i < len; i++) {
+ swfdec_as_array_push (format->tab_stops, &val);
+ }
} else {
- SWFDEC_AS_VALUE_SET_INT (&val, 0);
- }
- for (i = 0; i < len; i++) {
- swfdec_as_array_push (format->tab_stops, &val);
+ swfdec_text_format_mark_unset (format, PROP_TAB_STOPS);
}
}
}
else if (swfdec_text_format_is_set (format, PROP_TAB_STOPS))
{
swfdec_as_array_set_length (format->tab_stops, 0);
- swfdec_text_format_mark_set (format,
- PROP_TAB_STOPS);
+ swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
}
}
commit ff8d1f6311b3c8d834d3727743914716db81a5ba
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Tue Dec 4 09:58:18 2007 +0200
Fix an assert in LoadVariables code
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
index d1995c8..194f858 100644
--- a/libswfdec/swfdec_as_object.c
+++ b/libswfdec/swfdec_as_object.c
@@ -1649,6 +1649,9 @@ swfdec_as_object_decode (SwfdecAsObject *object, const char *str)
char **varlist, *p, *unescaped;
guint i;
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (str != NULL);
+
varlist = g_strsplit (str, "&", -1);
for (i = 0; varlist[i] != NULL; i++) {
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 657b519..567da71 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -1612,9 +1612,11 @@ static void
swfdec_movie_load_variables_on_finish (SwfdecAsObject *target,
const char *text)
{
- swfdec_as_object_decode (target, text);
+ if (text != NULL)
+ swfdec_as_object_decode (target, text);
// only call onData for sprite movies
+ // FIXME: is it called even when loading fails?
if (target->context->version >= 6 && SWFDEC_IS_SPRITE_MOVIE (target))
swfdec_as_object_call (target, SWFDEC_AS_STR_onData, 0, NULL, NULL);
}
commit edb43b373fd05f677fea268effca532789aa163c
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Tue Dec 4 01:00:44 2007 +0200
Fix a problem in TextField's render code, triggered by underlined text at least
Don't make assumptions about cairo context position after pango calls, just use
cairo_move_to always
diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index 1f88654..db37d98 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -807,8 +807,6 @@ swfdec_text_field_movie_render (SwfdecMovie *movie, cairo_t *cr,
cairo_fill (cr);
}
- cairo_move_to (cr, x, y);
-
skipped = 0;
do {
if (++linenum < MIN (text_movie->scroll, text_movie->scroll_max))
@@ -833,21 +831,18 @@ swfdec_text_field_movie_render (SwfdecMovie *movie, cairo_t *cr,
x + layout->offset_x + rect.x + rect.width < limit.x0)
continue;
+ cairo_move_to (cr, x, y);
+
if (pango_layout_iter_at_last_line (iter_line))
cairo_rel_move_to (cr, 0, layout->last_line_offset_y);
cairo_rel_move_to (cr, layout->offset_x + rect.x,
pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE - skipped);
+
line = pango_layout_iter_get_line_readonly (iter_line);
pango_cairo_show_layout_line (cr, line);
- cairo_rel_move_to (cr, -(layout->offset_x + rect.x),
- -(pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE -
- skipped));
- if (pango_layout_iter_at_last_line (iter_line))
- cairo_rel_move_to (cr, 0, -layout->last_line_offset_y);
} while (pango_layout_iter_next_line (iter_line));
if (linenum >= MIN (text_movie->scroll, text_movie->scroll_max)) {
- cairo_rel_move_to (cr, 0, layout->height - skipped);
y += layout->height - skipped;
skipped = 0;
}
More information about the Swfdec
mailing list