Author: jmb
Date: Tue Aug 7 08:58:04 2007
New Revision: 3481
URL:
http://source.netsurf-browser.org?rev=3481&view=rev
Log:
Fix division by 0 caused by uninitialised scale value.
Break out initialisation of common parts of struct browser_window into their own
function.
Modified:
trunk/netsurf/desktop/browser.c
trunk/netsurf/desktop/browser.h
trunk/netsurf/desktop/frames.c
Modified: trunk/netsurf/desktop/browser.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.c?rev=348...
==============================================================================
--- trunk/netsurf/desktop/browser.c (original)
+++ trunk/netsurf/desktop/browser.c Tue Aug 7 08:58:04 2007
@@ -136,11 +136,43 @@
return NULL;
}
- /* content */
+ /* Initialise common parts */
+ browser_window_initialise_common(bw, clone);
+
+ /* window characteristics */
+ bw->browser_window_type = BROWSER_WINDOW_NORMAL;
+ bw->scrolling = SCROLLING_YES;
+ bw->border = true;
+ bw->no_resize = true;
+
+ /* gui window */
+ if ((bw->window = gui_create_browser_window(bw, clone)) == NULL) {
+ browser_window_destroy(bw);
+ return NULL;
+ }
+ if (url)
+ browser_window_go(bw, url, referer, history_add);
+
+ return bw;
+}
+
+
+/**
+ * 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
@@ -149,23 +181,10 @@
/* 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;
- bw->no_resize = true;
-
- /* gui window */
- if ((bw->window = gui_create_browser_window(bw, clone)) == NULL) {
- browser_window_destroy(bw);
- return NULL;
- }
- if (url)
- browser_window_go(bw, url, referer, history_add);
-
- return bw;
}
@@ -1073,14 +1092,14 @@
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'
Modified: trunk/netsurf/desktop/browser.h
URL:
http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.h?rev=348...
==============================================================================
--- trunk/netsurf/desktop/browser.h (original)
+++ trunk/netsurf/desktop/browser.h Tue Aug 7 08:58:04 2007
@@ -188,6 +188,8 @@
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,
Modified: trunk/netsurf/desktop/frames.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/desktop/frames.c?rev=3481...
==============================================================================
--- trunk/netsurf/desktop/frames.c (original)
+++ trunk/netsurf/desktop/frames.c Tue Aug 7 08:58:04 2007
@@ -66,13 +66,10 @@
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 @@
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;