Author: fejj
Date: 2008-02-08 15:04:00 -0500 (Fri, 08 Feb 2008)
New Revision: 95297
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/xaml.cpp
Log:
2008-02-08 Jeffrey Stedfast <[EMAIL PROTECTED]>
Fixes some text layout bugs in TextBlockFontFamilies.xaml
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2008-02-08 19:47:30 UTC (rev 95296)
+++ trunk/moon/src/ChangeLog 2008-02-08 20:04:00 UTC (rev 95297)
@@ -1,3 +1,18 @@
+2008-02-08 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ Fixes some text layout bugs in TextBlockFontFamilies.xaml
+
+ * xaml.cpp (flush_char_data): Now takes a string 'next_element'
+ argument rather than a bool 'start' argument so that we can make
+ sure that the previous and next element types are <Run>'s because
+ lwsp between a <LineBreak/> and a <Run> or a </Run> and a
+ <LineBreak/> should be ignored. Also, never g_strchomp() this
+ cdata.
+ (start_element_handler): Pass the name of the next element to
+ flush_char_data().
+ (end_element_handler): Pass NULL to flush_char_data() as the
+ next_element argument.
+
2008-02-08 Chris Toshok <[EMAIL PROTECTED]>
* media.cpp (MediaElement::Render): reorder things so that we're
Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp 2008-02-08 19:47:30 UTC (rev 95296)
+++ trunk/moon/src/xaml.cpp 2008-02-08 20:04:00 UTC (rev 95297)
@@ -891,7 +891,7 @@
}
static void
-flush_char_data (XamlParserInfo *p, bool start)
+flush_char_data (XamlParserInfo *p, const char *next_element)
{
DependencyProperty *content;
const char *prop_name = NULL;
@@ -899,7 +899,7 @@
if (!p->has_cdata || !p->current_element)
return;
-
+
if (p->current_element->info)
prop_name = p->current_element->info->content_property;
@@ -924,15 +924,16 @@
p->current_element->item->SetValue (content, Value
(p->cdata->str));
} else if (p->current_element->item && is_instance_of
(p->current_element, Type::TEXTBLOCK)) {
Inlines *inlines = text_block_get_inlines ((TextBlock *)
p->current_element->item);
+ List::Node *last = inlines ? inlines->list->Last () : NULL;
- if (!p->cdata && inlines && !inlines->list->IsEmpty () &&
start) {
+ if (!p->cdata && next_element && !strcmp (next_element, "Run")
&& inlines &&
+ last && ((Collection::Node *) last)->obj->GetObjectType ()
== Type::RUN) {
// LWSP between <Run> elements is to be treated as a
single-SPACE <Run> element
p->cdata = g_string_new (" ");
- } else if (p->cdata) {
- // This is the normal case
- g_strchomp (p->cdata->str);
- } else {
- // This is either LWSP before the first <Run> element
or after the last <Run> element
+ } else if (!p->cdata) {
+ // This is either LWSP before the first <Run> element,
+ // after the last <Run> element, or between a <Run>
+ // element and a <LineBreak> element.
goto done;
}
@@ -968,22 +969,28 @@
return;
char **name = g_strsplit (el, "|", -1);
+ XamlNamespace *next_namespace = NULL;
char *element = NULL;
-
- flush_char_data (p, true);
-
- p->current_namespace = NULL;
+
if (g_strv_length (name) == 2) {
- // Find the proper namespace
- p->current_namespace = (XamlNamespace *) g_hash_table_lookup
(p->namespace_map, name [0]);
+ // Find the proper namespace for our next element
+ next_namespace = (XamlNamespace *) g_hash_table_lookup
(p->namespace_map, name [0]);
element = name [1];
}
-
- if (!p->current_namespace && p->implicit_default_namespace) {
- p->current_namespace = default_namespace;
+
+ if (!next_namespace && p->implicit_default_namespace) {
+ // Use the default namespace for the next element
+ next_namespace = default_namespace;
element = name [0];
}
-
+
+ // Flush our cdata, passing the name of the next element so it
+ // can do smart things for TextBlock cdata (and maybe others).
+ flush_char_data (p, element);
+
+ // Now update our namespace
+ p->current_namespace = next_namespace;
+
if (!p->current_namespace) {
if (name [1])
parser_error (p, name [1], NULL, -1, g_strdup_printf
("No handlers available for namespace: '%s' (%s)\n", name [0], el));
@@ -1009,7 +1016,7 @@
switch (info->current_element->element_type) {
case XamlElementInstance::ELEMENT:
- flush_char_data (info, false);
+ flush_char_data (info, NULL);
break;
case XamlElementInstance::PROPERTY: {
List::Node *walk = info->current_element->children->First ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches