netsurf: branch master updated. release/3.2-273-g8947af7
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8947af72ce5fb2600531a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8947af72ce5fb2600531a9a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8947af72ce5fb2600531a9a0f...
The branch, master has been updated
via 8947af72ce5fb2600531a9a0f2ac711030b7e06a (commit)
from b1ee46cfb3f9617115e313da500d9b08d01ac345 (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=8947af72ce5fb260053...
commit 8947af72ce5fb2600531a9a0f2ac711030b7e06a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make history update return error code.
This now returns errors instead of failing and inconsistantly calling
user warnings for some error paths.
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index f10f351..d4785d8 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -555,14 +555,8 @@ nserror browser_window_history_add(struct browser_window *bw,
}
-/**
- * Update the thumbnail for the current entry.
- *
- * \param history opaque history structure, as returned by history_create()
- * \param content content for current entry
- */
-
-void browser_window_history_update(struct browser_window *bw,
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_update(struct browser_window *bw,
struct hlcache_handle *content)
{
struct history *history;
@@ -572,23 +566,24 @@ void browser_window_history_update(struct browser_window *bw,
history = bw->history;
- if (!history || !history->current || !history->current->bitmap)
- return;
+ if (!history || !history->current || !history->current->bitmap) {
+ return NSERROR_INVALID;
+ }
assert(history->current->page.url);
assert(history->current->page.title);
title = strdup(content_get_title(content));
- if (!title) {
- warn_user("NoMemory", 0);
- return;
+ if (title == NULL) {
+ return NSERROR_NOMEM;
}
- assert(title);
free(history->current->page.title);
history->current->page.title = title;
thumbnail_create(content, history->current->bitmap, NULL);
+
+ return NSERROR_OK;
}
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
index d7b2b25..1aac414 100644
--- a/desktop/browser_history.h
+++ b/desktop/browser_history.h
@@ -48,8 +48,17 @@ nserror browser_window_history_clone(const struct browser_window *existing,
*/
nserror browser_window_history_add(struct browser_window *bw,
struct hlcache_handle *content, lwc_string *frag_id);
-void browser_window_history_update(struct browser_window *bw,
+
+/**
+ * Update the thumbnail for the current entry.
+ *
+ * \param bw The browser window to update the history within.
+ * \param content content for current entry
+ * \return NSERROR_OK or error code on faliure.
+ */
+nserror browser_window_history_update(struct browser_window *bw,
struct hlcache_handle *content);
+
void browser_window_history_destroy(struct browser_window *bw);
void browser_window_history_back(struct browser_window *bw, bool new_window);
void browser_window_history_forward(struct browser_window *bw, bool new_window);
-----------------------------------------------------------------------
Summary of changes:
desktop/browser_history.c | 23 +++++++++--------------
desktop/browser_history.h | 11 ++++++++++-
2 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index f10f351..d4785d8 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -555,14 +555,8 @@ nserror browser_window_history_add(struct browser_window *bw,
}
-/**
- * Update the thumbnail for the current entry.
- *
- * \param history opaque history structure, as returned by history_create()
- * \param content content for current entry
- */
-
-void browser_window_history_update(struct browser_window *bw,
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_update(struct browser_window *bw,
struct hlcache_handle *content)
{
struct history *history;
@@ -572,23 +566,24 @@ void browser_window_history_update(struct browser_window *bw,
history = bw->history;
- if (!history || !history->current || !history->current->bitmap)
- return;
+ if (!history || !history->current || !history->current->bitmap) {
+ return NSERROR_INVALID;
+ }
assert(history->current->page.url);
assert(history->current->page.title);
title = strdup(content_get_title(content));
- if (!title) {
- warn_user("NoMemory", 0);
- return;
+ if (title == NULL) {
+ return NSERROR_NOMEM;
}
- assert(title);
free(history->current->page.title);
history->current->page.title = title;
thumbnail_create(content, history->current->bitmap, NULL);
+
+ return NSERROR_OK;
}
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
index d7b2b25..1aac414 100644
--- a/desktop/browser_history.h
+++ b/desktop/browser_history.h
@@ -48,8 +48,17 @@ nserror browser_window_history_clone(const struct browser_window *existing,
*/
nserror browser_window_history_add(struct browser_window *bw,
struct hlcache_handle *content, lwc_string *frag_id);
-void browser_window_history_update(struct browser_window *bw,
+
+/**
+ * Update the thumbnail for the current entry.
+ *
+ * \param bw The browser window to update the history within.
+ * \param content content for current entry
+ * \return NSERROR_OK or error code on faliure.
+ */
+nserror browser_window_history_update(struct browser_window *bw,
struct hlcache_handle *content);
+
void browser_window_history_destroy(struct browser_window *bw);
void browser_window_history_back(struct browser_window *bw, bool new_window);
void browser_window_history_forward(struct browser_window *bw, bool new_window);
--
NetSurf Browser
8 years, 3 months
netsurf: branch master updated. release/3.2-272-gb1ee46c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/b1ee46cfb3f9617115e31...
...commit http://git.netsurf-browser.org/netsurf.git/commit/b1ee46cfb3f9617115e313d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/b1ee46cfb3f9617115e313da5...
The branch, master has been updated
via b1ee46cfb3f9617115e313da500d9b08d01ac345 (commit)
via a221fa721360e4aef1488eddc4891e10c26cb73d (commit)
from 847e1111bce323ba5277c4babf70c5441233bcd7 (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=b1ee46cfb3f9617115e...
commit b1ee46cfb3f9617115e313da500d9b08d01ac345
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make adding a history entry return an error code.
This returns the error code to the caller instead of (sometimes)
warning the user directly.
diff --git a/desktop/browser.c b/desktop/browser.c
index a13c294..b1c4044 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1332,7 +1332,7 @@ static nserror browser_window_callback(hlcache_handle *c,
/* This is safe as we've just added the URL */
global_history_add(urldb_get_url(url));
}
- /* TODO: Urldb / Thumbnails / Local history brokenness
+ /** \todo Urldb / Thumbnails / Local history brokenness
*
* We add to local history after calling urldb_add_url
* rather than in the block above. If urldb_add_url
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 309bcb2..f10f351 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -482,18 +482,8 @@ nserror browser_window_history_clone(const struct browser_window *existing,
}
-/**
- * Insert a url into the history tree.
- *
- * \param bw browser window with history object
- * \param content content to add to history
- * \param frag_id fragment identifier, or NULL.
- *
- * The page is added after the current entry and becomes current.
- */
-
-
-void browser_window_history_add(struct browser_window *bw,
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_add(struct browser_window *bw,
struct hlcache_handle *content, lwc_string *frag_id)
{
struct history *history;
@@ -510,14 +500,14 @@ void browser_window_history_add(struct browser_window *bw,
/* allocate space */
entry = malloc(sizeof *entry);
- if (entry == NULL)
- return;
+ if (entry == NULL) {
+ return NSERROR_NOMEM;
+ }
title = strdup(content_get_title(content));
if (title == NULL) {
- warn_user("NoMemory", 0);
free(entry);
- return;
+ return NSERROR_NOMEM;
}
entry->page.url = nsurl_ref(nsurl);
@@ -545,16 +535,13 @@ void browser_window_history_add(struct browser_window *bw,
/* if we have a thumbnail, don't update until the page has finished
* loading */
bitmap = urldb_get_thumbnail(nsurl);
- if (!bitmap) {
+ if (bitmap == NULL) {
LOG(("Creating thumbnail for %s", nsurl_access(nsurl)));
bitmap = bitmap_create(WIDTH, HEIGHT,
BITMAP_NEW | BITMAP_CLEAR_MEMORY |
BITMAP_OPAQUE);
- if (!bitmap) {
- warn_user("NoMemory", 0);
- return;
- }
- if (thumbnail_create(content, bitmap, nsurl) == false) {
+ if ((bitmap != NULL) &&
+ (thumbnail_create(content, bitmap, nsurl) == false)) {
/* Thumbnailing failed. Ignore it silently */
bitmap_destroy(bitmap);
bitmap = NULL;
@@ -563,6 +550,8 @@ void browser_window_history_add(struct browser_window *bw,
entry->bitmap = bitmap;
browser_window_history__layout(history);
+
+ return NSERROR_OK;
}
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
index f3e524b..d7b2b25 100644
--- a/desktop/browser_history.h
+++ b/desktop/browser_history.h
@@ -36,7 +36,17 @@ struct redraw_context;
nserror browser_window_history_create(struct browser_window *bw);
nserror browser_window_history_clone(const struct browser_window *existing,
struct browser_window *clone);
-void browser_window_history_add(struct browser_window *bw,
+/**
+ * Insert a url into the history tree.
+ *
+ * \param bw browser window with history object
+ * \param content content to add to history
+ * \param frag_id fragment identifier, or NULL.
+ * \return NSERROR_OK or error code on faliure.
+ *
+ * The page is added after the current entry and becomes current.
+ */
+nserror browser_window_history_add(struct browser_window *bw,
struct hlcache_handle *content, lwc_string *frag_id);
void browser_window_history_update(struct browser_window *bw,
struct hlcache_handle *content);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a221fa721360e4aef14...
commit a221fa721360e4aef1488eddc4891e10c26cb73d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Ensure browser window creation returns errors from common initialisation.
The browser window common initialisation code returns error codes which
were being ignored. The errors were additionally being reported via
warn_user in inappropriate places within browser history construction.
diff --git a/desktop/browser.c b/desktop/browser.c
index e6fc2f7..a13c294 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -752,6 +752,7 @@ nserror browser_window_create(enum browser_window_create_flags flags,
{
gui_window_create_flags gw_flags = GW_CREATE_NONE;
struct browser_window *ret;
+ nserror err;
/* Check parameters */
if (flags & BW_CREATE_CLONE) {
@@ -778,7 +779,11 @@ nserror browser_window_create(enum browser_window_create_flags flags,
NULL);
/* Initialise common parts */
- browser_window_initialise_common(flags, ret, existing);
+ err = browser_window_initialise_common(flags, ret, existing);
+ if (err != NSERROR_OK) {
+ browser_window_destroy(ret);
+ return err;
+ }
/* window characteristics */
ret->browser_window_type = BROWSER_WINDOW_NORMAL;
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 445c0ee..309bcb2 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -416,9 +416,9 @@ static bool browser_window_history__enumerate_entry(
/**
* Create a new history tree for a browser window window.
*
- * \param bw browser window to create history for.
+ * \param bw browser window to create history for.
*
- * \return NSERROR_OK or appropriate error otherwise
+ * \return NSERROR_OK or appropriate error otherwise
*/
nserror browser_window_history_create(struct browser_window *bw)
@@ -428,10 +428,10 @@ nserror browser_window_history_create(struct browser_window *bw)
bw->history = NULL;
history = calloc(1, sizeof *history);
- if (!history) {
- warn_user("NoMemory", 0);
+ if (history == NULL) {
return NSERROR_NOMEM;
}
+
history->width = RIGHT_MARGIN / 2;
history->height = BOTTOM_MARGIN / 2;
@@ -473,7 +473,6 @@ nserror browser_window_history_clone(const struct browser_window *existing,
new_history->start);
if (!new_history->start) {
LOG(("Insufficient memory to clone history"));
- warn_user("NoMemory", 0);
browser_window_history_destroy(clone);
clone->history = NULL;
return NSERROR_NOMEM;
-----------------------------------------------------------------------
Summary of changes:
desktop/browser.c | 9 +++++++--
desktop/browser_history.c | 42 +++++++++++++++---------------------------
desktop/browser_history.h | 12 +++++++++++-
3 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/desktop/browser.c b/desktop/browser.c
index e6fc2f7..b1c4044 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -752,6 +752,7 @@ nserror browser_window_create(enum browser_window_create_flags flags,
{
gui_window_create_flags gw_flags = GW_CREATE_NONE;
struct browser_window *ret;
+ nserror err;
/* Check parameters */
if (flags & BW_CREATE_CLONE) {
@@ -778,7 +779,11 @@ nserror browser_window_create(enum browser_window_create_flags flags,
NULL);
/* Initialise common parts */
- browser_window_initialise_common(flags, ret, existing);
+ err = browser_window_initialise_common(flags, ret, existing);
+ if (err != NSERROR_OK) {
+ browser_window_destroy(ret);
+ return err;
+ }
/* window characteristics */
ret->browser_window_type = BROWSER_WINDOW_NORMAL;
@@ -1327,7 +1332,7 @@ static nserror browser_window_callback(hlcache_handle *c,
/* This is safe as we've just added the URL */
global_history_add(urldb_get_url(url));
}
- /* TODO: Urldb / Thumbnails / Local history brokenness
+ /** \todo Urldb / Thumbnails / Local history brokenness
*
* We add to local history after calling urldb_add_url
* rather than in the block above. If urldb_add_url
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 445c0ee..f10f351 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -416,9 +416,9 @@ static bool browser_window_history__enumerate_entry(
/**
* Create a new history tree for a browser window window.
*
- * \param bw browser window to create history for.
+ * \param bw browser window to create history for.
*
- * \return NSERROR_OK or appropriate error otherwise
+ * \return NSERROR_OK or appropriate error otherwise
*/
nserror browser_window_history_create(struct browser_window *bw)
@@ -428,10 +428,10 @@ nserror browser_window_history_create(struct browser_window *bw)
bw->history = NULL;
history = calloc(1, sizeof *history);
- if (!history) {
- warn_user("NoMemory", 0);
+ if (history == NULL) {
return NSERROR_NOMEM;
}
+
history->width = RIGHT_MARGIN / 2;
history->height = BOTTOM_MARGIN / 2;
@@ -473,7 +473,6 @@ nserror browser_window_history_clone(const struct browser_window *existing,
new_history->start);
if (!new_history->start) {
LOG(("Insufficient memory to clone history"));
- warn_user("NoMemory", 0);
browser_window_history_destroy(clone);
clone->history = NULL;
return NSERROR_NOMEM;
@@ -483,18 +482,8 @@ nserror browser_window_history_clone(const struct browser_window *existing,
}
-/**
- * Insert a url into the history tree.
- *
- * \param bw browser window with history object
- * \param content content to add to history
- * \param frag_id fragment identifier, or NULL.
- *
- * The page is added after the current entry and becomes current.
- */
-
-
-void browser_window_history_add(struct browser_window *bw,
+/* exported interface documented in desktop/browser_history.h */
+nserror browser_window_history_add(struct browser_window *bw,
struct hlcache_handle *content, lwc_string *frag_id)
{
struct history *history;
@@ -511,14 +500,14 @@ void browser_window_history_add(struct browser_window *bw,
/* allocate space */
entry = malloc(sizeof *entry);
- if (entry == NULL)
- return;
+ if (entry == NULL) {
+ return NSERROR_NOMEM;
+ }
title = strdup(content_get_title(content));
if (title == NULL) {
- warn_user("NoMemory", 0);
free(entry);
- return;
+ return NSERROR_NOMEM;
}
entry->page.url = nsurl_ref(nsurl);
@@ -546,16 +535,13 @@ void browser_window_history_add(struct browser_window *bw,
/* if we have a thumbnail, don't update until the page has finished
* loading */
bitmap = urldb_get_thumbnail(nsurl);
- if (!bitmap) {
+ if (bitmap == NULL) {
LOG(("Creating thumbnail for %s", nsurl_access(nsurl)));
bitmap = bitmap_create(WIDTH, HEIGHT,
BITMAP_NEW | BITMAP_CLEAR_MEMORY |
BITMAP_OPAQUE);
- if (!bitmap) {
- warn_user("NoMemory", 0);
- return;
- }
- if (thumbnail_create(content, bitmap, nsurl) == false) {
+ if ((bitmap != NULL) &&
+ (thumbnail_create(content, bitmap, nsurl) == false)) {
/* Thumbnailing failed. Ignore it silently */
bitmap_destroy(bitmap);
bitmap = NULL;
@@ -564,6 +550,8 @@ void browser_window_history_add(struct browser_window *bw,
entry->bitmap = bitmap;
browser_window_history__layout(history);
+
+ return NSERROR_OK;
}
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
index f3e524b..d7b2b25 100644
--- a/desktop/browser_history.h
+++ b/desktop/browser_history.h
@@ -36,7 +36,17 @@ struct redraw_context;
nserror browser_window_history_create(struct browser_window *bw);
nserror browser_window_history_clone(const struct browser_window *existing,
struct browser_window *clone);
-void browser_window_history_add(struct browser_window *bw,
+/**
+ * Insert a url into the history tree.
+ *
+ * \param bw browser window with history object
+ * \param content content to add to history
+ * \param frag_id fragment identifier, or NULL.
+ * \return NSERROR_OK or error code on faliure.
+ *
+ * The page is added after the current entry and becomes current.
+ */
+nserror browser_window_history_add(struct browser_window *bw,
struct hlcache_handle *content, lwc_string *frag_id);
void browser_window_history_update(struct browser_window *bw,
struct hlcache_handle *content);
--
NetSurf Browser
8 years, 3 months
netsurf: branch master updated. release/3.2-270-g847e111
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/847e1111bce323ba5277c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/847e1111bce323ba5277c4b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/847e1111bce323ba5277c4bab...
The branch, master has been updated
via 847e1111bce323ba5277c4babf70c5441233bcd7 (commit)
from d900feefba603b07655b0e95d15753706e59638e (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=847e1111bce323ba527...
commit 847e1111bce323ba5277c4babf70c5441233bcd7
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix beos url setting function to return error code
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 48cf72e..cdd809f 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -2166,18 +2166,21 @@ void gui_window_set_status(struct gui_window *_g, const char *text)
g->top_view->UnlockLooper();
}
-nserror gui_window_set_url(struct gui_window *_g, const char *url)
+nserror gui_window_set_url(struct gui_window *gw, const char *url)
{
- struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
- if (g->top_level != _g) return;
- assert(g->status_bar);
+ struct beos_scaffolding *g;
- if (!g->top_view->LockLooper())
- return;
+ g = nsbeos_get_scaffold(gw);
+ if (g->top_level != gw)
+ return NSERROR_OK;
+
+ assert(g->status_bar);
- g->url_bar->SetText(url);
+ if (g->top_view->LockLooper()) {
+ g->url_bar->SetText(url);
- g->top_view->UnlockLooper();
+ g->top_view->UnlockLooper();
+ }
return NSERROR_OK;
}
-----------------------------------------------------------------------
Summary of changes:
beos/scaffolding.cpp | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 48cf72e..cdd809f 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -2166,18 +2166,21 @@ void gui_window_set_status(struct gui_window *_g, const char *text)
g->top_view->UnlockLooper();
}
-nserror gui_window_set_url(struct gui_window *_g, const char *url)
+nserror gui_window_set_url(struct gui_window *gw, const char *url)
{
- struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
- if (g->top_level != _g) return;
- assert(g->status_bar);
+ struct beos_scaffolding *g;
- if (!g->top_view->LockLooper())
- return;
+ g = nsbeos_get_scaffold(gw);
+ if (g->top_level != gw)
+ return NSERROR_OK;
+
+ assert(g->status_bar);
- g->url_bar->SetText(url);
+ if (g->top_view->LockLooper()) {
+ g->url_bar->SetText(url);
- g->top_view->UnlockLooper();
+ g->top_view->UnlockLooper();
+ }
return NSERROR_OK;
}
--
NetSurf Browser
8 years, 3 months
netsurf: branch master updated. release/3.2-268-g7ace528
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7ace528729c37d665e269...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7ace528729c37d665e269c8...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7ace528729c37d665e269c8a7...
The branch, master has been updated
via 7ace528729c37d665e269c8a76991739c9437088 (commit)
from 4b941297aaa8de2b092b6b799fcfc91d6e0e4782 (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=7ace528729c37d665e2...
commit 7ace528729c37d665e269c8a76991739c9437088
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update url setting API to return nserror code instead of calling warn_user
diff --git a/amiga/gui.c b/amiga/gui.c
index 9ee209e..4788a08 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -4774,12 +4774,11 @@ static void gui_window_set_status(struct gui_window *g, const char *text)
}
}
-static void gui_window_set_url(struct gui_window *g, const char *url)
+static nserror gui_window_set_url(struct gui_window *g, const char *url)
{
int cur_tab = 0;
if(!g) return;
- if(!url) return;
if(g->tab_node && (g->shared->tabs > 1)) GetAttr(CLICKTAB_Current,
g->shared->objects[GID_TABS], (ULONG *)&cur_tab);
@@ -4791,6 +4790,8 @@ static void gui_window_set_url(struct gui_window *g, const char *url)
}
ami_update_buttons(g->shared);
+
+ return NSERROR_OK;
}
diff --git a/atari/gui.c b/atari/gui.c
index 7e5207f..cb071a1 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -115,7 +115,7 @@ EVMULT_OUT aes_event_out;
short aes_msg_out[8];
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
-static void gui_window_set_url(struct gui_window *w, const char *url);
+static nserror gui_window_set_url(struct gui_window *w, const char *url);
/**
* Core atari event processing.
@@ -553,7 +553,7 @@ void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape)
}
-static void gui_window_set_url(struct gui_window *w, const char *url)
+static nserror gui_window_set_url(struct gui_window *w, const char *url)
{
int l;
@@ -572,6 +572,8 @@ static void gui_window_set_url(struct gui_window *w, const char *url)
if(input_window == w->root->active_gui_window) {
toolbar_set_url(w->root->toolbar, url);
}
+
+ return NSERROR_OK;
}
char * gui_window_get_url(struct gui_window *gw)
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 860c057..48cf72e 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -2166,7 +2166,7 @@ void gui_window_set_status(struct gui_window *_g, const char *text)
g->top_view->UnlockLooper();
}
-void gui_window_set_url(struct gui_window *_g, const char *url)
+nserror gui_window_set_url(struct gui_window *_g, const char *url)
{
struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
if (g->top_level != _g) return;
@@ -2178,6 +2178,8 @@ void gui_window_set_url(struct gui_window *_g, const char *url)
g->url_bar->SetText(url);
g->top_view->UnlockLooper();
+
+ return NSERROR_OK;
}
void gui_window_start_throbber(struct gui_window* _g)
diff --git a/beos/scaffolding.h b/beos/scaffolding.h
index 78ba142..c732bc9 100644
--- a/beos/scaffolding.h
+++ b/beos/scaffolding.h
@@ -200,7 +200,7 @@ void nsbeos_scaffolding_destroy(nsbeos_scaffolding *scaffold);
void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where);
void gui_window_set_title(struct gui_window *_g, const char *title);
-void gui_window_set_url(struct gui_window *_g, const char *url);
+nserror gui_window_set_url(struct gui_window *_g, const char *url);
void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon);
void gui_window_set_status(struct gui_window *_g, const char *text);
void gui_window_start_throbber(struct gui_window* _g);
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 28e68e9..c9cef15 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -194,9 +194,10 @@ static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape
}
}
-static void gui_window_set_url(struct gui_window *g, const char *url)
+static nserror gui_window_set_url(struct gui_window *g, const char *url)
{
[(BrowserViewController *)g setUrl: [NSString stringWithUTF8String: url]];
+ return NSERROR_OK;
}
static void gui_window_start_throbber(struct gui_window *g)
diff --git a/desktop/browser.c b/desktop/browser.c
index 315859a..e6fc2f7 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -769,7 +769,6 @@ nserror browser_window_create(enum browser_window_create_flags flags,
if ((ret = calloc(1, sizeof(struct browser_window))) == NULL) {
- warn_user("NoMemory", 0);
return NSERROR_NOMEM;
}
@@ -1784,18 +1783,18 @@ static void browser_window_destroy_internal(struct browser_window *bw)
* \param bw Browser window to update URL bar for.
* \param url URL for content displayed by bw including any fragment.
*/
-static inline void browser_window_refresh_url_bar_internal(
- struct browser_window *bw, nsurl *url)
+static inline nserror
+browser_window_refresh_url_bar_internal(struct browser_window *bw, nsurl *url)
{
assert(bw);
assert(url);
- if (bw->parent != NULL) {
- /* Not root window; don't set a URL in GUI URL bar */
- return;
+ if ((bw->parent != NULL) || (bw->window == NULL)) {
+ /* Not root window or no gui window so do not set a URL */
+ return NSERROR_OK;
}
- guit->window->set_url(bw->window, nsurl_access(url));
+ return guit->window->set_url(bw->window, nsurl_access(url));
}
@@ -1811,39 +1810,38 @@ void browser_window_destroy(struct browser_window *bw)
}
/* exported interface, documented in desktop/browser.h */
-void browser_window_refresh_url_bar(struct browser_window *bw)
+nserror browser_window_refresh_url_bar(struct browser_window *bw)
{
+ nserror ret;
+ nsurl *display_url;
+
assert(bw);
if (bw->parent != NULL) {
/* Not root window; don't set a URL in GUI URL bar */
- return;
+ return NSERROR_OK;
}
if (bw->current_content == NULL) {
- /* TODO: set "about:blank"? */
- return;
- }
-
- if (bw->frag_id == NULL) {
- browser_window_refresh_url_bar_internal(bw,
+ /* no content so return about:blank */
+ ret = browser_window_refresh_url_bar_internal(bw,
+ corestring_nsurl_about_blank);
+ } else if (bw->frag_id == NULL) {
+ ret = browser_window_refresh_url_bar_internal(bw,
hlcache_handle_get_url(bw->current_content));
} else {
- nsurl *display_url;
- nserror error;
-
/* Combine URL and Fragment */
- error = nsurl_refragment(
+ ret = nsurl_refragment(
hlcache_handle_get_url(bw->current_content),
bw->frag_id, &display_url);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return;
+ if (ret == NSERROR_OK) {
+ ret = browser_window_refresh_url_bar_internal(bw,
+ display_url);
+ nsurl_unref(display_url);
}
-
- browser_window_refresh_url_bar_internal(bw, display_url);
- nsurl_unref(display_url);
}
+
+ return ret;
}
@@ -1989,11 +1987,13 @@ nserror browser_window_navigate(struct browser_window *bw,
case NSERROR_OK:
bw->loading_content = c;
browser_window_start_throbber(bw);
- browser_window_refresh_url_bar_internal(bw, url);
+ error = browser_window_refresh_url_bar_internal(bw, url);
break;
case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
- /** @todo does this always try and download even unverifiable content? */
+ /** \todo does this always try and download even
+ * unverifiable content?
+ */
error = guit->browser->launch_url(url);
break;
@@ -2098,7 +2098,8 @@ const char* browser_window_get_title(struct browser_window *bw)
return content_get_title(bw->current_content);
}
- return NULL;
+ /* no content so return about:blank */
+ return nsurl_access(corestring_nsurl_about_blank);
}
/* Exported interface, documented in browser.h */
diff --git a/desktop/browser.h b/desktop/browser.h
index 29a8736..5a1d70d 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -357,7 +357,7 @@ void browser_window_set_gadget_filename(struct browser_window *bw,
*
* \param bw Browser window to update URL bar for.
*/
-void browser_window_refresh_url_bar(struct browser_window *bw);
+nserror browser_window_refresh_url_bar(struct browser_window *bw);
/**
* Handle mouse clicks in a browser window.
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index b69700f..e26eccb 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -42,8 +42,9 @@ static void gui_default_window_set_title(struct gui_window *g, const char *title
{
}
-static void gui_default_window_set_url(struct gui_window *g, const char *url)
+static nserror gui_default_window_set_url(struct gui_window *g, const char *url)
{
+ return NSERROR_OK;
}
static void gui_default_window_start_throbber(struct gui_window *g)
diff --git a/desktop/gui_window.h b/desktop/gui_window.h
index e503d4b..38432f5 100644
--- a/desktop/gui_window.h
+++ b/desktop/gui_window.h
@@ -184,7 +184,7 @@ struct gui_window_table {
* \param gw window to update.
* \param url The url to use as icon.
*/
- void (*set_url)(struct gui_window *gw, const char *url);
+ nserror (*set_url)(struct gui_window *gw, const char *url);
/**
* Set a favicon for a gui window.
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 180c261..0ee60c9 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -1896,10 +1896,11 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
}
}
-static void
+static nserror
gui_window_set_url(struct gui_window *g, const char *url)
{
fbtk_set_text(g->url, url);
+ return NSERROR_OK;
}
static void
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 0fa2470..571ba93 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -2309,12 +2309,16 @@ void gui_window_set_title(struct gui_window *gw, const char *title)
}
-void gui_window_set_url(struct gui_window *_g, const char *url)
+nserror gui_window_set_url(struct gui_window *gw, const char *url)
{
- struct nsgtk_scaffolding *g = nsgtk_get_scaffold(_g);
- if (g->top_level != _g) return;
- gtk_entry_set_text(GTK_ENTRY(g->url_bar), url);
- gtk_editable_set_position(GTK_EDITABLE(g->url_bar), -1);
+ struct nsgtk_scaffolding *g;
+
+ g = nsgtk_get_scaffold(gw);
+ if (g->top_level == gw) {
+ gtk_entry_set_text(GTK_ENTRY(g->url_bar), url);
+ gtk_editable_set_position(GTK_EDITABLE(g->url_bar), -1);
+ }
+ return NSERROR_OK;
}
void gui_window_start_throbber(struct gui_window* _g)
diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h
index e7d945e..07433bf 100644
--- a/gtk/scaffolding.h
+++ b/gtk/scaffolding.h
@@ -235,7 +235,7 @@ nserror nsgtk_scaffolding_new_tab(struct gui_window *gw);
/* core acessors */
void gui_window_set_title(struct gui_window *g, const char *title);
-void gui_window_set_url(struct gui_window *g, const char *url);
+nserror gui_window_set_url(struct gui_window *g, const char *url);
void gui_window_start_throbber(struct gui_window *g);
void gui_window_stop_throbber(struct gui_window *g);
diff --git a/monkey/browser.c b/monkey/browser.c
index 06517e0..1ebdaec 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -251,10 +251,11 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
fprintf(stdout, "WINDOW SET_POINTER WIN %u POINTER %s\n", g->win_num, ptr_name);
}
-static void
+static nserror
gui_window_set_url(struct gui_window *g, const char *url)
{
fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, url);
+ return NSERROR_OK;
}
static bool
diff --git a/riscos/window.c b/riscos/window.c
index b7cb6e8..6a62d56 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1052,13 +1052,14 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
/* exported function documented in riscos/window.h */
-void gui_window_set_url(struct gui_window *g, const char *url)
+nserror gui_window_set_url(struct gui_window *g, const char *url)
{
- if (!g->toolbar)
- return;
+ if (g->toolbar) {
+ ro_toolbar_set_url(g->toolbar, url, true, false);
+ ro_gui_url_complete_start(g->toolbar);
+ }
- ro_toolbar_set_url(g->toolbar, url, true, false);
- ro_gui_url_complete_start(g->toolbar);
+ return NSERROR_OK;
}
diff --git a/riscos/window.h b/riscos/window.h
index c4daf8b..ea31fcb 100644
--- a/riscos/window.h
+++ b/riscos/window.h
@@ -39,7 +39,7 @@ bool ro_gui_window_check_menu(wimp_menu *menu);
* \param g gui_window to update
* \param url new url for address bar
*/
-void gui_window_set_url(struct gui_window *g, const char *url);
+nserror gui_window_set_url(struct gui_window *g, const char *url);
#endif
diff --git a/windows/gui.c b/windows/gui.c
index 3804b18..cc0c056 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -760,6 +760,8 @@ nsws_window_command(HWND hwnd,
int identifier,
HWND ctrl_window)
{
+ nserror ret;
+
LOG(("notification_code %x identifier %x ctrl_window %p",
notification_code, identifier, ctrl_window));
@@ -781,11 +783,14 @@ nsws_window_command(HWND hwnd,
break;
case IDM_FILE_OPEN_WINDOW:
- browser_window_create(BW_CREATE_NONE,
+ ret = browser_window_create(BW_CREATE_NONE,
NULL,
NULL,
gw->bw,
NULL);
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ }
break;
case IDM_FILE_CLOSE_WINDOW:
@@ -1657,11 +1662,11 @@ struct nsws_pointers *nsws_get_pointers(void)
return &nsws_pointer;
}
-static void gui_window_set_url(struct gui_window *w, const char *url)
+static nserror gui_window_set_url(struct gui_window *w, const char *url)
{
- if (w == NULL)
- return;
SendMessage(w->urlbar, WM_SETTEXT, 0, (LPARAM) url);
+
+ return NSERROR_OK;
}
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 5 +++--
atari/gui.c | 6 ++++--
beos/scaffolding.cpp | 4 +++-
beos/scaffolding.h | 2 +-
cocoa/gui.m | 3 ++-
desktop/browser.c | 57 +++++++++++++++++++++++++------------------------
desktop/browser.h | 2 +-
desktop/gui_factory.c | 3 ++-
desktop/gui_window.h | 2 +-
framebuffer/gui.c | 3 ++-
gtk/scaffolding.c | 14 +++++++-----
gtk/scaffolding.h | 2 +-
monkey/browser.c | 3 ++-
riscos/window.c | 11 +++++-----
riscos/window.h | 2 +-
windows/gui.c | 13 +++++++----
16 files changed, 76 insertions(+), 56 deletions(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index 9ee209e..4788a08 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -4774,12 +4774,11 @@ static void gui_window_set_status(struct gui_window *g, const char *text)
}
}
-static void gui_window_set_url(struct gui_window *g, const char *url)
+static nserror gui_window_set_url(struct gui_window *g, const char *url)
{
int cur_tab = 0;
if(!g) return;
- if(!url) return;
if(g->tab_node && (g->shared->tabs > 1)) GetAttr(CLICKTAB_Current,
g->shared->objects[GID_TABS], (ULONG *)&cur_tab);
@@ -4791,6 +4790,8 @@ static void gui_window_set_url(struct gui_window *g, const char *url)
}
ami_update_buttons(g->shared);
+
+ return NSERROR_OK;
}
diff --git a/atari/gui.c b/atari/gui.c
index 7e5207f..cb071a1 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -115,7 +115,7 @@ EVMULT_OUT aes_event_out;
short aes_msg_out[8];
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
-static void gui_window_set_url(struct gui_window *w, const char *url);
+static nserror gui_window_set_url(struct gui_window *w, const char *url);
/**
* Core atari event processing.
@@ -553,7 +553,7 @@ void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape)
}
-static void gui_window_set_url(struct gui_window *w, const char *url)
+static nserror gui_window_set_url(struct gui_window *w, const char *url)
{
int l;
@@ -572,6 +572,8 @@ static void gui_window_set_url(struct gui_window *w, const char *url)
if(input_window == w->root->active_gui_window) {
toolbar_set_url(w->root->toolbar, url);
}
+
+ return NSERROR_OK;
}
char * gui_window_get_url(struct gui_window *gw)
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 860c057..48cf72e 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -2166,7 +2166,7 @@ void gui_window_set_status(struct gui_window *_g, const char *text)
g->top_view->UnlockLooper();
}
-void gui_window_set_url(struct gui_window *_g, const char *url)
+nserror gui_window_set_url(struct gui_window *_g, const char *url)
{
struct beos_scaffolding *g = nsbeos_get_scaffold(_g);
if (g->top_level != _g) return;
@@ -2178,6 +2178,8 @@ void gui_window_set_url(struct gui_window *_g, const char *url)
g->url_bar->SetText(url);
g->top_view->UnlockLooper();
+
+ return NSERROR_OK;
}
void gui_window_start_throbber(struct gui_window* _g)
diff --git a/beos/scaffolding.h b/beos/scaffolding.h
index 78ba142..c732bc9 100644
--- a/beos/scaffolding.h
+++ b/beos/scaffolding.h
@@ -200,7 +200,7 @@ void nsbeos_scaffolding_destroy(nsbeos_scaffolding *scaffold);
void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where);
void gui_window_set_title(struct gui_window *_g, const char *title);
-void gui_window_set_url(struct gui_window *_g, const char *url);
+nserror gui_window_set_url(struct gui_window *_g, const char *url);
void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon);
void gui_window_set_status(struct gui_window *_g, const char *text);
void gui_window_start_throbber(struct gui_window* _g);
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 28e68e9..c9cef15 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -194,9 +194,10 @@ static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape
}
}
-static void gui_window_set_url(struct gui_window *g, const char *url)
+static nserror gui_window_set_url(struct gui_window *g, const char *url)
{
[(BrowserViewController *)g setUrl: [NSString stringWithUTF8String: url]];
+ return NSERROR_OK;
}
static void gui_window_start_throbber(struct gui_window *g)
diff --git a/desktop/browser.c b/desktop/browser.c
index 315859a..e6fc2f7 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -769,7 +769,6 @@ nserror browser_window_create(enum browser_window_create_flags flags,
if ((ret = calloc(1, sizeof(struct browser_window))) == NULL) {
- warn_user("NoMemory", 0);
return NSERROR_NOMEM;
}
@@ -1784,18 +1783,18 @@ static void browser_window_destroy_internal(struct browser_window *bw)
* \param bw Browser window to update URL bar for.
* \param url URL for content displayed by bw including any fragment.
*/
-static inline void browser_window_refresh_url_bar_internal(
- struct browser_window *bw, nsurl *url)
+static inline nserror
+browser_window_refresh_url_bar_internal(struct browser_window *bw, nsurl *url)
{
assert(bw);
assert(url);
- if (bw->parent != NULL) {
- /* Not root window; don't set a URL in GUI URL bar */
- return;
+ if ((bw->parent != NULL) || (bw->window == NULL)) {
+ /* Not root window or no gui window so do not set a URL */
+ return NSERROR_OK;
}
- guit->window->set_url(bw->window, nsurl_access(url));
+ return guit->window->set_url(bw->window, nsurl_access(url));
}
@@ -1811,39 +1810,38 @@ void browser_window_destroy(struct browser_window *bw)
}
/* exported interface, documented in desktop/browser.h */
-void browser_window_refresh_url_bar(struct browser_window *bw)
+nserror browser_window_refresh_url_bar(struct browser_window *bw)
{
+ nserror ret;
+ nsurl *display_url;
+
assert(bw);
if (bw->parent != NULL) {
/* Not root window; don't set a URL in GUI URL bar */
- return;
+ return NSERROR_OK;
}
if (bw->current_content == NULL) {
- /* TODO: set "about:blank"? */
- return;
- }
-
- if (bw->frag_id == NULL) {
- browser_window_refresh_url_bar_internal(bw,
+ /* no content so return about:blank */
+ ret = browser_window_refresh_url_bar_internal(bw,
+ corestring_nsurl_about_blank);
+ } else if (bw->frag_id == NULL) {
+ ret = browser_window_refresh_url_bar_internal(bw,
hlcache_handle_get_url(bw->current_content));
} else {
- nsurl *display_url;
- nserror error;
-
/* Combine URL and Fragment */
- error = nsurl_refragment(
+ ret = nsurl_refragment(
hlcache_handle_get_url(bw->current_content),
bw->frag_id, &display_url);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return;
+ if (ret == NSERROR_OK) {
+ ret = browser_window_refresh_url_bar_internal(bw,
+ display_url);
+ nsurl_unref(display_url);
}
-
- browser_window_refresh_url_bar_internal(bw, display_url);
- nsurl_unref(display_url);
}
+
+ return ret;
}
@@ -1989,11 +1987,13 @@ nserror browser_window_navigate(struct browser_window *bw,
case NSERROR_OK:
bw->loading_content = c;
browser_window_start_throbber(bw);
- browser_window_refresh_url_bar_internal(bw, url);
+ error = browser_window_refresh_url_bar_internal(bw, url);
break;
case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
- /** @todo does this always try and download even unverifiable content? */
+ /** \todo does this always try and download even
+ * unverifiable content?
+ */
error = guit->browser->launch_url(url);
break;
@@ -2098,7 +2098,8 @@ const char* browser_window_get_title(struct browser_window *bw)
return content_get_title(bw->current_content);
}
- return NULL;
+ /* no content so return about:blank */
+ return nsurl_access(corestring_nsurl_about_blank);
}
/* Exported interface, documented in browser.h */
diff --git a/desktop/browser.h b/desktop/browser.h
index 29a8736..5a1d70d 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -357,7 +357,7 @@ void browser_window_set_gadget_filename(struct browser_window *bw,
*
* \param bw Browser window to update URL bar for.
*/
-void browser_window_refresh_url_bar(struct browser_window *bw);
+nserror browser_window_refresh_url_bar(struct browser_window *bw);
/**
* Handle mouse clicks in a browser window.
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index b69700f..e26eccb 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -42,8 +42,9 @@ static void gui_default_window_set_title(struct gui_window *g, const char *title
{
}
-static void gui_default_window_set_url(struct gui_window *g, const char *url)
+static nserror gui_default_window_set_url(struct gui_window *g, const char *url)
{
+ return NSERROR_OK;
}
static void gui_default_window_start_throbber(struct gui_window *g)
diff --git a/desktop/gui_window.h b/desktop/gui_window.h
index e503d4b..38432f5 100644
--- a/desktop/gui_window.h
+++ b/desktop/gui_window.h
@@ -184,7 +184,7 @@ struct gui_window_table {
* \param gw window to update.
* \param url The url to use as icon.
*/
- void (*set_url)(struct gui_window *gw, const char *url);
+ nserror (*set_url)(struct gui_window *gw, const char *url);
/**
* Set a favicon for a gui window.
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index 180c261..0ee60c9 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -1896,10 +1896,11 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
}
}
-static void
+static nserror
gui_window_set_url(struct gui_window *g, const char *url)
{
fbtk_set_text(g->url, url);
+ return NSERROR_OK;
}
static void
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 0fa2470..571ba93 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -2309,12 +2309,16 @@ void gui_window_set_title(struct gui_window *gw, const char *title)
}
-void gui_window_set_url(struct gui_window *_g, const char *url)
+nserror gui_window_set_url(struct gui_window *gw, const char *url)
{
- struct nsgtk_scaffolding *g = nsgtk_get_scaffold(_g);
- if (g->top_level != _g) return;
- gtk_entry_set_text(GTK_ENTRY(g->url_bar), url);
- gtk_editable_set_position(GTK_EDITABLE(g->url_bar), -1);
+ struct nsgtk_scaffolding *g;
+
+ g = nsgtk_get_scaffold(gw);
+ if (g->top_level == gw) {
+ gtk_entry_set_text(GTK_ENTRY(g->url_bar), url);
+ gtk_editable_set_position(GTK_EDITABLE(g->url_bar), -1);
+ }
+ return NSERROR_OK;
}
void gui_window_start_throbber(struct gui_window* _g)
diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h
index e7d945e..07433bf 100644
--- a/gtk/scaffolding.h
+++ b/gtk/scaffolding.h
@@ -235,7 +235,7 @@ nserror nsgtk_scaffolding_new_tab(struct gui_window *gw);
/* core acessors */
void gui_window_set_title(struct gui_window *g, const char *title);
-void gui_window_set_url(struct gui_window *g, const char *url);
+nserror gui_window_set_url(struct gui_window *g, const char *url);
void gui_window_start_throbber(struct gui_window *g);
void gui_window_stop_throbber(struct gui_window *g);
diff --git a/monkey/browser.c b/monkey/browser.c
index 06517e0..1ebdaec 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -251,10 +251,11 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
fprintf(stdout, "WINDOW SET_POINTER WIN %u POINTER %s\n", g->win_num, ptr_name);
}
-static void
+static nserror
gui_window_set_url(struct gui_window *g, const char *url)
{
fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, url);
+ return NSERROR_OK;
}
static bool
diff --git a/riscos/window.c b/riscos/window.c
index b7cb6e8..6a62d56 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1052,13 +1052,14 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
/* exported function documented in riscos/window.h */
-void gui_window_set_url(struct gui_window *g, const char *url)
+nserror gui_window_set_url(struct gui_window *g, const char *url)
{
- if (!g->toolbar)
- return;
+ if (g->toolbar) {
+ ro_toolbar_set_url(g->toolbar, url, true, false);
+ ro_gui_url_complete_start(g->toolbar);
+ }
- ro_toolbar_set_url(g->toolbar, url, true, false);
- ro_gui_url_complete_start(g->toolbar);
+ return NSERROR_OK;
}
diff --git a/riscos/window.h b/riscos/window.h
index c4daf8b..ea31fcb 100644
--- a/riscos/window.h
+++ b/riscos/window.h
@@ -39,7 +39,7 @@ bool ro_gui_window_check_menu(wimp_menu *menu);
* \param g gui_window to update
* \param url new url for address bar
*/
-void gui_window_set_url(struct gui_window *g, const char *url);
+nserror gui_window_set_url(struct gui_window *g, const char *url);
#endif
diff --git a/windows/gui.c b/windows/gui.c
index 3804b18..cc0c056 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -760,6 +760,8 @@ nsws_window_command(HWND hwnd,
int identifier,
HWND ctrl_window)
{
+ nserror ret;
+
LOG(("notification_code %x identifier %x ctrl_window %p",
notification_code, identifier, ctrl_window));
@@ -781,11 +783,14 @@ nsws_window_command(HWND hwnd,
break;
case IDM_FILE_OPEN_WINDOW:
- browser_window_create(BW_CREATE_NONE,
+ ret = browser_window_create(BW_CREATE_NONE,
NULL,
NULL,
gw->bw,
NULL);
+ if (ret != NSERROR_OK) {
+ warn_user(messages_get_errorcode(ret), 0);
+ }
break;
case IDM_FILE_CLOSE_WINDOW:
@@ -1657,11 +1662,11 @@ struct nsws_pointers *nsws_get_pointers(void)
return &nsws_pointer;
}
-static void gui_window_set_url(struct gui_window *w, const char *url)
+static nserror gui_window_set_url(struct gui_window *w, const char *url)
{
- if (w == NULL)
- return;
SendMessage(w->urlbar, WM_SETTEXT, 0, (LPARAM) url);
+
+ return NSERROR_OK;
}
--
NetSurf Browser
8 years, 3 months
netsurf: branch master updated. release/3.2-267-g4b94129
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/4b941297aaa8de2b092b6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/4b941297aaa8de2b092b6b7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/4b941297aaa8de2b092b6b799...
The branch, master has been updated
via 4b941297aaa8de2b092b6b799fcfc91d6e0e4782 (commit)
from bbcb7d91b286cada167cf7a0547bc9ec03ec4a54 (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=4b941297aaa8de2b092...
commit 4b941297aaa8de2b092b6b799fcfc91d6e0e4782
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
If the initial download dir is changed, update requesters immediately to use that as the next location.
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index 04beb81..290db3e 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -1767,7 +1767,11 @@ static void ami_gui_opts_use(bool save)
}
GetAttr(GETFILE_Drawer,gow->objects[GID_OPTS_DLDIR],(ULONG *)&data);
- nsoption_set_charp(download_dir, (char *)strdup((char *)data));
+ if(strcmp(data, nsoption_charp(download_dir)) != 0) {
+ nsoption_set_charp(download_dir, (char *)strdup((char *)data));
+ ami_file_req_free();
+ ami_file_req_init();
+ }
GetAttr(GA_Selected,gow->objects[GID_OPTS_TAB_ACTIVE],(ULONG *)&data);
if (data) {
-----------------------------------------------------------------------
Summary of changes:
amiga/gui_options.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index 04beb81..290db3e 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -1767,7 +1767,11 @@ static void ami_gui_opts_use(bool save)
}
GetAttr(GETFILE_Drawer,gow->objects[GID_OPTS_DLDIR],(ULONG *)&data);
- nsoption_set_charp(download_dir, (char *)strdup((char *)data));
+ if(strcmp(data, nsoption_charp(download_dir)) != 0) {
+ nsoption_set_charp(download_dir, (char *)strdup((char *)data));
+ ami_file_req_free();
+ ami_file_req_init();
+ }
GetAttr(GA_Selected,gow->objects[GID_OPTS_TAB_ACTIVE],(ULONG *)&data);
if (data) {
--
NetSurf Browser
8 years, 3 months
netsurf: branch master updated. release/3.2-266-gbbcb7d9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/bbcb7d91b286cada167cf...
...commit http://git.netsurf-browser.org/netsurf.git/commit/bbcb7d91b286cada167cf7a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/bbcb7d91b286cada167cf7a05...
The branch, master has been updated
via bbcb7d91b286cada167cf7a0547bc9ec03ec4a54 (commit)
from d204d6d555ac8e79da330a93e96fb070c8ee8f8c (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=bbcb7d91b286cada167...
commit bbcb7d91b286cada167cf7a0547bc9ec03ec4a54
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix amiga pdf save include
diff --git a/amiga/file.c b/amiga/file.c
index f8f21fd..e74c5d0 100644
--- a/amiga/file.c
+++ b/amiga/file.c
@@ -29,7 +29,7 @@
#include "content/fetch.h"
#include "desktop/browser_private.h"
#include "desktop/save_complete.h"
-#include "desktop/save_pdf/pdf_plotters.h"
+#include "desktop/save_pdf.h"
#include "desktop/save_text.h"
#include "desktop/gui_window.h"
diff --git a/gtk/gui.c b/gtk/gui.c
index c4dc0e1..9994911 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -97,10 +97,6 @@ static void nsgtk_ssl_accept(GtkButton *w, gpointer data);
static void nsgtk_ssl_reject(GtkWidget *w, gpointer data);
static gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event,
gpointer data);
-#ifdef WITH_PDF_EXPORT
-static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data);
-static void nsgtk_PDF_no_pass(GtkButton *w, gpointer data);
-#endif
#define THROBBER_FRAMES 9
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 4be27c7..0fa2470 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -38,8 +38,8 @@
#include "desktop/print.h"
#include "desktop/save_complete.h"
#ifdef WITH_PDF_EXPORT
-#include "desktop/save_pdf/font_haru.h"
-#include "desktop/save_pdf/pdf_plotters.h"
+#include "desktop/font_haru.h"
+#include "desktop/save_pdf.h"
#endif
#include "desktop/save_text.h"
#include "desktop/searchweb.h"
-----------------------------------------------------------------------
Summary of changes:
amiga/file.c | 2 +-
gtk/gui.c | 4 ----
gtk/scaffolding.c | 4 ++--
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/amiga/file.c b/amiga/file.c
index f8f21fd..e74c5d0 100644
--- a/amiga/file.c
+++ b/amiga/file.c
@@ -29,7 +29,7 @@
#include "content/fetch.h"
#include "desktop/browser_private.h"
#include "desktop/save_complete.h"
-#include "desktop/save_pdf/pdf_plotters.h"
+#include "desktop/save_pdf.h"
#include "desktop/save_text.h"
#include "desktop/gui_window.h"
diff --git a/gtk/gui.c b/gtk/gui.c
index c4dc0e1..9994911 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -97,10 +97,6 @@ static void nsgtk_ssl_accept(GtkButton *w, gpointer data);
static void nsgtk_ssl_reject(GtkWidget *w, gpointer data);
static gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event,
gpointer data);
-#ifdef WITH_PDF_EXPORT
-static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data);
-static void nsgtk_PDF_no_pass(GtkButton *w, gpointer data);
-#endif
#define THROBBER_FRAMES 9
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 4be27c7..0fa2470 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -38,8 +38,8 @@
#include "desktop/print.h"
#include "desktop/save_complete.h"
#ifdef WITH_PDF_EXPORT
-#include "desktop/save_pdf/font_haru.h"
-#include "desktop/save_pdf/pdf_plotters.h"
+#include "desktop/font_haru.h"
+#include "desktop/save_pdf.h"
#endif
#include "desktop/save_text.h"
#include "desktop/searchweb.h"
--
NetSurf Browser
8 years, 3 months
netsurf: branch master updated. release/3.2-265-gd204d6d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/d204d6d555ac8e79da330...
...commit http://git.netsurf-browser.org/netsurf.git/commit/d204d6d555ac8e79da330a9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/d204d6d555ac8e79da330a93e...
The branch, master has been updated
via d204d6d555ac8e79da330a93e96fb070c8ee8f8c (commit)
from 29dfdd459dc4f835bc4dda5d67714b4aaa2c897a (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=d204d6d555ac8e79da3...
commit d204d6d555ac8e79da330a93e96fb070c8ee8f8c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Clean up saving as PDF
This removes the global PDF_Password interface that had completely
bitrotted and moves it into the standard misc operation table with a
sensible defualt implementation.
This also cleans up and fixes the gtk frontend implementation of the
pdf password callback so it compiles.
Finally this moves the implementation to a sensible place alongside
the other exporters reducing target makefile complexity futher.
diff --git a/Makefile b/Makefile
index 4fe22e2..0876608 100644
--- a/Makefile
+++ b/Makefile
@@ -571,9 +571,6 @@ include javascript/Makefile
# Image content handler sources
include image/Makefile
-# PDF saving sources
-include desktop/save_pdf/Makefile
-
# S_COMMON are sources common to all builds
S_COMMON := $(S_CONTENT) $(S_FETCHERS) $(S_CSS) $(S_RENDER) $(S_UTILS) \
$(S_HTTP) $(S_DESKTOP) $(S_JAVASCRIPT)
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index ea765af..8939dbc 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -78,7 +78,7 @@ S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
# are not yet available
-SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA) $(S_PDF)
+SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA)
# ----------------------------------------------------------------------------
# Install target
diff --git a/amiga/save_pdf.c b/amiga/save_pdf.c
index 1659221..b70fc57 100644
--- a/amiga/save_pdf.c
+++ b/amiga/save_pdf.c
@@ -56,9 +56,4 @@ bool save_as_pdf(struct hlcache_handle *c, const char *path)
return true;
}
-void PDF_Password(char **owner_pass, char **user_pass, char *path)
-{
- /*TODO:this waits to be written, until then no PDF encryption*/
- *owner_pass = NULL;
-}
#endif
diff --git a/cocoa/utils.m b/cocoa/utils.m
index b49e503..2c73e9b 100644
--- a/cocoa/utils.m
+++ b/cocoa/utils.m
@@ -20,9 +20,6 @@
#import "utils/utils.h"
-#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
-
-
void warn_user(const char *warning, const char *detail)
{
NSRunAlertPanel( NSLocalizedString( @"Warning", @"Warning title" ),
@@ -31,9 +28,3 @@ void warn_user(const char *warning, const char *detail)
warning, detail != NULL ? ": " : "",
detail != NULL ? detail : "" );
}
-
-void PDF_Password(char **owner_pass, char **user_pass, char *path)
-{
- UNIMPL();
-}
-
diff --git a/desktop/Makefile b/desktop/Makefile
index 218f60e..894b518 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -13,7 +13,7 @@ desktop/version.c: testament $(OBJROOT)/testament.h
# S_BROWSER are sources related to full browsers but are common
# between RISC OS, GTK, BeOS and AmigaOS builds
S_BROWSER := browser.c browser_history.c download.c frames.c netsurf.c \
- save_complete.c save_text.c selection.c textinput.c gui_factory.c
+ save_complete.c save_text.c selection.c textinput.c gui_factory.c \
+ save_pdf.c font_haru.c
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
-
diff --git a/desktop/font_haru.c b/desktop/font_haru.c
new file mode 100644
index 0000000..aaee84c
--- /dev/null
+++ b/desktop/font_haru.c
@@ -0,0 +1,375 @@
+/*
+ * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
+ * Copyright 2009 John Tytgat <joty(a)netsurf-browser.org>
+ *
+ * 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
+ * Font handling in Haru pdf documents (implementation).
+ *
+ * The functions were written to implement the same interface as the Pango ones
+ * so that the usage of the latter wouldn't have to be modified.
+ */
+
+#include "utils/config.h"
+#ifdef WITH_PDF_EXPORT
+
+/*#define FONT_HARU_DEBUG */
+
+#include <assert.h>
+#include <float.h>
+#include <math.h>
+#include <string.h>
+
+#include <hpdf.h>
+
+#include "css/css.h"
+#include "css/utils.h"
+
+#include "utils/nsoption.h"
+#include "desktop/save_pdf/font_haru.h"
+#include "desktop/font.h"
+#include "utils/log.h"
+
+
+static bool haru_nsfont_init(HPDF_Doc *pdf, HPDF_Page *page,
+ const char *string, char **string_nt, int length);
+
+static bool haru_nsfont_width(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int *width);
+
+static bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int x, size_t *char_offset, int *actual_x);
+
+static bool haru_nsfont_split(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int x, size_t *char_offset, int *actual_x);
+
+static float pdf_text_scale = DEFAULT_EXPORT_SCALE;
+
+const struct font_functions haru_nsfont = {
+ haru_nsfont_width,
+ haru_nsfont_position_in_string,
+ haru_nsfont_split
+};
+
+/**
+ * Haru error handler
+ * for debugging purposes - it immediately exits the program on the first error,
+ * as it would otherwise flood the user with all resulting complications,
+ * covering the most important error source.
+ */
+static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no,
+ void *user_data)
+{
+ LOG(("ERROR: in font_haru \n\terror_no=%x\n\tdetail_no=%d\n",
+ (HPDF_UINT)error_no, (HPDF_UINT)detail_no));
+#ifdef FONT_HARU_DEBUG
+ exit(1);
+#endif
+}
+
+static bool haru_nsfont_init(HPDF_Doc *pdf, HPDF_Page *page,
+ const char *string, char **string_nt, int length)
+{
+
+ *pdf = HPDF_New(error_handler, NULL);
+
+ if (*pdf == NULL)
+ return false;
+
+ *page = HPDF_AddPage(*pdf);
+
+ if (*page == NULL) {
+ HPDF_Free(*pdf);
+ return false;
+ }
+
+ *string_nt = malloc((length + 1) * sizeof(char));
+ if (*string_nt == NULL) {
+ HPDF_Free(*pdf);
+ return false;
+ }
+
+ memcpy(*string_nt, string, length);
+ (*string_nt)[length] = '\0';
+ return true;
+}
+
+/**
+ * Measure the width of a string.
+ *
+ * \param fstyle style for this text
+ * \param string string to measure (no UTF-8 currently)
+ * \param length length of string
+ * \param width updated to width of string[0..length]
+ * \return true on success, false on error and error reported
+ */
+bool haru_nsfont_width(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int *width)
+{
+ HPDF_Doc pdf;
+ HPDF_Page page;
+ char *string_nt;
+ HPDF_REAL width_real;
+
+ *width = 0;
+
+ if (length == 0)
+ return true;
+
+ if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length))
+ return false;
+
+ if (!haru_nsfont_apply_style(fstyle, pdf, page, NULL, NULL)) {
+ free(string_nt);
+ HPDF_Free(pdf);
+ return false;
+ }
+
+ width_real = HPDF_Page_TextWidth(page, string_nt);
+ *width = width_real;
+
+#ifdef FONT_HARU_DEBUG
+ LOG(("Measuring string: %s ; Calculated width: %f %i",string_nt, width_real, *width));
+#endif
+ free(string_nt);
+ HPDF_Free(pdf);
+
+ return true;
+}
+
+
+/**
+ * Find the position in a string where an x coordinate falls.
+ *
+ * \param fstyle style for this text
+ * \param string string to measure (no UTF-8 currently)
+ * \param length length of string
+ * \param x x coordinate to search for
+ * \param char_offset updated to offset in string of actual_x, [0..length]
+ * \param actual_x updated to x coordinate of character closest to x
+ * \return true on success, false on error and error reported
+ */
+
+bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int x, size_t *char_offset, int *actual_x)
+{
+ HPDF_Doc pdf;
+ HPDF_Page page;
+ char *string_nt;
+ HPDF_UINT offset;
+ HPDF_REAL real_width;
+
+ if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length))
+ return false;
+
+ if (HPDF_Page_SetWidth(page, x) != HPDF_OK
+ || !haru_nsfont_apply_style(fstyle, pdf, page, NULL, NULL)) {
+ free(string_nt);
+ HPDF_Free(pdf);
+ return false;
+ }
+
+
+ offset = HPDF_Page_MeasureText(page, string_nt, x,
+ HPDF_FALSE, &real_width);
+
+
+ if (real_width < x)
+ *char_offset = offset;
+ else {
+ assert(fabs(real_width - x) < FLT_EPSILON);
+ assert(offset > 0);
+ *char_offset = offset - 1;
+ }
+
+ /*TODO: this is only the right edge of the character*/
+ *actual_x = real_width;
+
+#ifdef FONT_HARU_DEBUG
+ LOG(("Position in string: %s at x: %i; Calculated position: %i",
+ string_nt, x, *char_offset));
+#endif
+ free(string_nt);
+ HPDF_Free(pdf);
+
+ return true;
+}
+
+/**
+ * Find where to split a string to make it fit a width.
+ *
+ * \param fstyle style for this text
+ * \param string string to measure (no UTF-8 currently)
+ * \param length length of string
+ * \param x width available
+ * \param char_offset updated to offset in string of actual_x, [0..length]
+ * \param actual_x updated to x coordinate of character closest to x
+ * \return true on success, false on error and error reported
+ */
+
+bool haru_nsfont_split(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int x, size_t *char_offset, int *actual_x)
+{
+ HPDF_Doc pdf;
+ HPDF_Page page;
+ char *string_nt;
+ HPDF_REAL real_width;
+ HPDF_UINT offset;
+
+
+ if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length))
+ return false;
+
+ if (HPDF_Page_SetWidth(page, x) != HPDF_OK
+ || !haru_nsfont_apply_style(fstyle, pdf, page, NULL, NULL)) {
+ free(string_nt);
+ HPDF_Free(pdf);
+ return false;
+ }
+
+ offset = HPDF_Page_MeasureText(page, string_nt, x,
+ HPDF_TRUE, &real_width);
+
+#ifdef FONT_HARU_DEBUG
+ LOG(("Splitting string: %s for width: %i ; Calculated position: %i Calculated real_width: %f",
+ string_nt, x, *char_offset, real_width));
+#endif
+ *char_offset = offset - 1;
+
+ /*TODO: this is only the right edge of the character*/
+ *actual_x = real_width;
+
+ free(string_nt);
+ HPDF_Free(pdf);
+
+ return true;
+}
+
+/**
+ * Apply font style to a Haru HPDF_Page
+ *
+ * \param fstyle plot style for this page
+ * \param doc document owning the page
+ * \param page the page to apply the style to
+ * \param font if this is non NULL it is updated to the font based
+ * on given style
+ * \param font_size if this is non NULL it is updated to the font size
+ * based on given style
+ * \return true on success, false on error and error reported
+ *
+ * When both font and font_size are NULL, the HPDF_Page is updated for given
+ * style, otherwise it is left to the called to do this.
+ */
+bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
+ HPDF_Doc doc, HPDF_Page page,
+ HPDF_Font *font, HPDF_REAL *font_size)
+{
+ HPDF_Font pdf_font;
+ HPDF_REAL size;
+ char font_name[50];
+ bool roman = false;
+ bool bold = false;
+ bool styled = false;
+
+ /*TODO: style handling, we are mapping the
+ styles on the basic 14 fonts only
+ */
+ switch (fstyle->family) {
+ case PLOT_FONT_FAMILY_SERIF:
+ strcpy(font_name, "Times");
+ roman = true;
+ break;
+ case PLOT_FONT_FAMILY_MONOSPACE:
+ strcpy(font_name, "Courier");
+ break;
+ case PLOT_FONT_FAMILY_SANS_SERIF:
+ strcpy(font_name, "Helvetica");
+ break;
+ case PLOT_FONT_FAMILY_CURSIVE:
+ case PLOT_FONT_FAMILY_FANTASY:
+ default:
+ strcpy(font_name, "Times");
+ roman=true;
+ break;
+ }
+
+ if (fstyle->weight == 700) {
+ strcat(font_name, "-Bold");
+ bold = true;
+ }
+
+ if ((fstyle->flags & FONTF_ITALIC) || (fstyle->flags & FONTF_OBLIQUE)) {
+ if (!bold)
+ strcat(font_name,"-");
+ if (roman)
+ strcat(font_name,"Italic");
+ else
+ strcat(font_name,"Oblique");
+
+ styled = true;
+ }
+
+ if (roman && !styled && !bold)
+ strcat(font_name, "-Roman");
+
+#ifdef FONT_HARU_DEBUG
+ LOG(("Setting font: %s", font_name));
+#endif
+
+ size = fstyle->size;
+
+ if (font != NULL)
+ size *= pdf_text_scale;
+
+ if (size <= 0)
+ return true;
+
+ size /= FONT_SIZE_SCALE;
+
+ if (size > HPDF_MAX_FONTSIZE)
+ size = HPDF_MAX_FONTSIZE;
+
+ if (font_size)
+ *font_size = size;
+
+ pdf_font = HPDF_GetFont(doc, font_name, "StandardEncoding");
+ if (pdf_font == NULL)
+ return false;
+ if (font != NULL)
+ *font = pdf_font;
+
+ if (font == NULL || font_size == NULL)
+ HPDF_Page_SetFontAndSize(page, pdf_font, size);
+
+ return true;
+}
+
+/**
+ * Sync the text scale with the scale for the whole content
+ */
+void haru_nsfont_set_scale(float s)
+{
+ pdf_text_scale = s;
+}
+
+#endif /* WITH_PDF_EXPORT */
diff --git a/desktop/font_haru.h b/desktop/font_haru.h
new file mode 100644
index 0000000..479f7de
--- /dev/null
+++ b/desktop/font_haru.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
+ * Copyright 2009 John Tytgat <joty(a)netsurf-browser.org>
+ *
+ * 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
+ * Font handling in Haru pdf documents (interface).
+ */
+
+#ifndef _NETSURF_DESKTOP_FONT_HARU_H_
+#define _NETSURF_DESKTOP_FONT_HARU_H_
+
+#include <hpdf.h>
+
+#include "desktop/plot_style.h"
+#include "desktop/font.h"
+
+bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
+ HPDF_Doc doc, HPDF_Page page,
+ HPDF_Font *font, HPDF_REAL *font_size);
+
+void haru_nsfont_set_scale(float s);
+
+extern const struct font_functions haru_nsfont;
+
+#endif
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index e7770e7..b69700f 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -20,6 +20,7 @@
#include "content/backing_store.h"
#include "utils/file.h"
+#include "desktop/save_pdf.h"
#include "desktop/download.h"
#include "desktop/searchweb.h"
#include "desktop/gui_download.h"
@@ -259,6 +260,12 @@ static void gui_default_download_done(struct gui_download_window *dw)
{
}
+static struct gui_download_table default_download_table = {
+ .create = gui_default_download_create,
+ .data = gui_default_download_data,
+ .error = gui_default_download_error,
+ .done = gui_default_download_done,
+};
/** verify download window table is valid */
static nserror verify_download_register(struct gui_download_table *gdt)
@@ -566,12 +573,12 @@ static void gui_default_401login_open(nsurl *url, const char *realm,
cb(false, cbpw);
}
-static struct gui_download_table default_download_table = {
- .create = gui_default_download_create,
- .data = gui_default_download_data,
- .error = gui_default_download_error,
- .done = gui_default_download_done,
-};
+static void
+gui_default_pdf_password(char **owner_pass, char **user_pass, char *path)
+{
+ *owner_pass = NULL;
+ save_pdf(path);
+}
/** verify browser table is valid */
static nserror verify_browser_register(struct gui_browser_table *gbt)
@@ -599,6 +606,9 @@ static nserror verify_browser_register(struct gui_browser_table *gbt)
if (gbt->login == NULL) {
gbt->login = gui_default_401login_open;
}
+ if (gbt->pdf_password == NULL) {
+ gbt->pdf_password = gui_default_pdf_password;
+ }
return NSERROR_OK;
}
diff --git a/desktop/gui_misc.h b/desktop/gui_misc.h
index daad6ba..8005006 100644
--- a/desktop/gui_misc.h
+++ b/desktop/gui_misc.h
@@ -80,6 +80,16 @@ struct gui_browser_table {
void (*login)(struct nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
+ /**
+ * Warn the user of an event.
+ */
+ void (*warning)(const char *warning, const char *detail);
+
+ /**
+ * Prompt the user for a password for a PDF.
+ */
+ void (*pdf_password)(char **owner_pass, char **user_pass, char *path);
+
};
#endif
diff --git a/desktop/save_pdf.c b/desktop/save_pdf.c
new file mode 100644
index 0000000..e3f9cbc
--- /dev/null
+++ b/desktop/save_pdf.c
@@ -0,0 +1,990 @@
+/*
+ * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
+ * Copyright 2009 John Tytgat <joty(a)netsurf-browser.org>
+ *
+ * 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
+ * Target independent PDF plotting using Haru Free PDF Library.
+ */
+
+/* TODO
+ * - finish all graphic primitives
+ * - allow adding raw bitmaps
+ * - make image-aware (embed the image in its native/original type if possible)
+ *
+ * - adjust content width to page width
+ * - divide output into multiple pages (not just the first one)
+ * - rearrange file structure
+ *
+ * - separate print-plotting as much as possible from window redrawing
+ * - add text-scaling (if not yet using the original font - make the default one
+ * have the same width)
+ * - add a save file.. dialogue
+ * - add utf support to Haru ( doable? )
+ * - wait for browser to end fetching?
+ * - analyze and deal with performance issues(huge file hangs some pdf viewers,
+ * for example kpdf when viewing plotted http://www.onet.pl)
+ * - deal with to wide pages - when window layouting adds a horizontal
+ * scrollbar, we should treat it otherwise - either print
+ * horizontal or scale or, better, find a new layout.
+ */
+
+#include "utils/config.h"
+
+#include "desktop/save_pdf.h"
+
+#ifdef WITH_PDF_EXPORT
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <hpdf.h>
+
+#include "content/hlcache.h"
+#include "utils/nsoption.h"
+#include "desktop/plotters.h"
+#include "desktop/print.h"
+#include "desktop/printer.h"
+#include "image/bitmap.h"
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/useragent.h"
+
+#include "font_haru.h"
+
+/* #define PDF_DEBUG */
+/* #define PDF_DEBUG_DUMPGRID */
+
+static bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
+static bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
+static bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style);
+static bool pdf_plot_clip(const struct rect *clip);
+static bool pdf_plot_text(int x, int y, const char *text, size_t length,
+ const plot_font_style_t *fstyle);
+static bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style);
+static bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2,
+ const plot_style_t *style);
+static bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
+ struct bitmap *bitmap, colour bg,
+ bitmap_flags_t flags);
+static bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width,
+ colour c, const float transform[6]);
+
+static HPDF_Image pdf_extract_image(struct bitmap *bitmap);
+
+static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no,
+ void *user_data);
+
+#ifdef PDF_DEBUG_DUMPGRID
+static void pdf_plot_grid(int x_dist,int y_dist,unsigned int colour);
+#endif
+
+typedef enum {
+ DashPattern_eNone,
+ DashPattern_eDash,
+ DashPattern_eDotted
+} DashPattern_e;
+
+/* Wrapper routines to minimize gstate updates in the produced PDF file. */
+static void pdfw_gs_init(void);
+static void pdfw_gs_save(HPDF_Page page);
+static void pdfw_gs_restore(HPDF_Page page);
+static void pdfw_gs_fillcolour(HPDF_Page page, colour col);
+static void pdfw_gs_strokecolour(HPDF_Page page, colour col);
+static void pdfw_gs_linewidth(HPDF_Page page, float lineWidth);
+static void pdfw_gs_font(HPDF_Page page, HPDF_Font font, HPDF_REAL font_size);
+static void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash);
+
+/**
+ * Our PDF gstate mirror which we use to minimize gstate updates
+ * in the PDF file.
+ */
+typedef struct {
+ colour fillColour; /**< Current fill colour. */
+ colour strokeColour; /**< Current stroke colour. */
+ float lineWidth; /**< Current line width. */
+ HPDF_Font font; /**< Current font. */
+ HPDF_REAL font_size; /**< Current font size. */
+ DashPattern_e dash; /**< Current dash state. */
+} PDFW_GState;
+
+static void apply_clip_and_mode(bool selectTextMode, colour fillCol,
+ colour strokeCol, float lineWidth, DashPattern_e dash);
+
+#define PDFW_MAX_GSTATES 4
+static PDFW_GState pdfw_gs[PDFW_MAX_GSTATES];
+static unsigned int pdfw_gs_level;
+
+static HPDF_Doc pdf_doc; /**< Current PDF document. */
+static HPDF_Page pdf_page; /**< Current page. */
+
+/*PDF Page size*/
+static HPDF_REAL page_height, page_width;
+
+static bool in_text_mode; /**< true if we're currently in text mode or not. */
+static bool clip_update_needed; /**< true if pdf_plot_clip was invoked for
+ current page and not yet synced with PDF output. */
+static int last_clip_x0, last_clip_y0, last_clip_x1, last_clip_y1;
+
+static const struct print_settings *settings;
+
+static const struct plotter_table pdf_plotters = {
+ .rectangle = pdf_plot_rectangle,
+ .line = pdf_plot_line,
+ .polygon = pdf_plot_polygon,
+ .clip = pdf_plot_clip,
+ .text = pdf_plot_text,
+ .disc = pdf_plot_disc,
+ .arc = pdf_plot_arc,
+ .bitmap = pdf_plot_bitmap_tile,
+ .path = pdf_plot_path,
+ .option_knockout = false,
+};
+
+const struct printer pdf_printer = {
+ &pdf_plotters,
+ pdf_begin,
+ pdf_next_page,
+ pdf_end
+};
+
+static char *owner_pass;
+static char *user_pass;
+
+bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
+{
+ DashPattern_e dash;
+#ifdef PDF_DEBUG
+ LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, pstyle->fill_colour));
+#endif
+
+ if (pstyle->fill_type != PLOT_OP_TYPE_NONE) {
+
+ apply_clip_and_mode(false, pstyle->fill_colour, NS_TRANSPARENT, 0., DashPattern_eNone);
+
+ /* Normalize boundaries of the area - to prevent
+ overflows. It is needed only in a few functions,
+ where integers are subtracted. When the whole
+ browser window is meant min and max int values are
+ used what must be handled in paged output.
+ */
+ x0 = min(max(x0, 0), page_width);
+ y0 = min(max(y0, 0), page_height);
+ x1 = min(max(x1, 0), page_width);
+ y1 = min(max(y1, 0), page_height);
+
+ HPDF_Page_Rectangle(pdf_page, x0, page_height - y1, x1 - x0, y1 - y0);
+ HPDF_Page_Fill(pdf_page);
+
+ }
+
+ if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
+
+ switch (pstyle->stroke_type) {
+ case PLOT_OP_TYPE_DOT:
+ dash = DashPattern_eDotted;
+ break;
+
+ case PLOT_OP_TYPE_DASH:
+ dash = DashPattern_eDash;
+ break;
+
+ default:
+ dash = DashPattern_eNone;
+ break;
+
+ }
+
+ apply_clip_and_mode(false,
+ NS_TRANSPARENT,
+ pstyle->stroke_colour,
+ pstyle->stroke_width,
+ dash);
+
+ HPDF_Page_Rectangle(pdf_page, x0, page_height - y0, x1 - x0, -(y1 - y0));
+ HPDF_Page_Stroke(pdf_page);
+ }
+
+ return true;
+}
+
+bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
+{
+ DashPattern_e dash;
+
+ switch (pstyle->stroke_type) {
+ case PLOT_OP_TYPE_DOT:
+ dash = DashPattern_eDotted;
+ break;
+
+ case PLOT_OP_TYPE_DASH:
+ dash = DashPattern_eDash;
+ break;
+
+ default:
+ dash = DashPattern_eNone;
+ break;
+
+ }
+
+ apply_clip_and_mode(false,
+ NS_TRANSPARENT,
+ pstyle->stroke_colour,
+ pstyle->stroke_width,
+ dash);
+
+ HPDF_Page_MoveTo(pdf_page, x0, page_height - y0);
+ HPDF_Page_LineTo(pdf_page, x1, page_height - y1);
+ HPDF_Page_Stroke(pdf_page);
+
+ return true;
+}
+
+bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
+{
+ unsigned int i;
+#ifdef PDF_DEBUG
+ int pmaxx = p[0], pmaxy = p[1];
+ int pminx = p[0], pminy = p[1];
+ LOG(("."));
+#endif
+ if (n == 0)
+ return true;
+
+ apply_clip_and_mode(false, style->fill_colour, NS_TRANSPARENT, 0., DashPattern_eNone);
+
+ HPDF_Page_MoveTo(pdf_page, p[0], page_height - p[1]);
+ for (i = 1 ; i<n ; i++) {
+ HPDF_Page_LineTo(pdf_page, p[i*2], page_height - p[i*2+1]);
+#ifdef PDF_DEBUG
+ pmaxx = max(pmaxx, p[i*2]);
+ pmaxy = max(pmaxy, p[i*2+1]);
+ pminx = min(pminx, p[i*2]);
+ pminy = min(pminy, p[i*2+1]);
+#endif
+ }
+
+#ifdef PDF_DEBUG
+ LOG(("%d %d %d %d %f", pminx, pminy, pmaxx, pmaxy, page_height - pminy));
+#endif
+
+ HPDF_Page_Fill(pdf_page);
+
+ return true;
+}
+
+
+/**here the clip is only queried */
+bool pdf_plot_clip(const struct rect *clip)
+{
+#ifdef PDF_DEBUG
+ LOG(("%d %d %d %d", clip->x0, clip->y0, clip->x1, clip->y1));
+#endif
+
+ /*Normalize cllipping area - to prevent overflows.
+ See comment in pdf_plot_fill.
+ */
+ last_clip_x0 = min(max(clip->x0, 0), page_width);
+ last_clip_y0 = min(max(clip->y0, 0), page_height);
+ last_clip_x1 = min(max(clip->x1, 0), page_width);
+ last_clip_y1 = min(max(clip->y1, 0), page_height);
+
+ clip_update_needed = true;
+
+ return true;
+}
+
+bool pdf_plot_text(int x, int y, const char *text, size_t length,
+ const plot_font_style_t *fstyle)
+{
+#ifdef PDF_DEBUG
+ LOG((". %d %d %.*s", x, y, (int)length, text));
+#endif
+ char *word;
+ HPDF_Font pdf_font;
+ HPDF_REAL size;
+
+ if (length == 0)
+ return true;
+
+ apply_clip_and_mode(true, fstyle->foreground, NS_TRANSPARENT, 0.,
+ DashPattern_eNone);
+
+ haru_nsfont_apply_style(fstyle, pdf_doc, pdf_page, &pdf_font, &size);
+ pdfw_gs_font(pdf_page, pdf_font, size);
+
+ /* FIXME: UTF-8 to current font encoding needs to done. Or the font
+ * encoding needs to be UTF-8 or other Unicode encoding. */
+ word = (char *)malloc( sizeof(char) * (length+1) );
+ if (word == NULL)
+ return false;
+ memcpy(word, text, length);
+ word[length] = '\0';
+
+ HPDF_Page_TextOut (pdf_page, x, page_height - y, word);
+
+ free(word);
+
+ return true;
+}
+
+bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style)
+{
+#ifdef PDF_DEBUG
+ LOG(("."));
+#endif
+ if (style->fill_type != PLOT_OP_TYPE_NONE) {
+ apply_clip_and_mode(false,
+ style->fill_colour,
+ NS_TRANSPARENT,
+ 1., DashPattern_eNone);
+
+ HPDF_Page_Circle(pdf_page, x, page_height - y, radius);
+
+ HPDF_Page_Fill(pdf_page);
+ }
+
+ if (style->stroke_type != PLOT_OP_TYPE_NONE) {
+ /* FIXME: line width 1 is ok ? */
+ apply_clip_and_mode(false,
+ NS_TRANSPARENT,
+ style->stroke_colour,
+ 1., DashPattern_eNone);
+
+ HPDF_Page_Circle(pdf_page, x, page_height - y, radius);
+
+ HPDF_Page_Stroke(pdf_page);
+ }
+
+ return true;
+}
+
+bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style)
+{
+#ifdef PDF_DEBUG
+ LOG(("%d %d %d %d %d %X", x, y, radius, angle1, angle2, style->stroke_colour));
+#endif
+
+ /* FIXME: line width 1 is ok ? */
+ apply_clip_and_mode(false, NS_TRANSPARENT, style->fill_colour, 1., DashPattern_eNone);
+
+ /* Normalize angles */
+ angle1 %= 360;
+ angle2 %= 360;
+ if (angle1 > angle2)
+ angle1 -= 360;
+
+ HPDF_Page_Arc(pdf_page, x, page_height - y, radius, angle1, angle2);
+
+ HPDF_Page_Stroke(pdf_page);
+ return true;
+}
+
+
+bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
+ struct bitmap *bitmap, colour bg,
+ bitmap_flags_t flags)
+{
+ HPDF_Image image;
+ HPDF_REAL current_x, current_y ;
+ HPDF_REAL max_width, max_height;
+
+#ifdef PDF_DEBUG
+ LOG(("%d %d %d %d %p 0x%x", x, y, width, height,
+ bitmap, bg));
+#endif
+ if (width == 0 || height == 0)
+ return true;
+
+ apply_clip_and_mode(false, NS_TRANSPARENT, NS_TRANSPARENT, 0., DashPattern_eNone);
+
+ image = pdf_extract_image(bitmap);
+ if (!image)
+ return false;
+
+ /*The position of the next tile*/
+ max_width = (flags & BITMAPF_REPEAT_X) ? page_width : width;
+ max_height = (flags & BITMAPF_REPEAT_Y) ? page_height : height;
+
+ for (current_y = 0; current_y < max_height; current_y += height)
+ for (current_x = 0; current_x < max_width; current_x += width)
+ HPDF_Page_DrawImage(pdf_page, image,
+ current_x + x,
+ page_height - current_y - y - height,
+ width, height);
+
+ return true;
+}
+
+HPDF_Image pdf_extract_image(struct bitmap *bitmap)
+{
+ HPDF_Image image = NULL;
+ hlcache_handle *content = NULL;
+
+ /* TODO - get content from bitmap pointer */
+
+ if (content) {
+ const char *source_data;
+ unsigned long source_size;
+
+ /*Not sure if I don't have to check if downloading has been
+ finished.
+ Other way - lock pdf plotting while fetching a website
+ */
+ source_data = content_get_source_data(content, &source_size);
+
+ switch(content_get_type(content)){
+ /*Handle "embeddable" types of images*/
+ case CONTENT_JPEG:
+ image = HPDF_LoadJpegImageFromMem(pdf_doc,
+ (const HPDF_BYTE *) source_data,
+ source_size);
+ break;
+
+ /*Disabled until HARU PNG support will be more stable.
+
+ case CONTENT_PNG:
+ image = HPDF_LoadPngImageFromMem(pdf_doc,
+ (const HPDF_BYTE *)content->source_data,
+ content->total_size);
+ break;*/
+ default:
+ break;
+ }
+ }
+
+ if (!image) {
+ HPDF_Image smask;
+ unsigned char *img_buffer, *rgb_buffer, *alpha_buffer;
+ int img_width, img_height, img_rowstride;
+ int i, j;
+
+ /*Handle pixmaps*/
+ img_buffer = bitmap_get_buffer(bitmap);
+ img_width = bitmap_get_width(bitmap);
+ img_height = bitmap_get_height(bitmap);
+ img_rowstride = bitmap_get_rowstride(bitmap);
+
+ rgb_buffer = (unsigned char *)malloc(3 * img_width * img_height);
+ alpha_buffer = (unsigned char *)malloc(img_width * img_height);
+ if (rgb_buffer == NULL || alpha_buffer == NULL) {
+ LOG(("Not enough memory to create RGB buffer"));
+ free(rgb_buffer);
+ free(alpha_buffer);
+ return NULL;
+ }
+
+ for (i = 0; i < img_height; i++)
+ for (j = 0; j < img_width; j++) {
+ rgb_buffer[((i * img_width) + j) * 3] =
+ img_buffer[(i * img_rowstride) + (j * 4)];
+
+ rgb_buffer[(((i * img_width) + j) * 3) + 1] =
+ img_buffer[(i * img_rowstride) + (j * 4) + 1];
+
+ rgb_buffer[(((i * img_width) + j) * 3) + 2] =
+ img_buffer[(i * img_rowstride) + (j * 4) + 2];
+
+ alpha_buffer[(i * img_width)+j] =
+ img_buffer[(i * img_rowstride) + (j * 4) + 3];
+ }
+
+ smask = HPDF_LoadRawImageFromMem(pdf_doc, alpha_buffer,
+ img_width, img_height,
+ HPDF_CS_DEVICE_GRAY, 8);
+
+ image = HPDF_LoadRawImageFromMem(pdf_doc, rgb_buffer,
+ img_width, img_height,
+ HPDF_CS_DEVICE_RGB, 8);
+
+ if (HPDF_Image_AddSMask(image, smask) != HPDF_OK)
+ image = NULL;
+
+ free(rgb_buffer);
+ free(alpha_buffer);
+ }
+
+ return image;
+}
+
+/**
+ * Enter/leave text mode and update PDF gstate for its clip, fill & stroke
+ * colour, line width and dash pattern parameters.
+ * \param selectTextMode true if text mode needs to be entered if required;
+ * false otherwise.
+ * \param fillCol Desired fill colour, use NS_TRANSPARENT if no update is
+ * required.
+ * \param strokeCol Desired stroke colour, use NS_TRANSPARENT if no update is
+ * required.
+ * \param lineWidth Desired line width. Only taken into account when strokeCol
+ * is different from NS_TRANSPARENT.
+ * \param dash Desired dash pattern. Only taken into account when strokeCol
+ * is different from NS_TRANSPARENT.
+ */
+static void apply_clip_and_mode(bool selectTextMode, colour fillCol,
+ colour strokeCol, float lineWidth, DashPattern_e dash)
+{
+ /* Leave text mode when
+ * 1) we're not setting text anymore
+ * 2) or we need to update the current clippath
+ * 3) or we need to update any fill/stroke colour, linewidth or dash.
+ * Note: the test on stroke parameters (stroke colour, line width and
+ * dash) is commented out as if these need updating we want to be
+ * outside the text mode anyway (i.e. selectTextMode is false).
+ */
+ if (in_text_mode && (!selectTextMode || clip_update_needed
+ || (fillCol != NS_TRANSPARENT
+ && fillCol != pdfw_gs[pdfw_gs_level].fillColour)
+ /* || (strokeCol != NS_TRANSPARENT
+ && (strokeCol != pdfw_gs[pdfw_gs_level].strokeColour
+ || lineWidth != pdfw_gs[pdfw_gs_level].lineWidth
+ || dash != pdfw_gs[pdfw_gs_level].dash)) */)) {
+ HPDF_Page_EndText(pdf_page);
+ in_text_mode = false;
+ }
+
+ if (clip_update_needed)
+ pdfw_gs_restore(pdf_page);
+
+ /* Update fill/stroke colour, linewidth and dash when needed. */
+ if (fillCol != NS_TRANSPARENT)
+ pdfw_gs_fillcolour(pdf_page, fillCol);
+ if (strokeCol != NS_TRANSPARENT) {
+ pdfw_gs_strokecolour(pdf_page, strokeCol);
+ pdfw_gs_linewidth(pdf_page, lineWidth);
+ pdfw_gs_dash(pdf_page, dash);
+ }
+
+ if (clip_update_needed) {
+ pdfw_gs_save(pdf_page);
+
+ HPDF_Page_Rectangle(pdf_page, last_clip_x0,
+ page_height - last_clip_y1,
+ last_clip_x1 - last_clip_x0,
+ last_clip_y1 - last_clip_y0);
+ HPDF_Page_Clip(pdf_page);
+ HPDF_Page_EndPath(pdf_page);
+
+ clip_update_needed = false;
+ }
+
+ if (selectTextMode && !in_text_mode) {
+ HPDF_Page_BeginText(pdf_page);
+ in_text_mode = true;
+ }
+}
+
+static inline float transform_x(const float transform[6], float x, float y)
+{
+ return transform[0] * x + transform[2] * y + transform[4];
+}
+
+static inline float transform_y(const float transform[6], float x, float y)
+{
+ return page_height
+ - (transform[1] * x + transform[3] * y + transform[5]);
+}
+
+bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width,
+ colour c, const float transform[6])
+{
+ unsigned int i;
+ bool empty_path;
+
+#ifdef PDF_DEBUG
+ LOG(("."));
+#endif
+
+ if (n == 0)
+ return true;
+
+ if (c == NS_TRANSPARENT && fill == NS_TRANSPARENT)
+ return true;
+
+ if (p[0] != PLOTTER_PATH_MOVE)
+ return false;
+
+ apply_clip_and_mode(false, fill, c, width, DashPattern_eNone);
+
+ empty_path = true;
+ for (i = 0 ; i < n ; ) {
+ if (p[i] == PLOTTER_PATH_MOVE) {
+ HPDF_Page_MoveTo(pdf_page,
+ transform_x(transform, p[i+1], p[i+2]),
+ transform_y(transform, p[i+1], p[i+2]));
+ i+= 3;
+ } else if (p[i] == PLOTTER_PATH_CLOSE) {
+ if (!empty_path)
+ HPDF_Page_ClosePath(pdf_page);
+ i++;
+ } else if (p[i] == PLOTTER_PATH_LINE) {
+ HPDF_Page_LineTo(pdf_page,
+ transform_x(transform, p[i+1], p[i+2]),
+ transform_y(transform, p[i+1], p[i+2]));
+ i+=3;
+ empty_path = false;
+ } else if (p[i] == PLOTTER_PATH_BEZIER) {
+ HPDF_Page_CurveTo(pdf_page,
+ transform_x(transform, p[i+1], p[i+2]),
+ transform_y(transform, p[i+1], p[i+2]),
+ transform_x(transform, p[i+3], p[i+4]),
+ transform_y(transform, p[i+3], p[i+4]),
+ transform_x(transform, p[i+5], p[i+6]),
+ transform_y(transform, p[i+5], p[i+6]));
+ i += 7;
+ empty_path = false;
+ } else {
+ LOG(("bad path command %f", p[i]));
+ return false;
+ }
+ }
+
+ if (empty_path) {
+ HPDF_Page_EndPath(pdf_page);
+ return true;
+ }
+
+ if (fill != NS_TRANSPARENT) {
+ if (c != NS_TRANSPARENT)
+ HPDF_Page_FillStroke(pdf_page);
+ else
+ HPDF_Page_Fill(pdf_page);
+ }
+ else
+ HPDF_Page_Stroke(pdf_page);
+
+ return true;
+}
+
+/**
+ * Begin pdf plotting - initialize a new document
+ * \param path Output file path
+ * \param pg_width page width
+ * \param pg_height page height
+ */
+bool pdf_begin(struct print_settings *print_settings)
+{
+ pdfw_gs_init();
+
+ if (pdf_doc != NULL)
+ HPDF_Free(pdf_doc);
+ pdf_doc = HPDF_New(error_handler, NULL);
+ if (!pdf_doc) {
+ LOG(("Error creating pdf_doc"));
+ return false;
+ }
+
+ settings = print_settings;
+
+ page_width = settings->page_width -
+ FIXTOFLT(FSUB(settings->margins[MARGINLEFT],
+ settings->margins[MARGINRIGHT]));
+
+ page_height = settings->page_height -
+ FIXTOFLT(settings->margins[MARGINTOP]);
+
+
+#ifndef PDF_DEBUG
+ if (option_enable_PDF_compression)
+ HPDF_SetCompressionMode(pdf_doc, HPDF_COMP_ALL); /*Compression on*/
+#endif
+ HPDF_SetInfoAttr(pdf_doc, HPDF_INFO_CREATOR, user_agent_string());
+
+ pdf_page = NULL;
+
+#ifdef PDF_DEBUG
+ LOG(("pdf_begin finishes"));
+#endif
+ return true;
+}
+
+
+bool pdf_next_page(void)
+{
+#ifdef PDF_DEBUG
+ LOG(("pdf_next_page begins"));
+#endif
+ clip_update_needed = false;
+ if (pdf_page != NULL) {
+ apply_clip_and_mode(false, NS_TRANSPARENT, NS_TRANSPARENT, 0.,
+ DashPattern_eNone);
+ pdfw_gs_restore(pdf_page);
+ }
+
+#ifdef PDF_DEBUG_DUMPGRID
+ if (pdf_page != NULL) {
+ pdf_plot_grid(10, 10, 0xCCCCCC);
+ pdf_plot_grid(100, 100, 0xCCCCFF);
+ }
+#endif
+ pdf_page = HPDF_AddPage(pdf_doc);
+ if (pdf_page == NULL)
+ return false;
+
+ HPDF_Page_SetWidth (pdf_page, settings->page_width);
+ HPDF_Page_SetHeight(pdf_page, settings->page_height);
+
+ HPDF_Page_Concat(pdf_page, 1, 0, 0, 1,
+ FIXTOFLT(settings->margins[MARGINLEFT]), 0);
+
+ pdfw_gs_save(pdf_page);
+
+#ifdef PDF_DEBUG
+ LOG(("%f %f", page_width, page_height));
+#endif
+
+ return true;
+}
+
+
+void pdf_end(void)
+{
+#ifdef PDF_DEBUG
+ LOG(("pdf_end begins"));
+#endif
+ clip_update_needed = false;
+ if (pdf_page != NULL) {
+ apply_clip_and_mode(false, NS_TRANSPARENT, NS_TRANSPARENT, 0.,
+ DashPattern_eNone);
+ pdfw_gs_restore(pdf_page);
+ }
+
+#ifdef PDF_DEBUG_DUMPGRID
+ if (pdf_page != NULL) {
+ pdf_plot_grid(10, 10, 0xCCCCCC);
+ pdf_plot_grid(100, 100, 0xCCCCFF);
+ }
+#endif
+
+ assert(settings->output != NULL);
+
+ /*Encryption on*/
+ if (option_enable_PDF_password)
+ guit->browser->pdf_password(&owner_pass, &user_pass,
+ (void *)settings->output);
+ else
+ save_pdf(settings->output);
+#ifdef PDF_DEBUG
+ LOG(("pdf_end finishes"));
+#endif
+}
+
+/** saves the pdf with optional encryption */
+void save_pdf(const char *path)
+{
+ bool success = false;
+
+ if (option_enable_PDF_password && owner_pass != NULL ) {
+ HPDF_SetPassword(pdf_doc, owner_pass, user_pass);
+ HPDF_SetEncryptionMode(pdf_doc, HPDF_ENCRYPT_R3, 16);
+ free(owner_pass);
+ free(user_pass);
+ }
+
+ if (path != NULL) {
+ if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK)
+ remove(path);
+ else
+ success = true;
+ }
+
+ if (!success)
+ warn_user("Unable to save PDF file.", 0);
+
+ HPDF_Free(pdf_doc);
+ pdf_doc = NULL;
+}
+
+
+/**
+ * Haru error handler
+ * for debugging purposes - it immediately exits the program on the first error,
+ * as it would otherwise flood the user with all resulting complications,
+ * covering the most important error source.
+*/
+static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no,
+ void *user_data)
+{
+ LOG(("ERROR:\n\terror_no=%x\n\tdetail_no=%d\n", (HPDF_UINT)error_no,
+ (HPDF_UINT)detail_no));
+#ifdef PDF_DEBUG
+ exit(1);
+#endif
+}
+
+/**
+ * This function plots a grid - used for debug purposes to check if all
+ * elements' final coordinates are correct.
+*/
+#ifdef PDF_DEBUG_DUMPGRID
+void pdf_plot_grid(int x_dist, int y_dist, unsigned int colour)
+{
+ for (int i = x_dist ; i < page_width ; i += x_dist)
+ pdf_plot_line(i, 0, i, page_height, 1, colour, false, false);
+
+ for (int i = y_dist ; i < page_height ; i += x_dist)
+ pdf_plot_line(0, i, page_width, i, 1, colour, false, false);
+}
+#endif
+
+/**
+ * Initialize the gstate wrapper code.
+ */
+void pdfw_gs_init()
+{
+ pdfw_gs_level = 0;
+ pdfw_gs[0].fillColour = 0x00000000; /* Default PDF fill colour is black. */
+ pdfw_gs[0].strokeColour = 0x00000000; /* Default PDF stroke colour is black. */
+ pdfw_gs[0].lineWidth = 1.0; /* Default PDF line width is 1. */
+ pdfw_gs[0].font = NULL;
+ pdfw_gs[0].font_size = 0.;
+ pdfw_gs[0].dash = DashPattern_eNone; /* Default dash state is a solid line. */
+}
+
+/**
+ * Increase gstate level.
+ * \param page PDF page where the update needs to happen.
+ */
+void pdfw_gs_save(HPDF_Page page)
+{
+ if (pdfw_gs_level == PDFW_MAX_GSTATES)
+ abort();
+ pdfw_gs[pdfw_gs_level + 1] = pdfw_gs[pdfw_gs_level];
+ ++pdfw_gs_level;
+ HPDF_Page_GSave(page);
+}
+
+/**
+ * Decrease gstate level and restore the gstate to its value at last save
+ * operation.
+ * \param page PDF page where the update needs to happen.
+ */
+void pdfw_gs_restore(HPDF_Page page)
+{
+ if (pdfw_gs_level == 0)
+ abort();
+ --pdfw_gs_level;
+ HPDF_Page_GRestore(page);
+}
+
+#define RBYTE(x) (((x) & 0x0000FF) >> 0)
+#define GBYTE(x) (((x) & 0x00FF00) >> 8)
+#define BBYTE(x) (((x) & 0xFF0000) >> 16)
+#define R(x) (RBYTE(x) / 255.)
+#define G(x) (GBYTE(x) / 255.)
+#define B(x) (BBYTE(x) / 255.)
+
+/**
+ * Checks if given fill colour is already set in PDF gstate and if not,
+ * update the gstate accordingly.
+ * \param page PDF page where the update needs to happen.
+ * \param col Wanted fill colour.
+ */
+void pdfw_gs_fillcolour(HPDF_Page page, colour col)
+{
+ if (col == pdfw_gs[pdfw_gs_level].fillColour)
+ return;
+ pdfw_gs[pdfw_gs_level].fillColour = col;
+ if (RBYTE(col) == GBYTE(col) && GBYTE(col) == BBYTE(col))
+ HPDF_Page_SetGrayFill(pdf_page, R(col));
+ else
+ HPDF_Page_SetRGBFill(pdf_page, R(col), G(col), B(col));
+}
+
+/**
+ * Checks if given stroke colour is already set in PDF gstate and if not,
+ * update the gstate accordingly.
+ * \param page PDF page where the update needs to happen.
+ * \param col Wanted stroke colour.
+ */
+void pdfw_gs_strokecolour(HPDF_Page page, colour col)
+{
+ if (col == pdfw_gs[pdfw_gs_level].strokeColour)
+ return;
+ pdfw_gs[pdfw_gs_level].strokeColour = col;
+ if (RBYTE(col) == GBYTE(col) && GBYTE(col) == BBYTE(col))
+ HPDF_Page_SetGrayStroke(pdf_page, R(col));
+ else
+ HPDF_Page_SetRGBStroke(pdf_page, R(col), G(col), B(col));
+}
+
+/**
+ * Checks if given line width is already set in PDF gstate and if not, update
+ * the gstate accordingly.
+ * \param page PDF page where the update needs to happen.
+ * \param lineWidth Wanted line width.
+ */
+void pdfw_gs_linewidth(HPDF_Page page, float lineWidth)
+{
+ if (lineWidth == pdfw_gs[pdfw_gs_level].lineWidth)
+ return;
+ pdfw_gs[pdfw_gs_level].lineWidth = lineWidth;
+ HPDF_Page_SetLineWidth(page, lineWidth);
+}
+
+/**
+ * Checks if given font and font size is already set in PDF gstate and if not,
+ * update the gstate accordingly.
+ * \param page PDF page where the update needs to happen.
+ * \param font Wanted PDF font.
+ * \param font_size Wanted PDF font size.
+ */
+void pdfw_gs_font(HPDF_Page page, HPDF_Font font, HPDF_REAL font_size)
+{
+ if (font == pdfw_gs[pdfw_gs_level].font
+ && font_size == pdfw_gs[pdfw_gs_level].font_size)
+ return;
+ pdfw_gs[pdfw_gs_level].font = font;
+ pdfw_gs[pdfw_gs_level].font_size = font_size;
+ HPDF_Page_SetFontAndSize(page, font, font_size);
+}
+
+/**
+ * Checks if given dash pattern is already set in PDF gstate and if not,
+ * update the gstate accordingly.
+ * \param page PDF page where the update needs to happen.
+ * \param dash Wanted dash pattern.
+ */
+void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash)
+{
+ if (dash == pdfw_gs[pdfw_gs_level].dash)
+ return;
+ pdfw_gs[pdfw_gs_level].dash = dash;
+ switch (dash) {
+ case DashPattern_eNone: {
+ HPDF_Page_SetDash(page, NULL, 0, 0);
+ break;
+ }
+ case DashPattern_eDash: {
+ const HPDF_UINT16 dash_ptn[] = {3};
+ HPDF_Page_SetDash(page, dash_ptn, 1, 1);
+ break;
+ }
+ case DashPattern_eDotted: {
+ const HPDF_UINT16 dash_ptn[] = {1};
+ HPDF_Page_SetDash(page, dash_ptn, 1, 1);
+ break;
+ }
+ }
+}
+
+#else
+void save_pdf(const char *path)
+{
+}
+#endif /* WITH_PDF_EXPORT */
diff --git a/desktop/save_pdf.h b/desktop/save_pdf.h
new file mode 100644
index 0000000..d02c356
--- /dev/null
+++ b/desktop/save_pdf.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
+ *
+ * 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
+ PDF Plotting
+*/
+
+#ifndef NETSURF_PDF_PLOTTERS_H
+#define NETSURF_PDF_PLOTTERS_H
+
+#include "desktop/print.h"
+
+extern const struct printer pdf_printer;
+
+/**Start plotting a pdf file*/
+bool pdf_begin(struct print_settings *settings);
+
+/**Finish the current page and start a new one*/
+bool pdf_next_page(void);
+
+/**Close pdf document and save changes to file*/
+void pdf_end(void);
+
+void save_pdf(const char *path);
+
+#endif /*NETSURF_PDF_PLOTTERS_H*/
diff --git a/desktop/save_pdf/Makefile b/desktop/save_pdf/Makefile
deleted file mode 100644
index cf1f978..0000000
--- a/desktop/save_pdf/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# PDF saving sources
-
-# S_PDF are sources of the pdf plotter + the ones for paged-printing
-S_PDF := pdf_plotters.c font_haru.c
-
-S_PDF := $(addprefix desktop/save_pdf/,$(S_PDF))
diff --git a/desktop/save_pdf/TODO b/desktop/save_pdf/TODO
deleted file mode 100644
index 1b3a896..0000000
--- a/desktop/save_pdf/TODO
+++ /dev/null
@@ -1,19 +0,0 @@
-- finish all graphic primitives
-- allow adding raw bitmaps
-- make image-aware (embed the image in its native/original type if possible)
-
-- adjust content width to page width
-- divide output into multiple pages (not just the first one)
-- rearrange file structure
-
-- separate print-plotting as much as possible from window redrawing
-- add text-scaling (if not yet using the original font - make the default one
- have the same width)
-- add a save file.. dialogue
-- add utf support to Haru ( doable? )
-- wait for browser to end fetching?
-- analyze and deal with performance issues(huge file hangs some pdf viewers,
- for example kpdf when viewing plotted http://www.onet.pl)
-- deal with to wide pages - when window layouting adds a horizontal scrollbar,
- we should treat it otherwise - either print horizontal or scale or,
- better, find a new layout.
\ No newline at end of file
diff --git a/desktop/save_pdf/font_haru.c b/desktop/save_pdf/font_haru.c
deleted file mode 100644
index e8643f7..0000000
--- a/desktop/save_pdf/font_haru.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
- * Copyright 2009 John Tytgat <joty(a)netsurf-browser.org>
- *
- * 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
- * Font handling in Haru pdf documents (implementation).
- *
- * The functions were written to implement the same interface as the Pango ones
- * so that the usage of the latter wouldn't have to be modified.
- */
-
-#include "utils/config.h"
-#ifdef WITH_PDF_EXPORT
-
-/*#define FONT_HARU_DEBUG */
-
-#include <assert.h>
-#include <float.h>
-#include <math.h>
-#include <string.h>
-
-#include <hpdf.h>
-
-#include "css/css.h"
-#include "css/utils.h"
-
-#include "utils/nsoption.h"
-#include "desktop/save_pdf/font_haru.h"
-#include "desktop/font.h"
-#include "utils/log.h"
-
-
-static bool haru_nsfont_init(HPDF_Doc *pdf, HPDF_Page *page,
- const char *string, char **string_nt, int length);
-
-static bool haru_nsfont_width(const plot_font_style_t *fstyle,
- const char *string, size_t length,
- int *width);
-
-static bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle,
- const char *string, size_t length,
- int x, size_t *char_offset, int *actual_x);
-
-static bool haru_nsfont_split(const plot_font_style_t *fstyle,
- const char *string, size_t length,
- int x, size_t *char_offset, int *actual_x);
-
-static float pdf_text_scale = DEFAULT_EXPORT_SCALE;
-
-const struct font_functions haru_nsfont = {
- haru_nsfont_width,
- haru_nsfont_position_in_string,
- haru_nsfont_split
-};
-
-/**
- * Haru error handler
- * for debugging purposes - it immediately exits the program on the first error,
- * as it would otherwise flood the user with all resulting complications,
- * covering the most important error source.
- */
-static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no,
- void *user_data)
-{
- LOG(("ERROR: in font_haru \n\terror_no=%x\n\tdetail_no=%d\n",
- (HPDF_UINT)error_no, (HPDF_UINT)detail_no));
-#ifdef FONT_HARU_DEBUG
- exit(1);
-#endif
-}
-
-static bool haru_nsfont_init(HPDF_Doc *pdf, HPDF_Page *page,
- const char *string, char **string_nt, int length)
-{
-
- *pdf = HPDF_New(error_handler, NULL);
-
- if (*pdf == NULL)
- return false;
-
- *page = HPDF_AddPage(*pdf);
-
- if (*page == NULL) {
- HPDF_Free(*pdf);
- return false;
- }
-
- *string_nt = malloc((length + 1) * sizeof(char));
- if (*string_nt == NULL) {
- HPDF_Free(*pdf);
- return false;
- }
-
- memcpy(*string_nt, string, length);
- (*string_nt)[length] = '\0';
- return true;
-}
-
-/**
- * Measure the width of a string.
- *
- * \param fstyle style for this text
- * \param string string to measure (no UTF-8 currently)
- * \param length length of string
- * \param width updated to width of string[0..length]
- * \return true on success, false on error and error reported
- */
-bool haru_nsfont_width(const plot_font_style_t *fstyle,
- const char *string, size_t length,
- int *width)
-{
- HPDF_Doc pdf;
- HPDF_Page page;
- char *string_nt;
- HPDF_REAL width_real;
-
- *width = 0;
-
- if (length == 0)
- return true;
-
- if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length))
- return false;
-
- if (!haru_nsfont_apply_style(fstyle, pdf, page, NULL, NULL)) {
- free(string_nt);
- HPDF_Free(pdf);
- return false;
- }
-
- width_real = HPDF_Page_TextWidth(page, string_nt);
- *width = width_real;
-
-#ifdef FONT_HARU_DEBUG
- LOG(("Measuring string: %s ; Calculated width: %f %i",string_nt, width_real, *width));
-#endif
- free(string_nt);
- HPDF_Free(pdf);
-
- return true;
-}
-
-
-/**
- * Find the position in a string where an x coordinate falls.
- *
- * \param fstyle style for this text
- * \param string string to measure (no UTF-8 currently)
- * \param length length of string
- * \param x x coordinate to search for
- * \param char_offset updated to offset in string of actual_x, [0..length]
- * \param actual_x updated to x coordinate of character closest to x
- * \return true on success, false on error and error reported
- */
-
-bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle,
- const char *string, size_t length,
- int x, size_t *char_offset, int *actual_x)
-{
- HPDF_Doc pdf;
- HPDF_Page page;
- char *string_nt;
- HPDF_UINT offset;
- HPDF_REAL real_width;
-
- if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length))
- return false;
-
- if (HPDF_Page_SetWidth(page, x) != HPDF_OK
- || !haru_nsfont_apply_style(fstyle, pdf, page, NULL, NULL)) {
- free(string_nt);
- HPDF_Free(pdf);
- return false;
- }
-
-
- offset = HPDF_Page_MeasureText(page, string_nt, x,
- HPDF_FALSE, &real_width);
-
-
- if (real_width < x)
- *char_offset = offset;
- else {
- assert(fabs(real_width - x) < FLT_EPSILON);
- assert(offset > 0);
- *char_offset = offset - 1;
- }
-
- /*TODO: this is only the right edge of the character*/
- *actual_x = real_width;
-
-#ifdef FONT_HARU_DEBUG
- LOG(("Position in string: %s at x: %i; Calculated position: %i",
- string_nt, x, *char_offset));
-#endif
- free(string_nt);
- HPDF_Free(pdf);
-
- return true;
-}
-
-/**
- * Find where to split a string to make it fit a width.
- *
- * \param fstyle style for this text
- * \param string string to measure (no UTF-8 currently)
- * \param length length of string
- * \param x width available
- * \param char_offset updated to offset in string of actual_x, [0..length]
- * \param actual_x updated to x coordinate of character closest to x
- * \return true on success, false on error and error reported
- */
-
-bool haru_nsfont_split(const plot_font_style_t *fstyle,
- const char *string, size_t length,
- int x, size_t *char_offset, int *actual_x)
-{
- HPDF_Doc pdf;
- HPDF_Page page;
- char *string_nt;
- HPDF_REAL real_width;
- HPDF_UINT offset;
-
-
- if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length))
- return false;
-
- if (HPDF_Page_SetWidth(page, x) != HPDF_OK
- || !haru_nsfont_apply_style(fstyle, pdf, page, NULL, NULL)) {
- free(string_nt);
- HPDF_Free(pdf);
- return false;
- }
-
- offset = HPDF_Page_MeasureText(page, string_nt, x,
- HPDF_TRUE, &real_width);
-
-#ifdef FONT_HARU_DEBUG
- LOG(("Splitting string: %s for width: %i ; Calculated position: %i Calculated real_width: %f",
- string_nt, x, *char_offset, real_width));
-#endif
- *char_offset = offset - 1;
-
- /*TODO: this is only the right edge of the character*/
- *actual_x = real_width;
-
- free(string_nt);
- HPDF_Free(pdf);
-
- return true;
-}
-
-/**
- * Apply font style to a Haru HPDF_Page
- *
- * \param fstyle plot style for this page
- * \param doc document owning the page
- * \param page the page to apply the style to
- * \param font if this is non NULL it is updated to the font based
- * on given style
- * \param font_size if this is non NULL it is updated to the font size
- * based on given style
- * \return true on success, false on error and error reported
- *
- * When both font and font_size are NULL, the HPDF_Page is updated for given
- * style, otherwise it is left to the called to do this.
- */
-bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
- HPDF_Doc doc, HPDF_Page page,
- HPDF_Font *font, HPDF_REAL *font_size)
-{
- HPDF_Font pdf_font;
- HPDF_REAL size;
- char font_name[50];
- bool roman = false;
- bool bold = false;
- bool styled = false;
-
- /*TODO: style handling, we are mapping the
- styles on the basic 14 fonts only
- */
- switch (fstyle->family) {
- case PLOT_FONT_FAMILY_SERIF:
- strcpy(font_name, "Times");
- roman = true;
- break;
- case PLOT_FONT_FAMILY_MONOSPACE:
- strcpy(font_name, "Courier");
- break;
- case PLOT_FONT_FAMILY_SANS_SERIF:
- strcpy(font_name, "Helvetica");
- break;
- case PLOT_FONT_FAMILY_CURSIVE:
- case PLOT_FONT_FAMILY_FANTASY:
- default:
- strcpy(font_name, "Times");
- roman=true;
- break;
- }
-
- if (fstyle->weight == 700) {
- strcat(font_name, "-Bold");
- bold = true;
- }
-
- if ((fstyle->flags & FONTF_ITALIC) || (fstyle->flags & FONTF_OBLIQUE)) {
- if (!bold)
- strcat(font_name,"-");
- if (roman)
- strcat(font_name,"Italic");
- else
- strcat(font_name,"Oblique");
-
- styled = true;
- }
-
- if (roman && !styled && !bold)
- strcat(font_name, "-Roman");
-
-#ifdef FONT_HARU_DEBUG
- LOG(("Setting font: %s", font_name));
-#endif
-
- size = fstyle->size;
-
- if (font != NULL)
- size *= pdf_text_scale;
-
- if (size <= 0)
- return true;
-
- size /= FONT_SIZE_SCALE;
-
- if (size > HPDF_MAX_FONTSIZE)
- size = HPDF_MAX_FONTSIZE;
-
- if (font_size)
- *font_size = size;
-
- pdf_font = HPDF_GetFont(doc, font_name, "StandardEncoding");
- if (pdf_font == NULL)
- return false;
- if (font != NULL)
- *font = pdf_font;
-
- if (font == NULL || font_size == NULL)
- HPDF_Page_SetFontAndSize(page, pdf_font, size);
-
- return true;
-}
-
-/**
- * Sync the text scale with the scale for the whole content
- */
-void haru_nsfont_set_scale(float s)
-{
- pdf_text_scale = s;
-}
-
-#endif /* WITH_PDF_EXPORT */
-
diff --git a/desktop/save_pdf/font_haru.h b/desktop/save_pdf/font_haru.h
deleted file mode 100644
index c6578b0..0000000
--- a/desktop/save_pdf/font_haru.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
- * Copyright 2009 John Tytgat <joty(a)netsurf-browser.org>
- *
- * 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
- * Font handling in Haru pdf documents (interface).
- */
-
-#ifndef _NETSURF_RENDER_FONT_HARU_H_
-#define _NETSURF_RENDER_FONT_HARU_H_
-
-#include <hpdf.h>
-
-#include "desktop/plot_style.h"
-#include "desktop/font.h"
-
-bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
- HPDF_Doc doc, HPDF_Page page,
- HPDF_Font *font, HPDF_REAL *font_size);
-
-void haru_nsfont_set_scale(float s);
-
-extern const struct font_functions haru_nsfont;
-
-#endif
diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf/pdf_plotters.c
deleted file mode 100644
index 123408d..0000000
--- a/desktop/save_pdf/pdf_plotters.c
+++ /dev/null
@@ -1,963 +0,0 @@
-/*
- * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
- * Copyright 2009 John Tytgat <joty(a)netsurf-browser.org>
- *
- * 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
- * Target independent PDF plotting using Haru Free PDF Library.
- */
-
-#include "utils/config.h"
-#ifdef WITH_PDF_EXPORT
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <hpdf.h>
-
-#include "content/hlcache.h"
-#include "utils/nsoption.h"
-#include "desktop/plotters.h"
-#include "desktop/print.h"
-#include "desktop/printer.h"
-#include "desktop/save_pdf/pdf_plotters.h"
-#include "image/bitmap.h"
-#include "utils/log.h"
-#include "utils/utils.h"
-#include "utils/useragent.h"
-
-#include "font_haru.h"
-
-/* #define PDF_DEBUG */
-/* #define PDF_DEBUG_DUMPGRID */
-
-static bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
-static bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style);
-static bool pdf_plot_clip(const struct rect *clip);
-static bool pdf_plot_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle);
-static bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style);
-static bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2,
- const plot_style_t *style);
-static bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg,
- bitmap_flags_t flags);
-static bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6]);
-
-static HPDF_Image pdf_extract_image(struct bitmap *bitmap);
-
-static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no,
- void *user_data);
-
-#ifdef PDF_DEBUG_DUMPGRID
-static void pdf_plot_grid(int x_dist,int y_dist,unsigned int colour);
-#endif
-
-typedef enum {
- DashPattern_eNone,
- DashPattern_eDash,
- DashPattern_eDotted
-} DashPattern_e;
-
-/* Wrapper routines to minimize gstate updates in the produced PDF file. */
-static void pdfw_gs_init(void);
-static void pdfw_gs_save(HPDF_Page page);
-static void pdfw_gs_restore(HPDF_Page page);
-static void pdfw_gs_fillcolour(HPDF_Page page, colour col);
-static void pdfw_gs_strokecolour(HPDF_Page page, colour col);
-static void pdfw_gs_linewidth(HPDF_Page page, float lineWidth);
-static void pdfw_gs_font(HPDF_Page page, HPDF_Font font, HPDF_REAL font_size);
-static void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash);
-
-/**
- * Our PDF gstate mirror which we use to minimize gstate updates
- * in the PDF file.
- */
-typedef struct {
- colour fillColour; /**< Current fill colour. */
- colour strokeColour; /**< Current stroke colour. */
- float lineWidth; /**< Current line width. */
- HPDF_Font font; /**< Current font. */
- HPDF_REAL font_size; /**< Current font size. */
- DashPattern_e dash; /**< Current dash state. */
-} PDFW_GState;
-
-static void apply_clip_and_mode(bool selectTextMode, colour fillCol,
- colour strokeCol, float lineWidth, DashPattern_e dash);
-
-#define PDFW_MAX_GSTATES 4
-static PDFW_GState pdfw_gs[PDFW_MAX_GSTATES];
-static unsigned int pdfw_gs_level;
-
-static HPDF_Doc pdf_doc; /**< Current PDF document. */
-static HPDF_Page pdf_page; /**< Current page. */
-
-/*PDF Page size*/
-static HPDF_REAL page_height, page_width;
-
-static bool in_text_mode; /**< true if we're currently in text mode or not. */
-static bool clip_update_needed; /**< true if pdf_plot_clip was invoked for
- current page and not yet synced with PDF output. */
-static int last_clip_x0, last_clip_y0, last_clip_x1, last_clip_y1;
-
-static const struct print_settings *settings;
-
-static const struct plotter_table pdf_plotters = {
- .rectangle = pdf_plot_rectangle,
- .line = pdf_plot_line,
- .polygon = pdf_plot_polygon,
- .clip = pdf_plot_clip,
- .text = pdf_plot_text,
- .disc = pdf_plot_disc,
- .arc = pdf_plot_arc,
- .bitmap = pdf_plot_bitmap_tile,
- .path = pdf_plot_path,
- .option_knockout = false,
-};
-
-const struct printer pdf_printer = {
- &pdf_plotters,
- pdf_begin,
- pdf_next_page,
- pdf_end
-};
-
-static char *owner_pass;
-static char *user_pass;
-
-bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
-{
- DashPattern_e dash;
-#ifdef PDF_DEBUG
- LOG(("%d %d %d %d %f %X", x0, y0, x1, y1, page_height - y0, pstyle->fill_colour));
-#endif
-
- if (pstyle->fill_type != PLOT_OP_TYPE_NONE) {
-
- apply_clip_and_mode(false, pstyle->fill_colour, NS_TRANSPARENT, 0., DashPattern_eNone);
-
- /* Normalize boundaries of the area - to prevent
- overflows. It is needed only in a few functions,
- where integers are subtracted. When the whole
- browser window is meant min and max int values are
- used what must be handled in paged output.
- */
- x0 = min(max(x0, 0), page_width);
- y0 = min(max(y0, 0), page_height);
- x1 = min(max(x1, 0), page_width);
- y1 = min(max(y1, 0), page_height);
-
- HPDF_Page_Rectangle(pdf_page, x0, page_height - y1, x1 - x0, y1 - y0);
- HPDF_Page_Fill(pdf_page);
-
- }
-
- if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
-
- switch (pstyle->stroke_type) {
- case PLOT_OP_TYPE_DOT:
- dash = DashPattern_eDotted;
- break;
-
- case PLOT_OP_TYPE_DASH:
- dash = DashPattern_eDash;
- break;
-
- default:
- dash = DashPattern_eNone;
- break;
-
- }
-
- apply_clip_and_mode(false,
- NS_TRANSPARENT,
- pstyle->stroke_colour,
- pstyle->stroke_width,
- dash);
-
- HPDF_Page_Rectangle(pdf_page, x0, page_height - y0, x1 - x0, -(y1 - y0));
- HPDF_Page_Stroke(pdf_page);
- }
-
- return true;
-}
-
-bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
-{
- DashPattern_e dash;
-
- switch (pstyle->stroke_type) {
- case PLOT_OP_TYPE_DOT:
- dash = DashPattern_eDotted;
- break;
-
- case PLOT_OP_TYPE_DASH:
- dash = DashPattern_eDash;
- break;
-
- default:
- dash = DashPattern_eNone;
- break;
-
- }
-
- apply_clip_and_mode(false,
- NS_TRANSPARENT,
- pstyle->stroke_colour,
- pstyle->stroke_width,
- dash);
-
- HPDF_Page_MoveTo(pdf_page, x0, page_height - y0);
- HPDF_Page_LineTo(pdf_page, x1, page_height - y1);
- HPDF_Page_Stroke(pdf_page);
-
- return true;
-}
-
-bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style)
-{
- unsigned int i;
-#ifdef PDF_DEBUG
- int pmaxx = p[0], pmaxy = p[1];
- int pminx = p[0], pminy = p[1];
- LOG(("."));
-#endif
- if (n == 0)
- return true;
-
- apply_clip_and_mode(false, style->fill_colour, NS_TRANSPARENT, 0., DashPattern_eNone);
-
- HPDF_Page_MoveTo(pdf_page, p[0], page_height - p[1]);
- for (i = 1 ; i<n ; i++) {
- HPDF_Page_LineTo(pdf_page, p[i*2], page_height - p[i*2+1]);
-#ifdef PDF_DEBUG
- pmaxx = max(pmaxx, p[i*2]);
- pmaxy = max(pmaxy, p[i*2+1]);
- pminx = min(pminx, p[i*2]);
- pminy = min(pminy, p[i*2+1]);
-#endif
- }
-
-#ifdef PDF_DEBUG
- LOG(("%d %d %d %d %f", pminx, pminy, pmaxx, pmaxy, page_height - pminy));
-#endif
-
- HPDF_Page_Fill(pdf_page);
-
- return true;
-}
-
-
-/**here the clip is only queried */
-bool pdf_plot_clip(const struct rect *clip)
-{
-#ifdef PDF_DEBUG
- LOG(("%d %d %d %d", clip->x0, clip->y0, clip->x1, clip->y1));
-#endif
-
- /*Normalize cllipping area - to prevent overflows.
- See comment in pdf_plot_fill.
- */
- last_clip_x0 = min(max(clip->x0, 0), page_width);
- last_clip_y0 = min(max(clip->y0, 0), page_height);
- last_clip_x1 = min(max(clip->x1, 0), page_width);
- last_clip_y1 = min(max(clip->y1, 0), page_height);
-
- clip_update_needed = true;
-
- return true;
-}
-
-bool pdf_plot_text(int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle)
-{
-#ifdef PDF_DEBUG
- LOG((". %d %d %.*s", x, y, (int)length, text));
-#endif
- char *word;
- HPDF_Font pdf_font;
- HPDF_REAL size;
-
- if (length == 0)
- return true;
-
- apply_clip_and_mode(true, fstyle->foreground, NS_TRANSPARENT, 0.,
- DashPattern_eNone);
-
- haru_nsfont_apply_style(fstyle, pdf_doc, pdf_page, &pdf_font, &size);
- pdfw_gs_font(pdf_page, pdf_font, size);
-
- /* FIXME: UTF-8 to current font encoding needs to done. Or the font
- * encoding needs to be UTF-8 or other Unicode encoding. */
- word = (char *)malloc( sizeof(char) * (length+1) );
- if (word == NULL)
- return false;
- memcpy(word, text, length);
- word[length] = '\0';
-
- HPDF_Page_TextOut (pdf_page, x, page_height - y, word);
-
- free(word);
-
- return true;
-}
-
-bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style)
-{
-#ifdef PDF_DEBUG
- LOG(("."));
-#endif
- if (style->fill_type != PLOT_OP_TYPE_NONE) {
- apply_clip_and_mode(false,
- style->fill_colour,
- NS_TRANSPARENT,
- 1., DashPattern_eNone);
-
- HPDF_Page_Circle(pdf_page, x, page_height - y, radius);
-
- HPDF_Page_Fill(pdf_page);
- }
-
- if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- /* FIXME: line width 1 is ok ? */
- apply_clip_and_mode(false,
- NS_TRANSPARENT,
- style->stroke_colour,
- 1., DashPattern_eNone);
-
- HPDF_Page_Circle(pdf_page, x, page_height - y, radius);
-
- HPDF_Page_Stroke(pdf_page);
- }
-
- return true;
-}
-
-bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style)
-{
-#ifdef PDF_DEBUG
- LOG(("%d %d %d %d %d %X", x, y, radius, angle1, angle2, style->stroke_colour));
-#endif
-
- /* FIXME: line width 1 is ok ? */
- apply_clip_and_mode(false, NS_TRANSPARENT, style->fill_colour, 1., DashPattern_eNone);
-
- /* Normalize angles */
- angle1 %= 360;
- angle2 %= 360;
- if (angle1 > angle2)
- angle1 -= 360;
-
- HPDF_Page_Arc(pdf_page, x, page_height - y, radius, angle1, angle2);
-
- HPDF_Page_Stroke(pdf_page);
- return true;
-}
-
-
-bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
- struct bitmap *bitmap, colour bg,
- bitmap_flags_t flags)
-{
- HPDF_Image image;
- HPDF_REAL current_x, current_y ;
- HPDF_REAL max_width, max_height;
-
-#ifdef PDF_DEBUG
- LOG(("%d %d %d %d %p 0x%x", x, y, width, height,
- bitmap, bg));
-#endif
- if (width == 0 || height == 0)
- return true;
-
- apply_clip_and_mode(false, NS_TRANSPARENT, NS_TRANSPARENT, 0., DashPattern_eNone);
-
- image = pdf_extract_image(bitmap);
- if (!image)
- return false;
-
- /*The position of the next tile*/
- max_width = (flags & BITMAPF_REPEAT_X) ? page_width : width;
- max_height = (flags & BITMAPF_REPEAT_Y) ? page_height : height;
-
- for (current_y = 0; current_y < max_height; current_y += height)
- for (current_x = 0; current_x < max_width; current_x += width)
- HPDF_Page_DrawImage(pdf_page, image,
- current_x + x,
- page_height - current_y - y - height,
- width, height);
-
- return true;
-}
-
-HPDF_Image pdf_extract_image(struct bitmap *bitmap)
-{
- HPDF_Image image = NULL;
- hlcache_handle *content = NULL;
-
- /* TODO - get content from bitmap pointer */
-
- if (content) {
- const char *source_data;
- unsigned long source_size;
-
- /*Not sure if I don't have to check if downloading has been
- finished.
- Other way - lock pdf plotting while fetching a website
- */
- source_data = content_get_source_data(content, &source_size);
-
- switch(content_get_type(content)){
- /*Handle "embeddable" types of images*/
- case CONTENT_JPEG:
- image = HPDF_LoadJpegImageFromMem(pdf_doc,
- (const HPDF_BYTE *) source_data,
- source_size);
- break;
-
- /*Disabled until HARU PNG support will be more stable.
-
- case CONTENT_PNG:
- image = HPDF_LoadPngImageFromMem(pdf_doc,
- (const HPDF_BYTE *)content->source_data,
- content->total_size);
- break;*/
- default:
- break;
- }
- }
-
- if (!image) {
- HPDF_Image smask;
- unsigned char *img_buffer, *rgb_buffer, *alpha_buffer;
- int img_width, img_height, img_rowstride;
- int i, j;
-
- /*Handle pixmaps*/
- img_buffer = bitmap_get_buffer(bitmap);
- img_width = bitmap_get_width(bitmap);
- img_height = bitmap_get_height(bitmap);
- img_rowstride = bitmap_get_rowstride(bitmap);
-
- rgb_buffer = (unsigned char *)malloc(3 * img_width * img_height);
- alpha_buffer = (unsigned char *)malloc(img_width * img_height);
- if (rgb_buffer == NULL || alpha_buffer == NULL) {
- LOG(("Not enough memory to create RGB buffer"));
- free(rgb_buffer);
- free(alpha_buffer);
- return NULL;
- }
-
- for (i = 0; i < img_height; i++)
- for (j = 0; j < img_width; j++) {
- rgb_buffer[((i * img_width) + j) * 3] =
- img_buffer[(i * img_rowstride) + (j * 4)];
-
- rgb_buffer[(((i * img_width) + j) * 3) + 1] =
- img_buffer[(i * img_rowstride) + (j * 4) + 1];
-
- rgb_buffer[(((i * img_width) + j) * 3) + 2] =
- img_buffer[(i * img_rowstride) + (j * 4) + 2];
-
- alpha_buffer[(i * img_width)+j] =
- img_buffer[(i * img_rowstride) + (j * 4) + 3];
- }
-
- smask = HPDF_LoadRawImageFromMem(pdf_doc, alpha_buffer,
- img_width, img_height,
- HPDF_CS_DEVICE_GRAY, 8);
-
- image = HPDF_LoadRawImageFromMem(pdf_doc, rgb_buffer,
- img_width, img_height,
- HPDF_CS_DEVICE_RGB, 8);
-
- if (HPDF_Image_AddSMask(image, smask) != HPDF_OK)
- image = NULL;
-
- free(rgb_buffer);
- free(alpha_buffer);
- }
-
- return image;
-}
-
-/**
- * Enter/leave text mode and update PDF gstate for its clip, fill & stroke
- * colour, line width and dash pattern parameters.
- * \param selectTextMode true if text mode needs to be entered if required;
- * false otherwise.
- * \param fillCol Desired fill colour, use NS_TRANSPARENT if no update is
- * required.
- * \param strokeCol Desired stroke colour, use NS_TRANSPARENT if no update is
- * required.
- * \param lineWidth Desired line width. Only taken into account when strokeCol
- * is different from NS_TRANSPARENT.
- * \param dash Desired dash pattern. Only taken into account when strokeCol
- * is different from NS_TRANSPARENT.
- */
-static void apply_clip_and_mode(bool selectTextMode, colour fillCol,
- colour strokeCol, float lineWidth, DashPattern_e dash)
-{
- /* Leave text mode when
- * 1) we're not setting text anymore
- * 2) or we need to update the current clippath
- * 3) or we need to update any fill/stroke colour, linewidth or dash.
- * Note: the test on stroke parameters (stroke colour, line width and
- * dash) is commented out as if these need updating we want to be
- * outside the text mode anyway (i.e. selectTextMode is false).
- */
- if (in_text_mode && (!selectTextMode || clip_update_needed
- || (fillCol != NS_TRANSPARENT
- && fillCol != pdfw_gs[pdfw_gs_level].fillColour)
- /* || (strokeCol != NS_TRANSPARENT
- && (strokeCol != pdfw_gs[pdfw_gs_level].strokeColour
- || lineWidth != pdfw_gs[pdfw_gs_level].lineWidth
- || dash != pdfw_gs[pdfw_gs_level].dash)) */)) {
- HPDF_Page_EndText(pdf_page);
- in_text_mode = false;
- }
-
- if (clip_update_needed)
- pdfw_gs_restore(pdf_page);
-
- /* Update fill/stroke colour, linewidth and dash when needed. */
- if (fillCol != NS_TRANSPARENT)
- pdfw_gs_fillcolour(pdf_page, fillCol);
- if (strokeCol != NS_TRANSPARENT) {
- pdfw_gs_strokecolour(pdf_page, strokeCol);
- pdfw_gs_linewidth(pdf_page, lineWidth);
- pdfw_gs_dash(pdf_page, dash);
- }
-
- if (clip_update_needed) {
- pdfw_gs_save(pdf_page);
-
- HPDF_Page_Rectangle(pdf_page, last_clip_x0,
- page_height - last_clip_y1,
- last_clip_x1 - last_clip_x0,
- last_clip_y1 - last_clip_y0);
- HPDF_Page_Clip(pdf_page);
- HPDF_Page_EndPath(pdf_page);
-
- clip_update_needed = false;
- }
-
- if (selectTextMode && !in_text_mode) {
- HPDF_Page_BeginText(pdf_page);
- in_text_mode = true;
- }
-}
-
-static inline float transform_x(const float transform[6], float x, float y)
-{
- return transform[0] * x + transform[2] * y + transform[4];
-}
-
-static inline float transform_y(const float transform[6], float x, float y)
-{
- return page_height
- - (transform[1] * x + transform[3] * y + transform[5]);
-}
-
-bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width,
- colour c, const float transform[6])
-{
- unsigned int i;
- bool empty_path;
-
-#ifdef PDF_DEBUG
- LOG(("."));
-#endif
-
- if (n == 0)
- return true;
-
- if (c == NS_TRANSPARENT && fill == NS_TRANSPARENT)
- return true;
-
- if (p[0] != PLOTTER_PATH_MOVE)
- return false;
-
- apply_clip_and_mode(false, fill, c, width, DashPattern_eNone);
-
- empty_path = true;
- for (i = 0 ; i < n ; ) {
- if (p[i] == PLOTTER_PATH_MOVE) {
- HPDF_Page_MoveTo(pdf_page,
- transform_x(transform, p[i+1], p[i+2]),
- transform_y(transform, p[i+1], p[i+2]));
- i+= 3;
- } else if (p[i] == PLOTTER_PATH_CLOSE) {
- if (!empty_path)
- HPDF_Page_ClosePath(pdf_page);
- i++;
- } else if (p[i] == PLOTTER_PATH_LINE) {
- HPDF_Page_LineTo(pdf_page,
- transform_x(transform, p[i+1], p[i+2]),
- transform_y(transform, p[i+1], p[i+2]));
- i+=3;
- empty_path = false;
- } else if (p[i] == PLOTTER_PATH_BEZIER) {
- HPDF_Page_CurveTo(pdf_page,
- transform_x(transform, p[i+1], p[i+2]),
- transform_y(transform, p[i+1], p[i+2]),
- transform_x(transform, p[i+3], p[i+4]),
- transform_y(transform, p[i+3], p[i+4]),
- transform_x(transform, p[i+5], p[i+6]),
- transform_y(transform, p[i+5], p[i+6]));
- i += 7;
- empty_path = false;
- } else {
- LOG(("bad path command %f", p[i]));
- return false;
- }
- }
-
- if (empty_path) {
- HPDF_Page_EndPath(pdf_page);
- return true;
- }
-
- if (fill != NS_TRANSPARENT) {
- if (c != NS_TRANSPARENT)
- HPDF_Page_FillStroke(pdf_page);
- else
- HPDF_Page_Fill(pdf_page);
- }
- else
- HPDF_Page_Stroke(pdf_page);
-
- return true;
-}
-
-/**
- * Begin pdf plotting - initialize a new document
- * \param path Output file path
- * \param pg_width page width
- * \param pg_height page height
- */
-bool pdf_begin(struct print_settings *print_settings)
-{
- pdfw_gs_init();
-
- if (pdf_doc != NULL)
- HPDF_Free(pdf_doc);
- pdf_doc = HPDF_New(error_handler, NULL);
- if (!pdf_doc) {
- LOG(("Error creating pdf_doc"));
- return false;
- }
-
- settings = print_settings;
-
- page_width = settings->page_width -
- FIXTOFLT(FSUB(settings->margins[MARGINLEFT],
- settings->margins[MARGINRIGHT]));
-
- page_height = settings->page_height -
- FIXTOFLT(settings->margins[MARGINTOP]);
-
-
-#ifndef PDF_DEBUG
- if (option_enable_PDF_compression)
- HPDF_SetCompressionMode(pdf_doc, HPDF_COMP_ALL); /*Compression on*/
-#endif
- HPDF_SetInfoAttr(pdf_doc, HPDF_INFO_CREATOR, user_agent_string());
-
- pdf_page = NULL;
-
-#ifdef PDF_DEBUG
- LOG(("pdf_begin finishes"));
-#endif
- return true;
-}
-
-
-bool pdf_next_page(void)
-{
-#ifdef PDF_DEBUG
- LOG(("pdf_next_page begins"));
-#endif
- clip_update_needed = false;
- if (pdf_page != NULL) {
- apply_clip_and_mode(false, NS_TRANSPARENT, NS_TRANSPARENT, 0.,
- DashPattern_eNone);
- pdfw_gs_restore(pdf_page);
- }
-
-#ifdef PDF_DEBUG_DUMPGRID
- if (pdf_page != NULL) {
- pdf_plot_grid(10, 10, 0xCCCCCC);
- pdf_plot_grid(100, 100, 0xCCCCFF);
- }
-#endif
- pdf_page = HPDF_AddPage(pdf_doc);
- if (pdf_page == NULL)
- return false;
-
- HPDF_Page_SetWidth (pdf_page, settings->page_width);
- HPDF_Page_SetHeight(pdf_page, settings->page_height);
-
- HPDF_Page_Concat(pdf_page, 1, 0, 0, 1,
- FIXTOFLT(settings->margins[MARGINLEFT]), 0);
-
- pdfw_gs_save(pdf_page);
-
-#ifdef PDF_DEBUG
- LOG(("%f %f", page_width, page_height));
-#endif
-
- return true;
-}
-
-
-void pdf_end(void)
-{
-#ifdef PDF_DEBUG
- LOG(("pdf_end begins"));
-#endif
- clip_update_needed = false;
- if (pdf_page != NULL) {
- apply_clip_and_mode(false, NS_TRANSPARENT, NS_TRANSPARENT, 0.,
- DashPattern_eNone);
- pdfw_gs_restore(pdf_page);
- }
-
-#ifdef PDF_DEBUG_DUMPGRID
- if (pdf_page != NULL) {
- pdf_plot_grid(10, 10, 0xCCCCCC);
- pdf_plot_grid(100, 100, 0xCCCCFF);
- }
-#endif
-
- assert(settings->output != NULL);
-
- /*Encryption on*/
- if (option_enable_PDF_password)
- PDF_Password(&owner_pass, &user_pass,
- (void *)settings->output);
- else
- save_pdf(settings->output);
-#ifdef PDF_DEBUG
- LOG(("pdf_end finishes"));
-#endif
-}
-
-/** saves the pdf optionally encrypting it before*/
-void save_pdf(const char *path)
-{
- bool success = false;
-
- if (option_enable_PDF_password && owner_pass != NULL ) {
- HPDF_SetPassword(pdf_doc, owner_pass, user_pass);
- HPDF_SetEncryptionMode(pdf_doc, HPDF_ENCRYPT_R3, 16);
- free(owner_pass);
- free(user_pass);
- }
-
- if (path != NULL) {
- if (HPDF_SaveToFile(pdf_doc, path) != HPDF_OK)
- remove(path);
- else
- success = true;
- }
-
- if (!success)
- warn_user("Unable to save PDF file.", 0);
-
- HPDF_Free(pdf_doc);
- pdf_doc = NULL;
-}
-
-
-/**
- * Haru error handler
- * for debugging purposes - it immediately exits the program on the first error,
- * as it would otherwise flood the user with all resulting complications,
- * covering the most important error source.
-*/
-static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no,
- void *user_data)
-{
- LOG(("ERROR:\n\terror_no=%x\n\tdetail_no=%d\n", (HPDF_UINT)error_no,
- (HPDF_UINT)detail_no));
-#ifdef PDF_DEBUG
- exit(1);
-#endif
-}
-
-/**
- * This function plots a grid - used for debug purposes to check if all
- * elements' final coordinates are correct.
-*/
-#ifdef PDF_DEBUG_DUMPGRID
-void pdf_plot_grid(int x_dist, int y_dist, unsigned int colour)
-{
- for (int i = x_dist ; i < page_width ; i += x_dist)
- pdf_plot_line(i, 0, i, page_height, 1, colour, false, false);
-
- for (int i = y_dist ; i < page_height ; i += x_dist)
- pdf_plot_line(0, i, page_width, i, 1, colour, false, false);
-}
-#endif
-
-/**
- * Initialize the gstate wrapper code.
- */
-void pdfw_gs_init()
-{
- pdfw_gs_level = 0;
- pdfw_gs[0].fillColour = 0x00000000; /* Default PDF fill colour is black. */
- pdfw_gs[0].strokeColour = 0x00000000; /* Default PDF stroke colour is black. */
- pdfw_gs[0].lineWidth = 1.0; /* Default PDF line width is 1. */
- pdfw_gs[0].font = NULL;
- pdfw_gs[0].font_size = 0.;
- pdfw_gs[0].dash = DashPattern_eNone; /* Default dash state is a solid line. */
-}
-
-/**
- * Increase gstate level.
- * \param page PDF page where the update needs to happen.
- */
-void pdfw_gs_save(HPDF_Page page)
-{
- if (pdfw_gs_level == PDFW_MAX_GSTATES)
- abort();
- pdfw_gs[pdfw_gs_level + 1] = pdfw_gs[pdfw_gs_level];
- ++pdfw_gs_level;
- HPDF_Page_GSave(page);
-}
-
-/**
- * Decrease gstate level and restore the gstate to its value at last save
- * operation.
- * \param page PDF page where the update needs to happen.
- */
-void pdfw_gs_restore(HPDF_Page page)
-{
- if (pdfw_gs_level == 0)
- abort();
- --pdfw_gs_level;
- HPDF_Page_GRestore(page);
-}
-
-#define RBYTE(x) (((x) & 0x0000FF) >> 0)
-#define GBYTE(x) (((x) & 0x00FF00) >> 8)
-#define BBYTE(x) (((x) & 0xFF0000) >> 16)
-#define R(x) (RBYTE(x) / 255.)
-#define G(x) (GBYTE(x) / 255.)
-#define B(x) (BBYTE(x) / 255.)
-
-/**
- * Checks if given fill colour is already set in PDF gstate and if not,
- * update the gstate accordingly.
- * \param page PDF page where the update needs to happen.
- * \param col Wanted fill colour.
- */
-void pdfw_gs_fillcolour(HPDF_Page page, colour col)
-{
- if (col == pdfw_gs[pdfw_gs_level].fillColour)
- return;
- pdfw_gs[pdfw_gs_level].fillColour = col;
- if (RBYTE(col) == GBYTE(col) && GBYTE(col) == BBYTE(col))
- HPDF_Page_SetGrayFill(pdf_page, R(col));
- else
- HPDF_Page_SetRGBFill(pdf_page, R(col), G(col), B(col));
-}
-
-/**
- * Checks if given stroke colour is already set in PDF gstate and if not,
- * update the gstate accordingly.
- * \param page PDF page where the update needs to happen.
- * \param col Wanted stroke colour.
- */
-void pdfw_gs_strokecolour(HPDF_Page page, colour col)
-{
- if (col == pdfw_gs[pdfw_gs_level].strokeColour)
- return;
- pdfw_gs[pdfw_gs_level].strokeColour = col;
- if (RBYTE(col) == GBYTE(col) && GBYTE(col) == BBYTE(col))
- HPDF_Page_SetGrayStroke(pdf_page, R(col));
- else
- HPDF_Page_SetRGBStroke(pdf_page, R(col), G(col), B(col));
-}
-
-/**
- * Checks if given line width is already set in PDF gstate and if not, update
- * the gstate accordingly.
- * \param page PDF page where the update needs to happen.
- * \param lineWidth Wanted line width.
- */
-void pdfw_gs_linewidth(HPDF_Page page, float lineWidth)
-{
- if (lineWidth == pdfw_gs[pdfw_gs_level].lineWidth)
- return;
- pdfw_gs[pdfw_gs_level].lineWidth = lineWidth;
- HPDF_Page_SetLineWidth(page, lineWidth);
-}
-
-/**
- * Checks if given font and font size is already set in PDF gstate and if not,
- * update the gstate accordingly.
- * \param page PDF page where the update needs to happen.
- * \param font Wanted PDF font.
- * \param font_size Wanted PDF font size.
- */
-void pdfw_gs_font(HPDF_Page page, HPDF_Font font, HPDF_REAL font_size)
-{
- if (font == pdfw_gs[pdfw_gs_level].font
- && font_size == pdfw_gs[pdfw_gs_level].font_size)
- return;
- pdfw_gs[pdfw_gs_level].font = font;
- pdfw_gs[pdfw_gs_level].font_size = font_size;
- HPDF_Page_SetFontAndSize(page, font, font_size);
-}
-
-/**
- * Checks if given dash pattern is already set in PDF gstate and if not,
- * update the gstate accordingly.
- * \param page PDF page where the update needs to happen.
- * \param dash Wanted dash pattern.
- */
-void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash)
-{
- if (dash == pdfw_gs[pdfw_gs_level].dash)
- return;
- pdfw_gs[pdfw_gs_level].dash = dash;
- switch (dash) {
- case DashPattern_eNone: {
- HPDF_Page_SetDash(page, NULL, 0, 0);
- break;
- }
- case DashPattern_eDash: {
- const HPDF_UINT16 dash_ptn[] = {3};
- HPDF_Page_SetDash(page, dash_ptn, 1, 1);
- break;
- }
- case DashPattern_eDotted: {
- const HPDF_UINT16 dash_ptn[] = {1};
- HPDF_Page_SetDash(page, dash_ptn, 1, 1);
- break;
- }
- }
-}
-
-#endif /* WITH_PDF_EXPORT */
-
diff --git a/desktop/save_pdf/pdf_plotters.h b/desktop/save_pdf/pdf_plotters.h
deleted file mode 100644
index 7ecb549..0000000
--- a/desktop/save_pdf/pdf_plotters.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2008 Adam Blokus <adamblokus(a)gmail.com>
- *
- * 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
- PDF Plotting
-*/
-
-#ifndef NETSURF_PDF_PLOTTERS_H
-#define NETSURF_PDF_PLOTTERS_H
-
-#include "desktop/print.h"
-
-extern const struct printer pdf_printer;
-
-/**Start plotting a pdf file*/
-bool pdf_begin(struct print_settings *settings);
-
-/**Finish the current page and start a new one*/
-bool pdf_next_page(void);
-
-/**Close pdf document and save changes to file*/
-void pdf_end(void);
-
-void save_pdf(const char *path);
-
-#endif /*NETSURF_PDF_PLOTTERS_H*/
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index be0dad2..b1a6f61 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -117,7 +117,7 @@ S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
# are not yet available
-SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_PIXBUF) $(S_GTK)
+SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PIXBUF) $(S_GTK)
EXETARGET := nsgtk
# ----------------------------------------------------------------------------
diff --git a/gtk/gui.c b/gtk/gui.c
index eeba466..c4dc0e1 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -54,7 +54,7 @@
#include "content/backing_store.h"
#include "desktop/browser.h"
#include "desktop/save_complete.h"
-#include "desktop/save_pdf/pdf_plotters.h"
+#include "desktop/save_pdf.h"
#include "desktop/searchweb.h"
#include "desktop/sslcert_viewer.h"
#include "desktop/textinput.h"
@@ -696,71 +696,45 @@ gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, gpointer data)
return FALSE;
}
-#ifdef WITH_PDF_EXPORT
-
-void PDF_Password(char **owner_pass, char **user_pass, char *path)
-{
- GladeXML *x = glade_xml_new(glade_password_file_location, NULL, NULL);
- GtkWindow *wnd = GTK_WINDOW(glade_xml_get_widget(x, "wndPDFPassword"));
- GtkButton *ok, *no;
- void **data = malloc(5 * sizeof(void *));
-
- *owner_pass = NULL;
- *user_pass = NULL;
-
- data[0] = owner_pass;
- data[1] = user_pass;
- data[2] = wnd;
- data[3] = x;
- data[4] = path;
-
- ok = GTK_BUTTON(glade_xml_get_widget(x, "buttonPDFSetPassword"));
- no = GTK_BUTTON(glade_xml_get_widget(x, "buttonPDFNoPassword"));
-
- g_signal_connect(G_OBJECT(ok), "clicked",
- G_CALLBACK(nsgtk_PDF_set_pass), (gpointer)data);
- g_signal_connect(G_OBJECT(no), "clicked",
- G_CALLBACK(nsgtk_PDF_no_pass), (gpointer)data);
-
- gtk_widget_show(GTK_WIDGET(wnd));
-}
static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data)
{
char **owner_pass = ((void **)data)[0];
char **user_pass = ((void **)data)[1];
GtkWindow *wnd = ((void **)data)[2];
- GladeXML *x = ((void **)data)[3];
+ GtkBuilder *gladeFile = ((void **)data)[3];
char *path = ((void **)data)[4];
char *op, *op1;
char *up, *up1;
- op = strdup(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(x,
- "entryPDFOwnerPassword"))));
- op1 = strdup(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(x,
- "entryPDFOwnerPassword1"))));
- up = strdup(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(x,
- "entryPDFUserPassword"))));
- up1 = strdup(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(x,
- "entryPDFUserPassword1"))));
+ op = strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_builder_get_object(gladeFile,
+ "entryPDFOwnerPassword"))));
+ op1 = strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_builder_get_object(gladeFile,
+ "entryPDFOwnerPassword1"))));
+ up = strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_builder_get_object(gladeFile,
+ "entryPDFUserPassword"))));
+ up1 = strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_builder_get_object(gladeFile,
+ "entryPDFUserPassword1"))));
if (op[0] == '\0') {
- gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(x,
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gladeFile,
"labelInfo")),
"Owner password must be at least 1 character long:");
free(op);
free(up);
- }
- else if (!strcmp(op, up)) {
- gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(x,
+ } else if (!strcmp(op, up)) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gladeFile,
"labelInfo")),
"User and owner passwords must be different:");
free(op);
free(up);
- }
- else if (!strcmp(op, op1) && !strcmp(up, up1)) {
+ } else if (!strcmp(op, op1) && !strcmp(up, up1)) {
*owner_pass = op;
if (up[0] == '\0')
@@ -770,13 +744,13 @@ static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data)
free(data);
gtk_widget_destroy(GTK_WIDGET(wnd));
- g_object_unref(G_OBJECT(x));
+ g_object_unref(G_OBJECT(gladeFile));
save_pdf(path);
+
free(path);
- }
- else {
- gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(x,
+ } else {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gladeFile,
"labelInfo")), "Passwords not confirmed:");
free(op);
free(up);
@@ -789,18 +763,60 @@ static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data)
static void nsgtk_PDF_no_pass(GtkButton *w, gpointer data)
{
GtkWindow *wnd = ((void **)data)[2];
- GladeXML *x = ((void **)data)[3];
+ GtkBuilder *gladeFile = ((void **)data)[3];
char *path = ((void **)data)[4];
free(data);
gtk_widget_destroy(GTK_WIDGET(wnd));
- g_object_unref(G_OBJECT(x));
+ g_object_unref(G_OBJECT(gladeFile));
save_pdf(path);
+
free(path);
}
-#endif
+
+static void nsgtk_pdf_password(char **owner_pass, char **user_pass, char *path)
+{
+ GtkButton *ok, *no;
+ GtkWindow *wnd;
+ void **data;
+ GtkBuilder *gladeFile;
+ GError* error = NULL;
+
+ gladeFile = gtk_builder_new();
+ if (!gtk_builder_add_from_file(gladeFile,
+ glade_file_location->password,
+ &error)) {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ wnd = GTK_WINDOW(gtk_builder_get_object(gladeFile, "wndPDFPassword"));
+
+ data = malloc(5 * sizeof(void *));
+
+ *owner_pass = NULL;
+ *user_pass = NULL;
+
+ data[0] = owner_pass;
+ data[1] = user_pass;
+ data[2] = wnd;
+ data[3] = gladeFile;
+ data[4] = path;
+
+ ok = GTK_BUTTON(gtk_builder_get_object(gladeFile, "buttonPDFSetPassword"));
+ no = GTK_BUTTON(gtk_builder_get_object(gladeFile, "buttonPDFNoPassword"));
+
+ g_signal_connect(G_OBJECT(ok), "clicked",
+ G_CALLBACK(nsgtk_PDF_set_pass), (gpointer)data);
+ g_signal_connect(G_OBJECT(no), "clicked",
+ G_CALLBACK(nsgtk_PDF_no_pass), (gpointer)data);
+
+ gtk_widget_show(GTK_WIDGET(wnd));
+}
+
uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
{
@@ -1194,6 +1210,7 @@ static struct gui_browser_table nsgtk_browser_table = {
.launch_url = gui_launch_url,
.cert_verify = gui_cert_verify,
.login = gui_401login_open,
+ .pdf_password = nsgtk_pdf_password,
};
/**
diff --git a/riscos/Makefile.target b/riscos/Makefile.target
index 46ca341..a52c03f 100644
--- a/riscos/Makefile.target
+++ b/riscos/Makefile.target
@@ -92,7 +92,7 @@ TPL_RISCOS := $(addprefix riscos/templates/,$(TPL_RISCOS))
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
# are not yet available
-SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_RISCOS)
+SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_RISCOS)
EXETARGET := !NetSurf/!RunImage$(EXEEXT)
!NetSurf/!Run$(RUNEXT): riscos/scripts/Run $(EXETARGET)
diff --git a/riscos/gui.c b/riscos/gui.c
index ade22cb..198fd23 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -2152,13 +2152,6 @@ bool ro_gui_prequit(void)
}
-void PDF_Password(char **owner_pass, char **user_pass, char *path)
-{
- /** @todo this waits to be written, until then no PDF encryption */
- *owner_pass = NULL;
-}
-
-
/**
* Generate a riscos path from one or more component elemnts.
*
diff --git a/utils/utils.h b/utils/utils.h
index b908432..00d1501 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -258,6 +258,5 @@ int dir_sort_alpha(const struct dirent **d1, const struct dirent **d2);
/* Platform specific functions */
void warn_user(const char *warning, const char *detail);
-void PDF_Password(char **owner_pass, char **user_pass, char *path);
#endif
-----------------------------------------------------------------------
Summary of changes:
Makefile | 3 -
amiga/Makefile.target | 2 +-
amiga/save_pdf.c | 5 -
cocoa/utils.m | 9 --
desktop/Makefile | 4 +-
desktop/{save_pdf => }/font_haru.c | 97 +++++++++---------
desktop/{save_pdf => }/font_haru.h | 10 +-
desktop/gui_factory.c | 22 +++--
desktop/gui_misc.h | 10 ++
desktop/{save_pdf/pdf_plotters.c => save_pdf.c} | 69 +++++++++----
desktop/{save_pdf/pdf_plotters.h => save_pdf.h} | 2 +-
desktop/save_pdf/Makefile | 6 --
desktop/save_pdf/TODO | 19 ----
gtk/Makefile.target | 2 +-
gtk/gui.c | 119 +++++++++++++----------
riscos/Makefile.target | 2 +-
riscos/gui.c | 7 --
utils/utils.h | 1 -
18 files changed, 201 insertions(+), 188 deletions(-)
rename desktop/{save_pdf => }/font_haru.c (93%)
rename desktop/{save_pdf => }/font_haru.h (93%)
rename desktop/{save_pdf/pdf_plotters.c => save_pdf.c} (94%)
rename desktop/{save_pdf/pdf_plotters.h => save_pdf.h} (99%)
delete mode 100644 desktop/save_pdf/Makefile
delete mode 100644 desktop/save_pdf/TODO
diff --git a/Makefile b/Makefile
index 4fe22e2..0876608 100644
--- a/Makefile
+++ b/Makefile
@@ -571,9 +571,6 @@ include javascript/Makefile
# Image content handler sources
include image/Makefile
-# PDF saving sources
-include desktop/save_pdf/Makefile
-
# S_COMMON are sources common to all builds
S_COMMON := $(S_CONTENT) $(S_FETCHERS) $(S_CSS) $(S_RENDER) $(S_UTILS) \
$(S_HTTP) $(S_DESKTOP) $(S_JAVASCRIPT)
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index ea765af..8939dbc 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -78,7 +78,7 @@ S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
# are not yet available
-SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA) $(S_PDF)
+SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_AMIGA)
# ----------------------------------------------------------------------------
# Install target
diff --git a/amiga/save_pdf.c b/amiga/save_pdf.c
index 1659221..b70fc57 100644
--- a/amiga/save_pdf.c
+++ b/amiga/save_pdf.c
@@ -56,9 +56,4 @@ bool save_as_pdf(struct hlcache_handle *c, const char *path)
return true;
}
-void PDF_Password(char **owner_pass, char **user_pass, char *path)
-{
- /*TODO:this waits to be written, until then no PDF encryption*/
- *owner_pass = NULL;
-}
#endif
diff --git a/cocoa/utils.m b/cocoa/utils.m
index b49e503..2c73e9b 100644
--- a/cocoa/utils.m
+++ b/cocoa/utils.m
@@ -20,9 +20,6 @@
#import "utils/utils.h"
-#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
-
-
void warn_user(const char *warning, const char *detail)
{
NSRunAlertPanel( NSLocalizedString( @"Warning", @"Warning title" ),
@@ -31,9 +28,3 @@ void warn_user(const char *warning, const char *detail)
warning, detail != NULL ? ": " : "",
detail != NULL ? detail : "" );
}
-
-void PDF_Password(char **owner_pass, char **user_pass, char *path)
-{
- UNIMPL();
-}
-
diff --git a/desktop/Makefile b/desktop/Makefile
index 218f60e..894b518 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -13,7 +13,7 @@ desktop/version.c: testament $(OBJROOT)/testament.h
# S_BROWSER are sources related to full browsers but are common
# between RISC OS, GTK, BeOS and AmigaOS builds
S_BROWSER := browser.c browser_history.c download.c frames.c netsurf.c \
- save_complete.c save_text.c selection.c textinput.c gui_factory.c
+ save_complete.c save_text.c selection.c textinput.c gui_factory.c \
+ save_pdf.c font_haru.c
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
-
diff --git a/desktop/save_pdf/font_haru.c b/desktop/font_haru.c
similarity index 93%
rename from desktop/save_pdf/font_haru.c
rename to desktop/font_haru.c
index e8643f7..aaee84c 100644
--- a/desktop/save_pdf/font_haru.c
+++ b/desktop/font_haru.c
@@ -16,7 +16,7 @@
* 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
* Font handling in Haru pdf documents (implementation).
*
@@ -28,11 +28,11 @@
#ifdef WITH_PDF_EXPORT
/*#define FONT_HARU_DEBUG */
-
-#include <assert.h>
-#include <float.h>
+
+#include <assert.h>
+#include <float.h>
#include <math.h>
-#include <string.h>
+#include <string.h>
#include <hpdf.h>
@@ -59,7 +59,7 @@ static bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle,
static bool haru_nsfont_split(const plot_font_style_t *fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x);
-
+
static float pdf_text_scale = DEFAULT_EXPORT_SCALE;
const struct font_functions haru_nsfont = {
@@ -77,37 +77,37 @@ const struct font_functions haru_nsfont = {
static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no,
void *user_data)
{
- LOG(("ERROR: in font_haru \n\terror_no=%x\n\tdetail_no=%d\n",
+ LOG(("ERROR: in font_haru \n\terror_no=%x\n\tdetail_no=%d\n",
(HPDF_UINT)error_no, (HPDF_UINT)detail_no));
-#ifdef FONT_HARU_DEBUG
+#ifdef FONT_HARU_DEBUG
exit(1);
-#endif
+#endif
}
static bool haru_nsfont_init(HPDF_Doc *pdf, HPDF_Page *page,
const char *string, char **string_nt, int length)
{
-
+
*pdf = HPDF_New(error_handler, NULL);
-
+
if (*pdf == NULL)
return false;
*page = HPDF_AddPage(*pdf);
-
+
if (*page == NULL) {
HPDF_Free(*pdf);
- return false;
+ return false;
}
-
+
*string_nt = malloc((length + 1) * sizeof(char));
if (*string_nt == NULL) {
HPDF_Free(*pdf);
return false;
}
-
+
memcpy(*string_nt, string, length);
- (*string_nt)[length] = '\0';
+ (*string_nt)[length] = '\0';
return true;
}
@@ -146,7 +146,7 @@ bool haru_nsfont_width(const plot_font_style_t *fstyle,
width_real = HPDF_Page_TextWidth(page, string_nt);
*width = width_real;
-#ifdef FONT_HARU_DEBUG
+#ifdef FONT_HARU_DEBUG
LOG(("Measuring string: %s ; Calculated width: %f %i",string_nt, width_real, *width));
#endif
free(string_nt);
@@ -177,10 +177,10 @@ bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle,
char *string_nt;
HPDF_UINT offset;
HPDF_REAL real_width;
-
+
if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length))
return false;
-
+
if (HPDF_Page_SetWidth(page, x) != HPDF_OK
|| !haru_nsfont_apply_style(fstyle, pdf, page, NULL, NULL)) {
free(string_nt);
@@ -188,10 +188,10 @@ bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle,
return false;
}
-
+
offset = HPDF_Page_MeasureText(page, string_nt, x,
HPDF_FALSE, &real_width);
-
+
if (real_width < x)
*char_offset = offset;
@@ -200,17 +200,17 @@ bool haru_nsfont_position_in_string(const plot_font_style_t *fstyle,
assert(offset > 0);
*char_offset = offset - 1;
}
-
+
/*TODO: this is only the right edge of the character*/
*actual_x = real_width;
-
-#ifdef FONT_HARU_DEBUG
+
+#ifdef FONT_HARU_DEBUG
LOG(("Position in string: %s at x: %i; Calculated position: %i",
- string_nt, x, *char_offset));
-#endif
+ string_nt, x, *char_offset));
+#endif
free(string_nt);
HPDF_Free(pdf);
-
+
return true;
}
@@ -235,34 +235,34 @@ bool haru_nsfont_split(const plot_font_style_t *fstyle,
char *string_nt;
HPDF_REAL real_width;
HPDF_UINT offset;
-
-
+
+
if (!haru_nsfont_init(&pdf, &page, string, &string_nt, length))
return false;
-
+
if (HPDF_Page_SetWidth(page, x) != HPDF_OK
|| !haru_nsfont_apply_style(fstyle, pdf, page, NULL, NULL)) {
free(string_nt);
HPDF_Free(pdf);
return false;
}
-
+
offset = HPDF_Page_MeasureText(page, string_nt, x,
HPDF_TRUE, &real_width);
-
-#ifdef FONT_HARU_DEBUG
- LOG(("Splitting string: %s for width: %i ; Calculated position: %i Calculated real_width: %f",
- string_nt, x, *char_offset, real_width));
-#endif
+
+#ifdef FONT_HARU_DEBUG
+ LOG(("Splitting string: %s for width: %i ; Calculated position: %i Calculated real_width: %f",
+ string_nt, x, *char_offset, real_width));
+#endif
*char_offset = offset - 1;
-
+
/*TODO: this is only the right edge of the character*/
*actual_x = real_width;
-
+
free(string_nt);
HPDF_Free(pdf);
-
- return true;
+
+ return true;
}
/**
@@ -305,14 +305,14 @@ bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
case PLOT_FONT_FAMILY_SANS_SERIF:
strcpy(font_name, "Helvetica");
break;
- case PLOT_FONT_FAMILY_CURSIVE:
- case PLOT_FONT_FAMILY_FANTASY:
+ case PLOT_FONT_FAMILY_CURSIVE:
+ case PLOT_FONT_FAMILY_FANTASY:
default:
strcpy(font_name, "Times");
roman=true;
break;
}
-
+
if (fstyle->weight == 700) {
strcat(font_name, "-Bold");
bold = true;
@@ -325,16 +325,16 @@ bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
strcat(font_name,"Italic");
else
strcat(font_name,"Oblique");
-
+
styled = true;
}
-
+
if (roman && !styled && !bold)
strcat(font_name, "-Roman");
-#ifdef FONT_HARU_DEBUG
+#ifdef FONT_HARU_DEBUG
LOG(("Setting font: %s", font_name));
-#endif
+#endif
size = fstyle->size;
@@ -360,7 +360,7 @@ bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
if (font == NULL || font_size == NULL)
HPDF_Page_SetFontAndSize(page, pdf_font, size);
-
+
return true;
}
@@ -373,4 +373,3 @@ void haru_nsfont_set_scale(float s)
}
#endif /* WITH_PDF_EXPORT */
-
diff --git a/desktop/save_pdf/font_haru.h b/desktop/font_haru.h
similarity index 93%
rename from desktop/save_pdf/font_haru.h
rename to desktop/font_haru.h
index c6578b0..479f7de 100644
--- a/desktop/save_pdf/font_haru.h
+++ b/desktop/font_haru.h
@@ -16,19 +16,19 @@
* 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
* Font handling in Haru pdf documents (interface).
*/
-
-#ifndef _NETSURF_RENDER_FONT_HARU_H_
-#define _NETSURF_RENDER_FONT_HARU_H_
+
+#ifndef _NETSURF_DESKTOP_FONT_HARU_H_
+#define _NETSURF_DESKTOP_FONT_HARU_H_
#include <hpdf.h>
#include "desktop/plot_style.h"
#include "desktop/font.h"
-
+
bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
HPDF_Doc doc, HPDF_Page page,
HPDF_Font *font, HPDF_REAL *font_size);
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index e7770e7..b69700f 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -20,6 +20,7 @@
#include "content/backing_store.h"
#include "utils/file.h"
+#include "desktop/save_pdf.h"
#include "desktop/download.h"
#include "desktop/searchweb.h"
#include "desktop/gui_download.h"
@@ -259,6 +260,12 @@ static void gui_default_download_done(struct gui_download_window *dw)
{
}
+static struct gui_download_table default_download_table = {
+ .create = gui_default_download_create,
+ .data = gui_default_download_data,
+ .error = gui_default_download_error,
+ .done = gui_default_download_done,
+};
/** verify download window table is valid */
static nserror verify_download_register(struct gui_download_table *gdt)
@@ -566,12 +573,12 @@ static void gui_default_401login_open(nsurl *url, const char *realm,
cb(false, cbpw);
}
-static struct gui_download_table default_download_table = {
- .create = gui_default_download_create,
- .data = gui_default_download_data,
- .error = gui_default_download_error,
- .done = gui_default_download_done,
-};
+static void
+gui_default_pdf_password(char **owner_pass, char **user_pass, char *path)
+{
+ *owner_pass = NULL;
+ save_pdf(path);
+}
/** verify browser table is valid */
static nserror verify_browser_register(struct gui_browser_table *gbt)
@@ -599,6 +606,9 @@ static nserror verify_browser_register(struct gui_browser_table *gbt)
if (gbt->login == NULL) {
gbt->login = gui_default_401login_open;
}
+ if (gbt->pdf_password == NULL) {
+ gbt->pdf_password = gui_default_pdf_password;
+ }
return NSERROR_OK;
}
diff --git a/desktop/gui_misc.h b/desktop/gui_misc.h
index daad6ba..8005006 100644
--- a/desktop/gui_misc.h
+++ b/desktop/gui_misc.h
@@ -80,6 +80,16 @@ struct gui_browser_table {
void (*login)(struct nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
+ /**
+ * Warn the user of an event.
+ */
+ void (*warning)(const char *warning, const char *detail);
+
+ /**
+ * Prompt the user for a password for a PDF.
+ */
+ void (*pdf_password)(char **owner_pass, char **user_pass, char *path);
+
};
#endif
diff --git a/desktop/save_pdf/pdf_plotters.c b/desktop/save_pdf.c
similarity index 94%
rename from desktop/save_pdf/pdf_plotters.c
rename to desktop/save_pdf.c
index 123408d..e3f9cbc 100644
--- a/desktop/save_pdf/pdf_plotters.c
+++ b/desktop/save_pdf.c
@@ -21,7 +21,32 @@
* Target independent PDF plotting using Haru Free PDF Library.
*/
+/* TODO
+ * - finish all graphic primitives
+ * - allow adding raw bitmaps
+ * - make image-aware (embed the image in its native/original type if possible)
+ *
+ * - adjust content width to page width
+ * - divide output into multiple pages (not just the first one)
+ * - rearrange file structure
+ *
+ * - separate print-plotting as much as possible from window redrawing
+ * - add text-scaling (if not yet using the original font - make the default one
+ * have the same width)
+ * - add a save file.. dialogue
+ * - add utf support to Haru ( doable? )
+ * - wait for browser to end fetching?
+ * - analyze and deal with performance issues(huge file hangs some pdf viewers,
+ * for example kpdf when viewing plotted http://www.onet.pl)
+ * - deal with to wide pages - when window layouting adds a horizontal
+ * scrollbar, we should treat it otherwise - either print
+ * horizontal or scale or, better, find a new layout.
+ */
+
#include "utils/config.h"
+
+#include "desktop/save_pdf.h"
+
#ifdef WITH_PDF_EXPORT
#include <assert.h>
@@ -35,7 +60,6 @@
#include "desktop/plotters.h"
#include "desktop/print.h"
#include "desktop/printer.h"
-#include "desktop/save_pdf/pdf_plotters.h"
#include "image/bitmap.h"
#include "utils/log.h"
#include "utils/utils.h"
@@ -50,7 +74,7 @@ static bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_
static bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle);
static bool pdf_plot_polygon(const int *p, unsigned int n, const plot_style_t *style);
static bool pdf_plot_clip(const struct rect *clip);
-static bool pdf_plot_text(int x, int y, const char *text, size_t length,
+static bool pdf_plot_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle);
static bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style);
static bool pdf_plot_arc(int x, int y, int radius, int angle1, int angle2,
@@ -86,7 +110,7 @@ static void pdfw_gs_linewidth(HPDF_Page page, float lineWidth);
static void pdfw_gs_font(HPDF_Page page, HPDF_Font font, HPDF_REAL font_size);
static void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash);
-/**
+/**
* Our PDF gstate mirror which we use to minimize gstate updates
* in the PDF file.
*/
@@ -186,9 +210,9 @@ bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *psty
}
- apply_clip_and_mode(false,
- NS_TRANSPARENT,
- pstyle->stroke_colour,
+ apply_clip_and_mode(false,
+ NS_TRANSPARENT,
+ pstyle->stroke_colour,
pstyle->stroke_width,
dash);
@@ -218,9 +242,9 @@ bool pdf_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
}
- apply_clip_and_mode(false,
- NS_TRANSPARENT,
- pstyle->stroke_colour,
+ apply_clip_and_mode(false,
+ NS_TRANSPARENT,
+ pstyle->stroke_colour,
pstyle->stroke_width,
dash);
@@ -285,7 +309,7 @@ bool pdf_plot_clip(const struct rect *clip)
return true;
}
-bool pdf_plot_text(int x, int y, const char *text, size_t length,
+bool pdf_plot_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle)
{
#ifdef PDF_DEBUG
@@ -298,7 +322,7 @@ bool pdf_plot_text(int x, int y, const char *text, size_t length,
if (length == 0)
return true;
- apply_clip_and_mode(true, fstyle->foreground, NS_TRANSPARENT, 0.,
+ apply_clip_and_mode(true, fstyle->foreground, NS_TRANSPARENT, 0.,
DashPattern_eNone);
haru_nsfont_apply_style(fstyle, pdf_doc, pdf_page, &pdf_font, &size);
@@ -326,7 +350,7 @@ bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style)
#endif
if (style->fill_type != PLOT_OP_TYPE_NONE) {
apply_clip_and_mode(false,
- style->fill_colour,
+ style->fill_colour,
NS_TRANSPARENT,
1., DashPattern_eNone);
@@ -338,7 +362,7 @@ bool pdf_plot_disc(int x, int y, int radius, const plot_style_t *style)
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
/* FIXME: line width 1 is ok ? */
apply_clip_and_mode(false,
- NS_TRANSPARENT,
+ NS_TRANSPARENT,
style->stroke_colour,
1., DashPattern_eNone);
@@ -410,9 +434,9 @@ bool pdf_plot_bitmap_tile(int x, int y, int width, int height,
HPDF_Image pdf_extract_image(struct bitmap *bitmap)
{
HPDF_Image image = NULL;
- hlcache_handle *content = NULL;
+ hlcache_handle *content = NULL;
- /* TODO - get content from bitmap pointer */
+ /* TODO - get content from bitmap pointer */
if (content) {
const char *source_data;
@@ -667,11 +691,11 @@ bool pdf_begin(struct print_settings *print_settings)
settings = print_settings;
- page_width = settings->page_width -
+ page_width = settings->page_width -
FIXTOFLT(FSUB(settings->margins[MARGINLEFT],
settings->margins[MARGINRIGHT]));
- page_height = settings->page_height -
+ page_height = settings->page_height -
FIXTOFLT(settings->margins[MARGINTOP]);
@@ -715,7 +739,7 @@ bool pdf_next_page(void)
HPDF_Page_SetWidth (pdf_page, settings->page_width);
HPDF_Page_SetHeight(pdf_page, settings->page_height);
- HPDF_Page_Concat(pdf_page, 1, 0, 0, 1,
+ HPDF_Page_Concat(pdf_page, 1, 0, 0, 1,
FIXTOFLT(settings->margins[MARGINLEFT]), 0);
pdfw_gs_save(pdf_page);
@@ -751,7 +775,7 @@ void pdf_end(void)
/*Encryption on*/
if (option_enable_PDF_password)
- PDF_Password(&owner_pass, &user_pass,
+ guit->browser->pdf_password(&owner_pass, &user_pass,
(void *)settings->output);
else
save_pdf(settings->output);
@@ -760,7 +784,7 @@ void pdf_end(void)
#endif
}
-/** saves the pdf optionally encrypting it before*/
+/** saves the pdf with optional encryption */
void save_pdf(const char *path)
{
bool success = false;
@@ -959,5 +983,8 @@ void pdfw_gs_dash(HPDF_Page page, DashPattern_e dash)
}
}
+#else
+void save_pdf(const char *path)
+{
+}
#endif /* WITH_PDF_EXPORT */
-
diff --git a/desktop/save_pdf/pdf_plotters.h b/desktop/save_pdf.h
similarity index 99%
rename from desktop/save_pdf/pdf_plotters.h
rename to desktop/save_pdf.h
index 7ecb549..d02c356 100644
--- a/desktop/save_pdf/pdf_plotters.h
+++ b/desktop/save_pdf.h
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/** \file
PDF Plotting
*/
diff --git a/desktop/save_pdf/Makefile b/desktop/save_pdf/Makefile
deleted file mode 100644
index cf1f978..0000000
--- a/desktop/save_pdf/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# PDF saving sources
-
-# S_PDF are sources of the pdf plotter + the ones for paged-printing
-S_PDF := pdf_plotters.c font_haru.c
-
-S_PDF := $(addprefix desktop/save_pdf/,$(S_PDF))
diff --git a/desktop/save_pdf/TODO b/desktop/save_pdf/TODO
deleted file mode 100644
index 1b3a896..0000000
--- a/desktop/save_pdf/TODO
+++ /dev/null
@@ -1,19 +0,0 @@
-- finish all graphic primitives
-- allow adding raw bitmaps
-- make image-aware (embed the image in its native/original type if possible)
-
-- adjust content width to page width
-- divide output into multiple pages (not just the first one)
-- rearrange file structure
-
-- separate print-plotting as much as possible from window redrawing
-- add text-scaling (if not yet using the original font - make the default one
- have the same width)
-- add a save file.. dialogue
-- add utf support to Haru ( doable? )
-- wait for browser to end fetching?
-- analyze and deal with performance issues(huge file hangs some pdf viewers,
- for example kpdf when viewing plotted http://www.onet.pl)
-- deal with to wide pages - when window layouting adds a horizontal scrollbar,
- we should treat it otherwise - either print horizontal or scale or,
- better, find a new layout.
\ No newline at end of file
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index be0dad2..b1a6f61 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -117,7 +117,7 @@ S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
# are not yet available
-SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_PIXBUF) $(S_GTK)
+SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PIXBUF) $(S_GTK)
EXETARGET := nsgtk
# ----------------------------------------------------------------------------
diff --git a/gtk/gui.c b/gtk/gui.c
index eeba466..c4dc0e1 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -54,7 +54,7 @@
#include "content/backing_store.h"
#include "desktop/browser.h"
#include "desktop/save_complete.h"
-#include "desktop/save_pdf/pdf_plotters.h"
+#include "desktop/save_pdf.h"
#include "desktop/searchweb.h"
#include "desktop/sslcert_viewer.h"
#include "desktop/textinput.h"
@@ -696,71 +696,45 @@ gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, gpointer data)
return FALSE;
}
-#ifdef WITH_PDF_EXPORT
-
-void PDF_Password(char **owner_pass, char **user_pass, char *path)
-{
- GladeXML *x = glade_xml_new(glade_password_file_location, NULL, NULL);
- GtkWindow *wnd = GTK_WINDOW(glade_xml_get_widget(x, "wndPDFPassword"));
- GtkButton *ok, *no;
- void **data = malloc(5 * sizeof(void *));
-
- *owner_pass = NULL;
- *user_pass = NULL;
-
- data[0] = owner_pass;
- data[1] = user_pass;
- data[2] = wnd;
- data[3] = x;
- data[4] = path;
-
- ok = GTK_BUTTON(glade_xml_get_widget(x, "buttonPDFSetPassword"));
- no = GTK_BUTTON(glade_xml_get_widget(x, "buttonPDFNoPassword"));
-
- g_signal_connect(G_OBJECT(ok), "clicked",
- G_CALLBACK(nsgtk_PDF_set_pass), (gpointer)data);
- g_signal_connect(G_OBJECT(no), "clicked",
- G_CALLBACK(nsgtk_PDF_no_pass), (gpointer)data);
-
- gtk_widget_show(GTK_WIDGET(wnd));
-}
static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data)
{
char **owner_pass = ((void **)data)[0];
char **user_pass = ((void **)data)[1];
GtkWindow *wnd = ((void **)data)[2];
- GladeXML *x = ((void **)data)[3];
+ GtkBuilder *gladeFile = ((void **)data)[3];
char *path = ((void **)data)[4];
char *op, *op1;
char *up, *up1;
- op = strdup(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(x,
- "entryPDFOwnerPassword"))));
- op1 = strdup(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(x,
- "entryPDFOwnerPassword1"))));
- up = strdup(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(x,
- "entryPDFUserPassword"))));
- up1 = strdup(gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(x,
- "entryPDFUserPassword1"))));
+ op = strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_builder_get_object(gladeFile,
+ "entryPDFOwnerPassword"))));
+ op1 = strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_builder_get_object(gladeFile,
+ "entryPDFOwnerPassword1"))));
+ up = strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_builder_get_object(gladeFile,
+ "entryPDFUserPassword"))));
+ up1 = strdup(gtk_entry_get_text(
+ GTK_ENTRY(gtk_builder_get_object(gladeFile,
+ "entryPDFUserPassword1"))));
if (op[0] == '\0') {
- gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(x,
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gladeFile,
"labelInfo")),
"Owner password must be at least 1 character long:");
free(op);
free(up);
- }
- else if (!strcmp(op, up)) {
- gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(x,
+ } else if (!strcmp(op, up)) {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gladeFile,
"labelInfo")),
"User and owner passwords must be different:");
free(op);
free(up);
- }
- else if (!strcmp(op, op1) && !strcmp(up, up1)) {
+ } else if (!strcmp(op, op1) && !strcmp(up, up1)) {
*owner_pass = op;
if (up[0] == '\0')
@@ -770,13 +744,13 @@ static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data)
free(data);
gtk_widget_destroy(GTK_WIDGET(wnd));
- g_object_unref(G_OBJECT(x));
+ g_object_unref(G_OBJECT(gladeFile));
save_pdf(path);
+
free(path);
- }
- else {
- gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(x,
+ } else {
+ gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(gladeFile,
"labelInfo")), "Passwords not confirmed:");
free(op);
free(up);
@@ -789,18 +763,60 @@ static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data)
static void nsgtk_PDF_no_pass(GtkButton *w, gpointer data)
{
GtkWindow *wnd = ((void **)data)[2];
- GladeXML *x = ((void **)data)[3];
+ GtkBuilder *gladeFile = ((void **)data)[3];
char *path = ((void **)data)[4];
free(data);
gtk_widget_destroy(GTK_WIDGET(wnd));
- g_object_unref(G_OBJECT(x));
+ g_object_unref(G_OBJECT(gladeFile));
save_pdf(path);
+
free(path);
}
-#endif
+
+static void nsgtk_pdf_password(char **owner_pass, char **user_pass, char *path)
+{
+ GtkButton *ok, *no;
+ GtkWindow *wnd;
+ void **data;
+ GtkBuilder *gladeFile;
+ GError* error = NULL;
+
+ gladeFile = gtk_builder_new();
+ if (!gtk_builder_add_from_file(gladeFile,
+ glade_file_location->password,
+ &error)) {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ wnd = GTK_WINDOW(gtk_builder_get_object(gladeFile, "wndPDFPassword"));
+
+ data = malloc(5 * sizeof(void *));
+
+ *owner_pass = NULL;
+ *user_pass = NULL;
+
+ data[0] = owner_pass;
+ data[1] = user_pass;
+ data[2] = wnd;
+ data[3] = gladeFile;
+ data[4] = path;
+
+ ok = GTK_BUTTON(gtk_builder_get_object(gladeFile, "buttonPDFSetPassword"));
+ no = GTK_BUTTON(gtk_builder_get_object(gladeFile, "buttonPDFNoPassword"));
+
+ g_signal_connect(G_OBJECT(ok), "clicked",
+ G_CALLBACK(nsgtk_PDF_set_pass), (gpointer)data);
+ g_signal_connect(G_OBJECT(no), "clicked",
+ G_CALLBACK(nsgtk_PDF_no_pass), (gpointer)data);
+
+ gtk_widget_show(GTK_WIDGET(wnd));
+}
+
uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
{
@@ -1194,6 +1210,7 @@ static struct gui_browser_table nsgtk_browser_table = {
.launch_url = gui_launch_url,
.cert_verify = gui_cert_verify,
.login = gui_401login_open,
+ .pdf_password = nsgtk_pdf_password,
};
/**
diff --git a/riscos/Makefile.target b/riscos/Makefile.target
index 46ca341..a52c03f 100644
--- a/riscos/Makefile.target
+++ b/riscos/Makefile.target
@@ -92,7 +92,7 @@ TPL_RISCOS := $(addprefix riscos/templates/,$(TPL_RISCOS))
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
# are not yet available
-SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_PDF) $(S_RISCOS)
+SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_RISCOS)
EXETARGET := !NetSurf/!RunImage$(EXEEXT)
!NetSurf/!Run$(RUNEXT): riscos/scripts/Run $(EXETARGET)
diff --git a/riscos/gui.c b/riscos/gui.c
index ade22cb..198fd23 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -2152,13 +2152,6 @@ bool ro_gui_prequit(void)
}
-void PDF_Password(char **owner_pass, char **user_pass, char *path)
-{
- /** @todo this waits to be written, until then no PDF encryption */
- *owner_pass = NULL;
-}
-
-
/**
* Generate a riscos path from one or more component elemnts.
*
diff --git a/utils/utils.h b/utils/utils.h
index b908432..00d1501 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -258,6 +258,5 @@ int dir_sort_alpha(const struct dirent **d1, const struct dirent **d2);
/* Platform specific functions */
void warn_user(const char *warning, const char *detail);
-void PDF_Password(char **owner_pass, char **user_pass, char *path);
#endif
--
NetSurf Browser
8 years, 3 months
netsurf: branch master updated. release/3.2-264-g29dfdd4
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/29dfdd459dc4f835bc4dd...
...commit http://git.netsurf-browser.org/netsurf.git/commit/29dfdd459dc4f835bc4dda5...
...tree http://git.netsurf-browser.org/netsurf.git/tree/29dfdd459dc4f835bc4dda5d6...
The branch, master has been updated
via 29dfdd459dc4f835bc4dda5d67714b4aaa2c897a (commit)
from bad77803787be27e33fd3f2422b578f1582e7eb4 (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=29dfdd459dc4f835bc4...
commit 29dfdd459dc4f835bc4dda5d67714b4aaa2c897a
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Move scroller check into update_extent, where it makes more sense
diff --git a/amiga/gui.c b/amiga/gui.c
index 75d09da..9ee209e 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -4441,7 +4441,6 @@ static void amiga_window_reformat(struct gui_window *gw)
if (gw != NULL) {
GetAttr(SPACE_AreaBox, (Object *)gw->shared->objects[GID_BROWSER], (ULONG *)&bbox);
browser_window_reformat(gw->shared->bw, false, bbox->Width, bbox->Height);
- ami_gui_scroller_update(gw->shared);
gw->shared->redraw_scroll = false;
}
}
@@ -4731,6 +4730,8 @@ static void gui_window_update_extent(struct gui_window *g)
TAG_DONE);
}
}
+
+ ami_gui_scroller_update(g->shared);
g->shared->new_content = true;
}
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index 75d09da..9ee209e 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -4441,7 +4441,6 @@ static void amiga_window_reformat(struct gui_window *gw)
if (gw != NULL) {
GetAttr(SPACE_AreaBox, (Object *)gw->shared->objects[GID_BROWSER], (ULONG *)&bbox);
browser_window_reformat(gw->shared->bw, false, bbox->Width, bbox->Height);
- ami_gui_scroller_update(gw->shared);
gw->shared->redraw_scroll = false;
}
}
@@ -4731,6 +4730,8 @@ static void gui_window_update_extent(struct gui_window *g)
TAG_DONE);
}
}
+
+ ami_gui_scroller_update(g->shared);
g->shared->new_content = true;
}
--
NetSurf Browser
8 years, 3 months
netsurf: branch master updated. release/3.2-263-gbad7780
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/bad77803787be27e33fd3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/bad77803787be27e33fd3f2...
...tree http://git.netsurf-browser.org/netsurf.git/tree/bad77803787be27e33fd3f242...
The branch, master has been updated
via bad77803787be27e33fd3f2422b578f1582e7eb4 (commit)
from 784d893eb74a59eec212e3d61003b9eea53d5706 (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=bad77803787be27e33f...
commit bad77803787be27e33fd3f2422b578f1582e7eb4
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Check scroller requirements as part of the reformat.
diff --git a/amiga/gui.c b/amiga/gui.c
index 0cb8174..75d09da 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1518,7 +1518,7 @@ static bool ami_gui_vscroll_remove(struct gui_window_2 *gwin)
*
* \param gwin "Shared" GUI window to check the state of
*/
-static void ami_gui_vscroll_update(struct gui_window_2 *gwin)
+static void ami_gui_scroller_update(struct gui_window_2 *gwin)
{
int h = 1, w = 1, wh = 0, ww = 0;
bool rethinkv = false;
@@ -1528,8 +1528,6 @@ static void ami_gui_vscroll_update(struct gui_window_2 *gwin)
browser_window_get_scrollbar_type(gwin->bw, &hscroll, &vscroll);
- /* We only bother with vscroll, as the hscroller is embedded in the
- bottom window border with the status bar, so toggling it is pointless */
if(browser_window_is_frameset(gwin->bw) == true) {
rethinkv = ami_gui_vscroll_remove(gwin);
rethinkh = ami_gui_hscroll_remove(gwin);
@@ -2366,7 +2364,6 @@ static void ami_handle_msg(void)
struct browser_window *bw = NULL;
case AMINS_WINDOW:
- ami_gui_vscroll_update(gwin);
ami_set_border_gadget_size(gwin);
ami_throbber_redraw_schedule(0, gwin->bw->window);
@@ -2827,7 +2824,7 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw)
browser_window_refresh_url_bar(gwin->bw);
ami_gui_update_hotlist_button(gwin);
- ami_gui_vscroll_update(gwin);
+ ami_gui_scroller_update(gwin);
ami_throbber_redraw_schedule(0, gwin->bw->window);
}
}
@@ -4444,7 +4441,7 @@ static void amiga_window_reformat(struct gui_window *gw)
if (gw != NULL) {
GetAttr(SPACE_AreaBox, (Object *)gw->shared->objects[GID_BROWSER], (ULONG *)&bbox);
browser_window_reformat(gw->shared->bw, false, bbox->Width, bbox->Height);
-
+ ami_gui_scroller_update(gw->shared);
gw->shared->redraw_scroll = false;
}
}
@@ -4931,7 +4928,7 @@ static void gui_window_new_content(struct gui_window *g)
ami_plot_release_pens(&g->shared->shared_pens);
ami_menu_update_disabled(g, c);
ami_gui_update_hotlist_button(g->shared);
- ami_gui_vscroll_update(g->shared);
+ ami_gui_scroller_update(g->shared);
}
static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index 0cb8174..75d09da 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -1518,7 +1518,7 @@ static bool ami_gui_vscroll_remove(struct gui_window_2 *gwin)
*
* \param gwin "Shared" GUI window to check the state of
*/
-static void ami_gui_vscroll_update(struct gui_window_2 *gwin)
+static void ami_gui_scroller_update(struct gui_window_2 *gwin)
{
int h = 1, w = 1, wh = 0, ww = 0;
bool rethinkv = false;
@@ -1528,8 +1528,6 @@ static void ami_gui_vscroll_update(struct gui_window_2 *gwin)
browser_window_get_scrollbar_type(gwin->bw, &hscroll, &vscroll);
- /* We only bother with vscroll, as the hscroller is embedded in the
- bottom window border with the status bar, so toggling it is pointless */
if(browser_window_is_frameset(gwin->bw) == true) {
rethinkv = ami_gui_vscroll_remove(gwin);
rethinkh = ami_gui_hscroll_remove(gwin);
@@ -2366,7 +2364,6 @@ static void ami_handle_msg(void)
struct browser_window *bw = NULL;
case AMINS_WINDOW:
- ami_gui_vscroll_update(gwin);
ami_set_border_gadget_size(gwin);
ami_throbber_redraw_schedule(0, gwin->bw->window);
@@ -2827,7 +2824,7 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw)
browser_window_refresh_url_bar(gwin->bw);
ami_gui_update_hotlist_button(gwin);
- ami_gui_vscroll_update(gwin);
+ ami_gui_scroller_update(gwin);
ami_throbber_redraw_schedule(0, gwin->bw->window);
}
}
@@ -4444,7 +4441,7 @@ static void amiga_window_reformat(struct gui_window *gw)
if (gw != NULL) {
GetAttr(SPACE_AreaBox, (Object *)gw->shared->objects[GID_BROWSER], (ULONG *)&bbox);
browser_window_reformat(gw->shared->bw, false, bbox->Width, bbox->Height);
-
+ ami_gui_scroller_update(gw->shared);
gw->shared->redraw_scroll = false;
}
}
@@ -4931,7 +4928,7 @@ static void gui_window_new_content(struct gui_window *g)
ami_plot_release_pens(&g->shared->shared_pens);
ami_menu_update_disabled(g, c);
ami_gui_update_hotlist_button(g->shared);
- ami_gui_vscroll_update(g->shared);
+ ami_gui_scroller_update(g->shared);
}
static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
--
NetSurf Browser
8 years, 3 months