changeset 1370:f231450b81a1

let later space override previous space The earlier space is less likely to be styled with the intended appearance.
author corvid <corvid@lavabit.com>
date Mon, 26 Oct 2009 23:04:46 +0000
parents 9f6a30a418f3
children 94d8df3cb645
files dw/textblock.cc src/form.cc src/html.cc src/html_common.hh
diffstat 4 files changed, 6 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/dw/textblock.cc	Mon Oct 26 22:26:53 2009 +0000
+++ b/dw/textblock.cc	Mon Oct 26 23:04:46 2009 +0000
@@ -1706,10 +1706,11 @@
          //                    page->words[nw].eff_space);
          //DBG_OBJ_ARRSET_NUM (page, "words.%d.content.space", nw,
          //                    page->words[nw].content.space);
-
-         words->getRef(nw)->spaceStyle->unref ();
-         words->getRef(nw)->spaceStyle = style;
-         style->ref ();
+         if (style != words->getRef(nw)->spaceStyle) {
+            words->getRef(nw)->spaceStyle->unref ();
+            words->getRef(nw)->spaceStyle = style;
+            style->ref ();
+         }
       }
    }
 }
--- a/src/form.cc	Mon Oct 26 22:26:53 2009 +0000
+++ b/src/form.cc	Mon Oct 26 23:04:46 2009 +0000
@@ -552,7 +552,6 @@
 //                                   strtol(attrbuf, NULL, 10));
       }
       HT2TB(html)->addWidget (embed, html->styleEngine->backgroundStyle());
-      html->PrevWasSPC = false;
    }
    dFree(type);
    dFree(name);
@@ -596,7 +595,6 @@
    Html_add_input(html, DILLO_HTML_INPUT_INDEX, embed, NULL, NULL, FALSE);
 
    HT2TB(html)->addWidget (embed, html->styleEngine->backgroundStyle ());
-   html->PrevWasSPC = false;
 
    a_Url_free(action);
    html->InFlags &= ~IN_FORM;
@@ -665,7 +663,6 @@
    Html_add_input(html, DILLO_HTML_INPUT_TEXTAREA, embed, name, NULL, false);
 
    HT2TB(html)->addWidget (embed, html->styleEngine->backgroundStyle ());
-   html->PrevWasSPC = false;
    dFree(name);
 }
 
@@ -752,7 +749,6 @@
    HT2TB(html)->addWidget (embed, html->styleEngine->backgroundStyle ());
 
    Html_add_input(html, type, embed, name, NULL, false);
-   html->PrevWasSPC = false;
    a_Html_stash_init(html);
    dFree(name);
 }
@@ -1917,7 +1913,6 @@
             factory->createComplexButtonResource(IM2DW(Image), false);
          button = new Embed(complex_b_r);
          HT2TB(html)->addWidget (button, html->styleEngine->style ());
-         html->PrevWasSPC = false;
 //       gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */
 
          /* a right button press brings up the image menu */
--- a/src/html.cc	Mon Oct 26 22:26:53 2009 +0000
+++ b/src/html.cc	Mon Oct 26 23:04:46 2009 +0000
@@ -449,7 +449,6 @@
    pre_column = 0;
    PreFirstChar = false;
    PrevWasCR = false;
-   PrevWasSPC = false;
    InVisitedLink = false;
    ReqTagClose = false;
    TagSoup = true;
@@ -1106,9 +1105,8 @@
    } else {
       if (SGML_SPCDEL) {
          /* SGML_SPCDEL ignores white space immediately after an open tag */
-      } else if (!html->PrevWasSPC) {
+      } else {
          HT2TB(html)->addSpace(html->styleEngine->wordStyle ());
-         html->PrevWasSPC = true;
       }
 
       if (parse_mode == DILLO_HTML_PARSE_MODE_STASH_AND_BODY)
@@ -1199,7 +1197,6 @@
             i += len;
             HT2TB(html)->addText(word2 + start, i - start,
                                  html->styleEngine->wordStyle ());
-            html->PrevWasSPC = false;
          } else {
             do {
                i += len;
@@ -1207,7 +1204,6 @@
                      (!a_Utf8_ideographic(word2+i, word2_end, &len)));
             HT2TB(html)->addText(word2 + start, i - start,
                                  html->styleEngine->wordStyle ());
-            html->PrevWasSPC = false;
          }
       }
       if (Pword == word2)
@@ -2158,7 +2154,6 @@
 
    Image = a_Html_image_new(html, tag, tagsize, url);
    HT2TB(html)->addWidget((Widget*)Image->dw, html->styleEngine->style());
-   html->PrevWasSPC = false;
 
    /* Image maps */
    if (a_Html_get_attr(html, tag, tagsize, "ismap")) {
@@ -2657,11 +2652,9 @@
       }
       numtostr((*list_number)++, buf, 16, style->listStyleType);
       list_item->initWithText (buf, wordStyle);
-      html->PrevWasSPC = true; /* space added in initWithText */
    } else {
       // unordered
       list_item->initWithWidget (new Bullet(), wordStyle);
-      html->PrevWasSPC = true; /* space added in initWithWidget */
    }
 }
 
--- a/src/html_common.hh	Mon Oct 26 22:26:53 2009 +0000
+++ b/src/html_common.hh	Mon Oct 26 23:04:46 2009 +0000
@@ -168,7 +168,6 @@
    bool PreFirstChar;     /* used to skip the first CR or CRLF in PRE tags */
    bool PrevWasCR;        /* Flag to help parsing of "\r\n" in PRE tags */
    bool PrevWasOpenTag;   /* Flag to help deferred parsing of white space */
-   bool PrevWasSPC;       /* Flag to help handling collapsing white space */
    bool InVisitedLink;    /* used to 'contrast_visited_colors' */
    bool ReqTagClose;      /* Flag to help handling bad-formed HTML */
    bool TagSoup;          /* Flag to enable the parser's cleanup functions */