changeset 184:e9c8fd71790a

- Improved parsing of collapsing white space.
author jcid
date Thu, 17 Apr 2008 22:25:03 +0200
parents 3c5a98e4ffb5
children 1bfc8712f980
files ChangeLog configure.in dpi/ftp.c src/html.cc
diffstat 4 files changed, 13 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 15 20:38:31 2008 +0200
+++ b/ChangeLog	Thu Apr 17 22:25:03 2008 +0200
@@ -50,6 +50,7 @@
  - Fixed a SEGFAULT bug in http.c (handling of web->url).
  - Fixed handling of #anchors with repush, and other operations.
  - Implemented a_Dialog_choice5(). May be used by dpis and dillo.
+ - Improved parsing of collapsing white space.
    Patches: Jorge Arellano Cid
 +- Connected signals to <li> elements (fixes links within lists).
  - Enabled text, background-color, panel_size, geometry, fullscreen,
--- a/configure.in	Tue Apr 15 20:38:31 2008 +0200
+++ b/configure.in	Thu Apr 17 22:25:03 2008 +0200
@@ -81,7 +81,7 @@
 typedef unsigned short  ushort_t;
 typedef unsigned long   ulong_t;
 typedef unsigned int    uint_t; 
-typedef int             bool_t;
+typedef unsigned char   bool_t;
 
 
 #endif /* __D_SIZE_H__ */
--- a/dpi/ftp.c	Tue Apr 15 20:38:31 2008 +0200
+++ b/dpi/ftp.c	Thu Apr 17 22:25:03 2008 +0200
@@ -173,7 +173,7 @@
 
    ssize_t n;
    int nb, minibuf_sz;
-   const char *mime_type;
+   const char *mime_type = "application/octet-stream";
    char buf[4096], minibuf[MinSZ], *d_cmd;
    pid_t ch_pid;
    int aborted = 0;
--- a/src/html.cc	Tue Apr 15 20:38:31 2008 +0200
+++ b/src/html.cc	Thu Apr 17 22:25:03 2008 +0200
@@ -304,6 +304,7 @@
    bool_t PrevWasCR;      /* Flag to help parsing of "\r\n" in PRE tags */
    bool_t PrevWasOpenTag; /* Flag to help deferred parsing of white space */
    bool_t SPCPending;     /* Flag to help deferred parsing of white space */
+   bool_t PrevWasSPC;     /* Flag to help handling collapsing white space */
    bool_t InVisitedLink;  /* used to 'contrast_visited_colors' */
    bool_t ReqTagClose;    /* Flag to help handling bad-formed HTML */
    bool_t CloseOneTag;    /* Flag to help Html_tag_cleanup_at_close() */
@@ -842,6 +843,7 @@
    PreFirstChar = FALSE;
    PrevWasCR = FALSE;
    PrevWasOpenTag = FALSE;
+   PrevWasSPC = FALSE;
    SPCPending = FALSE;
    InVisitedLink = FALSE;
    ReqTagClose = FALSE;
@@ -1482,11 +1484,14 @@
       html->SPCPending = FALSE;
 
    } else {
-      if (SGML_SPCDEL && html->PrevWasOpenTag) {
+      if (SGML_SPCDEL) {
          /* SGML_SPCDEL ignores white space inmediately after an open tag */
+         if (html->PrevWasOpenTag)
+            html->SPCPending = FALSE;
+      } else if (!html->PrevWasSPC) {
+         DW2TB(html->dw)->addSpace(S_TOP(html)->style);
          html->SPCPending = FALSE;
-      } else {
-         html->SPCPending = TRUE;
+         html->PrevWasSPC = TRUE;
       }
 
       if (parse_mode == DILLO_HTML_PARSE_MODE_STASH_AND_BODY)
@@ -1544,11 +1549,6 @@
       dFree(Pword);
 
    } else {
-      /* add pending space if present */
-      if (html->SPCPending && (!SGML_SPCDEL || !html->PrevWasOpenTag))
-         /* SGML_SPCDEL ignores space after an open tag */
-         DW2TB(html->dw)->addSpace (S_TOP(html)->style);
-
       /* Collapse white-space entities inside the word (except &nbsp;) */
       Pword = Html_parse_entities(html, word, size);
       for (i = 0; Pword[i]; ++i)
@@ -1559,6 +1559,7 @@
    }
 
    html->PrevWasOpenTag = FALSE;
+   html->PrevWasSPC = FALSE;
    html->SPCPending = FALSE;
    if (html->InFlags & IN_LI)
       html->WordAfterLI = TRUE;
@@ -2631,7 +2632,6 @@
  */
 static void Html_tag_open_font(DilloHtml *html, const char *tag, int tagsize)
 {
-#if 1
    StyleAttrs style_attrs;
    Style *old_style;
    /*Font font;*/
@@ -2665,8 +2665,6 @@
          Style::create (HT2LT(html), &style_attrs);
       old_style->unref ();
    }
-
-#endif
 }
 
 /*
@@ -3329,6 +3327,7 @@
       numtostr((*list_number)++, buf, 16, S_TOP(html)->style->listStyleType);
       list_item->initWithText (dStrdup(buf), word_style);
       list_item->addSpace (word_style);
+      html->PrevWasSPC = TRUE;
       break;
    case HTML_LIST_NONE:
       MSG_HTML("<li> outside <ul> or <ol>\n");
@@ -5393,22 +5392,6 @@
    if (ni != -1 && !(html->InFlags & IN_BODY) /* && parsing HTML */)
       Html_test_section(html, ni, IsCloseTag);
 
-   /* White space handling */
-   if (html->SPCPending) {
-      if (SGML_SPCDEL) {
-         /* SGML_SPCDEL requires space pending and open tag */
-         if (!IsCloseTag)
-            DW2TB(html->dw)->addSpace(S_TOP(html)->style);
-         html->SPCPending = FALSE;
-      } else {
-         /* custom space handling: preserve pending space past close tags */
-         if (!IsCloseTag) {
-            DW2TB(html->dw)->addSpace(S_TOP(html)->style);
-            html->SPCPending = FALSE;
-         }
-      }
-   }
-
    /* Tag processing */
    ci = S_TOP(html)->tag_idx;
    if (ni != -1) {