summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-07-06 18:34:34 +0100
committerVincent Sanders <vince@kyllikki.org>2014-07-06 18:34:34 +0100
commit3a9fa29ee53bef70a0e643847acc2fb374501f70 (patch)
treee9a8946c7655e03e4c9a9d702bbf36b1952a92df
parentcaf918d2f28f600184036aef3f096024d3af62a7 (diff)
downloadnetsurf-3a9fa29ee53bef70a0e643847acc2fb374501f70.tar.gz
netsurf-3a9fa29ee53bef70a0e643847acc2fb374501f70.tar.bz2
try and improve usage of browser window internals
-rw-r--r--amiga/menu.c8
-rw-r--r--atari/gui.c10
-rw-r--r--desktop/browser.c40
-rw-r--r--desktop/browser.h35
-rw-r--r--desktop/browser_private.h1
-rw-r--r--gtk/scaffolding.c5
-rw-r--r--gtk/window.c8
-rw-r--r--render/form.h3
-rw-r--r--render/html.h7
-rw-r--r--riscos/dialog.c1
-rw-r--r--riscos/iconbar.c1
-rw-r--r--riscos/window.c10
12 files changed, 79 insertions, 50 deletions
diff --git a/amiga/menu.c b/amiga/menu.c
index c1e863a65..70028af68 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -893,8 +893,12 @@ static void ami_menu_item_edit_copy(struct Hook *hook, APTR window, struct Intui
}
else if(bm = content_get_bitmap(gwin->bw->current_content))
{
- bm->url = (char *)nsurl_access(hlcache_handle_get_url(gwin->bw->current_content));
- bm->title = (char *)content_get_title(gwin->bw->current_content);
+ /** @todo It should be checked that the lifetime of
+ * the objects containing the values returned (and the
+ * constness cast away) is safe.
+ */
+ bm->url = (char *)nsurl_access(browser_window_get_url(gwin->bw));
+ bm->title = (char *)browser_window_get_title(gwin->bw);
ami_easy_clipboard_bitmap(bm);
}
#ifdef WITH_NS_SVG
diff --git a/atari/gui.c b/atari/gui.c
index efa23efe4..f267b69a8 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -394,10 +394,10 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
static void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
{
- if ((w == NULL)
- || (w->browser->bw == NULL)
- || (w->browser->bw->current_content == NULL))
- return;
+ if ( (w == NULL)
+ || (w->browser->bw == NULL)
+ || (!browser_window_has_content(w->browser->bw)))
+ return;
LOG(("scroll (gui_window: %p) %d, %d\n", w, sx, sy));
window_scroll_by(w->root, sx, sy);
@@ -412,7 +412,7 @@ static void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
static void gui_window_update_extent(struct gui_window *gw)
{
- if( gw->browser->bw->current_content != NULL ) {
+ if(browser_window_has_content(gw->browser->bw)) {
// TODO: store content size!
if(window_get_active_gui_window(gw->root) == gw) {
window_set_content_size( gw->root,
diff --git a/desktop/browser.c b/desktop/browser.c
index dc2db723c..684035a0a 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -781,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)
@@ -793,7 +802,6 @@ nserror browser_window_initialise_common(enum browser_window_create_flags flags,
bw->refresh_interval = -1;
bw->drag_type = DRAGGING_NONE;
- bw->scale = (float) nsoption_int(scale) / 100.0;
bw->scroll_x = NULL;
bw->scroll_y = NULL;
@@ -1958,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);
@@ -1973,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)
@@ -2436,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)
@@ -2458,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 88b757727..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,
@@ -120,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);
@@ -142,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,
@@ -157,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.
@@ -200,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);
/**
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index cbc29aaa3..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"
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index c2dc0fdc9..ee2d46227 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -2444,9 +2444,8 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
nsgtk_scaffolding_set_icon(gw);
/* Ensure the window's title bar is updated */
- if (bw->current_content != NULL) {
- gui_window_set_title(gw, content_get_title(bw->current_content));
- }
+ gui_window_set_title(gw, browser_window_get_title(bw));
+
}
/* exported interface documented in scaffolding.h */
diff --git a/gtk/window.c b/gtk/window.c
index d1cd6b1a5..9c4b668b9 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -34,7 +34,7 @@
#include "gtk/window.h"
#include "gtk/selection.h"
#include "desktop/gui.h"
-#include "desktop/browser_private.h"
+#include "desktop/browser.h"
#include "desktop/mouse.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
@@ -728,12 +728,6 @@ gui_window_create(struct browser_window *bw,
g->bw = bw;
g->mouse.state = 0;
g->current_pointer = GUI_POINTER_DEFAULT;
- if (flags & GW_CREATE_CLONE) {
- assert(existing != NULL);
- bw->scale = existing->bw->scale;
- } else {
- bw->scale = nsoption_int(scale) / 100;
- }
/* attach scaffold */
if (flags & GW_CREATE_TAB) {
diff --git a/render/form.h b/render/form.h
index f072b801e..7715b9ad3 100644
--- a/render/form.h
+++ b/render/form.h
@@ -36,6 +36,7 @@ struct form_select_menu;
struct html_content;
struct dom_string;
struct content;
+struct nsurl;
/** Form submit method. */
typedef enum {
@@ -188,7 +189,7 @@ void form_select_mouse_drag_end(struct form_control *control,
void form_select_get_dimensions(struct form_control *control,
int *width, int *height);
void form_select_process_selection(struct form_control *control, int item);
-void form_submit(nsurl *page_url, struct browser_window *target,
+void form_submit(struct nsurl *page_url, struct browser_window *target,
struct form *form, struct form_control *submit_button);
void form_radio_set(struct form_control *radio);
diff --git a/render/html.h b/render/html.h
index 7ca75e713..a5ee5ffa5 100644
--- a/render/html.h
+++ b/render/html.h
@@ -51,6 +51,7 @@ struct scrollbar;
struct scrollbar_msg_data;
struct search_context;
struct selection;
+struct nsurl;
/**
* Container for stylesheets used by an HTML document
@@ -113,7 +114,7 @@ struct content_html_frames {
int margin_height; /** frame margin height */
char *name; /** frame name (for targetting) */
- nsurl *url; /** frame url */
+ struct nsurl *url; /** frame url */
bool no_resize; /** frame is not resizable */
frame_scrolling scrolling; /** scrolling characteristics */
@@ -131,7 +132,7 @@ struct content_html_iframe {
int margin_height; /** frame margin height */
char *name; /** frame name (for targetting) */
- nsurl *url; /** frame url */
+ struct nsurl *url; /** frame url */
frame_scrolling scrolling; /** scrolling characteristics */
bool border; /** frame has a border */
@@ -176,7 +177,7 @@ const char *html_get_encoding(struct hlcache_handle *h);
dom_hubbub_encoding_source html_get_encoding_source(struct hlcache_handle *h);
struct content_html_frames *html_get_frameset(struct hlcache_handle *h);
struct content_html_iframe *html_get_iframe(struct hlcache_handle *h);
-nsurl *html_get_base_url(struct hlcache_handle *h);
+struct nsurl *html_get_base_url(struct hlcache_handle *h);
const char *html_get_base_target(struct hlcache_handle *h);
void html_set_file_gadget_filename(struct hlcache_handle *hl,
struct form_control *gadget, const char *fn);
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 1c95a7099..fd854b857 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -37,6 +37,7 @@
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "utils/nsurl.h"
#include "utils/url.h"
#include "utils/utils.h"
#include "desktop/netsurf.h"
diff --git a/riscos/iconbar.c b/riscos/iconbar.c
index 11640fe7c..f29b019a2 100644
--- a/riscos/iconbar.c
+++ b/riscos/iconbar.c
@@ -36,6 +36,7 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
+#include "utils/nsurl.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
diff --git a/riscos/window.c b/riscos/window.c
index 2ad432b2e..ab4cb0c50 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -602,8 +602,6 @@ static struct gui_window *gui_window_create(struct browser_window *bw,
ro_gui_window_menu_close);
/* Set the window options */
- bw->window = g;
- bw->scale = ((float)nsoption_int(scale)) / 100;
ro_gui_window_clone_options(g, existing);
ro_gui_window_update_toolbar_buttons(g);
@@ -2424,7 +2422,6 @@ void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
wimp_selection *selection, menu_action action)
{
struct gui_window *g;
- struct browser_window *bw;
hlcache_handle *h;
struct toolbar *toolbar;
bool export;
@@ -2434,8 +2431,7 @@ void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
g = (struct gui_window *) ro_gui_wimp_event_get_user_data(w);
toolbar = g->toolbar;
- bw = g->bw;
- h = bw->current_content;
+ h = g->bw->current_content;
switch (action) {
case BROWSER_PAGE_INFO:
@@ -2472,9 +2468,9 @@ void ro_gui_window_menu_warning(wimp_w w, wimp_i i, wimp_menu *menu,
break;
case BROWSER_SELECTION_SAVE:
- if (browser_window_get_editor_flags(bw) & BW_EDITOR_CAN_COPY)
+ if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_COPY)
ro_gui_save_prepare(GUI_SAVE_TEXT_SELECTION, NULL,
- browser_window_get_selection(bw),
+ browser_window_get_selection(g->bw),
NULL, NULL);
break;