r2681 rjw - /trunk/netsurf/utils/url.c
by netsurf@semichrome.net
Author: rjw
Date: Sat Jul 1 00:09:21 2006
New Revision: 2681
URL: http://svn.semichrome.net?rev=2681&view=rev
Log:
Stop possible pollution of the cache.
Modified:
trunk/netsurf/utils/url.c
Modified: trunk/netsurf/utils/url.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/url.c?rev=2681&r1=2680&r2=2...
==============================================================================
--- trunk/netsurf/utils/url.c (original)
+++ trunk/netsurf/utils/url.c Sat Jul 1 00:09:21 2006
@@ -248,7 +248,7 @@
assert(base);
assert(rel);
- /* break down the relative URL */
+ /* break down the relative URL (not cached, corruptable) */
status = url_get_components(rel, &rel_components, false);
if (status != URL_FUNC_OK) {
LOG(("relative url '%s' failed to get components", rel));
@@ -260,7 +260,7 @@
if (rel_components.scheme)
goto url_join_reform_url;
- /* break down the base URL */
+ /* break down the base URL (possibly cached, not corruptable) */
status = url_get_components(base, &base_components, true);
if (status != URL_FUNC_OK) {
LOG(("base url '%s' failed to get components", base));
@@ -275,7 +275,15 @@
/* [3] handle empty paths */
merged_components.authority = base_components.authority;
if (!rel_components.path) {
- merged_components.path = base_components.path;
+ /* we cannot refer directly to base_components.path as it
+ * may be in the cache and could get altered during dot
+ * removal in url_join_reform_url */
+ merge_path = strdup(base_components.path);
+ if (!merge_path) {
+ LOG(("malloc failed"));
+ goto url_join_no_mem;
+ }
+ merged_components.path = merge_path;
if (!rel_components.query)
merged_components.query = base_components.query;
goto url_join_reform_url;
@@ -290,7 +298,7 @@
merge_path = malloc(strlen(rel_components.path) + 2);
if (!merge_path) {
LOG(("malloc failed"));
- goto url_join_reform_no_mem;
+ goto url_join_no_mem;
}
sprintf(merge_path, "/%s", rel_components.path);
merged_components.path = merge_path;
@@ -304,7 +312,7 @@
merge_path = malloc(buf_len);
if (!merge_path) {
LOG(("malloc failed"));
- goto url_join_reform_no_mem;
+ goto url_join_no_mem;
}
memcpy(merge_path, base_components.path, len);
memcpy(merge_path + len, rel_components.path,
@@ -323,7 +331,7 @@
output = start = malloc(strlen(input) + 1);
if (!output) {
LOG(("malloc failed"));
- goto url_join_reform_no_mem;
+ goto url_join_no_mem;
}
merged_components.path = output;
*output = '\0';
@@ -403,12 +411,12 @@
/* 5.3 */
*result = url_reform_components(&merged_components);
if (!(*result))
- goto url_join_reform_no_mem;
+ goto url_join_no_mem;
/* return success */
status = URL_FUNC_OK;
-url_join_reform_no_mem:
+url_join_no_mem:
free(output);
free(merge_path);
url_destroy_components(&base_components);
17 years, 3 months
r2680 jmb - /trunk/netsurf/render/layout.c
by netsurf@semichrome.net
Author: jmb
Date: Fri Jun 30 00:30:06 2006
New Revision: 2680
URL: http://svn.semichrome.net?rev=2680&view=rev
Log:
Ensure containing block has valid height for positioning absolute children
Modified:
trunk/netsurf/render/layout.c
Modified: trunk/netsurf/render/layout.c
URL: http://svn.semichrome.net/trunk/netsurf/render/layout.c?rev=2680&r1=2679&...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Fri Jun 30 00:30:06 2006
@@ -158,6 +158,7 @@
int max_pos_margin = 0;
int max_neg_margin = 0;
int y;
+ int old_height;
struct box *margin_box;
assert(block->type == BOX_BLOCK ||
@@ -296,9 +297,18 @@
cy = y;
}
+ /* Before positioning absolute children, ensure box has a
+ * valid height. */
+ old_height = box->height;
+ if (box->height == AUTO)
+ box->height = 0;
+
/* Absolutely positioned children. */
if (!layout_absolute_children(box, content))
return false;
+
+ /* And restore height for normal layout */
+ box->height = old_height;
/* Advance to next box. */
if (box->type == BOX_BLOCK && !box->object && box->children) {
@@ -2783,6 +2793,10 @@
struct box *containing_block,
int *top, int *right, int *bottom, int *left)
{
+ assert(containing_block->width != UNKNOWN_WIDTH &&
+ containing_block->width != AUTO &&
+ containing_block->height != AUTO);
+
/* left */
if (box->style->pos[LEFT].pos == CSS_POS_PERCENT)
*left = ((box->style->pos[LEFT].value.percent *
17 years, 3 months
r2679 jmb - /trunk/netsurf/render/html.c
by netsurf@semichrome.net
Author: jmb
Date: Fri Jun 30 00:29:15 2006
New Revision: 2679
URL: http://svn.semichrome.net?rev=2679&view=rev
Log:
Ignore alternate stylesheets
Modified:
trunk/netsurf/render/html.c
Modified: trunk/netsurf/render/html.c
URL: http://svn.semichrome.net/trunk/netsurf/render/html.c?rev=2679&r1=2678&r2...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Fri Jun 30 00:29:15 2006
@@ -594,6 +594,10 @@
if ((rel = (char *) xmlGetProp(node, (const xmlChar *) "rel")) == NULL)
continue;
if (strstr(rel, "stylesheet") == 0) {
+ xmlFree(rel);
+ continue;
+ } else if (strstr(rel, "alternate")) {
+ /* Ignore alternate stylesheets */
xmlFree(rel);
continue;
}
17 years, 3 months
r2678 jmb - /trunk/netsurf/content/fetch.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Jun 29 23:04:56 2006
New Revision: 2678
URL: http://svn.semichrome.net?rev=2678&view=rev
Log:
Fix crash when url_* fails
Modified:
trunk/netsurf/content/fetch.c
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=2678&r1=2677&...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Thu Jun 29 23:04:56 2006
@@ -315,24 +315,32 @@
return 0;
res = url_host(url, &host);
- /* we only fail memory exhaustion */
- if (res == URL_FUNC_NOMEM)
- goto failed;
- if (!host)
- host = strdup("");
- if (!host)
- goto failed;
-
- res = url_scheme(url, &ref1);
- /* we only fail memory exhaustion */
- if (res == URL_FUNC_NOMEM)
- goto failed;
-
- if (referer) {
- res = url_scheme(referer, &ref2);
+ if (res != URL_FUNC_OK) {
/* we only fail memory exhaustion */
if (res == URL_FUNC_NOMEM)
goto failed;
+
+ host = strdup("");
+ if (!host)
+ goto failed;
+ }
+
+ res = url_scheme(url, &ref1);
+ if (res != URL_FUNC_OK) {
+ /* we only fail memory exhaustion */
+ if (res == URL_FUNC_NOMEM)
+ goto failed;
+ ref1 = NULL;
+ }
+
+ if (referer) {
+ res = url_scheme(referer, &ref2);
+ if (res != URL_FUNC_OK) {
+ /* we only fail memory exhaustion */
+ if (res == URL_FUNC_NOMEM)
+ goto failed;
+ ref2 = NULL;
+ }
}
LOG(("fetch %p, url '%s'", fetch, url));
17 years, 3 months
r2677 jmb - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Jun 29 22:30:05 2006
New Revision: 2677
URL: http://svn.semichrome.net?rev=2677&view=rev
Log:
Handle transparent borders correctly when plotting
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://svn.semichrome.net/trunk/netsurf/render/html_redraw.c?rev=2677&r1=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Thu Jun 29 22:30:05 2006
@@ -756,6 +756,9 @@
unsigned int light = i;
colour c_lit;
+ if (c == TRANSPARENT)
+ return true;
+
switch (style) {
case CSS_BORDER_STYLE_DOTTED:
dotted = true;
@@ -947,9 +950,9 @@
if (!(plot.fill(x, y, x + width, y + height, WIDGET_BASEC) &&
plot.line(x, y, x + width, y, 1, dark, false, false) &&
plot.line(x, y, x, y + height, 1, dark, false, false) &&
- plot.line(x + width, y, x + width, y + height, 1, lite,
+ plot.line(x + width, y, x + width, y + height, 1, lite,
false, false) &&
- plot.line(x, y + height, x + width, y + height, 1, lite,
+ plot.line(x, y + height, x + width, y + height, 1, lite,
false, false)))
return false;
@@ -962,12 +965,12 @@
return false;
} else {
/* render a tick, as it'll fit comfortably */
- if (!(plot.line(x + width - z,
+ if (!(plot.line(x + width - z,
y + z,
x + (z * 3),
y + height - z,
2, WIDGET_BLOBC, false, false) &&
-
+
plot.line(x + (z * 3),
y + height - z,
x + z + z,
@@ -995,7 +998,7 @@
{
int dark = html_redraw_darker(html_redraw_darker(WIDGET_BASEC));
int lite = html_redraw_lighter(html_redraw_lighter(WIDGET_BASEC));
-
+
/* plot background of radio button */
if (!plot.disc(x + width * 0.5, y + height * 0.5,
width * 0.5 - 1, WIDGET_BASEC, true))
@@ -1005,7 +1008,7 @@
if (!plot.arc(x + width * 0.5, y + height * 0.5,
width * 0.5 - 1, 45, 225, dark))
return false;
-
+
/* plot light arc */
if (!plot.arc(x + width * 0.5, y + height * 0.5,
width * 0.5 - 1, 225, 45, lite))
17 years, 3 months
r2676 jmb - /trunk/netsurf/render/html.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Jun 29 22:29:21 2006
New Revision: 2676
URL: http://svn.semichrome.net?rev=2676&view=rev
Log:
Link rel attribute may be a space separated list, take account of this
when looking for stylesheets.
Modified:
trunk/netsurf/render/html.c
Modified: trunk/netsurf/render/html.c
URL: http://svn.semichrome.net/trunk/netsurf/render/html.c?rev=2676&r1=2675&r2...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Thu Jun 29 22:29:21 2006
@@ -590,10 +590,10 @@
continue;
if (strcmp(node->name, "link") == 0) {
- /* rel='stylesheet' */
+ /* rel=<space separated list, including 'stylesheet'> */
if ((rel = (char *) xmlGetProp(node, (const xmlChar *) "rel")) == NULL)
continue;
- if (strcasecmp(rel, "stylesheet") != 0) {
+ if (strstr(rel, "stylesheet") == 0) {
xmlFree(rel);
continue;
}
17 years, 3 months
r2675 jmb - /trunk/netsurf/render/html.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Jun 29 20:55:08 2006
New Revision: 2675
URL: http://svn.semichrome.net?rev=2675&view=rev
Log:
Fix clipping of page background if body shorter than window height
Modified:
trunk/netsurf/render/html.c
Modified: trunk/netsurf/render/html.c
URL: http://svn.semichrome.net/trunk/netsurf/render/html.c?rev=2675&r1=2674&r2...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Thu Jun 29 20:55:08 2006
@@ -1050,7 +1050,8 @@
c->status ==
CONTENT_STATUS_DONE)
content_reformat(c,
- c->available_width, 0);
+ c->available_width,
+ c->height);
}
break;
@@ -1169,7 +1170,7 @@
msg == CONTENT_MSG_REDIRECT ||
msg == CONTENT_MSG_AUTH)) {
/* all objects have arrived */
- content_reformat(c, c->available_width, 0);
+ content_reformat(c, c->available_width, c->height);
c->status = CONTENT_STATUS_DONE;
content_set_status(c, messages_get("Done"));
content_broadcast(c, CONTENT_MSG_DONE, data);
@@ -1376,11 +1377,11 @@
struct box *doc;
layout_document(c, width, height);
doc = c->data.html.layout;
-
- c->width = doc->descendant_x1 +
+
+ c->width = doc->descendant_x1 +
doc->margin[LEFT] + doc->margin[RIGHT];
-
- c->height = doc->descendant_y1 +
+
+ c->height = doc->descendant_y1 +
doc->margin[TOP] + doc->margin[BOTTOM];
}
17 years, 3 months
r2674 jmb - /trunk/netsurftest/absolute-padding.html
by netsurf@semichrome.net
Author: jmb
Date: Thu Jun 29 16:56:38 2006
New Revision: 2674
URL: http://svn.semichrome.net?rev=2674&view=rev
Log:
Testcase for padding on block-level containing block for absolutely
positioned boxes
Added:
trunk/netsurftest/absolute-padding.html
Added: trunk/netsurftest/absolute-padding.html
URL: http://svn.semichrome.net/trunk/netsurftest/absolute-padding.html?rev=267...
==============================================================================
--- trunk/netsurftest/absolute-padding.html (added)
+++ trunk/netsurftest/absolute-padding.html Thu Jun 29 16:56:38 2006
@@ -1,0 +1,88 @@
+<html>
+<head>
+<style type="text/css">
+#container {
+ padding: 50px 50px 50px 50px;
+ position: absolute;
+ border: 1px solid black;
+ top: 0;
+ left: 0;
+ }
+
+#content {
+ width: 100%;
+ height: 100%;
+ background-color: #d345d6;
+}
+
+#tl {
+ position: absolute;
+ top: 0;
+ left: 0;
+ background-color: red;
+ width: 50px;
+}
+
+#tr {
+ position: absolute;
+ top: 0;
+ right: 0;
+ background-color: yellow;
+ width: 50px;
+}
+
+#bl {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ background-color: green;
+ width: 50px;
+}
+
+#br {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ background-color: blue;
+ width: 50px;
+}
+
+#c {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ background-color: orange;
+ width: 50px;
+}
+</style></head>
+
+<body>
+
+<div id="container">
+<div id="content">
+ Content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+ content content content content content content content
+</div>
+<div id="tl">tl</div>
+<div id="tr">tr</div>
+<div id="bl">bl</div>
+<div id="br">br</div>
+<div id="c">c</div>
+
+</body></html>
17 years, 3 months
r2673 jmb - /trunk/netsurf/render/layout.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Jun 29 16:53:17 2006
New Revision: 2673
URL: http://svn.semichrome.net?rev=2673&view=rev
Log:
Properly take account of padding on containing block.
Modified:
trunk/netsurf/render/layout.c
Modified: trunk/netsurf/render/layout.c
URL: http://svn.semichrome.net/trunk/netsurf/render/layout.c?rev=2673&r1=2672&...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Thu Jun 29 16:53:17 2006
@@ -2486,9 +2486,24 @@
assert(box->type == BOX_BLOCK || box->type == BOX_TABLE);
+ if (containing_block->type == BOX_BLOCK ||
+ containing_block->type == BOX_INLINE_BLOCK ||
+ containing_block->type == BOX_TABLE_CELL) {
+ /* Block level container => temporarily increase containing
+ * block dimensions to include padding (we restore this
+ * again at the end) */
+ containing_block->width += containing_block->padding[LEFT] +
+ containing_block->padding[RIGHT];
+ containing_block->height += containing_block->padding[TOP] +
+ containing_block->padding[BOTTOM];
+ } else {
+ /** \todo inline containers */
+ }
+
layout_compute_offsets(box, containing_block,
&top, &right, &bottom, &left);
- layout_find_dimensions(containing_block->width, box->style,
+
+ layout_find_dimensions(available_width, box->style,
&width, &height, margin, padding, border);
/* 10.3.7 */
@@ -2616,10 +2631,9 @@
if (containing_block->type == BOX_BLOCK ||
containing_block->type == BOX_INLINE_BLOCK ||
containing_block->type == BOX_TABLE_CELL) {
- /* Block-level ancestor => compensate for ancestor's
- * l,r padding */
- box->x += containing_block->padding[RIGHT] -
- containing_block->padding[LEFT];
+ /* Block-level ancestor => reset container's width */
+ containing_block->width -= containing_block->padding[LEFT] +
+ containing_block->padding[RIGHT];
} else {
/** \todo inline ancestors */
}
@@ -2739,10 +2753,9 @@
if (containing_block->type == BOX_BLOCK ||
containing_block->type == BOX_INLINE_BLOCK ||
containing_block->type == BOX_TABLE_CELL) {
- /* Block-level ancestor => compensate for ancestor's
- * t,b padding */
- box->y += containing_block->padding[BOTTOM] -
- containing_block->padding[TOP];
+ /* Block-level ancestor => reset container's height */
+ containing_block->height -= containing_block->padding[TOP] +
+ containing_block->padding[BOTTOM];
} else {
/** \todo Inline ancestors */
}
17 years, 3 months
r2672 jmb - /trunk/netsurf/render/layout.c
by netsurf@semichrome.net
Author: jmb
Date: Thu Jun 29 12:55:21 2006
New Revision: 2672
URL: http://svn.semichrome.net?rev=2672&view=rev
Log:
Position specifiers are relative to containing block's padding edge for
absolutely positioned boxes. Compensate for this.
Modified:
trunk/netsurf/render/layout.c
Modified: trunk/netsurf/render/layout.c
URL: http://svn.semichrome.net/trunk/netsurf/render/layout.c?rev=2672&r1=2671&...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Thu Jun 29 12:55:21 2006
@@ -2613,6 +2613,16 @@
containing_block->width));
box->x = left + margin[LEFT] + border[LEFT];
+ if (containing_block->type == BOX_BLOCK ||
+ containing_block->type == BOX_INLINE_BLOCK ||
+ containing_block->type == BOX_TABLE_CELL) {
+ /* Block-level ancestor => compensate for ancestor's
+ * l,r padding */
+ box->x += containing_block->padding[RIGHT] -
+ containing_block->padding[LEFT];
+ } else {
+ /** \todo inline ancestors */
+ }
box->width = width;
box->height = height;
@@ -2726,6 +2736,16 @@
containing_block->height));
box->y = top + margin[TOP] + border[TOP];
+ if (containing_block->type == BOX_BLOCK ||
+ containing_block->type == BOX_INLINE_BLOCK ||
+ containing_block->type == BOX_TABLE_CELL) {
+ /* Block-level ancestor => compensate for ancestor's
+ * t,b padding */
+ box->y += containing_block->padding[BOTTOM] -
+ containing_block->padding[TOP];
+ } else {
+ /** \todo Inline ancestors */
+ }
box->height = height;
return true;
17 years, 3 months