r3861 bursa - in /trunk/libsvgtiny: colors.gperf makefile svgtiny.c svgtiny.h svgtiny_gradient.c svgtiny_internal.h svgtiny_test.c
by netsurf@semichrome.net
Author: bursa
Date: Mon Feb 18 20:47:03 2008
New Revision: 3861
URL: http://source.netsurf-browser.org?rev=3861&view=rev
Log:
Linear gradients, part 1.
Added:
trunk/libsvgtiny/svgtiny_gradient.c
trunk/libsvgtiny/svgtiny_internal.h
Modified:
trunk/libsvgtiny/colors.gperf
trunk/libsvgtiny/makefile
trunk/libsvgtiny/svgtiny.c
trunk/libsvgtiny/svgtiny.h
trunk/libsvgtiny/svgtiny_test.c
Modified: trunk/libsvgtiny/colors.gperf
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/colors.gperf?rev=3861&...
==============================================================================
--- trunk/libsvgtiny/colors.gperf (original)
+++ trunk/libsvgtiny/colors.gperf Mon Feb 18 20:47:03 2008
@@ -15,6 +15,7 @@
%{
#include <string.h>
#include "svgtiny.h"
+#include "svgtiny_internal.h"
%}
struct svgtiny_named_color;
Modified: trunk/libsvgtiny/makefile
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/makefile?rev=3861&r1=3...
==============================================================================
--- trunk/libsvgtiny/makefile (original)
+++ trunk/libsvgtiny/makefile Mon Feb 18 20:47:03 2008
@@ -5,8 +5,8 @@
# Copyright 2008 James Bursa <james(a)semichrome.net>
#
-SOURCE = svgtiny.c colors.c
-HDRS = svgtiny.h
+SOURCE = svgtiny.c svgtiny_gradient.c colors.c
+HDRS = svgtiny.h svgtiny_internal.h
CFLAGS = -std=c99 -W -Wall -Wundef -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
@@ -68,7 +68,7 @@
install: $(LIBDIR)/libsvgtiny.a
$(INSTALL) -t $(PREFIX)/lib $(LIBDIR)/libsvgtiny.a
- $(INSTALL) -t $(PREFIX)/include $(HDRS)
+ $(INSTALL) -t $(PREFIX)/include svgtiny.h
clean:
-rm $(OBJS) $(LIBDIR)/libsvgtiny.a $(BINDIR)/svgtiny_test$(EXEEXT) colors.c
Modified: trunk/libsvgtiny/svgtiny.c
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/svgtiny.c?rev=3861&r1=...
==============================================================================
--- trunk/libsvgtiny/svgtiny.c (original)
+++ trunk/libsvgtiny/svgtiny.c Mon Feb 18 20:47:03 2008
@@ -16,38 +16,23 @@
#include <libxml/parser.h>
#include <libxml/debugXML.h>
#include "svgtiny.h"
-
-
-struct svgtiny_parse_state {
- struct svgtiny_diagram *diagram;
- xmlDoc *document;
-
- float viewport_width;
- float viewport_height;
-
- /* current transformation matrix */
- struct {
- float a, b, c, d, e, f;
- } ctm;
-
- /*struct css_style style;*/
-
- /* paint attributes */
- svgtiny_colour fill;
- svgtiny_colour stroke;
- int stroke_width;
-};
-
-
-static bool svgtiny_parse_svg(xmlNode *svg, struct svgtiny_parse_state state);
-static bool svgtiny_parse_path(xmlNode *path, struct svgtiny_parse_state state);
-static bool svgtiny_parse_rect(xmlNode *rect, struct svgtiny_parse_state state);
-static bool svgtiny_parse_circle(xmlNode *circle,
+#include "svgtiny_internal.h"
+
+
+static svgtiny_code svgtiny_parse_svg(xmlNode *svg,
struct svgtiny_parse_state state);
-static bool svgtiny_parse_line(xmlNode *line, struct svgtiny_parse_state state);
-static bool svgtiny_parse_poly(xmlNode *poly, struct svgtiny_parse_state state,
- bool polygon);
-static bool svgtiny_parse_text(xmlNode *text, struct svgtiny_parse_state state);
+static svgtiny_code svgtiny_parse_path(xmlNode *path,
+ struct svgtiny_parse_state state);
+static svgtiny_code svgtiny_parse_rect(xmlNode *rect,
+ struct svgtiny_parse_state state);
+static svgtiny_code svgtiny_parse_circle(xmlNode *circle,
+ struct svgtiny_parse_state state);
+static svgtiny_code svgtiny_parse_line(xmlNode *line,
+ struct svgtiny_parse_state state);
+static svgtiny_code svgtiny_parse_poly(xmlNode *poly,
+ struct svgtiny_parse_state state, bool polygon);
+static svgtiny_code svgtiny_parse_text(xmlNode *text,
+ struct svgtiny_parse_state state);
static void svgtiny_parse_position_attributes(const xmlNode *node,
const struct svgtiny_parse_state state,
float *x, float *y, float *width, float *height);
@@ -55,17 +40,17 @@
const struct svgtiny_parse_state state);
static void svgtiny_parse_paint_attributes(const xmlNode *node,
struct svgtiny_parse_state *state);
-static void svgtiny_parse_color(const char *s, svgtiny_colour *c,
- struct svgtiny_parse_state *state);
static void svgtiny_parse_font_attributes(const xmlNode *node,
struct svgtiny_parse_state *state);
static void svgtiny_parse_transform_attributes(xmlNode *node,
struct svgtiny_parse_state *state);
-static struct svgtiny_shape *svgtiny_add_shape(
+static svgtiny_code svgtiny_add_path(float *p, unsigned int n,
struct svgtiny_parse_state *state);
-static void svgtiny_transform_path(float *p, unsigned int n,
- struct svgtiny_parse_state *state);
-
+
+
+/**
+ * Create a new svgtiny_diagram structure.
+ */
struct svgtiny_diagram *svgtiny_create(void)
{
@@ -77,10 +62,16 @@
diagram->shape = 0;
diagram->shape_count = 0;
+ diagram->error_line = 0;
+ diagram->error_message = 0;
return diagram;
}
+
+/**
+ * Parse a block of memory into a svgtiny_diagram.
+ */
svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram,
const char *buffer, size_t size, const char *url,
@@ -89,6 +80,8 @@
xmlDoc *document;
xmlNode *svg;
struct svgtiny_parse_state state;
+ float x, y, width, height;
+ svgtiny_code code;
assert(diagram);
assert(buffer);
@@ -96,8 +89,7 @@
/* parse XML to tree */
document = xmlReadMemory(buffer, size, url, 0,
- XML_PARSE_NONET | XML_PARSE_COMPACT |
- XML_PARSE_DTDVALID /* needed for xmlGetID to work */);
+ XML_PARSE_NONET | XML_PARSE_COMPACT);
if (!document)
return svgtiny_LIBXML_ERROR;
@@ -111,7 +103,6 @@
return svgtiny_NOT_SVG;
/* get graphic dimensions */
- float x, y, width, height;
state.diagram = diagram;
state.document = document;
state.viewport_width = viewport_width;
@@ -120,6 +111,7 @@
diagram->width = width;
diagram->height = height;
+ /* set up parsing state */
state.viewport_width = width;
state.viewport_height = height;
state.ctm.a = 1; /*(float) viewport_width / (float) width;*/
@@ -133,12 +125,15 @@
state.fill = 0x000000;
state.stroke = svgtiny_TRANSPARENT;
state.stroke_width = 1;
-
- svgtiny_parse_svg(svg, state);
-
+ state.linear_gradient_stop_count = 0;
+
+ /* parse tree */
+ code = svgtiny_parse_svg(svg, state);
+
+ /* free XML tree */
xmlFreeDoc(document);
- return svgtiny_OK;
+ return code;
}
@@ -146,7 +141,8 @@
* Parse a <svg> or <g> element node.
*/
-bool svgtiny_parse_svg(xmlNode *svg, struct svgtiny_parse_state state)
+svgtiny_code svgtiny_parse_svg(xmlNode *svg,
+ struct svgtiny_parse_state state)
{
float x, y, width, height;
@@ -173,38 +169,39 @@
svgtiny_parse_transform_attributes(svg, &state);
for (xmlNode *child = svg->children; child; child = child->next) {
- bool ok = true;
+ svgtiny_code code = svgtiny_OK;
if (child->type == XML_ELEMENT_NODE) {
const char *name = (const char *) child->name;
if (strcmp(name, "svg") == 0)
- ok = svgtiny_parse_svg(child, state);
+ code = svgtiny_parse_svg(child, state);
else if (strcmp(name, "g") == 0)
- ok = svgtiny_parse_svg(child, state);
+ code = svgtiny_parse_svg(child, state);
else if (strcmp(name, "a") == 0)
- ok = svgtiny_parse_svg(child, state);
+ code = svgtiny_parse_svg(child, state);
else if (strcmp(name, "path") == 0)
- ok = svgtiny_parse_path(child, state);
+ code = svgtiny_parse_path(child, state);
else if (strcmp(name, "rect") == 0)
- ok = svgtiny_parse_rect(child, state);
+ code = svgtiny_parse_rect(child, state);
else if (strcmp(name, "circle") == 0)
- ok = svgtiny_parse_circle(child, state);
+ code = svgtiny_parse_circle(child, state);
else if (strcmp(name, "line") == 0)
- ok = svgtiny_parse_line(child, state);
+ code = svgtiny_parse_line(child, state);
else if (strcmp(name, "polyline") == 0)
- ok = svgtiny_parse_poly(child, state, false);
+ code = svgtiny_parse_poly(child, state, false);
else if (strcmp(name, "polygon") == 0)
- ok = svgtiny_parse_poly(child, state, true);
+ code = svgtiny_parse_poly(child, state, true);
else if (strcmp(name, "text") == 0)
- ok = svgtiny_parse_text(child, state);
+ code = svgtiny_parse_text(child, state);
}
- if (!ok)
- return false;
- }
-
- return true;
-}
+ if (code != svgtiny_OK)
+ return code;
+ }
+
+ return svgtiny_OK;
+}
+
/**
@@ -213,7 +210,8 @@
* http://www.w3.org/TR/SVG11/paths#PathElement
*/
-bool svgtiny_parse_path(xmlNode *path, struct svgtiny_parse_state state)
+svgtiny_code svgtiny_parse_path(xmlNode *path,
+ struct svgtiny_parse_state state)
{
char *s, *path_d;
@@ -223,16 +221,15 @@
/* read d attribute */
s = path_d = (char *) xmlGetProp(path, (const xmlChar *) "d");
if (!s) {
- /*LOG(("path missing d attribute"));*/
- return false;
+ state.diagram->error_line = path->line;
+ state.diagram->error_message = "path: missing d attribute";
+ return svgtiny_SVG_ERROR;
}
/* allocate space for path: it will never have more elements than d */
float *p = malloc(sizeof p[0] * strlen(s));
- if (!p) {
- /*LOG(("out of memory"));*/
- return false;
- }
+ if (!p)
+ return svgtiny_OUT_OF_MEMORY;
/* parse d and build path */
for (unsigned int i = 0; s[i]; i++)
@@ -408,18 +405,7 @@
xmlFree(path_d);
- svgtiny_transform_path(p, i, &state);
-
- struct svgtiny_shape *shape = svgtiny_add_shape(&state);
- if (!shape) {
- free(p);
- return false;
- }
- shape->path = p;
- shape->path_length = i;
- state.diagram->shape_count++;
-
- return true;
+ return svgtiny_add_path(p, i, &state);
}
@@ -429,7 +415,8 @@
* http://www.w3.org/TR/SVG11/shapes#RectElement
*/
-bool svgtiny_parse_rect(xmlNode *rect, struct svgtiny_parse_state state)
+svgtiny_code svgtiny_parse_rect(xmlNode *rect,
+ struct svgtiny_parse_state state)
{
float x, y, width, height;
@@ -440,7 +427,7 @@
float *p = malloc(13 * sizeof p[0]);
if (!p)
- return false;
+ return svgtiny_OUT_OF_MEMORY;
p[0] = svgtiny_PATH_MOVE;
p[1] = x;
@@ -456,18 +443,7 @@
p[11] = y + height;
p[12] = svgtiny_PATH_CLOSE;
- svgtiny_transform_path(p, 13, &state);
-
- struct svgtiny_shape *shape = svgtiny_add_shape(&state);
- if (!shape) {
- free(p);
- return false;
- }
- shape->path = p;
- shape->path_length = 13;
- state.diagram->shape_count++;
-
- return true;
+ return svgtiny_add_path(p, 13, &state);
}
@@ -475,7 +451,8 @@
* Parse a <circle> element node.
*/
-bool svgtiny_parse_circle(xmlNode *circle, struct svgtiny_parse_state state)
+svgtiny_code svgtiny_parse_circle(xmlNode *circle,
+ struct svgtiny_parse_state state)
{
float x = 0, y = 0, r = 0;
const float kappa = 0.5522847498;
@@ -498,7 +475,7 @@
float *p = malloc(32 * sizeof p[0]);
if (!p)
- return false;
+ return svgtiny_OUT_OF_MEMORY;
p[0] = svgtiny_PATH_MOVE;
p[1] = x - r;
@@ -533,18 +510,7 @@
p[30] = y;
p[31] = svgtiny_PATH_CLOSE;
- svgtiny_transform_path(p, 32, &state);
-
- struct svgtiny_shape *shape = svgtiny_add_shape(&state);
- if (!shape) {
- free(p);
- return false;
- }
- shape->path = p;
- shape->path_length = 32;
- state.diagram->shape_count++;
-
- return true;
+ return svgtiny_add_path(p, 32, &state);
}
@@ -552,7 +518,8 @@
* Parse a <line> element node.
*/
-bool svgtiny_parse_line(xmlNode *line, struct svgtiny_parse_state state)
+svgtiny_code svgtiny_parse_line(xmlNode *line,
+ struct svgtiny_parse_state state)
{
float x1 = 0, y1 = 0, x2 = 0, y2 = 0;
@@ -577,7 +544,7 @@
float *p = malloc(7 * sizeof p[0]);
if (!p)
- return false;
+ return svgtiny_OUT_OF_MEMORY;
p[0] = svgtiny_PATH_MOVE;
p[1] = x1;
@@ -587,18 +554,7 @@
p[5] = y2;
p[6] = svgtiny_PATH_CLOSE;
- svgtiny_transform_path(p, 7, &state);
-
- struct svgtiny_shape *shape = svgtiny_add_shape(&state);
- if (!shape) {
- free(p);
- return false;
- }
- shape->path = p;
- shape->path_length = 7;
- state.diagram->shape_count++;
-
- return true;
+ return svgtiny_add_path(p, 7, &state);
}
@@ -609,26 +565,28 @@
* http://www.w3.org/TR/SVG11/shapes#PolygonElement
*/
-bool svgtiny_parse_poly(xmlNode *poly, struct svgtiny_parse_state state,
- bool polygon)
+svgtiny_code svgtiny_parse_poly(xmlNode *poly,
+ struct svgtiny_parse_state state, bool polygon)
{
char *s, *points;
svgtiny_parse_paint_attributes(poly, &state);
svgtiny_parse_transform_attributes(poly, &state);
- /* read d attribute */
+ /* read points attribute */
s = points = (char *) xmlGetProp(poly, (const xmlChar *) "points");
if (!s) {
- /*LOG(("poly missing d attribute"));*/
- return false;
+ state.diagram->error_line = poly->line;
+ state.diagram->error_message =
+ "polyline/polygon: missing points attribute";
+ return svgtiny_SVG_ERROR;
}
/* allocate space for path: it will never have more elements than s */
float *p = malloc(sizeof p[0] * strlen(s));
if (!p) {
- /*LOG(("out of memory"));*/
- return false;
+ xmlFree(points);
+ return svgtiny_OUT_OF_MEMORY;
}
/* parse s and build path */
@@ -657,18 +615,7 @@
xmlFree(points);
- svgtiny_transform_path(p, i, &state);
-
- struct svgtiny_shape *shape = svgtiny_add_shape(&state);
- if (!shape) {
- free(p);
- return false;
- }
- shape->path = p;
- shape->path_length = i;
- state.diagram->shape_count++;
-
- return true;
+ return svgtiny_add_path(p, i, &state);
}
@@ -676,7 +623,8 @@
* Parse a <text> or <tspan> element node.
*/
-bool svgtiny_parse_text(xmlNode *text, struct svgtiny_parse_state state)
+svgtiny_code svgtiny_parse_text(xmlNode *text,
+ struct svgtiny_parse_state state)
{
float x, y, width, height;
@@ -694,12 +642,12 @@
style.font_size.value.length.value *= state.ctm.a;*/
for (xmlNode *child = text->children; child; child = child->next) {
- bool ok = true;
+ svgtiny_code code = svgtiny_OK;
if (child->type == XML_TEXT_NODE) {
struct svgtiny_shape *shape = svgtiny_add_shape(&state);
if (!shape)
- return false;
+ return svgtiny_OUT_OF_MEMORY;
shape->text = strdup((const char *) child->content);
shape->text_x = px;
shape->text_y = py;
@@ -708,14 +656,14 @@
} else if (child->type == XML_ELEMENT_NODE &&
strcmp((const char *) child->name,
"tspan") == 0) {
- ok = svgtiny_parse_text(child, state);
+ code = svgtiny_parse_text(child, state);
}
- if (!ok)
- return false;
- }
-
- return true;
+ if (!code != svgtiny_OK)
+ return code;
+ }
+
+ return svgtiny_OK;
}
@@ -850,7 +798,6 @@
float rf, gf, bf;
size_t len = strlen(s);
char *id = 0, *rparen;
- xmlAttr *id_attr;
if (len == 4 && s[0] == '#') {
if (sscanf(s + 1, "%1x%1x%1x", &r, &g, &b) == 3)
@@ -883,15 +830,16 @@
rparen = strchr(id, ')');
if (rparen)
*rparen = 0;
- id_attr = xmlGetID(state->document,
- (const xmlChar *) id);
- if (!id_attr) {
- fprintf(stderr, "id \"%s\" not found\n", id);
- free(id);
- return;
- }
- fprintf(stderr, "id \"%s\" at %p\n", id, id_attr);
+ svgtiny_find_gradient(id, state);
free(id);
+ fprintf(stderr, "linear_gradient_stop_count %i\n",
+ state->linear_gradient_stop_count);
+ if (state->linear_gradient_stop_count == 0)
+ *c = svgtiny_TRANSPARENT;
+ else if (state->linear_gradient_stop_count == 1)
+ *c = state->gradient_stop[0].color;
+ else
+ *c = svgtiny_LINEAR_GRADIENT;
}
} else {
@@ -1015,6 +963,31 @@
/**
+ * Add a path to the svgtiny_diagram.
+ */
+
+svgtiny_code svgtiny_add_path(float *p, unsigned int n,
+ struct svgtiny_parse_state *state)
+{
+ if (state->fill == svgtiny_LINEAR_GRADIENT)
+ return svgtiny_add_path_linear_gradient(p, n, state);
+
+ svgtiny_transform_path(p, n, state);
+
+ struct svgtiny_shape *shape = svgtiny_add_shape(state);
+ if (!shape) {
+ free(p);
+ return svgtiny_OUT_OF_MEMORY;
+ }
+ shape->path = p;
+ shape->path_length = n;
+ state->diagram->shape_count++;
+
+ return svgtiny_OK;
+}
+
+
+/**
* Add a svgtiny_shape to the svgtiny_diagram.
*/
@@ -1033,12 +1006,16 @@
shape->text = 0;
shape->fill = state->fill;
shape->stroke = state->stroke;
- shape->stroke_width = state->stroke_width *
- (state->ctm.a + state->ctm.d) / 2;
+ shape->stroke_width = 1; /*state->stroke_width *
+ (state->ctm.a + state->ctm.d) / 2;*/
return shape;
}
+
+/**
+ * Apply the current transformation matrix to a path.
+ */
void svgtiny_transform_path(float *p, unsigned int n,
struct svgtiny_parse_state *state)
@@ -1074,6 +1051,10 @@
}
+/**
+ * Free all memory used by a diagram.
+ */
+
void svgtiny_free(struct svgtiny_diagram *svg)
{
assert(svg);
Modified: trunk/libsvgtiny/svgtiny.h
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/svgtiny.h?rev=3861&r1=...
==============================================================================
--- trunk/libsvgtiny/svgtiny.h (original)
+++ trunk/libsvgtiny/svgtiny.h Mon Feb 18 20:47:03 2008
@@ -14,8 +14,14 @@
#define svgtiny_TRANSPARENT 0x1000000
#ifdef riscos
#define svgtiny_RGB(r, g, b) ((b) << 16 | (g) << 8 | (r))
+#define svgtiny_RED(c) ((c) & 0xff)
+#define svgtiny_GREEN(c) (((c) >> 8) & 0xff)
+#define svgtiny_BLUE(c) (((c) >> 16) & 0xff)
#else
#define svgtiny_RGB(r, g, b) ((r) << 16 | (g) << 8 | (b))
+#define svgtiny_RED(c) (((c) >> 16) & 0xff)
+#define svgtiny_GREEN(c) (((c) >> 8) & 0xff)
+#define svgtiny_BLUE(c) ((c) & 0xff)
#endif
struct svgtiny_shape {
@@ -33,6 +39,9 @@
struct svgtiny_shape *shape;
unsigned int shape_count;
+
+ unsigned short error_line;
+ const char *error_message;
};
typedef enum {
@@ -40,6 +49,7 @@
svgtiny_OUT_OF_MEMORY,
svgtiny_LIBXML_ERROR,
svgtiny_NOT_SVG,
+ svgtiny_SVG_ERROR,
} svgtiny_code;
enum {
@@ -61,7 +71,4 @@
int width, int height);
void svgtiny_free(struct svgtiny_diagram *svg);
-const struct svgtiny_named_color *
-svgtiny_color_lookup (register const char *str, register unsigned int len);
-
#endif
Added: trunk/libsvgtiny/svgtiny_gradient.c
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/svgtiny_gradient.c?rev...
==============================================================================
--- trunk/libsvgtiny/svgtiny_gradient.c (added)
+++ trunk/libsvgtiny/svgtiny_gradient.c Mon Feb 18 20:47:03 2008
@@ -1,0 +1,517 @@
+/*
+ * This file is part of Libsvgtiny
+ * Licensed under the MIT License,
+ * http://opensource.org/licenses/mit-license.php
+ * Copyright 2008 James Bursa <james(a)semichrome.net>
+ */
+
+#define _GNU_SOURCE /* for strndup */
+#include <assert.h>
+#include <string.h>
+#include "svgtiny.h"
+#include "svgtiny_internal.h"
+
+#define GRADIENT_DEBUG
+
+static svgtiny_code svgtiny_parse_linear_gradient(xmlNode *linear,
+ struct svgtiny_parse_state *state);
+static float svgtiny_parse_gradient_offset(const char *s);
+static void svgtiny_path_bbox(float *p, unsigned int n,
+ float *x0, float *y0, float *x1, float *y1);
+
+
+/**
+ * Find a gradient by id and parse it.
+ */
+
+void svgtiny_find_gradient(const char *id, struct svgtiny_parse_state *state)
+{
+ fprintf(stderr, "svgtiny_find_gradient: id \"%s\"\n", id);
+
+ state->linear_gradient_stop_count = 0;
+
+ xmlNode *gradient = svgtiny_find_element_by_id(
+ (xmlNode *) state->document, id);
+ fprintf(stderr, "gradient %p\n", gradient);
+ if (!gradient) {
+ fprintf(stderr, "gradient \"%s\" not found\n", id);
+ return;
+ }
+
+ fprintf(stderr, "gradient name \"%s\"\n", gradient->name);
+ if (strcmp((const char *) gradient->name, "linearGradient") == 0) {
+ svgtiny_parse_linear_gradient(gradient, state);
+ }
+}
+
+
+/**
+ * Parse a <linearGradient> element node.
+ *
+ * http://www.w3.org/TR/SVG11/pservers#LinearGradients
+ */
+
+svgtiny_code svgtiny_parse_linear_gradient(xmlNode *linear,
+ struct svgtiny_parse_state *state)
+{
+ xmlAttr *href = xmlHasProp(linear, (const xmlChar *) "href");
+ if (href && href->children->content[0] == '#')
+ svgtiny_find_gradient((const char *) href->children->content
+ + 1, state);
+
+ unsigned int i = 0;
+ for (xmlNode *stop = linear->children; stop; stop = stop->next) {
+ float offset = -1;
+ svgtiny_colour color = svgtiny_TRANSPARENT;
+
+ if (stop->type != XML_ELEMENT_NODE)
+ continue;
+ if (strcmp((const char *) stop->name, "stop") != 0)
+ continue;
+
+ for (xmlAttr *attr = stop->properties; attr;
+ attr = attr->next) {
+ const char *name = (const char *) attr->name;
+ const char *content =
+ (const char *) attr->children->content;
+ if (strcmp(name, "offset") == 0)
+ offset = svgtiny_parse_gradient_offset(content);
+ else if (strcmp(name, "stop-color") == 0)
+ svgtiny_parse_color(content, &color, state);
+ else if (strcmp(name, "style") == 0) {
+ const char *s;
+ char *value;
+ if ((s = strstr(content, "stop-color:"))) {
+ s += 11;
+ while (*s == ' ')
+ s++;
+ value = strndup(s, strcspn(s, "; "));
+ svgtiny_parse_color(value, &color,
+ state);
+ free(value);
+ }
+ }
+ }
+
+ if (offset != -1 && color != svgtiny_TRANSPARENT) {
+ fprintf(stderr, "stop %g %x\n", offset, color);
+ state->gradient_stop[i].offset = offset;
+ state->gradient_stop[i].color = color;
+ i++;
+ }
+
+ if (i == svgtiny_MAX_STOPS)
+ break;
+ }
+
+ if (i)
+ state->linear_gradient_stop_count = i;
+
+ return svgtiny_OK;
+}
+
+
+float svgtiny_parse_gradient_offset(const char *s)
+{
+ int num_length = strspn(s, "0123456789+-.");
+ const char *unit = s + num_length;
+ float n = atof((const char *) s);
+
+ if (unit[0] == 0)
+ ;
+ else if (unit[0] == '%')
+ n /= 100.0;
+ else
+ return -1;
+
+ if (n < 0)
+ n = 0;
+ if (1 < n)
+ n = 1;
+ return n;
+}
+
+
+/**
+ * Add a path with a linear gradient fill to the svgtiny_diagram.
+ */
+
+svgtiny_code svgtiny_add_path_linear_gradient(float *p, unsigned int n,
+ struct svgtiny_parse_state *state)
+{
+ /* determine object bounding box */
+ float object_x0, object_y0, object_x1, object_y1;
+ svgtiny_path_bbox(p, n, &object_x0, &object_y0, &object_x1, &object_y1);
+ #ifdef GRADIENT_DEBUG
+ fprintf(stderr, "object bbox: (%g %g) (%g %g)\n",
+ object_x0, object_y0, object_x1, object_y1);
+ #endif
+
+ /* compute gradient vector */
+ float gradient_x0 = 0, gradient_y0 = 0,
+ gradient_x1 = 1, gradient_y1 = 0.7,
+ 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_dx = gradient_x1 - gradient_x0;
+ gradient_dy = gradient_y1 - gradient_y0;
+ #ifdef GRADIENT_DEBUG
+ fprintf(stderr, "gradient vector: (%g %g) => (%g %g)\n",
+ gradient_x0, gradient_y0, gradient_x1, gradient_y1);
+ #endif
+
+ /* show theoretical gradient strips for debugging */
+ /*unsigned int strips = 10;
+ for (unsigned int z = 0; z != strips; z++) {
+ float f0, fd, strip_x0, strip_y0, strip_dx, strip_dy;
+ f0 = (float) z / (float) strips;
+ fd = (float) 1 / (float) strips;
+ strip_x0 = gradient_x0 + f0 * gradient_dx;
+ strip_y0 = gradient_y0 + f0 * gradient_dy;
+ strip_dx = fd * gradient_dx;
+ strip_dy = fd * gradient_dy;
+ fprintf(stderr, "strip %i vector: (%g %g) + (%g %g)\n",
+ z, strip_x0, strip_y0, strip_dx, strip_dy);
+
+ float *p = malloc(13 * sizeof p[0]);
+ if (!p)
+ return svgtiny_OUT_OF_MEMORY;
+ p[0] = svgtiny_PATH_MOVE;
+ p[1] = strip_x0 + (strip_dy * 3);
+ p[2] = strip_y0 - (strip_dx * 3);
+ p[3] = svgtiny_PATH_LINE;
+ p[4] = p[1] + strip_dx;
+ p[5] = p[2] + strip_dy;
+ p[6] = svgtiny_PATH_LINE;
+ p[7] = p[4] - (strip_dy * 6);
+ p[8] = p[5] + (strip_dx * 6);
+ p[9] = svgtiny_PATH_LINE;
+ p[10] = p[7] - strip_dx;
+ p[11] = p[8] - strip_dy;
+ p[12] = svgtiny_PATH_CLOSE;
+ svgtiny_transform_path(p, 13, state);
+ struct svgtiny_shape *shape = svgtiny_add_shape(state);
+ if (!shape) {
+ free(p);
+ return svgtiny_OUT_OF_MEMORY;
+ }
+ shape->path = p;
+ shape->path_length = 13;
+ shape->fill = svgtiny_TRANSPARENT;
+ shape->stroke = svgtiny_RGB(0, 0xff, 0);
+ state->diagram->shape_count++;
+ }*/
+
+ /* compute points on the path for triangle vertices */
+ unsigned int steps = 10;
+ float x0, y0, x1, y1;
+ float gradient_norm_squared = gradient_dx * gradient_dx +
+ gradient_dy * gradient_dy;
+ struct grad_point {
+ float x, y, r;
+ };
+ struct grad_point *pts = malloc(n * steps * sizeof pts[0]);
+ if (!pts)
+ return svgtiny_OUT_OF_MEMORY;
+ unsigned int pts_count = 0;
+ float min_r = 1000;
+ unsigned int min_pt = 0;
+ for (unsigned int j = 0; j != n; ) {
+ switch ((int) p[j]) {
+ case svgtiny_PATH_MOVE:
+ x0 = p[j + 1];
+ y0 = p[j + 2];
+ j += 3;
+ break;
+ case svgtiny_PATH_LINE:
+ case svgtiny_PATH_CLOSE:
+ if (((int) p[j]) == svgtiny_PATH_LINE) {
+ x1 = p[j + 1];
+ y1 = p[j + 2];
+ j += 3;
+ } else {
+ x1 = p[1];
+ y1 = p[2];
+ j++;
+ }
+ fprintf(stderr, "line: ");
+ for (unsigned int z = 0; z != steps; z++) {
+ float f, x, y, r;
+ f = (float) z / (float) steps;
+ x = x0 + f * (x1 - x0);
+ y = y0 + f * (y1 - y0);
+ r = ((x - gradient_x0) * gradient_dx +
+ (y - gradient_y0) * gradient_dy) /
+ gradient_norm_squared;
+ fprintf(stderr, "(%g %g [%g]) ", x, y, r);
+ pts[pts_count].x = x;
+ pts[pts_count].y = y;
+ pts[pts_count].r = r;
+ if (r < min_r) {
+ min_r = r;
+ min_pt = pts_count;
+ }
+ pts_count++;
+ }
+ fprintf(stderr, "\n");
+ x0 = x1;
+ y0 = y1;
+ break;
+ case svgtiny_PATH_BEZIER:
+ fprintf(stderr, "bezier: ");
+ for (unsigned int z = 0; z != steps; z++) {
+ float t, x, y, r;
+ t = (float) z / (float) steps;
+ x = (1-t) * (1-t) * (1-t) * x0 +
+ 3 * t * (1-t) * (1-t) * p[j + 1] +
+ 3 * t * t * (1-t) * p[j + 3] +
+ t * t * t * p[j + 5];
+ y = (1-t) * (1-t) * (1-t) * y0 +
+ 3 * t * (1-t) * (1-t) * p[j + 2] +
+ 3 * t * t * (1-t) * p[j + 4] +
+ t * t * t * p[j + 6];
+ r = ((x - gradient_x0) * gradient_dx +
+ (y - gradient_y0) * gradient_dy) /
+ gradient_norm_squared;
+ fprintf(stderr, "(%g %g [%g]) ", x, y, r);
+ pts[pts_count].x = x;
+ pts[pts_count].y = y;
+ pts[pts_count].r = r;
+ if (r < min_r) {
+ min_r = r;
+ min_pt = pts_count;
+ }
+ pts_count++;
+ }
+ fprintf(stderr, "\n");
+ x0 = p[j + 5];
+ y0 = p[j + 6];
+ j += 7;
+ break;
+ default:
+ assert(0);
+ }
+ }
+ fprintf(stderr, "pts_count %i, min_pt %i, min_r %.3f\n",
+ pts_count, min_pt, min_r);
+
+ unsigned int stop_count = state->linear_gradient_stop_count;
+ assert(2 <= stop_count);
+ unsigned int current_stop = 0;
+ float last_stop_r = 0;
+ float current_stop_r = state->gradient_stop[0].offset;
+ int red0, green0, blue0, red1, green1, blue1;
+ red0 = red1 = svgtiny_RED(state->gradient_stop[0].color);
+ green0 = green1 = svgtiny_GREEN(state->gradient_stop[0].color);
+ blue0 = blue1 = svgtiny_BLUE(state->gradient_stop[0].color);
+ unsigned int t, a, b;
+ t = min_pt;
+ a = (min_pt + 1) % pts_count;
+ 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 "
+ "mean_r %.3f\n",
+ t, pts[t].r, a, pts[a].r, b, pts[b].r,
+ mean_r);
+ while (current_stop != stop_count && current_stop_r < mean_r) {
+ current_stop++;
+ if (current_stop == stop_count)
+ break;
+ red0 = red1;
+ green0 = green1;
+ blue0 = blue1;
+ red1 = svgtiny_RED(state->
+ gradient_stop[current_stop].color);
+ green1 = svgtiny_GREEN(state->
+ gradient_stop[current_stop].color);
+ blue1 = svgtiny_BLUE(state->
+ gradient_stop[current_stop].color);
+ last_stop_r = current_stop_r;
+ current_stop_r = state->
+ gradient_stop[current_stop].offset;
+ }
+ float *p = malloc(10 * sizeof p[0]);
+ if (!p)
+ return svgtiny_OUT_OF_MEMORY;
+ p[0] = svgtiny_PATH_MOVE;
+ p[1] = pts[t].x;
+ p[2] = pts[t].y;
+ p[3] = svgtiny_PATH_LINE;
+ p[4] = pts[a].x;
+ p[5] = pts[a].y;
+ p[6] = svgtiny_PATH_LINE;
+ p[7] = pts[b].x;
+ p[8] = pts[b].y;
+ p[9] = svgtiny_PATH_CLOSE;
+ svgtiny_transform_path(p, 10, state);
+ struct svgtiny_shape *shape = svgtiny_add_shape(state);
+ if (!shape) {
+ free(p);
+ return svgtiny_OUT_OF_MEMORY;
+ }
+ shape->path = p;
+ shape->path_length = 10;
+ /*shape->fill = svgtiny_TRANSPARENT;*/
+ if (current_stop == 0)
+ shape->fill = state->gradient_stop[0].color;
+ else if (current_stop == stop_count)
+ shape->fill = state->
+ gradient_stop[stop_count - 1].color;
+ else {
+ float stop_r = (mean_r - last_stop_r) /
+ (current_stop_r - last_stop_r);
+ shape->fill = svgtiny_RGB(
+ (int) ((1 - stop_r) * red0 + stop_r * red1),
+ (int) ((1 - stop_r) * green0 + stop_r * green1),
+ (int) ((1 - stop_r) * blue0 + stop_r * blue1));
+ }
+ shape->stroke = svgtiny_TRANSPARENT;
+ #ifdef GRADIENT_DEBUG
+ shape->stroke = svgtiny_RGB(0, 0, 0xff);
+ #endif
+ state->diagram->shape_count++;
+ if (pts[a].r < pts[b].r) {
+ t = a;
+ a = (a + 1) % pts_count;
+ } else {
+ t = b;
+ b = b == 0 ? pts_count - 1 : b - 1;
+ }
+ }
+
+ /* render gradient vector for debugging */
+ #ifdef GRADIENT_DEBUG
+ {
+ float *p = malloc(7 * sizeof p[0]);
+ if (!p)
+ return svgtiny_OUT_OF_MEMORY;
+ p[0] = svgtiny_PATH_MOVE;
+ p[1] = gradient_x0;
+ p[2] = gradient_y0;
+ p[3] = svgtiny_PATH_LINE;
+ p[4] = gradient_x1;
+ p[5] = gradient_y1;
+ p[6] = svgtiny_PATH_CLOSE;
+ svgtiny_transform_path(p, 7, state);
+ struct svgtiny_shape *shape = svgtiny_add_shape(state);
+ if (!shape) {
+ free(p);
+ return svgtiny_OUT_OF_MEMORY;
+ }
+ shape->path = p;
+ shape->path_length = 7;
+ shape->fill = svgtiny_TRANSPARENT;
+ shape->stroke = svgtiny_RGB(0xff, 0, 0);
+ state->diagram->shape_count++;
+ }
+ #endif
+
+ /* render triangle vertices with r values for debugging */
+ #ifdef GRADIENT_DEBUG
+ for (unsigned int i = 0; i != pts_count; i++) {
+ struct svgtiny_shape *shape = svgtiny_add_shape(state);
+ if (!shape)
+ return svgtiny_OUT_OF_MEMORY;
+ char *text = malloc(20);
+ if (!text)
+ return svgtiny_OUT_OF_MEMORY;
+ sprintf(text, "%i=%.3f", i, pts[i].r);
+ shape->text = text;
+ shape->text_x = state->ctm.a * pts[i].x +
+ state->ctm.c * pts[i].y + state->ctm.e;
+ shape->text_y = state->ctm.b * pts[i].x +
+ state->ctm.d * pts[i].y + state->ctm.f;
+ shape->fill = svgtiny_RGB(0, 0, 0);
+ state->diagram->shape_count++;
+ }
+ #endif
+
+ /* plot actual path outline */
+ if (state->stroke != svgtiny_TRANSPARENT) {
+ svgtiny_transform_path(p, n, state);
+
+ struct svgtiny_shape *shape = svgtiny_add_shape(state);
+ if (!shape) {
+ free(p);
+ return svgtiny_OUT_OF_MEMORY;
+ }
+ shape->path = p;
+ shape->path_length = n;
+ shape->fill = svgtiny_TRANSPARENT;
+ state->diagram->shape_count++;
+ }
+
+ return svgtiny_OK;
+}
+
+
+/**
+ * Get the bounding box of path.
+ */
+
+void svgtiny_path_bbox(float *p, unsigned int n,
+ float *x0, float *y0, float *x1, float *y1)
+{
+ *x0 = *x1 = p[1];
+ *y0 = *y1 = p[2];
+
+ for (unsigned int j = 0; j != n; ) {
+ unsigned int points = 0;
+ switch ((int) p[j]) {
+ case svgtiny_PATH_MOVE:
+ case svgtiny_PATH_LINE:
+ points = 1;
+ break;
+ case svgtiny_PATH_CLOSE:
+ points = 0;
+ break;
+ case svgtiny_PATH_BEZIER:
+ points = 3;
+ break;
+ default:
+ assert(0);
+ }
+ j++;
+ for (unsigned int k = 0; k != points; k++) {
+ float x = p[j], y = p[j + 1];
+ if (x < *x0)
+ *x0 = x;
+ else if (*x1 < x)
+ *x1 = x;
+ if (y < *y0)
+ *y0 = y;
+ else if (*y1 < y)
+ *y1 = y;
+ j += 2;
+ }
+ }
+}
+
+
+/**
+ * Find an element in the document by id.
+ */
+
+xmlNode *svgtiny_find_element_by_id(xmlNode *node, const char *id)
+{
+ xmlNode *child;
+ xmlNode *found;
+
+ for (child = node->children; child; child = child->next) {
+ if (child->type != XML_ELEMENT_NODE)
+ continue;
+ xmlAttr *attr = xmlHasProp(child, (const xmlChar *) "id");
+ if (attr && strcmp(id, (const char *) attr->children->content)
+ == 0)
+ return child;
+ found = svgtiny_find_element_by_id(child, id);
+ if (found)
+ return found;
+ }
+
+ return 0;
+}
+
Added: trunk/libsvgtiny/svgtiny_internal.h
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/svgtiny_internal.h?rev...
==============================================================================
--- trunk/libsvgtiny/svgtiny_internal.h (added)
+++ trunk/libsvgtiny/svgtiny_internal.h Mon Feb 18 20:47:03 2008
@@ -1,0 +1,62 @@
+/*
+ * This file is part of Libsvgtiny
+ * Licensed under the MIT License,
+ * http://opensource.org/licenses/mit-license.php
+ * Copyright 2008 James Bursa <james(a)semichrome.net>
+ */
+
+#ifndef SVGTINY_INTERNAL_H
+#define SVGTINY_INTERNAL_H
+
+struct svgtiny_gradient_stop {
+ float offset;
+ svgtiny_colour color;
+};
+
+#define svgtiny_MAX_STOPS 10
+#define svgtiny_LINEAR_GRADIENT 0x2000000
+
+struct svgtiny_parse_state {
+ struct svgtiny_diagram *diagram;
+ xmlDoc *document;
+
+ float viewport_width;
+ float viewport_height;
+
+ /* current transformation matrix */
+ struct {
+ float a, b, c, d, e, f;
+ } ctm;
+
+ /*struct css_style style;*/
+
+ /* paint attributes */
+ svgtiny_colour fill;
+ svgtiny_colour stroke;
+ int stroke_width;
+
+ /* gradients */
+ unsigned int linear_gradient_stop_count;
+ 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);
+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);
+
+/* svgtiny_gradient.c */
+void svgtiny_find_gradient(const char *id, struct svgtiny_parse_state *state);
+svgtiny_code svgtiny_add_path_linear_gradient(float *p, unsigned int n,
+ struct svgtiny_parse_state *state);
+xmlNode *svgtiny_find_element_by_id(xmlNode *node, const char *id);
+
+/* colors.gperf */
+const struct svgtiny_named_color *
+ svgtiny_color_lookup(register const char *str,
+ register unsigned int len);
+
+#endif
Modified: trunk/libsvgtiny/svgtiny_test.c
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/svgtiny_test.c?rev=386...
==============================================================================
--- trunk/libsvgtiny/svgtiny_test.c (original)
+++ trunk/libsvgtiny/svgtiny_test.c Mon Feb 18 20:47:03 2008
@@ -64,8 +64,29 @@
/* parse */
code = svgtiny_parse(diagram, buffer, size, argv[1], 1000, 1000);
- if (code != svgtiny_OK)
- fprintf(stderr, "svgtiny_parse failed: %i\n", code);
+ if (code != svgtiny_OK) {
+ fprintf(stderr, "svgtiny_parse failed: ");
+ switch (code) {
+ case svgtiny_OUT_OF_MEMORY:
+ fprintf(stderr, "svgtiny_OUT_OF_MEMORY");
+ break;
+ case svgtiny_LIBXML_ERROR:
+ fprintf(stderr, "svgtiny_LIBXML_ERROR");
+ break;
+ case svgtiny_NOT_SVG:
+ fprintf(stderr, "svgtiny_NOT_SVG");
+ break;
+ case svgtiny_SVG_ERROR:
+ fprintf(stderr, "svgtiny_SVG_ERROR: line %i: %s",
+ diagram->error_line,
+ diagram->error_message);
+ break;
+ default:
+ fprintf(stderr, "unknown svgtiny_code %i", code);
+ break;
+ }
+ fprintf(stderr, "\n");
+ }
free(buffer);
15 years, 7 months
r3860 tlsa - in /trunk/netsurfweb: ./ about/ about/screenshots/ contact/ developers/ documentation/ downloads/ downloads/themes/ errors/ webmasters/ welcome/
by netsurf@semichrome.net
Author: tlsa
Date: Mon Feb 18 18:24:02 2008
New Revision: 3860
URL: http://source.netsurf-browser.org?rev=3860&view=rev
Log:
Remove body width restriction. Remove alternate stylesheet.
Removed:
trunk/netsurfweb/netsurfur.css
Modified:
trunk/netsurfweb/about/awards.en
trunk/netsurfweb/about/index.en
trunk/netsurfweb/about/licence.en
trunk/netsurfweb/about/news.en
trunk/netsurfweb/about/screenshots/index.en
trunk/netsurfweb/about/team.en
trunk/netsurfweb/contact/index.en
trunk/netsurfweb/developers/contribute.en
trunk/netsurfweb/developers/index.en
trunk/netsurfweb/developers/publicity.en
trunk/netsurfweb/documentation/develop.en
trunk/netsurfweb/documentation/guide.en
trunk/netsurfweb/documentation/index.en
trunk/netsurfweb/documentation/info.en
trunk/netsurfweb/documentation/nstheme.en
trunk/netsurfweb/documentation/progress.en
trunk/netsurfweb/documentation/robuild.en
trunk/netsurfweb/documentation/roinfo.en
trunk/netsurfweb/documentation/translations.en
trunk/netsurfweb/downloads/extras.en
trunk/netsurfweb/downloads/index.en
trunk/netsurfweb/downloads/packages.en
trunk/netsurfweb/downloads/source.en
trunk/netsurfweb/downloads/testbuilds.en
trunk/netsurfweb/downloads/themes/index.en
trunk/netsurfweb/errors/404.en
trunk/netsurfweb/index.en
trunk/netsurfweb/netsurf.css
trunk/netsurfweb/webmasters/index.en
trunk/netsurfweb/welcome/index.en
Modified: trunk/netsurfweb/about/awards.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/about/awards.en?rev=38...
==============================================================================
--- trunk/netsurfweb/about/awards.en (original)
+++ trunk/netsurfweb/about/awards.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Awards</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/about/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/about/index.en?rev=386...
==============================================================================
--- trunk/netsurfweb/about/index.en (original)
+++ trunk/netsurfweb/about/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | About NetSurf</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/about/licence.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/about/licence.en?rev=3...
==============================================================================
--- trunk/netsurfweb/about/licence.en (original)
+++ trunk/netsurfweb/about/licence.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Licence</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/about/news.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/about/news.en?rev=3860...
==============================================================================
--- trunk/netsurfweb/about/news.en (original)
+++ trunk/netsurfweb/about/news.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | News</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/about/screenshots/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/about/screenshots/inde...
==============================================================================
--- trunk/netsurfweb/about/screenshots/index.en (original)
+++ trunk/netsurfweb/about/screenshots/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Screenshot Gallery</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/about/team.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/about/team.en?rev=3860...
==============================================================================
--- trunk/netsurfweb/about/team.en (original)
+++ trunk/netsurfweb/about/team.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Development Team</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/contact/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/contact/index.en?rev=3...
==============================================================================
--- trunk/netsurfweb/contact/index.en (original)
+++ trunk/netsurfweb/contact/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Contacting the Developers</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/developers/contribute.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/developers/contribute....
==============================================================================
--- trunk/netsurfweb/developers/contribute.en (original)
+++ trunk/netsurfweb/developers/contribute.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Contribution Guide</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/developers/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/developers/index.en?re...
==============================================================================
--- trunk/netsurfweb/developers/index.en (original)
+++ trunk/netsurfweb/developers/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Developers and Contributors</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/developers/publicity.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/developers/publicity.e...
==============================================================================
--- trunk/netsurfweb/developers/publicity.en (original)
+++ trunk/netsurfweb/developers/publicity.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Publicity</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/develop.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/develop....
==============================================================================
--- trunk/netsurfweb/documentation/develop.en (original)
+++ trunk/netsurfweb/documentation/develop.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Developer Documentation</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/guide.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/guide.en...
==============================================================================
--- trunk/netsurfweb/documentation/guide.en (original)
+++ trunk/netsurfweb/documentation/guide.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | User Guide</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/index.en...
==============================================================================
--- trunk/netsurfweb/documentation/index.en (original)
+++ trunk/netsurfweb/documentation/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Documentation</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/info.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/info.en?...
==============================================================================
--- trunk/netsurfweb/documentation/info.en (original)
+++ trunk/netsurfweb/documentation/info.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | User Information</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/nstheme.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/nstheme....
==============================================================================
--- trunk/netsurfweb/documentation/nstheme.en (original)
+++ trunk/netsurfweb/documentation/nstheme.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | NSTheme Guide</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/progress.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/progress...
==============================================================================
--- trunk/netsurfweb/documentation/progress.en (original)
+++ trunk/netsurfweb/documentation/progress.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Development Progress</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/robuild.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/robuild....
==============================================================================
--- trunk/netsurfweb/documentation/robuild.en (original)
+++ trunk/netsurfweb/documentation/robuild.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Building on RISC OS</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/roinfo.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/roinfo.e...
==============================================================================
--- trunk/netsurfweb/documentation/roinfo.en (original)
+++ trunk/netsurfweb/documentation/roinfo.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | RISC OS User Information</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/documentation/translations.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/documentation/translat...
==============================================================================
--- trunk/netsurfweb/documentation/translations.en (original)
+++ trunk/netsurfweb/documentation/translations.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Producing Translations</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/downloads/extras.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/downloads/extras.en?re...
==============================================================================
--- trunk/netsurfweb/downloads/extras.en (original)
+++ trunk/netsurfweb/downloads/extras.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Extras</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/downloads/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/downloads/index.en?rev...
==============================================================================
--- trunk/netsurfweb/downloads/index.en (original)
+++ trunk/netsurfweb/downloads/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Downloads</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/downloads/packages.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/downloads/packages.en?...
==============================================================================
--- trunk/netsurfweb/downloads/packages.en (original)
+++ trunk/netsurfweb/downloads/packages.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Packages</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/downloads/source.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/downloads/source.en?re...
==============================================================================
--- trunk/netsurfweb/downloads/source.en (original)
+++ trunk/netsurfweb/downloads/source.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Source Code</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/downloads/testbuilds.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/downloads/testbuilds.e...
==============================================================================
--- trunk/netsurfweb/downloads/testbuilds.en (original)
+++ trunk/netsurfweb/downloads/testbuilds.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | RISC OS Development Builds</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/downloads/themes/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/downloads/themes/index...
==============================================================================
--- trunk/netsurfweb/downloads/themes/index.en (original)
+++ trunk/netsurfweb/downloads/themes/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Themes</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/errors/404.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/errors/404.en?rev=3860...
==============================================================================
--- trunk/netsurfweb/errors/404.en (original)
+++ trunk/netsurfweb/errors/404.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | 404 Error</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/index.en?rev=3860&r1=3...
==============================================================================
--- trunk/netsurfweb/index.en (original)
+++ trunk/netsurfweb/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf Web Browser</title>
<link rel="stylesheet" title="Standard" type="text/css" href="netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/netsurf.css
URL: http://source.netsurf-browser.org/trunk/netsurfweb/netsurf.css?rev=3860&r...
==============================================================================
--- trunk/netsurfweb/netsurf.css (original)
+++ trunk/netsurfweb/netsurf.css Mon Feb 18 18:24:02 2008
@@ -7,7 +7,6 @@
background-color: #fff;
font-family: sans-serif;
font-size: 94%;
- max-width: 80em;
margin: 0 auto;
position: relative; }
Removed: trunk/netsurfweb/netsurfur.css
URL: http://source.netsurf-browser.org/trunk/netsurfweb/netsurfur.css?rev=3859...
==============================================================================
--- trunk/netsurfweb/netsurfur.css (original)
+++ trunk/netsurfweb/netsurfur.css (removed)
@@ -1,5 +1,0 @@
-/* Unrestricted width */
-
-@import "netsurf.css";
-
-body { max-width: none; }
Modified: trunk/netsurfweb/webmasters/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/webmasters/index.en?re...
==============================================================================
--- trunk/netsurfweb/webmasters/index.en (original)
+++ trunk/netsurfweb/webmasters/index.en Mon Feb 18 18:24:02 2008
@@ -4,7 +4,6 @@
<head>
<title>NetSurf | Webmaster Area</title>
<link rel="stylesheet" title="Standard" type="text/css" href="/netsurf.css">
-<link rel="alternate stylesheet" title="Unrestricted width" type="text/css" href="/netsurfur.css">
</head>
<body>
Modified: trunk/netsurfweb/welcome/index.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/welcome/index.en?rev=3...
==============================================================================
--- trunk/netsurfweb/welcome/index.en (original)
+++ trunk/netsurfweb/welcome/index.en Mon Feb 18 18:24:02 2008
@@ -2,7 +2,7 @@
<html>
<head>
<title>Welcome to NetSurf</title>
-<style type="text/css">html,body{margin:0;padding:0;}body{color:#000;background:#fff;font-family:sans-serif;max-width:80em;margin:0 auto;}a:link{text-decoration:underline;color:#00f;}a:visited{text-decoration:underline;color:#60a;}a:hover{text-decoration:none;}a:active{text-decoration:underline;color:#f00;}.banner{margin:0;padding:0;background:#94adff;text-align:left;}.banner img{border:none;color:#000;height:86px;width:308px;display:block;}.onlycontent{margin:0 1em;}.nslinks{display:table;width:100%;margin:0;border-spacing:0;padding:0;background:#ccd8ff;font-size:94%;}.nslinks li{display:table-cell;text-align:center;padding:0.2em 0.3em 0.3em;vertical-align:middle;}.nslinks li+li{border-left:2px solid #b1c3ff;}.version{padding:0;margin:1.2em auto 0;width:90%;color:#444;font-size:160%;}.intro{width: 90%;margin:1em auto;color:#666;}.websearch{margin:1.5em auto;padding:1.2em 0.3em;background:#d8e2ff;border:2px solid #c5d3ff;width:80%;text-align:center;}input[type=text]{border:2px solid #b6c7ff;background:#f9faff;color:#000;margin:2px;}input[type=submit]{border:2px outset #cedaff;color:#000;background:#cedaff;margin:2px;}.links{display:table;width:80%;margin:0 auto 3em;font-size:94%;}.links ul{display:table-cell;padding-left:2.5em;}.links ul+ul{padding-left:1em;}.footer{font-style:italic;text-align:right;}.footer p{margin-top:1.5em;padding-top:0.4em;border-top:2px solid #94adff;}</style>
+<style type="text/css">html,body{margin:0;padding:0;}body{color:#000;background:#fff;font-family:sans-serif;margin:0 auto;}a:link{text-decoration:underline;color:#00f;}a:visited{text-decoration:underline;color:#60a;}a:hover{text-decoration:none;}a:active{text-decoration:underline;color:#f00;}.banner{margin:0;padding:0;background:#94adff;text-align:left;}.banner img{border:none;color:#000;height:86px;width:308px;display:block;}.onlycontent{margin:0 1em;}.nslinks{display:table;width:100%;margin:0;border-spacing:0;padding:0;background:#ccd8ff;font-size:94%;}.nslinks li{display:table-cell;text-align:center;padding:0.2em 0.3em 0.3em;vertical-align:middle;}.nslinks li+li{border-left:2px solid #b1c3ff;}.version{padding:0;margin:1.2em auto 0;width:90%;color:#444;font-size:160%;}.intro{width: 90%;margin:1em auto;color:#666;}.websearch{margin:1.5em auto;padding:1.2em 0.3em;background:#d8e2ff;border:2px solid #c5d3ff;width:80%;text-align:center;}input[type=text]{border:2px solid #b6c7ff;background:#f9faff;color:#000;margin:2px;}input[type=submit]{border:2px outset #cedaff;color:#000;background:#cedaff;margin:2px;}.links{display:table;width:80%;margin:0 auto 3em;font-size:94%;}.links ul{display:table-cell;padding-left:2.5em;}.links ul+ul{padding-left:1em;}.footer{font-style:italic;text-align:right;}.footer p{margin-top:1.5em;padding-top:0.4em;border-top:2px solid #94adff;}</style>
</head>
<body>
15 years, 7 months
r3859 tlsa - /trunk/netsurf/render/layout.c
by netsurf@semichrome.net
Author: tlsa
Date: Sun Feb 17 18:22:06 2008
New Revision: 3859
URL: http://source.netsurf-browser.org?rev=3859&view=rev
Log:
For form gadgets, specified percentage width is inclusive of margin, border and padding space.
Modified:
trunk/netsurf/render/layout.c
Modified: trunk/netsurf/render/layout.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/layout.c?rev=3859&...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Sun Feb 17 18:22:06 2008
@@ -66,7 +66,7 @@
static void layout_float_find_dimensions(int available_width,
struct css_style *style, struct box *box);
static void layout_find_dimensions(int available_width,
- struct css_style *style,
+ struct box *box, struct css_style *style,
int *width, int *height,
int margin[4], int padding[4], int border[4]);
static int layout_clear(struct box *fl, css_clear clear);
@@ -550,7 +550,7 @@
int *border = box->border;
struct css_style *style = box->style;
- layout_find_dimensions(available_width, style,
+ layout_find_dimensions(available_width, box, style,
&width, &height, margin, padding, border);
if (box->object && box->object->type != CONTENT_HTML) {
@@ -666,7 +666,7 @@
style->overflow == CSS_OVERFLOW_AUTO) ?
SCROLLBAR_WIDTH : 0;
- layout_find_dimensions(available_width, style,
+ layout_find_dimensions(available_width, box, style,
&width, &height, margin, padding, border);
if (margin[LEFT] == AUTO)
@@ -712,6 +712,7 @@
* Calculate width, height, and thickness of margins, paddings, and borders.
*
* \param available_width width of containing block
+ * \param box current box
* \param style style giving width, height, margins, paddings,
* and borders
* \param width updated to width, may be NULL
@@ -722,11 +723,13 @@
*/
void layout_find_dimensions(int available_width,
- struct css_style *style,
+ struct box *box, struct css_style *style,
int *width, int *height,
int margin[4], int padding[4], int border[4])
{
unsigned int i;
+ int fixed = 0;
+ float frac = 0;
if (width) {
switch (style->width.width) {
@@ -737,6 +740,17 @@
case CSS_WIDTH_PERCENT:
*width = available_width *
style->width.value.percent / 100;
+ /* gadget widths include margins,
+ * borders and padding */
+ if (box->gadget) {
+ calculate_mbp_width(style,
+ LEFT, &fixed, &frac);
+ calculate_mbp_width(style,
+ RIGHT, &fixed, &frac);
+ *width -= frac + fixed;
+ *width = *width > 0 ?
+ *width : 0;
+ }
break;
case CSS_WIDTH_AUTO:
default:
@@ -1098,7 +1112,7 @@
if (b->type == BOX_INLINE) {
/* calculate borders, margins, and padding */
- layout_find_dimensions(*width, b->style,
+ layout_find_dimensions(*width, b, b->style,
0, 0, b->margin, b->padding, b->border);
for (i = 0; i != 4; i++)
if (b->margin[i] == AUTO)
@@ -1930,15 +1944,15 @@
memcpy(col, table->col, sizeof(col[0]) * columns);
/* find margins, paddings, and borders for table and cells */
- layout_find_dimensions(available_width, style, 0, 0, table->margin,
- table->padding, table->border);
+ layout_find_dimensions(available_width, table, style, 0, 0,
+ table->margin, table->padding, table->border);
for (row_group = table->children; row_group;
row_group = row_group->next) {
for (row = row_group->children; row; row = row->next) {
for (c = row->children; c; c = c->next) {
assert(c->style);
layout_find_dimensions(available_width,
- c->style, 0, 0, 0,
+ c, c->style, 0, 0, 0,
c->padding, c->border);
if (c->style->overflow ==
CSS_OVERFLOW_SCROLL ||
@@ -2736,7 +2750,7 @@
layout_compute_offsets(box, containing_block,
&top, &right, &bottom, &left);
- layout_find_dimensions(available_width, box->style,
+ layout_find_dimensions(available_width, box, box->style,
&width, &height, margin, padding, border);
/* 10.3.7 */
15 years, 7 months
r3857 tlsa - /trunk/netsurftest/haveproblems/select-option-wrap.html
by netsurf@semichrome.net
Author: tlsa
Date: Mon Feb 11 21:20:08 2008
New Revision: 3857
URL: http://source.netsurf-browser.org?rev=3857&view=rev
Log:
Test case for select option wrap.
Added:
trunk/netsurftest/haveproblems/select-option-wrap.html
Added: trunk/netsurftest/haveproblems/select-option-wrap.html
URL: http://source.netsurf-browser.org/trunk/netsurftest/haveproblems/select-o...
==============================================================================
--- trunk/netsurftest/haveproblems/select-option-wrap.html (added)
+++ trunk/netsurftest/haveproblems/select-option-wrap.html Mon Feb 11 21:20:08 2008
@@ -1,0 +1,16 @@
+<html>
+<body>
+
+<div style="width:25em;">
+<select>
+<option>AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA AAA</option>
+<option>BBB BBB BBB BBB BBB BBB BBB BBB BBB BBB BBB BBB BBB BBB BBB BBB BBB
+ BBB BBB BBB BBB BBB BBB BBB</option>
+<option>CCC CCC CCC CCC CCC CCC CCC CCC CCC CCC CCC CCC</option>
+</select>
+</div>
+
+<p>We need <code style="color:#800;" title="CSS">white-space:nowrap;</code> to be supported to prevent option text from wrapping.</p>
+
+</body>
+</html>
15 years, 7 months
r3856 tlsa - /trunk/netsurf/!NetSurf/Resources/CSS,f79
by netsurf@semichrome.net
Author: tlsa
Date: Mon Feb 11 21:18:53 2008
New Revision: 3856
URL: http://source.netsurf-browser.org?rev=3856&view=rev
Log:
Tweak select element style.
Modified:
trunk/netsurf/!NetSurf/Resources/CSS,f79
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 11 21:18:53 2008
@@ -171,7 +171,8 @@
select { background-color: #d9d9d9; color: #000; text-align: left;
font-family: sans-serif; width: auto; height: auto; overflow: hidden;
- margin: 1px; border: medium inset #d9d9d9; padding: 1px 2px; }
+ margin: 1px; border: medium inset #d9d9d9; padding: 1px 3px 1px 2px;
+ white-space: nowrap; }
select:after { content: "\25bc"; border-left: 4px ridge #d9d9d9; }
textarea { background-color: #fff; color: #000; text-align: left;
15 years, 7 months
r3855 tlsa - in /trunk/netsurf: !NetSurf/Resources/CSS, f79 render/layout.c
by netsurf@semichrome.net
Author: tlsa
Date: Mon Feb 11 17:53:00 2008
New Revision: 3855
URL: http://source.netsurf-browser.org?rev=3855&view=rev
Log:
Select element width is width of longest option text.
Modified:
trunk/netsurf/!NetSurf/Resources/CSS,f79
trunk/netsurf/render/layout.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 11 17:53:00 2008
@@ -170,7 +170,7 @@
input[align=right] { float: right; }
select { background-color: #d9d9d9; color: #000; text-align: left;
- font-family: sans-serif; width: 10em; height: auto; overflow: hidden;
+ font-family: sans-serif; width: auto; height: auto; overflow: hidden;
margin: 1px; border: medium inset #d9d9d9; padding: 1px 2px; }
select:after { content: "\25bc"; border-left: 4px ridge #d9d9d9; }
Modified: trunk/netsurf/render/layout.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/layout.c?rev=3855&...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Mon Feb 11 17:53:00 2008
@@ -46,6 +46,7 @@
#include "desktop/options.h"
#include "render/box.h"
#include "render/font.h"
+#include "render/form.h"
#include "render/layout.h"
#define NDEBUG
#include "utils/log.h"
@@ -1140,10 +1141,36 @@
continue;
}
- if (b->width == UNKNOWN_WIDTH)
- /** \todo handle errors */
- nsfont_width(b->style, b->text, b->length,
- &b->width);
+ if (b->width == UNKNOWN_WIDTH) {
+ /** \todo handle errors */
+
+ /* If it's a select element, we must use the
+ * width of the widest option text */
+ if (b->parent->parent->gadget &&
+ b->parent->parent->gadget->type
+ == GADGET_SELECT) {
+ int opt_maxwidth = 0;
+ struct form_option *o;
+
+ for (o = b->parent->parent->gadget->
+ data.select.items; o;
+ o = o->next) {
+ int opt_width;
+ nsfont_width(b->style, o->text,
+ strlen(o->text),
+ &opt_width);
+
+ if (opt_maxwidth < opt_width)
+ opt_maxwidth =opt_width;
+ }
+
+ b->width = opt_maxwidth;
+ } else {
+ nsfont_width(b->style, b->text,
+ b->length, &b->width);
+ }
+ }
+
x += b->width;
if (b->space)
/** \todo optimize out */
@@ -1628,10 +1655,35 @@
if (!b->text)
continue;
- if (b->width == UNKNOWN_WIDTH)
- /** \todo handle errors */
- nsfont_width(b->style, b->text, b->length,
- &b->width);
+ if (b->width == UNKNOWN_WIDTH) {
+ /** \todo handle errors */
+
+ /* If it's a select element, we must use the
+ * width of the widest option text */
+ if (b->parent->parent->gadget &&
+ b->parent->parent->gadget->type
+ == GADGET_SELECT) {
+ int opt_maxwidth = 0;
+ struct form_option *o;
+
+ for (o = b->parent->parent->gadget->
+ data.select.items; o;
+ o = o->next) {
+ int opt_width;
+ nsfont_width(b->style, o->text,
+ strlen(o->text),
+ &opt_width);
+
+ if (opt_maxwidth < opt_width)
+ opt_maxwidth =opt_width;
+ }
+
+ b->width = opt_maxwidth;
+ } else {
+ nsfont_width(b->style, b->text,
+ b->length, &b->width);
+ }
+ }
max += b->width;
if (b->next && b->space) {
nsfont_width(b->style, " ", 1, &width);
15 years, 7 months
r3854 bursa - /trunk/netsurf/image/gifread.c
by netsurf@semichrome.net
Author: bursa
Date: Sun Feb 10 00:35:03 2008
New Revision: 3854
URL: http://source.netsurf-browser.org?rev=3854&view=rev
Log:
Make GIF decoding work correctly on big-endian (colors were wrong).
Modified:
trunk/netsurf/image/gifread.c
Modified: trunk/netsurf/image/gifread.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/gifread.c?rev=3854&...
==============================================================================
--- trunk/netsurf/image/gifread.c (original)
+++ trunk/netsurf/image/gifread.c Sun Feb 10 00:35:03 2008
@@ -235,8 +235,8 @@
return GIF_INSUFFICIENT_DATA;
}
for (index = 0; index < gif->colour_table_size; index++) {
- gif->global_colour_table[index] = gif_data[0] | (gif_data[1] << 8) |
- (gif_data[2] << 16) | 0xff000000;
+ char colour[] = {gif_data[0], gif_data[1], gif_data[2], 0xff};
+ gif->global_colour_table[index] = *((int *) colour);
gif_data += 3;
}
gif->buffer_position = (gif_data - gif->gif_data);
@@ -704,8 +704,9 @@
colour_table = gif->local_colour_table;
if (!clear_image) {
for (index = 0; index < colour_table_size; index++) {
- colour_table[index] = gif_data[0] | (gif_data[1] << 8) |
- (gif_data[2] << 16) | 0xff000000;
+ char colour[] = {gif_data[0], gif_data[1],
+ gif_data[2], 0xff};
+ colour_table[index] = *((int *) colour);
gif_data += 3;
}
} else {
15 years, 7 months
r3853 jmb - /trunk/netsurf/Makefile.unix
by netsurf@semichrome.net
Author: jmb
Date: Sat Feb 9 22:37:51 2008
New Revision: 3853
URL: http://source.netsurf-browser.org?rev=3853&view=rev
Log:
Reinstate WARNFLAGS
Make RISC OS build CFLAGS specify -mpoke-function-name
Modified:
trunk/netsurf/Makefile.unix
Modified: trunk/netsurf/Makefile.unix
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile.unix?rev=3853&r1...
==============================================================================
--- trunk/netsurf/Makefile.unix (original)
+++ trunk/netsurf/Makefile.unix Sat Feb 9 22:37:51 2008
@@ -54,10 +54,10 @@
$(Q)$(MKDIR) $(DEPROOT)
$(Q)$(TOUCH) $(DEPROOT)/created
-#WARNFLAGS = -W -Wall -Wundef -Wpointer-arith -Wcast-qual \
-# -Wcast-align -Wwrite-strings -Wstrict-prototypes \
-# -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
-# -Wnested-externs -Winline -Wno-unused-parameter -Wuninitialized
+WARNFLAGS = -W -Wall -Wundef -Wpointer-arith -Wcast-qual \
+ -Wcast-align -Wwrite-strings -Wstrict-prototypes \
+ -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
+ -Wnested-externs -Winline -Wno-unused-parameter -Wuninitialized
STARTGROUP := -Wl,--start-group
ENDGROUP := -Wl,--end-group
@@ -104,7 +104,9 @@
ifeq ($(TARGET),riscos)
GCCSDK_INSTALL_ENV := /home/riscos/env
-CFLAGS += -I. -O $(WARNFLAGS) -Driscos -std=c99 -D_BSD_SOURCE
+CFLAGS += -I. -O $(WARNFLAGS) -Driscos \
+ -std=c99 -D_BSD_SOURCE -D_POSIX_C_SOURCE \
+ -mpoke-function-name
CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include \
-I$(GCCSDK_INSTALL_ENV)/include/libxml2 \
15 years, 7 months