r3874 tlsa - in /trunk/netsurf: content/content.h desktop/options.c desktop/options.h render/html.c riscos/options.h
by netsurf@semichrome.net
Author: tlsa
Date: Fri Feb 29 23:03:26 2008
New Revision: 3874
URL: http://source.netsurf-browser.org?rev=3874&view=rev
Log:
Periodically reflow the page while fetching a page's objects. Make buffer all rendering default.
Modified:
trunk/netsurf/content/content.h
trunk/netsurf/desktop/options.c
trunk/netsurf/desktop/options.h
trunk/netsurf/render/html.c
trunk/netsurf/riscos/options.h
Modified: trunk/netsurf/content/content.h
URL: http://source.netsurf-browser.org/trunk/netsurf/content/content.h?rev=387...
==============================================================================
--- trunk/netsurf/content/content.h (original)
+++ trunk/netsurf/content/content.h Fri Feb 29 23:03:26 2008
@@ -97,7 +97,7 @@
/** Extra data for some content_msg messages. */
union content_msg_data {
const char *error; /**< Error message, for CONTENT_MSG_ERROR. */
- const char *new_url; /**< Replacement URL (or NULL if the same
+ const char *new_url; /**< Replacement URL (or NULL if the same
* as previous), for CONTENT_MSG_NEWPTR. */
/** Area of content which needs redrawing, for CONTENT_MSG_REDRAW. */
struct {
@@ -204,6 +204,10 @@
unsigned int time; /**< Creation time, if TYPE_UNKNOWN,
LOADING or READY,
otherwise total time. */
+
+ unsigned int reformat_time; /**< Time the HTML content was last
+ reformatted. Used while fetching
+ a page's objects. */
unsigned int size; /**< Estimated size of all data
associated with this content, except
Modified: trunk/netsurf/desktop/options.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/options.c?rev=387...
==============================================================================
--- trunk/netsurf/desktop/options.c (original)
+++ trunk/netsurf/desktop/options.c Fri Feb 29 23:03:26 2008
@@ -128,6 +128,14 @@
#endif
/** default window scale */
int option_scale = 100;
+/* Whether to reflow web pages while objects are fetching */
+bool option_incremental_reflow = true;
+/* Minimum time between HTML reflows while objects are fetching */
+#ifdef riscos
+int option_min_reflow_period = 100; /* time in cs */
+#else
+int option_min_reflow_period = 25; /* time in cs */
+#endif
/* Fetcher configuration */
/** Maximum simultaneous active fetchers */
@@ -192,6 +200,8 @@
{ "window_screen_height",OPTION_INTEGER, &option_window_screen_height },
{ "toolbar_status_size", OPTION_INTEGER, &option_toolbar_status_width },
{ "scale", OPTION_INTEGER, &option_scale },
+ { "incremental_reflow", OPTION_BOOL, &option_incremental_reflow },
+ { "min_reflow_period", OPTION_INTEGER, &option_min_reflow_period },
/* Fetcher options */
{ "max_fetchers", OPTION_INTEGER, &option_max_fetchers },
{ "max_fetchers_per_host",
@@ -568,7 +578,7 @@
return false;
}
- title = xmlNewTextChild(head, NULL, (const xmlChar *) "title",
+ title = xmlNewTextChild(head, NULL, (const xmlChar *) "title",
(const xmlChar *) page_title);
if (!title) {
warn_user("NoMemory", 0);
@@ -625,8 +635,8 @@
} else {
/* directory */
/* invalid HTML */
- h4 = xmlNewTextChild(ul, NULL,
- (const xmlChar *) "h4",
+ h4 = xmlNewTextChild(ul, NULL,
+ (const xmlChar *) "h4",
(const xmlChar *) child->data.text);
if (!h4)
return false;
@@ -657,7 +667,7 @@
if (!li)
return false;
- a = xmlNewTextChild(li, NULL, (const xmlChar *) "a",
+ a = xmlNewTextChild(li, NULL, (const xmlChar *) "a",
(const xmlChar *) entry->data.text);
if (!a)
return false;
@@ -665,7 +675,7 @@
element = tree_find_element(entry, TREE_ELEMENT_URL);
if (!element)
return false;
- href = xmlNewProp(a, (const xmlChar *) "href",
+ href = xmlNewProp(a, (const xmlChar *) "href",
(const xmlChar *) element->text);
if (!href)
return false;
Modified: trunk/netsurf/desktop/options.h
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/options.h?rev=387...
==============================================================================
--- trunk/netsurf/desktop/options.h (original)
+++ trunk/netsurf/desktop/options.h Fri Feb 29 23:03:26 2008
@@ -80,6 +80,8 @@
extern int option_window_screen_height;
extern int option_toolbar_status_width;
extern int option_scale;
+extern bool option_incremental_reflow;
+extern int option_min_reflow_period;
/* Fetcher configuration. */
extern int option_max_fetchers;
Modified: trunk/netsurf/render/html.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html.c?rev=3874&r1...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Fri Feb 29 23:03:26 2008
@@ -492,6 +492,7 @@
content_broadcast(c, CONTENT_MSG_STATUS, msg_data);
LOG(("Layout document"));
html_reformat(c, width, height);
+ c->reformat_time = wallclock();
/*box_dump(c->data.html.layout->children, 0);*/
if (c->active == 0)
@@ -526,7 +527,7 @@
continue;
LOG(("Node: %s", node->name));
- if (!c->title && strcmp((const char *) node->name,
+ if (!c->title && strcmp((const char *) node->name,
"title") == 0) {
xmlChar *title = xmlNodeGetContent(node);
if (!title)
@@ -557,16 +558,16 @@
/* don't use the central values to ease freeing later on */
if ((s = xmlGetProp(node, (const xmlChar *) "target"))) {
if ((!strcasecmp((const char *) s, "_blank")) ||
- (!strcasecmp((const char *) s,
+ (!strcasecmp((const char *) s,
"_top")) ||
- (!strcasecmp((const char *) s,
+ (!strcasecmp((const char *) s,
"_parent")) ||
- (!strcasecmp((const char *) s,
+ (!strcasecmp((const char *) s,
"_self")) ||
('a' <= s[0] && s[0] <= 'z') ||
('A' <= s[0] && s[0] <= 'Z')) { /* [6.16] */
- c->data.html.base_target =
- talloc_strdup(c,
+ c->data.html.base_target =
+ talloc_strdup(c,
(const char *) s);
if (!c->data.html.base_target) {
xmlFree(s);
@@ -1405,6 +1406,21 @@
content_reformat(c, c->available_width, c->height);
html_set_status(c, "");
content_set_done(c);
+ }
+ /* If 1) the configuration option to reflow pages while objects are
+ * fetched is set
+ * 2) an object is newly fetched & converted,
+ * 3) the object's parent HTML is ready for reformat,
+ * 4) the time since the previous reformat is more than the
+ * configured minimum time between reformats
+ * then reformat the page to display newly fetched objects */
+ else if (option_incremental_reflow && msg == CONTENT_MSG_DONE &&
+ (c->status == CONTENT_STATUS_READY ||
+ c->status == CONTENT_STATUS_DONE) &&
+ (option_min_reflow_period <
+ (wallclock() - c->reformat_time))) {
+ content_reformat(c, c->available_width, c->height);
+ c->reformat_time = wallclock();
}
if (c->status == CONTENT_STATUS_READY)
html_set_status(c, "");
Modified: trunk/netsurf/riscos/options.h
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/options.h?rev=3874...
==============================================================================
--- trunk/netsurf/riscos/options.h (original)
+++ trunk/netsurf/riscos/options.h Fri Feb 29 23:03:26 2008
@@ -83,7 +83,7 @@
bool option_window_size_clone = true; \
bool option_background_images = true; \
bool option_buffer_animations = true; \
-bool option_buffer_everything = false; \
+bool option_buffer_everything = true; \
bool option_open_browser_at_startup = false; \
bool option_no_plugins = false; \
bool option_block_popups = false; \
15 years, 7 months
r3873 tlsa - /trunk/netsurf/render/box_construct.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Feb 28 20:36:09 2008
New Revision: 3873
URL: http://source.netsurf-browser.org?rev=3873&view=rev
Log:
Fix align attributes on TABLE etc being overridden in the table's cells by the default alignment of cells with no align attribute.
Modified:
trunk/netsurf/render/box_construct.c
Modified: trunk/netsurf/render/box_construct.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box_construct.c?re...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Thu Feb 28 20:36:09 2008
@@ -101,6 +101,8 @@
bool cell_padding;
long padding_width;
+
+ bool table;
};
static bool convert_xml_to_box(xmlNode *n, struct content *content,
@@ -822,7 +824,8 @@
url_func_result res;
colour border_color = 0x888888; /* mid-grey default for tables */
- /* if not in a table, switch off cellpadding and cell borders */
+ /* if not in a table, switch off cellpadding and cell borders
+ * and record that we're not in a table */
if (strcmp((const char *) n->name, "thead") != 0 &&
strcmp((const char *) n->name, "tbody") != 0 &&
strcmp((const char *) n->name, "tfoot") != 0 &&
@@ -833,6 +836,7 @@
strcmp((const char *) n->name, "colgroup") != 0) {
markup_track->cell_border = false;
markup_track->cell_padding = false;
+ markup_track->table = false;
}
style = talloc_memdup(c, parent_style, sizeof *style);
@@ -1211,6 +1215,7 @@
else if (strcmp((const char *) n->name, "div") == 0 ||
strcmp((const char *) n->name, "col") == 0 ||
strcmp((const char *) n->name, "colgroup") == 0 ||
+ strcmp((const char *) n->name, "table") == 0 ||
strcmp((const char *) n->name, "tbody") == 0 ||
strcmp((const char *) n->name, "td") == 0 ||
strcmp((const char *) n->name, "tfoot") == 0 ||
@@ -1227,16 +1232,22 @@
markup_track->align = ALIGN_LEFT;
xmlFree(s);
}
+ /* Need to remember if we're in a table, so that any alignment
+ * rules set on the table's elements won't get overridden by the
+ * default alignment of a cell with no align attribute.
+ * At this point, we're in a table if the element isn't a div */
+ if (strcmp((const char *) n->name, "div") != 0)
+ markup_track->table = true;
}
/* Table cells without an align value have a default implied
- * alignment */
- if (strcmp((const char *) n->name, "td") == 0) {
+ * alignment. */
+ if (strcmp((const char *) n->name, "td") == 0 && !markup_track->table) {
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
markup_track->align = ALIGN_LEFT;
else
xmlFree(s);
}
- if (strcmp((const char *) n->name, "th") == 0) {
+ if (strcmp((const char *) n->name, "th") == 0 && !markup_track->table) {
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
markup_track->align = ALIGN_CENTER;
else
15 years, 7 months
r3872 jmb - /trunk/netsurf/content/fetchcache.c
by netsurf@semichrome.net
Author: jmb
Date: Wed Feb 27 19:13:35 2008
New Revision: 3872
URL: http://source.netsurf-browser.org?rev=3872&view=rev
Log:
Mark old contents as stale if a conditional request succeeded so they'll be flushed from the cache as soon as they're unused.
Modified:
trunk/netsurf/content/fetchcache.c
Modified: trunk/netsurf/content/fetchcache.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchcache.c?rev=...
==============================================================================
--- trunk/netsurf/content/fetchcache.c (original)
+++ trunk/netsurf/content/fetchcache.c Wed Feb 27 19:13:35 2008
@@ -411,6 +411,25 @@
if (!res) {
fetch_abort(c->fetch);
c->fetch = 0;
+ }
+
+ if (c->cache_data->date || c->cache_data->etag) {
+ /* We've just made a conditional request
+ * that returned with something other
+ * than 304. Therefore, there's a stale
+ * content floating around in the cache.
+ * Hunt it down and mark it as stale, so
+ * it'll get cleaned when unused. We
+ * assume it's either READY or DONE --
+ * anything else is of marginal staleness
+ * (or in error, which will cause it to
+ * be flushed from the cache, anyway)
+ */
+ struct content *stale_content =
+ content_get_ready(c->url);
+
+ if (stale_content)
+ stale_content->fresh = false;
}
break;
15 years, 7 months
r3871 jmb - /trunk/netsurf/content/fetchcache.c
by netsurf@semichrome.net
Author: jmb
Date: Wed Feb 27 18:48:35 2008
New Revision: 3871
URL: http://source.netsurf-browser.org?rev=3871&view=rev
Log:
Explicitly mark error pages as non-fresh so they'll get purged from the cache ASAP.
Modified:
trunk/netsurf/content/fetchcache.c
Modified: trunk/netsurf/content/fetchcache.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchcache.c?rev=...
==============================================================================
--- trunk/netsurf/content/fetchcache.c (original)
+++ trunk/netsurf/content/fetchcache.c Wed Feb 27 18:48:35 2008
@@ -605,6 +605,10 @@
if (!content_process_data(c, error_page, length))
return;
content_convert(c, c->width, c->height);
+
+ /* Mark content as non-fresh, so it'll get cleaned from the
+ * cache at the earliest opportunity */
+ c->fresh = false;
}
15 years, 7 months
r3870 jmb - in /trunk/netsurf: content/content.c desktop/browser.c render/html.c
by netsurf@semichrome.net
Author: jmb
Date: Wed Feb 27 18:38:41 2008
New Revision: 3870
URL: http://source.netsurf-browser.org?rev=3870&view=rev
Log:
Make content_reset actually do what it's meant to (i.e. reset the appropriate members)
Fix up CONTENT_MSG_REFRESH scheduled events to gracefully the refresh URL disappearing from under them.
Modified:
trunk/netsurf/content/content.c
trunk/netsurf/desktop/browser.c
trunk/netsurf/render/html.c
Modified: trunk/netsurf/content/content.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/content.c?rev=387...
==============================================================================
--- trunk/netsurf/content/content.c (original)
+++ trunk/netsurf/content/content.c Wed Feb 27 18:38:41 2008
@@ -931,6 +931,13 @@
c->size = 0;
talloc_free(c->mime_type);
c->mime_type = 0;
+ talloc_free(c->refresh);
+ c->refresh = 0;
+ talloc_free(c->title);
+ c->title = 0;
+ talloc_free(c->source_data);
+ c->source_data = 0;
+ c->source_size = c->source_allocated = 0;
}
Modified: trunk/netsurf/desktop/browser.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.c?rev=387...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Wed Feb 27 18:38:41 2008
@@ -648,8 +648,14 @@
struct browser_window *bw = p;
bool history_add = true;
- assert(bw->current_content->status == CONTENT_STATUS_READY ||
- bw->current_content->status == CONTENT_STATUS_DONE);
+ assert(bw->current_content &&
+ (bw->current_content->status == CONTENT_STATUS_READY ||
+ bw->current_content->status == CONTENT_STATUS_DONE));
+
+ /* Ignore if the refresh URL has gone
+ * (may happen if a fetch error occurred) */
+ if (!bw->current_content->refresh)
+ return;
/* mark this content as invalid so it gets flushed from the cache */
bw->current_content->fresh = false;
Modified: trunk/netsurf/render/html.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html.c?rev=3870&r1...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Wed Feb 27 18:38:41 2008
@@ -1563,7 +1563,12 @@
{
struct content *c = (struct content *)p;
- assert(c->type == CONTENT_HTML && c->refresh);
+ assert(c->type == CONTENT_HTML);
+
+ /* Ignore if refresh URL has gone
+ * (may happen if fetch errored) */
+ if (!c->refresh)
+ return;
c->fresh = false;
15 years, 7 months
r3869 tlsa - /trunk/netsurf/render/box_construct.c
by netsurf@semichrome.net
Author: tlsa
Date: Tue Feb 26 22:31:38 2008
New Revision: 3869
URL: http://source.netsurf-browser.org?rev=3869&view=rev
Log:
Don't meddle with blockquote's margins.
Modified:
trunk/netsurf/render/box_construct.c
Modified: trunk/netsurf/render/box_construct.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box_construct.c?re...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Tue Feb 26 22:31:38 2008
@@ -1164,7 +1164,8 @@
*/
if (markup_track->align != ALIGN_NONE &&
(style->display == CSS_DISPLAY_BLOCK ||
- style->display == CSS_DISPLAY_TABLE)) {
+ style->display == CSS_DISPLAY_TABLE) &&
+ (strcmp((const char *) n->name, "blockquote") != 0)) {
if (!author->margin[LEFT]) {
if (markup_track->align == ALIGN_LEFT) {
/* left */
@@ -1348,7 +1349,7 @@
if ((unsigned char) s[0] < 0x80)
s[0] = toupper(s[0]);
for (i = 1; i < len; ++i)
- if ((unsigned char) s[i] < 0x80 &&
+ if ((unsigned char) s[i] < 0x80 &&
isspace(s[i - 1]))
s[i] = toupper(s[i]);
break;
15 years, 7 months
r3868 jmb - in /trunk/netsurf: desktop/browser.c desktop/options.c desktop/textinput.c image/bmp.c image/bmpread.c image/gif.c image/gifread.c image/ico.c image/jpeg.c render/box_construct.c render/html.c render/imagemap.c render/textplain.c utils/utf8.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Feb 25 17:58:00 2008
New Revision: 3868
URL: http://source.netsurf-browser.org?rev=3868&view=rev
Log:
SignednessWarnings.squash()
Aside from a number of instances of const being cast away (mostly relating to the urldb, which is correct to only export const data) this now builds warning-free with GCC 4 on x86, which is nice.
Modified:
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/options.c
trunk/netsurf/desktop/textinput.c
trunk/netsurf/image/bmp.c
trunk/netsurf/image/bmpread.c
trunk/netsurf/image/gif.c
trunk/netsurf/image/gifread.c
trunk/netsurf/image/ico.c
trunk/netsurf/image/jpeg.c
trunk/netsurf/render/box_construct.c
trunk/netsurf/render/html.c
trunk/netsurf/render/imagemap.c
trunk/netsurf/render/textplain.c
trunk/netsurf/utils/utf8.c
Modified: trunk/netsurf/desktop/browser.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.c?rev=386...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Mon Feb 25 17:58:00 2008
@@ -1422,7 +1422,7 @@
if (text_box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(text_box->style,
text_box->text,
@@ -1431,7 +1431,8 @@
&idx,
&pixel_offset);
- selection_click(bw->sel, mouse, text_box->byte_offset + idx);
+ selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx);
if (selection_dragging(bw->sel)) {
bw->drag_type = DRAGGING_SELECTION;
@@ -1456,9 +1457,10 @@
}
else if (text_box) {
int pixel_offset;
- int idx;
-
- if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2))
+ size_t idx;
+
+ if (mouse & (BROWSER_MOUSE_DRAG_1 |
+ BROWSER_MOUSE_DRAG_2))
selection_init(bw->sel, gadget_box);
nsfont_position_in_string(text_box->style,
@@ -1468,7 +1470,8 @@
&idx,
&pixel_offset);
- selection_click(bw->sel, mouse, text_box->byte_offset + idx);
+ selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx);
if (selection_dragging(bw->sel))
bw->drag_type = DRAGGING_SELECTION;
@@ -1546,7 +1549,7 @@
if (text_box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(text_box->style,
text_box->text,
@@ -1555,14 +1558,18 @@
&idx,
&pixel_offset);
- if (selection_click(bw->sel, mouse, text_box->byte_offset + idx)) {
- /* key presses must be directed at the main browser
- * window, paste text operations ignored */
+ if (selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx)) {
+ /* key presses must be directed at the
+ * main browser window, paste text
+ * operations ignored */
browser_window_remove_caret(bw);
if (selection_dragging(bw->sel)) {
- bw->drag_type = DRAGGING_SELECTION;
- status = messages_get("Selecting");
+ bw->drag_type =
+ DRAGGING_SELECTION;
+ status =
+ messages_get("Selecting");
} else
status = c->status_message;
@@ -1805,7 +1812,7 @@
&dx, &dy, dir);
if (box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(box->style,
box->text,
@@ -1814,7 +1821,8 @@
&idx,
&pixel_offset);
- selection_track(bw->sel, mouse, box->byte_offset + idx);
+ selection_track(bw->sel, mouse,
+ box->byte_offset + idx);
}
}
break;
@@ -1877,7 +1885,7 @@
if (c) {
bool found = true;
int dir = -1;
- int idx;
+ size_t idx;
if (selection_dragging_start(bw->sel)) dir = 1;
@@ -1889,7 +1897,8 @@
box = browser_window_pick_text_box(bw, mouse, x, y,
&dx, &dy, dir);
if (box) {
- nsfont_position_in_string(box->style,
+ nsfont_position_in_string(
+ box->style,
box->text,
box->length,
dx,
@@ -1897,7 +1906,8 @@
&pixel_offset);
idx += box->byte_offset;
- selection_track(bw->sel, mouse, idx);
+ selection_track(bw->sel, mouse,
+ idx);
}
else
found = false;
Modified: trunk/netsurf/desktop/options.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/options.c?rev=386...
==============================================================================
--- trunk/netsurf/desktop/options.c (original)
+++ trunk/netsurf/desktop/options.c Mon Feb 25 17:58:00 2008
@@ -428,11 +428,11 @@
if (n->type != XML_ELEMENT_NODE)
continue;
- if (strcmp(n->name, "li") == 0) {
+ if (strcmp((const char *) n->name, "li") == 0) {
/* entry */
options_load_tree_entry(n, directory);
- } else if (strcmp(n->name, "h4") == 0) {
+ } else if (strcmp((const char *) n->name, "h4") == 0) {
/* directory */
title = (char *) xmlNodeGetContent(n);
if (!title) {
@@ -445,7 +445,7 @@
n && n->type != XML_ELEMENT_NODE;
n = n->next)
;
- if (!n || strcmp(n->name, "ul") != 0) {
+ if (!n || strcmp((const char *) n->name, "ul") != 0) {
/* next element isn't expected ul */
free(title);
warn_user("HotlistLoadError", "(Expected "
@@ -478,7 +478,7 @@
for (n = li->children; n; n = n->next) {
/* The li must contain an "a" element */
if (n->type == XML_ELEMENT_NODE &&
- strcmp(n->name, "a") == 0) {
+ strcmp((const char *) n->name, "a") == 0) {
url = (char *) xmlGetProp(n, (const xmlChar *) "href");
title = (char *) xmlNodeGetContent(n);
}
@@ -526,7 +526,7 @@
return 0;
for (n = node->children;
n && !(n->type == XML_ELEMENT_NODE &&
- strcmp(n->name, name) == 0);
+ strcmp((const char *) n->name, name) == 0);
n = n->next)
;
return n;
@@ -545,14 +545,15 @@
/* Unfortunately the Browse Hotlist format is invalid HTML,
* so this is a lie. */
- doc = htmlNewDoc("http://www.w3.org/TR/html4/strict.dtd",
- "-//W3C//DTD HTML 4.01//EN");
+ doc = htmlNewDoc(
+ (const xmlChar *) "http://www.w3.org/TR/html4/strict.dtd",
+ (const xmlChar *) "-//W3C//DTD HTML 4.01//EN");
if (!doc) {
warn_user("NoMemory", 0);
return false;
}
- html = xmlNewNode(NULL, "html");
+ html = xmlNewNode(NULL, (const xmlChar *) "html");
if (!html) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
@@ -560,21 +561,22 @@
}
xmlDocSetRootElement(doc, html);
- head = xmlNewChild(html, NULL, "head", NULL);
+ head = xmlNewChild(html, NULL, (const xmlChar *) "head", NULL);
if (!head) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
return false;
}
- title = xmlNewTextChild(head, NULL, "title", page_title);
+ title = xmlNewTextChild(head, NULL, (const xmlChar *) "title",
+ (const xmlChar *) page_title);
if (!title) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
return false;
}
- body = xmlNewChild(html, NULL, "body", NULL);
+ body = xmlNewChild(html, NULL, (const xmlChar *) "body", NULL);
if (!body) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
@@ -611,7 +613,7 @@
struct node *child;
xmlNode *ul, *h4;
- ul = xmlNewChild(node, NULL, "ul", NULL);
+ ul = xmlNewChild(node, NULL, (const xmlChar *) "ul", NULL);
if (!ul)
return false;
@@ -623,7 +625,9 @@
} else {
/* directory */
/* invalid HTML */
- h4 = xmlNewTextChild(ul, NULL, "h4", child->data.text);
+ h4 = xmlNewTextChild(ul, NULL,
+ (const xmlChar *) "h4",
+ (const xmlChar *) child->data.text);
if (!h4)
return false;
@@ -649,18 +653,20 @@
xmlAttr *href;
struct node_element *element;
- li = xmlNewChild(node, NULL, "li", NULL);
+ li = xmlNewChild(node, NULL, (const xmlChar *) "li", NULL);
if (!li)
return false;
- a = xmlNewTextChild(li, NULL, "a", entry->data.text);
+ a = xmlNewTextChild(li, NULL, (const xmlChar *) "a",
+ (const xmlChar *) entry->data.text);
if (!a)
return false;
element = tree_find_element(entry, TREE_ELEMENT_URL);
if (!element)
return false;
- href = xmlNewProp(a, "href", element->text);
+ href = xmlNewProp(a, (const xmlChar *) "href",
+ (const xmlChar *) element->text);
if (!href)
return false;
return true;
Modified: trunk/netsurf/desktop/textinput.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/textinput.c?rev=3...
==============================================================================
--- trunk/netsurf/desktop/textinput.c (original)
+++ trunk/netsurf/desktop/textinput.c Mon Feb 25 17:58:00 2008
@@ -84,8 +84,9 @@
struct box *end_box, unsigned end_idx);
static void textarea_reflow(struct browser_window *bw, struct box *textarea,
struct box *inline_container);
-static bool word_left(const char *text, int *poffset, int *pchars);
-static bool word_right(const char *text, int len, int *poffset, int *pchars);
+static bool word_left(const char *text, size_t *poffset, size_t *pchars);
+static bool word_right(const char *text, size_t len, size_t *poffset,
+ size_t *pchars);
static bool ensure_caret_visible(struct box *textarea);
/**
@@ -179,7 +180,7 @@
nsfont_position_in_string(text_box->style, text_box->text,
text_box->length,
(unsigned int)(x - text_box->x),
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset, ppixel_offset);
} else {
/* find the relevant text box */
y -= inline_container->y;
@@ -202,7 +203,8 @@
text_box->text,
text_box->length,
textarea->width,
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset,
+ ppixel_offset);
} else {
/* in a text box */
if (text_box->type == BOX_BR)
@@ -221,7 +223,8 @@
text_box->text,
text_box->length,
(unsigned int)(x - text_box->x),
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset,
+ ppixel_offset);
}
}
@@ -1023,7 +1026,7 @@
break;
case KEY_WORD_LEFT: {
- int nchars;
+ size_t nchars;
/* Text box */
if (word_left(input->gadget->value, &form_offset, &nchars)) {
/* Gadget */
@@ -1037,7 +1040,7 @@
break;
case KEY_WORD_RIGHT: {
- int nchars;
+ size_t nchars;
/* Text box */
if (word_right(input->gadget->value, input->gadget->length,
&form_offset, &nchars)) {
@@ -1513,7 +1516,7 @@
box_coords(input, &box_x, &box_y);
nsfont_width(text_box->style, text_box->text, box_offset,
- &pixel_offset);
+ (int *) &pixel_offset);
dx = text_box->x;
text_box->x = 0;
if (input->width < text_box->width &&
@@ -1901,11 +1904,11 @@
* \return true iff the start of a word was found before/at the string start
*/
-bool word_left(const char *text, int *poffset, int *pchars)
-{
- int offset = *poffset;
+bool word_left(const char *text, size_t *poffset, size_t *pchars)
+{
+ size_t offset = *poffset;
bool success = false;
- int nchars = 0;
+ size_t nchars = 0;
while (offset > 0) {
offset = utf8_prev(text, offset);
@@ -1914,7 +1917,7 @@
}
while (offset > 0) {
- int prev = utf8_prev(text, offset);
+ size_t prev = utf8_prev(text, offset);
success = true;
if (isspace(text[prev]))
break;
@@ -1939,11 +1942,11 @@
* \return true iff the start of a word was found before the string end
*/
-bool word_right(const char *text, int len, int *poffset, int *pchars)
-{
- int offset = *poffset;
+bool word_right(const char *text, size_t len, size_t *poffset, size_t *pchars)
+{
+ size_t offset = *poffset;
bool success = false;
- int nchars = 0;
+ size_t nchars = 0;
while (offset < len) {
if (isspace(text[offset])) break;
Modified: trunk/netsurf/image/bmp.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/bmp.c?rev=3868&r1=3...
==============================================================================
--- trunk/netsurf/image/bmp.c (original)
+++ trunk/netsurf/image/bmp.c Mon Feb 25 17:58:00 2008
@@ -52,7 +52,7 @@
/* set our source data */
bmp = c->data.bmp.bmp;
- bmp->bmp_data = c->source_data;
+ bmp->bmp_data = (unsigned char *) c->source_data;
bmp->buffer_size = c->source_size;
/* analyse the BMP */
Modified: trunk/netsurf/image/bmpread.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/bmpread.c?rev=3868&...
==============================================================================
--- trunk/netsurf/image/bmpread.c (original)
+++ trunk/netsurf/image/bmpread.c Mon Feb 25 17:58:00 2008
@@ -50,7 +50,7 @@
* \return BMP_OK on success
*/
bmp_result bmp_analyse(struct bmp_image *bmp) {
- char *data = bmp->bmp_data;
+ char *data = (char *) bmp->bmp_data;
/* ensure we aren't already initialised */
if (bmp->bitmap)
@@ -87,7 +87,7 @@
* \return BMP_OK on success
*/
bmp_result ico_analyse(struct ico_collection *ico) {
- char *data = ico->ico_data;
+ char *data = (char *) ico->ico_data;
unsigned int count, i;
bmp_result result;
struct ico_image *image;
@@ -126,7 +126,8 @@
image->bmp.bmp_data = ico->ico_data + READ_INT(data, 12);
image->bmp.ico = true;
data += 16;
- result = bmp_analyse_header(&image->bmp, image->bmp.bmp_data);
+ result = bmp_analyse_header(&image->bmp,
+ (char *) image->bmp.bmp_data);
if (result != BMP_OK)
return result;
area = image->bmp.width * image->bmp.height;
@@ -370,7 +371,7 @@
assert(bmp->bitmap);
- data = bmp->bmp_data + bmp->bitmap_offset;
+ data = (char *) bmp->bmp_data + bmp->bitmap_offset;
bytes = bmp->buffer_size - bmp->bitmap_offset;
switch (bmp->encoding) {
Modified: trunk/netsurf/image/gif.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/gif.c?rev=3868&r1=3...
==============================================================================
--- trunk/netsurf/image/gif.c (original)
+++ trunk/netsurf/image/gif.c Mon Feb 25 17:58:00 2008
@@ -73,7 +73,7 @@
/* Create our animation
*/
gif = c->data.gif.gif;
- gif->gif_data = c->source_data;
+ gif->gif_data = (unsigned char *) c->source_data;
gif->buffer_size = c->source_size;
gif->buffer_position = 0;
Modified: trunk/netsurf/image/gifread.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/gifread.c?rev=3868&...
==============================================================================
--- trunk/netsurf/image/gifread.c (original)
+++ trunk/netsurf/image/gifread.c Mon Feb 25 17:58:00 2008
@@ -149,7 +149,7 @@
/* Check we are a GIF
*/
- if (strncmp(gif_data, "GIF", 3) != 0)
+ if (strncmp((const char *) gif_data, "GIF", 3) != 0)
return GIF_DATA_ERROR;
gif_data += 3;
@@ -410,7 +410,8 @@
*/
} else if ((gif_data[1] == 0xff) &&
(gif_data[2] == 0x0b) &&
- (strncmp(gif_data + 3, "NETSCAPE2.0", 11) == 0) &&
+ (strncmp((const char *) gif_data + 3,
+ "NETSCAPE2.0", 11) == 0) &&
(gif_data[14] == 0x03) &&
(gif_data[15] == 0x01)) {
gif->loop_count = gif_data[16] | (gif_data[17] << 8);
Modified: trunk/netsurf/image/ico.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/ico.c?rev=3868&r1=3...
==============================================================================
--- trunk/netsurf/image/ico.c (original)
+++ trunk/netsurf/image/ico.c Mon Feb 25 17:58:00 2008
@@ -53,7 +53,7 @@
/* set our source data */
ico = c->data.ico.ico;
- ico->ico_data = c->source_data;
+ ico->ico_data = (unsigned char *) c->source_data;
ico->buffer_size = c->source_size;
/* analyse the BMP */
Modified: trunk/netsurf/image/jpeg.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/jpeg.c?rev=3868&r1=...
==============================================================================
--- trunk/netsurf/image/jpeg.c (original)
+++ trunk/netsurf/image/jpeg.c Mon Feb 25 17:58:00 2008
@@ -95,7 +95,7 @@
return false;
}
jpeg_create_decompress(&cinfo);
- source_mgr.next_input_byte = c->source_data;
+ source_mgr.next_input_byte = (unsigned char *) c->source_data;
source_mgr.bytes_in_buffer = c->source_size;
cinfo.src = &source_mgr;
jpeg_read_header(&cinfo, TRUE);
@@ -180,7 +180,7 @@
}
-static char nsjpeg_eoi[] = { 0xff, JPEG_EOI };
+static unsigned char nsjpeg_eoi[] = { 0xff, JPEG_EOI };
/**
* JPEG data source manager: fill the input buffer.
Modified: trunk/netsurf/render/box_construct.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box_construct.c?re...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Mon Feb 25 17:58:00 2008
@@ -355,7 +355,7 @@
/* extract title attribute, if present */
if ((title0 = xmlGetProp(n, (const xmlChar *) "title"))) {
- char *title1 = squash_whitespace(title0);
+ char *title1 = squash_whitespace((char *) title0);
xmlFree(title0);
if (!title1)
return false;
@@ -638,7 +638,7 @@
if (parent_style->white_space == CSS_WHITE_SPACE_NORMAL ||
parent_style->white_space == CSS_WHITE_SPACE_NOWRAP) {
- char *text = squash_whitespace(n->content);
+ char *text = squash_whitespace((char *) n->content);
if (!text)
return false;
@@ -719,7 +719,7 @@
} else {
/* white-space: pre */
- char *text = cnv_space2nbsp(n->content);
+ char *text = cnv_space2nbsp((char *) n->content);
char *current;
/* note: pre-wrap/pre-line are unimplemented */
assert(parent_style->white_space == CSS_WHITE_SPACE_PRE ||
@@ -823,14 +823,14 @@
colour border_color = 0x888888; /* mid-grey default for tables */
/* if not in a table, switch off cellpadding and cell borders */
- if (strcmp(n->name, "thead") != 0 &&
- strcmp(n->name, "tbody") != 0 &&
- strcmp(n->name, "tfoot") != 0 &&
- strcmp(n->name, "tr") != 0 &&
- strcmp(n->name, "td") != 0 &&
- strcmp(n->name, "th") != 0 &&
- strcmp(n->name, "col") != 0 &&
- strcmp(n->name, "colgroup") != 0) {
+ if (strcmp((const char *) n->name, "thead") != 0 &&
+ strcmp((const char *) n->name, "tbody") != 0 &&
+ strcmp((const char *) n->name, "tfoot") != 0 &&
+ strcmp((const char *) n->name, "tr") != 0 &&
+ strcmp((const char *) n->name, "td") != 0 &&
+ strcmp((const char *) n->name, "th") != 0 &&
+ strcmp((const char *) n->name, "col") != 0 &&
+ strcmp((const char *) n->name, "colgroup") != 0) {
markup_track->cell_border = false;
markup_track->cell_padding = false;
}
@@ -1205,17 +1205,17 @@
* text-align for the current block can be handled in the default
* CSS file.
*/
- if (strcmp(n->name, "center") == 0)
+ if (strcmp((const char *) n->name, "center") == 0)
markup_track->align = ALIGN_CENTER;
- else if (strcmp(n->name, "div") == 0 ||
- strcmp(n->name, "col") == 0 ||
- strcmp(n->name, "colgroup") == 0 ||
- strcmp(n->name, "tbody") == 0 ||
- strcmp(n->name, "td") == 0 ||
- strcmp(n->name, "tfoot") == 0 ||
- strcmp(n->name, "th") == 0 ||
- strcmp(n->name, "thead") == 0 ||
- strcmp(n->name, "tr") == 0) {
+ else if (strcmp((const char *) n->name, "div") == 0 ||
+ strcmp((const char *) n->name, "col") == 0 ||
+ strcmp((const char *) n->name, "colgroup") == 0 ||
+ strcmp((const char *) n->name, "tbody") == 0 ||
+ strcmp((const char *) n->name, "td") == 0 ||
+ strcmp((const char *) n->name, "tfoot") == 0 ||
+ strcmp((const char *) n->name, "th") == 0 ||
+ strcmp((const char *) n->name, "thead") == 0 ||
+ strcmp((const char *) n->name, "tr") == 0) {
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "align"))) {
if (strcasecmp(s, "center") == 0)
@@ -1229,13 +1229,13 @@
}
/* Table cells without an align value have a default implied
* alignment */
- if (strcmp(n->name, "td") == 0) {
+ if (strcmp((const char *) n->name, "td") == 0) {
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
markup_track->align = ALIGN_LEFT;
else
xmlFree(s);
}
- if (strcmp(n->name, "th") == 0) {
+ if (strcmp((const char *) n->name, "th") == 0) {
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
markup_track->align = ALIGN_CENTER;
else
@@ -1336,19 +1336,20 @@
switch (tt) {
case CSS_TEXT_TRANSFORM_UPPERCASE:
for (i = 0; i < len; ++i)
- if (s[i] < 0x80)
+ if ((unsigned char) s[i] < 0x80)
s[i] = toupper(s[i]);
break;
case CSS_TEXT_TRANSFORM_LOWERCASE:
for (i = 0; i < len; ++i)
- if (s[i] < 0x80)
+ if ((unsigned char) s[i] < 0x80)
s[i] = tolower(s[i]);
break;
case CSS_TEXT_TRANSFORM_CAPITALIZE:
- if (s[0] < 0x80)
+ if ((unsigned char) s[0] < 0x80)
s[0] = toupper(s[0]);
for (i = 1; i < len; ++i)
- if (s[i] < 0x80 && isspace(s[i - 1]))
+ if ((unsigned char) s[i] < 0x80 &&
+ isspace(s[i - 1]))
s[i] = toupper(s[i]);
break;
default:
@@ -1437,19 +1438,19 @@
/* target frame [16.3] */
if ((s = xmlGetProp(n, (const xmlChar *) "target"))) {
- if (!strcasecmp(s, "_blank"))
+ if (!strcasecmp((const char *) s, "_blank"))
box->target = TARGET_BLANK;
- else if (!strcasecmp(s, "_top"))
+ else if (!strcasecmp((const char *) s, "_top"))
box->target = TARGET_TOP;
- else if (!strcasecmp(s, "_parent"))
+ else if (!strcasecmp((const char *) s, "_parent"))
box->target = TARGET_PARENT;
- else if (!strcasecmp(s, "_self"))
+ else if (!strcasecmp((const char *) s, "_self"))
/* the default may have been overridden by a
* <base target=...>, so this is different to 0 */
box->target = TARGET_SELF;
else if (('a' <= s[0] && s[0] <= 'z') ||
('A' <= s[0] && s[0] <= 'Z')) { /* [6.16] */
- box->target = talloc_strdup(content, s);
+ box->target = talloc_strdup(content, (const char *) s);
if (!box->target) {
xmlFree(s);
return false;
@@ -1477,7 +1478,7 @@
/* handle alt text */
if ((alt = xmlGetProp(n, (const xmlChar *) "alt"))) {
- s = squash_whitespace(alt);
+ s = squash_whitespace((const char *) alt);
xmlFree(alt);
if (!s)
return false;
@@ -2589,12 +2590,12 @@
char *text_nowrap = 0;
bool selected;
xmlChar *content;
- xmlChar *s;
+ char *s;
content = xmlNodeGetContent(n);
if (!content)
goto no_memory;
- text = squash_whitespace(content);
+ text = squash_whitespace((const char *) content);
xmlFree(content);
if (!text)
goto no_memory;
@@ -2703,8 +2704,8 @@
while (1) {
/* BOX_TEXT */
- len = strcspn(current, "\r\n");
- s = talloc_strndup(content, current, len);
+ len = strcspn((const char *) current, "\r\n");
+ s = talloc_strndup(content, (const char *) current, len);
if (!s) {
xmlFree(string);
xmlBufferFree(buf);
@@ -2849,7 +2850,7 @@
xmlChar *s = xmlGetProp(n, (const xmlChar *) attribute);
if (!s)
return true;
- *value = talloc_strdup(context, s);
+ *value = talloc_strdup(context, (const char *) s);
xmlFree(s);
if (!*value)
return false;
Modified: trunk/netsurf/render/html.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html.c?rev=3868&r1...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Mon Feb 25 17:58:00 2008
@@ -203,16 +203,19 @@
/* However, if that encoding is non-ASCII-compatible,
* ignore it, as it can't possibly be correct */
- if (strncasecmp(c->data.html.parser->input->encoding,
+ if (strncasecmp((const char *) c->data.html.parser->
+ input->encoding,
"UTF-16", 6) == 0 || /* UTF-16(LE|BE)? */
- strncasecmp(c->data.html.parser->input->encoding,
+ strncasecmp((const char *) c->data.html.parser->
+ input->encoding,
"UTF-32", 6) == 0) { /* UTF-32(LE|BE)? */
c->data.html.encoding = talloc_strdup(c, "ISO-8859-1");
c->data.html.encoding_source =
ENCODING_SOURCE_DETECTED;
} else {
c->data.html.encoding = talloc_strdup(c,
- c->data.html.parser->input->encoding);
+ (const char *) c->data.html.parser->
+ input->encoding);
c->data.html.encoding_source = ENCODING_SOURCE_META;
}
@@ -523,11 +526,12 @@
continue;
LOG(("Node: %s", node->name));
- if (!c->title && strcmp(node->name, "title") == 0) {
+ if (!c->title && strcmp((const char *) node->name,
+ "title") == 0) {
xmlChar *title = xmlNodeGetContent(node);
if (!title)
return false;
- char *title2 = squash_whitespace(title);
+ char *title2 = squash_whitespace((const char *) title);
xmlFree(title);
if (!title2)
return false;
@@ -536,7 +540,7 @@
if (!c->title)
return false;
- } else if (strcmp(node->name, "base") == 0) {
+ } else if (strcmp((const char *) node->name, "base") == 0) {
char *href = (char *) xmlGetProp(node,
(const xmlChar *) "href");
if (href) {
@@ -552,12 +556,18 @@
}
/* don't use the central values to ease freeing later on */
if ((s = xmlGetProp(node, (const xmlChar *) "target"))) {
- if ((!strcasecmp(s, "_blank")) || (!strcasecmp(s, "_top")) ||
- (!strcasecmp(s, "_parent")) ||
- (!strcasecmp(s, "_self")) ||
+ if ((!strcasecmp((const char *) s, "_blank")) ||
+ (!strcasecmp((const char *) s,
+ "_top")) ||
+ (!strcasecmp((const char *) s,
+ "_parent")) ||
+ (!strcasecmp((const char *) s,
+ "_self")) ||
('a' <= s[0] && s[0] <= 'z') ||
('A' <= s[0] && s[0] <= 'Z')) { /* [6.16] */
- c->data.html.base_target = talloc_strdup(c, s);
+ c->data.html.base_target =
+ talloc_strdup(c,
+ (const char *) s);
if (!c->data.html.base_target) {
xmlFree(s);
return false;
@@ -594,7 +604,7 @@
continue;
/* Recurse into noscript elements */
- if (strcmp((const char *)n->name, "noscript") == 0) {
+ if (strcmp((const char *) n->name, "noscript") == 0) {
if (!html_meta_refresh(c, n)) {
/* Some error occurred */
return false;
@@ -604,26 +614,26 @@
}
}
- if (strcmp((const char *)n->name, "meta")) {
- continue;
- }
-
- equiv = xmlGetProp(n, (const xmlChar *)"http-equiv");
+ if (strcmp((const char *) n->name, "meta")) {
+ continue;
+ }
+
+ equiv = xmlGetProp(n, (const xmlChar *) "http-equiv");
if (!equiv)
continue;
- if (strcasecmp((const char *)equiv, "refresh")) {
+ if (strcasecmp((const char *) equiv, "refresh")) {
xmlFree(equiv);
continue;
}
xmlFree(equiv);
- content = xmlGetProp(n, (const xmlChar *)"content");
+ content = xmlGetProp(n, (const xmlChar *) "content");
if (!content)
continue;
- end = (char *)content + strlen(content);
+ end = (char *) content + strlen((const char *) content);
msg_data.delay = (int)strtol((char *) content, &url, 10);
/* a very small delay and self-referencing URL can cause a loop
@@ -776,7 +786,7 @@
if (node->type != XML_ELEMENT_NODE)
continue;
- if (strcmp(node->name, "link") != 0)
+ if (strcmp((const char *) node->name, "link") != 0)
continue;
/* rel=<space separated list, including 'stylesheet'> */
@@ -949,7 +959,7 @@
if (node->type != XML_ELEMENT_NODE)
continue;
- if (strcmp(node->name, "style") != 0)
+ if (strcmp((const char *) node->name, "style") != 0)
continue;
if (!html_process_style_element(c, node))
@@ -1012,7 +1022,7 @@
* give the content of comments which may be used to 'hide'
* the content */
for (child = style->children; child != 0; child = child->next) {
- data = xmlNodeGetContent(child);
+ data = (char *) xmlNodeGetContent(child);
if (!content_process_data(c->data.html.
stylesheet_content[STYLESHEET_STYLE],
data, strlen(data))) {
Modified: trunk/netsurf/render/imagemap.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/imagemap.c?rev=386...
==============================================================================
--- trunk/netsurf/render/imagemap.c (original)
+++ trunk/netsurf/render/imagemap.c Mon Feb 25 17:58:00 2008
@@ -247,11 +247,11 @@
assert(c != NULL);
if (node->type == XML_ELEMENT_NODE) {
- if (strcmp(node->name, "map") == 0) {
- if ((name = (char *)xmlGetProp(node,
- (const xmlChar *)"id")) == NULL) {
- if ((name = (char *)xmlGetProp(node,
- (const xmlChar *)"name")) ==
+ if (strcmp((const char *) node->name, "map") == 0) {
+ if ((name = (char *) xmlGetProp(node,
+ (const xmlChar *) "id")) == NULL) {
+ if ((name = (char *) xmlGetProp(node,
+ (const xmlChar *) "name")) ==
NULL)
return true;
}
@@ -306,8 +306,8 @@
/** \todo ignore <area> elements if there are other
* block-level elements present in map
*/
- if (strcmp(node->name, "area") == 0 ||
- strcmp(node->name, "a") == 0) {
+ if (strcmp((const char *) node->name, "area") == 0 ||
+ strcmp((const char *) node->name, "a") == 0) {
return imagemap_addtolist(node,
c->data.html.base_url, entry);
}
@@ -341,7 +341,7 @@
assert(base_url != NULL);
assert(entry != NULL);
- if (strcmp(n->name, "area") == 0) {
+ if (strcmp((const char *) n->name, "area") == 0) {
/* nohref attribute present - ignore this entry */
if (xmlGetProp(n, (const xmlChar*)"nohref") != 0) {
return true;
Modified: trunk/netsurf/render/textplain.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/textplain.c?rev=38...
==============================================================================
--- trunk/netsurf/render/textplain.c (original)
+++ trunk/netsurf/render/textplain.c Mon Feb 25 17:58:00 2008
@@ -503,7 +503,7 @@
if (x <= width) {
int pixel_offset;
- int char_offset;
+ size_t char_offset;
nsfont_position_in_string(&textplain_style,
text, next_offset, x,
Modified: trunk/netsurf/utils/utf8.c
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/utf8.c?rev=3868&r1=...
==============================================================================
--- trunk/netsurf/utils/utf8.c (original)
+++ trunk/netsurf/utils/utf8.c Mon Feb 25 17:58:00 2008
@@ -44,9 +44,10 @@
* \param l Length of sequence
* \return UCS4 character
*/
-size_t utf8_to_ucs4(const char *s, size_t l)
+size_t utf8_to_ucs4(const char *s_in, size_t l)
{
size_t c = 0;
+ const unsigned char *s = (const unsigned char *) s_in;
if (!s)
assert(0);
15 years, 7 months
r3867 jmb - /trunk/netsurf/css/css.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Feb 25 17:08:09 2008
New Revision: 3867
URL: http://source.netsurf-browser.org?rev=3867&view=rev
Log:
s/FALSE/false/g
s/TRUE/true/g
Modified:
trunk/netsurf/css/css.c
Modified: trunk/netsurf/css/css.c
URL: http://source.netsurf-browser.org/trunk/netsurf/css/css.c?rev=3867&r1=386...
==============================================================================
--- trunk/netsurf/css/css.c (original)
+++ trunk/netsurf/css/css.c Mon Feb 25 17:08:09 2008
@@ -2435,23 +2435,23 @@
}
/**
- * Set all members to FALSE
+ * Set all members to false
*/
void css_importance_reset(struct css_importance *i) {
- i->background_color = FALSE;
- i->background_image = FALSE;
- i->border_spacing = FALSE;
- i->color = FALSE;
- i->height = FALSE;
- i->width = FALSE;
+ i->background_color = false;
+ i->background_image = false;
+ i->border_spacing = false;
+ i->color = false;
+ i->height = false;
+ i->width = false;
/**< top, right, bottom, left */
for (int j = 0; j < 4; j++) {
- i->border_color[j] = FALSE;
- i->border_style[j] = FALSE;
- i->border_width[j] = FALSE;
- i->margin[j] = FALSE;
- i->padding[j] = FALSE;
+ i->border_color[j] = false;
+ i->border_style[j] = false;
+ i->border_width[j] = false;
+ i->margin[j] = false;
+ i->padding[j] = false;
}
}
@@ -2851,34 +2851,34 @@
/* Set author level CSS importance (used for HTML style attribute) */
if (author) {
if (apply->background_color != CSS_COLOR_NOT_SET)
- author->background_color = TRUE;
+ author->background_color = true;
if (apply->background_image.type !=
CSS_BACKGROUND_IMAGE_NOT_SET)
- author->background_image = TRUE;
+ author->background_image = true;
if (apply->border_spacing.border_spacing !=
CSS_BORDER_SPACING_NOT_SET)
- author->border_spacing = TRUE;
+ author->border_spacing = true;
if (apply->color != CSS_COLOR_NOT_SET)
- author->color = TRUE;
+ author->color = true;
if (apply->height.height != CSS_HEIGHT_NOT_SET)
- author->height = TRUE;
+ author->height = true;
if (apply->width.width != CSS_WIDTH_NOT_SET)
- author->width = TRUE;
+ author->width = true;
for (i = 0; i != 4; i++) {
if (apply->border[i].color != CSS_COLOR_NOT_SET)
- author->border_color[i] = TRUE;
+ author->border_color[i] = true;
if (apply->border[i].width.width !=
CSS_BORDER_WIDTH_NOT_SET)
- author->border_width[i] = TRUE;
+ author->border_width[i] = true;
if (apply->border[i].style != CSS_BORDER_STYLE_NOT_SET)
- author->border_style[i] = TRUE;
+ author->border_style[i] = true;
if (apply->margin[i].margin != CSS_MARGIN_NOT_SET)
- author->margin[i] = TRUE;
+ author->margin[i] = true;
if (apply->padding[i].padding != CSS_PADDING_NOT_SET)
- author->padding[i] = TRUE;
+ author->padding[i] = true;
}
}
}
@@ -2909,12 +2909,12 @@
if (apply->background_color != CSS_COLOR_NOT_SET) {
style->background_color = apply->background_color;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->background_color = TRUE;
+ author->background_color = true;
}
if (apply->background_image.type != CSS_BACKGROUND_IMAGE_NOT_SET) {
style->background_image = apply->background_image;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->background_image = TRUE;
+ author->background_image = true;
}
if (apply->background_repeat != CSS_BACKGROUND_REPEAT_NOT_SET)
style->background_repeat = apply->background_repeat;
@@ -2923,7 +2923,7 @@
if (apply->border_spacing.border_spacing != CSS_BORDER_SPACING_NOT_SET){
style->border_spacing = apply->border_spacing;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->border_spacing = TRUE;
+ author->border_spacing = true;
}
if (apply->caption_side != CSS_CAPTION_SIDE_NOT_SET)
style->caption_side = apply->caption_side;
@@ -2932,7 +2932,7 @@
if (apply->color != CSS_COLOR_NOT_SET) {
style->color = apply->color;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->color = TRUE;
+ author->color = true;
}
if (apply->content.type != CSS_CONTENT_NOT_SET)
style->content = apply->content;
@@ -2963,7 +2963,7 @@
if (apply->height.height != CSS_HEIGHT_NOT_SET) {
style->height = apply->height;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->height = TRUE;
+ author->height = true;
}
if (apply->letter_spacing.letter_spacing != CSS_LETTER_SPACING_NOT_SET)
style->letter_spacing = apply->letter_spacing;
@@ -3019,7 +3019,7 @@
if (apply->width.width != CSS_WIDTH_NOT_SET) {
style->width = apply->width;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->width = TRUE;
+ author->width = true;
}
if (apply->word_spacing.word_spacing != CSS_WORD_SPACING_NOT_SET)
style->word_spacing = apply->word_spacing;
@@ -3059,29 +3059,29 @@
if (apply->border[i].color != CSS_COLOR_NOT_SET) {
style->border[i].color = apply->border[i].color;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->border_color[i] = TRUE;
+ author->border_color[i] = true;
}
if (apply->border[i].width.width != CSS_BORDER_WIDTH_NOT_SET) {
style->border[i].width = apply->border[i].width;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->border_width[i] = TRUE;
+ author->border_width[i] = true;
}
if (apply->border[i].style != CSS_BORDER_STYLE_NOT_SET) {
style->border[i].style = apply->border[i].style;
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->border_style[i] = TRUE;
+ author->border_style[i] = true;
}
if (apply->margin[i].margin != CSS_MARGIN_NOT_SET) {
style->margin[i] = apply->margin[i];
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->margin[i] = TRUE;
+ author->margin[i] = true;
}
if (apply->padding[i].padding != CSS_PADDING_NOT_SET) {
style->padding[i] = apply->padding[i];
if (specificity >= CSS_SPECIFICITY_AUTHOR)
- author->padding[i] = TRUE;
+ author->padding[i] = true;
}
if (apply->pos[i].pos != CSS_POS_NOT_SET)
15 years, 7 months
r3866 tlsa - in /trunk/netsurf: !NetSurf/Resources/CSS, f79 css/css.c css/css.h render/box_construct.c render/box_normalise.c
by netsurf@semichrome.net
Author: tlsa
Date: Mon Feb 25 16:37:48 2008
New Revision: 3866
URL: http://source.netsurf-browser.org?rev=3866&view=rev
Log:
Improve handling of HTML attributes / markup:
* Only apply presentational HTML attributes if no more
important CSS has been set for the property. (NetSurf used
to be a bit hit-and-miss when presentational markup and
CSS were mixed.)
* Change table cellpadding and border handling to happen as
soon the boxes styles are available, rather than after the
whole table has been constructed. Also fix default table
border colour.
* Improve handling of CENTER tag and ALIGN attribute. These
could not be correctly supported in the default CSS file,
so block level element alignment is now done during box
construction. (Fixes #1891379, #1824492, #1723853)
Form improvements:
* Small MAXLENGTH values on text inputs now reduce element
width. (Fixes #1894854)
* Prevent select option text from wrapping.
Modified:
trunk/netsurf/!NetSurf/Resources/CSS,f79
trunk/netsurf/css/css.c
trunk/netsurf/css/css.h
trunk/netsurf/render/box_construct.c
trunk/netsurf/render/box_normalise.c
Modified: trunk/netsurf/!NetSurf/Resources/CSS,f79
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/CSS%...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/CSS,f79 (original)
+++ trunk/netsurf/!NetSurf/Resources/CSS,f79 Mon Feb 25 16:37:48 2008
@@ -11,9 +11,6 @@
body { display: block; padding: 8px; line-height: 1.33; }
div { display: block; }
-div[align=left] > * { margin-right: auto; }
-div[align=center] > * { margin-left: auto; margin-right: auto; }
-div[align=right] > * { margin-left: auto; }
h1 { display: block; font-size: 2em; font-weight: bold; margin: .67em 0; }
h2 { display: block; font-size: 1.5em; font-weight: bold; margin: .69em 0; }
@@ -92,13 +89,9 @@
td[nowrap], th[nowrap] { white-space: nowrap; }
-td[align=left] > *, th[align=left] > * { margin-right: auto; }
-td[align=center] > *, th[align=center] > * { margin-left: auto; margin-right: auto; }
-td[align=right] > *, th[align=right] > * { margin-left: auto; }
-
-tr[align=left] > td, tr[align=left] > th { text-align: left; margin-right: auto; }
-tr[align=center] > td, tr[align=center] > th { text-align: center; margin-left: auto; margin-right: auto; }
-tr[align=right] > td, tr[align=right] > th { text-align: right; margin-left: auto; }
+tr[align=left] > td, tr[align=left] > th { text-align: left; }
+tr[align=center] > td, tr[align=center] > th { text-align: center; }
+tr[align=right] > td, tr[align=right] > th { text-align: right; }
col[valign=top], colgroup[valign=top], tbody[valign=top], td[valign=top], tfoot[valign=top], th[valign=top], thead[valign=top], tr[valign=top] { vertical-align: top; }
col[valign=middle], colgroup[valign=middle], tbody[valign=middle], td[valign=middle], tfoot[valign=middle], th[valign=middle], thead[valign=middle], tr[valign=middle] { vertical-align: middle; }
@@ -117,7 +110,6 @@
applet[align=right] { float: right; }
center { display: block; text-align: center; }
-center > * { margin-left: auto; margin-right: auto; }
tt { font-family: monospace; }
i { font-style: italic; }
Modified: trunk/netsurf/css/css.c
URL: http://source.netsurf-browser.org/trunk/netsurf/css/css.c?rev=3866&r1=386...
==============================================================================
--- trunk/netsurf/css/css.c (original)
+++ trunk/netsurf/css/css.c Mon Feb 25 16:37:48 2008
@@ -1,6 +1,7 @@
/*
* Copyright 2004 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2004 John M Bell <jmb202(a)ecs.soton.ac.uk>
+ * Copyright 2008 Michael Drake <tlsa(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -131,6 +132,7 @@
static void css_dump_selector(const struct css_selector *r);
static void css_dump_working_stylesheet(
const struct css_working_stylesheet *ws);
+static void css_importance_reset(struct css_importance *i);
/** Default style for a document. These are the 'Initial values' from the
* spec. */
@@ -1124,15 +1126,19 @@
* \param working_stylesheet working stylesheet
* \param element element in xml tree to match
* \param style style to update
+ * \pram author updated to indicate properties with author level css
+ * importance
*
* The style is updated with any rules that match the element.
*/
void css_get_style(struct css_working_stylesheet *working_stylesheet,
- xmlNode *element, struct css_style *style)
+ xmlNode *element, struct css_style *style,
+ struct css_importance *author)
{
unsigned int hash, rule_0 = 0, rule_h = 0;
struct css_selector *rule;
+ css_importance_reset(author); /* initialise to sub-author level */
hash = css_hash((const char *) element->name,
strlen((const char *) element->name));
@@ -1153,7 +1159,8 @@
rule_h++;
}
if (css_match_rule(rule, element))
- css_merge(style, rule->style);
+ css_merge(style, rule->style, rule->specificity,
+ author);
}
/* remaining rules from hash chain 0 */
@@ -1162,7 +1169,8 @@
rule = working_stylesheet->rule[0][rule_0];
rule_0++;
if (css_match_rule(rule, element))
- css_merge(style, rule->style);
+ css_merge(style, rule->style, rule->specificity,
+ author);
}
/* remaining rules from hash chain for element name */
@@ -1171,7 +1179,8 @@
rule = working_stylesheet->rule[hash][rule_h];
rule_h++;
if (css_match_rule(rule, element))
- css_merge(style, rule->style);
+ css_merge(style, rule->style, rule->specificity,
+ author);
}
}
@@ -2426,6 +2435,27 @@
}
/**
+ * Set all members to FALSE
+ */
+void css_importance_reset(struct css_importance *i) {
+ i->background_color = FALSE;
+ i->background_image = FALSE;
+ i->border_spacing = FALSE;
+ i->color = FALSE;
+ i->height = FALSE;
+ i->width = FALSE;
+
+ /**< top, right, bottom, left */
+ for (int j = 0; j < 4; j++) {
+ i->border_color[j] = FALSE;
+ i->border_style[j] = FALSE;
+ i->border_width[j] = FALSE;
+ i->margin[j] = FALSE;
+ i->padding[j] = FALSE;
+ }
+}
+
+/**
* Dump a complete css_stylesheet to stderr in CSS syntax.
*/
@@ -2526,8 +2556,11 @@
/**
* Cascade styles.
*
- * \param style css_style to modify
- * \param apply css_style to cascade onto style
+ * \param style css_style to modify
+ * \param apply css_style to cascade onto style
+ * \param author updated to indicate which properties have greater
+ * than author level CSS importance. (NULL if
+ * importance isn't required.)
*
* Attributes which have the value 'inherit' or 'unset' in apply are
* unchanged in style.
@@ -2536,7 +2569,8 @@
*/
void css_cascade(struct css_style * const style,
- const struct css_style * const apply)
+ const struct css_style * const apply,
+ struct css_importance * const author)
{
unsigned int i;
float f;
@@ -2813,42 +2847,93 @@
apply->pos[i].pos != CSS_POS_NOT_SET)
style->pos[i] = apply->pos[i];
}
+
+ /* Set author level CSS importance (used for HTML style attribute) */
+ if (author) {
+ if (apply->background_color != CSS_COLOR_NOT_SET)
+ author->background_color = TRUE;
+ if (apply->background_image.type !=
+ CSS_BACKGROUND_IMAGE_NOT_SET)
+ author->background_image = TRUE;
+ if (apply->border_spacing.border_spacing !=
+ CSS_BORDER_SPACING_NOT_SET)
+ author->border_spacing = TRUE;
+ if (apply->color != CSS_COLOR_NOT_SET)
+ author->color = TRUE;
+ if (apply->height.height != CSS_HEIGHT_NOT_SET)
+ author->height = TRUE;
+ if (apply->width.width != CSS_WIDTH_NOT_SET)
+ author->width = TRUE;
+
+ for (i = 0; i != 4; i++) {
+ if (apply->border[i].color != CSS_COLOR_NOT_SET)
+ author->border_color[i] = TRUE;
+ if (apply->border[i].width.width !=
+ CSS_BORDER_WIDTH_NOT_SET)
+ author->border_width[i] = TRUE;
+ if (apply->border[i].style != CSS_BORDER_STYLE_NOT_SET)
+ author->border_style[i] = TRUE;
+
+ if (apply->margin[i].margin != CSS_MARGIN_NOT_SET)
+ author->margin[i] = TRUE;
+
+ if (apply->padding[i].padding != CSS_PADDING_NOT_SET)
+ author->padding[i] = TRUE;
+ }
+ }
}
/**
* Merge styles.
*
- * \param style css_style to modify
- * \param apply css_style to merge onto style
+ * \param style css_style to modify
+ * \param apply css_style to merge onto style
+ * \param specificity specificity of current CSS rule
+ * \param author updated to indicate which properties have greater than
+ * author level CSS importance
*
* Attributes which have the value 'unset' in apply are unchanged in style.
* Other attributes are copied to style, overwriting it.
*/
void css_merge(struct css_style * const style,
- const struct css_style * const apply)
+ const struct css_style * const apply,
+ const unsigned long specificity,
+ struct css_importance * const author)
{
unsigned int i;
if (apply->background_attachment != CSS_BACKGROUND_ATTACHMENT_NOT_SET)
style->background_attachment = apply->background_attachment;
- if (apply->background_color != CSS_COLOR_NOT_SET)
+ if (apply->background_color != CSS_COLOR_NOT_SET) {
style->background_color = apply->background_color;
- if (apply->background_image.type != CSS_BACKGROUND_IMAGE_NOT_SET)
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->background_color = TRUE;
+ }
+ if (apply->background_image.type != CSS_BACKGROUND_IMAGE_NOT_SET) {
style->background_image = apply->background_image;
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->background_image = TRUE;
+ }
if (apply->background_repeat != CSS_BACKGROUND_REPEAT_NOT_SET)
style->background_repeat = apply->background_repeat;
if (apply->border_collapse != CSS_BORDER_COLLAPSE_NOT_SET)
style->border_collapse = apply->border_collapse;
- if (apply->border_spacing.border_spacing != CSS_BORDER_SPACING_NOT_SET)
+ if (apply->border_spacing.border_spacing != CSS_BORDER_SPACING_NOT_SET){
style->border_spacing = apply->border_spacing;
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->border_spacing = TRUE;
+ }
if (apply->caption_side != CSS_CAPTION_SIDE_NOT_SET)
style->caption_side = apply->caption_side;
if (apply->clear != CSS_CLEAR_NOT_SET)
style->clear = apply->clear;
- if (apply->color != CSS_COLOR_NOT_SET)
+ if (apply->color != CSS_COLOR_NOT_SET) {
style->color = apply->color;
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->color = TRUE;
+ }
if (apply->content.type != CSS_CONTENT_NOT_SET)
style->content = apply->content;
if (apply->counter_reset.type != CSS_COUNTER_RESET_NOT_SET)
@@ -2875,8 +2960,11 @@
style->font_variant = apply->font_variant;
if (apply->font_weight != CSS_FONT_WEIGHT_NOT_SET)
style->font_weight = apply->font_weight;
- if (apply->height.height != CSS_HEIGHT_NOT_SET)
+ if (apply->height.height != CSS_HEIGHT_NOT_SET) {
style->height = apply->height;
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->height = TRUE;
+ }
if (apply->letter_spacing.letter_spacing != CSS_LETTER_SPACING_NOT_SET)
style->letter_spacing = apply->letter_spacing;
if (apply->line_height.size != CSS_LINE_HEIGHT_NOT_SET)
@@ -2928,8 +3016,11 @@
style->white_space = apply->white_space;
if (apply->widows.widows != CSS_WIDOWS_NOT_SET)
style->widows = apply->widows;
- if (apply->width.width != CSS_WIDTH_NOT_SET)
+ if (apply->width.width != CSS_WIDTH_NOT_SET) {
style->width = apply->width;
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->width = TRUE;
+ }
if (apply->word_spacing.word_spacing != CSS_WORD_SPACING_NOT_SET)
style->word_spacing = apply->word_spacing;
if (apply->z_index.z_index != CSS_Z_INDEX_NOT_SET)
@@ -2965,18 +3056,33 @@
/* borders, margins, padding and box position */
for (i = 0; i != 4; i++) {
- if (apply->border[i].color != CSS_COLOR_NOT_SET)
+ if (apply->border[i].color != CSS_COLOR_NOT_SET) {
style->border[i].color = apply->border[i].color;
- if (apply->border[i].width.width != CSS_BORDER_WIDTH_NOT_SET)
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->border_color[i] = TRUE;
+ }
+ if (apply->border[i].width.width != CSS_BORDER_WIDTH_NOT_SET) {
style->border[i].width = apply->border[i].width;
- if (apply->border[i].style != CSS_BORDER_STYLE_NOT_SET)
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->border_width[i] = TRUE;
+ }
+ if (apply->border[i].style != CSS_BORDER_STYLE_NOT_SET) {
style->border[i].style = apply->border[i].style;
-
- if (apply->margin[i].margin != CSS_MARGIN_NOT_SET)
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->border_style[i] = TRUE;
+ }
+
+ if (apply->margin[i].margin != CSS_MARGIN_NOT_SET) {
style->margin[i] = apply->margin[i];
-
- if (apply->padding[i].padding != CSS_PADDING_NOT_SET)
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->margin[i] = TRUE;
+ }
+
+ if (apply->padding[i].padding != CSS_PADDING_NOT_SET) {
style->padding[i] = apply->padding[i];
+ if (specificity >= CSS_SPECIFICITY_AUTHOR)
+ author->padding[i] = TRUE;
+ }
if (apply->pos[i].pos != CSS_POS_NOT_SET)
style->pos[i] = apply->pos[i];
Modified: trunk/netsurf/css/css.h
URL: http://source.netsurf-browser.org/trunk/netsurf/css/css.h?rev=3866&r1=386...
==============================================================================
--- trunk/netsurf/css/css.h (original)
+++ trunk/netsurf/css/css.h Mon Feb 25 16:37:48 2008
@@ -479,6 +479,31 @@
CSS_Z_INDEX_NOT_SET } z_index;
int value;
} z_index;
+};
+
+/** Author level CSS importance info for properties that may be set in HTML */
+struct css_importance {
+ /* background properties */
+ bool background_color;
+ bool background_image;
+
+ /* borders */
+ bool border_style[4]; /**< top, right, bottom, left */
+ bool border_color[4];
+ bool border_width[4];
+ bool border_spacing;
+
+ bool color;
+
+ bool height;
+
+ /* margins */
+ bool margin[4]; /**< top, right, bottom, left */
+
+ /* padding */
+ bool padding[4]; /**< top, right, bottom, left */
+
+ bool width;
};
struct css_stylesheet;
@@ -650,15 +675,19 @@
struct content **stylesheet_content,
unsigned int stylesheet_count);
void css_get_style(struct css_working_stylesheet *working_stylesheet,
- xmlNode *element, struct css_style *style);
+ xmlNode *element, struct css_style *style,
+ struct css_importance *author);
struct css_style *css_duplicate_style(const struct css_style * const style);
void css_free_style(struct css_style *style);
void css_deep_free_content(struct css_content *content);
void css_deep_free_counter_control(struct css_counter_control *control);
void css_cascade(struct css_style * const style,
- const struct css_style * const apply);
+ const struct css_style * const apply,
+ struct css_importance * const author);
void css_merge(struct css_style * const style,
- const struct css_style * const apply);
+ const struct css_style * const apply,
+ const unsigned long specificity,
+ struct css_importance * const author);
void css_parse_property_list(struct content *c, struct css_style * style,
char * str);
colour named_colour(const char *name);
Modified: trunk/netsurf/render/box_construct.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box_construct.c?re...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Mon Feb 25 16:37:48 2008
@@ -3,6 +3,7 @@
* Copyright 2003 Phil Mellor <monkeyson(a)users.sourceforge.net>
* Copyright 2005 John M Bell <jmb202(a)ecs.soton.ac.uk>
* Copyright 2006 Richard Wilson <info(a)tinct.net>
+ * Copyright 2008 Michael Drake <tlsa(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -87,29 +88,48 @@
const char *TARGET_TOP = "_top";
const char *TARGET_BLANK = "_blank";
+/* keeps track of markup presentation */
+struct markup_track {
+ enum {
+ ALIGN_NONE,
+ ALIGN_LEFT,
+ ALIGN_CENTER,
+ ALIGN_RIGHT
+ } align;
+ bool cell_border;
+ colour border_color;
+
+ bool cell_padding;
+ long padding_width;
+};
static bool convert_xml_to_box(xmlNode *n, struct content *content,
struct css_style *parent_style,
struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title);
+ char *href, const char *target, char *title,
+ struct markup_track markup_track,
+ struct css_importance *author);
bool box_construct_element(xmlNode *n, struct content *content,
struct css_style *parent_style,
struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title);
+ char *href, const char *target, char *title,
+ struct markup_track markup_track,
+ struct css_importance *author);
bool box_construct_text(xmlNode *n, struct content *content,
struct css_style *parent_style,
struct box *parent, struct box **inline_container,
char *href, const char *target, char *title);
static struct css_style * box_get_style(struct content *c,
struct css_style *parent_style,
- xmlNode *n);
+ xmlNode *n, struct markup_track *markup_track,
+ struct css_importance *author);
static void box_solve_display(struct css_style *style, bool root);
-static void box_set_cellpadding(struct box *box, int value);
-static void box_set_table_border(struct box *box, int value, colour color);
static void box_text_transform(char *s, unsigned int len,
css_text_transform tt);
#define BOX_SPECIAL_PARAMS xmlNode *n, struct content *content, \
- struct box *box, bool *convert_children
+ struct box *box, bool *convert_children, \
+ struct markup_track markup_track, \
+ struct css_importance *author
static bool box_a(BOX_SPECIAL_PARAMS);
static bool box_body(BOX_SPECIAL_PARAMS);
static bool box_br(BOX_SPECIAL_PARAMS);
@@ -161,7 +181,6 @@
};
#define ELEMENT_TABLE_COUNT (sizeof(element_table) / sizeof(element_table[0]))
-
/**
* Construct a box tree from an xml tree and stylesheets.
*
@@ -174,6 +193,11 @@
{
struct box root;
struct box *inline_container = 0;
+ struct css_importance author;
+ struct markup_track markup_track;
+ markup_track.cell_border = false;
+ markup_track.cell_padding = false;
+ markup_track.align = ALIGN_NONE;
assert(c->type == CONTENT_HTML);
@@ -200,7 +224,7 @@
c->data.html.object = 0;
if (!convert_xml_to_box(n, c, c->data.html.style, &root,
- &inline_container, 0, 0, 0))
+ &inline_container, 0, 0, 0, markup_track, &author))
return false;
if (!box_normalise_block(&root, c))
@@ -247,19 +271,24 @@
* \param href current link URL, or 0 if not in a link
* \param target current link target, or 0 if none
* \param title current title, or 0 if none
+ * \param markup_track track presentation markup that affects descendents
+ * \param author denotes whether current style has author level
+ * importance for certain properties
* \return true on success, false on memory exhaustion
*/
bool convert_xml_to_box(xmlNode *n, struct content *content,
struct css_style *parent_style,
struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title)
+ char *href, const char *target, char *title,
+ struct markup_track markup_track,
+ struct css_importance *author)
{
switch (n->type) {
case XML_ELEMENT_NODE:
return box_construct_element(n, content, parent_style, parent,
inline_container,
- href, target, title);
+ href, target, title, markup_track, author);
case XML_TEXT_NODE:
return box_construct_text(n, content, parent_style, parent,
inline_container, href, target, title);
@@ -282,13 +311,18 @@
* \param href current link URL, or 0 if not in a link
* \param target current link target, or 0 if none
* \param title current title, or 0 if none
+ * \param markup_track track presentation markup that affects descendents
+ * \param author denotes whether current style has author level
+ * importance for certain properties
* \return true on success, false on memory exhaustion
*/
bool box_construct_element(xmlNode *n, struct content *content,
struct css_style *parent_style,
struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title)
+ char *href, const char *target, char *title,
+ struct markup_track markup_track,
+ struct css_importance *author)
{
bool convert_children = true;
char *id = 0;
@@ -298,7 +332,6 @@
struct box *inline_end;
struct css_style *style = 0;
struct element_entry *element;
- colour border_color = 0x888888;
xmlChar *title0;
xmlNode *c;
@@ -316,7 +349,7 @@
*/
parent->strip_leading_newline = 0;
- style = box_get_style(content, parent_style, n);
+ style = box_get_style(content, parent_style, n, &markup_track, author);
if (!style)
return false;
@@ -349,11 +382,13 @@
(int (*)(const void *, const void *)) strcmp);
if (element) {
/* a special convert function exists for this element */
- if (!element->convert(n, content, box, &convert_children))
+ if (!element->convert(n, content, box, &convert_children,
+ markup_track, author))
return false;
href = box->href;
target = box->target;
}
+
if (style->display == CSS_DISPLAY_NONE) {
/* Free style and invalidate box's style pointer */
talloc_free(style);
@@ -395,7 +430,8 @@
for (c = n->children; c; c = c->next)
if (!convert_xml_to_box(c, content, style,
parent, inline_container,
- href, target, title))
+ href, target, title,
+ markup_track, author))
return false;
inline_end = box_create(style, href, target, title, id,
content);
@@ -416,7 +452,8 @@
for (c = n->children; convert_children && c; c = c->next)
if (!convert_xml_to_box(c, content, style, box,
&inline_container_c,
- href, target, title))
+ href, target, title, markup_track,
+ author))
return false;
} else {
if (style->float_ == CSS_FLOAT_LEFT ||
@@ -495,7 +532,8 @@
for (c = n->children; convert_children && c; c = c->next)
if (!convert_xml_to_box(c, content, style, box,
&inline_container_c,
- href, target, title))
+ href, target, title, markup_track,
+ author))
return false;
if (style->float_ == CSS_FLOAT_NONE)
/* new inline container unless this is a float */
@@ -519,32 +557,9 @@
}
xmlFree(s);
}
- if (strcmp((const char *) n->name, "table") == 0) {
- border_color = CSS_COLOR_NONE; /* not set */
- if ((s = (char *) xmlGetProp(n,
- (const xmlChar *) "cellpadding"))) {
- char *endp;
- long value = strtol(s, &endp, 10);
- if (*endp == 0 && 0 <= value && value < 1000)
- /* % not implemented */
- box_set_cellpadding(box, value);
- xmlFree(s);
- }
- if ((s = (char *) xmlGetProp(n,
- (const xmlChar *) "bordercolor"))) {
- parse_inline_colour(s, &border_color);
- xmlFree(s);
- }
- if ((s = (char *) xmlGetProp(n,
- (const xmlChar *) "border"))) {
- int value = atoi(s);
- if (!strrchr(s, '%') && 0 < value) /* % not implemented */
- box_set_table_border(box, value, border_color);
- xmlFree(s);
- }
- }
/* transfer <tr height="n"> down to the <td> elements */
+ /* \todo move this into box_get_style() */
if (strcmp((const char *) n->name, "tr") == 0) {
if ((s = (char *) xmlGetProp(n,
(const xmlChar *) "height"))) {
@@ -555,23 +570,25 @@
/* the specification doesn't make clear what
* percentage heights mean, so ignore them */
} else {
- /* The tree is not normalized yet, so accept cells not
- * in rows and rows not in row groups. */
+ /* The tree is not normalized yet, so accept
+ * cells not in rows and rows not in row
+ * groups. */
struct box *child;
float current;
- for (child = box->children; child; child = child->next) {
+ for (child = box->children; child;
+ child = child->next) {
if (child->type == BOX_TABLE_CELL) {
current = css_len2px(
- &child->style->height.length,
- child->style);
+ &child->style->height.
+ length, child->style);
value = (value > current) ?
- value : current;
+ value : current;
child->style->height.height =
- CSS_HEIGHT_LENGTH;
- child->style->height.length.unit =
- CSS_UNIT_PX;
- child->style->height.length.value =
- value;
+ CSS_HEIGHT_LENGTH;
+ child->style->height.length.
+ unit = CSS_UNIT_PX;
+ child->style->height.length.
+ value = value;
}
}
}
@@ -782,23 +799,41 @@
* \param c content of type CONTENT_HTML that is being processed
* \param parent_style style at this point in xml tree
* \param n node in xml tree
+ * \param markup_track track presentation markup that affects descendents
+ * \param author denotes whether current style has author level
+ * importance for certain properties
* \return the new style, or 0 on memory exhaustion
*
* The style is collected from three sources:
* 1. any styles for this element in the document stylesheet(s)
- * 2. non-CSS HTML attributes
- * 3. the 'style' attribute
+ * 2. the 'style' attribute
+ * 3. non-CSS HTML attributes (subject to importance of CSS style properties)
*/
struct css_style * box_get_style(struct content *c,
struct css_style *parent_style,
- xmlNode *n)
+ xmlNode *n, struct markup_track *markup_track,
+ struct css_importance *author)
{
char *s;
struct css_style *style;
struct css_style *style_new;
char *url;
url_func_result res;
+ colour border_color = 0x888888; /* mid-grey default for tables */
+
+ /* if not in a table, switch off cellpadding and cell borders */
+ if (strcmp(n->name, "thead") != 0 &&
+ strcmp(n->name, "tbody") != 0 &&
+ strcmp(n->name, "tfoot") != 0 &&
+ strcmp(n->name, "tr") != 0 &&
+ strcmp(n->name, "td") != 0 &&
+ strcmp(n->name, "th") != 0 &&
+ strcmp(n->name, "col") != 0 &&
+ strcmp(n->name, "colgroup") != 0) {
+ markup_track->cell_border = false;
+ markup_track->cell_padding = false;
+ }
style = talloc_memdup(c, parent_style, sizeof *style);
if (!style)
@@ -807,17 +842,37 @@
style_new = talloc_memdup(c, &css_blank_style, sizeof *style_new);
if (!style_new)
return 0;
- css_get_style(c->data.html.working_stylesheet, n, style_new);
- css_cascade(style, style_new);
+ css_get_style(c->data.html.working_stylesheet, n, style_new, author);
+ css_cascade(style, style_new, NULL);
/* style_new isn't needed past this point */
talloc_free(style_new);
+
+ /* Handle style attribute. (style attribute values have high enough
+ * specificity to override existing style data.) */
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "style"))) {
+ struct css_style *astyle;
+ astyle = css_duplicate_style(&css_empty_style);
+ if (!astyle) {
+ xmlFree(s);
+ return 0;
+ }
+ css_parse_property_list(c, astyle, s);
+ css_cascade(style, astyle, author);
+ css_free_style(astyle);
+ xmlFree(s);
+ }
+
+ /* Apply presentational HTML attributes to style
+ * (Only apply if style property does not have "author" level
+ * importance or higher.)
+ */
/* This property only applies to the body element, if you believe
* the spec. Many browsers seem to allow it on other elements too,
* so let's be generic ;) */
- if (((s = (char *) xmlGetProp(n, (const xmlChar *) "background"))) &&
- (style->background_image.type == CSS_BACKGROUND_IMAGE_NONE)) {
+ if (!author->background_image && (s = (char *) xmlGetProp(n,
+ (const xmlChar *) "background"))) {
res = url_join(s, c->data.html.base_url, &url);
xmlFree(s);
if (res == URL_FUNC_NOMEM) {
@@ -839,18 +894,20 @@
}
}
- if (((s = (char *) xmlGetProp(n, (const xmlChar *) "bgcolor"))) &&
- (style->background_color == TRANSPARENT)) {
+ if (!author->background_color && (s = (char *) xmlGetProp(n,
+ (const xmlChar *) "bgcolor"))) {
parse_inline_colour(s, &style->background_color);
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "color"))) {
+ if (!author->color && (s = (char *) xmlGetProp(n,
+ (const xmlChar *) "color"))) {
parse_inline_colour(s, &style->color);
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "height"))) {
+ if (!author->height && (s = (char *) xmlGetProp(n,
+ (const xmlChar *) "height"))) {
float value = isdigit(s[0]) ? atof(s) : -1;
if (value <= 0 || strlen(s) == 0) {
/* ignore negative values and height="" */
@@ -865,9 +922,10 @@
xmlFree(s);
}
- if (strcmp((const char *) n->name, "input") == 0) {
+ if (!author->width && strcmp((const char *) n->name, "input") == 0) {
+ int size = -1;
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "size"))) {
- int size = isdigit(s[0]) ? atoi(s): -1;
+ size = isdigit(s[0]) ? atoi(s): -1;
if (0 < size) {
char *type = (char *) xmlGetProp(n,
(const xmlChar *) "type");
@@ -889,16 +947,41 @@
}
xmlFree(s);
}
- }
-
- if (strcmp((const char *) n->name, "body") == 0) {
+ /* If valid maxlength value is provided, the size attribute is
+ * unset and maxlength is small, use it to reduce input width
+ * to sensible size */
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *)
+ "maxlength"))) {
+ int maxlength = isdigit(s[0]) ? atoi(s): -1;
+ if (0 < maxlength && size == -1 && maxlength < 10) {
+ /* Bump up really small widths */
+ maxlength = maxlength < 5 ? maxlength + 1 :
+ maxlength;
+ char *type = (char *) xmlGetProp(n,
+ (const xmlChar *) "type");
+ style->width.width = CSS_WIDTH_LENGTH;
+ if (!type || strcasecmp(type, "text") == 0 ||
+ strcasecmp(type, "password") == 0)
+ /* in characters for text, password */
+ style->width.value.length.unit =
+ CSS_UNIT_EX;
+ style->width.value.length.value = maxlength;
+ if (type)
+ xmlFree(type);
+ }
+ xmlFree(s);
+ }
+ }
+
+ if (!author->color && strcmp((const char *) n->name, "body") == 0) {
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "text"))) {
parse_inline_colour(s, &style->color);
xmlFree(s);
}
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "width"))) {
+ if (!author->width && (s = (char *) xmlGetProp(n,
+ (const xmlChar *) "width"))) {
float value = isdigit(s[0]) ? atof(s) : -1;
if (value < 0 || strlen(s) == 0) {
/* ignore negative values and width="" */
@@ -914,7 +997,8 @@
}
if (strcmp((const char *) n->name, "textarea") == 0) {
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "rows"))) {
+ if (!author->height && (s = (char *) xmlGetProp(n,
+ (const xmlChar *) "rows"))) {
int value = isdigit(s[0]) ? atoi(s): -1;
if (0 < value) {
style->height.height = CSS_HEIGHT_LENGTH;
@@ -923,7 +1007,8 @@
}
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "cols"))) {
+ if (!author->width && (s = (char *) xmlGetProp(n,
+ (const xmlChar *) "cols"))) {
int value = isdigit(s[0]) ? atoi(s): -1;
if (0 < value) {
style->width.width = CSS_WIDTH_LENGTH;
@@ -935,22 +1020,88 @@
}
if (strcmp((const char *) n->name, "table") == 0) {
- if ((s = (char *) xmlGetProp(n,
- (const xmlChar *) "cellspacing"))) {
- if (!strrchr(s, '%')) { /* % not implemented */
+ if (!author->border_spacing && (s = (char *) xmlGetProp(n,
+ (const xmlChar *) "cellspacing"))) {
+ /* percentage cellspacing not implemented */
+ if (!strrchr(s, '%')) {
int value = isdigit(s[0]) ? atoi(s): -1;
if (0 <= value) {
style->border_spacing.border_spacing =
CSS_BORDER_SPACING_LENGTH;
style->border_spacing.horz.unit =
style->border_spacing.vert.unit =
- CSS_UNIT_PX;
+ CSS_UNIT_PX;
style->border_spacing.horz.value =
style->border_spacing.vert.value =
- value;
+ value;
}
}
xmlFree(s);
+ }
+
+ if ((s = (char *) xmlGetProp(n,
+ (const xmlChar *) "bordercolor"))) {
+ parse_inline_colour(s, &border_color);
+ xmlFree(s);
+ }
+ if ((s = (char *) xmlGetProp(n,
+ (const xmlChar *) "border"))) {
+ int border_width = atoi(s);
+ /* precentage border width not implemented */
+ if (!strrchr(s, '%') && 0 < border_width) {
+ for (unsigned int i = 0; i != 4; i++) {
+ if (!author->border_color[i])
+ style->border[i].color =
+ border_color;
+ if (!author->border_width[i]) {
+ style->border[i].width.width =
+ CSS_BORDER_WIDTH_LENGTH;
+ style->border[i].width.value.
+ value = border_width;
+ style->border[i].width.value.
+ unit = CSS_UNIT_PX;
+ }
+ if (!author->border_style[i])
+ style->border[i].style =
+ CSS_BORDER_STYLE_OUTSET;
+ }
+ }
+ xmlFree(s);
+ }
+ }
+
+ if (strcmp((const char *) n->name, "td") == 0 ||
+ strcmp((const char *) n->name, "th") == 0) {
+ /* set any cellborders stipulated by associated table */
+ if (markup_track->cell_border) {
+ for (unsigned int i = 0; i != 4; i++) {
+ if (!author->border_color[i])
+ style->border[i].color = markup_track->
+ border_color;
+ if (!author->border_width[i]) {
+ style->border[i].width.width =
+ CSS_BORDER_WIDTH_LENGTH;
+ style->border[i].width.value.value = 1;
+ style->border[i].width.value.unit =
+ CSS_UNIT_PX;
+ }
+ if (!author->border_style[i])
+ style->border[i].style =
+ CSS_BORDER_STYLE_INSET;
+ }
+ }
+ /* set any cellpadding stipulated by associated table */
+ if (markup_track->cell_padding) {
+ for (unsigned int i = 0; i != 4; i++) {
+ if (!author->padding[i]) {
+ style->padding[i].padding =
+ CSS_PADDING_LENGTH;
+ style->padding[i].value.length.value =
+ markup_track->padding_width;
+ style->padding[i].value.length.unit =
+ CSS_UNIT_PX;
+ }
+ }
}
}
@@ -959,19 +1110,22 @@
(strcmp((const char *) n->name, "applet") == 0)) {
if ((s = (char *) xmlGetProp(n,
(const xmlChar *) "hspace"))) {
- if (!strrchr(s, '%')) { /* % not implemented */
+ /* percentage hspace not implemented */
+ if (!strrchr(s, '%')) {
int value = isdigit(s[0]) ? atoi(s): -1;
- if (0 <= value) {
+ if (0 <= value && !author->margin[LEFT]) {
style->margin[LEFT].margin =
CSS_MARGIN_LENGTH;
style->margin[LEFT].value.length.value =
value;
style->margin[LEFT].value.length.unit =
CSS_UNIT_PX;
+ }
+ if (0 <= value && !author->margin[RIGHT]) {
style->margin[RIGHT].margin =
CSS_MARGIN_LENGTH;
- style->margin[RIGHT].value.length.value =
- value;
+ style->margin[RIGHT].value.length.
+ value = value;
style->margin[RIGHT].value.length.unit =
CSS_UNIT_PX;
}
@@ -980,41 +1134,140 @@
}
if ((s = (char *) xmlGetProp(n,
(const xmlChar *) "vspace"))) {
- if (!strrchr(s, '%')) { /* % not implemented */
+ /* percentage vspace not implemented */
+ if (!strrchr(s, '%')) {
int value = isdigit(s[0]) ? atoi(s): -1;
- if (0 <= value) {
+ if (0 <= value && !author->margin[TOP]) {
style->margin[TOP].margin =
CSS_MARGIN_LENGTH;
style->margin[TOP].value.length.value =
value;
style->margin[TOP].value.length.unit =
CSS_UNIT_PX;
+ }
+ if (0 <= value && !author->margin[BOTTOM]) {
style->margin[BOTTOM].margin =
CSS_MARGIN_LENGTH;
- style->margin[BOTTOM].value.length.value =
- value;
- style->margin[BOTTOM].value.length.unit =
- CSS_UNIT_PX;
+ style->margin[BOTTOM].value.length.
+ value = value;
+ style->margin[BOTTOM].value.length.
+ unit = CSS_UNIT_PX;
}
}
xmlFree(s);
}
}
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "style"))) {
- struct css_style *astyle;
- astyle = css_duplicate_style(&css_empty_style);
- if (!astyle) {
+ /* Handle markup-originating alignment of block level elements.
+ * Adjust left and right margins. text-align property is handled in
+ * the default CSS file.
+ */
+ if (markup_track->align != ALIGN_NONE &&
+ (style->display == CSS_DISPLAY_BLOCK ||
+ style->display == CSS_DISPLAY_TABLE)) {
+ if (!author->margin[LEFT]) {
+ if (markup_track->align == ALIGN_LEFT) {
+ /* left */
+ style->margin[LEFT].margin = CSS_MARGIN_LENGTH;
+ style->margin[LEFT].value.length.value = 0;
+ style->margin[LEFT].value.length.unit =
+ CSS_UNIT_PX;
+ } else
+ /* center or right */
+ style->margin[LEFT].margin = CSS_MARGIN_AUTO;
+ }
+
+ if (!author->margin[RIGHT]) {
+ if (markup_track->align == ALIGN_RIGHT) {
+ /* right */
+ style->margin[RIGHT].margin = CSS_MARGIN_LENGTH;
+ style->margin[RIGHT].value.length.value= 0;
+ style->margin[RIGHT].value.length.unit =
+ CSS_UNIT_PX;
+ } else
+ /* left or center */
+ style->margin[RIGHT].margin = CSS_MARGIN_AUTO;
+ }
+ if (author->margin[LEFT] || author->margin[RIGHT]) {
+ /* author stylesheet sets a margin so stop markup
+ * alignment model propagation */
+ markup_track->align = ALIGN_NONE;
+ }
+ }
+
+ box_solve_display(style, !n->parent);
+
+ /* Update markup_track with attributes which affect children of
+ * current box. */
+
+ /* Handle html block level element alignment model.
+ * Note that only margins of block level children are considered,
+ * text-align for the current block can be handled in the default
+ * CSS file.
+ */
+ if (strcmp(n->name, "center") == 0)
+ markup_track->align = ALIGN_CENTER;
+ else if (strcmp(n->name, "div") == 0 ||
+ strcmp(n->name, "col") == 0 ||
+ strcmp(n->name, "colgroup") == 0 ||
+ strcmp(n->name, "tbody") == 0 ||
+ strcmp(n->name, "td") == 0 ||
+ strcmp(n->name, "tfoot") == 0 ||
+ strcmp(n->name, "th") == 0 ||
+ strcmp(n->name, "thead") == 0 ||
+ strcmp(n->name, "tr") == 0) {
+
+ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "align"))) {
+ if (strcasecmp(s, "center") == 0)
+ markup_track->align = ALIGN_CENTER;
+ else if (strcasecmp(s, "right") == 0)
+ markup_track->align = ALIGN_RIGHT;
+ else if (strcasecmp(s, "left") == 0)
+ markup_track->align = ALIGN_LEFT;
xmlFree(s);
- return 0;
- }
- css_parse_property_list(c, astyle, s);
- css_cascade(style, astyle);
- css_free_style(astyle);
- xmlFree(s);
- }
-
- box_solve_display(style, !n->parent);
+ }
+ }
+ /* Table cells without an align value have a default implied
+ * alignment */
+ if (strcmp(n->name, "td") == 0) {
+ if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
+ markup_track->align = ALIGN_LEFT;
+ else
+ xmlFree(s);
+ }
+ if (strcmp(n->name, "th") == 0) {
+ if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
+ markup_track->align = ALIGN_CENTER;
+ else
+ xmlFree(s);
+ }
+
+ /* Some of TABLE's attributes apply to the table cells contained
+ * within the table. Those details are stored so they may be applied
+ * to the cells when we get to them. */
+ if (strcmp((const char *) n->name, "table") == 0) {
+ if ((s = (char *) xmlGetProp(n,
+ (const xmlChar *) "cellpadding"))) {
+ char *endp;
+ long value = strtol(s, &endp, 10);
+ /* precentage padding width not implemented */
+ if (*endp == 0 && 0 <= value && value < 1000) {
+ markup_track->padding_width = value;
+ markup_track->cell_padding = true;
+ }
+ xmlFree(s);
+ }
+ if ((s = (char *) xmlGetProp(n,
+ (const xmlChar *) "border"))) {
+ markup_track->border_color = border_color;
+ int border_width = atoi(s);
+ /* percentage border width not implemented */
+ if (!strrchr(s, '%') && 0 < border_width) {
+ markup_track->cell_border = true;
+ }
+ xmlFree(s);
+ }
+ }
return style;
}
@@ -1030,7 +1283,7 @@
void box_solve_display(struct css_style *style, bool root)
{
- if (style->display == CSS_DISPLAY_NONE) /* 1. */
+ if (style->display == CSS_DISPLAY_NONE) /* 1. */
return;
else if (style->position == CSS_POSITION_ABSOLUTE ||
style->position == CSS_POSITION_FIXED) /* 2. */
@@ -1063,106 +1316,6 @@
; /* same as specified */
else
style->display = CSS_DISPLAY_BLOCK;
-}
-
-
-/**
- * Set the cellpadding on a table.
- *
- * \param box box to set cellpadding on
- * \param value padding in pixels
- *
- * The descendants of the box are searched for table cells, and the padding is
- * set on each one.
- */
-
-void box_set_cellpadding(struct box *box, int value)
-{
- /* The tree is not normalized yet, so accept cells not in rows and
- * rows not in row groups. */
- struct box *child;
- for (child = box->children; child; child = child->next) {
- switch (child->type) {
- case BOX_TABLE_ROW_GROUP:
- case BOX_TABLE_ROW:
- box_set_cellpadding(child, value);
- break;
- case BOX_TABLE_CELL:
- for (unsigned int i = 0; i != 4; i++) {
- child->style->padding[i].padding =
- CSS_PADDING_LENGTH;
- child->style->padding[i].value.length.value =
- value;
- child->style->padding[i].value.length.unit =
- CSS_UNIT_PX;
- }
- break;
- default:
- break;
- }
- }
-}
-
-
-/**
- * Set the borders on a table.
- *
- * \param box box to set cellpadding on
- * \param value border in pixels
- *
- * The descendants of the box are searched for table cells, and the border is
- * set on each one.
- */
-
-void box_set_table_border(struct box *box, int value, colour color)
-{
- struct box *child;
-
- if (box->type == BOX_TABLE) {
- for (unsigned int i = 0; i != 4; i++) {
- if (box->style->border[i].style ==
- CSS_BORDER_STYLE_NONE) {
- box->style->border[i].color = color;
- box->style->border[i].width.width =
- CSS_BORDER_WIDTH_LENGTH;
- box->style->border[i].width.value.value =
- value;
- box->style->border[i].width.value.unit =
- CSS_UNIT_PX;
- box->style->border[i].style =
- CSS_BORDER_STYLE_OUTSET;
- }
- }
- }
-
- /* The tree is not normalized yet, so accept cells not in rows and
- * rows not in row groups. */
- for (child = box->children; child; child = child->next) {
- switch (child->type) {
- case BOX_TABLE_ROW_GROUP:
- case BOX_TABLE_ROW:
- box_set_table_border(child, value, color);
- break;
- case BOX_TABLE_CELL:
- for (unsigned int i = 0; i != 4; i++) {
- if (child->style->border[i].style ==
- CSS_BORDER_STYLE_NONE) {
- child->style->border[i].color = color;
- child->style->border[i].width.width =
- CSS_BORDER_WIDTH_LENGTH;
- child->style->border[i].width.value.value =
- 1;
- child->style->border[i].width.value.unit =
- CSS_UNIT_PX;
- child->style->border[i].style =
- CSS_BORDER_STYLE_INSET;
- }
- }
- break;
- default:
- break;
- }
- }
}
@@ -1497,7 +1650,8 @@
/* convert children and place into fallback */
for (c = n->children; c; c = c->next) {
if (!convert_xml_to_box(c, content, box->style, box,
- &inline_container, 0, 0, 0))
+ &inline_container, 0, 0, 0, markup_track,
+ author))
return false;
}
box->fallback = box->children;
@@ -1576,25 +1730,29 @@
if (!pp)
goto no_memory;
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "name")) != NULL) {
+ if ((s = (char *) xmlGetProp(c,
+ (const xmlChar *) "name")) != NULL) {
pp->name = strdup(s);
xmlFree(s);
if (!pp->name)
goto no_memory;
}
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "value")) != NULL) {
+ if ((s = (char *) xmlGetProp(c,
+ (const xmlChar *) "value")) != NULL) {
pp->value = strdup(s);
xmlFree(s);
if (!pp->value)
goto no_memory;
}
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "type")) != NULL) {
+ if ((s = (char *) xmlGetProp(c,
+ (const xmlChar *) "type")) != NULL) {
pp->type = strdup(s);
xmlFree(s);
if (!pp->type)
goto no_memory;
}
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "valuetype")) != NULL) {
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *)
+ "valuetype")) != NULL) {
pp->valuetype = strdup(s);
xmlFree(s);
if (!pp->valuetype)
@@ -1660,7 +1818,8 @@
return true;
}
- content->data.html.frameset = talloc_zero(content, struct content_html_frames);
+ content->data.html.frameset = talloc_zero(content,
+ struct content_html_frames);
if (!content->data.html.frameset)
return false;
@@ -1723,7 +1882,8 @@
default_border = false;
xmlFree(s);
}
- /* common extension: bordercolor="#RRGGBB|<named colour>" to control all children */
+ /* common extension: bordercolor="#RRGGBB|<named colour>" to control
+ *all children */
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "bordercolor"))) {
parse_inline_colour(s, &default_border_colour);
xmlFree(s);
@@ -1733,7 +1893,8 @@
f->cols = cols;
f->rows = rows;
f->scrolling = SCROLLING_NO;
- f->children = talloc_array(content, struct content_html_frames, (rows * cols));
+ f->children = talloc_array(content, struct content_html_frames,
+ (rows * cols));
for (row = 0; row < rows; row++) {
for (col = 0; col < cols; col++) {
index = (row * cols) + col;
@@ -1785,7 +1946,8 @@
url = NULL;
if ((s = (char *) xmlGetProp(c,
(const xmlChar *) "src"))) {
- box_extract_link(s, content->data.html.base_url, &url);
+ box_extract_link(s, content->data.html.base_url,
+ &url);
xmlFree(s);
}
@@ -1793,7 +1955,8 @@
if (url) {
/* no self-references */
if (strcmp(content->data.html.base_url, url))
- frame->url = talloc_strdup(content, url);
+ frame->url = talloc_strdup(content,
+ url);
free(url);
url = NULL;
}
@@ -1830,7 +1993,8 @@
frame->margin_height = atoi(s);
xmlFree(s);
}
- if ((s = (char *) xmlGetProp(c, (const xmlChar *) "bordercolor"))) {
+ if ((s = (char *) xmlGetProp(c, (const xmlChar *)
+ "bordercolor"))) {
parse_inline_colour(s, &frame->border_colour);
xmlFree(s);
}
@@ -2020,7 +2184,8 @@
type = (char *) xmlGetProp(n, (const xmlChar *) "type");
if (type && strcasecmp(type, "password") == 0) {
- if (!box_input_text(n, content, box, 0, true))
+ if (!box_input_text(n, content, box, 0, markup_track, author,
+ true))
goto no_memory;
gadget = box->gadget;
gadget->box = box;
@@ -2070,7 +2235,7 @@
} else if (type && (strcasecmp(type, "submit") == 0 ||
strcasecmp(type, "reset") == 0)) {
struct box *inline_container, *inline_box;
- if (!box_button(n, content, box, 0))
+ if (!box_button(n, content, box, 0, markup_track, author))
goto no_memory;
inline_container = box_create(0, 0, 0, 0, 0, content);
if (!inline_container)
@@ -2098,7 +2263,7 @@
} else if (type && strcasecmp(type, "button") == 0) {
struct box *inline_container, *inline_box;
- if (!box_button(n, content, box, 0))
+ if (!box_button(n, content, box, 0, markup_track, author))
goto no_memory;
inline_container = box_create(0, 0, 0, 0, 0, content);
if (!inline_container)
@@ -2142,7 +2307,8 @@
html.base_url) != 0) {
if (!html_fetch_object(content, url,
box, image_types,
- content->available_width,
+ content->
+ available_width,
1000, false)) {
free(url);
goto no_memory;
@@ -2154,7 +2320,8 @@
} else {
/* the default type is "text" */
- if (!box_input_text(n, content, box, 0, false))
+ if (!box_input_text(n, content, box, 0, markup_track, author,
+ false))
goto no_memory;
gadget = box->gadget;
gadget->box = box;
@@ -2419,6 +2586,7 @@
{
char *value = 0;
char *text = 0;
+ char *text_nowrap = 0;
bool selected;
xmlChar *content;
xmlChar *s;
@@ -2441,14 +2609,22 @@
selected = xmlHasProp(n, (const xmlChar *) "selected");
- if (!form_add_option(control, value, text, selected))
+ /* replace spaces/TABs with hard spaces to prevent line wrapping */
+ text_nowrap = cnv_space2nbsp(text);
+ if (!text_nowrap)
goto no_memory;
+
+ if (!form_add_option(control, value, text_nowrap, selected))
+ goto no_memory;
+
+ free(text);
return true;
no_memory:
free(value);
free(text);
+ free(text_nowrap);
return false;
}
Modified: trunk/netsurf/render/box_normalise.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box_normalise.c?re...
==============================================================================
--- trunk/netsurf/render/box_normalise.c (original)
+++ trunk/netsurf/render/box_normalise.c Mon Feb 25 16:37:48 2008
@@ -141,7 +141,7 @@
style = talloc_memdup(c, block->style, sizeof *style);
if (!style)
return false;
- css_cascade(style, &css_blank_style);
+ css_cascade(style, &css_blank_style, NULL);
table = box_create(style, block->href, block->target,
0, 0, c);
if (!table) {
@@ -225,7 +225,7 @@
free(col_info.spans);
return false;
}
- css_cascade(style, &css_blank_style);
+ css_cascade(style, &css_blank_style, NULL);
row_group = box_create(style, table->href,
table->target, 0, 0, c);
if (!row_group) {
@@ -401,7 +401,7 @@
sizeof *style);
if (!style)
return false;
- css_cascade(style, &css_blank_style);
+ css_cascade(style, &css_blank_style, NULL);
row = box_create(style, row_group->href,
row_group->target, 0, 0, c);
if (!row) {
@@ -501,7 +501,7 @@
style = talloc_memdup(c, row->style, sizeof *style);
if (!style)
return false;
- css_cascade(style, &css_blank_style);
+ css_cascade(style, &css_blank_style, NULL);
cell = box_create(style, row->href, row->target, 0, 0,
c);
if (!cell) {
15 years, 7 months
r3862 bursa - in /trunk/libsvgtiny: svgtiny.c svgtiny_gradient.c svgtiny_internal.h
by netsurf@semichrome.net
Author: bursa
Date: Tue Feb 19 01:13:11 2008
New Revision: 3862
URL: http://source.netsurf-browser.org?rev=3862&view=rev
Log:
Add support for x1, y1, x2, y2 attributes of linearGradient.
Modified:
trunk/libsvgtiny/svgtiny.c
trunk/libsvgtiny/svgtiny_gradient.c
trunk/libsvgtiny/svgtiny_internal.h
Modified: trunk/libsvgtiny/svgtiny.c
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/svgtiny.c?rev=3862&r1=...
==============================================================================
--- trunk/libsvgtiny/svgtiny.c (original)
+++ trunk/libsvgtiny/svgtiny.c Tue Feb 19 01:13:11 2008
@@ -36,8 +36,6 @@
static void svgtiny_parse_position_attributes(const xmlNode *node,
const struct svgtiny_parse_state state,
float *x, float *y, float *width, float *height);
-static float svgtiny_parse_length(const char *s, int viewport_size,
- const struct svgtiny_parse_state state);
static void svgtiny_parse_paint_attributes(const xmlNode *node,
struct svgtiny_parse_state *state);
static void svgtiny_parse_font_attributes(const xmlNode *node,
Modified: trunk/libsvgtiny/svgtiny_gradient.c
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/svgtiny_gradient.c?rev...
==============================================================================
--- trunk/libsvgtiny/svgtiny_gradient.c (original)
+++ trunk/libsvgtiny/svgtiny_gradient.c Tue Feb 19 01:13:11 2008
@@ -11,7 +11,7 @@
#include "svgtiny.h"
#include "svgtiny_internal.h"
-#define GRADIENT_DEBUG
+#undef GRADIENT_DEBUG
static svgtiny_code svgtiny_parse_linear_gradient(xmlNode *linear,
struct svgtiny_parse_state *state);
@@ -29,6 +29,10 @@
fprintf(stderr, "svgtiny_find_gradient: id \"%s\"\n", id);
state->linear_gradient_stop_count = 0;
+ state->gradient_x1 = "0%";
+ state->gradient_y1 = "0%";
+ state->gradient_x2 = "100%";
+ state->gradient_y2 = "0%";
xmlNode *gradient = svgtiny_find_element_by_id(
(xmlNode *) state->document, id);
@@ -58,6 +62,19 @@
if (href && href->children->content[0] == '#')
svgtiny_find_gradient((const char *) href->children->content
+ 1, state);
+
+ for (xmlAttr *attr = linear->properties; attr; attr = attr->next) {
+ const char *name = (const char *) attr->name;
+ const char *content = (const char *) attr->children->content;
+ if (strcmp(name, "x1") == 0)
+ state->gradient_x1 = content;
+ else if (strcmp(name, "y1") == 0)
+ state->gradient_y1 = content;
+ else if (strcmp(name, "x2") == 0)
+ state->gradient_x2 = content;
+ else if (strcmp(name, "y2") == 0)
+ state->gradient_y2 = content;
+ }
unsigned int i = 0;
for (xmlNode *stop = linear->children; stop; stop = stop->next) {
@@ -148,13 +165,19 @@
#endif
/* compute gradient vector */
- float gradient_x0 = 0, gradient_y0 = 0,
- gradient_x1 = 1, gradient_y1 = 0.7,
+ fprintf(stderr, "x1 %s, y1 %s, x2 %s, y2 %s\n",
+ state->gradient_x1, state->gradient_y1,
+ state->gradient_x2, state->gradient_y2);
+ float gradient_x0, gradient_y0, gradient_x1, gradient_y1,
gradient_dx, gradient_dy;
- gradient_x0 = object_x0 + gradient_x0 * (object_x1 - object_x0);
- gradient_y0 = object_y0 + gradient_y0 * (object_y1 - object_y0);
- gradient_x1 = object_x0 + gradient_x1 * (object_x1 - object_x0);
- gradient_y1 = object_y0 + gradient_y1 * (object_y1 - object_y0);
+ gradient_x0 = object_x0 + svgtiny_parse_length(state->gradient_x1,
+ object_x1 - object_x0, *state);
+ gradient_y0 = object_y0 + svgtiny_parse_length(state->gradient_y1,
+ object_y1 - object_y0, *state);
+ gradient_x1 = object_x0 + svgtiny_parse_length(state->gradient_x2,
+ object_x1 - object_x0, *state);
+ gradient_y1 = object_y0 + svgtiny_parse_length(state->gradient_y2,
+ object_y1 - object_y0, *state);
gradient_dx = gradient_x1 - gradient_x0;
gradient_dy = gradient_y1 - gradient_y0;
#ifdef GRADIENT_DEBUG
@@ -199,7 +222,7 @@
}
shape->path = p;
shape->path_length = 13;
- shape->fill = svgtiny_TRANSPARENT;
+ shape->fill = svgtiny_TRANSPARENT;
shape->stroke = svgtiny_RGB(0, 0xff, 0);
state->diagram->shape_count++;
}*/
@@ -312,10 +335,10 @@
b = min_pt == 0 ? pts_count - 1 : min_pt - 1;
while (a != b) {
float mean_r = (pts[t].r + pts[a].r + pts[b].r) / 3;
- fprintf(stderr, "triangle: t %i %.3f a %i %.3f b %i %.3f "
+ /*fprintf(stderr, "triangle: t %i %.3f a %i %.3f b %i %.3f "
"mean_r %.3f\n",
t, pts[t].r, a, pts[a].r, b, pts[b].r,
- mean_r);
+ mean_r);*/
while (current_stop != stop_count && current_stop_r < mean_r) {
current_stop++;
if (current_stop == stop_count)
@@ -403,7 +426,7 @@
}
shape->path = p;
shape->path_length = 7;
- shape->fill = svgtiny_TRANSPARENT;
+ shape->fill = svgtiny_TRANSPARENT;
shape->stroke = svgtiny_RGB(0xff, 0, 0);
state->diagram->shape_count++;
}
Modified: trunk/libsvgtiny/svgtiny_internal.h
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/svgtiny_internal.h?rev...
==============================================================================
--- trunk/libsvgtiny/svgtiny_internal.h (original)
+++ trunk/libsvgtiny/svgtiny_internal.h Tue Feb 19 01:13:11 2008
@@ -37,16 +37,19 @@
/* gradients */
unsigned int linear_gradient_stop_count;
+ const char *gradient_x1, *gradient_y1, *gradient_x2, *gradient_y2;
struct svgtiny_gradient_stop gradient_stop[svgtiny_MAX_STOPS];
};
/* svgtiny.c */
-void svgtiny_transform_path(float *p, unsigned int n,
- struct svgtiny_parse_state *state);
+float svgtiny_parse_length(const char *s, int viewport_size,
+ const struct svgtiny_parse_state state);
void svgtiny_parse_color(const char *s, svgtiny_colour *c,
struct svgtiny_parse_state *state);
struct svgtiny_shape *svgtiny_add_shape(struct svgtiny_parse_state *state);
+void svgtiny_transform_path(float *p, unsigned int n,
+ struct svgtiny_parse_state *state);
/* svgtiny_gradient.c */
void svgtiny_find_gradient(const char *id, struct svgtiny_parse_state *state);
15 years, 7 months