r12915 vince - in /branches/vince/netsurf-cairo: gtk/bitmap.c gtk/bitmap.h gtk/plotters.c gtk/print.c gtk/scaffolding.c gtk/thumbnail.c image/gif.c image/png.c
by netsurf@semichrome.net
Author: vince
Date: Fri Sep 30 03:19:56 2011
New Revision: 12915
URL: http://source.netsurf-browser.org?rev=12915&view=rev
Log:
initial stab at making gtk frontend use cairo image surfaces instead of gdk pixmaps
Modified:
branches/vince/netsurf-cairo/gtk/bitmap.c
branches/vince/netsurf-cairo/gtk/bitmap.h
branches/vince/netsurf-cairo/gtk/plotters.c
branches/vince/netsurf-cairo/gtk/print.c
branches/vince/netsurf-cairo/gtk/scaffolding.c
branches/vince/netsurf-cairo/gtk/thumbnail.c
branches/vince/netsurf-cairo/image/gif.c
branches/vince/netsurf-cairo/image/png.c
Modified: branches/vince/netsurf-cairo/gtk/bitmap.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-cairo/gtk/bitmap...
==============================================================================
--- branches/vince/netsurf-cairo/gtk/bitmap.c (original)
+++ branches/vince/netsurf-cairo/gtk/bitmap.c Fri Sep 30 03:19:56 2011
@@ -25,27 +25,21 @@
#include <assert.h>
#include <stdbool.h>
#include <string.h>
-#include <gdk/gdk.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <cairo.h>
+#include <gtk/gtk.h>
#include "content/content.h"
+#include "gtk/scaffolding.h"
#include "gtk/bitmap.h"
-#include "gtk/scaffolding.h"
#include "image/bitmap.h"
#include "utils/log.h"
struct bitmap {
- GdkPixbuf *primary;
- GdkPixbuf *pretile_x;
- GdkPixbuf *pretile_y;
- GdkPixbuf *pretile_xy;
- bool opaque;
+ cairo_surface_t *surface;
+ bool opaque;
};
-
-#define MIN_PRETILE_WIDTH 256
-#define MIN_PRETILE_HEIGHT 256
-
/**
* Create a bitmap.
@@ -58,17 +52,19 @@
void *bitmap_create(int width, int height, unsigned int state)
{
- struct bitmap *bmp = malloc(sizeof(struct bitmap));
-
- bmp->primary = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true,
- 8, width, height);
-
- /* fill the pixbuf in with 100% transparent black, as the memory
- * won't have been cleared.
- */
- gdk_pixbuf_fill(bmp->primary, 0);
- bmp->pretile_x = bmp->pretile_y = bmp->pretile_xy = NULL;
- bmp->opaque = (state & BITMAP_OPAQUE) != 0;
+ struct bitmap *bmp;
+ bmp = calloc(1, sizeof(struct bitmap));
+
+ if (bmp != NULL) {
+ bmp->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
+ bmp->opaque = (state & BITMAP_OPAQUE) != 0;
+
+ if (cairo_surface_status(bmp->surface) != CAIRO_STATUS_SUCCESS) {
+ cairo_surface_destroy(bmp->surface);
+ free(bmp);
+ bmp = NULL;
+ }
+ }
return bmp;
}
@@ -129,7 +125,7 @@
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
- return (unsigned char *)gdk_pixbuf_get_pixels(bitmap->primary);
+ return cairo_image_surface_get_data(bitmap->surface);
}
@@ -144,7 +140,7 @@
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
- return gdk_pixbuf_get_rowstride(bitmap->primary);
+ return cairo_image_surface_get_stride(bitmap->surface);
}
@@ -163,15 +159,6 @@
}
-static void
-gtk_bitmap_free_pretiles(struct bitmap *bitmap)
-{
-#define FREE_TILE(XY) if (bitmap->pretile_##XY) g_object_unref(bitmap->pretile_##XY); bitmap->pretile_##XY = NULL
- FREE_TILE(x);
- FREE_TILE(y);
- FREE_TILE(xy);
-#undef FREE_TILE
-}
/**
* Free a bitmap.
@@ -183,8 +170,8 @@
{
struct bitmap *bitmap = (struct bitmap *)vbitmap;
assert(bitmap);
- gtk_bitmap_free_pretiles(bitmap);
- g_object_unref(bitmap->primary);
+
+ cairo_surface_destroy(bitmap->surface);
free(bitmap);
}
@@ -200,16 +187,9 @@
bool bitmap_save(void *vbitmap, const char *path, unsigned flags)
{
- struct bitmap *bitmap = (struct bitmap *)vbitmap;
- GError *err = NULL;
-
- gdk_pixbuf_save(bitmap->primary, path, "png", &err, NULL);
-
- if (err == NULL)
- /* TODO: report an error here */
- return false;
-
- return true;
+// struct bitmap *bitmap = (struct bitmap *)vbitmap;
+
+ return false;
}
@@ -220,7 +200,19 @@
*/
void bitmap_modified(void *vbitmap) {
struct bitmap *bitmap = (struct bitmap *)vbitmap;
- gtk_bitmap_free_pretiles(bitmap);
+ int pixel_loop;
+ int pixel_count = cairo_image_surface_get_width(bitmap->surface) * cairo_image_surface_get_height(bitmap->surface);
+ uint32_t *pixels = (uint32_t *)cairo_image_surface_get_data(bitmap->surface);
+ uint32_t pixel;
+
+ for (pixel_loop=0; pixel_loop < pixel_count; pixel_loop++) {
+ pixel = pixels[pixel_loop];
+ pixels[pixel_loop] = (pixel & 0xff00ff00) |
+ ((pixel & 0xff) << 16) |
+ ((pixel & 0xff0000) >> 16);
+
+ }
+ cairo_surface_flush (bitmap->surface);
}
@@ -237,112 +229,23 @@
int bitmap_get_width(void *vbitmap){
struct bitmap *bitmap = (struct bitmap *)vbitmap;
- return gdk_pixbuf_get_width(bitmap->primary);
+ return cairo_image_surface_get_width(bitmap->surface);
}
int bitmap_get_height(void *vbitmap){
struct bitmap *bitmap = (struct bitmap *)vbitmap;
- return gdk_pixbuf_get_height(bitmap->primary);
-}
-
-static GdkPixbuf *
-gtk_bitmap_generate_pretile(GdkPixbuf *primary, int repeat_x, int repeat_y)
-{
- int width = gdk_pixbuf_get_width(primary);
- int height = gdk_pixbuf_get_height(primary);
- size_t primary_stride = gdk_pixbuf_get_rowstride(primary);
- GdkPixbuf *result = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8,
- width * repeat_x, height * repeat_y);
- char *target_buffer = (char *)gdk_pixbuf_get_pixels(result);
- int x,y,row;
- /* This algorithm won't work if the strides are not multiples */
- assert((size_t)gdk_pixbuf_get_rowstride(result) ==
- (primary_stride * repeat_x));
-
- if (repeat_x == 1 && repeat_y == 1) {
- g_object_ref(primary);
- g_object_unref(result);
- return primary;
- }
-
- for (y = 0; y < repeat_y; ++y) {
- char *primary_buffer = (char *)gdk_pixbuf_get_pixels(primary);
- for (row = 0; row < height; ++row) {
- for (x = 0; x < repeat_x; ++x) {
- memcpy(target_buffer,
- primary_buffer, primary_stride);
- target_buffer += primary_stride;
- }
- primary_buffer += primary_stride;
- }
- }
- return result;
-}
-
-/**
- * The primary image associated with this bitmap object.
+ return cairo_image_surface_get_height(bitmap->surface);
+}
+
+
+/**
+ * The image associated with this bitmap object.
*
* \param bitmap a bitmap, as returned by bitmap_create()
*/
-GdkPixbuf *
-gtk_bitmap_get_primary(struct bitmap *bitmap)
-{
- if (bitmap != NULL)
- return bitmap->primary;
- else
- return NULL;
-}
-
-/**
- * The X-pretiled image associated with this bitmap object.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-GdkPixbuf *
-gtk_bitmap_get_pretile_x(struct bitmap* bitmap)
-{
- if (!bitmap->pretile_x) {
- int width = gdk_pixbuf_get_width(bitmap->primary);
- int xmult = (MIN_PRETILE_WIDTH + width - 1)/width;
- LOG(("Pretiling %p for X*%d", bitmap, xmult));
- bitmap->pretile_x = gtk_bitmap_generate_pretile(bitmap->primary, xmult, 1);
- }
- return bitmap->pretile_x;
-
-}
-
-/**
- * The Y-pretiled image associated with this bitmap object.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-GdkPixbuf *
-gtk_bitmap_get_pretile_y(struct bitmap* bitmap)
-{
- if (!bitmap->pretile_y) {
- int height = gdk_pixbuf_get_height(bitmap->primary);
- int ymult = (MIN_PRETILE_HEIGHT + height - 1)/height;
- LOG(("Pretiling %p for Y*%d", bitmap, ymult));
- bitmap->pretile_y = gtk_bitmap_generate_pretile(bitmap->primary, 1, ymult);
- }
- return bitmap->pretile_y;
-}
-
-/**
- * The XY-pretiled image associated with this bitmap object.
- *
- * \param bitmap a bitmap, as returned by bitmap_create()
- */
-GdkPixbuf *
-gtk_bitmap_get_pretile_xy(struct bitmap* bitmap)
-{
- if (!bitmap->pretile_xy) {
- int width = gdk_pixbuf_get_width(bitmap->primary);
- int height = gdk_pixbuf_get_height(bitmap->primary);
- int xmult = (MIN_PRETILE_WIDTH + width - 1)/width;
- int ymult = (MIN_PRETILE_HEIGHT + height - 1)/height;
- LOG(("Pretiling %p for X*%d Y*%d", bitmap, xmult, ymult));
- bitmap->pretile_xy = gtk_bitmap_generate_pretile(bitmap->primary, xmult, ymult);
- }
- return bitmap->pretile_xy;
-}
+cairo_surface_t *
+gtk_bitmap_get_surface(struct bitmap *bitmap)
+{
+ return bitmap->surface;
+}
+
Modified: branches/vince/netsurf-cairo/gtk/bitmap.h
URL: http://source.netsurf-browser.org/branches/vince/netsurf-cairo/gtk/bitmap...
==============================================================================
--- branches/vince/netsurf-cairo/gtk/bitmap.h (original)
+++ branches/vince/netsurf-cairo/gtk/bitmap.h Fri Sep 30 03:19:56 2011
@@ -19,15 +19,9 @@
#ifndef NS_GTK_BITMAP_H
#define NS_GTK_BITMAP_H
-#include <gdk/gdk.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <cairo.h>
#include "image/bitmap.h"
-GdkPixbuf *gtk_bitmap_get_primary(struct bitmap*);
-GdkPixbuf *gtk_bitmap_get_pretile_x(struct bitmap*);
-GdkPixbuf *gtk_bitmap_get_pretile_y(struct bitmap*);
-GdkPixbuf *gtk_bitmap_get_pretile_xy(struct bitmap*);
-
-
+cairo_surface_t *gtk_bitmap_get_surface(struct bitmap *bitmap);
#endif /* NS_GTK_BITMAP_H */
Modified: branches/vince/netsurf-cairo/gtk/plotters.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-cairo/gtk/plotte...
==============================================================================
--- branches/vince/netsurf-cairo/gtk/plotters.c (original)
+++ branches/vince/netsurf-cairo/gtk/plotters.c Fri Sep 30 03:19:56 2011
@@ -281,7 +281,7 @@
static bool nsgtk_plot_pixbuf(int x, int y, int width, int height,
- GdkPixbuf *pixbuf, colour bg)
+ cairo_surface_t *bmsurface, colour bg)
{
/* XXX: This currently ignores the background colour supplied.
* Does this matter?
@@ -289,6 +289,7 @@
int x0, y0, x1, y1;
int dsrcx, dsrcy, dwidth, dheight;
+ int bmwidth, bmheight;
/* Bail early if we can */
if (width == 0 || height == 0)
@@ -338,18 +339,47 @@
if (dwidth == 0 || dheight == 0)
/* Nothing to plot */
return true;
+ bmwidth = cairo_image_surface_get_width(bmsurface);
+ bmheight = cairo_image_surface_get_height(bmsurface);
/* Render the bitmap */
- if (gdk_pixbuf_get_width(pixbuf) == width &&
- gdk_pixbuf_get_height(pixbuf) == height) {
+ if ((bmwidth == width) && (bmheight == height)) {
/* Bitmap is not scaled */
/* Plot the bitmap */
- gdk_cairo_set_source_pixbuf(current_cr, pixbuf, x - dsrcx, y -dsrcy);
+ cairo_set_source_surface(current_cr, bmsurface, x - dsrcx, y -dsrcy);
cairo_rectangle(current_cr, x , y , dwidth, dheight);
cairo_fill(current_cr);
} else {
/* Bitmap is scaled */
+ cairo_surface_t *scsurface = cairo_surface_create_similar(bmsurface,CAIRO_CONTENT_COLOR_ALPHA, width, height);
+ cairo_t *cr = cairo_create (scsurface);
+
+ /* Scale *before* setting the source surface (1) */
+ cairo_scale (cr, (double)width / bmwidth, (double)height / bmheight);
+ cairo_set_source_surface (cr, bmsurface, 0, 0);
+
+ /* To avoid getting the edge pixels blended with 0 alpha, which would
+ * occur with the default EXTEND_NONE. Use EXTEND_PAD for 1.2 or newer (2)
+ */
+ cairo_pattern_set_extend (cairo_get_source(cr), CAIRO_EXTEND_REFLECT);
+
+ /* Replace the destination with the source instead of overlaying */
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+
+ /* Do the actual drawing */
+ cairo_paint (cr);
+
+ cairo_destroy (cr);
+
+ /* Plot the scaled bitmap */
+ cairo_set_source_surface(current_cr, scsurface, x, y);
+ cairo_rectangle(current_cr, x , y , dwidth, dheight);
+ cairo_fill(current_cr);
+
+ cairo_surface_destroy(scsurface);
+
+#if 0
/* Get scale factors */
double sx = (double)width / gdk_pixbuf_get_width(pixbuf);
double sy = (double)height / gdk_pixbuf_get_height(pixbuf);
@@ -366,13 +396,9 @@
GDK_INTERP_NEAREST);
if (!scaled)
return false;
-
- /* Plot the scaled bitmap */
- gdk_cairo_set_source_pixbuf(current_cr, scaled, x, y);
- cairo_rectangle(current_cr, x , y , dwidth, dheight);
- cairo_fill(current_cr);
-
- g_object_unref(scaled);
+#endif
+
+// g_object_unref(scaled);
}
return true;
@@ -383,33 +409,21 @@
bitmap_flags_t flags)
{
int doneheight = 0, donewidth = 0;
- GdkPixbuf *primary;
- GdkPixbuf *pretiled = NULL;
-
bool repeat_x = (flags & BITMAPF_REPEAT_X);
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
+ cairo_surface_t *bmsurface;
+
+ bmsurface = gtk_bitmap_get_surface(bitmap);
+
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
- primary = gtk_bitmap_get_primary(bitmap);
- return nsgtk_plot_pixbuf(x, y, width, height, primary, bg);
- }
-
- if (repeat_x && !repeat_y)
- pretiled = gtk_bitmap_get_pretile_x(bitmap);
- if (repeat_x && repeat_y)
- pretiled = gtk_bitmap_get_pretile_xy(bitmap);
- if (!repeat_x && repeat_y)
- pretiled = gtk_bitmap_get_pretile_y(bitmap);
-
- assert(pretiled != NULL);
-
- primary = gtk_bitmap_get_primary(bitmap);
- /* use the primary and pretiled widths to scale the w/h provided */
- width *= gdk_pixbuf_get_width(pretiled);
- width /= gdk_pixbuf_get_width(primary);
- height *= gdk_pixbuf_get_height(pretiled);
- height /= gdk_pixbuf_get_height(primary);
+ return nsgtk_plot_pixbuf(x, y, width, height, bmsurface, bg);
+ }
+
+ width = bitmap_get_width(bitmap);
+ height = bitmap_get_height(bitmap);
+
if (y > cliprect.y)
doneheight = (cliprect.y - height) + ((y - cliprect.y) % height);
@@ -423,7 +437,7 @@
donewidth = x;
while (donewidth < (cliprect.x + cliprect.width)) {
nsgtk_plot_pixbuf(donewidth, doneheight,
- width, height, pretiled, bg);
+ width, height, bmsurface, bg);
donewidth += width;
if (!repeat_x) break;
}
Modified: branches/vince/netsurf-cairo/gtk/print.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-cairo/gtk/print....
==============================================================================
--- branches/vince/netsurf-cairo/gtk/print.c (original)
+++ branches/vince/netsurf-cairo/gtk/print.c Fri Sep 30 03:19:56 2011
@@ -373,7 +373,7 @@
bitmap_flags_t flags)
{
int doneheight = 0, donewidth = 0;
- GdkPixbuf *primary;
+ GdkPixbuf *primary= NULL;
GdkPixbuf *pretiled = NULL;
bool repeat_x = (flags & BITMAPF_REPEAT_X);
@@ -381,10 +381,10 @@
if (!(repeat_x || repeat_y)) {
/* Not repeating at all, so just pass it on */
- primary = gtk_bitmap_get_primary(bitmap);
+// primary = gtk_bitmap_get_primary(bitmap);
return nsgtk_print_plot_pixbuf(x, y, width, height, primary, bg);
}
-
+#if 0
if (repeat_x && !repeat_y)
pretiled = gtk_bitmap_get_pretile_x(bitmap);
if (repeat_x && repeat_y)
@@ -395,7 +395,7 @@
assert(pretiled != NULL);
primary = gtk_bitmap_get_primary(bitmap);
-
+#endif
/* use the primary and pretiled widths to scale the w/h provided */
width *= gdk_pixbuf_get_width(pretiled);
width /= gdk_pixbuf_get_width(primary);
Modified: branches/vince/netsurf-cairo/gtk/scaffolding.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-cairo/gtk/scaffo...
==============================================================================
--- branches/vince/netsurf-cairo/gtk/scaffolding.c (original)
+++ branches/vince/netsurf-cairo/gtk/scaffolding.c Fri Sep 30 03:19:56 2011
@@ -2004,12 +2004,14 @@
icon_bitmap = (icon != NULL) ? content_get_bitmap(icon) : NULL;
if (icon_bitmap != NULL) {
+#if 0
GdkPixbuf *pb = gtk_bitmap_get_primary(icon_bitmap);
if (pb != NULL && gdk_pixbuf_get_width(pb) > 0 &&
gdk_pixbuf_get_height(pb) > 0) {
pb = gdk_pixbuf_scale_simple(pb, 16, 16, GDK_INTERP_HYPER);
iconImage = GTK_IMAGE(gtk_image_new_from_pixbuf(pb));
}
+#endif
}
if (iconImage == NULL) {
/** \todo Does pb need cleaning up? */
@@ -2033,7 +2035,7 @@
void gui_window_set_search_ico(hlcache_handle *ico)
{
- GdkPixbuf *pbico;
+ GdkPixbuf *pbico = NULL;
GtkImage *searchico;
struct bitmap *ico_bitmap;
nsgtk_scaffolding *current;
@@ -2045,7 +2047,7 @@
if (ico_bitmap == NULL)
return;
- pbico = gtk_bitmap_get_primary(ico_bitmap);
+// pbico = gtk_bitmap_get_primary(ico_bitmap);
if (pbico != NULL && gdk_pixbuf_get_width(pbico) > 0 &&
gdk_pixbuf_get_height(pbico) > 0) {
pbico = gdk_pixbuf_scale_simple(pbico, 20, 20,
Modified: branches/vince/netsurf-cairo/gtk/thumbnail.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-cairo/gtk/thumbn...
==============================================================================
--- branches/vince/netsurf-cairo/gtk/thumbnail.c (original)
+++ branches/vince/netsurf-cairo/gtk/thumbnail.c Fri Sep 30 03:19:56 2011
@@ -70,7 +70,7 @@
assert(bitmap);
/* Get details of required final thumbnail image */
- pixbuf = gtk_bitmap_get_primary(bitmap);
+ pixbuf = NULL;//gtk_bitmap_get_primary(bitmap);
width = gdk_pixbuf_get_width(pixbuf);
height = gdk_pixbuf_get_height(pixbuf);
depth = (gdk_screen_get_system_visual(gdk_screen_get_default()))->depth;
Modified: branches/vince/netsurf-cairo/image/gif.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-cairo/image/gif....
==============================================================================
--- branches/vince/netsurf-cairo/image/gif.c (original)
+++ branches/vince/netsurf-cairo/image/gif.c Fri Sep 30 03:19:56 2011
@@ -297,6 +297,8 @@
bitmap_set_suspendable(gif->gif->frame_image, gif->gif,
nsgif_invalidate);
+ bitmap_modified(gif->gif->frame_image);
+
/* Exit as a success */
content_set_ready(c);
content_set_done(c);
@@ -328,6 +330,7 @@
for (frame = previous_frame; frame <= current_frame; frame++) {
res = gif_decode_frame(gif->gif, frame);
+ bitmap_modified(gif->gif->frame_image);
}
return res;
Modified: branches/vince/netsurf-cairo/image/png.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-cairo/image/png....
==============================================================================
--- branches/vince/netsurf-cairo/image/png.c (original)
+++ branches/vince/netsurf-cairo/image/png.c Fri Sep 30 03:19:56 2011
@@ -498,7 +498,9 @@
free((png_bytep *) row_pointers);
- return (struct bitmap *) bitmap;
+ bitmap_modified((struct bitmap *)bitmap);
+
+ return (struct bitmap *)bitmap;
}
static bool nspng_convert(struct content *c)
11 years, 12 months
r12913 chris_y - /trunk/netsurf/amiga/gui.c
by netsurf@semichrome.net
Author: chris_y
Date: Thu Sep 29 17:13:13 2011
New Revision: 12913
URL: http://source.netsurf-browser.org?rev=12913&view=rev
Log:
Disable RAmiga-U temporarily as ActivateGadget() is causing a bizarre but fatal
interaction with context menus.
Modified:
trunk/netsurf/amiga/gui.c
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=12913&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Thu Sep 29 17:13:13 2011
@@ -1475,12 +1475,13 @@
if(browser_window_reload_available(gwin->bw))
browser_window_reload(gwin->bw,false);
break;
-
+/*
case 'u': // open url
if((option_kiosk_mode == false))
ActivateGadget((struct Gadget *)gwin->objects[GID_URL],
gwin->win, NULL);
break;
+*/
}
}
else
11 years, 12 months
r12912 jmb - in /trunk/netsurf/render: box.c box.h box_construct.c html.c html.h html_interaction.c hubbub_binding.c parser_binding.h
by netsurf@semichrome.net
Author: jmb
Date: Thu Sep 29 14:15:54 2011
New Revision: 12912
URL: http://source.netsurf-browser.org?rev=12912&view=rev
Log:
Restartable box tree constructor. Yield between elements.
Modified:
trunk/netsurf/render/box.c
trunk/netsurf/render/box.h
trunk/netsurf/render/box_construct.c
trunk/netsurf/render/html.c
trunk/netsurf/render/html.h
trunk/netsurf/render/html_interaction.c
trunk/netsurf/render/hubbub_binding.c
trunk/netsurf/render/parser_binding.h
Modified: trunk/netsurf/render/box.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box.c?rev=12912&r1...
==============================================================================
--- trunk/netsurf/render/box.c (original)
+++ trunk/netsurf/render/box.c Thu Sep 29 14:15:54 2011
@@ -109,8 +109,8 @@
*/
struct box * box_create(css_select_results *styles, css_computed_style *style,
- bool style_owned, char *href, const char *target, char *title,
- char *id, void *context)
+ bool style_owned, const char *href, const char *target,
+ const char *title, char *id, void *context)
{
unsigned int i;
struct box *box;
Modified: trunk/netsurf/render/box.h
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box.h?rev=12912&r1...
==============================================================================
--- trunk/netsurf/render/box.h (original)
+++ trunk/netsurf/render/box.h Thu Sep 29 14:15:54 2011
@@ -104,6 +104,7 @@
#define UNKNOWN_WIDTH INT_MAX
#define UNKNOWN_MAX_WIDTH INT_MAX
+typedef void (*box_construct_complete_cb)(struct html_content *c, bool success);
/** Type of a struct box. */
typedef enum {
@@ -128,7 +129,8 @@
MAKE_HEIGHT = 1 << 7, /* box causes its own height */
NEED_MIN = 1 << 8, /* minimum width is required for layout */
REPLACE_DIM = 1 << 9, /* replaced element has given dimensions */
- IFRAME = 1 << 10 /* box contains an iframe */
+ IFRAME = 1 << 10, /* box contains an iframe */
+ CONVERT_CHILDREN = 1 << 11 /* wanted children converting */
} box_flags;
/* Sides of a box */
@@ -211,9 +213,9 @@
/** Width of space after current text (depends on font and size). */
int space;
- char *href; /**< Link, or 0. */
+ const char *href; /**< Link, or 0. */
const char *target; /**< Link target, or 0. */
- char *title; /**< Title, or 0. */
+ const char *title; /**< Title, or 0. */
unsigned int columns; /**< Number of columns for TABLE / TABLE_CELL. */
unsigned int rows; /**< Number of rows for TABLE only. */
@@ -310,8 +312,8 @@
void *box_style_alloc(void *ptr, size_t len, void *pw);
struct box * box_create(css_select_results *styles, css_computed_style *style,
- bool style_owned, char *href, const char *target, char *title,
- char *id, void *context);
+ bool style_owned, const char *href, const char *target,
+ const char *title, char *id, void *context);
void box_add_child(struct box *parent, struct box *child);
void box_insert_sibling(struct box *box, struct box *new_box);
void box_unlink_and_free(struct box *box);
@@ -336,7 +338,8 @@
bool box_vscrollbar_present(const struct box *box);
bool box_hscrollbar_present(const struct box *box);
-bool xml_to_box(xmlNode *n, struct html_content *c);
+bool xml_to_box(xmlNode *n, struct html_content *c,
+ box_construct_complete_cb cb);
bool box_normalise_block(struct box *block, struct html_content *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 Sep 29 14:15:54 2011
@@ -45,10 +45,44 @@
#include "utils/locale.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "utils/schedule.h"
#include "utils/talloc.h"
#include "utils/url.h"
#include "utils/utils.h"
+/**
+ * Context for box tree construction
+ */
+struct box_construct_ctx {
+ html_content *content; /**< Content we're constructing for */
+
+ xmlNode *n; /**< Current node to process */
+
+ struct box *root_box; /**< Root box in the tree */
+
+ box_construct_complete_cb cb; /**< Callback to invoke on completion */
+};
+
+/**
+ * Transient properties for construction of current node
+ */
+struct box_construct_props {
+ /** Style from which to inherit, or NULL if none */
+ const css_computed_style *parent_style;
+ /** Current link target, or NULL if none */
+ const char *href;
+ /** Current frame target, or NULL if none */
+ const char *target;
+ /** Current title attribute, or NULL if none */
+ const char *title;
+ /** Identity of the current block-level container */
+ struct box *containing_block;
+ /** Current container for inlines, or NULL if none
+ * \note If non-NULL, will be the last child of containing_block */
+ struct box *inline_container;
+ /** Whether the current node is the root of the DOM tree */
+ bool node_is_root;
+};
static const content_type image_types = CONTENT_IMAGE;
@@ -58,20 +92,11 @@
const char *TARGET_TOP = "_top";
const char *TARGET_BLANK = "_blank";
-static bool convert_xml_to_box(xmlNode *n, html_content *content,
- const css_computed_style *parent_style,
- struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title);
-bool box_construct_element(xmlNode *n, html_content *content,
- const css_computed_style *parent_style,
- struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title);
-void box_construct_generate(xmlNode *n, html_content *content,
- struct box *box, const css_computed_style *style);
-bool box_construct_text(xmlNode *n, html_content *content,
- const css_computed_style *parent_style,
- struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title);
+static void convert_xml_to_box(struct box_construct_ctx *ctx);
+static bool box_construct_element(struct box_construct_ctx *ctx,
+ bool *convert_children);
+static void box_construct_element_after(xmlNode *n, html_content *content);
+static bool box_construct_text(struct box_construct_ctx *ctx);
static css_select_results * box_get_style(html_content *c,
const css_computed_style *parent_style, xmlNode *n);
static void box_text_transform(char *s, unsigned int len,
@@ -126,40 +151,29 @@
/**
* Construct a box tree from an xml tree and stylesheets.
*
- * \param n xml tree
- * \param c content of type CONTENT_HTML to construct box tree in
+ * \param n xml tree
+ * \param c content of type CONTENT_HTML to construct box tree in
+ * \param cb callback to report conversion completion
* \return true on success, false on memory exhaustion
*/
-bool xml_to_box(xmlNode *n, html_content *c)
-{
- struct box root;
- struct box *inline_container = NULL;
-
- root.type = BOX_BLOCK;
- root.style = NULL;
- root.next = NULL;
- root.prev = NULL;
- root.children = NULL;
- root.last = NULL;
- root.parent = NULL;
- root.float_children = NULL;
- root.next_float = NULL;
-
- /* The root box's style */
- if (!convert_xml_to_box(n, c, NULL, &root,
- &inline_container, 0, 0, 0))
- return false;
-
- if (!box_normalise_block(&root, c))
- return false;
-
- c->layout = root.children;
- c->layout->parent = NULL;
+bool xml_to_box(xmlNode *n, html_content *c, box_construct_complete_cb cb)
+{
+ struct box_construct_ctx *ctx;
+
+ ctx = malloc(sizeof(*ctx));
+ if (ctx == NULL)
+ return false;
+
+ ctx->content = c;
+ ctx->n = n;
+ ctx->root_box = NULL;
+ ctx->cb = cb;
+
+ schedule(0, (schedule_callback_fn) convert_xml_to_box, ctx);
return true;
}
-
/* mapping from CSS display to box type
* this table must be in sync with libcss' css_display enum */
@@ -183,507 +197,644 @@
BOX_NONE /*CSS_DISPLAY_NONE*/
};
-
-/**
- * Recursively construct a box tree from an xml tree and stylesheets.
- *
- * \param n fragment of xml tree
- * \param content content of type CONTENT_HTML that is being processed
- * \param parent_style style at this point in xml tree, or NULL for root box
- * \param parent parent in box tree
- * \param inline_container current inline container box, or 0, updated to
- * new current inline container on exit
- * \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
+static inline struct box *box_for_node(const xmlNode *n)
+{
+ return ((binding_private *) n->_private)->box;
+}
+
+static inline bool box_is_root(const xmlNode *n)
+{
+ return n->parent == NULL || n->parent->type == XML_HTML_DOCUMENT_NODE;
+}
+
+/**
+ * Find the next node in the DOM tree, completing
+ * element construction where appropriate.
+ *
+ * \param n Current node
+ * \param content Containing content
+ * \param convert_children Whether to consider children of \a n
+ * \return Next node to process, or NULL if complete
+ */
+static xmlNode *next_node(xmlNode *n, html_content *content,
+ bool convert_children)
+{
+ xmlNode *next = NULL;
+
+ if (convert_children && n->children != NULL) {
+ next = n->children;
+ } else if (n->next != NULL) {
+ if (box_for_node(n) != NULL)
+ box_construct_element_after(n, content);
+
+ next = n->next;
+ } else {
+ if (box_for_node(n) != NULL)
+ box_construct_element_after(n, content);
+
+ while (box_is_root(n) == false && n->parent->next == NULL) {
+ n = n->parent;
+
+ if (box_for_node(n) != NULL)
+ box_construct_element_after(n, content);
+ }
+
+ if (box_is_root(n) == false) {
+ if (box_for_node(n->parent) != NULL) {
+ box_construct_element_after(n->parent, content);
+ }
+
+ next = n->parent->next;
+ }
+ }
+
+ return next;
+}
+
+/**
+ * Convert an ELEMENT node to a box tree fragment,
+ * then schedule conversion of the next ELEMENT node
+ */
+void convert_xml_to_box(struct box_construct_ctx *ctx)
+{
+ xmlNode *next;
+ bool convert_children = true;
+
+ assert(ctx->n != NULL);
+ assert(ctx->n->type == XML_ELEMENT_NODE);
+
+ if (box_construct_element(ctx, &convert_children) == false) {
+ ctx->cb(ctx->content, false);
+ free(ctx);
+ return;
+ }
+
+ /* Find next element to process, converting text nodes as we go */
+ next = next_node(ctx->n, ctx->content, convert_children);
+ while (next != NULL && next->type != XML_ELEMENT_NODE) {
+ if (next->type == XML_TEXT_NODE) {
+ ctx->n = next;
+ if (box_construct_text(ctx) == false) {
+ ctx->cb(ctx->content, false);
+ free(ctx);
+ return;
+ }
+ }
+
+ next = next_node(next, ctx->content, true);
+ }
+
+ ctx->n = next;
+
+ if (next != NULL) {
+ /* More work to do: schedule a continuation */
+ schedule(0, (schedule_callback_fn) convert_xml_to_box, ctx);
+ } else {
+ /* Conversion complete */
+ struct box root;
+
+ memset(&root, 0, sizeof(root));
+
+ root.type = BOX_BLOCK;
+ root.children = root.last = ctx->root_box;
+ root.children->parent = &root;
+
+ /** \todo Remove box_normalise_block */
+ if (box_normalise_block(&root, ctx->content) == false) {
+ ctx->cb(ctx->content, false);
+ } else {
+ ctx->content->layout = root.children;
+ ctx->content->layout->parent = NULL;
+
+ ctx->cb(ctx->content, true);
+ }
+
+ free(ctx);
+ }
+}
+
+/**
+ * Construct a list marker box
+ *
+ * \param box Box to attach marker to
+ * \param title Current title attribute
+ * \param content Containing content
+ * \param parent Current block-level container
+ * \return True on success, false on memory exhaustion
+ */
+static bool box_construct_marker(struct box *box, const char *title,
+ html_content *content, struct box *parent)
+{
+ lwc_string *image_uri;
+ struct box *marker;
+
+ marker = box_create(NULL, box->style, false, NULL, NULL, title,
+ NULL, content);
+ if (marker == false)
+ return false;
+
+ marker->type = BOX_BLOCK;
+
+ /** \todo marker content (list-style-type) */
+ switch (css_computed_list_style_type(box->style)) {
+ case CSS_LIST_STYLE_TYPE_DISC:
+ /* 2022 BULLET */
+ marker->text = (char *) "\342\200\242";
+ marker->length = 3;
+ break;
+ case CSS_LIST_STYLE_TYPE_CIRCLE:
+ /* 25CB WHITE CIRCLE */
+ marker->text = (char *) "\342\227\213";
+ marker->length = 3;
+ break;
+ case CSS_LIST_STYLE_TYPE_SQUARE:
+ /* 25AA BLACK SMALL SQUARE */
+ marker->text = (char *) "\342\226\252";
+ marker->length = 3;
+ break;
+ case CSS_LIST_STYLE_TYPE_DECIMAL:
+ case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
+ case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
+ case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
+ default:
+ if (parent->last) {
+ struct box *last = parent->last;
+
+ /* Drill down into last child of parent
+ * to find the list marker (if any)
+ *
+ * Floated list boxes end up as:
+ *
+ * parent
+ * BOX_INLINE_CONTAINER
+ * BOX_FLOAT_{LEFT,RIGHT}
+ * BOX_BLOCK <-- list box
+ * ...
+ */
+ while (last != NULL) {
+ if (last->list_marker != NULL)
+ break;
+
+ last = last->last;
+ }
+
+ if (last && last->list_marker) {
+ marker->rows = last->list_marker->rows + 1;
+ }
+ }
+
+ marker->text = talloc_array(content, char, 20);
+ if (marker->text == NULL)
+ return false;
+
+ snprintf(marker->text, 20, "%u.", marker->rows);
+ marker->length = strlen(marker->text);
+ break;
+ case CSS_LIST_STYLE_TYPE_NONE:
+ marker->text = 0;
+ marker->length = 0;
+ break;
+ }
+
+ if (css_computed_list_style_image(box->style, &image_uri) ==
+ CSS_LIST_STYLE_IMAGE_URI && image_uri != NULL) {
+ if (html_fetch_object(content,
+ lwc_string_data(image_uri),
+ marker, image_types,
+ content->base.available_width,
+ 1000, false) == false)
+ return false;
+ }
+
+ box->list_marker = marker;
+ marker->parent = box;
+
+ return true;
+}
+
+/**
+ * Construct the box required for a generated element.
+ *
+ * \param n XML node of type XML_ELEMENT_NODE
+ * \param content Content of type CONTENT_HTML that is being processed
+ * \param box Box which may have generated content
+ * \param style Complete computed style for pseudo element, or NULL
+ *
+ * TODO:
+ * This is currently incomplete. It just does enough to support the clearfix
+ * hack. ( http://www.positioniseverything.net/easyclearing.html )
+ */
+static void box_construct_generate(xmlNode *n, html_content *content,
+ struct box *box, const css_computed_style *style)
+{
+ struct box *gen = NULL;
+ const css_computed_content_item *c_item;
+
+ /* Nothing to generate if the parent box is not a block */
+ if (box->type != BOX_BLOCK)
+ return;
+
+ /* To determine if an element has a pseudo element, we select
+ * for it and test to see if the returned style's content
+ * property is set to normal. */
+ if (style == NULL ||
+ css_computed_content(style, &c_item) ==
+ CSS_CONTENT_NORMAL) {
+ /* No pseudo element */
+ return;
+ }
+
+ /* create box for this element */
+ if (css_computed_display(style, box_is_root(n)) == CSS_DISPLAY_BLOCK) {
+ /* currently only support block level elements */
+
+ /** \todo Not wise to drop const from the computed style */
+ gen = box_create(NULL, (css_computed_style *) style,
+ false, NULL, NULL, NULL, NULL, content);
+ if (gen == NULL) {
+ return;
+ }
+
+ /* set box type from computed display */
+ gen->type = box_map[css_computed_display(
+ style, box_is_root(n))];
+
+ box_add_child(box, gen);
+ }
+}
+
+/**
+ * Extract transient construction properties
+ *
+ * \param n Current DOM node to convert
+ * \param props Property object to populate
+ */
+static void box_extract_properties(const xmlNode *n,
+ struct box_construct_props *props)
+{
+ memset(props, 0, sizeof(*props));
+
+ props->node_is_root = box_is_root(n);
+
+ /* Extract properties from containing DOM node */
+ if (props->node_is_root == false) {
+ struct box *parent_box;
+
+ /* Find ancestor node containing parent box */
+ while (n->parent != NULL && box_for_node(n->parent) == NULL)
+ n = n->parent;
+
+ parent_box = box_for_node(n->parent);
+
+ props->parent_style = parent_box->style;
+ props->href = parent_box->href;
+ props->target = parent_box->target;
+ props->title = parent_box->title;
+
+ /* Find containing block (may be parent) */
+ for (n = n->parent; n != NULL; n = n->parent) {
+ struct box *b = box_for_node(n);
+
+ /* Children of nodes that created an inline box
+ * will generate boxes which are attached as
+ * _siblings_ of the box generated for their
+ * parent node. Note, however, that we'll still
+ * use the parent node's styling as the parent
+ * style, above. */
+ if (b != NULL && b->type != BOX_INLINE &&
+ b->type != BOX_BR) {
+ props->containing_block = b;
+ break;
+ }
+ }
+ }
+
+ /* Compute current inline container, if any */
+ if (props->containing_block != NULL &&
+ props->containing_block->last != NULL &&
+ props->containing_block->last->type ==
+ BOX_INLINE_CONTAINER)
+ props->inline_container = props->containing_block->last;
+}
+
+/**
+ * Construct the box tree for an XML element.
+ *
+ * \param ctx Tree construction context
+ * \param convert_children Whether to convert children
* \return true on success, false on memory exhaustion
*/
-bool convert_xml_to_box(xmlNode *n, html_content *content,
- const css_computed_style *parent_style,
- struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title)
-{
- switch (n->type) {
- case XML_ELEMENT_NODE:
- return box_construct_element(n, content, parent_style, parent,
- inline_container, href, target, title);
- case XML_TEXT_NODE:
- return box_construct_text(n, content, parent_style, parent,
- inline_container, href, target, title);
- default:
- /* not an element or text node: ignore it (eg. comment) */
- return true;
- }
-}
-
-
-/**
- * Construct the box tree for an XML element.
- *
- * \param n XML node of type XML_ELEMENT_NODE
- * \param content content of type CONTENT_HTML that is being processed
- * \param parent_style style at this point in xml tree, or NULL for root node
- * \param parent parent in box tree
- * \param inline_container current inline container box, or 0, updated to
- * new current inline container on exit
- * \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
- * \return true on success, false on memory exhaustion
- */
-
-bool box_construct_element(xmlNode *n, html_content *content,
- const css_computed_style *parent_style,
- struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title)
-{
- bool convert_children = true;
- char *id = 0;
- char *s;
- struct box *box = 0;
- struct box *inline_container_c;
- struct box *inline_end;
+bool box_construct_element(struct box_construct_ctx *ctx,
+ bool *convert_children)
+{
+ xmlChar *title0, *s;
+ char *id = NULL;
+ struct box *box = NULL;
css_select_results *styles = NULL;
struct element_entry *element;
- xmlChar *title0;
- xmlNode *c;
lwc_string *bgimage_uri;
-
- assert(n);
- assert(n->type == XML_ELEMENT_NODE);
- assert(parent);
- assert(inline_container);
-
- /* In case the parent is a pre block, we clear the
- * PRE_STRIP flag since it is not used if we
- * follow the pre with a tag
- */
- parent->flags &= ~PRE_STRIP;
-
- styles = box_get_style(content, parent_style, n);
- if (!styles)
- return false;
-
- /* extract title attribute, if present */
- if ((title0 = xmlGetProp(n, (const xmlChar *) "title"))) {
- char *title1 = squash_whitespace((char *) title0);
+ struct box_construct_props props;
+
+ assert(ctx->n != NULL);
+ assert(ctx->n->type == XML_ELEMENT_NODE);
+
+ box_extract_properties(ctx->n, &props);
+
+ if (props.containing_block != NULL) {
+ /* In case the containing block is a pre block, we clear
+ * the PRE_STRIP flag since it is not used if we follow
+ * the pre with a tag */
+ props.containing_block->flags &= ~PRE_STRIP;
+ }
+
+ styles = box_get_style(ctx->content, props.parent_style, ctx->n);
+ if (styles == NULL)
+ return false;
+
+ /* Extract title attribute, if present */
+ if ((title0 = xmlGetProp(ctx->n, (const xmlChar *) "title")) != NULL) {
+ char *t = squash_whitespace((char *) title0);
xmlFree(title0);
- if (!title1)
- return false;
-
- title = talloc_strdup(content, title1);
-
- free(title1);
-
- if (!title)
- return false;
- }
-
- /* extract id attribute, if present */
- if (!box_get_attribute(n, "id", content, &id))
- return false;
-
- /* create box for this element */
+ if (t == NULL)
+ return false;
+
+ props.title = talloc_strdup(ctx->content, t);
+
+ free(t);
+
+ if (props.title == NULL)
+ return false;
+ }
+
+ /* Extract id attribute, if present */
+ if (box_get_attribute(ctx->n, "id", ctx->content, &id) == false)
+ return false;
+
box = box_create(styles, styles->styles[CSS_PSEUDO_ELEMENT_NONE], false,
- href, target, title, id, content);
- if (!box)
- return false;
- /* set box type from computed display */
+ props.href, props.target, props.title, id,
+ ctx->content);
+ if (box == NULL)
+ return false;
+
+ /* If this is the root box, add it to the context */
+ if (props.node_is_root)
+ ctx->root_box = box;
+
+ /* Deal with colspan/rowspan */
+ if ((s = xmlGetProp(ctx->n, (const xmlChar *) "colspan")) != NULL) {
+ if ('0' <= s[0] && s[0] <= '9')
+ box->columns = strtol((char *) s, NULL, 10);
+
+ xmlFree(s);
+ }
+
+ if ((s = xmlGetProp(ctx->n, (const xmlChar *) "rowspan")) != NULL) {
+ if ('0' <= s[0] && s[0] <= '9')
+ box->rows = strtol((char *) s, NULL, 10);
+
+ xmlFree(s);
+ }
+
+ /* Set box type from computed display */
if ((css_computed_position(box->style) == CSS_POSITION_ABSOLUTE ||
css_computed_position(box->style) ==
CSS_POSITION_FIXED) &&
- (css_computed_display_static(box->style) ==
+ (css_computed_display_static(box->style) ==
CSS_DISPLAY_INLINE ||
- css_computed_display_static(box->style) ==
+ css_computed_display_static(box->style) ==
CSS_DISPLAY_INLINE_BLOCK ||
- css_computed_display_static(box->style) ==
+ css_computed_display_static(box->style) ==
CSS_DISPLAY_INLINE_TABLE)) {
/* Special case for absolute positioning: make absolute inlines
- * into inline block so that the boxes are constructed in an
- * inline container as if they were not absolutely positioned.
+ * into inline block so that the boxes are constructed in an
+ * inline container as if they were not absolutely positioned.
* Layout expects and handles this. */
box->type = box_map[CSS_DISPLAY_INLINE_BLOCK];
} else {
/* Normal mapping */
box->type = box_map[css_computed_display(box->style,
- n->parent == NULL)];
- }
-
- /* handle the :before pseudo element */
-
- /* TODO: Replace with true implementation.
- * Currently we only implement enough of this to support the
- * 'clearfix' hack, which is in widespread use and the layout
- * of many sites depend on. As such, only bother if box is a
- * block for now. */
- if (box->type == BOX_BLOCK) {
- box_construct_generate(n, content, box,
- box->styles->styles[CSS_PSEUDO_ELEMENT_BEFORE]);
- }
-
- /* special elements */
- element = bsearch((const char *) n->name, element_table,
+ props.node_is_root)];
+ }
+
+ /* Handle the :before pseudo element */
+ box_construct_generate(ctx->n, ctx->content, box,
+ box->styles->styles[CSS_PSEUDO_ELEMENT_BEFORE]);
+
+ /* Special elements */
+ element = bsearch((const char *) ctx->n->name, element_table,
ELEMENT_TABLE_COUNT, sizeof(element_table[0]),
(int (*)(const void *, const void *)) strcmp);
- if (element) {
- /* a special convert function exists for this element */
- if (!element->convert(n, content, box, &convert_children))
- return false;
-
- href = box->href;
- target = box->target;
+ if (element != NULL) {
+ /* A special convert function exists for this element */
+ if (element->convert(ctx->n, ctx->content, box,
+ convert_children) == false)
+ return false;
}
if (box->type == BOX_NONE || css_computed_display(box->style,
- n->parent == NULL) == CSS_DISPLAY_NONE) {
- /* Free style and invalidate box's style pointer */
+ props.node_is_root) == CSS_DISPLAY_NONE) {
css_select_results_destroy(styles);
box->styles = NULL;
box->style = NULL;
- /* If this box has an associated gadget, invalidate the
- * gadget's box pointer and our pointer to the gadget. */
- if (box->gadget) {
+ /* Invalidate associated gadget, if any */
+ if (box->gadget != NULL) {
box->gadget->box = NULL;
box->gadget = NULL;
}
- /* We can't do this, as it will destroy any gadget
- * associated with the box, thus making any form usage
- * access freed memory. The box is in the talloc context,
- * anyway, so will get cleaned up with the content. */
+ /* Can't do this, because the lifetimes of boxes and gadgets
+ * are inextricably linked. Fortunately, talloc will save us
+ * (for now) */
/* box_free_box(box); */
+
+ *convert_children = false;
+
return true;
}
- if (!*inline_container &&
+ /* Attach box to DOM node */
+ ((binding_private *) ctx->n->_private)->box = box;
+
+ if (props.inline_container == NULL &&
(box->type == BOX_INLINE ||
- box->type == BOX_BR ||
- box->type == BOX_INLINE_BLOCK ||
- css_computed_float(box->style) == CSS_FLOAT_LEFT ||
- css_computed_float(box->style) == CSS_FLOAT_RIGHT)) {
- /* this is the first inline in a block: make a container */
- *inline_container = box_create(NULL, 0, false, 0, 0, 0, 0,
- content);
- if (!*inline_container)
- return false;
-
- (*inline_container)->type = BOX_INLINE_CONTAINER;
-
- box_add_child(parent, *inline_container);
- }
+ box->type == BOX_BR ||
+ box->type == BOX_INLINE_BLOCK ||
+ css_computed_float(box->style) == CSS_FLOAT_LEFT ||
+ css_computed_float(box->style) == CSS_FLOAT_RIGHT)) {
+ /* Found an inline child of a block without a current container
+ * (i.e. this box is the first child of its parent, or was
+ * preceded by block-level siblings) */
+ assert(props.containing_block != NULL &&
+ "Root box must not be inline or floated");
+
+ props.inline_container = box_create(NULL, NULL, false, NULL,
+ NULL, NULL, NULL, ctx->content);
+ if (props.inline_container == NULL)
+ return false;
+
+ props.inline_container->type = BOX_INLINE_CONTAINER;
+
+ box_add_child(props.containing_block, props.inline_container);
+ }
+
+ /* Kick off fetch for any background image */
+ if (css_computed_background_image(box->style, &bgimage_uri) ==
+ CSS_BACKGROUND_IMAGE_IMAGE && bgimage_uri != NULL) {
+ if (html_fetch_object(ctx->content,
+ lwc_string_data(bgimage_uri),
+ box, image_types,
+ ctx->content->base.available_width, 1000,
+ true) == false)
+ return false;
+ }
+
+ if (*convert_children)
+ box->flags |= CONVERT_CHILDREN;
+
+ if (box->type == BOX_INLINE || box->type == BOX_BR ||
+ box->type == BOX_INLINE_BLOCK) {
+ /* Inline container must exist, as we'll have
+ * created it above if it didn't */
+ assert(props.inline_container != NULL);
+
+ box_add_child(props.inline_container, box);
+ } else {
+ if (css_computed_display(box->style, props.node_is_root) ==
+ CSS_DISPLAY_LIST_ITEM) {
+ /* List item: compute marker */
+ if (box_construct_marker(box, props.title, ctx->content,
+ props.containing_block) == false)
+ return false;
+ }
+
+ if (css_computed_float(box->style) == CSS_FLOAT_LEFT ||
+ css_computed_float(box->style) ==
+ CSS_FLOAT_RIGHT) {
+ /* Float: insert a float between the parent and box. */
+ struct box *flt = box_create(NULL, NULL, false,
+ props.href, props.target, props.title,
+ NULL, ctx->content);
+ if (flt == NULL)
+ return false;
+
+ if (css_computed_float(box->style) == CSS_FLOAT_LEFT)
+ flt->type = BOX_FLOAT_LEFT;
+ else
+ flt->type = BOX_FLOAT_RIGHT;
+
+ box_add_child(props.inline_container, flt);
+ box_add_child(flt, box);
+ } else {
+ /* Non-floated block-level box: add to containing block
+ * if there is one. If we're the root box, then there
+ * won't be. */
+ if (props.containing_block != NULL)
+ box_add_child(props.containing_block, box);
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Complete construction of the box tree for an element.
+ *
+ * \param n DOM node to construct for
+ * \param content Containing document
+ *
+ * This will be called after all children of an element have been processed
+ */
+void box_construct_element_after(xmlNode *n, html_content *content)
+{
+ struct box_construct_props props;
+ struct box *box = box_for_node(n);
+
+ assert(box != NULL);
+
+ box_extract_properties(n, &props);
if (box->type == BOX_INLINE || box->type == BOX_BR) {
- /* inline box: add to tree and recurse */
- box_add_child(*inline_container, box);
-
- if (convert_children && n->children) {
- for (c = n->children; c; c = c->next)
- if (!convert_xml_to_box(c, content, box->style,
- parent, inline_container,
- href, target, title))
- return false;
-
- inline_end = box_create(NULL, box->style, false, href,
- target, title, id, content);
- if (!inline_end)
- return false;
-
+ /* Insert INLINE_END into containing block */
+ struct box *inline_end;
+
+ if (n->children == NULL ||
+ (box->flags & CONVERT_CHILDREN) == 0) {
+ /* No children, or didn't want children converted */
+ return;
+ }
+
+ if (props.inline_container == NULL) {
+ /* Create inline container if we don't have one */
+ props.inline_container = box_create(NULL, NULL, false,
+ NULL, NULL, NULL, NULL, content);
+ if (props.inline_container == NULL)
+ return;
+
+ props.inline_container->type = BOX_INLINE_CONTAINER;
+
+ box_add_child(props.containing_block,
+ props.inline_container);
+ }
+
+ inline_end = box_create(NULL, box->style, false,
+ box->href, box->target, box->title,
+ box->id, content);
+ if (inline_end != NULL) {
inline_end->type = BOX_INLINE_END;
- if (*inline_container)
- box_add_child(*inline_container, inline_end);
- else
- box_add_child(box->parent, inline_end);
+ assert(props.inline_container != NULL);
+
+ box_add_child(props.inline_container, inline_end);
box->inline_end = inline_end;
inline_end->inline_end = box;
}
- } else if (box->type == BOX_INLINE_BLOCK) {
- /* inline block box: add to tree and recurse */
- box_add_child(*inline_container, box);
-
- inline_container_c = 0;
-
- for (c = n->children; convert_children && c; c = c->next)
- if (!convert_xml_to_box(c, content, box->style, box,
- &inline_container_c,
- href, target, title))
- return false;
} else {
- /* list item: compute marker, then treat as non-inline box */
- if (css_computed_display(box->style, n->parent == NULL) ==
- CSS_DISPLAY_LIST_ITEM) {
- lwc_string *image_uri;
- struct box *marker;
-
- marker = box_create(NULL, box->style, false, 0, 0,
- title, 0, content);
- if (!marker)
- return false;
-
- marker->type = BOX_BLOCK;
-
- /** \todo marker content (list-style-type) */
- switch (css_computed_list_style_type(box->style)) {
- case CSS_LIST_STYLE_TYPE_DISC:
- /* 2022 BULLET */
- marker->text = (char *) "\342\200\242";
- marker->length = 3;
- break;
- case CSS_LIST_STYLE_TYPE_CIRCLE:
- /* 25CB WHITE CIRCLE */
- marker->text = (char *) "\342\227\213";
- marker->length = 3;
- break;
- case CSS_LIST_STYLE_TYPE_SQUARE:
- /* 25AA BLACK SMALL SQUARE */
- marker->text = (char *) "\342\226\252";
- marker->length = 3;
- break;
- case CSS_LIST_STYLE_TYPE_DECIMAL:
- case CSS_LIST_STYLE_TYPE_LOWER_ALPHA:
- case CSS_LIST_STYLE_TYPE_LOWER_ROMAN:
- case CSS_LIST_STYLE_TYPE_UPPER_ALPHA:
- case CSS_LIST_STYLE_TYPE_UPPER_ROMAN:
- default:
- if (parent->last) {
- struct box *last = parent->last;
-
- /* Drill down into last child of parent
- * to find the list marker (if any)
- *
- * Floated list boxes end up as:
- *
- * parent
- * BOX_INLINE_CONTAINER
- * BOX_FLOAT_{LEFT,RIGHT}
- * BOX_BLOCK <-- list box
- * ...
- */
- while (last != NULL) {
- if (last->list_marker != NULL)
- break;
-
- last = last->last;
- }
-
- if (last && last->list_marker) {
- marker->rows = last->
- list_marker->rows + 1;
- }
- }
-
- marker->text = talloc_array(content, char, 20);
- if (!marker->text)
- return false;
-
- snprintf(marker->text, 20, "%u.", marker->rows);
- marker->length = strlen(marker->text);
- break;
- case CSS_LIST_STYLE_TYPE_NONE:
- marker->text = 0;
- marker->length = 0;
- break;
- }
-
- if (css_computed_list_style_image(box->style,
- &image_uri) ==
- CSS_LIST_STYLE_IMAGE_URI &&
- image_uri != NULL) {
- if (!html_fetch_object(content,
- lwc_string_data(image_uri),
- marker, image_types,
- content->base.available_width,
- 1000, false))
- return false;
- }
-
- box->list_marker = marker;
- marker->parent = box;
- }
-
- /* float: insert a float box between the parent and
- * current node. Note: new parent will be the float */
- if (css_computed_float(box->style) == CSS_FLOAT_LEFT ||
- css_computed_float(box->style) ==
- CSS_FLOAT_RIGHT) {
- parent = box_create(NULL, 0, false, href, target, title,
- 0, content);
- if (!parent)
- return false;
-
- if (css_computed_float(box->style) == CSS_FLOAT_LEFT)
- parent->type = BOX_FLOAT_LEFT;
- else
- parent->type = BOX_FLOAT_RIGHT;
-
- box_add_child(*inline_container, parent);
- }
-
- /* non-inline box: add to tree and recurse */
- box_add_child(parent, box);
-
- inline_container_c = 0;
-
- for (c = n->children; convert_children && c; c = c->next)
- if (!convert_xml_to_box(c, content, box->style, box,
- &inline_container_c,
- href, target, title))
- return false;
-
- if (css_computed_float(box->style) == CSS_FLOAT_NONE)
- /* new inline container unless this is a float */
- *inline_container = 0;
- }
-
- /* misc. attributes that can't be handled in box_get_style() */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "colspan"))) {
- if (isdigit(s[0])) {
- box->columns = strtol(s, NULL, 10);
- }
- xmlFree(s);
- }
-
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "rowspan"))) {
- if (isdigit(s[0])) {
- box->rows = strtol(s, NULL, 10);
- }
- xmlFree(s);
- }
-
- /* fetch any background image for this box */
- if (css_computed_background_image(box->style, &bgimage_uri) ==
- CSS_BACKGROUND_IMAGE_IMAGE &&
- bgimage_uri != NULL) {
- if (!html_fetch_object(content,
- lwc_string_data(bgimage_uri),
- box, image_types, content->base.available_width,
- 1000, true))
- return false;
- }
-
- /* handle the :after pseudo element */
-
- /* TODO: Replace with true implementation.
- * Currently we only implement enough of this to support the
- * 'clearfix' hack, which is in widespread use and the layout
- * of many sites depend on. As such, only bother if box is a
- * block for now. */
- if (box->type == BOX_BLOCK) {
+ /* Handle the :after pseudo element */
box_construct_generate(n, content, box,
box->styles->styles[CSS_PSEUDO_ELEMENT_AFTER]);
}
-
- return true;
-}
-
-/**
- * Construct the box required for a generated element.
- *
- * \param n XML node of type XML_ELEMENT_NODE
- * \param content content of type CONTENT_HTML that is being processed
- * \param box box which may have generated content
- * \param style complete computed style for pseudo element
- *
- * TODO:
- * This is currently incomplete. It just does enough to support the clearfix
- * hack. ( http://www.positioniseverything.net/easyclearing.html )
- *
- * To determine if an element has a pseudo element, we select for it and test to
- * see if the returned style's content property is set to normal.
- *
- * We don't actually support generated content yet.
- */
-
-void box_construct_generate(xmlNode *n, html_content *content,
- struct box *box, const css_computed_style *style)
-{
- struct box *gen = NULL;
- const css_computed_content_item *c_item;
-
- if (style == NULL ||
- css_computed_content(style, &c_item) ==
- CSS_CONTENT_NORMAL) {
- /* No pseudo element */
- return;
- }
-
- /* create box for this element */
- if (css_computed_display(style, n->parent == NULL) ==
- CSS_DISPLAY_BLOCK) {
- /* currently only support block level after elements */
-
- /** \todo Not wise to drop const from the computed style */
- gen = box_create(NULL, (css_computed_style *) style,
- false, NULL, NULL, NULL, NULL, content);
- if (gen == NULL) {
- return;
- }
-
- /* set box type from computed display */
- gen->type = box_map[css_computed_display(
- style, n->parent == NULL)];
-
- box_add_child(box, gen);
- }
-}
-
+}
/**
* Construct the box tree for an XML text node.
*
- * \param n XML node of type XML_TEXT_NODE
- * \param content content of type CONTENT_HTML that is being processed
- * \param parent_style style at this point in xml tree
- * \param parent parent in box tree
- * \param inline_container current inline container box, or 0, updated to
- * new current inline container on exit
- * \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 ctx Tree construction context
* \return true on success, false on memory exhaustion
*/
-bool box_construct_text(xmlNode *n, html_content *content,
- const css_computed_style *parent_style,
- struct box *parent, struct box **inline_container,
- char *href, const char *target, char *title)
-{
- struct box *box = 0;
-
- assert(n);
- assert(n->type == XML_TEXT_NODE);
- assert(parent_style);
- assert(parent);
- assert(inline_container);
-
- if (css_computed_white_space(parent_style) == CSS_WHITE_SPACE_NORMAL ||
- css_computed_white_space(parent_style) ==
+bool box_construct_text(struct box_construct_ctx *ctx)
+{
+ struct box_construct_props props;
+ struct box *box = NULL;
+
+ assert(ctx->n != NULL);
+ assert(ctx->n->type == XML_TEXT_NODE);
+
+ box_extract_properties(ctx->n, &props);
+
+ assert(props.containing_block != NULL);
+
+ if (css_computed_white_space(props.parent_style) ==
+ CSS_WHITE_SPACE_NORMAL ||
+ css_computed_white_space(props.parent_style) ==
CSS_WHITE_SPACE_NOWRAP) {
- char *text = squash_whitespace((char *) n->content);
- if (!text)
+ char *text = squash_whitespace((char *) ctx->n->content);
+ if (text == NULL)
return false;
/* if the text is just a space, combine it with the preceding
* text node, if any */
if (text[0] == ' ' && text[1] == 0) {
- if (*inline_container) {
- if ((*inline_container)->last == 0) {
- LOG(("empty inline_container %p",
- *inline_container));
- while (parent->parent &&
- parent->parent->parent)
- parent = parent->parent;
- box_dump(stderr, parent, 0);
- }
-
- assert((*inline_container)->last != 0);
-
- (*inline_container)->last->space =
+ if (props.inline_container != NULL) {
+ assert(props.inline_container->last != NULL);
+
+ props.inline_container->last->space =
UNKNOWN_WIDTH;
}
@@ -692,33 +843,38 @@
return true;
}
- if (!*inline_container) {
- /* this is the first inline node: make a container */
- *inline_container = box_create(NULL, 0, false, 0, 0, 0,
- 0, content);
- if (!*inline_container) {
+ if (props.inline_container == NULL) {
+ /* Child of a block without a current container
+ * (i.e. this box is the first child of its parent, or
+ * was preceded by block-level siblings) */
+ props.inline_container = box_create(NULL, NULL, false,
+ NULL, NULL, NULL, NULL, ctx->content);
+ if (props.inline_container == NULL) {
free(text);
return false;
}
- (*inline_container)->type = BOX_INLINE_CONTAINER;
-
- box_add_child(parent, *inline_container);
+ props.inline_container->type = BOX_INLINE_CONTAINER;
+
+ box_add_child(props.containing_block,
+ props.inline_container);
}
/** \todo Dropping const here is not clever */
- box = box_create(NULL, (css_computed_style *) parent_style,
- false, href, target, title, 0, content);
- if (!box) {
+ box = box_create(NULL,
+ (css_computed_style *) props.parent_style,
+ false, props.href, props.target, props.title,
+ NULL, ctx->content);
+ if (box == NULL) {
free(text);
return false;
}
box->type = BOX_TEXT;
- box->text = talloc_strdup(content, text);
+ box->text = talloc_strdup(ctx->content, text);
free(text);
- if (!box->text)
+ if (box->text == NULL)
return false;
box->length = strlen(box->text);
@@ -729,12 +885,13 @@
box->length--;
}
- if (css_computed_text_transform(parent_style) !=
+ if (css_computed_text_transform(props.parent_style) !=
CSS_TEXT_TRANSFORM_NONE)
box_text_transform(box->text, box->length,
- css_computed_text_transform(parent_style));
-
- if (css_computed_white_space(parent_style) ==
+ css_computed_text_transform(
+ props.parent_style));
+
+ if (css_computed_white_space(props.parent_style) ==
CSS_WHITE_SPACE_NOWRAP) {
unsigned int i;
@@ -755,7 +912,7 @@
}
}
- box_add_child(*inline_container, box);
+ box_add_child(props.inline_container, box);
if (box->text[0] == ' ') {
box->length--;
@@ -765,40 +922,42 @@
if (box->prev != NULL)
box->prev->space = UNKNOWN_WIDTH;
}
-
} else {
/* white-space: pre */
- char *text = cnv_space2nbsp((char *) n->content);
+ char *text = cnv_space2nbsp((char *) ctx->n->content);
char *current;
enum css_white_space_e white_space =
- css_computed_white_space(parent_style);
+ css_computed_white_space(props.parent_style);
/* note: pre-wrap/pre-line are unimplemented */
assert(white_space == CSS_WHITE_SPACE_PRE ||
white_space == CSS_WHITE_SPACE_PRE_LINE ||
white_space == CSS_WHITE_SPACE_PRE_WRAP);
- if (!text)
- return false;
-
- if (css_computed_text_transform(parent_style) !=
+ if (text == NULL)
+ return false;
+
+ if (css_computed_text_transform(props.parent_style) !=
CSS_TEXT_TRANSFORM_NONE)
box_text_transform(text, strlen(text),
- css_computed_text_transform(parent_style));
+ css_computed_text_transform(
+ props.parent_style));
current = text;
/* swallow a single leading new line */
- if (parent->flags & PRE_STRIP) {
+ if (props.containing_block->flags & PRE_STRIP) {
switch (*current) {
case '\n':
- current++; break;
+ current++;
+ break;
case '\r':
current++;
- if (*current == '\n') current++;
+ if (*current == '\n')
+ current++;
break;
}
- parent->flags &= ~PRE_STRIP;
+ props.containing_block->flags &= ~PRE_STRIP;
}
do {
@@ -807,40 +966,47 @@
current[len] = 0;
- if (!*inline_container) {
- *inline_container = box_create(NULL, 0, false,
- 0, 0, 0, 0, content);
- if (!*inline_container) {
+ if (props.inline_container == NULL) {
+ /* Child of a block without a current container
+ * (i.e. this box is the first child of its
+ * parent, or was preceded by block-level
+ * siblings) */
+ props.inline_container = box_create(NULL, NULL,
+ false, NULL, NULL, NULL, NULL,
+ ctx->content);
+ if (props.inline_container == NULL) {
free(text);
return false;
}
- (*inline_container)->type =
+ props.inline_container->type =
BOX_INLINE_CONTAINER;
- box_add_child(parent, *inline_container);
+ box_add_child(props.containing_block,
+ props.inline_container);
}
/** \todo Dropping const isn't clever */
box = box_create(NULL,
- (css_computed_style *) parent_style,
- false, href, target, title, 0, content);
- if (!box) {
+ (css_computed_style *) props.parent_style,
+ false, props.href, props.target, props.title,
+ NULL, ctx->content);
+ if (box == NULL) {
free(text);
return false;
}
box->type = BOX_TEXT;
- box->text = talloc_strdup(content, current);
- if (!box->text) {
+ box->text = talloc_strdup(ctx->content, current);
+ if (box->text == NULL) {
free(text);
return false;
}
box->length = strlen(box->text);
- box_add_child(*inline_container, box);
+ box_add_child(props.inline_container, box);
current[len] = old;
@@ -848,10 +1014,10 @@
if (current[0] == '\r' && current[1] == '\n') {
current += 2;
- *inline_container = 0;
+ props.inline_container = NULL;
} else if (current[0] != 0) {
current++;
- *inline_container = 0;
+ props.inline_container = NULL;
}
} while (*current);
Modified: trunk/netsurf/render/html.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html.c?rev=12912&r...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Thu Sep 29 14:15:54 2011
@@ -83,6 +83,7 @@
static content_type html_content_type(void);
static void html_finish_conversion(html_content *c);
+static void html_box_convert_done(html_content *c, bool success);
static nserror html_convert_css_callback(hlcache_handle *css,
const hlcache_event *event, void *pw);
static bool html_meta_refresh(html_content *c, xmlNode *head);
@@ -91,6 +92,7 @@
static bool html_process_style_element(html_content *c, unsigned int *index,
xmlNode *style);
static void html_inline_style_done(struct content_css_data *css, void *pw);
+static bool html_fetch_objects(html_content *c);
static bool html_replace_object(struct content_html_object *object,
const char *url);
static nserror html_object_callback(hlcache_handle *object,
@@ -632,16 +634,46 @@
}
/* convert xml tree to box tree */
- LOG(("XML to box"));
+ LOG(("XML to box (%p)", c));
content_set_status(&c->base, messages_get("Processing"));
content_broadcast(&c->base, CONTENT_MSG_STATUS, msg_data);
- if (xml_to_box(html, c) == false) {
+ if (xml_to_box(html, c, html_box_convert_done) == false) {
html_destroy_objects(c);
msg_data.error = messages_get("NoMemory");
content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
content_set_error(&c->base);
return;
}
+}
+
+/**
+ * Perform post-box-creation conversion of a document
+ *
+ * \param c HTML content to complete conversion of
+ * \param success Whether box tree construction was successful
+ */
+void html_box_convert_done(html_content *c, bool success)
+{
+ union content_msg_data msg_data;
+ xmlNode *html;
+
+ LOG(("Done XML to box (%p)", c));
+
+ /* Clean up and report error if unsuccessful or aborted */
+ if (success == false || c->aborted) {
+ html_destroy_objects(c);
+ if (success == false)
+ msg_data.error = messages_get("NoMemory");
+ else
+ msg_data.error = messages_get("Stopped");
+ content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
+ content_set_error(&c->base);
+ return;
+ }
+
+ html = xmlDocGetRootElement(c->document);
+ assert(html != NULL);
+
#if ALWAYS_DUMP_BOX
box_dump(stderr, c->layout->children, 0);
#endif
@@ -664,6 +696,9 @@
/* Destroy the parser binding */
binding_destroy_tree(c->parser_binding);
c->parser_binding = NULL;
+
+ /* Spawn object fetches */
+ html_fetch_objects(c);
content_set_ready(&c->base);
@@ -1334,7 +1369,7 @@
/**
- * Start a fetch for an object required by a page.
+ * Queue a fetch for an object required by a page.
*
* \param c content of type CONTENT_HTML
* \param url URL of object to fetch (copied)
@@ -1352,17 +1387,12 @@
bool background)
{
struct content_html_object *object;
- hlcache_child_context child;
char *url2;
url_func_result res;
- nserror error;
/* If we've already been aborted, don't bother attempting the fetch */
if (c->aborted)
return true;
-
- child.charset = c->encoding;
- child.quirks = c->base.quirks;
/* Normalize the URL */
res = url_normalize(url, &url2);
@@ -1383,28 +1413,43 @@
object->box = box;
object->permitted_types = permitted_types;
object->background = background;
+ object->url = url2;
- error = hlcache_handle_retrieve(url2, HLCACHE_RETRIEVE_SNIFF_TYPE,
- content__get_url(&c->base), NULL,
- html_object_callback, object, &child,
- permitted_types, &object->content);
-
- /* No longer need normalized url */
- free(url2);
-
- if (error != NSERROR_OK) {
- talloc_free(object);
- return error != NSERROR_NOMEM;
- }
-
/* add to object list */
object->next = c->object_list;
c->object_list = object;
c->num_objects++;
- c->base.active++;
-
- return error != NSERROR_NOMEM;
+
+ return true;
+}
+
+/**
+ * Start fetches for objects requested by a page
+ *
+ * \param c Content object
+ * \return true on success, false otherwise
+ */
+bool html_fetch_objects(html_content *c)
+{
+ struct content_html_object *object;
+ hlcache_child_context child;
+ nserror error;
+
+ child.charset = c->encoding;
+ child.quirks = c->base.quirks;
+
+ for (object = c->object_list; object != NULL; object = object->next) {
+ error = hlcache_handle_retrieve(object->url,
+ HLCACHE_RETRIEVE_SNIFF_TYPE,
+ content__get_url(&c->base), NULL,
+ html_object_callback, object, &child,
+ object->permitted_types, &object->content);
+ if (error == NSERROR_OK)
+ c->base.active++;
+ }
+
+ return c->base.active == c->num_objects;
}
@@ -1857,7 +1902,7 @@
binding_destroy_tree(html->parser_binding);
if (html->document != NULL)
- xmlFreeDoc(html->document);
+ binding_destroy_document(html->document);
/* Free base target */
if (html->base_target != NULL) {
@@ -1915,6 +1960,8 @@
hlcache_handle_release(victim->content);
}
+
+ free(victim->url);
html->object_list = victim->next;
talloc_free(victim);
Modified: trunk/netsurf/render/html.h
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html.h?rev=12912&r...
==============================================================================
--- trunk/netsurf/render/html.h (original)
+++ trunk/netsurf/render/html.h Thu Sep 29 14:15:54 2011
@@ -78,6 +78,7 @@
struct content *parent; /**< Parent document */
struct content_html_object *next; /**< Next in chain */
+ char *url; /**< URL of content */
struct hlcache_handle *content; /**< Content, or 0. */
struct box *box; /**< Node in box tree containing it. */
/** Bitmap of acceptable content types */
Modified: trunk/netsurf/render/html_interaction.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_interaction.c...
==============================================================================
--- trunk/netsurf/render/html_interaction.c (original)
+++ trunk/netsurf/render/html_interaction.c Thu Sep 29 14:15:54 2011
@@ -167,7 +167,7 @@
{
html_content *html = (html_content *) c;
enum { ACTION_NONE, ACTION_SUBMIT, ACTION_GO } action = ACTION_NONE;
- char *title = 0;
+ const char *title = 0;
const char *url = 0;
const char *target = 0;
char status_buffer[200];
Modified: trunk/netsurf/render/hubbub_binding.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/hubbub_binding.c?r...
==============================================================================
--- trunk/netsurf/render/hubbub_binding.c (original)
+++ trunk/netsurf/render/hubbub_binding.c Thu Sep 29 14:15:54 2011
@@ -34,6 +34,15 @@
#include "utils/log.h"
#include "utils/talloc.h"
+/**
+ * Private data attached to each DOM node
+ */
+typedef struct hubbub_private {
+ binding_private base;
+
+ uint32_t refcnt;
+} hubbub_private;
+
typedef struct hubbub_ctx {
hubbub_parser *parser;
@@ -69,6 +78,7 @@
{ "xmlns", "http://www.w3.org/2000/xmlns/" }
};
+static hubbub_private *create_private(uint32_t refcnt);
static inline char *c_string_from_hubbub_string(hubbub_ctx *ctx,
const hubbub_string *str);
static void create_namespaces(hubbub_ctx *ctx, xmlNode *root);
@@ -168,7 +178,13 @@
free(c);
return BINDING_NOMEM;
}
- c->document->_private = (void *) 0;
+ c->document->_private = create_private(0);
+ if (c->document->_private == NULL) {
+ xmlFreeDoc(c->document);
+ hubbub_parser_destroy(c->parser);
+ free(c);
+ return BINDING_NOMEM;
+ }
for (i = 0; i < sizeof(c->namespaces) / sizeof(c->namespaces[0]); i++) {
c->namespaces[i] = NULL;
@@ -200,7 +216,7 @@
hubbub_parser_destroy(c->parser);
if (c->owns_doc)
- xmlFreeDoc(c->document);
+ binding_destroy_document(c->document);
c->parser = NULL;
c->encoding = NULL;
@@ -290,7 +306,42 @@
return ctl;
}
+void binding_destroy_document(xmlDocPtr doc)
+{
+ xmlNode *n = (xmlNode *) doc;
+
+ while (n != NULL) {
+ free(n->_private);
+
+ if (n->children != NULL) {
+ n = n->children;
+ } else if (n->next != NULL) {
+ n = n->next;
+ } else {
+ while (n->parent != NULL && n->parent->next == NULL)
+ n = n->parent;
+
+ if (n->parent != NULL)
+ n = n->parent->next;
+ else
+ n = NULL;
+ }
+ }
+
+ xmlFreeDoc(doc);
+}
+
/*****************************************************************************/
+
+hubbub_private *create_private(uint32_t refcnt)
+{
+ hubbub_private *pvt = calloc(1, sizeof(*pvt));
+
+ if (pvt != NULL)
+ pvt->refcnt = refcnt;
+
+ return pvt;
+}
char *c_string_from_hubbub_string(hubbub_ctx *ctx, const hubbub_string *str)
{
@@ -328,7 +379,12 @@
free(content);
return HUBBUB_NOMEM;
}
- n->_private = (void *) (uintptr_t) 1;
+ n->_private = create_private(1);
+ if (n->_private == NULL) {
+ xmlFreeNode(n);
+ free(content);
+ return HUBBUB_NOMEM;
+ }
free(content);
@@ -374,7 +430,14 @@
free(name);
return HUBBUB_NOMEM;
}
- n->_private = (void *) (uintptr_t) 1;
+ n->_private = create_private(1);
+ if (n->_private == NULL) {
+ xmlFreeDtd(n);
+ free(system);
+ free(public);
+ free(name);
+ return HUBBUB_NOMEM;
+ }
*result = (void *) n;
@@ -413,10 +476,16 @@
free(name);
return HUBBUB_NOMEM;
}
- n->_private = (void *) (uintptr_t) 1;
+ n->_private = create_private(1);
+ if (n->_private == NULL) {
+ xmlFreeNode(n);
+ free(name);
+ return HUBBUB_NOMEM;
+ }
if (tag->n_attributes > 0 && add_attributes(ctx, (void *) n,
tag->attributes, tag->n_attributes) != HUBBUB_OK) {
+ free(n->_private);
xmlFreeNode(n);
free(name);
return HUBBUB_NOMEM;
@@ -427,6 +496,7 @@
/* Memory exhaustion */
if (form == NULL) {
+ free(n->_private);
xmlFreeNode(n);
free(name);
return HUBBUB_NOMEM;
@@ -453,7 +523,11 @@
if (n == NULL) {
return HUBBUB_NOMEM;
}
- n->_private = (void *) (uintptr_t) 1;
+ n->_private = create_private(1);
+ if (n->_private == NULL) {
+ xmlFreeNode(n);
+ return HUBBUB_NOMEM;
+ }
*result = (void *) n;
@@ -463,17 +537,18 @@
hubbub_error ref_node(void *ctx, void *node)
{
hubbub_ctx *c = (hubbub_ctx *) ctx;
+ hubbub_private *pvt;
if (node == c->document) {
xmlDoc *n = (xmlDoc *) node;
- uintptr_t count = (uintptr_t) n->_private;
-
- n->_private = (void *) (++count);
+ pvt = n->_private;
+
+ pvt->refcnt++;
} else {
xmlNode *n = (xmlNode *) node;
- uintptr_t count = (uintptr_t) n->_private;
-
- n->_private = (void *) (++count);
+ pvt = n->_private;
+
+ pvt->refcnt++;
}
return HUBBUB_OK;
@@ -482,23 +557,25 @@
hubbub_error unref_node(void *ctx, void *node)
{
hubbub_ctx *c = (hubbub_ctx *) ctx;
+ hubbub_private *pvt;
if (node == c->document) {
xmlDoc *n = (xmlDoc *) node;
- uintptr_t count = (uintptr_t) n->_private;
-
- assert(count != 0 && "Node has refcount of zero");
-
- n->_private = (void *) (--count);
+ pvt = n->_private;
+
+ assert(pvt->refcnt != 0 && "Node has refcount of zero");
+
+ pvt->refcnt--;
} else {
xmlNode *n = (xmlNode *) node;
- uintptr_t count = (uintptr_t) n->_private;
-
- assert(count != 0 && "Node has refcount of zero");
-
- n->_private = (void *) (--count);
-
- if (count == 0 && n->parent == NULL) {
+ pvt = n->_private;
+
+ assert(pvt->refcnt != 0 && "Node has refcount of zero");
+
+ pvt->refcnt--;
+
+ if (pvt->refcnt == 0 && n->parent == NULL) {
+ free(pvt);
xmlFreeNode(n);
}
}
@@ -585,13 +662,18 @@
hubbub_error clone_node(void *ctx, void *node, bool deep, void **result)
{
xmlNode *n = (xmlNode *) node;
-
- *result = xmlCopyNode(n, deep ? 1 : 2);
-
- if (*result == NULL)
- return HUBBUB_NOMEM;
-
- ((xmlNode *)(*result))->_private = (void *) (uintptr_t) 1;
+ xmlNode *copy = xmlCopyNode(n, deep ? 1 : 2);
+
+ if (copy == NULL)
+ return HUBBUB_NOMEM;
+
+ copy->_private = create_private(1);
+ if (copy->_private == NULL) {
+ xmlFreeNode(copy);
+ return HUBBUB_NOMEM;
+ }
+
+ *result = copy;
return HUBBUB_OK;
}
Modified: trunk/netsurf/render/parser_binding.h
URL: http://source.netsurf-browser.org/trunk/netsurf/render/parser_binding.h?r...
==============================================================================
--- trunk/netsurf/render/parser_binding.h (original)
+++ trunk/netsurf/render/parser_binding.h Thu Sep 29 14:15:54 2011
@@ -23,8 +23,16 @@
#include <libxml/tree.h>
+struct box;
struct form;
struct form_control;
+
+/**
+ * Private data attached to each DOM node
+ */
+typedef struct binding_private {
+ struct box *box; /**< Root box if ELEMENT node, or NULL */
+} binding_private;
typedef enum binding_error {
BINDING_OK,
@@ -57,5 +65,7 @@
struct form *binding_get_forms(void *ctx);
struct form_control *binding_get_control_for_node(void *ctx, xmlNodePtr node);
+void binding_destroy_document(xmlDocPtr doc);
+
#endif
11 years, 12 months
r12911 tlsa - /trunk/netsurf/utils/ring.h
by netsurf@semichrome.net
Author: tlsa
Date: Thu Sep 29 10:32:39 2011
New Revision: 12911
URL: http://source.netsurf-browser.org?rev=12911&view=rev
Log:
lwc version of ring function.
Modified:
trunk/netsurf/utils/ring.h
Modified: trunk/netsurf/utils/ring.h
URL: http://source.netsurf-browser.org/trunk/netsurf/utils/ring.h?rev=12911&r1...
==============================================================================
--- trunk/netsurf/utils/ring.h (original)
+++ trunk/netsurf/utils/ring.h Thu Sep 29 10:32:39 2011
@@ -81,6 +81,25 @@
if (!found) element = 0; \
} else element = 0
+/** Find the element (by hostname) in the given ring, leave it in the
+ * provided element variable
+ */
+#define RING_FINDBYLWCHOST(ring, element, lwc_hostname) \
+ /*LOG(("RING_FINDBYHOST(%s, %s)", #ring, hostname));*/ \
+ if (ring) { \
+ bool found = false; \
+ element = ring; \
+ do { \
+ if (lwc_string_isequal(element->host, lwc_hostname, \
+ &found) == lwc_error_ok && \
+ found == true) { \
+ break; \
+ } \
+ element = element->r_next; \
+ } while (element != ring); \
+ if (!found) element = 0; \
+ } else element = 0
+
/** Measure the size of a ring and put it in the supplied variable */
#define RING_GETSIZE(ringtype, ring, sizevar) \
/*LOG(("RING_GETSIZE(%s)", #ring));*/ \
11 years, 12 months
r12910 tlsa - in /trunk/netsurf/content: fetch.c fetch.h fetchers/about.c fetchers/curl.c fetchers/data.c fetchers/file.c fetchers/resource.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Sep 29 10:31:54 2011
New Revision: 12910
URL: http://source.netsurf-browser.org?rev=12910&view=rev
Log:
Convert fetchers to nsurl.
Modified:
trunk/netsurf/content/fetch.c
trunk/netsurf/content/fetch.h
trunk/netsurf/content/fetchers/about.c
trunk/netsurf/content/fetchers/curl.c
trunk/netsurf/content/fetchers/data.c
trunk/netsurf/content/fetchers/file.c
trunk/netsurf/content/fetchers/resource.c
Modified: trunk/netsurf/content/fetch.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetch.c?rev=12910...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Thu Sep 29 10:31:54 2011
@@ -317,8 +317,7 @@
goto failed;
/* Got a scheme fetcher, try and set up the fetch */
- fetch->fetcher_handle =
- fetch->ops->setup_fetch(fetch, nsurl_access(url),
+ fetch->fetcher_handle = fetch->ops->setup_fetch(fetch, url,
only_2xx, post_urlenc,
post_multipart, headers);
Modified: trunk/netsurf/content/fetch.h
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetch.h?rev=12910...
==============================================================================
--- trunk/netsurf/content/fetch.h (original)
+++ trunk/netsurf/content/fetch.h Thu Sep 29 10:31:54 2011
@@ -110,7 +110,7 @@
/* API for fetchers themselves */
typedef bool (*fetcher_initialise)(lwc_string *);
-typedef void* (*fetcher_setup_fetch)(struct fetch *, const char *,
+typedef void* (*fetcher_setup_fetch)(struct fetch *, nsurl *,
bool, const char *,
const struct fetch_multipart_data *,
const char **);
Modified: trunk/netsurf/content/fetchers/about.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/about.c?...
==============================================================================
--- trunk/netsurf/content/fetchers/about.c (original)
+++ trunk/netsurf/content/fetchers/about.c Thu Sep 29 10:31:54 2011
@@ -68,7 +68,7 @@
bool aborted; /**< Flag indicating fetch has been aborted */
bool locked; /**< Flag indicating entry is already entered */
- char *url; /**< The full url the fetch refers to */
+ nsurl *url; /**< The full url the fetch refers to */
fetch_about_handler handler;
};
@@ -396,6 +396,7 @@
bool hidden; /* Flag indicating if entry should be show in listing */
};
+/* TODO: lwc_string identifiers, since they're compared to an lwc_string */
struct about_handlers about_handler_list[] = {
{ "credits", fetch_about_credits_handler, false },
{ "licence", fetch_about_licence_handler, false },
@@ -501,7 +502,7 @@
/** callback to set up a about fetch context. */
static void *
fetch_about_setup(struct fetch *fetchh,
- const char *url,
+ nsurl *url,
bool only_2xx,
const char *post_urlenc,
const struct fetch_multipart_data *post_multipart,
@@ -509,25 +510,27 @@
{
struct fetch_about_context *ctx;
unsigned int handler_loop;
- struct url_components urlcomp;
+ lwc_string *path;
ctx = calloc(1, sizeof(*ctx));
if (ctx == NULL)
return NULL;
- url_get_components(url, &urlcomp);
+ path = nsurl_get_component(url, NSURL_PATH);
for (handler_loop = 0;
handler_loop < about_handler_list_len;
handler_loop++) {
ctx->handler = about_handler_list[handler_loop].handler;
- if (strcmp(about_handler_list[handler_loop].name, urlcomp.path) == 0)
+ if (strcmp(about_handler_list[handler_loop].name,
+ lwc_string_data(path)) == 0)
break;
}
- url_destroy_components(&urlcomp);
+ lwc_string_unref(path);
ctx->fetchh = fetchh;
+ ctx->url = nsurl_ref(url);
RING_INSERT(ring, ctx);
@@ -538,7 +541,7 @@
static void fetch_about_free(void *ctx)
{
struct fetch_about_context *c = ctx;
- free(c->url);
+ nsurl_unref(c->url);
RING_REMOVE(ring, c);
free(ctx);
}
Modified: trunk/netsurf/content/fetchers/curl.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/curl.c?r...
==============================================================================
--- trunk/netsurf/content/fetchers/curl.c (original)
+++ trunk/netsurf/content/fetchers/curl.c Thu Sep 29 10:31:54 2011
@@ -109,7 +109,7 @@
static bool fetch_curl_initialise(lwc_string *scheme);
static void fetch_curl_finalise(lwc_string *scheme);
-static void * fetch_curl_setup(struct fetch *parent_fetch, const char *url,
+static void * fetch_curl_setup(struct fetch *parent_fetch, nsurl *url,
bool only_2xx, const char *post_urlenc,
const struct fetch_multipart_data *post_multipart,
const char **headers);
@@ -324,7 +324,7 @@
* callbacks will contain this.
*/
-void * fetch_curl_setup(struct fetch *parent_fetch, const char *url,
+void * fetch_curl_setup(struct fetch *parent_fetch, nsurl *url,
bool only_2xx, const char *post_urlenc,
const struct fetch_multipart_data *post_multipart,
const char **headers)
@@ -341,7 +341,7 @@
fetch->fetch_handle = parent_fetch;
- res = url_host(url, &host);
+ res = url_host(nsurl_access(url), &host);
if (res != URL_FUNC_OK) {
/* we only fail memory exhaustion */
if (res == URL_FUNC_NOMEM)
@@ -360,7 +360,7 @@
fetch->abort = false;
fetch->stopped = false;
fetch->only_2xx = only_2xx;
- fetch->url = strdup(url);
+ fetch->url = strdup(nsurl_access(url));
fetch->headers = 0;
fetch->host = host;
fetch->location = 0;
Modified: trunk/netsurf/content/fetchers/data.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/data.c?r...
==============================================================================
--- trunk/netsurf/content/fetchers/data.c (original)
+++ trunk/netsurf/content/fetchers/data.c Thu Sep 29 10:31:54 2011
@@ -75,7 +75,7 @@
curl_easy_cleanup(curl);
}
-static void *fetch_data_setup(struct fetch *parent_fetch, const char *url,
+static void *fetch_data_setup(struct fetch *parent_fetch, nsurl *url,
bool only_2xx, const char *post_urlenc,
const struct fetch_multipart_data *post_multipart,
const char **headers)
@@ -86,7 +86,8 @@
return NULL;
ctx->parent_fetch = parent_fetch;
- ctx->url = strdup(url);
+ /* TODO: keep as nsurl to avoid copy */
+ ctx->url = strdup(nsurl_access(url));
if (ctx->url == NULL) {
free(ctx);
Modified: trunk/netsurf/content/fetchers/file.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/file.c?r...
==============================================================================
--- trunk/netsurf/content/fetchers/file.c (original)
+++ trunk/netsurf/content/fetchers/file.c Thu Sep 29 10:31:54 2011
@@ -61,7 +61,7 @@
bool aborted; /**< Flag indicating fetch has been aborted */
bool locked; /**< Flag indicating entry is already entered */
- char *url; /**< The full url the fetch refers to */
+ nsurl *url; /**< The full url the fetch refers to */
char *path; /**< The actual path to be used with open() */
time_t file_etag; /**< Request etag for file (previous st.m_time) */
@@ -113,7 +113,7 @@
/** callback to set up a file fetch context. */
static void *
fetch_file_setup(struct fetch *fetchh,
- const char *url,
+ nsurl *url,
bool only_2xx,
const char *post_urlenc,
const struct fetch_multipart_data *post_multipart,
@@ -126,18 +126,13 @@
if (ctx == NULL)
return NULL;
- ctx->path = url_to_path(url);
+ ctx->path = url_to_path(nsurl_access(url));
if (ctx->path == NULL) {
free(ctx);
return NULL;
}
- ctx->url = strdup(url);
- if (ctx->url == NULL) {
- free(ctx->path);
- free(ctx);
- return NULL;
- }
+ ctx->url = nsurl_ref(url);
/* Scan request headers looking for If-None-Match */
for (i = 0; headers[i] != NULL; i++) {
@@ -167,7 +162,7 @@
static void fetch_file_free(void *ctx)
{
struct fetch_file_context *c = ctx;
- free(c->url);
+ nsurl_unref(c->url);
free(c->path);
RING_REMOVE(ring, c);
free(ctx);
@@ -226,7 +221,7 @@
snprintf(buffer, sizeof buffer, "<html><head><title>%s</title></head>"
"<body><h1>%s</h1>"
"<p>Error %d while fetching file %s</p></body></html>",
- title, title, code, ctx->url);
+ title, title, code, nsurl_access(ctx->url));
if (fetch_file_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
FETCH_ERROR_NO_ERROR))
@@ -445,9 +440,9 @@
goto fetch_file_process_dir_aborted;
/* Print parent directory link */
- res = url_parent(ctx->url, &up);
+ res = url_parent(nsurl_access(ctx->url), &up);
if (res == URL_FUNC_OK) {
- res = url_compare(ctx->url, up, false, &compare);
+ res = url_compare(nsurl_access(ctx->url), up, false, &compare);
if ((res == URL_FUNC_OK) && compare == false) {
dirlist_generate_parent_link(up, buffer, sizeof buffer);
Modified: trunk/netsurf/content/fetchers/resource.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/resource...
==============================================================================
--- trunk/netsurf/content/fetchers/resource.c (original)
+++ trunk/netsurf/content/fetchers/resource.c Thu Sep 29 10:31:54 2011
@@ -164,7 +164,7 @@
/** callback to set up a resource fetch context. */
static void *
fetch_resource_setup(struct fetch *fetchh,
- const char *url,
+ nsurl *url,
bool only_2xx,
const char *post_urlenc,
const struct fetch_multipart_data *post_multipart,
@@ -177,7 +177,7 @@
if (ctx == NULL)
return NULL;
- url_get_components(url, &urlcomp);
+ url_get_components(nsurl_access(url), &urlcomp);
ctx->redirect_url = gui_get_resource_url(urlcomp.path);
if (ctx->redirect_url == NULL) {
@@ -186,7 +186,7 @@
ctx->handler = fetch_resource_redirect_handler;
}
- ctx->url = strdup(url);
+ ctx->url = strdup(nsurl_access(url));
url_destroy_components(&urlcomp);
11 years, 12 months
r12909 chris_y - /trunk/netsurf/amiga/resources/default.css.info
by netsurf@semichrome.net
Author: chris_y
Date: Wed Sep 28 12:12:28 2011
New Revision: 12909
URL: http://source.netsurf-browser.org?rev=12909&view=rev
Log:
Re-instate default.css.info as the install script copies it to def_css.info if there
isn't one already.
Added:
trunk/netsurf/amiga/resources/default.css.info (with props)
Added: trunk/netsurf/amiga/resources/default.css.info
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/resources/default.c...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/amiga/resources/default.css.info
------------------------------------------------------------------------------
amiga:protection = ----rw-d ---- ----
Propchange: trunk/netsurf/amiga/resources/default.css.info
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
11 years, 12 months
r12908 chris_y - /trunk/libsvgtiny/Makefile
by netsurf@semichrome.net
Author: chris_y
Date: Wed Sep 28 12:04:54 2011
New Revision: 12908
URL: http://source.netsurf-browser.org?rev=12908&view=rev
Log:
Don't treat warnings as errors on AmigaOS
Modified:
trunk/libsvgtiny/Makefile
Modified: trunk/libsvgtiny/Makefile
URL: http://source.netsurf-browser.org/trunk/libsvgtiny/Makefile?rev=12908&r1=...
==============================================================================
--- trunk/libsvgtiny/Makefile (original)
+++ trunk/libsvgtiny/Makefile Wed Sep 28 12:04:54 2011
@@ -13,12 +13,13 @@
WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wnested-externs -pedantic
-# BeOS/Haiku/AmigaOS4 standard library headers create warnings
+# BeOS/Haiku/AmigaOS standard library headers create warnings
ifneq ($(TARGET),beos)
ifneq ($(TARGET),AmigaOS)
WARNFLAGS := $(WARNFLAGS) -Werror
endif
endif
+
CFLAGS := -D_BSD_SOURCE -I$(CURDIR)/include/ \
-I$(CURDIR)/src $(WARNFLAGS) $(CFLAGS)
ifneq ($(GCCVER),2)
11 years, 12 months
r12907 vince - /trunk/netsurf/Makefile
by netsurf@semichrome.net
Author: vince
Date: Wed Sep 28 11:01:06 2011
New Revision: 12907
URL: http://source.netsurf-browser.org?rev=12907&view=rev
Log:
set default pkg-config path on Mac OS X to make default build work
Modified:
trunk/netsurf/Makefile
Modified: trunk/netsurf/Makefile
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile?rev=12907&r1=129...
==============================================================================
--- trunk/netsurf/Makefile (original)
+++ trunk/netsurf/Makefile Wed Sep 28 11:01:06 2011
@@ -238,8 +238,12 @@
PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
endif
else
- # Building for GTK, Framebuffer, Atari
- PKG_CONFIG := pkg-config
+ ifeq ($(TARGET),cocoa)
+ PKG_CONFIG := PKG_CONFIG_PATH="$(PKG_CONFIG_PATH):/usr/local/lib/pkgconfig" pkg-config
+ else
+ # Building for GTK, Framebuffer, Atari
+ PKG_CONFIG := pkg-config
+ endif
endif
endif
endif
11 years, 12 months
r12906 tlsa - in /trunk/netsurfweb: about/thanks.en webimages/logofoundry.png
by netsurf@semichrome.net
Author: tlsa
Date: Wed Sep 28 09:53:09 2011
New Revision: 12906
URL: http://source.netsurf-browser.org?rev=12906&view=rev
Log:
Thanks to The Foundry.
Added:
trunk/netsurfweb/webimages/logofoundry.png (with props)
Modified:
trunk/netsurfweb/about/thanks.en
Modified: trunk/netsurfweb/about/thanks.en
URL: http://source.netsurf-browser.org/trunk/netsurfweb/about/thanks.en?rev=12...
==============================================================================
--- trunk/netsurfweb/about/thanks.en (original)
+++ trunk/netsurfweb/about/thanks.en Wed Sep 28 09:53:09 2011
@@ -57,7 +57,17 @@
<p>We would like to thank the following organisations for their kind generosity and the help they have given us:</p>
-<h2><img class="thankslogo" src="/webimages/logoadv6.png" alt="">Advantage Six</h2>
+<ul>
+<li><a href="#AdvSix">Advantage Six</a></li>
+<li><a href="#Foundry">The Foundry</a></li>
+<li><a href="#GSoC">Google Summer of Code</a></li>
+<li><a href="#Pepperfish">Pepperfish</a></li>
+<li><a href="#Simtec">Simtec Electronics</a></li>
+</ul>
+
+<p class="updated">Last updated 28 September 2011</p>
+
+<h2 id="AdvSix"><img class="thankslogo" src="/webimages/logoadv6.png" alt="">Advantage Six</h2>
<p>Advantage Six Ltd offer design, manufacture and support services for OEM customers. One of their products is the A9home computer which runs the RISC OS operating system.</p>
@@ -68,7 +78,17 @@
<li><a href="http://www.advantagesix.co.uk/products/A9home.html">A9home computer</a></li>
</ul>
-<h2><img class="thankslogo" src="/webimages/logogsoc2008.png" alt="">Google Summer of Code</h2>
+<h2 id="Foundry"><img class="thankslogo" src="/webimages/logofoundry.png" alt="">The Foundry</h2>
+
+<p>The Foundry is a world-leading innovator of visual effects and image processing technologies that boost productivity in motion picture and video post-production. Users of their software include Hollywood movie makers such as Warner Bros, The Moving Picture Company, Weta Digital, Sony Pictures, and more.</p>
+
+<p>The Foundry donated a 1.66 GHz intel core duo powered Mac Mini running Mac OS X 10.6.8 to the NetSurf project. It has been set up to allow developers to log in and use remotely, enabling us to build and test the browser on Mac OS X.</p>
+
+<ul>
+<li><a href="http://www.thefoundry.co.uk/">The Foundry</a></li>
+</ul>
+
+<h2 id="GSoC"><img class="thankslogo" src="/webimages/logogsoc2008.png" alt="">Google Summer of Code</h2>
<p>Google Summer of Code generously offers funding for students to work on open source projects over the summer. NetSurf was selected to participate as a mentoring organisation in both the 2008 and 2009 programmes. Several excellent students worked with us and the experience proved a great success for NetSurf.</p>
@@ -90,7 +110,7 @@
<li><a href="http://socghop.appspot.com/gsoc/org/home/google/gsoc2009/netsurf">GSoC 2009 - NetSurf organisation listing</a></li>
</ul>
-<h2><img class="thankslogo" src="/webimages/logoppf.png" alt="">Pepperfish</h2>
+<h2 id="Pepperfish"><img class="thankslogo" src="/webimages/logoppf.png" alt="">Pepperfish</h2>
<p>Pepperfish is a small independent hosting provider. They generously host the NetSurf web site, mailing lists and downloads. They also take care of all our web server setup and configuration needs.</p>
@@ -98,7 +118,7 @@
<li><a href="http://www.pepperfish.net/">Pepperfish</a></li>
</ul>
-<h2><img class="thankslogo" src="/webimages/logosimtec.png" alt="">Simtec Electronics</h2>
+<h2 id="Simtec"><img class="thankslogo" src="/webimages/logosimtec.png" alt="">Simtec Electronics</h2>
<p>Simtec Electronics is an experienced electronics development and design consultancy. In addition to their range of design and manufacture services, they provide an extensive range of standard hardware and software products that include ARM processor evaluation boards, I/O modules, the ABLE boot loader firmware and an embedded USB host stack.</p>
@@ -110,7 +130,7 @@
</ul>
<div class="footer">
-<p>Copyright 2003 - 2009 The NetSurf Developers</p>
+<p>Copyright 2003 - 2011 The NetSurf Developers</p>
</div>
</div>
Added: trunk/netsurfweb/webimages/logofoundry.png
URL: http://source.netsurf-browser.org/trunk/netsurfweb/webimages/logofoundry....
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurfweb/webimages/logofoundry.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
11 years, 12 months