Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/4953bd0fe1914860ede6c80c0d6c7fcb5492f613
...commit
http://git.netsurf-browser.org/netsurf.git/commit/4953bd0fe1914860ede6c80c0d6c7fcb5492f613
...tree
http://git.netsurf-browser.org/netsurf.git/tree/4953bd0fe1914860ede6c80c0d6c7fcb5492f613
The branch, vince/pdf has been updated
via 4953bd0fe1914860ede6c80c0d6c7fcb5492f613 (commit)
from 5b02a041fab685098e11fe14f9e6486b60730661 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=4953bd0fe1914860ede6c80c0d6c7fcb5492f613
commit 4953bd0fe1914860ede6c80c0d6c7fcb5492f613
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
allow clicking to change page
diff --git a/content/content.c b/content/content.c
index 9a24041..d359268 100644
--- a/content/content.c
+++ b/content/content.c
@@ -544,7 +544,7 @@ void content__request_redraw(struct content *c,
}
-/* exported interface, documented in content/content.h */
+/* exported interface, documented in content/content_protected.h */
bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
const struct rect *clip, const struct redraw_context *ctx)
{
diff --git a/content/handlers/pdf/pdf.c b/content/handlers/pdf/pdf.c
index d62f1ff..d8c4d61 100644
--- a/content/handlers/pdf/pdf.c
+++ b/content/handlers/pdf/pdf.c
@@ -31,7 +31,10 @@
#include <nspdf/meta.h>
#include <nspdf/page.h>
+#include "utils/messages.h"
#include "utils/utils.h"
+#include "netsurf/plotters.h"
+#include "netsurf/content.h"
#include "content/llcache.h"
#include "content/content_protected.h"
@@ -41,6 +44,8 @@ typedef struct pdf_content {
struct content base;
struct nspdf_doc *doc;
+
+ unsigned int current_page;
} pdf_content;
static nserror nspdf2nserr(nspdferror nspdferr)
@@ -120,6 +125,8 @@ static bool pdf_convert(struct content *c)
const uint8_t *content_data;
unsigned long content_length;
struct lwc_string_s *title;
+ float page_width;
+ float page_height;
content_data = (const uint8_t *)content__get_source_data(c,
&content_length);
@@ -137,6 +144,18 @@ static bool pdf_convert(struct content *c)
content__set_title(c, lwc_string_data(title));
}
+ /** \todo extract documents starting page number */
+ pdfc->current_page = 0;
+
+ pdfres = nspdf_get_page_dimensions(pdfc->doc,
+ pdfc->current_page,
+ &page_width,
+ &page_height);
+ if (pdfres == NSPDFERROR_OK) {
+ pdfc->base.width = page_width;
+ pdfc->base.height = page_height;
+ }
+
content_set_ready(c);
content_set_done(c);
@@ -145,11 +164,19 @@ static bool pdf_convert(struct content *c)
static nspdferror
pdf_path(const struct nspdf_style *style,
- const float *p,
- unsigned int n,
+ const float *path,
+ unsigned int path_length,
const float transform[6],
- const void *ctx)
+ const void *ctxin)
{
+ const struct redraw_context *ctx = ctxin;
+
+ ctx->plot->path(ctx,
+ style,
+ path,
+ path_length,
+ style->stroke_width,
+ transform);
return NSPDFERROR_OK;
}
@@ -164,16 +191,20 @@ pdf_redraw(struct content *c,
nspdferror pdfres;
struct nspdf_render_ctx render_ctx;
+ printf("data x:%d y:%d w:%d h:%d\nclip %d %d %d %d\n",
+ data->x, data->y, data->width, data->height,
+ clip->x0, clip->y0, clip->x1, clip->y1);
+
render_ctx.ctx = ctx;
- render_ctx.device_space[0] = 1;
+ render_ctx.device_space[0] = 1; /* scale x */
render_ctx.device_space[1] = 0;
render_ctx.device_space[2] = 0;
- render_ctx.device_space[3] = 1;
+ render_ctx.device_space[3] = -1; /* scale y */
render_ctx.device_space[4] = 0; /* x offset */
- render_ctx.device_space[5] = -200; /* y offset */
+ render_ctx.device_space[5] = data->height; /* y offset */
render_ctx.path = pdf_path;
- pdfres = nspdf_page_render(pdfc->doc, 0, &render_ctx);
+ pdfres = nspdf_page_render(pdfc->doc, pdfc->current_page, &render_ctx);
return true;
@@ -192,12 +223,42 @@ static content_type pdf_content_type(void)
return CONTENT_PDF;
}
+static void
+pdf_mouse_action(struct content *c,
+ struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
+{
+ struct pdf_content *pdfc = (struct pdf_content *)c;
+ nspdferror pdfres;
+ printf("ici\n");
+ if (mouse & BROWSER_MOUSE_CLICK_1) {
+ float page_width;
+ float page_height;
+
+ pdfc->current_page++;
+
+ pdfres = nspdf_get_page_dimensions(pdfc->doc,
+ pdfc->current_page,
+ &page_width,
+ &page_height);
+ if (pdfres == NSPDFERROR_OK) {
+ pdfc->base.width = page_width;
+ pdfc->base.height = page_height;
+ printf("page $d w:%f h:%f\n",pdfc->current_page,
page_width, page_height);
+ }
+
+ browser_window_update(bw, false);
+
+ }
+}
static const content_handler nspdf_content_handler = {
.create = pdf_create,
.data_complete = pdf_convert,
.destroy = pdf_destroy,
.redraw = pdf_redraw,
+ .mouse_action = pdf_mouse_action,
.clone = pdf_clone,
.type = pdf_content_type,
.no_share = false,
diff --git a/desktop/browser.c b/desktop/browser.c
index 19cfebb..e9d19ca 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -3259,6 +3259,7 @@ void browser_window_mouse_click(struct browser_window *bw,
switch (content_get_type(c)) {
case CONTENT_HTML:
+ case CONTENT_PDF:
case CONTENT_TEXTPLAIN:
{
/* Give bw focus */
diff --git a/frontends/gtk/plotters.c b/frontends/gtk/plotters.c
index 88e7760..b40d5c1 100644
--- a/frontends/gtk/plotters.c
+++ b/frontends/gtk/plotters.c
@@ -421,7 +421,7 @@ nsgtk_plot_path(const struct redraw_context *ctx,
cairo_get_matrix(current_cr, &old_ctm);
/* Set up line style and width */
- cairo_set_line_width(current_cr, 1);
+ cairo_set_line_width(current_cr, width);
nsgtk_set_solid();
/* Load new CTM */
-----------------------------------------------------------------------
Summary of changes:
content/content.c | 2 +-
content/handlers/pdf/pdf.c | 75 +++++++++++++++++++++++++++++++++++++++-----
desktop/browser.c | 1 +
frontends/gtk/plotters.c | 2 +-
4 files changed, 71 insertions(+), 9 deletions(-)
diff --git a/content/content.c b/content/content.c
index 9a24041..d359268 100644
--- a/content/content.c
+++ b/content/content.c
@@ -544,7 +544,7 @@ void content__request_redraw(struct content *c,
}
-/* exported interface, documented in content/content.h */
+/* exported interface, documented in content/content_protected.h */
bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
const struct rect *clip, const struct redraw_context *ctx)
{
diff --git a/content/handlers/pdf/pdf.c b/content/handlers/pdf/pdf.c
index d62f1ff..d8c4d61 100644
--- a/content/handlers/pdf/pdf.c
+++ b/content/handlers/pdf/pdf.c
@@ -31,7 +31,10 @@
#include <nspdf/meta.h>
#include <nspdf/page.h>
+#include "utils/messages.h"
#include "utils/utils.h"
+#include "netsurf/plotters.h"
+#include "netsurf/content.h"
#include "content/llcache.h"
#include "content/content_protected.h"
@@ -41,6 +44,8 @@ typedef struct pdf_content {
struct content base;
struct nspdf_doc *doc;
+
+ unsigned int current_page;
} pdf_content;
static nserror nspdf2nserr(nspdferror nspdferr)
@@ -120,6 +125,8 @@ static bool pdf_convert(struct content *c)
const uint8_t *content_data;
unsigned long content_length;
struct lwc_string_s *title;
+ float page_width;
+ float page_height;
content_data = (const uint8_t *)content__get_source_data(c,
&content_length);
@@ -137,6 +144,18 @@ static bool pdf_convert(struct content *c)
content__set_title(c, lwc_string_data(title));
}
+ /** \todo extract documents starting page number */
+ pdfc->current_page = 0;
+
+ pdfres = nspdf_get_page_dimensions(pdfc->doc,
+ pdfc->current_page,
+ &page_width,
+ &page_height);
+ if (pdfres == NSPDFERROR_OK) {
+ pdfc->base.width = page_width;
+ pdfc->base.height = page_height;
+ }
+
content_set_ready(c);
content_set_done(c);
@@ -145,11 +164,19 @@ static bool pdf_convert(struct content *c)
static nspdferror
pdf_path(const struct nspdf_style *style,
- const float *p,
- unsigned int n,
+ const float *path,
+ unsigned int path_length,
const float transform[6],
- const void *ctx)
+ const void *ctxin)
{
+ const struct redraw_context *ctx = ctxin;
+
+ ctx->plot->path(ctx,
+ style,
+ path,
+ path_length,
+ style->stroke_width,
+ transform);
return NSPDFERROR_OK;
}
@@ -164,16 +191,20 @@ pdf_redraw(struct content *c,
nspdferror pdfres;
struct nspdf_render_ctx render_ctx;
+ printf("data x:%d y:%d w:%d h:%d\nclip %d %d %d %d\n",
+ data->x, data->y, data->width, data->height,
+ clip->x0, clip->y0, clip->x1, clip->y1);
+
render_ctx.ctx = ctx;
- render_ctx.device_space[0] = 1;
+ render_ctx.device_space[0] = 1; /* scale x */
render_ctx.device_space[1] = 0;
render_ctx.device_space[2] = 0;
- render_ctx.device_space[3] = 1;
+ render_ctx.device_space[3] = -1; /* scale y */
render_ctx.device_space[4] = 0; /* x offset */
- render_ctx.device_space[5] = -200; /* y offset */
+ render_ctx.device_space[5] = data->height; /* y offset */
render_ctx.path = pdf_path;
- pdfres = nspdf_page_render(pdfc->doc, 0, &render_ctx);
+ pdfres = nspdf_page_render(pdfc->doc, pdfc->current_page, &render_ctx);
return true;
@@ -192,12 +223,42 @@ static content_type pdf_content_type(void)
return CONTENT_PDF;
}
+static void
+pdf_mouse_action(struct content *c,
+ struct browser_window *bw,
+ browser_mouse_state mouse,
+ int x, int y)
+{
+ struct pdf_content *pdfc = (struct pdf_content *)c;
+ nspdferror pdfres;
+ printf("ici\n");
+ if (mouse & BROWSER_MOUSE_CLICK_1) {
+ float page_width;
+ float page_height;
+
+ pdfc->current_page++;
+
+ pdfres = nspdf_get_page_dimensions(pdfc->doc,
+ pdfc->current_page,
+ &page_width,
+ &page_height);
+ if (pdfres == NSPDFERROR_OK) {
+ pdfc->base.width = page_width;
+ pdfc->base.height = page_height;
+ printf("page $d w:%f h:%f\n",pdfc->current_page,
page_width, page_height);
+ }
+
+ browser_window_update(bw, false);
+
+ }
+}
static const content_handler nspdf_content_handler = {
.create = pdf_create,
.data_complete = pdf_convert,
.destroy = pdf_destroy,
.redraw = pdf_redraw,
+ .mouse_action = pdf_mouse_action,
.clone = pdf_clone,
.type = pdf_content_type,
.no_share = false,
diff --git a/desktop/browser.c b/desktop/browser.c
index 19cfebb..e9d19ca 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -3259,6 +3259,7 @@ void browser_window_mouse_click(struct browser_window *bw,
switch (content_get_type(c)) {
case CONTENT_HTML:
+ case CONTENT_PDF:
case CONTENT_TEXTPLAIN:
{
/* Give bw focus */
diff --git a/frontends/gtk/plotters.c b/frontends/gtk/plotters.c
index 88e7760..b40d5c1 100644
--- a/frontends/gtk/plotters.c
+++ b/frontends/gtk/plotters.c
@@ -421,7 +421,7 @@ nsgtk_plot_path(const struct redraw_context *ctx,
cairo_get_matrix(current_cr, &old_ctm);
/* Set up line style and width */
- cairo_set_line_width(current_cr, 1);
+ cairo_set_line_width(current_cr, width);
nsgtk_set_solid();
/* Load new CTM */
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org