summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-06-06 08:59:23 +0100
committerVincent Sanders <vince@kyllikki.org>2016-06-06 09:01:38 +0100
commit76a68d7dd02f3819e4e60cd9febfd45e20821e14 (patch)
treea86fc61314fd53d383cb95a313a2897779984214 /desktop
parentd923e109cd56c553c8e87cdb8bdab5085e68cc73 (diff)
downloadnetsurf-76a68d7dd02f3819e4e60cd9febfd45e20821e14.tar.gz
netsurf-76a68d7dd02f3819e4e60cd9febfd45e20821e14.tar.bz2
Update content to split public and internal API
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c8
-rw-r--r--desktop/browser_history.c7
-rw-r--r--desktop/browser_private.h1
-rw-r--r--desktop/frames.c19
-rw-r--r--desktop/print.c172
-rw-r--r--desktop/save_complete.c35
-rw-r--r--desktop/save_text.c5
-rw-r--r--desktop/searchweb.c1
-rw-r--r--desktop/treeview.c8
9 files changed, 135 insertions, 121 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index c0db76abc..47b7341eb 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -47,7 +47,10 @@
#include "utils/utils.h"
#include "utils/utf8.h"
#include "utils/nsoption.h"
-#include "content/content.h"
+#include "netsurf/misc.h"
+#include "netsurf/window.h"
+#include "netsurf/content.h"
+#include "netsurf/plotters.h"
#include "content/content_debug.h"
#include "content/fetch.h"
#include "content/hlcache.h"
@@ -68,10 +71,7 @@
#include "desktop/knockout.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
-#include "netsurf/plotters.h"
#include "desktop/theme.h"
-#include "netsurf/misc.h"
-#include "netsurf/window.h"
#include "desktop/gui_internal.h"
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index a8c8ee041..5cd98cde6 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -29,18 +29,17 @@
#include <time.h>
#include "utils/log.h"
-#include "utils/nsurl.h"
#include "utils/utils.h"
-#include "content/content.h"
+#include "netsurf/layout.h"
+#include "netsurf/plotters.h"
+#include "netsurf/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "netsurf/bitmap.h"
-#include "netsurf/layout.h"
#include "desktop/gui_internal.h"
#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "netsurf/plotters.h"
#define WIDTH 100
#define HEIGHT 86
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 2641a0e44..64c698beb 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -28,6 +28,7 @@
#include "netsurf/browser_window.h"
#include "desktop/frame_types.h"
+#include "desktop/plot_style.h"
struct box;
struct hlcache_handle;
diff --git a/desktop/frames.c b/desktop/frames.c
index 7be75ce77..70e51e754 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -29,18 +29,17 @@
#include <time.h>
#include <math.h>
-#include "utils/config.h"
-#include "content/hlcache.h"
-#include "desktop/browser_private.h"
-#include "desktop/frames.h"
-#include "desktop/scrollbar.h"
-#include "desktop/selection.h"
#include "utils/log.h"
-#include "utils/messages.h"
#include "utils/utils.h"
+#include "netsurf/content.h"
+#include "content/hlcache.h"
#include "render/html.h"
#include "render/box.h"
+#include "desktop/browser_private.h"
+#include "desktop/frames.h"
+#include "desktop/scrollbar.h"
+
/** maximum frame resize margin */
#define FRAME_RESIZE 6
@@ -98,7 +97,7 @@ void browser_window_scroll_callback(void *client_data,
/* exported interface, documented in browser.h */
void browser_window_handle_scrollbars(struct browser_window *bw)
{
- hlcache_handle *h = bw->current_content;
+ struct hlcache_handle *h = bw->current_content;
bool scroll_x;
bool scroll_y;
int c_width = 0;
@@ -380,8 +379,8 @@ nserror browser_window_create_frameset(struct browser_window *bw,
/* Use the URL of the first ancestor window containing html content
* as the referer */
for (window = bw; window->parent; window = window->parent) {
- if (window->current_content &&
- content_get_type(window->current_content) ==
+ if (window->current_content &&
+ content_get_type(window->current_content) ==
CONTENT_HTML)
break;
}
diff --git a/desktop/print.c b/desktop/print.c
index 8daec887c..2d9a0d5f9 100644
--- a/desktop/print.c
+++ b/desktop/print.c
@@ -30,12 +30,12 @@
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/talloc.h"
-#include "content/content.h"
+#include "netsurf/content.h"
+#include "netsurf/plotters.h"
#include "content/hlcache.h"
#include "content/handlers/css/utils.h"
#include "render/box.h"
-#include "netsurf/plotters.h"
#include "desktop/print.h"
#include "desktop/printer.h"
@@ -44,11 +44,8 @@
#define DEFAULT_PAGE_HEIGHT 840
#define DEFAULT_COPIES 1
-static hlcache_handle *print_init(hlcache_handle *, struct print_settings *);
-static bool print_apply_settings(hlcache_handle *, struct print_settings *);
-
static float page_content_width, page_content_height;
-static hlcache_handle *printed_content;
+static struct hlcache_handle *printed_content;
static float done_height;
bool html_redraw_printing = false;
@@ -71,7 +68,7 @@ bool print_basic_run(hlcache_handle *content,
bool ret = true;
assert(content != NULL && printer != NULL && settings != NULL);
-
+
if (print_set_up(content, printer, settings, NULL))
return false;
@@ -80,10 +77,62 @@ bool print_basic_run(hlcache_handle *content,
}
print_cleanup(content, printer, settings);
-
+
return ret;
}
+
+/**
+ * The content passed to the function is duplicated with its boxes, font
+ * measuring functions are being set.
+ *
+ * \param content The content to be printed
+ * \param settings The settings for printing to use
+ * \return true if successful, false otherwise
+ */
+static struct hlcache_handle *
+print_init(struct hlcache_handle *content, struct print_settings *settings)
+{
+ struct hlcache_handle* printed_content;
+
+ hlcache_handle_clone(content, &printed_content);
+
+ return printed_content;
+}
+
+
+/**
+ * The content is resized to fit page width.
+ *
+ * \param content The content to be printed
+ * \param settings The settings for printing to use
+ * \return true if successful, false otherwise
+ */
+static bool
+print_apply_settings(hlcache_handle *content, struct print_settings *settings)
+{
+ if (settings == NULL)
+ return false;
+
+ /* Apply settings - adjust page size etc */
+
+ page_content_width = (settings->page_width -
+ FIXTOFLT(FSUB(settings->margins[MARGINLEFT],
+ settings->margins[MARGINRIGHT]))) / settings->scale;
+
+ page_content_height = (settings->page_height -
+ FIXTOFLT(FSUB(settings->margins[MARGINTOP],
+ settings->margins[MARGINBOTTOM]))) / settings->scale;
+
+ content_reformat(content, false, page_content_width, 0);
+
+ LOG("New layout applied.New height = %d ; New width = %d ",
+ content_get_height(content), content_get_width(content));
+
+ return true;
+}
+
+
/**
* This function prepares the content to be printed. The current browser content
* is duplicated and resized, printer initialization is called.
@@ -99,20 +148,20 @@ bool print_set_up(hlcache_handle *content,
double *height)
{
printed_content = print_init(content, settings);
-
+
if (printed_content == NULL)
return false;
-
+
print_apply_settings(printed_content, settings);
if (height)
*height = content_get_height(printed_content);
-
+
printer->print_begin(settings);
done_height = 0;
-
- return true;
+
+ return true;
}
/**
@@ -158,59 +207,12 @@ bool print_draw_next_page(const struct printer *printer,
done_height += page_content_height -
(html_redraw_printing_top_cropped != INT_MAX ?
- clip.y1 - html_redraw_printing_top_cropped : 0) /
+ clip.y1 - html_redraw_printing_top_cropped : 0) /
settings->scale;
return true;
}
-/**
- * The content passed to the function is duplicated with its boxes, font
- * measuring functions are being set.
- *
- * \param content The content to be printed
- * \param settings The settings for printing to use
- * \return true if successful, false otherwise
- */
-hlcache_handle *print_init(hlcache_handle *content,
- struct print_settings *settings)
-{
- hlcache_handle* printed_content;
-
- hlcache_handle_clone(content, &printed_content);
-
- return printed_content;
-}
-
-/**
- * The content is resized to fit page width.
- *
- * \param content The content to be printed
- * \param settings The settings for printing to use
- * \return true if successful, false otherwise
- */
-bool print_apply_settings(hlcache_handle *content,
- struct print_settings *settings)
-{
- if (settings == NULL)
- return false;
-
- /* Apply settings - adjust page size etc */
-
- page_content_width = (settings->page_width -
- FIXTOFLT(FSUB(settings->margins[MARGINLEFT],
- settings->margins[MARGINRIGHT]))) / settings->scale;
-
- page_content_height = (settings->page_height -
- FIXTOFLT(FSUB(settings->margins[MARGINTOP],
- settings->margins[MARGINBOTTOM]))) / settings->scale;
-
- content_reformat(content, false, page_content_width, 0);
-
- LOG("New layout applied.New height = %d ; New width = %d ", content_get_height(content), content_get_width(content));
-
- return true;
-}
/**
* Memory allocated during printing is being freed here.
@@ -224,16 +226,16 @@ bool print_cleanup(hlcache_handle *content, const struct printer *printer,
struct print_settings *settings)
{
printer->print_end();
-
+
html_redraw_printing = false;
-
+
if (printed_content) {
hlcache_handle_release(printed_content);
}
-
+
free((void *)settings->output);
free(settings);
-
+
return true;
}
@@ -252,57 +254,57 @@ struct print_settings *print_make_settings(print_configuration configuration,
struct print_settings *settings;
css_fixed length = 0;
css_unit unit = CSS_UNIT_MM;
-
+
switch (configuration){
- case PRINT_DEFAULT:
- settings = (struct print_settings*)
+ case PRINT_DEFAULT:
+ settings = (struct print_settings*)
malloc(sizeof(struct print_settings));
if (settings == NULL)
return NULL;
-
+
settings->page_width = DEFAULT_PAGE_WIDTH;
settings->page_height = DEFAULT_PAGE_HEIGHT;
settings->copies = DEFAULT_COPIES;
settings->scale = DEFAULT_EXPORT_SCALE;
-
+
length = INTTOFIX(DEFAULT_MARGIN_LEFT_MM);
- settings->margins[MARGINLEFT] =
+ settings->margins[MARGINLEFT] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(DEFAULT_MARGIN_RIGHT_MM);
- settings->margins[MARGINRIGHT] =
+ settings->margins[MARGINRIGHT] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(DEFAULT_MARGIN_TOP_MM);
- settings->margins[MARGINTOP] =
+ settings->margins[MARGINTOP] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(DEFAULT_MARGIN_BOTTOM_MM);
- settings->margins[MARGINBOTTOM] =
+ settings->margins[MARGINBOTTOM] =
nscss_len2px(length, unit, NULL);
break;
/* use settings from the Export options tab */
case PRINT_OPTIONS:
- settings = (struct print_settings*)
+ settings = (struct print_settings*)
malloc(sizeof(struct print_settings));
if (settings == NULL)
return NULL;
-
+
settings->page_width = DEFAULT_PAGE_WIDTH;
settings->page_height = DEFAULT_PAGE_HEIGHT;
settings->copies = DEFAULT_COPIES;
-
+
settings->scale = (float)nsoption_int(export_scale) / 100;
-
+
length = INTTOFIX(nsoption_int(margin_left));
- settings->margins[MARGINLEFT] =
+ settings->margins[MARGINLEFT] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(nsoption_int(margin_right));
- settings->margins[MARGINRIGHT] =
+ settings->margins[MARGINRIGHT] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(nsoption_int(margin_top));
- settings->margins[MARGINTOP] =
+ settings->margins[MARGINTOP] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(nsoption_int(margin_bottom));
- settings->margins[MARGINBOTTOM] =
+ settings->margins[MARGINBOTTOM] =
nscss_len2px(length, unit, NULL);
break;
default:
@@ -319,9 +321,9 @@ struct print_settings *print_make_settings(print_configuration configuration,
free(settings);
return NULL;
}
- } else
+ } else {
settings->output = NULL;
+ }
- return settings;
+ return settings;
}
-
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 201e80b0d..a1c71a4e0 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -17,8 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Save HTML document with dependencies (implementation).
+/**
+ * \file
+ * Save HTML document with dependencies implementation.
*/
#include <assert.h>
@@ -39,7 +40,7 @@
#include "utils/utils.h"
#include "utils/file.h"
#include "utils/messages.h"
-#include "content/content.h"
+#include "netsurf/content.h"
#include "content/hlcache.h"
#include "content/handlers/css/css.h"
#include "render/box.h"
@@ -53,7 +54,7 @@ regex_t save_complete_import_re;
/** An entry in save_complete_list. */
typedef struct save_complete_entry {
- hlcache_handle *content;
+ struct hlcache_handle *content;
struct save_complete_entry *next; /**< Next entry in list */
} save_complete_entry;
@@ -73,7 +74,7 @@ typedef enum {
} save_complete_event_type;
-static bool save_complete_save_html(save_complete_ctx *ctx, hlcache_handle *c,
+static bool save_complete_save_html(save_complete_ctx *ctx, struct hlcache_handle *c,
bool index);
static bool save_complete_save_imported_sheets(save_complete_ctx *ctx,
struct nscss_import *imports, uint32_t import_count);
@@ -99,7 +100,7 @@ static void save_complete_ctx_finalise(save_complete_ctx *ctx)
}
static bool save_complete_ctx_add_content(save_complete_ctx *ctx,
- hlcache_handle *content)
+ struct hlcache_handle *content)
{
save_complete_entry *entry;
@@ -114,24 +115,32 @@ static bool save_complete_ctx_add_content(save_complete_ctx *ctx,
return true;
}
-
-static hlcache_handle *save_complete_ctx_find_content(save_complete_ctx *ctx,
- const nsurl *url)
+/**
+ * find handle to content for url
+ *
+ * \param ctx The save context
+ * \param url The url to find content handle for
+ * \return The content handle or NULL if not found.
+ */
+static struct hlcache_handle *
+save_complete_ctx_find_content(save_complete_ctx *ctx, const nsurl *url)
{
save_complete_entry *entry;
- for (entry = ctx->list; entry != NULL; entry = entry->next)
+ for (entry = ctx->list; entry != NULL; entry = entry->next) {
if (nsurl_compare(url,
- hlcache_handle_get_url(entry->content),
- NSURL_COMPLETE))
+ hlcache_handle_get_url(entry->content),
+ NSURL_COMPLETE)) {
return entry->content;
+ }
+ }
return NULL;
}
static bool save_complete_ctx_has_content(save_complete_ctx *ctx,
- hlcache_handle *content)
+ struct hlcache_handle *content)
{
save_complete_entry *entry;
diff --git a/desktop/save_text.c b/desktop/save_text.c
index dee1c91e8..e63c96eb9 100644
--- a/desktop/save_text.c
+++ b/desktop/save_text.c
@@ -31,8 +31,7 @@
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
-#include "content/content.h"
-#include "content/hlcache.h"
+#include "netsurf/content.h"
#include "render/box.h"
#include "render/html.h"
@@ -55,7 +54,7 @@ static bool save_text_add_to_buffer(const char *text, size_t length,
* \param path Path to save text file too.
*/
-void save_as_text(hlcache_handle *c, char *path)
+void save_as_text(struct hlcache_handle *c, char *path)
{
FILE *out;
struct save_text_state save = { NULL, 0, 0 };
diff --git a/desktop/searchweb.c b/desktop/searchweb.c
index 83a19c31e..41ba062fa 100644
--- a/desktop/searchweb.c
+++ b/desktop/searchweb.c
@@ -27,6 +27,7 @@
#include "utils/log.h"
#include "utils/url.h"
#include "utils/nsoption.h"
+#include "netsurf/content.h"
#include "content/hlcache.h"
#include "desktop/searchweb.h"
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 4fa0544c5..05124193b 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -23,7 +23,9 @@
*/
#include "utils/log.h"
+#include "utils/nsurl.h"
#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
#include "content/hlcache.h"
#include "content/handlers/css/utils.h"
@@ -3634,8 +3636,10 @@ static void treeview_init_plot_styles(int font_pt_size)
/**
* Callback for hlcache.
*/
-static nserror treeview_res_cb(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
+static nserror
+treeview_res_cb(struct hlcache_handle *handle,
+ const hlcache_event *event,
+ void *pw)
{
struct treeview_resource *r = pw;