summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-08-07 07:58:04 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-08-07 07:58:04 +0000
commitcc684469dfd56079949a0b0377b606502d68bbf3 (patch)
treed2b73ac452a15a5c9e6aace740ab4a3940a322dc
parent01cc865e02b1e19b0010b3a9948b554dfd1881a7 (diff)
downloadnetsurf-cc684469dfd56079949a0b0377b606502d68bbf3.tar.gz
netsurf-cc684469dfd56079949a0b0377b606502d68bbf3.tar.bz2
Fix division by 0 caused by uninitialised scale value.
Break out initialisation of common parts of struct browser_window into their own function. svn path=/trunk/netsurf/; revision=3481
-rw-r--r--desktop/browser.c51
-rw-r--r--desktop/browser.h2
-rw-r--r--desktop/frames.c14
3 files changed, 41 insertions, 26 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index a55932ab4..b1c4d92c1 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -136,22 +136,10 @@ struct browser_window *browser_window_create(const char *url,
return NULL;
}
- /* content */
- if (!clone)
- bw->history = history_create();
- else
- bw->history = history_clone(clone->history);
- if (!clone || (clone && !clone->gesturer))
- bw->gesturer = NULL;
- else
- bw->gesturer = gesturer_clone(clone->gesturer);
+ /* Initialise common parts */
+ browser_window_initialise_common(bw, clone);
/* window characteristics */
- bw->sel = selection_create(bw);
- bw->refresh_interval = -1;
- bw->reformat_pending = false;
- bw->drag_type = DRAGGING_NONE;
- bw->scale = (float) option_scale / 100.0;
bw->browser_window_type = BROWSER_WINDOW_NORMAL;
bw->scrolling = SCROLLING_YES;
bw->border = true;
@@ -170,6 +158,37 @@ struct browser_window *browser_window_create(const char *url,
/**
+ * Initialise common parts of a browser window
+ *
+ * \param bw The window to initialise
+ * \param clone The window to clone, or NULL if none
+ */
+void browser_window_initialise_common(struct browser_window *bw,
+ struct browser_window *clone)
+{
+ assert(bw);
+
+ if (!clone)
+ bw->history = history_create();
+ else
+ bw->history = history_clone(clone->history);
+
+ if (!clone || (clone && !clone->gesturer))
+ bw->gesturer = NULL;
+ else
+ bw->gesturer = gesturer_clone(clone->gesturer);
+
+ /* window characteristics */
+ bw->sel = selection_create(bw);
+ bw->refresh_interval = -1;
+
+ bw->reformat_pending = false;
+ bw->drag_type = DRAGGING_NONE;
+ bw->scale = (float) option_scale / 100.0;
+}
+
+
+/**
* Start fetching a page in a browser window.
*
* \param bw browser window
@@ -1073,14 +1092,14 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, con
browser_window_find_target_internal(top, target, 0, bw, &rdepth, &bw_target);
if (bw_target)
return bw_target;
-
+
/* we require a new window using the target name */
if (!option_target_blank)
return bw;
bw_target = browser_window_create(NULL, bw, NULL, false);
if (!bw_target)
return bw;
-
+
/* frame names should begin with an alphabetic character (a-z,A-Z), however in
* practice you get things such as '_new' and '2left'. The only real effect this
* has is when giving out names as it can be assumed that an author intended '_new'
diff --git a/desktop/browser.h b/desktop/browser.h
index 3e1285324..1e1bf7704 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -188,6 +188,8 @@ extern bool browser_reformat_pending;
struct browser_window * browser_window_create(const char *url,
struct browser_window *clone, const char *referer,
bool history_add);
+void browser_window_initialise_common(struct browser_window *bw,
+ struct browser_window *clone);
void browser_window_go(struct browser_window *bw, const char *url,
const char *referer, bool history_add);
void browser_window_go_unverifiable(struct browser_window *bw,
diff --git a/desktop/frames.c b/desktop/frames.c
index cd2dc9e21..b0f6a7ea8 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -66,13 +66,10 @@ void browser_window_create_iframes(struct browser_window *bw,
for (cur = iframe; cur; cur = cur->next) {
window = &(bw->iframes[index++]);
- /* content */
- window->history = history_create();
- window->sel = selection_create(window);
- window->refresh_interval = -1;
+ /* Initialise common parts */
+ browser_window_initialise_common(window, NULL);
/* window characteristics */
- window->drag_type = DRAGGING_NONE;
window->browser_window_type = BROWSER_WINDOW_IFRAME;
window->scrolling = cur->scrolling;
window->border = cur->border;
@@ -171,13 +168,10 @@ void browser_window_create_frameset(struct browser_window *bw,
frame = &frameset->children[index];
window = &bw->children[index];
- /* content */
- window->history = history_create();
- window->sel = selection_create(window);
- window->refresh_interval = -1;
+ /* Initialise common parts */
+ browser_window_initialise_common(window, NULL);
/* window characteristics */
- window->drag_type = DRAGGING_NONE;
if (frame->children)
window->browser_window_type =
BROWSER_WINDOW_FRAMESET;