Author: tlsa
Date: Thu Jun 30 13:27:24 2011
New Revision: 12546
URL:
http://source.netsurf-browser.org?rev=12546&view=rev
Log:
Make text/plain contents aware of the browser window they are opened in.
Modified:
trunk/netsurf/render/textplain.c
Modified: trunk/netsurf/render/textplain.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/render/textplain.c?rev=12...
==============================================================================
--- trunk/netsurf/render/textplain.c (original)
+++ trunk/netsurf/render/textplain.c Thu Jun 30 13:27:24 2011
@@ -66,6 +66,7 @@
unsigned long physical_line_count;
struct textplain_line *physical_line;
int formatted_width;
+ struct browser_window *bw;
} textplain_content;
@@ -104,6 +105,9 @@
static void textplain_destroy(struct content *c);
static bool textplain_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip, const struct redraw_context *ctx);
+static void textplain_open(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params);
static nserror textplain_clone(const struct content *old,
struct content **newc);
static content_type textplain_content_type(lwc_string *mime_type);
@@ -127,6 +131,7 @@
.mouse_track = textplain_mouse_track,
.mouse_action = textplain_mouse_action,
.redraw = textplain_redraw,
+ .open = textplain_open,
.clone = textplain_clone,
.type = textplain_content_type,
.no_share = true,
@@ -259,6 +264,7 @@
c->physical_line = 0;
c->physical_line_count = 0;
c->formatted_width = 0;
+ c->bw = NULL;
return NSERROR_OK;
@@ -679,7 +685,7 @@
const struct rect *clip, const struct redraw_context *ctx)
{
textplain_content *text = (textplain_content *) c;
- struct browser_window *bw = current_redraw_browser;
+ struct browser_window *bw = text->bw;
const struct plotter_table *plot = ctx->plot;
char *utf8_data = text->utf8_data;
long lineno;
@@ -805,6 +811,20 @@
return true;
}
+
+/**
+ * Handle a window containing a CONTENT_TEXTPLAIN being opened.
+ */
+
+void textplain_open(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params)
+{
+ textplain_content *textplain = (textplain_content *) c;
+
+ textplain->bw = bw;
+}
+
/**
* Retrieve number of lines in content
*