aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/bw.c4
-rw-r--r--src/bw.h5
-rw-r--r--src/html.cc22
-rw-r--r--src/html_common.hh1
-rw-r--r--src/nav.c7
6 files changed, 24 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index b932fdb9..c652b238 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,7 @@ dillo-2.1
? Trying a new iconv() test in configure.in.
- Allowed the rc parser to skip whitespace around the equal sign.
- Fixed the parser not to call Html_tag_close_* functions twice.
+ - Implemented CSS Stylesheet loading.
Patches: Jorge Arellano Cid
dw
diff --git a/src/bw.c b/src/bw.c
index 27f3066c..d0c92086 100644
--- a/src/bw.c
+++ b/src/bw.c
@@ -63,6 +63,7 @@ BrowserWindow *a_Bw_new()
bw->ImageClients = dList_new(8);
bw->NumImages = 0;
bw->NumImagesGot = 0;
+ bw->NumPendingStyleSheets = 0;
bw->PageUrls = dList_new(8);
bw->Docs = dList_new(8);
@@ -253,6 +254,9 @@ void a_Bw_cleanup(BrowserWindow *bw)
/* Zero image-progress data */
bw->NumImages = 0;
bw->NumImagesGot = 0;
+
+ /* Zero stylesheet counter */
+ bw->NumPendingStyleSheets = 0;
}
/*--------------------------------------------------------------------------*/
diff --git a/src/bw.h b/src/bw.h
index 4345bf54..1dcf3a3a 100644
--- a/src/bw.h
+++ b/src/bw.h
@@ -38,6 +38,8 @@ struct _BrowserWindow
int NumImages;
/* Number of images already loaded */
int NumImagesGot;
+ /* Number of not yet arrived style sheets */
+ int NumPendingStyleSheets;
/* List of all Urls requested by this page (and its types) */
Dlist *PageUrls;
@@ -57,8 +59,7 @@ struct _BrowserWindow
* redirection loops (accounts for WEB_RootUrl only) */
int redirect_level;
- /* TODO: maybe this fits better in the linkblock.
- * Although having it here avoids having a signal for handling it. */
+ /* HTML-bugs detected at parse time */
int num_page_bugs;
Dstr *page_bugs;
};
diff --git a/src/html.cc b/src/html.cc
index 772c0bb1..0bfa0420 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -430,7 +430,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
stop_parser = false;
stop_parser_after_head = false;
repush_after_head = false;
- repush_after_stylesheet = false;
CurrTagOfs = 0;
OldTagOfs = 0;
@@ -2907,12 +2906,17 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
}
}
+/*
+ * Called by the network engine when a stylesheet has new data.
+ */
static void Html_css_load_callback(int Op, CacheClient_t *Client)
{
- MSG("Css_callback: Op=%d\n", Op);
+ _MSG("Css_callback: Op=%d\n", Op);
if (Op) { /* EOF */
- // May check num_style_sheets here...
- a_Nav_repush(((DilloWeb *)Client->Web)->bw);
+ BrowserWindow *bw = ((DilloWeb *)Client->Web)->bw;
+ /* Repush when we've got them all */
+ if (--bw->NumPendingStyleSheets == 0)
+ a_Nav_repush(bw);
}
}
@@ -2935,9 +2939,11 @@ static void Html_load_stylesheet(DilloHtml *html, DilloUrl *url)
Web->bw = html->bw;
//Web->flags |= WEB_Stylesheet;
if ((ClientKey = a_Capi_open_url(Web, Html_css_load_callback, NULL))) {
- html->repush_after_stylesheet = true;
+ ++html->bw->NumPendingStyleSheets;
a_Bw_add_client(html->bw, ClientKey, 0);
a_Bw_add_url(html->bw, url);
+ MSG("Html_load_stylesheet: NumPendingStyleSheets=%d\n",
+ html->bw->NumPendingStyleSheets);
}
}
}
@@ -2964,9 +2970,6 @@ static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize)
BUG_MSG("the LINK element must be inside the HEAD section\n");
return;
}
- /* Load only one stylesheet by now... */
- if (html->repush_after_stylesheet)
- return;
/* TODO: How will we know when to use "handheld"? Ask the html->bw->ui for
screen dimensions, or a dillorc preference. */
@@ -2985,8 +2988,7 @@ static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize)
return;
MSG(" Html_tag_open_link(): URL=%s\n", URL_STR(url));
- MSG(" repush after HEAD=%d SHEET=%d\n",
- html->repush_after_head, html->repush_after_stylesheet);
+ MSG(" repush after HEAD=%d\n", html->repush_after_head);
Html_load_stylesheet(html, url);
a_Url_free(url);
diff --git a/src/html_common.hh b/src/html_common.hh
index ead9cf14..4c6f40c5 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -174,7 +174,6 @@ public: //BUG: for now everything is public
bool stop_parser_after_head;
bool repush_after_head;
- bool repush_after_stylesheet;
size_t CurrTagOfs;
size_t OldTagOfs, OldTagLine;
diff --git a/src/nav.c b/src/nav.c
index c441ddfd..3450d5aa 100644
--- a/src/nav.c
+++ b/src/nav.c
@@ -194,12 +194,13 @@ static void Nav_stack_clean(BrowserWindow *bw)
static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset)
{
DilloUrl *old_url;
- bool_t MustLoad, ForceReload;
+ bool_t MustLoad, ForceReload, Repush;
int x, y, idx, ClientKey;
DilloWeb *Web;
MSG("Nav_open_url: new url='%s'\n", URL_STR_(url));
+ Repush = (URL_FLAGS(url) & URL_ReloadFromCache);
ForceReload = (URL_FLAGS(url) & (URL_E2EQuery + URL_ReloadFromCache)) != 0;
/* Get the url of the current page */
@@ -207,8 +208,8 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset)
old_url = a_History_get_url(NAV_UIDX(bw, idx));
_MSG("Nav_open_url: old_url='%s' idx=%d\n", URL_STR(old_url), idx);
/* Record current scrolling position */
- if (URL_FLAGS(url) & URL_ReloadFromCache) {
- /* Repush operation, don't change scroll position */
+ if (Repush) {
+ /* Don't change scroll position */
} else if (old_url) {
a_UIcmd_get_scroll_xy(bw, &x, &y);
Nav_save_scroll_pos(bw, idx, x, y);