summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2014-07-08 19:23:55 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2014-07-08 19:23:55 +0100
commit3c818abaea53b61c15393d1aeaefd1eba52f4d5c (patch)
tree13704d81d7041a4cd4bc44414baf0de6045021db /desktop
parente7e914b6242a17abebb84ecfc5f0b1facaac4e94 (diff)
parent0694f345daa509546d79f31be285987f43cc5be3 (diff)
downloadnetsurf-3c818abaea53b61c15393d1aeaefd1eba52f4d5c.tar.gz
netsurf-3c818abaea53b61c15393d1aeaefd1eba52f4d5c.tar.bz2
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c63
-rw-r--r--desktop/browser.h52
-rw-r--r--desktop/browser_private.h4
-rw-r--r--desktop/gui.h15
-rw-r--r--desktop/gui_factory.c3
-rw-r--r--desktop/netsurf.c11
-rw-r--r--desktop/save_complete.c7
7 files changed, 112 insertions, 43 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 6e3ed9718..684035a0a 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -66,14 +66,11 @@
#include "utils/utils.h"
#include "utils/utf8.h"
-/** one or more windows require a reformat */
-bool browser_reformat_pending;
/** maximum frame depth */
#define FRAME_DEPTH 8
-
/**
* Get position of scrollbar widget within browser window.
*
@@ -784,9 +781,18 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
if (flags & BW_CREATE_CLONE) {
assert(existing != NULL);
+
+ /* clone history */
err = browser_window_history_clone(existing, bw);
+
+ /* copy the scale */
+ bw->scale = existing->scale;
} else {
+ /* create history */
err = browser_window_history_create(bw);
+
+ /* default scale */
+ bw->scale = (float) nsoption_int(scale) / 100.0;
}
if (err != NSERROR_OK)
@@ -795,9 +801,7 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
/* window characteristics */
bw->refresh_interval = -1;
- bw->reformat_pending = false;
bw->drag_type = DRAGGING_NONE;
- bw->scale = (float) nsoption_int(scale) / 100.0;
bw->scroll_x = NULL;
bw->scroll_y = NULL;
@@ -1623,7 +1627,13 @@ void browser_window_destroy_internal(struct browser_window *bw)
browser_window_destroy_children(bw);
}
+ /* clear any pending callbacks */
guit->browser->schedule(-1, browser_window_refresh, bw);
+ /* The ugly cast here is so the reformat function can be
+ * passed a gui window pointer in its API rather than void*
+ */
+ LOG(("Clearing schedule %p(%p)", guit->window->reformat, bw->window));
+ guit->browser->schedule(-1, (void(*)(void*))guit->window->reformat, bw->window);
/* If this brower window is not the root window, and has focus, unset
* the root browser window's focus pointer. */
@@ -1956,7 +1966,7 @@ nserror browser_window_navigate(struct browser_window *bw,
/* Exported interface, documented in browser.h */
-nsurl * browser_window_get_url(struct browser_window *bw)
+nsurl* browser_window_get_url(struct browser_window *bw)
{
assert(bw != NULL);
@@ -1971,6 +1981,17 @@ nsurl * browser_window_get_url(struct browser_window *bw)
return corestring_nsurl_about_blank;
}
+/* Exported interface, documented in browser.h */
+const char* browser_window_get_title(struct browser_window *bw)
+{
+ assert(bw != NULL);
+
+ if (bw->current_content != NULL) {
+ return content_get_title(bw->current_content);
+ }
+
+ return NULL;
+}
/* Exported interface, documented in browser.h */
struct history * browser_window_get_history(struct browser_window *bw)
@@ -2362,6 +2383,16 @@ void browser_window_set_pointer(struct browser_window *bw,
guit->window->set_pointer(root->window, gui_shape);
}
+/* exported function documented in desktop/browser.h */
+nserror browser_window_schedule_reformat(struct browser_window *bw)
+{
+ /* The ugly cast here is so the reformat function can be
+ * passed a gui window pointer in its API rather than void*
+ */
+ LOG(("Scheduleing %p(%p)", guit->window->reformat, bw->window));
+ guit->browser->schedule(0, (void(*)(void*))guit->window->reformat, bw->window);
+ return NSERROR_OK;
+}
/**
* Reformat a browser window contents to a new width or height.
@@ -2413,8 +2444,7 @@ static void browser_window_set_scale_internal(struct browser_window *bw,
if (content_can_reformat(c) == false) {
browser_window_update(bw, false);
} else {
- bw->reformat_pending = true;
- browser_reformat_pending = true;
+ browser_window_schedule_reformat(bw);
}
}
@@ -2425,14 +2455,7 @@ static void browser_window_set_scale_internal(struct browser_window *bw,
}
-/**
- * Sets the scale of a browser window
- *
- * \param bw The browser window to scale
- * \param scale The new scale
- * \param all Scale all windows in the tree (ie work up aswell as down)
- */
-
+/* exported interface documented in desktop/browser.h */
void browser_window_set_scale(struct browser_window *bw, float scale, bool all)
{
while (bw->parent && all)
@@ -2447,13 +2470,7 @@ void browser_window_set_scale(struct browser_window *bw, float scale, bool all)
}
-/**
- * Gets the scale of a browser window
- *
- * \param bw The browser window to scale
- * \return
- */
-
+/* exported interface documented in desktop/browser.h */
float browser_window_get_scale(struct browser_window *bw)
{
return bw->scale;
diff --git a/desktop/browser.h b/desktop/browser.h
index ca99a5d16..6e893fffb 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -28,7 +28,7 @@
#include <stdio.h>
#include "utils/types.h"
-#include "utils/nsurl.h"
+#include "utils/errors.h"
#include "desktop/plot_style.h"
#include "desktop/frame_types.h"
#include "desktop/mouse.h"
@@ -41,6 +41,7 @@ struct history;
struct selection;
struct fetch_multipart_data;
struct form_control;
+struct nsurl;
typedef enum {
DRAGGING_NONE,
@@ -60,8 +61,6 @@ typedef enum {
BW_EDITOR_CAN_PASTE = (1 << 2) /**< Can paste, input */
} browser_editor_flags;
-extern bool browser_reformat_pending;
-
/** flags to browser_window_create */
enum browser_window_create_flags {
/** No flags set */
@@ -122,7 +121,7 @@ enum browser_window_nav_flags {
* \return NSERROR_OK, or appropriate error otherwise.
*/
nserror browser_window_create(enum browser_window_create_flags flags,
- nsurl *url, nsurl *referrer,
+ struct nsurl *url, struct nsurl *referrer,
struct browser_window *existing,
struct browser_window **bw);
@@ -144,8 +143,8 @@ nserror browser_window_create(enum browser_window_create_flags flags,
*
*/
nserror browser_window_navigate(struct browser_window *bw,
- nsurl *url,
- nsurl *referrer,
+ struct nsurl *url,
+ struct nsurl *referrer,
enum browser_window_nav_flags flags,
char *post_urlenc,
struct fetch_multipart_data *post_multipart,
@@ -159,7 +158,14 @@ nserror browser_window_navigate(struct browser_window *bw,
*
* Note: guaranteed to return a valid nsurl ptr, never returns NULL.
*/
-nsurl * browser_window_get_url(struct browser_window *bw);
+struct nsurl* browser_window_get_url(struct browser_window *bw);
+
+/**
+ * Get the title of a browser_window.
+ *
+ * \param bw The browser window.
+ */
+const char* browser_window_get_title(struct browser_window *bw);
/**
* Get a browser window's history object.
@@ -202,7 +208,24 @@ void browser_window_reload(struct browser_window *bw, bool all);
void browser_window_destroy(struct browser_window *bw);
void browser_window_reformat(struct browser_window *bw, bool background,
int width, int height);
+
+
+/**
+ * Sets the scale of a browser window.
+ *
+ * \param bw The browser window to scale.
+ * \param scale The new scale.
+ * \param all Scale all windows in the tree (ie work up aswell as down)
+ */
void browser_window_set_scale(struct browser_window *bw, float scale, bool all);
+
+
+/**
+ * Gets the scale of a browser window
+ *
+ * \param bw The browser window to get the scale of.
+ * \return The scale of teh window.
+ */
float browser_window_get_scale(struct browser_window *bw);
/**
@@ -259,6 +282,21 @@ struct browser_window *browser_window_find_target(
struct browser_window *bw, const char *target,
browser_mouse_state mouse);
+/**
+ * Cause the frontends reformat entry to be called in safe context.
+ *
+ * The browser_window_reformat call cannot safely be called from some
+ * contexts, this call allows for the reformat to happen from a safe
+ * top level context.
+ *
+ * The callback is frontend provided as the context information (size
+ * etc.) about the windowing toolkit is only available to the
+ * frontend.
+ */
+nserror browser_window_schedule_reformat(struct browser_window *bw);
+
+
+
void browser_select_menu_callback(void *client_data,
int x, int y, int width, int height);
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 339bc46ee..d2c48d704 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -25,6 +25,7 @@
#define _NETSURF_DESKTOP_BROWSER_PRIVATE_H_
#include <stdbool.h>
+#include <libwapcaplet/libwapcaplet.h>
#include "desktop/browser.h"
@@ -87,9 +88,6 @@ struct browser_window {
/** Refresh interval (-1 if undefined) */
int refresh_interval;
- /** Window has been resized, and content needs reformatting. */
- bool reformat_pending;
-
/** Window dimensions */
int x;
int y;
diff --git a/desktop/gui.h b/desktop/gui.h
index d44b57d1c..a19f30115 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -105,7 +105,9 @@ struct gui_window_table {
struct gui_window *existing,
gui_window_create_flags flags);
- /** destroy previously created gui window */
+ /**
+ * Destroy previously created gui window
+ */
void (*destroy)(struct gui_window *g);
/**
@@ -168,6 +170,17 @@ struct gui_window_table {
*/
void (*update_extent)(struct gui_window *g);
+ /**
+ * Reformat a window.
+ *
+ * This is used to perform reformats when the page contents
+ * require reformating. The reformat is requested using
+ * browser_window_schedule_reformat and occours via a scheduled
+ * callback hence from top level context.
+ *
+ * \param g gui_window to reformat.
+ */
+ void (*reformat)(struct gui_window *g);
/* Optional entries */
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index fd0867491..977805e9c 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -154,6 +154,9 @@ static nserror verify_window_register(struct gui_window_table *gwt)
if (gwt->update_extent == NULL) {
return NSERROR_BAD_PARAMETER;
}
+ if (gwt->reformat == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
/* fill in the optional entries with defaults */
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index a1bc42b93..579648bae 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -29,7 +29,7 @@
#include "utils/config.h"
#include "utils/utsname.h"
#include "content/content_factory.h"
-#include "content/fetch.h"
+#include "content/fetchers.h"
#include "content/hlcache.h"
#include "content/mimesniff.h"
#include "content/urldb.h"
@@ -231,7 +231,7 @@ nserror netsurf_init(const char *messages, const char *store_path)
setlocale(LC_ALL, "C");
/* initialise the fetchers */
- ret = fetch_init();
+ ret = fetcher_init();
if (ret != NSERROR_OK)
return ret;
@@ -257,8 +257,7 @@ nserror netsurf_init(const char *messages, const char *store_path)
int netsurf_main_loop(void)
{
while (!netsurf_quit) {
- guit->browser->poll(fetch_active);
- hlcache_poll();
+ guit->browser->poll(false);
}
return 0;
@@ -285,7 +284,7 @@ void netsurf_exit(void)
hlcache_finalise();
LOG(("Closing fetches"));
- fetch_quit();
+ fetcher_quit();
mimesniff_fini();
@@ -310,5 +309,3 @@ void netsurf_exit(void)
LOG(("Exited successfully"));
}
-
-
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index f6d3e7664..71187eb10 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -355,8 +355,11 @@ static bool save_complete_save_imported_sheets(save_complete_ctx *ctx,
uint32_t i;
for (i = 0; i < import_count; i++) {
- if (save_complete_save_stylesheet(ctx, imports[i].c) == false)
- return false;
+ /* treat a valid content as a stylesheet to save */
+ if ((imports[i].c != NULL) &&
+ (save_complete_save_stylesheet(ctx, imports[i].c) == false)) {
+ return false;
+ }
}
return true;