Author: jmb
Date: Wed Aug 31 14:42:54 2011
New Revision: 12692
URL:
http://source.netsurf-browser.org?rev=12692&view=rev
Log:
Begin to make browser_window opaque
Added:
branches/jmb/opaque-browser/desktop/browser_internal.h
Modified:
branches/jmb/opaque-browser/desktop/browser.c
branches/jmb/opaque-browser/desktop/browser.h
branches/jmb/opaque-browser/desktop/frames.c
branches/jmb/opaque-browser/desktop/search.c
branches/jmb/opaque-browser/desktop/selection.c
branches/jmb/opaque-browser/desktop/textinput.c
branches/jmb/opaque-browser/framebuffer/gui.c
branches/jmb/opaque-browser/framebuffer/localhistory.c
branches/jmb/opaque-browser/render/form.c
branches/jmb/opaque-browser/render/textinput.c
Modified: branches/jmb/opaque-browser/desktop/browser.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/desktop/bro...
==============================================================================
--- branches/jmb/opaque-browser/desktop/browser.c (original)
+++ branches/jmb/opaque-browser/desktop/browser.c Wed Aug 31 14:42:54 2011
@@ -42,7 +42,7 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/401login.h"
-#include "desktop/browser.h"
+#include "desktop/browser_internal.h"
#include "desktop/download.h"
#include "desktop/frames.h"
#include "desktop/history_core.h"
Modified: branches/jmb/opaque-browser/desktop/browser.h
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/desktop/bro...
==============================================================================
--- branches/jmb/opaque-browser/desktop/browser.h (original)
+++ branches/jmb/opaque-browser/desktop/browser.h Wed Aug 31 14:42:54 2011
@@ -65,143 +65,6 @@
DRAGGING_SCR_Y,
DRAGGING_OTHER
} browser_drag_type;
-
-
-
-/** Browser window data. */
-struct browser_window {
- /** Page currently displayed, or 0. Must have status READY or DONE. */
- struct hlcache_handle *current_content;
- /** Page being loaded, or 0. */
- struct hlcache_handle *loading_content;
-
- /** Window history structure. */
- struct history *history;
-
- /** Handler for keyboard input, or 0. */
- browser_caret_callback caret_callback;
- /** Handler for pasting text, or 0. */
- browser_paste_callback paste_callback;
- /** Handler for repositioning caret, or 0. */
- browser_move_callback move_callback;
-
- /** User parameters for caret_callback, paste_callback, and
- * move_callback */
- void *caret_p1;
- void *caret_p2;
-
- /** Platform specific window data. */
- struct gui_window *window;
-
- /** Busy indicator is active. */
- bool throbbing;
- /** Add loading_content to the window history when it loads. */
- bool history_add;
-
- /** Fragment identifier for current_content. */
- char *frag_id;
-
- /** Current drag status. */
- browser_drag_type drag_type;
-
- /** Current drag's browser window, when not in root bw. */
- struct browser_window *drag_window;
-
- /** Mouse position at start of current scroll drag. */
- int drag_start_x;
- int drag_start_y;
- /** Scroll offsets at start of current scroll draw. */
- int drag_start_scroll_x;
- int drag_start_scroll_y;
- /** Frame resize directions for current frame resize drag. */
- unsigned int drag_resize_left : 1;
- unsigned int drag_resize_right : 1;
- unsigned int drag_resize_up : 1;
- unsigned int drag_resize_down : 1;
-
- /** Current fetch is download */
- bool download;
-
- /** Refresh interval (-1 if undefined) */
- int refresh_interval;
-
- /** Window has been resized, and content needs reformatting. */
- bool reformat_pending;
-
- /** Window dimensions (to be phased out) */
- int x0;
- int y0;
- int x1;
- int y1;
-
- /** Window dimensions */
- int x;
- int y;
- int width;
- int height;
-
- struct scrollbar *scroll_x; /**< Horizontal scroll. */
- struct scrollbar *scroll_y; /**< Vertical scroll. */
-
- /** scale of window contents */
- float scale;
-
- /** Window characteristics */
- enum {
- BROWSER_WINDOW_NORMAL,
- BROWSER_WINDOW_IFRAME,
- BROWSER_WINDOW_FRAME,
- BROWSER_WINDOW_FRAMESET,
- } browser_window_type;
-
- /** frameset characteristics */
- int rows;
- int cols;
-
- /** frame dimensions */
- struct frame_dimension frame_width;
- struct frame_dimension frame_height;
- int margin_width;
- int margin_height;
-
- /** frame name for targetting */
- char *name;
-
- /** frame characteristics */
- bool no_resize;
- frame_scrolling scrolling;
- bool border;
- colour border_colour;
-
- /** iframe parent box */
- struct box *box;
-
- /** [cols * rows] children */
- struct browser_window *children;
- struct browser_window *parent;
-
- /** [iframe_count] iframes */
- int iframe_count;
- struct browser_window *iframes;
-
- /** browser window child of root browser window which has input focus */
- struct browser_window *focus;
-
- /** Last time a link was followed in this window */
- unsigned int last_action;
-
- /** Current selection, or NULL if none */
- struct selection *cur_sel;
-
- /** Current context for free text search, or NULL if none */
- struct search_context *cur_search;
-
- /** cache of the currently displayed status text. */
- char *status_text; /**< Current status bar text. */
- int status_text_len; /**< Length of the ::status_text buffer. */
- int status_match; /**< Number of times an idempotent status-set operation was
performed. */
- int status_miss; /**< Number of times status was really updated. */
-};
extern bool browser_reformat_pending;
@@ -265,6 +128,11 @@
bool browser_window_reload_available(struct browser_window *bw);
bool browser_window_stop_available(struct browser_window *bw);
+/* Dubious accessors */
+float browser_window_get_scale(struct browser_window *bw);
+struct hlcache_handle *browser_window_get_content(struct browser_window *bw);
+struct history *browser_window_get_history(struct browser_window *bw);
+struct gui_window *browser_window_get_window(struct browser_window *bw);
/* In desktop/textinput.c */
void browser_window_place_caret(struct browser_window *bw,
Added: branches/jmb/opaque-browser/desktop/browser_internal.h
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/desktop/bro...
==============================================================================
--- branches/jmb/opaque-browser/desktop/browser_internal.h (added)
+++ branches/jmb/opaque-browser/desktop/browser_internal.h Wed Aug 31 14:42:54 2011
@@ -1,0 +1,166 @@
+/*
+ * Copyright 2003 Phil Mellor <monkeyson(a)users.sourceforge.net>
+ * Copyright 2006 James Bursa <bursa(a)users.sourceforge.net>
+ *
+ * This file is part of NetSurf,
http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Browser window creation and manipulation (internals).
+ */
+
+#ifndef NETSURF_DESKTOP_BROWSER_H_
+#define NETSURF_DESKTOP_BROWSER_H_
+
+
+#include "desktop/browser.h"
+
+/** Browser window data. */
+struct browser_window {
+ /** Page currently displayed, or 0. Must have status READY or DONE. */
+ struct hlcache_handle *current_content;
+ /** Page being loaded, or 0. */
+ struct hlcache_handle *loading_content;
+
+ /** Window history structure. */
+ struct history *history;
+
+ /** Handler for keyboard input, or 0. */
+ browser_caret_callback caret_callback;
+ /** Handler for pasting text, or 0. */
+ browser_paste_callback paste_callback;
+ /** Handler for repositioning caret, or 0. */
+ browser_move_callback move_callback;
+
+ /** User parameters for caret_callback, paste_callback, and
+ * move_callback */
+ void *caret_p1;
+ void *caret_p2;
+
+ /** Platform specific window data. */
+ struct gui_window *window;
+
+ /** Busy indicator is active. */
+ bool throbbing;
+ /** Add loading_content to the window history when it loads. */
+ bool history_add;
+
+ /** Fragment identifier for current_content. */
+ char *frag_id;
+
+ /** Current drag status. */
+ browser_drag_type drag_type;
+
+ /** Current drag's browser window, when not in root bw. */
+ struct browser_window *drag_window;
+
+ /** Mouse position at start of current scroll drag. */
+ int drag_start_x;
+ int drag_start_y;
+ /** Scroll offsets at start of current scroll draw. */
+ int drag_start_scroll_x;
+ int drag_start_scroll_y;
+ /** Frame resize directions for current frame resize drag. */
+ unsigned int drag_resize_left : 1;
+ unsigned int drag_resize_right : 1;
+ unsigned int drag_resize_up : 1;
+ unsigned int drag_resize_down : 1;
+
+ /** Current fetch is download */
+ bool download;
+
+ /** Refresh interval (-1 if undefined) */
+ int refresh_interval;
+
+ /** Window has been resized, and content needs reformatting. */
+ bool reformat_pending;
+
+ /** Window dimensions (to be phased out) */
+ int x0;
+ int y0;
+ int x1;
+ int y1;
+
+ /** Window dimensions */
+ int x;
+ int y;
+ int width;
+ int height;
+
+ struct scrollbar *scroll_x; /**< Horizontal scroll. */
+ struct scrollbar *scroll_y; /**< Vertical scroll. */
+
+ /** scale of window contents */
+ float scale;
+
+ /** Window characteristics */
+ enum {
+ BROWSER_WINDOW_NORMAL,
+ BROWSER_WINDOW_IFRAME,
+ BROWSER_WINDOW_FRAME,
+ BROWSER_WINDOW_FRAMESET,
+ } browser_window_type;
+
+ /** frameset characteristics */
+ int rows;
+ int cols;
+
+ /** frame dimensions */
+ struct frame_dimension frame_width;
+ struct frame_dimension frame_height;
+ int margin_width;
+ int margin_height;
+
+ /** frame name for targetting */
+ char *name;
+
+ /** frame characteristics */
+ bool no_resize;
+ frame_scrolling scrolling;
+ bool border;
+ colour border_colour;
+
+ /** iframe parent box */
+ struct box *box;
+
+ /** [cols * rows] children */
+ struct browser_window *children;
+ struct browser_window *parent;
+
+ /** [iframe_count] iframes */
+ int iframe_count;
+ struct browser_window *iframes;
+
+ /** browser window child of root browser window which has input focus */
+ struct browser_window *focus;
+
+ /** Last time a link was followed in this window */
+ unsigned int last_action;
+
+ /** Current selection, or NULL if none */
+ struct selection *cur_sel;
+
+ /** Current context for free text search, or NULL if none */
+ struct search_context *cur_search;
+
+ /** cache of the currently displayed status text. */
+ char *status_text; /**< Current status bar text. */
+ int status_text_len; /**< Length of the ::status_text buffer. */
+ int status_match; /**< Number of times an idempotent status-set operation was
performed. */
+ int status_miss; /**< Number of times status was really updated. */
+};
+
+#endif
+
Modified: branches/jmb/opaque-browser/desktop/frames.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/desktop/fra...
==============================================================================
--- branches/jmb/opaque-browser/desktop/frames.c (original)
+++ branches/jmb/opaque-browser/desktop/frames.c Wed Aug 31 14:42:54 2011
@@ -30,7 +30,7 @@
#include <math.h>
#include "utils/config.h"
#include "content/hlcache.h"
-#include "desktop/browser.h"
+#include "desktop/browser_internal.h"
#include "desktop/frames.h"
#include "desktop/history_core.h"
#include "desktop/gui.h"
Modified: branches/jmb/opaque-browser/desktop/search.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/desktop/sea...
==============================================================================
--- branches/jmb/opaque-browser/desktop/search.c (original)
+++ branches/jmb/opaque-browser/desktop/search.c Wed Aug 31 14:42:54 2011
@@ -27,7 +27,7 @@
#include <string.h>
#include "content/content.h"
#include "content/hlcache.h"
-#include "desktop/browser.h"
+#include "desktop/browser_internal.h"
#include "desktop/gui.h"
#include "desktop/options.h"
#include "desktop/search.h"
Modified: branches/jmb/opaque-browser/desktop/selection.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/desktop/sel...
==============================================================================
--- branches/jmb/opaque-browser/desktop/selection.c (original)
+++ branches/jmb/opaque-browser/desktop/selection.c Wed Aug 31 14:42:54 2011
@@ -27,6 +27,7 @@
#include <stdbool.h>
#include <string.h>
+#include "desktop/browser_internal.h"
#include "desktop/gui.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
Modified: branches/jmb/opaque-browser/desktop/textinput.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/desktop/tex...
==============================================================================
--- branches/jmb/opaque-browser/desktop/textinput.c (original)
+++ branches/jmb/opaque-browser/desktop/textinput.c Wed Aug 31 14:42:54 2011
@@ -28,7 +28,7 @@
#include <ctype.h>
#include <string.h>
-#include "desktop/browser.h"
+#include "desktop/browser_internal.h"
#include "desktop/gui.h"
#include "desktop/mouse.h"
#include "desktop/scrollbar.h"
Modified: branches/jmb/opaque-browser/framebuffer/gui.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/framebuffer...
==============================================================================
--- branches/jmb/opaque-browser/framebuffer/gui.c (original)
+++ branches/jmb/opaque-browser/framebuffer/gui.c Wed Aug 31 14:42:54 2011
@@ -117,7 +117,7 @@
struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser);
int content_height;
int height;
- float scale = gw->bw->scale;
+ float scale = browser_window_get_scale(gw->bw);
LOG(("window scroll"));
if (abs) {
@@ -127,7 +127,8 @@
}
bwidget->pan_required = true;
- content_height = content_get_height(gw->bw->current_content) * scale;
+ content_height =
+ content_get_height(browser_window_get_content(gw->bw)) * scale;
height = fbtk_get_height(gw->browser);
@@ -151,7 +152,7 @@
struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser);
int content_width;
int width;
- float scale = gw->bw->scale;
+ float scale = browser_window_get_scale(gw->bw);
if (abs) {
bwidget->panx = x - bwidget->scrollx;
@@ -160,7 +161,8 @@
}
bwidget->pan_required = true;
- content_width = content_get_width(gw->bw->current_content) * scale;
+ content_width =
+ content_get_width(browser_window_get_content(gw->bw)) * scale;
width = fbtk_get_width(gw->browser);
@@ -336,8 +338,8 @@
clip.y1 = bwidget->redraw_box.y1;
browser_window_redraw(bw,
- (x - bwidget->scrollx) / bw->scale,
- (y - bwidget->scrolly) / bw->scale,
+ (x - bwidget->scrollx) / browser_window_get_scale(bw),
+ (y - bwidget->scrolly) / browser_window_get_scale(bw),
&clip, &ctx);
nsfb_update(fbtk_get_nsfb(widget), &bwidget->redraw_box);
@@ -590,7 +592,7 @@
case NSFB_EVENT_KEY_DOWN:
switch (cbi->event->value.keycode) {
case NSFB_KEY_MOUSE_1:
- scale = gw->bw->scale;
+ scale = browser_window_get_scale(gw->bw);
browser_window_mouse_click(gw->bw,
BROWSER_MOUSE_PRESS_1,
(cbi->x + bwidget->scrollx) / scale,
@@ -598,7 +600,7 @@
break;
case NSFB_KEY_MOUSE_3:
- scale = gw->bw->scale;
+ scale = browser_window_get_scale(gw->bw);
browser_window_mouse_click(gw->bw,
BROWSER_MOUSE_PRESS_2,
(cbi->x + bwidget->scrollx) / scale,
@@ -624,7 +626,7 @@
case NSFB_EVENT_KEY_UP:
switch (cbi->event->value.keycode) {
case NSFB_KEY_MOUSE_1:
- scale = gw->bw->scale;
+ scale = browser_window_get_scale(gw->bw);
browser_window_mouse_click(gw->bw,
BROWSER_MOUSE_CLICK_1,
(cbi->x + bwidget->scrollx) / scale,
@@ -632,7 +634,7 @@
break;
case NSFB_KEY_MOUSE_3:
- scale = gw->bw->scale;
+ scale = browser_window_get_scale(gw->bw);
browser_window_mouse_click(gw->bw,
BROWSER_MOUSE_CLICK_2,
(cbi->x + bwidget->scrollx) / scale,
@@ -658,10 +660,11 @@
{
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
+ float scale = browser_window_get_scale(gw->bw);
browser_window_mouse_track(gw->bw, 0,
- (cbi->x + bwidget->scrollx) / gw->bw->scale,
- (cbi->y + bwidget->scrolly) / gw->bw->scale);
+ (cbi->x + bwidget->scrollx) / scale,
+ (cbi->y + bwidget->scrolly) / scale);
return 0;
}
@@ -773,8 +776,8 @@
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- if (history_back_available(bw->history))
- history_back(bw, bw->history);
+ if (history_back_available(browser_window_get_history(bw)))
+ history_back(bw, browser_window_get_history(bw));
fb_update_back_forward(gw);
@@ -791,8 +794,8 @@
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- if (history_forward_available(bw->history))
- history_forward(bw, bw->history);
+ if (history_forward_available(browser_window_get_history(bw)))
+ history_forward(bw, browser_window_get_history(bw));
fb_update_back_forward(gw);
return 1;
@@ -1267,28 +1270,11 @@
gw->bw = bw;
- switch(bw->browser_window_type) {
- case BROWSER_WINDOW_NORMAL:
- create_normal_browser_window(gw, option_fb_furniture_size);
- gw->localhistory = fb_create_localhistory(bw, fbtk, option_fb_furniture_size);
-
- /* map and request redraw of gui window */
- fbtk_set_mapping(gw->window, true);
-
- break;
-
- case BROWSER_WINDOW_FRAME:
- gw->window = fbtk_create_window(bw->parent->window->window, 0, 0, 0, 0,
0);
- create_browser_widget(gw, 0, 0);
- LOG(("create frame"));
- break;
-
- default:
- gw->window = fbtk_create_window(bw->parent->window->window, 0, 0, 0, 0,
0);
- create_browser_widget(gw, 0, 0);
- LOG(("unhandled type"));
-
- }
+ create_normal_browser_window(gw, option_fb_furniture_size);
+ gw->localhistory = fb_create_localhistory(bw, fbtk, option_fb_furniture_size);
+
+ /* map and request redraw of gui window */
+ fbtk_set_mapping(gw->window, true);
return gw;
}
@@ -1331,8 +1317,8 @@
{
struct browser_widget_s *bwidget = fbtk_get_userpw(g->browser);
- *sx = bwidget->scrollx / g->bw->scale;
- *sy = bwidget->scrolly / g->bw->scale;
+ *sx = bwidget->scrollx / browser_window_get_scale(g->bw);
+ *sy = bwidget->scrolly / browser_window_get_scale(g->bw);
return true;
}
@@ -1344,8 +1330,8 @@
assert(bwidget);
- widget_scroll_x(gw, sx * gw->bw->scale, true);
- widget_scroll_y(gw, sy * gw->bw->scale, true);
+ widget_scroll_x(gw, sx * browser_window_get_scale(gw->bw), true);
+ widget_scroll_y(gw, sy * browser_window_get_scale(gw->bw), true);
}
void
@@ -1358,6 +1344,7 @@
void
gui_window_position_frame(struct gui_window *g, int x0, int y0, int x1, int y1)
{
+#if 0
struct gui_window *parent;
int px, py;
int w, h;
@@ -1380,7 +1367,7 @@
fbtk_set_pos_and_size(g->window, px, py , w , h);
fbtk_request_redraw(parent->browser);
-
+#endif
}
void
@@ -1393,22 +1380,23 @@
*height = fbtk_get_height(g->browser);
if (scaled) {
- *width /= g->bw->scale;
- *height /= g->bw->scale;
+ *width /= browser_window_get_scale(g->bw);
+ *height /= browser_window_get_scale(g->bw);
}
}
void
gui_window_update_extent(struct gui_window *gw)
{
- float scale = gw->bw->scale;
+ float scale = browser_window_get_scale(gw->bw);
+ hlcache_handle *content = browser_window_get_content(gw->bw);
fbtk_set_scroll_parameters(gw->hscroll, 0,
- content_get_width(gw->bw->current_content) * scale,
+ content_get_width(content) * scale,
fbtk_get_width(gw->browser), 100);
fbtk_set_scroll_parameters(gw->vscroll, 0,
- content_get_height(gw->bw->current_content) * scale,
+ content_get_height(content) * scale,
fbtk_get_height(gw->browser), 100);
}
Modified: branches/jmb/opaque-browser/framebuffer/localhistory.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/framebuffer...
==============================================================================
--- branches/jmb/opaque-browser/framebuffer/localhistory.c (original)
+++ branches/jmb/opaque-browser/framebuffer/localhistory.c Wed Aug 31 14:42:54 2011
@@ -76,7 +76,7 @@
nsfb_plot_rectangle_fill(fbtk_get_nsfb(widget), &rbox, 0xffffffff);
- history_redraw_rectangle(glh->bw->history,
+ history_redraw_rectangle(browser_window_get_history(glh->bw),
glh->scrollx,
glh->scrolly,
fbtk_get_width(widget) + glh->scrollx,
@@ -96,7 +96,8 @@
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- history_click(glh->bw, glh->bw->history, cbi->x, cbi->y, false);
+ history_click(glh->bw, browser_window_get_history(glh->bw),
+ cbi->x, cbi->y, false);
fbtk_set_mapping(glh->window, false);
Modified: branches/jmb/opaque-browser/render/form.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/render/form...
==============================================================================
--- branches/jmb/opaque-browser/render/form.c (original)
+++ branches/jmb/opaque-browser/render/form.c Wed Aug 31 14:42:54 2011
@@ -92,6 +92,8 @@
int x, int y);
static void form_select_menu_scroll_callback(void *client_data,
struct scrollbar_msg_data *scrollbar_data);
+static void form__select_process_selection(struct content *c,
+ struct form_control *control, int item);
/**
* Create a struct form.
@@ -1131,7 +1133,7 @@
{
struct form_select_menu *menu = control->data.select.menu;
struct form_option *option;
- html_content *html = (html_content *)menu->c;
+ html_content *html = (html_content *) menu->c;
int line_height, line_height_with_spacing;
int item_bottom_y;
int scroll, i;
@@ -1152,9 +1154,7 @@
}
if (option != NULL) {
- /* TODO: going via the bw to get a hlcache_handle is nasty */
- form_select_process_selection(html->bw->current_content,
- control, i);
+ form__select_process_selection(&html->base, control, i);
}
menu->callback(menu->client_data, 0, 0, menu->width, menu->height);
@@ -1292,7 +1292,8 @@
menu->scroll_capture = true;
root_bw = browser_window_get_root(html->bw);
- gui_window_box_scroll_start(root_bw->window,
+ gui_window_box_scroll_start(
+ browser_window_get_window(root_bw),
scrollbar_data->x0, scrollbar_data->y0,
scrollbar_data->x1, scrollbar_data->y1);
break;
@@ -1330,17 +1331,24 @@
void form_select_process_selection(hlcache_handle *h,
struct form_control *control, int item)
{
+ assert(h != NULL);
+
+ /** \todo Even though the form code is effectively part of the html
+ * content handler, poking around inside contents is not good */
+ form__select_process_selection(hlcache_handle_get_content(h),
+ control, item);
+}
+
+void form__select_process_selection(struct content *c,
+ struct form_control *control, int item)
+{
struct box *inline_box;
struct form_option *o;
int count;
- struct content *current_content;
assert(control != NULL);
- assert(h != NULL);
-
- /** \todo Even though the form code is effectively part of the html
- * content handler, poking around inside contents is not good */
- current_content = hlcache_handle_get_content(h);
+ assert(c != NULL);
+
inline_box = control->box->children->children;
@@ -1369,14 +1377,12 @@
talloc_free(inline_box->text);
inline_box->text = 0;
if (control->data.select.num_selected == 0)
- inline_box->text = talloc_strdup(current_content,
- messages_get("Form_None"));
+ inline_box->text = talloc_strdup(c, messages_get("Form_None"));
else if (control->data.select.num_selected == 1)
- inline_box->text = talloc_strdup(current_content,
+ inline_box->text = talloc_strdup(c,
control->data.select.current->text);
else
- inline_box->text = talloc_strdup(current_content,
- messages_get("Form_Many"));
+ inline_box->text = talloc_strdup(c, messages_get("Form_Many"));
if (!inline_box->text) {
warn_user("NoMemory", 0);
inline_box->length = 0;
@@ -1384,7 +1390,7 @@
inline_box->length = strlen(inline_box->text);
inline_box->width = control->box->width;
- html_redraw_a_box(h, control->box);
+ html__redraw_a_box(c, control->box);
}
/**
Modified: branches/jmb/opaque-browser/render/textinput.c
URL:
http://source.netsurf-browser.org/branches/jmb/opaque-browser/render/text...
==============================================================================
--- branches/jmb/opaque-browser/render/textinput.c (original)
+++ branches/jmb/opaque-browser/render/textinput.c Wed Aug 31 14:42:54 2011
@@ -1305,7 +1305,7 @@
break;
case KEY_PASTE:
- gui_paste_from_clipboard(bw->window,
+ gui_paste_from_clipboard(browser_window_get_window(bw),
box_x + inline_container->x +
text_box->x + pixel_offset,
box_y + inline_container->y + text_box->y);
@@ -1907,8 +1907,11 @@
case KEY_CR: /* Return/Enter hit */
selection_clear(&html->sel, true);
- if (form)
- form_submit(bw->current_content, bw, form, 0);
+ if (form) {
+ form_submit(browser_window_get_content(bw),
+ bw, form, 0);
+ }
+
return true;
case KEY_SHIFT_TAB:
@@ -1946,7 +1949,7 @@
break;
case KEY_PASTE:
- gui_paste_from_clipboard(bw->window,
+ gui_paste_from_clipboard(browser_window_get_window(bw),
box_x + input->children->x + text_box->x + pixel_offset,
box_y + input->children->y + text_box->y);