Gitweb links:
...log
http://git.netsurf-browser.org/libnslayout.git/shortlog/244ff9f08dd8c83ba...
...commit
http://git.netsurf-browser.org/libnslayout.git/commit/244ff9f08dd8c83baba...
...tree
http://git.netsurf-browser.org/libnslayout.git/tree/244ff9f08dd8c83baba4d...
The branch, master has been updated
via 244ff9f08dd8c83baba4d44401eae0e8ebb58246 (commit)
from c721328b2ce5775a6dbee4b8f37a8c949394c8d8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libnslayout.git/commit/?id=244ff9f08dd8c83...
commit 244ff9f08dd8c83baba4d44401eae0e8ebb58246
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add basic buildsystem.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..beb2b46
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,69 @@
+#!/bin/make
+#
+# Makefile for nslayout
+#
+# Copyright 2009-2015 John-Mark Bell <jmb(a)netsurf-browser.org>
+
+# Component settings
+COMPONENT := nslayout
+COMPONENT_VERSION := 0.0.0
+# Default to a static library
+COMPONENT_TYPE ?= lib-static
+
+# Setup the tooling
+PREFIX ?= /opt/netsurf
+NSSHARED ?= $(PREFIX)/share/netsurf-buildsystem
+include $(NSSHARED)/makefiles/Makefile.tools
+
+# Reevaluate when used, as BUILDDIR won't be defined yet
+TESTRUNNER = $(BUILDDIR)/test_testrunner$(EXEEXT)
+
+# Toolchain flags
+WARNFLAGS := -Wall -Wextra -W -Wundef -Wpointer-arith -Wcast-align \
+ -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
+ -Wmissing-declarations -Wnested-externs
+# BeOS/Haiku standard library headers issue warnings
+ifneq ($(BUILD),i586-pc-haiku)
+ WARNFLAGS := $(WARNFLAGS) -Werror
+endif
+
+CFLAGS := -D_BSD_SOURCE -D_DEFAULT_SOURCE \
+ -I$(CURDIR)/include/ -I$(CURDIR)/src \
+ $(WARNFLAGS) $(CFLAGS)
+ifneq ($(GCCVER),2)
+ CFLAGS := $(CFLAGS) -std=c99
+else
+ # __inline__ is a GCCism
+ CFLAGS := $(CFLAGS) -Dinline="__inline__"
+endif
+
+# libwapcaplet, libparserutils, libcss, libdom
+ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
+ ifneq ($(PKGCONFIG),)
+ CFLAGS := $(CFLAGS) $(shell $(PKGCONFIG) \
+ libwapcaplet libparserutils libcss libdom --cflags)
+ LDFLAGS := $(LDFLAGS) $(shell $(PKGCONFIG) \
+ libwapcaplet libparserutils libcss libdom --libs)
+ else
+ CFLAGS := $(CFLAGS) -I$(PREFIX)/include
+ LDFLAGS := $(LDFLAGS) -lparserutils -lwapcaplet -lcss -ldom
+ endif
+endif
+
+include $(NSBUILD)/Makefile.top
+
+ifeq ($(WANT_TEST),yes)
+ ifneq ($(PKGCONFIG),)
+ TESTCFLAGS := $(TESTCFLAGS) $(shell $(PKGCONFIG) --cflags check)
+ TESTLDFLAGS := $(TESTLDFLAGS) $(shell $(PKGCONFIG) --libs check)
+ else
+ TESTLDFLAGS := $(TESTLDFLAGS) -lcheck
+ endif
+endif
+
+# Extra installation rules
+I := /$(INCLUDEDIR)/lib$(COMPONENT)
+
+INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):include/lib$(COMPONENT)/libnslayout.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR)/pkgconfig:lib$(COMPONENT).pc.in
+INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR):$(OUTPUT)
diff --git a/include/libnslayout/nslayout.h b/include/libnslayout/nslayout.h
new file mode 100644
index 0000000..a720b32
--- /dev/null
+++ b/include/libnslayout/nslayout.h
@@ -0,0 +1,211 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ * Copyright 2015 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+#ifndef nslayout_nslayout_h_
+#define nslayout_nslayout_h_
+
+#include <libcss/libcss.h>
+#include <dom/dom.h>
+
+/** An opaque client-owned replaced element */
+typedef void nslayout_replaced;
+
+/** A rectangle */
+typedef struct nslayout_rect {
+ int x;
+ int y;
+ int w;
+ int h;
+} nslayout_rect;
+
+/** Render list */
+typedef struct nslayout_render_list {
+} nslayout_render_list;
+
+/** Render list */
+typedef struct nslayout_layout nslayout_layout;
+
+/**
+ * A LibNSLayout request
+ *
+ * Passed to the client via nslayout_callback
+ */
+typedef struct nslayout_request {
+ /** Request type */
+ enum type {
+ NSLAYOUT_GET_RESOURCE,
+ NSLAYOUT_CREATE_REPLACED,
+ NSLAYOUT_RENDER,
+ NSLAYOUT_SET_EXTENTS,
+ NSLAYOUT_GET_INTRINSIC_SIZE
+ } type;
+ /** Request's type-specific parameters */
+ union {
+ struct {
+ const char *url; /**< Absolute URL */
+ } get_resource;
+ struct {
+ dom_element *element; /**< DOM element */
+ } create_replaced;
+ struct {
+ nslayout_render_list *list; /**< Render list */
+ } render;
+ struct {
+ unsigned int width; /**< Document width in px */
+ unsigned int height; /**< Document height in px */
+ } set_extents;
+ struct {
+ nslayout_replaced *replaced; /** A replacement object */
+ } get_intrinsic_size;
+ } request;
+ /** Request's type-specific return values */
+ union {
+ struct {
+ nslayout_replaced **replaced; /** Replacement object */
+ } get_resource;
+ struct {
+ nslayout_replaced **replaced; /** Replacement object */
+ } create_replaced;
+ struct {
+ unsigned int *width; /** Replacement object's width */
+ unsigned int *height; /** Replacement object's height */
+ } get_intrinsic_size;
+ } response;
+} nslayout_request;
+
+/** Libnslayout return codes */
+typedef enum nslayout_error {
+ NSLAYOUT_OK,
+ NSLAYOUT_NO_MEM
+} nslayout_error;
+
+/**
+ * Initialise LibNSLayout
+ *
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_init(void);
+
+/**
+ * Finalise LibNSLayout
+ *
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_fini(void);
+
+/**
+ * LibNSLayout client callback function
+ *
+ * \param req The request details.
+ * \param layout The layout we're making a request for.
+ * \param pw The client's private data for this layout.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+typedef nslayout_error (*nslayout_callback)(
+ nslayout_request *req,
+ nslayout_layout *layout,
+ void *pw);
+
+/**
+ * Create a Layout object for a given DOM
+ *
+ * \param doc The LibDOM document to build a layout for.
+ * \param css_ctx The LibCSS selection context for the document.
+ * \param media The LibCSS media to use when selecting for this layout.
+ * \param cb The client's private data for this layout.
+ * \param pw The client's private data for this layout.
+ * \param layout Returns a pointer to the created layout object.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_layout_create(
+ dom_document *doc,
+ css_select_ctx *css_ctx,
+ css_media_type *media,
+ nslayout_callback *cb,
+ void *pw,
+ nslayout_layout **layout);
+
+/**
+ * Destroy a Layout object
+ *
+ * \param layout Returns a pointer to the created layout object.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_layout_destroy(
+ nslayout_layout *layout);
+
+/**
+ * Update the viewport for a layout
+ *
+ * Note: Before this is called, the layout engine will create internal
+ * data structures for the document, but will not start to position
+ * things and will not emit render lists.
+ *
+ * \param layout Layout to set viewport for.
+ * \param viewport Viewport dimensions and offset.
+ * \param scale Rendering scale.
+ * \param dpi DPI of render target with viewport.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_update_viewport(
+ nslayout_layout *layout,
+ nslayout_rect *viewport,
+ css_fixed scale,
+ unsigned int dpi);
+
+/**
+ * Find the top-most element at a given point, in terms of z-order.
+ *
+ * \param layout Layout to locate an element in.
+ * \param element Updated to area with position relative to viewport.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_element_get_location(
+ nslayout_layout *layout,
+ nslayout_rect *area);
+
+/**
+ * Find the top-most element at a given point, in terms of z-order.
+ *
+ * \param layout Layout to find an element in.
+ * \param x Mouse x-coordinate (viewport relative).
+ * \param y Mouse y-coordinate (viewport relative).
+ * \param element Updated to point at the element we found.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_element_at_point(
+ nslayout_layout *layout,
+ unsigned int x,
+ unsigned int y,
+ dom_event_target **element);
+
+/**
+ * Mark an element (or part of it) as needing redraw.
+ *
+ * \param layout Layout to indicate redraw is required for.
+ * \param element Element to mark as needing redraw.
+ * \param rel_area Area of element to redraw relative to object's top-left.
+ * May be NULL, to redraw whole element.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_layout_dirty_element(
+ nslayout_layout *layout,
+ dom_element *element,
+ nslayout_rect *rel_area);
+
+/**
+ * Mark an area as needing redraw.
+ *
+ * \param layout Layout to indicate redraw is required for.
+ * \param area Area to redraw relative to viewport's top-left.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_layout_dirty_area(
+ nslayout_layout *layout,
+ nslayout_rect *area);
+
+#endif
diff --git a/include/nslayout.c b/include/nslayout.c
deleted file mode 100644
index 1144e4b..0000000
--- a/include/nslayout.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * This file is part of LibNSLayout
- * Licensed under the ISC License,
http://opensource.org/licenses/ISC
- * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
- * Copyright 2015 John-Mark Bell <jmb(a)netsurf-browser.org>
- */
-
-/** An opaque client-owned replaced element */
-typedef void nslayout_replaced;
-
-/** A rectangle */
-typedef struct nslayout_rect {
- int x;
- int y;
- int w;
- int h;
-} nslayout_rect;
-
-/**
- * A LibNSLayout request
- *
- * Passed to the client via nslayout_callback
- */
-typedef struct nslayout_request {
- /** Request type */
- enum type {
- NSLAYOUT_GET_RESOURCE,
- NSLAYOUT_CREATE_REPLACED,
- NSLAYOUT_RENDER,
- NSLAYOUT_SET_EXTENTS,
- NSLAYOUT_GET_INTRINSIC_SIZE
- } type;
- /** Request's type-specific parameters */
- union {
- struct {
- const char *url; /**< Absolute URL */
- } get_resource;
- struct {
- dom_element *element; /**< DOM element */
- } create_replaced;
- struct {
- nslayout_render_list *list; /**< Render list */
- } render;
- struct {
- width; /**< Document width in px */
- height; /**< Document height in px */
- } set_extents;
- struct {
- nslayout_replaced *replaced; /** A replacement object */
- } get_intrinsic_size;
- } request;
- /** Request's type-specific return values */
- union {
- struct {
- nslayout_replaced **replaced; /** Replacement object */
- } get_resource;
- struct {
- nslayout_replaced **replaced; /** Replacement object */
- } create_replaced;
- struct {
- unsigned int *width; /** Replacement object's width */
- unsigned int *height; /** Replacement object's height */
- } get_intrinsic_size;
- } response;
-} nslayout_request;
-
-/**
- * Initialise LibNSLayout
- *
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_init(void);
-
-/**
- * Finalise LibNSLayout
- *
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_fini(void);
-
-/**
- * LibNSLayout client callback function
- *
- * \param req The request details.
- * \param layout The layout we're making a request for.
- * \param pw The client's private data for this layout.
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-typedef nslayout_error (*nslayout_callback)(
- nslayout_request *req,
- nslayout_layout *layout,
- void *pw);
-
-/**
- * Create a Layout object for a given DOM
- *
- * \param doc The LibDOM document to build a layout for.
- * \param css_ctx The LibCSS selection context for the document.
- * \param media The LibCSS media to use when selecting for this layout.
- * \param cb The client's private data for this layout.
- * \param pw The client's private data for this layout.
- * \param layout Returns a pointer to the created layout object.
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_layout_create(
- dom_document *doc,
- css_select_ctx *css_ctx,
- css_media_type *media,
- nslayout_callback *cb;
- void *pw,
- nslayout_layout **layout);
-
-/**
- * Destroy a Layout object
- *
- * \param layout Returns a pointer to the created layout object.
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_layout_destroy(
- nslayout_layout *layout);
-
-/**
- * Update the viewport for a layout
- *
- * Note: Before this is called, the layout engine will create internal
- * data structures for the document, but will not start to position
- * things and will not emit render lists.
- *
- * \param layout Layout to set viewport for.
- * \param viewport Viewport dimensions and offset.
- * \param scale Rendering scale.
- * \param dpi DPI of render target with viewport.
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_update_viewport(
- nslayout_layout *layout,
- nslayout_rect *viewport,
- css_fixed scale
- int dpi);
-
-/**
- * Find the top-most element at a given point, in terms of z-order.
- *
- * \param layout Layout to locate an element in.
- * \param element Updated to area with position relative to viewport.
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_element_get_location(
- nslayout_layout *layout,
- nslayout_rect *area);
-
-/**
- * Find the top-most element at a given point, in terms of z-order.
- *
- * \param layout Layout to find an element in.
- * \param x Mouse x-coordinate (viewport relative).
- * \param y Mouse y-coordinate (viewport relative).
- * \param element Updated to point at the element we found.
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_element_at_point(
- nslayout_layout *layout,
- unsigned int x,
- unsigned int y,
- dom_event_target **element);
-
-/**
- * Mark an element (or part of it) as needing redraw.
- *
- * \param layout Layout to indicate redraw is required for.
- * \param element Element to mark as needing redraw.
- * \param rel_area Area of element to redraw relative to object's top-left.
- * May be NULL, to redraw whole element.
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_layout_dirty_element(
- nslayout_layout *layout,
- dom_element *element,
- nslayout_rect *rel_area);
-
-/**
- * Mark an area as needing redraw.
- *
- * \param layout Layout to indicate redraw is required for.
- * \param area Area to redraw relative to viewport's top-left.
- * \return NSLAYOUT_OK on success, appropriate error otherwise.
- */
-nslayout_error nslayout_layout_dirty_area(
- nslayout_layout *layout,
- nslayout_rect *area);
-
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..7a6251d
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,11 @@
+#
+# Makefile for libnslayout
+#
+# Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+#
+# Released under the ISC License (see COPYING file)
+
+# Sources
+DIR_SOURCES := layout.c
+
+include $(NSBUILD)/Makefile.subdir
diff --git a/src/layout.c b/src/layout.c
new file mode 100644
index 0000000..dab4855
--- /dev/null
+++ b/src/layout.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "layout.h"
+
+
+/* Publically exported function, documented in include/libnslayout/nslayout.h */
+nslayout_error nslayout_layout_create(
+ dom_document *doc,
+ css_select_ctx *css_ctx,
+ css_media_type *media,
+ nslayout_callback *cb,
+ void *pw,
+ nslayout_layout **layout)
+{
+ nslayout_layout *l;
+
+ assert(doc != NULL);
+ assert(css_ctx != NULL);
+ assert(media != NULL);
+ assert(cb != NULL);
+ assert(pw != NULL);
+
+ l = calloc(1, sizeof(nslayout_layout));
+ if (l == NULL) {
+ return NSLAYOUT_NO_MEM;
+ }
+
+ /* TODO: Decide: ownership will probably be passed to libnslayout */
+ l->doc = doc;
+ l->css_ctx = css_ctx;
+ l->media = media;
+ l->cb = cb;
+ l->pw = pw;
+
+ *layout = l;
+ return NSLAYOUT_OK;
+}
+
+
+/* Publically exported function, documented in include/libnslayout/nslayout.h */
+nslayout_error nslayout_layout_destroy(
+ nslayout_layout *layout)
+{
+ /* TODO: free/unref the stuff we own in the layout */
+
+ free(layout);
+ return NSLAYOUT_OK;
+}
diff --git a/src/layout.h b/src/layout.h
new file mode 100644
index 0000000..5b43bc6
--- /dev/null
+++ b/src/layout.h
@@ -0,0 +1,20 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#ifndef nslayout_layout_h_
+#define nslayout_layout_h_
+
+#include <libnslayout/nslayout.h>
+
+struct nslayout_layout {
+ dom_document *doc;
+ css_select_ctx *css_ctx;
+ css_media_type *media;
+ nslayout_callback *cb;
+ void *pw;
+};
+
+#endif
-----------------------------------------------------------------------
Summary of changes:
Makefile | 69 ++++++++++++++++++++++++
include/{nslayout.c => libnslayout/nslayout.h} | 30 +++++++++--
src/Makefile | 11 ++++
src/layout.c | 55 +++++++++++++++++++
src/layout.h | 20 +++++++
5 files changed, 180 insertions(+), 5 deletions(-)
create mode 100644 Makefile
rename include/{nslayout.c => libnslayout/nslayout.h} (90%)
create mode 100644 src/Makefile
create mode 100644 src/layout.c
create mode 100644 src/layout.h
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..beb2b46
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,69 @@
+#!/bin/make
+#
+# Makefile for nslayout
+#
+# Copyright 2009-2015 John-Mark Bell <jmb(a)netsurf-browser.org>
+
+# Component settings
+COMPONENT := nslayout
+COMPONENT_VERSION := 0.0.0
+# Default to a static library
+COMPONENT_TYPE ?= lib-static
+
+# Setup the tooling
+PREFIX ?= /opt/netsurf
+NSSHARED ?= $(PREFIX)/share/netsurf-buildsystem
+include $(NSSHARED)/makefiles/Makefile.tools
+
+# Reevaluate when used, as BUILDDIR won't be defined yet
+TESTRUNNER = $(BUILDDIR)/test_testrunner$(EXEEXT)
+
+# Toolchain flags
+WARNFLAGS := -Wall -Wextra -W -Wundef -Wpointer-arith -Wcast-align \
+ -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
+ -Wmissing-declarations -Wnested-externs
+# BeOS/Haiku standard library headers issue warnings
+ifneq ($(BUILD),i586-pc-haiku)
+ WARNFLAGS := $(WARNFLAGS) -Werror
+endif
+
+CFLAGS := -D_BSD_SOURCE -D_DEFAULT_SOURCE \
+ -I$(CURDIR)/include/ -I$(CURDIR)/src \
+ $(WARNFLAGS) $(CFLAGS)
+ifneq ($(GCCVER),2)
+ CFLAGS := $(CFLAGS) -std=c99
+else
+ # __inline__ is a GCCism
+ CFLAGS := $(CFLAGS) -Dinline="__inline__"
+endif
+
+# libwapcaplet, libparserutils, libcss, libdom
+ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
+ ifneq ($(PKGCONFIG),)
+ CFLAGS := $(CFLAGS) $(shell $(PKGCONFIG) \
+ libwapcaplet libparserutils libcss libdom --cflags)
+ LDFLAGS := $(LDFLAGS) $(shell $(PKGCONFIG) \
+ libwapcaplet libparserutils libcss libdom --libs)
+ else
+ CFLAGS := $(CFLAGS) -I$(PREFIX)/include
+ LDFLAGS := $(LDFLAGS) -lparserutils -lwapcaplet -lcss -ldom
+ endif
+endif
+
+include $(NSBUILD)/Makefile.top
+
+ifeq ($(WANT_TEST),yes)
+ ifneq ($(PKGCONFIG),)
+ TESTCFLAGS := $(TESTCFLAGS) $(shell $(PKGCONFIG) --cflags check)
+ TESTLDFLAGS := $(TESTLDFLAGS) $(shell $(PKGCONFIG) --libs check)
+ else
+ TESTLDFLAGS := $(TESTLDFLAGS) -lcheck
+ endif
+endif
+
+# Extra installation rules
+I := /$(INCLUDEDIR)/lib$(COMPONENT)
+
+INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):include/lib$(COMPONENT)/libnslayout.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR)/pkgconfig:lib$(COMPONENT).pc.in
+INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR):$(OUTPUT)
diff --git a/include/nslayout.c b/include/libnslayout/nslayout.h
similarity index 90%
rename from include/nslayout.c
rename to include/libnslayout/nslayout.h
index 1144e4b..a720b32 100644
--- a/include/nslayout.c
+++ b/include/libnslayout/nslayout.h
@@ -5,6 +5,12 @@
* Copyright 2015 John-Mark Bell <jmb(a)netsurf-browser.org>
*/
+#ifndef nslayout_nslayout_h_
+#define nslayout_nslayout_h_
+
+#include <libcss/libcss.h>
+#include <dom/dom.h>
+
/** An opaque client-owned replaced element */
typedef void nslayout_replaced;
@@ -16,6 +22,13 @@ typedef struct nslayout_rect {
int h;
} nslayout_rect;
+/** Render list */
+typedef struct nslayout_render_list {
+} nslayout_render_list;
+
+/** Render list */
+typedef struct nslayout_layout nslayout_layout;
+
/**
* A LibNSLayout request
*
@@ -42,8 +55,8 @@ typedef struct nslayout_request {
nslayout_render_list *list; /**< Render list */
} render;
struct {
- width; /**< Document width in px */
- height; /**< Document height in px */
+ unsigned int width; /**< Document width in px */
+ unsigned int height; /**< Document height in px */
} set_extents;
struct {
nslayout_replaced *replaced; /** A replacement object */
@@ -64,6 +77,12 @@ typedef struct nslayout_request {
} response;
} nslayout_request;
+/** Libnslayout return codes */
+typedef enum nslayout_error {
+ NSLAYOUT_OK,
+ NSLAYOUT_NO_MEM
+} nslayout_error;
+
/**
* Initialise LibNSLayout
*
@@ -106,7 +125,7 @@ nslayout_error nslayout_layout_create(
dom_document *doc,
css_select_ctx *css_ctx,
css_media_type *media,
- nslayout_callback *cb;
+ nslayout_callback *cb,
void *pw,
nslayout_layout **layout);
@@ -135,8 +154,8 @@ nslayout_error nslayout_layout_destroy(
nslayout_error nslayout_update_viewport(
nslayout_layout *layout,
nslayout_rect *viewport,
- css_fixed scale
- int dpi);
+ css_fixed scale,
+ unsigned int dpi);
/**
* Find the top-most element at a given point, in terms of z-order.
@@ -189,3 +208,4 @@ nslayout_error nslayout_layout_dirty_area(
nslayout_layout *layout,
nslayout_rect *area);
+#endif
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..7a6251d
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,11 @@
+#
+# Makefile for libnslayout
+#
+# Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+#
+# Released under the ISC License (see COPYING file)
+
+# Sources
+DIR_SOURCES := layout.c
+
+include $(NSBUILD)/Makefile.subdir
diff --git a/src/layout.c b/src/layout.c
new file mode 100644
index 0000000..dab4855
--- /dev/null
+++ b/src/layout.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "layout.h"
+
+
+/* Publically exported function, documented in include/libnslayout/nslayout.h */
+nslayout_error nslayout_layout_create(
+ dom_document *doc,
+ css_select_ctx *css_ctx,
+ css_media_type *media,
+ nslayout_callback *cb,
+ void *pw,
+ nslayout_layout **layout)
+{
+ nslayout_layout *l;
+
+ assert(doc != NULL);
+ assert(css_ctx != NULL);
+ assert(media != NULL);
+ assert(cb != NULL);
+ assert(pw != NULL);
+
+ l = calloc(1, sizeof(nslayout_layout));
+ if (l == NULL) {
+ return NSLAYOUT_NO_MEM;
+ }
+
+ /* TODO: Decide: ownership will probably be passed to libnslayout */
+ l->doc = doc;
+ l->css_ctx = css_ctx;
+ l->media = media;
+ l->cb = cb;
+ l->pw = pw;
+
+ *layout = l;
+ return NSLAYOUT_OK;
+}
+
+
+/* Publically exported function, documented in include/libnslayout/nslayout.h */
+nslayout_error nslayout_layout_destroy(
+ nslayout_layout *layout)
+{
+ /* TODO: free/unref the stuff we own in the layout */
+
+ free(layout);
+ return NSLAYOUT_OK;
+}
diff --git a/src/layout.h b/src/layout.h
new file mode 100644
index 0000000..5b43bc6
--- /dev/null
+++ b/src/layout.h
@@ -0,0 +1,20 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License,
http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#ifndef nslayout_layout_h_
+#define nslayout_layout_h_
+
+#include <libnslayout/nslayout.h>
+
+struct nslayout_layout {
+ dom_document *doc;
+ css_select_ctx *css_ctx;
+ css_media_type *media;
+ nslayout_callback *cb;
+ void *pw;
+};
+
+#endif
--
NetSurf Layout Engine