netsurf: branch stevef/menus updated. release/3.0-1188-g3bb679c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3bb679c4a717e5a83408e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3bb679c4a717e5a83408e4c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3bb679c4a717e5a83408e4ca3...
The branch, stevef/menus has been updated
via 3bb679c4a717e5a83408e4ca33ef74c87e5da96a (commit)
via 101877442b1eaa79a28f4bb44b810c08bd1b34bc (commit)
via f0f05d691ba748314e57da754518dfbad6a7a339 (commit)
via fb072686c1b52f9f50ccff7241eff1e85a2dd97b (commit)
via 5324cd9abdf34c6568c7051a97c33a8934fcd89b (commit)
via 4575698f0f8b570f3c32e05cd3cbeb2d4f8ff237 (commit)
via a741ceadb89d09d7604a411ed04c0d92928ce814 (commit)
via b91c28b8d1ecf1ace615ff12e11adadf4f330b9a (commit)
via 88a99d9722f6c61cf8a338002d7a38622a1168ef (commit)
via 527bc23bdba33f1db6194c5d95f41f8a6b603bd5 (commit)
via 979b59887f6e868908519640fc795db0070371f7 (commit)
via a9fb42e71bc55ad4b498beaf2202c09cc37c5056 (commit)
via 442d1cb3cffe60253ab1481c0168d1708644fc97 (commit)
via 3445483e7838719d3feb0a6daf0fa9290b0cfb3f (commit)
via 9c60417f73868e2cd8e0db951020110ee8c295fc (commit)
via 0adbfe125e288c59588be87f7cd8493b0c8c0351 (commit)
via 97c12b975c163aa878736fe66d1968f0dc5af7eb (commit)
via b16cfd2d6edf20a31613f421582f528a93c40e41 (commit)
via 7738584b3411fa0941579831deae388139eb7a5a (commit)
via 119b8af2db392c85eb07d0aefbadeda62f1b1cc9 (commit)
via 7bcefbf72dee4cb60fa51ffc9eb4e0ab26ddab75 (commit)
via ed1ea8e6eec45123b27d6f74b9192271526f2f02 (commit)
via 6f9a93e33295fc3185ca27f2ce9a4f6fd4f4de69 (commit)
via c86d1cfba695867bf896afe463abfe61af7ca162 (commit)
via 4d4d74c8cd1a77a46cbe0816cf6150f8b4980947 (commit)
via fec9f916b640b8ffc18b7ff9f9d04fd742b32ad1 (commit)
via a67c49eacfcdfc65aadd457df9c63232eb806624 (commit)
via f09011cb0e001aca2c5e7e73927e33e96d6f4267 (commit)
via 5254f872aac16b1a810a52a1ca2d2f6375744d1a (commit)
via f7c756192e1d088e2b8198e4512e31b4841a12b8 (commit)
via 5e8c2b00f01937f82305c12fcac3943e778c92da (commit)
via ba1aeccc05fd45617cf12902e4fdd04cd4bd7a86 (commit)
via f104f99809939048890bc2e39d403a339f2976b2 (commit)
via 51cc2cfe38931f6e200a99df3a28ab2b267223ff (commit)
via e1045bf64b26e09a0b9e633d243613f6da5613bd (commit)
via 2059787a24b8bb9d1d94c028c2f4feb7745619d4 (commit)
via 5e1c19128b5ef32ca1798a9544aaf9b6e382e404 (commit)
via ca74c70cc724c8fdeb46aa2eafec354e5adcff4c (commit)
via fd139ba8f406595a538ce8f8768eecc3d12b9ca3 (commit)
via c44bbcdc08b880bead0a196826d64031de36bee6 (commit)
via 7a3d3437663ea6669811910f7671600d861a2f1f (commit)
via 9da93c23a4b6dd123f055de8507c0459e82189ce (commit)
via 0397a7cab12016c6ea452019248e6017b6f646af (commit)
via da0b969f2514df4e6d4febf78c54c8b4c34dcb9a (commit)
via 25ce52ee64126caac0550d7086abb79b10e1a951 (commit)
via 8d883978c6d31915f63325b1bc27659ca140bf43 (commit)
via 20b3c408167b2093f1d2d68792550ff6ec44aabd (commit)
via 5c6a0eda3b42d98f7f7aeab94b96021128c298c4 (commit)
via 87f6314dabdc2067a19e01f8b29f9ecc38ed825b (commit)
via fb9b171e325488dc9792ee0f3062f15d8ec597ee (commit)
via 6a558b293298fe1267c53ee4f6c42f8889ef581b (commit)
via 821adc1b0edf966b6f81d752d74313d20e69c34c (commit)
via 60973fe5d1da545b0c993df1261e6b649c7b4dd9 (commit)
via ff8c37a6eeed79eafb8693fa80ece4c05eb46527 (commit)
via 4591b65ad9003797e6af477ed84cc2279a661b91 (commit)
via 69b61198f28a510eba34eca747e8d5eacfee4a0a (commit)
via 6bcd221d0d3946abfddf40a7c73a8d9619b0ff78 (commit)
via a2d4c8ee0fd9a8036dcdbdd642a36aa92ddba409 (commit)
via 32a522241f94970df9681517edc999d7b6d6675a (commit)
via 71cb70065e6819c26f101ff11e34c10383487b30 (commit)
via b99357616cebe750e523f123701f284d7ac0037f (commit)
via 143f28572af65aaabd084cc7b46dbfc5ab766b06 (commit)
via b928095652a00bf579d8d724262b856f82a57a0f (commit)
via c47a497bca10e2fce6fd2f458e9b5b9f6992062d (commit)
via 1511a742031342944d7aae38b35854fe62eaaf91 (commit)
via 5e0efcbd6c8792b0b9287f2b85c9ca63e55188e7 (commit)
via d9002dc71c3e08c3222cf3e64f2d09c4ec9d87de (commit)
via 640fbe5f5f1f6a6990246fbe08e2136628f140a6 (commit)
via 518e4484da6cdacc6a05f8e3afa62c0778878f96 (commit)
via 6867726326c88ce6538d0b0b81fce32d91596210 (commit)
via 3efe56d7ef091d0e75bbcfbce6fc1c543057bb09 (commit)
via a38a63a37ef8bdc62661d398fb485296c0bed470 (commit)
via a55957b1c975e96a60d96d9a70c3b64bf02f96fd (commit)
via 1228cd757669b46f75d9a54b9c7ffdbafac276ef (commit)
via 4a59399cd799a23149b953e9bb38c88275b29936 (commit)
via 03cb9a302a6066b6c89130fd824ba0be37116922 (commit)
via f2ef17a1b5b268291c0d9c100beca3134923d4ed (commit)
via df5e5fb4875671181070f38cf15b5696d091a924 (commit)
via ef6b20fe83895279e5e78b336f357ff657f46407 (commit)
via 42be1ffa7b2975fc264bfc9187a8d2da2d1dccb9 (commit)
via 2f66b6f6e296edf6e05a78d44a686d195c5a36fe (commit)
via 49bed056dd016ed74a7ed5cc988e9bdf17738c7f (commit)
via 76b5378996c681ad1311e57a4c7c49dd465e634b (commit)
via 5087fde086ab45981547582355ba06ae2c73c286 (commit)
via 80fcfa7bce759f90d1e10af5e5c6d9da1a13a9ac (commit)
via f69f7b5ee77c1e39fc32cd65e923511cb80f67b0 (commit)
via cbf423d4c60ff145246851dd36315833a8581c5b (commit)
via 55a96a7eeeaa44bb1dece9e5e09ae6127c3ece48 (commit)
via c384c5dd3e6ec53bd8aabe62bfcf39b9aa2ef7e1 (commit)
via 7fa641616b4c1c2ef8b209618d4b158d45e370c4 (commit)
via e975b355f54212adfcd6b3a8e32fede621098a31 (commit)
via a6fd3284050532f43261ddce8972e03e6669bd94 (commit)
via 709665e5c050085fd5e250ae0534ea057df2ffda (commit)
via 802fb8a77ee26249f8fa8d43249eb59a5bec43ab (commit)
via 36e0715dfb5411a9719f3ca4a032a6d75c267c36 (commit)
via e1b5332192f85945e86ec5f581d4914b0c9601b0 (commit)
via 4aa59f538276ce9413121d6d2e6eeed8ae5c0900 (commit)
via a23b1f34d352fc216b2677a7d3d06baa8bf57595 (commit)
via af014bce99d4990f1a0cbb1a779127de0f716a90 (commit)
via 9720c024832c96d917de933b95c87cf2e4f867bf (commit)
via 8df71860d729ee023e6a8697d87390ea495da763 (commit)
via 7f2c9777887544c5bb66f86b866824e6338596c8 (commit)
via 3d2e416ea94167a5c49ff89e02cf385c73207dd3 (commit)
via 56b2770722d3001d57368a9f267aa5ce8426ecac (commit)
via 4259c04fe64ecc3d1366f30aee2d43b9dcdb9c2b (commit)
via bd5102676a54e55cbe5cc90b2ade0e1334c2e3e0 (commit)
via ce41b8d43181edde71240e48b4c44a1c8c021ef0 (commit)
via ea79e85fcd109a5bf5f222cece8435305fc8626a (commit)
via 987218e144f95e1917f1eb8956fed8a712ec3a70 (commit)
via 3d7cd77982d79ff798a92ebe7f3c0b2a52042cdf (commit)
via 2cd2e5b0541e7067c908e88f446b7cc56095253b (commit)
via 2c727e03d0cd669c069d767105a9927094037b76 (commit)
via 6ccf13839b86f9af6c67c252d040741d13ed9c01 (commit)
via 5e495f0ab973d6fb7b5b209b6cd8a8684358bf46 (commit)
via 616335c9ca63fcdc625e02469c5adbdc14535ca2 (commit)
via 11b152c915820e6112c4aa0f97e561e56913a726 (commit)
via efc4a837372ed939e05a0df23cf785a93a3a6d28 (commit)
via 5f517cc714ccfcc639c52b47108e9ae27759a7c0 (commit)
via 8deb9ec25c6146803e3d74c1b2e00425159fd17e (commit)
via ec7a02e550b1c83abecc0f9103ea86e1cfb989ea (commit)
via a505ea49dfd42f7196f64bf8bc4cb957ac1a9b35 (commit)
via 22d15380f40b82f7d1660648ec13af094643a3ca (commit)
via 022a303d6043ed5843458c696c2d035e7f4b66fd (commit)
via e33737ef235dd321e51aa543c5136f1b6f741e55 (commit)
via 3697f543d6573ecf41108b1cf036a64b046cc8be (commit)
via 43c3caa4699e6658ea0c23295e27efdeb08d87a7 (commit)
via 72b5bc85f27478ce63679df5543b6eef363189e3 (commit)
via 41d70c741f31e8c04c774fb5b2b90d284e4d8668 (commit)
via 7a81fe9165bfde355c462514c0f2a74a811aa5da (commit)
via 7794f3fb1412c1921f57a519379dcb77a3f5cee7 (commit)
via 8bc3a8032008a255e72e4c4dc88d391b7073814c (commit)
via 2cc6b04a4936f8fbc5b5216aa66bad69b4f22438 (commit)
via cf84e557fa22ed22671e7d3dc5af8792d115a551 (commit)
via 41d7084356e0dd1616d771b260ef8c88319cc7f2 (commit)
via f5f7dc99319179dcce9e13b2b13cf7da7eb643ae (commit)
via 665f724a364b0579ee96aa10f7aed1dc25e2f524 (commit)
via cd9268761cb9929e397a0f0df135f3ad550ee7a5 (commit)
via bf3ed6a67f85928dcfb82a5ea706e3ffed8357a2 (commit)
via b937ed1d8d0ec0bf6448a840f4d658452d359db0 (commit)
via 823aad5ddf3aaea53dda9eec8572b75d16c80a70 (commit)
via 8be1ebafd6c355dc5a8032776de18e9f47343ab6 (commit)
via 94f10fa0c0953c3cc9485390867987a27855568c (commit)
via 17ecb818add2bf49c933681ca5049c6b7ef90597 (commit)
via 25bc5b2b8c034b99b0dc97882776dad530e4f11f (commit)
via fba58ad4b0313c9fc2f96d2e35c57d55fac8b3bf (commit)
via 7b380d09824c0753516bd0a40afd421eb0e86c33 (commit)
via dc33cb1418c5e573d4f4325ae15cfab9eec0a140 (commit)
via 8d9e8791d9f9bb693b219af8232085abccbeeda0 (commit)
via 59fe9e09ac1dca268fed7dc04eb592fc49dbb2e6 (commit)
via 17231603db0a5cc64fc1575f8cd79eb10c05fc94 (commit)
via abb37ba148464221e7f9beb105f8abe0e1532aa0 (commit)
via 59eaaf30158f6241c1dc1cf116e8fcff669176d3 (commit)
via 3455d669219834075fd09b8be2c81c2fe31b126e (commit)
via 6799f68bccc7855336bf80bdd756290e599ff225 (commit)
via 6a7ca8b2a8709d38426897f739ef699a147defc0 (commit)
via 9da892c57976e24900731ff79f0420af9406cc1a (commit)
via 4fab874d4f93ad0810c5ac79502f9aced2d7ab29 (commit)
via dba69de613e519306ad5122bd2e16e372193bb3d (commit)
via 0b50b8f3f79c41a1c1d2891819ad7c43471f2957 (commit)
via 236e135d6309413ce97c453e23242dae04bc73f4 (commit)
via 7798dae86a1d85dc020de1e04e37f8ff2713094c (commit)
via 886a3106db6d6a60d2d706d2caad3e883dd70b14 (commit)
via 427f127fa9d42cdf9005d06813c580d18d5e0d6a (commit)
via 00bdf39dc21cd51216ef362529dca12f98cd1cf2 (commit)
via 8bb0e87b1a8fc9872762f5caa856f64c4e9f1cdd (commit)
via 72879e429b067c30c20d9e0d1b4d6ef1ef29b441 (commit)
via 1f62b5a980020b0e5df0e68cb476083ba2dc1fe5 (commit)
via 356461244e9a31d9c22fab358cdf95cb3f22364f (commit)
via 10bf1e2e852035111f7ea9d9471bf2db24069399 (commit)
via f99b17ae89ee27ff746346c17c03b1ee5ab3076b (commit)
via aaecf9e1af9e8cf22324cfbbd4eb13fb64ac3975 (commit)
via d5a971c281b110d8fa481fa86ccd7af10d2d3cf0 (commit)
via e353973518839245edfb9c00d2fb9c6ef14032e8 (commit)
via db33103fa3d0e7b4623dc321792963969e15e683 (commit)
from 0114cc825d8a23ff99ce3a667aebc0ed21b0339f (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=3bb679c4a717e5a8340...
commit 3bb679c4a717e5a83408e4ca33ef74c87e5da96a
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Allow mouse tracking events to terminate without a PointerLeaving event being received.
This change should handle the situation where a PointerEntering event is received without a corresponding PointerLeaving event, which appears to be caused by some third-party OS addons. This could cause unexpected consequences, so all such terminations are currently logged.
diff --git a/riscos/mouse.c b/riscos/mouse.c
index a20965e..e934c1c 100644
--- a/riscos/mouse.c
+++ b/riscos/mouse.c
@@ -163,9 +163,11 @@ void ro_mouse_drag_end(wimp_dragged *dragged)
* Start tracking the mouse in a window, providing a function to be called on
* null polls and optionally one to be called when it leaves the window.
*
- * \param *drag_end Callback for when the pointer leaves the window, or
- * NULL for none.
- * \param *drag_track Callback for mouse tracking while the pointer remains
+ * \param *poll_end Callback for when the pointer leaves the window, or
+ * NULL for none. Claimants can receive *leaving==NULL if
+ * a new tracker is started before a PointerLeaving event
+ * is received.
+ * \param *poll_track Callback for mouse tracking while the pointer remains
* in the window, or NULL for none.
* \param *data Data to be passed to the callback functions, or NULL.
*/
@@ -175,12 +177,31 @@ void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
void *data)
{
/* It should never be possible for the mouse to be in two windows
- * at the same time!
+ * at the same time! However, some third-party extensions to RISC OS
+ * appear to make this possible (MouseAxess being one), so in the
+ * event that there's still a claimant we tidy them up first and then
+ * log the fact in case there are any unexpected consequences.
+ *
+ * NB: The Poll End callback will get called with *leaving == NULL in
+ * this situation, as there's no PointerLeaving event to pass on.
*/
- assert(ro_mouse_poll_end_callback == NULL &&
- ro_mouse_poll_track_callback == NULL &&
- ro_mouse_poll_data == NULL);
+ if (ro_mouse_poll_end_callback != NULL ||
+ ro_mouse_poll_track_callback != NULL ||
+ ro_mouse_poll_data != NULL) {
+ if (ro_mouse_poll_end_callback != NULL &&
+ ro_mouse_ignore_leaving_event == false)
+ ro_mouse_poll_end_callback(NULL, ro_mouse_poll_data);
+
+ LOG(("Unexpected mouse track termination."));
+
+ ro_mouse_ignore_leaving_event = false;
+ ro_mouse_poll_end_callback = NULL;
+ ro_mouse_poll_track_callback = NULL;
+ ro_mouse_poll_data = NULL;
+ }
+
+ /* Now record details of the new claimant. */
ro_mouse_poll_end_callback = poll_end;
ro_mouse_poll_track_callback = poll_track;
diff --git a/riscos/mouse.h b/riscos/mouse.h
index bcb3b50..8a7405a 100644
--- a/riscos/mouse.h
+++ b/riscos/mouse.h
@@ -65,9 +65,11 @@ void ro_mouse_drag_end(wimp_dragged *dragged);
* Start tracking the mouse in a window, providing a function to be called on
* null polls and optionally one to be called when it leaves the window.
*
- * \param *drag_end Callback for when the pointer leaves the window, or
- * NULL for none.
- * \param *drag_track Callback for mouse tracking while the pointer remains
+ * \param *poll_end Callback for when the pointer leaves the window, or
+ * NULL for none. Claimants can receive *leaving==NULL if
+ * a new tracker is started before a PointerLeaving event
+ * is received.
+ * \param *poll_track Callback for mouse tracking while the pointer remains
* in the window, or NULL for none.
* \param *data Data to be passed to the callback functions, or NULL.
*/
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=101877442b1eaa79a28...
commit 101877442b1eaa79a28f4bb44b810c08bd1b34bc
Merge: 72879e4 f0f05d6
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Merge branch 'master' of git://git.netsurf-browser.org/netsurf into stevef/menus
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=72879e429b067c30c20...
commit 72879e429b067c30c20d9e0d1b4d6ef1ef29b441
Merge: 10bf1e2 1f62b5a
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Merge branch 'master' of git://git.netsurf-browser.org/netsurf into stevef/menus
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=10bf1e2e852035111f7...
commit 10bf1e2e852035111f7ea9d9471bf2db24069399
Merge: 0114cc8 f99b17a
Author: Steve Fryatt <stevef(a)netsurf-browser.org>
Commit: Steve Fryatt <stevef(a)netsurf-browser.org>
Merge branch 'master' of git://git.netsurf-browser.org/netsurf into stevef/menus
-----------------------------------------------------------------------
Summary of changes:
Docs/BUILDING-AmigaOS | 56 +-
Docs/BUILDING-Framebuffer | 221 ++++--
Docs/BUILDING-GTK | 175 ++++--
Docs/BUILDING-Monkey | 104 ---
Docs/Doxyfile | 13 +-
Docs/QUICK-START | 72 ++
Docs/env.sh | 111 +++-
amiga/Makefile.defaults | 76 ++--
amiga/Makefile.target | 2 +-
amiga/agclass/amigaguide_class.c | 167 +++--
amiga/agclass/amigaguide_class.h | 7 +-
amiga/arexx.c | 20 +-
amiga/clipboard.c | 25 +-
amiga/context_menu.c | 56 +-
amiga/dist/NetSurf.guide | 5 +
amiga/download.c | 7 +-
amiga/dt_anim.c | 2 +-
amiga/file.c | 4 +-
amiga/font.c | 6 +-
amiga/gui.c | 403 +++++-------
amiga/gui.h | 1 +
amiga/gui_options.c | 16 +-
amiga/gui_options.h | 1 +
amiga/help.c | 21 +-
amiga/help.h | 6 +-
amiga/history_local.c | 18 +-
amiga/menu.c | 19 +-
amiga/print.c | 7 +-
amiga/schedule.c | 165 +++---
amiga/schedule.h | 38 +-
amiga/search.c | 24 +-
amiga/search.h | 2 +
amiga/theme.c | 8 +-
amiga/tree.c | 9 +-
amiga/utf8.c | 65 +-
amiga/utf8.h | 7 +
atari/Makefile.defaults | 77 ++--
atari/about.c | 3 +-
atari/certview.c | 1 +
atari/ctxmenu.c | 16 +-
atari/deskmenu.c | 16 +-
atari/download.c | 1 -
atari/encoding.c | 10 +
atari/encoding.h | 47 +-
atari/gui.c | 35 +-
atari/hotlist.h | 7 +
atari/plot/font_vdi.c | 2 +
atari/rootwin.c | 9 +-
atari/rootwin.h | 2 +-
atari/schedule.c | 126 ++--
atari/schedule.h | 25 +-
atari/search.c | 19 +-
atari/search.h | 3 +
atari/statusbar.c | 1 -
atari/toolbar.c | 16 +-
beos/Makefile.defaults | 42 +-
beos/about.cpp | 1 +
beos/download.cpp | 3 +
beos/gui.cpp | 35 +-
beos/gui.h | 3 -
beos/scaffolding.cpp | 42 +-
beos/scaffolding.h | 1 -
beos/schedule.cpp | 27 +-
beos/schedule.h | 7 +-
beos/window.cpp | 9 +-
cocoa/BookmarksController.m | 8 +-
cocoa/BrowserView.m | 18 +-
cocoa/BrowserViewController.m | 31 +-
cocoa/BrowserWindowController.m | 6 +-
cocoa/FormSelectMenu.m | 4 +-
cocoa/HistoryView.m | 17 +-
cocoa/Makefile.defaults | 64 +-
cocoa/Makefile.target | 75 +--
cocoa/NetSurfAppDelegate.m | 13 +-
cocoa/NetsurfApp.m | 6 +-
cocoa/PreferencesWindowController.m | 1 +
cocoa/SearchWindowController.h | 2 +
cocoa/SearchWindowController.m | 10 +-
cocoa/apple_image.m | 11 +-
cocoa/fetch.m | 1 +
cocoa/gui.m | 16 +-
cocoa/{selection.h => schedule.h} | 2 +-
cocoa/schedule.m | 22 +-
cocoa/utf8.m | 40 --
content/content.c | 15 +-
content/content.h | 5 +-
content/content_protected.h | 6 +-
content/fetchers/curl.c | 51 ++-
content/fetchers/resource.c | 1 -
content/hlcache.c | 8 +-
content/llcache.c | 418 ++++++------
content/mimesniff.c | 6 +-
content/urldb.c | 19 +-
css/css.c | 7 +-
desktop/Makefile | 2 +-
desktop/browser.c | 362 +++++++----
desktop/browser.h | 150 +++--
desktop/{local_history.c => browser_history.c} | 847 +++++++++++++-----------
desktop/browser_history.h | 141 ++++
desktop/browser_private.h | 13 +
desktop/download.c | 2 +-
desktop/frames.c | 14 +-
desktop/global_history.c | 17 +-
desktop/gui.h | 186 +++++-
desktop/gui_factory.c | 156 ++++-
desktop/hotlist.c | 17 +-
desktop/local_history.h | 131 ----
desktop/netsurf.c | 1 -
desktop/netsurf.h | 1 -
desktop/save_text.c | 12 +-
desktop/search.c | 64 +--
desktop/search.h | 56 +--
desktop/searchweb.c | 6 +-
desktop/selection.c | 1 -
desktop/sslcert_viewer.c | 2 +-
desktop/textarea.c | 47 +-
desktop/textinput.c | 1 -
desktop/tree.h | 7 +-
desktop/treeview.c | 8 +-
framebuffer/Makefile.defaults | 84 ++--
framebuffer/clipboard.c | 5 +-
framebuffer/convert_image.c | 1 +
framebuffer/fetch.c | 5 +-
framebuffer/font.h | 2 +
framebuffer/font_freetype.c | 33 +-
framebuffer/font_internal.c | 19 +-
framebuffer/gui.c | 93 ++--
framebuffer/localhistory.c | 32 +-
framebuffer/schedule.c | 103 ++--
framebuffer/schedule.h | 20 +
gtk/Makefile.defaults | 42 +-
gtk/bitmap.c | 135 +++--
gtk/compat.h | 2 +
gtk/dialogs/about.c | 9 +-
gtk/dialogs/preferences.c | 14 +-
gtk/dialogs/source.c | 30 +-
gtk/download.c | 4 +-
gtk/fetch.c | 3 +
gtk/font_pango.c | 2 -
gtk/gui.c | 54 +--
gtk/scaffolding.c | 189 ++----
gtk/scaffolding.h | 14 +-
gtk/schedule.c | 23 +-
gtk/schedule.h | 3 +-
gtk/search.c | 144 ++---
gtk/search.h | 13 +-
gtk/selection.c | 16 +-
gtk/selection.h | 7 +-
gtk/theme.c | 13 +-
gtk/toolbar.c | 20 +-
gtk/treeview.c | 68 ++-
gtk/treeview.h | 12 -
gtk/window.c | 142 +++--
gtk/window.h | 2 -
image/gif.c | 17 +-
image/image_cache.c | 16 +-
javascript/jsapi/location.bnd | 7 +-
monkey/Makefile.defaults | 19 +-
monkey/browser.c | 15 +-
monkey/cert.c | 3 +-
monkey/download.c | 8 +-
monkey/main.c | 18 +-
monkey/schedule.c | 26 +-
monkey/schedule.h | 3 +-
monkey/utils.c | 18 -
render/box_construct.c | 22 +-
render/box_textarea.c | 17 +-
render/form.c | 34 +-
render/form.h | 11 +-
render/html.c | 76 ++-
render/html_css.c | 11 +-
render/html_interaction.c | 23 +-
render/html_internal.h | 4 +-
render/html_object.c | 22 +-
render/search.c | 68 +--
render/search.h | 3 +-
render/textplain.c | 9 +-
resources/FatMessages | 10 +-
riscos/Makefile.defaults | 41 +-
riscos/dialog.c | 3 +-
riscos/download.c | 52 +-
riscos/gui.c | 49 +-
riscos/gui.h | 26 +-
riscos/gui/progress_bar.c | 23 +-
riscos/gui/status_bar.c | 5 +-
riscos/gui/url_bar.c | 16 +-
riscos/help.c | 1 +
riscos/history.c | 25 +-
riscos/hotlist.c | 18 +-
riscos/iconbar.c | 9 +-
riscos/menus.c | 14 +-
riscos/mouse.c | 35 +-
riscos/mouse.h | 8 +-
riscos/query.c | 1 +
riscos/save.c | 16 +-
riscos/save.h | 2 +-
riscos/schedule.c | 88 ++--
riscos/search.c | 42 +-
riscos/textselection.c | 22 +-
riscos/textselection.h | 3 +-
riscos/toolbar.c | 4 +-
riscos/treeview.c | 9 +-
riscos/ucstables.c | 16 +-
riscos/ucstables.h | 5 +
riscos/uri.c | 3 +-
riscos/url_complete.c | 3 +-
riscos/url_protocol.c | 3 +-
riscos/wimp.c | 1 +
riscos/window.c | 234 +++-----
test/Makefile | 6 +-
test/nsurl.c | 38 +-
utils/corestrings.c | 12 +
utils/corestrings.h | 3 +
utils/errors.h | 2 +
utils/libdom.c | 56 +-
utils/log.c | 3 +-
utils/log.h | 5 +-
utils/nsurl.c | 102 ++-
utils/schedule.h | 32 -
utils/utf8.c | 5 +-
utils/utf8.h | 5 -
windows/Makefile.defaults | 26 +-
windows/download.c | 22 +-
windows/font.c | 11 +-
windows/gui.c | 34 +-
windows/gui.h | 1 +
windows/localhistory.c | 18 +-
windows/main.c | 4 +-
windows/schedule.c | 101 ++--
windows/schedule.h | 16 +-
230 files changed, 4743 insertions(+), 4006 deletions(-)
delete mode 100644 Docs/BUILDING-Monkey
create mode 100644 Docs/QUICK-START
mode change 100755 => 100644 amiga/agclass/amigaguide_class.c
copy cocoa/{selection.h => schedule.h} (91%)
delete mode 100644 cocoa/utf8.m
rename desktop/{local_history.c => browser_history.c} (67%)
create mode 100644 desktop/browser_history.h
delete mode 100644 desktop/local_history.h
delete mode 100644 utils/schedule.h
diff --git a/Docs/BUILDING-AmigaOS b/Docs/BUILDING-AmigaOS
index c15db57..3239e88 100644
--- a/Docs/BUILDING-AmigaOS
+++ b/Docs/BUILDING-AmigaOS
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------------
- Build Instructions for AmigaOS NetSurf 13 February 2010
+ Build Instructions for AmigaOS NetSurf 29 March 2014
--------------------------------------------------------------------------------
This document provides instructions for building the AmigaOS version of
@@ -59,19 +59,9 @@
To build and install these libraries, simply enter each of their directories
and run:
- 1> gmake install
+ 1> gmake PREFIX=/path/to/buildsystem
- | Note: We advise enabling iconv() support in libparserutils, which vastly
- | increases the number of supported character sets. To do this,
- | create a file called Makefile.config.override in the libparserutils
- | directory, containing the following lines:
- |
- | CFLAGS += -DWITH_ICONV_FILTER
- | LDFLAGS += -liconv
- |
- | This requires libiconv as iconv support in newlib.library is buggy.
- |
- | For more information, consult the libparserutils README file.
+ The path MUST be in UNIX format and point to directory containing "share".
| Note: Building libsvgtiny requires gperf, which is available from Aminet:
|
@@ -83,21 +73,23 @@
A version of libcurl built for newlib is available from Aminet
- http://www.aminet.net/package/dev/lib/libcurl
+ http://www.os4depot.net/share/development/library/misc/libcurl.lha
- There is a shared object version included with some OWB releases. To use
- this when compiling with Cairo support, a link must be made:
+ To use the shared object when compiling with Cairo support, a link must be made:
- 1> makelink sdk:local/newlib/lib/libcurl.so sobjs:libcurl-7.16.so soft
+ 1> makelink sdk:local/newlib/lib/libcurl.so sobjs:libcurl.so.8 soft
libpng
--------
NetSurf uses libPNG to display PNG files.
- It builds without any problems on OS4, or available from Aminet:
+ It builds without any problems on OS4, or available from OS4Depot:
- http://www.aminet.net/package/dev/lib/libpng_so
+ http://www.os4depot.net/share/development/library/graphics/libpng.lha
+
+ If building with Cairo, NetSurf MUST be linked against the version of
+ libpng.so included with OS4.
OpenSSL
@@ -107,11 +99,10 @@
http://www.os4depot.net/share/development/library/misc/libopenssl.lha
- There is a shared object version included with some OWB releases. To use
- this when compiling with Cairo support, a link must be made:
+ To use the shared object when compiling with Cairo support, a link must be made:
- 1> makelink sdk:local/newlib/lib/libssl.so sobjs:libssl-0.9.8.so soft
- 1> makelink sdk:local/newlib/lib/libcrypto.so sobjs:libssl-0.9.8.so soft
+ 1> makelink sdk:local/newlib/lib/libssl.so sobjs:libssl.so.1.0.0 soft
+ 1> makelink sdk:local/newlib/lib/libcrypto.so sobjs:libcrypto.so.1.0.0 soft
Libharu
@@ -141,19 +132,18 @@
http://www.aminet.net/package/comm/www/OpenURL-OS4
- General requirements
-----------------------
+ Spidermonkey
+--------------
- SDK:newlib/include/strings.h needs to be modified by adding the following:
+ Experimental Javascript support requires Spidermonkey. The patches to
+ build v1.7 are available from the NetSurf toolchains Git repository.
- extern int strcasecmp(const char *, const char *);
- extern int strncasecmp(const char *, const char *, size_t);
- amiga/version.c is generated by version.rexx using the SVN command. If
- the source has not been checked out from SVN, or is being cross-compiled,
- this file will need to be created by hand. See the end of version.rexx
- for the variables that are defined in the file.
+ General requirements
+----------------------
Please note that building with Cairo (option NETSURF_AMIGA_USE_CAIRO) will
link NetSurf against shared objects, and require the OS4.1 SDK to build and
- AmigaOS 4.1 to run.
+ AmigaOS 4.1 to run. There is no longer any advantage in building against
+ Cairo beyond anti-aliasing, and this option may be removed in the future.
+
diff --git a/Docs/BUILDING-Framebuffer b/Docs/BUILDING-Framebuffer
index 9cbd660..8e695c4 100644
--- a/Docs/BUILDING-Framebuffer
+++ b/Docs/BUILDING-Framebuffer
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------------
- Build Instructions for Framebuffer NetSurf 13 February 2010
+ Build Instructions for Framebuffer NetSurf 16 March 2014
--------------------------------------------------------------------------------
This document provides instructions for building the Framebuffer version of
@@ -7,8 +7,153 @@
Framebuffer NetSurf has been tested on Ubuntu and Debian.
+ Depending on the framebuffer frontend selected the build may need specific
+ libraries installed, e.g. the SDL port requires SDL1.2 or later
+
+ There are two ways to get NetSurf building. The QUICK-START (recommended),
+ and the manual build. Whichever you choose, you should read both the
+ "Fonts", and "Selecting a frontend and appropriate options" sections below.
+
+
+ Quick Start
+=============
+
+ See the QUICK-START document, which provides a simple environment with
+ which you can fetch, build and install NetSurf and its dependencies.
+
+ The QUICK-START is the recommended way to build NetSurf.
+
+
+ Manual building
+=================
+
+ If you can't follow the quick start instructions, you will have to build
+ NetSurf manually. The instructions for doing this are given below.
+
+
+ Obtaining the build dependencies
+----------------------------------
+
+ Many of NetSurf's dependencies are packaged on various operating systems.
+ The remainder must be installed manually. Currently, some of the libraries
+ developed as part of the NetSurf project have not had official releases.
+ Hopefully they will soon be released with downloadable tarballs and packaged
+ in common distros. For now, you'll have to make do with Git checkouts.
+
+ Package installation
+ --------------------
+
+ Debian-like OS:
+
+ $ apt-get install libcurl3-dev libpng-dev
+
+ Recent OS versions might need libcurl4-dev instead of libcurl3-dev but
+ note that when it has not been built with OpenSSL, the SSL_CTX is not
+ available and results that certification details won't be presented in case
+ they are invalid. But as this is currently unimplemented in the Framebuffer
+ flavour of NetSurf, this won't make a difference at all.
+
+ Fedora:
+
+ $ yum install curl-devel libpng-devel lcms-devel
+
+ Other:
+
+ You'll need to install the development resources for libcurl3 and libpng.
+
+
+ Preparing your workspace
+--------------------------
+
+ NetSurf has a number of libraries which must be built in-order and
+ installed into your workspace. Each library depends on a core build
+ system which NetSurf projects use. This build system relies on the
+ presence of things like pkg-config to find libraries and also certain
+ environment variables in order to work correctly.
+
+ Assuming you are preparing a workspace in /home/netsurf/workspace then
+ the following steps will set you up:
+
+ Make the workspace directory and change to it
+ ---------------------------------------------
+
+ $ mkdir -p ${HOME}/netsurf/workspace
+ $ cd ${HOME}/netsurf/workspace
+
+ Make the temporary install space
+ --------------------------------
+
+ $ mkdir inst
+
+ Make an environment script
+ --------------------------
+ $ cat > env.sh <<'EOF'
+ export PKG_CONFIG_PATH=${HOME}/netsurf/workspace/inst/lib/pkgconfig::
+ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HOME}/netsurf/workspace/inst/lib
+ export PREFIX=${HOME}/netsurf/workspace/inst
+ EOF
+
+ Change to workspace and source the environment
+ ----------------------------------------------
+
+ Whenever you wish to start development in a new shell, run the following:
+
+ $ cd ${HOME}/netsurf/workspace
+ $ source env.sh
+
+ From here on, any commands in this document assume you have sourced your
+ shell environment.
+
+
+ The NetSurf project's libraries
+---------------------------------
+
+ The NetSurf project has developed several libraries which are required by
+ the browser. These are:
+
+ BuildSystem -- Shared build system, needed to build the other libraries
+ LibParserUtils -- Parser building utility functions
+ LibWapcaplet -- String internment
+ Hubbub -- HTML5 compliant HTML parser
+ LibCSS -- CSS parser and selection engine
+ LibNSGIF -- GIF format image decoder
+ LibNSBMP -- BMP and ICO format image decoder
+ LibROSprite -- RISC OS Sprite format image decoder
+ LibNSFB -- Framebuffer abstraction
+
+ To fetch each of these libraries, run the appropriate commands from the
+ Docs/LIBRARIES file.
+
+ To build and install these libraries, simply enter each of their directories
+ and run:
+
+ $ make install
+
+ | Note: We advise enabling iconv() support in libparserutils, which vastly
+ | increases the number of supported character sets. To do this,
+ | create a file called Makefile.config.override in the libparserutils
+ | directory, containing the following line:
+ |
+ | CFLAGS += -DWITH_ICONV_FILTER
+ |
+ | For more information, consult the libparserutils README file.
+
+
+ Getting the NetSurf source
+----------------------------
+
+ From your workspace directory, run the following command to get the NetSurf
+ source:
+
+ $ git clone git://git.netsurf-browser.org/netsurf.git
+
+ And change to the 'netsurf' directory:
+
+ $ cd netsurf
+
+
Building and executing NetSurf
-================================
+--------------------------------
First of all, you should examine the contents of Makefile.defaults
and enable and disable relevant features as you see fit in a
@@ -203,75 +348,3 @@ Index: framebuffer/font_freetype.c
The documentation of libnsfb should be consulted for futher
information about supported frontends and their configuration.
-
- Obtaining NetSurf's build dependencies
-========================================
-
- Many of NetSurf's dependencies are packaged on various operating systems.
- The remainder must be installed manually. Currently, some of the libraries
- developed as part of the NetSurf project have not had official releases.
- Hopefully they will soon be released with downloadable tarballs and packaged
- in common distros. For now, you'll have to make do with Git checkouts.
-
- Package installation
-----------------------
-
- Debian-like OS:
-
- $ apt-get install libcurl3-dev libpng-dev
-
- Recent OS versions might need libcurl4-dev instead of libcurl3-dev but
- note that when it has not been built with OpenSSL, the SSL_CTX is not
- available and results that certification details won't be presented in case
- they are invalid. But as this is currently unimplemented in the Framebuffer
- flavour of NetSurf, this won't make a difference at all.
-
- Fedora:
-
- $ yum install curl-devel libpng-devel lcms-devel
-
- Other:
-
- You'll need to install the development resources for libcurl3 and libpng.
-
- The NetSurf project's libraries
----------------------------------
-
- The NetSurf project has developed several libraries which are required by
- the browser. These are:
-
- LibParserUtils -- Parser building utility functions
- LibWapcaplet -- String internment
- Hubbub -- HTML5 compliant HTML parser
- LibCSS -- CSS parser and selection engine
- LibNSGIF -- GIF format image decoder
- LibNSBMP -- BMP and ICO format image decoder
- LibROSprite -- RISC OS Sprite format image decoder
- LibNSFB -- Framebuffer abstraction
-
- To fetch each of these libraries, run the appropriate commands from the
- Docs/LIBRARIES file.
-
- To build and install these libraries, simply enter each of their directories
- and run:
-
- $ sudo make install
-
- | Note: We advise enabling iconv() support in libparserutils, which vastly
- | increases the number of supported character sets. To do this,
- | create a file called Makefile.config.override in the libparserutils
- | directory, containing the following line:
- |
- | CFLAGS += -DWITH_ICONV_FILTER
- |
- | For more information, consult the libparserutils README file.
-
- General requirements
-----------------------
-
- Depending on the frontend selected the build may need specific
- libraries installed, e.g. the SDL port requires SDL1.2 or later
-
- Installing these libraries will often will pull in loads of things,
- like the PNG and JPEG libraries, colour management libraries, zlib,
- OpenSSL etc that NetSurf also depends on.
diff --git a/Docs/BUILDING-GTK b/Docs/BUILDING-GTK
index 4641924..dab2bef 100644
--- a/Docs/BUILDING-GTK
+++ b/Docs/BUILDING-GTK
@@ -1,51 +1,32 @@
--------------------------------------------------------------------------------
- Build Instructions for GTK NetSurf 8 April 2010
+ Build Instructions for GTK NetSurf 16 March 2014
--------------------------------------------------------------------------------
This document provides instructions for building the GTK version of NetSurf
and provides guidance on obtaining NetSurf's build dependencies.
GTK NetSurf has been tested on Debian, Ubuntu, Fedora 8, FreeBSD, NetBSD and
- Solaris 10.
+ Solaris 10. NetSurf requires at minimum GTK 2.12.
- Building and executing NetSurf
-================================
+ Quick Start
+=============
- First of all, you should examine the contents of Makefile.defaults
- and enable and disable relevant features as you see fit by creating
- a Makefile.config file. Some of these options can be automatically
- detected and used, and where this is the case they are set to such.
- Others cannot be automatically detected from the Makefile, so you
- will either need to install the dependencies, or set them to NO.
-
- You should then obtain NetSurf's dependencies, keeping in mind which options
- you have enabled in the configuration file. See the next section for
- specifics.
-
- Once done, to build GTK NetSurf on a UNIX-like platform, simply run:
+ See the QUICK-START document, which provides a simple environment with
+ which you can fetch, build and install NetSurf and its dependencies.
- $ make
+ The QUICK-START is the recommended way to build NetSurf.
- If that produces errors, you probably don't have some of NetSurf's
- build dependencies installed. See "Obtaining NetSurf's dependencies"
- below. Or turn off the complaining features in a Makefile.config
- file. You may need to "make clean" before attempting to build after
- installing the dependencies.
- Run NetSurf by executing the "test-nsgtk" shell script:
+ Manual building
+=================
- $ ./test-nsgtk
+ If you can't follow the quick start instructions, you will have to build
+ NetSurf manually. The instructions for doing this are given below.
- This script makes it easy to run the nsgtk binary from the build tree. It
- sets up some environment variables which enable NetSurf to find its
- resources.
- If you are packaging NetSurf, see the PACKAGING-GTK document.
-
-
- Obtaining NetSurf's build dependencies
-========================================
+ Obtaining the build dependencies
+----------------------------------
Many of NetSurf's dependencies are packaged on various operating systems.
The remainder must be installed manually. Currently, some of the libraries
@@ -53,16 +34,8 @@
Hopefully they will soon be released with downloadable tarballs and packaged
in common distros. For now, you'll have to make do with Git checkouts.
- Some of NetSurf's own libraries will be installed in /usr/local/ by default.
- Fedora, and perhaps some other distributions of Linux, do not ship a
- pkg-config that will search here, so you will either need to change where
- these libraries install, or do the following before building NetSurf itself;
-
- $ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
- $ export PKG_CONFIG_PATH
-
Package installation
-----------------------
+ --------------------
Debian-like OS:
@@ -92,12 +65,66 @@
You'll need to install the development resources for libglade2, libcurl3,
libpng and librsvg.
+ Libharu
+ -------
+
+ NetSurf can use Haru PDF to enable PDF export. Haru PDF can be obtained
+ from http://libharu.org/. We require libharu 2.2 or later.
+
+ | Note: libharu cannot be auto-detected by the Makefile. If you wish to
+ | enable it, do so by creating a Makefile.config file.
+
+
+ Preparing your workspace
+--------------------------
+
+ NetSurf has a number of libraries which must be built in-order and
+ installed into your workspace. Each library depends on a core build
+ system which NetSurf projects use. This build system relies on the
+ presence of things like pkg-config to find libraries and also certain
+ environment variables in order to work correctly.
+
+ Assuming you are preparing a workspace in /home/netsurf/workspace then
+ the following steps will set you up:
+
+ Make the workspace directory and change to it
+ ---------------------------------------------
+
+ $ mkdir -p ${HOME}/netsurf/workspace
+ $ cd ${HOME}/netsurf/workspace
+
+ Make the temporary install space
+ --------------------------------
+
+ $ mkdir inst
+
+ Make an environment script
+ --------------------------
+ $ cat > env.sh <<'EOF'
+ export PKG_CONFIG_PATH=${HOME}/netsurf/workspace/inst/lib/pkgconfig::
+ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HOME}/netsurf/workspace/inst/lib
+ export PREFIX=${HOME}/netsurf/workspace/inst
+ EOF
+
+ Change to workspace and source the environment
+ ----------------------------------------------
+
+ Whenever you wish to start development in a new shell, run the following:
+
+ $ cd ${HOME}/netsurf/workspace
+ $ source env.sh
+
+ From here on, any commands in this document assume you have sourced your
+ shell environment.
+
+
The NetSurf project's libraries
---------------------------------
The NetSurf project has developed several libraries which are required by
the browser. These are:
+ BuildSystem -- Shared build system, needed to build the other libraries
LibParserUtils -- Parser building utility functions
LibWapcaplet -- String internment
Hubbub -- HTML5 compliant HTML parser
@@ -107,12 +134,12 @@
LibROSprite -- RISC OS Sprite format image decoder
To fetch each of these libraries, run the appropriate commands from the
- Docs/LIBRARIES file.
+ Docs/LIBRARIES file, from within your workspace directory.
To build and install these libraries, simply enter each of their directories
and run:
- $ sudo make install
+ $ make install
| Note: We advise enabling iconv() support in libparserutils, which vastly
| increases the number of supported character sets. To do this,
@@ -123,22 +150,56 @@
|
| For more information, consult the libparserutils README file.
- Libharu
----------
+ Now you should have all the NetSurf project libraries built and installed.
- NetSurf can use Haru PDF to enable PDF export. Haru PDF can be obtained
- from http://libharu.org/. We require libharu 2.2 or later.
- | Note: libharu cannot be auto-detected by the Makefile. If you wish to
- | enable it, do so by creating a Makefile.config file.
+ Getting the NetSurf source
+----------------------------
+
+ From your workspace directory, run the following command to get the NetSurf
+ source:
+
+ $ git clone git://git.netsurf-browser.org/netsurf.git
+
+ And change to the 'netsurf' directory:
+
+ $ cd netsurf
+
+ Building and executing NetSurf
+--------------------------------
+
+ First of all, you should examine the contents of Makefile.defaults
+ and enable and disable relevant features as you see fit by creating
+ a Makefile.config file. Some of these options can be automatically
+ detected and used, and where this is the case they are set to such.
+ Others cannot be automatically detected from the Makefile, so you
+ will either need to install the dependencies, or set them to NO.
+
+ You should then obtain NetSurf's dependencies, keeping in mind which options
+ you have enabled in the configuration file. See the next section for
+ specifics.
+
+ Once done, to build GTK NetSurf on a UNIX-like platform, simply run:
+
+ $ make
- General requirements
-----------------------
+ If that produces errors, you probably don't have some of NetSurf's
+ build dependencies installed. See "Obtaining NetSurf's dependencies"
+ below. Or turn off the complaining features in a Makefile.config
+ file. You may need to "make clean" before attempting to build after
+ installing the dependencies.
- NetSurf requires at minimum GTK 2.12. Earlier versions will not work. It also
- depends on Cairo for rendering, but you should have this already with
- versions of GTK 2.12 or later.
+ Run NetSurf by executing the "test-nsgtk" shell script:
+
+ $ ./test-nsgtk
+
+ This script makes it easy to run the nsgtk binary from the build tree. It
+ sets up some environment variables which enable NetSurf to find its
+ resources.
+
+
+ Note for packagers
+====================
+
+ If you are packaging NetSurf, see the PACKAGING-GTK document.
- This will pull in loads of things, like all the GTK dev libraries, the PNG
- and JPEG libraries, colour management libraries, zlib, OpenSSL etc that
- NetSurf also depends on.
diff --git a/Docs/BUILDING-Monkey b/Docs/BUILDING-Monkey
deleted file mode 100644
index 727124c..0000000
--- a/Docs/BUILDING-Monkey
+++ /dev/null
@@ -1,104 +0,0 @@
---------------------------------------------------------------------------------
- Build Instructions for Monkey NetSurf 13 March 2011
---------------------------------------------------------------------------------
-
- This document provides instructions for building the Monkey
- automation version of NetSurf and provides guidance on obtaining
- NetSurf's build dependencies.
-
- Monkey NetSurf has been tested on Ubuntu 10.10/amd64.
-
-
- Building and executing NetSurf
- ==============================
-
- First of all, you should examine the contents of Makefile.defaults
- and enable and disable relevant features as you see fit by creating
- a Makefile.config file. Some of these options can be automatically
- detected and used, and where this is the case they are set to such.
- Others cannot be automatically detected from the Makefile, so you
- will either need to install the dependencies, or set them to NO.
-
- You should then obtain NetSurf's dependencies, keeping in mind which options
- you have enabled in the configuration file. See the next section for
- specifics.
-
- Once done, to build Monkey NetSurf on a UNIX-like platform, simply run:
-
- $ make TARGET=monkey
-
- If that produces errors, you probably don't have some of NetSurf's
- build dependencies installed. See "Obtaining NetSurf's dependencies"
- below. Or turn off the complaining features in a Makefile.config
- file. You may need to "make clean" before attempting to build after
- installing the dependencies.
-
- Run NetSurf by executing the "nsmonkey" command from within the build tree.
-
- $ ./nsmonkey
-
- If you are packaging NetSurf, do NOT package nsmonkey. It is a debug tool.
-
-
- Obtaining NetSurf's build dependencies
- ======================================
-
- Many of NetSurf's dependencies are packaged on various operating systems.
- The remainder must be installed manually. Currently, some of the libraries
- developed as part of the NetSurf project have not had official releases.
- Hopefully they will soon be released with downloadable tarballs and packaged
- in common distros. For now, you'll have to make do with Git checkouts.
-
- Some of NetSurf's own libraries will be installed in /usr/local/ by default.
- Fedora, and perhaps some other distributions of Linux, do not ship a
- pkg-config that will search here, so you will either need to change where
- these libraries install, or do the following before building NetSurf itself;
-
- $ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
- $ export PKG_CONFIG_PATH
-
- Package installation
-----------------------
-
- Debian-like OS:
-
- $ apt-get install libcurl3-dev
-
- Recent OS versions might need libcurl4-dev instead of libcurl3-dev but
- note that when it has not been built with OpenSSL, the SSL_CTX is not
- available and results that certification details won't be presented in case
- they are invalid. But as this is currently unimplemented in the GTK
- flavour of NetSurf, this won't make a difference at all.
-
-
- The NetSurf project's libraries
- -------------------------------
-
- The NetSurf project has developed several libraries which are required by
- the browser. These are:
-
- LibParserUtils -- Parser building utility functions
- LibWapcaplet -- String internment
- Hubbub -- HTML5 compliant HTML parser
- LibCSS -- CSS parser and selection engine
- LibNSGIF -- GIF format image decoder
- LibNSBMP -- BMP and ICO format image decoder
- LibROSprite -- RISC OS Sprite format image decoder
-
- To fetch each of these libraries, run the appropriate commands from the
- Docs/LIBRARIES file.
-
- To build and install these libraries, simply enter each of their directories
- and run:
-
- $ sudo make install
-
- | Note: We advise enabling iconv() support in libparserutils, which vastly
- | increases the number of supported character sets. To do this,
- | create a file called Makefile.config.override in the libparserutils
- | directory, containing the following line:
- |
- | CFLAGS += -DWITH_ICONV_FILTER
- |
- | For more information, consult the libparserutils README file.
-
diff --git a/Docs/Doxyfile b/Docs/Doxyfile
index 40102ea..29bd573 100644
--- a/Docs/Doxyfile
+++ b/Docs/Doxyfile
@@ -703,7 +703,9 @@ INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.h \
*.y \
- *.l
+ *.l \
+ *.cpp \
+ *.m
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
@@ -717,12 +719,7 @@ RECURSIVE = NO
# Note that relative paths are relative to the directory from which doxygen is
# run.
-EXCLUDE = css/css_enum.c \
- css/css_enum.h \
- css/parser.c \
- css/parser.h \
- css/scanner.c \
- css/scanner.h
+EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
@@ -1788,7 +1785,7 @@ MSCFILE_DIRS =
# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
-DOT_GRAPH_MAX_NODES = 50
+DOT_GRAPH_MAX_NODES = 100
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
# graphs generated by dot. A depth value of 3 means that only nodes reachable
diff --git a/Docs/QUICK-START b/Docs/QUICK-START
new file mode 100644
index 0000000..237027b
--- /dev/null
+++ b/Docs/QUICK-START
@@ -0,0 +1,72 @@
+--------------------------------------------------------------------------------
+ Quick Build Steps for NetSurf 26 February 2014
+--------------------------------------------------------------------------------
+
+ This document provides steps for building NetSurf.
+
+
+ Grab a temporary env.sh
+--------------------------
+
+ $ wget http://git.netsurf-browser.org/netsurf.git/plain/Docs/env.sh
+ $ source env.sh
+
+
+ Install any packages you need
+-------------------------------
+
+ Installs all packages required to build NetSurf and the NetSurf project
+ libraries.
+
+ $ ns-package-install
+
+ If your package manager is not supported, you will have to install third
+ party packages manually.
+
+
+ Get the NetSurf project source code from Git
+----------------------------------------------
+
+ $ ns-clone
+
+
+ Build and install our project libraries
+-----------------------------------------
+
+ Updates NetSurf project library sources to latest, builds and installs them.
+
+ $ ns-pull-install
+
+
+ Switch to new NetSurf workspace
+---------------------------------
+
+ $ rm env.sh
+ $ cd ~/dev-netsurf/workspace
+ $ source env.sh
+
+
+ Build and run NetSurf
+-----------------------
+
+ $ cd netsurf
+
+ To build the native front end (the GTK front end on Linux, BSDs, etc) you
+ could do:
+
+ $ make
+ $ ./nsgtk
+
+ To build the framebuffer front end, you could do:
+
+ $ make TARGET=framebuffer
+ $ ./nsfb
+
+
+ Not working?
+==============
+
+ If the above steps are inapplicable, or don't work, you can build manually.
+ Follow the instructions in the BUILDING-* documents in the Docs/ directory
+ the NetSurf browser source tree.
+
diff --git a/Docs/env.sh b/Docs/env.sh
index b1b2b34..89f9add 100644
--- a/Docs/env.sh
+++ b/Docs/env.sh
@@ -28,7 +28,16 @@ if [ "x${USE_CPUS}" = "x" ]; then
USE_CPUS="-j${NCPUS}"
fi
+# The GTK version to build for (either 2 or 3 currently)
+if [ "x${NETSURF_GTK_MAJOR}" = "x" ]; then
+ NETSURF_GTK_MAJOR=3
+fi
+
+# The host system doing the building
+HOST_ABI=$(uname -s)
+
# setup environment
+echo "HOST_ABI=${HOST_ABI}"
echo "TARGET_ABI=${TARGET_ABI}"
echo "TARGET_WORKSPACE=${TARGET_WORKSPACE}"
echo "USE_CPUS=${USE_CPUS}"
@@ -37,34 +46,43 @@ export PREFIX=${TARGET_WORKSPACE}/inst-${TARGET_ABI}
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}::
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PREFIX}/lib
export PATH=${PATH}:${PREFIX}/bin
+export NETSURF_GTK_MAJOR
+# NetSurf GIT repositories
NS_GIT="git://git.netsurf-browser.org"
+
# internal libraries all frontends require (order is important)
-NS_INTERNAL_LIBS="buildsystem libwapcaplet libparserutils libhubbub libdom libcss libnsgif libnsbmp libsvgtiny librosprite"
-# internal libraries only required by some frontends
-NS_FRONTEND_LIBS="libnsfb"
-# internal libraries required for the risc os target abi
-NS_RISCOS_LIBS="librufl libpencil"
-# tools required to build the browser
-NS_TOOLS="nsgenbind"
+NS_INTERNAL_LIBS="buildsystem libwapcaplet libparserutils libhubbub libdom libcss libnsgif libnsbmp"
+
# The browser itself
NS_BROWSER="netsurf"
-# deb packages
-NS_DEV_DEB="build-essential pkg-config git gperf"
-NS_TOOL_DEB="flex bison libhtml-parser-perl"
-NS_GTK_DEB="libgtk2.0-dev libcurl3-dev libpng-dev librsvg2-dev libjpeg-dev libmozjs185-dev"
+# add target specific libraries
+if [ "x${TARGET_ABI}" = "xHaiku" ]; then
+ # tools required to build the browser
+ NS_TOOLS=""
+ NS_FRONTEND_LIBS=""
+elif [ "x${TARGET_ABI}" = "xriscos" ]; then
+ # tools required to build the browser
+ NS_TOOLS="nsgenbind"
+ # libraries required for the risc os target abi
+ NS_FRONTEND_LIBS="libsvgtiny librufl libpencil librosprite"
+else
+ # tools required to build the browser
+ NS_TOOLS="nsgenbind"
+ # internal libraries only required by some frontends
+ NS_FRONTEND_LIBS="libsvgtiny libnsfb"
+fi
-# Haiku secondary arch suffix:
-# empty for primary (gcc2 on x86),
-# "_x86" for gcc4 secondary.
-HA=
-# Haiku packages
-NS_DEV_HPKG="curl${HA}_devel libpng${HA}_devel jpeg${HA}_devel openssl${HA}_devel libiconv${HA}_devel expat${HA}_devel pkgconfig${HA} html_parser cmd:getconf"
+################ OS Package installation ################
-#add target specific libraries
-if [ "x${TARGET_ABI}" = "xriscos" ]; then
- NS_FRONTEND_LIBS="${NS_FRONTEND_LIBS} ${NS_RISCOS_LIBS}"
+# deb packages for dpkg based systems
+NS_DEV_DEB="build-essential pkg-config git gperf libcurl3-dev libpng-dev libjpeg-dev libmozjs185-dev"
+NS_TOOL_DEB="flex bison libhtml-parser-perl"
+if [ "x${NETSURF_GTK_MAJOR}" = "x3" ]; then
+ NS_GTK_DEB="libgtk-3-dev librsvg2-dev"
+else
+ NS_GTK_DEB="libgtk2.0-dev librsvg2-dev"
fi
# apt get commandline to install necessary dev packages
@@ -73,12 +91,63 @@ ns-apt-get-install()
sudo apt-get install $(echo ${NS_DEV_DEB} ${NS_TOOL_DEB} ${NS_GTK_DEB})
}
+# RPM packages for rpm based systems (tested on fedora 20)
+NS_DEV_RPM="git gcc pkgconfig libexpat-devel openssl-devel js-devel-1.8.5 libcurl-devel perl-Digest-MD5-File libjpeg-devel libpng-devel"
+NS_TOOL_RPM="flex bison"
+if [ "x${NETSURF_GTK_MAJOR}" = "x3" ]; then
+ NS_GTK_RPM="gtk3-devel librsvg2-devel"
+else
+ NS_GTK_RPM="gtk2-devel librsvg2-devel"
+fi
+
+# yum commandline to install necessary dev packages
+ns-yum-install()
+{
+ sudo yum -y install $(echo ${NS_DEV_RPM} ${NS_TOOL_RPM} ${NS_GTK_RPM})
+}
+
+# Haiku secondary arch suffix:
+# empty for primary (gcc2 on x86),
+# "_x86" for gcc4 secondary.
+HA=
+# Haiku packages
+NS_DEV_HPKG="curl${HA}_devel libpng${HA}_devel jpeg${HA}_devel openssl${HA}_devel libiconv${HA}_devel expat${HA}_devel pkgconfig${HA} gperf${HA}"
+
# pkgman commandline to install necessary dev packages
ns-pkgman-install()
{
pkgman install $(echo ${NS_DEV_HPKG})
}
+# generic for help text
+NS_DEV_GEN="git, gcc, pkgconfig, expat library, openssl library, spidermonkey-1.8.5 library, libcurl, perl, perl MD5 digest, libjpeg library, libpng library"
+NS_TOOL_GEN="flex tool, bison tool"
+if [ "x${NETSURF_GTK_MAJOR}" = "x3" ]; then
+ NS_GTK_GEN="gtk+ 3 toolkit library, librsvg2 library"
+else
+ NS_GTK_GEN="gtk+ 2 toolkit library, librsvg2 library"
+fi
+
+
+# Genertic OS package install
+# looks for package managers and tries to use them if present
+ns-package-install()
+{
+ if [ -x "/usr/bin/apt-get" ]; then
+ ns-apt-get-install
+ elif [ -x "/usr/bin/yum" ]; then
+ ns-yum-install
+ elif [ -x "/bin/pkgman" ]; then
+ ns-pkgman-install
+ else
+ echo "Unable to determine OS packaging system in use."
+ echo "Please ensure development packages are installed for:"
+ echo ${NS_DEV_GEN}"," ${NS_TOOL_GEN}"," ${NS_GTK_GEN}
+ fi
+}
+
+################ Development helpers ################
+
# git pull in all repos parameters are passed to git pull
ns-pull()
{
@@ -120,7 +189,7 @@ ns-make-libs()
done
}
-# issues a make command to all libraries
+# issues a make command for framebuffer libraries
ns-make-libnsfb()
{
echo " MAKE: make -C libnsfb $USE_CPUS $*"
diff --git a/amiga/Makefile.defaults b/amiga/Makefile.defaults
index 35c35ae..43b42b2 100644
--- a/amiga/Makefile.defaults
+++ b/amiga/Makefile.defaults
@@ -2,41 +2,41 @@
# Amiga-specific options
# ----------------------------------------------------------------------------
- # Force using glibc internal iconv implementation instead of external libiconv
- # Valid options: YES, NO
- NETSURF_USE_LIBICONV_PLUG := YES
-
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := NO
-
- # Enable NetSurf's use of libwebp for displaying WebPs
- # Valid options: YES, NO
- NETSURF_USE_WEBP := NO
-
- # Enable NetSurf to display Amiga icons
- # Valid options: YES, NO (recommended)
- NETSURF_USE_AMIGA_ICON := YES
-
- # Enable NetSurf's use of DataTypes for unknown filetypes
- # Valid options: YES, NO
- NETSURF_USE_AMIGA_DATATYPES := YES
-
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO
- NETSURF_USE_NSSVG := YES
-
- # Enable NetSurf's use of libcairo for some plotter functions
- # This will also link NetSurf with shared objects, and
- # requires AmigaOS 4.1 or higher to run the resulting executable
- # Valid options: YES, NO, AUTO
- NETSURF_USE_AMIGA_CAIRO := AUTO
-
- # Enable NetSurf's use of Spidermonkey 1.80+
- # Only here to stop the build complaining;
- # enable NETSURF_USE_MOZJS instead for JavaScript support
- # Valid options: NO
- NETSURF_USE_JS := NO
-
- # Optimisation levels
- CFLAGS += -O2 -gstabs
+# Force using glibc internal iconv implementation instead of external libiconv
+# Valid options: YES, NO
+NETSURF_USE_LIBICONV_PLUG := YES
+
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := NO
+
+# Enable NetSurf's use of libwebp for displaying WebPs
+# Valid options: YES, NO
+NETSURF_USE_WEBP := NO
+
+# Enable NetSurf to display Amiga icons
+# Valid options: YES, NO (recommended)
+NETSURF_USE_AMIGA_ICON := YES
+
+# Enable NetSurf's use of DataTypes for unknown filetypes
+# Valid options: YES, NO
+NETSURF_USE_AMIGA_DATATYPES := YES
+
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO
+NETSURF_USE_NSSVG := YES
+
+# Enable NetSurf's use of libcairo for some plotter functions
+# This will also link NetSurf with shared objects, and
+# requires AmigaOS 4.1 or higher to run the resulting executable
+# Valid options: YES, NO, AUTO
+NETSURF_USE_AMIGA_CAIRO := AUTO
+
+# Enable NetSurf's use of Spidermonkey 1.80+
+# Only here to stop the build complaining;
+# enable NETSURF_USE_MOZJS instead for JavaScript support
+# Valid options: NO
+NETSURF_USE_JS := NO
+
+# Optimisation levels
+CFLAGS += -O2 -gstabs
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index 7b04f37..b54fa1e 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -54,7 +54,7 @@ else
CFLAGS += $(shell $(PKG_CONFIG) --cflags libcurl openssl)
CFLAGS += $(shell $(PKG_CONFIG) --cflags tre libdom libcss)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libcurl openssl)
+ LDFLAGS += $(shell $(PKG_CONFIG) --static --libs libcurl openssl)
LDFLAGS += $(shell $(PKG_CONFIG) --libs tre libdom libcss)
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
diff --git a/amiga/agclass/amigaguide_class.c b/amiga/agclass/amigaguide_class.c
old mode 100755
new mode 100644
index dfac7ad..9d69e96
--- a/amiga/agclass/amigaguide_class.c
+++ b/amiga/agclass/amigaguide_class.c
@@ -8,6 +8,8 @@
#include "amigaguide_class.h"
+
+
struct localObjectData
{
struct NewAmigaGuide nag;
@@ -15,7 +17,6 @@ struct localObjectData
AMIGAGUIDECONTEXT agHandle;
uint32 agContextID;
uint32 agSignal;
- BOOL agActive;
};
struct Library *AmigaGuideBase = NULL;
@@ -34,6 +35,7 @@ uint32 om_set(Class *, Object *, struct opSet *);
uint32 om_get(Class *, Object *, struct opGet *);
uint32 agm_open(Class *, Object *, Msg);
uint32 agm_close(Class *, Object *, Msg);
+uint32 agm_process(Class *, Object *, Msg);
/* *************************** class initialization and disposal ***************************** */
@@ -107,6 +109,9 @@ static uint32 dispatchAGClass(Class *cl, Object *o, Msg msg)
case AGM_CLOSE:
return agm_close(cl, o, msg);
+ case AGM_PROCESS:
+ return agm_process(cl, o, msg);
+
default:
return IIntuition->IDoSuperMethodA(cl, o, msg);
}
@@ -128,7 +133,6 @@ uint32 om_new(Class *cl, Object *o, struct opSet *msg)
if ( (lod = (struct localObjectData *)INST_DATA(cl, retVal)) )
{
// Initialize values.
- lod->agActive = FALSE;
lod->agHandle = NULL;
lod->agContextID = 0;
lod->nag.nag_Name = NULL;
@@ -169,10 +173,9 @@ uint32 om_dispose(Class *cl, Object *o, Msg msg)
uint32 om_set(Class *cl, Object *o, struct opSet *msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
- struct TagItem *tags, *ti;
-
-
- tags = msg->ops_AttrList;
+ struct TagItem *ti = NULL, *tags = msg->ops_AttrList;
+ uint32 retVal = 0L;
+
while ((ti = IUtility->NextTagItem (&tags)))
{
@@ -180,31 +183,32 @@ uint32 om_set(Class *cl, Object *o, struct opSet *msg)
{
case AMIGAGUIDE_Name:
lod->nag.nag_Name = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Database name has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_Screen:
lod->nag.nag_Screen = (struct Screen *)ti->ti_Data;
- lod->agActive = FALSE; // Screen pointer has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_PubScreen:
lod->nag.nag_PubScreen = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Pubscreen name has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_BaseName:
lod->nag.nag_BaseName = (STRPTR)ti->ti_Data;
- lod->agActive = FALSE; // Application basename has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_ContextArray:
lod->nag.nag_Context = (STRPTR *)ti->ti_Data;
- lod->agActive = FALSE; // Context array has changed, we must setup the help system again.
+ retVal++;
break;
case AMIGAGUIDE_ContextID:
lod->agContextID = (uint32)ti->ti_Data;
+ retVal++;
break;
default:
@@ -212,38 +216,7 @@ uint32 om_set(Class *cl, Object *o, struct opSet *msg)
}
}
-
- // Setup the help system, if not ready yet or needs changing.
- if ( lod->agActive == FALSE )
- {
- // Shut down help system should it already be running.
- if ( lod->agHandle ) agm_close(cl, o, (Msg)msg);
-
- // (Re)establish the AmigaGuide context and open the database asynchronously.
- if ( (lod->agHandle = IAmigaGuide->OpenAmigaGuideAsync(&(lod->nag), NULL)) )
- {
- if ( (lod->agSignal = IAmigaGuide->AmigaGuideSignal(lod->agHandle)) )
- {
- // Wait until the help system is up and running.
- IExec->Wait(lod->agSignal);
- while ( !(lod->agActive) )
- {
- while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
- {
- // The AmigaGuide process started OK.
- if ( lod->agm->agm_Type == ActiveToolID ) lod->agActive = TRUE;
-
- // Opening the guide file failed for some reason, continue as usual.
- if ( lod->agm->agm_Type == ToolStatusID && lod->agm->agm_Pri_Ret ) lod->agActive = TRUE;
-
- IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
- }
- }
- }
- }
- }
-
- return (uint32)lod->agHandle;
+ return retVal;
}
@@ -261,32 +234,37 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
{
case AMIGAGUIDE_Name:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Name;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_Screen:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Screen;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_PubScreen:
*(msg->opg_Storage) = (uint32)lod->nag.nag_PubScreen;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_BaseName:
*(msg->opg_Storage) = (uint32)lod->nag.nag_BaseName;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_ContextArray:
*(msg->opg_Storage) = (uint32)lod->nag.nag_Context;
- retVal = 1;
+ retVal = 1L;
break;
case AMIGAGUIDE_ContextID:
*(msg->opg_Storage) = (uint32)lod->agContextID;
- retVal = 1;
+ retVal = 1L;
+ break;
+
+ case AMIGAGUIDE_Signal:
+ *(msg->opg_Storage) = (uint32)lod->agSignal;
+ retVal = 1L;
break;
default:
@@ -304,23 +282,47 @@ uint32 om_get(Class *cl, Object *o, struct opGet *msg)
uint32 agm_open(Class *cl, Object *o, Msg msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
- uint32 retVal = 0;
+ BOOL agActive = FALSE;
+ uint32 retVal = 0L;
- if ( (lod->agHandle) && (lod->agActive) )
- {
- if ( lod->nag.nag_Context )
- {
- // A context node array is provided = open the current context node.
- IAmigaGuide->SetAmigaGuideContext(lod->agHandle, lod->agContextID, NULL);
- retVal = IAmigaGuide->SendAmigaGuideContext(lod->agHandle, NULL);
- }
- else
+ // Close a previous instance.
+ if ( lod->agHandle ) agm_close(cl, o, msg);
+
+ // (Re)establish the AmigaGuide context and open the database asynchronously.
+ if ( (lod->agHandle = IAmigaGuide->OpenAmigaGuideAsync(&(lod->nag), NULL)) )
{
- // No context array is provided = open the main node.
- retVal = IAmigaGuide->SendAmigaGuideCmd(lod->agHandle, "LINK MAIN", TAG_DONE);
+ if ( (lod->agSignal = IAmigaGuide->AmigaGuideSignal(lod->agHandle)) )
+ {
+ // Wait until the database is displayed and ready.
+ IExec->Wait(lod->agSignal);
+ while ( agActive == FALSE )
+ {
+ while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
+ {
+ // The AmigaGuide process started OK.
+ if ( lod->agm->agm_Type == ActiveToolID ) agActive = TRUE;
+
+ // Opening the guide file failed for some reason, continue as usual.
+ if ( lod->agm->agm_Type == ToolStatusID && lod->agm->agm_Pri_Ret ) agActive = TRUE;
+
+ IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
+ }
+ }
+ if ( lod->nag.nag_Context )
+ {
+ // A context node array is provided = open the current context node.
+ IAmigaGuide->SetAmigaGuideContext(lod->agHandle, lod->agContextID, NULL);
+ retVal = IAmigaGuide->SendAmigaGuideContext(lod->agHandle, NULL);
+ }
+ else
+ {
+ // No context array is provided = open the main node.
+ retVal = IAmigaGuide->SendAmigaGuideCmd(lod->agHandle, "LINK MAIN", TAG_DONE);
+ }
+ }
}
- }
+
return retVal;
}
@@ -332,15 +334,52 @@ uint32 agm_open(Class *cl, Object *o, Msg msg)
uint32 agm_close(Class *cl, Object *o, Msg msg)
{
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
+ uint32 retVal = 0L;
if ( lod->agHandle )
{
IAmigaGuide->CloseAmigaGuide(lod->agHandle);
lod->agHandle = NULL;
- lod->agActive = FALSE;
+ lod->agSignal = 0;
+ retVal = 1L;
}
- return (uint32)lod->agHandle;
+ return retVal;
+
+}
+
+
+
+
+
+
+uint32 agm_process(Class *cl, Object *o, Msg msg)
+{
+ struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
+ uint32 retVal = 0L;
+
+
+ if (lod->agHandle)
+ {
+ while ( (lod->agm = IAmigaGuide->GetAmigaGuideMsg(lod->agHandle)) )
+ {
+ switch (lod->agm->agm_Type)
+ {
+ case ShutdownMsgID:
+ agm_close(cl, o, msg);
+ retVal = 1L;
+ break;
+
+ default:
+ //printf("%d\n", lod->agm->agm_Type);
+ break;
+ }
+ IAmigaGuide->ReplyAmigaGuideMsg(lod->agm);
+ }
+ }
+ return retVal;
+
}
+
diff --git a/amiga/agclass/amigaguide_class.h b/amiga/agclass/amigaguide_class.h
index f122f35..ee7e55e 100755
--- a/amiga/agclass/amigaguide_class.h
+++ b/amiga/agclass/amigaguide_class.h
@@ -27,10 +27,13 @@
#define AMIGAGUIDE_BaseName (AMIGAGUIDE_Dummy + 4) // Basename of the application that opens the help file.
#define AMIGAGUIDE_ContextArray (AMIGAGUIDE_Dummy + 5) // Context node array (must be NULL-terminated).
#define AMIGAGUIDE_ContextID (AMIGAGUIDE_Dummy + 6) // Index value of the node to display.
+#define AMIGAGUIDE_Signal (AMIGAGUIDE_Dummy + 7) // Signal mask to wait on
// method definition
-#define AGM_OPEN WM_OPEN
-#define AGM_CLOSE WM_CLOSE
+#define AGM_Dummy AMIGAGUIDE_Dummy + 100
+#define AGM_OPEN AGM_Dummy + 1
+#define AGM_CLOSE AGM_Dummy + 2
+#define AGM_PROCESS AGM_Dummy + 3
// function prototypes
Class *initAGClass(void);
diff --git a/amiga/arexx.c b/amiga/arexx.c
index 472aea1..240aafe 100644
--- a/amiga/arexx.c
+++ b/amiga/arexx.c
@@ -248,8 +248,7 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
browser_window_navigate(curbw,
url,
NULL,
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -257,9 +256,8 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
}
else if(cmd->ac_ArgList[2])
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
bw,
@@ -267,8 +265,7 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
}
else if(cmd->ac_ArgList[1])
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -281,16 +278,14 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
}
else
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -510,8 +505,7 @@ STATIC VOID rx_home(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
diff --git a/amiga/clipboard.c b/amiga/clipboard.c
index d39e89e..6768dde 100644
--- a/amiga/clipboard.c
+++ b/amiga/clipboard.c
@@ -16,10 +16,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <proto/iffparse.h>
+#include <proto/intuition.h>
+#include <proto/exec.h>
+#include <proto/datatypes.h>
+#include <proto/diskfont.h>
+
+#include <diskfont/diskfonttag.h>
+#include <datatypes/textclass.h>
+#include <datatypes/pictureclass.h>
+
+#include "utils/nsoption.h"
+#include "utils/utf8.h"
#include "desktop/gui.h"
#include "desktop/plotters.h"
#include "desktop/textinput.h"
-#include "utils/nsoption.h"
#include "amiga/bitmap.h"
#include "amiga/clipboard.h"
@@ -31,18 +42,6 @@
#include "amiga/menu.h"
#include "amiga/utf8.h"
-#include "utils/utf8.h"
-
-#include <proto/iffparse.h>
-#include <proto/intuition.h>
-#include <proto/exec.h>
-#include <proto/datatypes.h>
-#include <proto/diskfont.h>
-
-#include <diskfont/diskfonttag.h>
-#include <datatypes/textclass.h>
-#include <datatypes/pictureclass.h>
-
#define ID_UTF8 MAKE_ID('U','T','F','8')
struct IFFHandle *iffh = NULL;
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 1aa8f7a..dde283b 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -39,8 +39,8 @@
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/local_history.h"
#include "desktop/hotlist.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
@@ -53,7 +53,7 @@
static uint32 ami_context_menu_hook(struct Hook *hook, Object *item, APTR reserved);
static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR reserved);
-static bool ami_context_menu_history(const struct history *history, int x0, int y0,
+static bool ami_context_menu_history(const struct browser_window *bw, int x0, int y0,
int x1, int y1, const struct history_entry *entry, void *user_data);
static uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved);
@@ -269,7 +269,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
PMIA_CommKey, "B",
TAG_DONE),
- TAG_DONE),
+ PMEND,
TAG_DONE),
~0);
break;
@@ -598,8 +598,8 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
ctxmenuhook.h_SubEntry = NULL;
ctxmenuhook.h_Data = gwin;
- ctxmenuobj = NewObject( POPUPMENU_GetClass(), NULL,
- PMA_MenuHandler, &ctxmenuhook,
+ ctxmenuobj = NewObject( POPUPMENU_GetClass(), NULL,
+ PMA_MenuHandler, &ctxmenuhook,
TAG_DONE);
if(gwin->bw && gwin->bw->history &&
@@ -607,7 +607,7 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
gwin->win->MouseX, gwin->win->MouseY))
{
gwin->temp = 0;
- history_enumerate_back(gwin->bw->history, ami_context_menu_history, gwin);
+ browser_window_history_enumerate_back(gwin->bw, ami_context_menu_history, gwin);
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
@@ -630,7 +630,7 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
gwin->win->MouseX, gwin->win->MouseY))
{
gwin->temp = 0;
- history_enumerate_forward(gwin->bw->history, ami_context_menu_history, gwin);
+ browser_window_history_enumerate_forward(gwin->bw, ami_context_menu_history, gwin);
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
@@ -707,7 +707,7 @@ void ami_context_menu_show(struct gui_window_2 *gwin,int x,int y)
static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved)
{
- int32 itemid = 0;
+ int32 itemid = 0;
struct gui_window_2 *gwin = hook->h_Data;
APTR userdata = NULL;
struct browser_window *bw;
@@ -718,10 +718,9 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
nsurl *url;
nserror error;
- if(GetAttrs(item,PMIA_ID,&itemid,
- PMIA_UserData,&userdata,
- TAG_DONE))
- {
+ if(GetAttrs(item, PMIA_ID, &itemid,
+ PMIA_UserData, &userdata,
+ TAG_DONE)) {
switch(itemid)
{
case CMID_SELECTFILE:
@@ -780,8 +779,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
case CMID_URLOPENWIN:
error = nsurl_create(userdata, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
url,
hlcache_handle_get_url(gwin->bw->current_content),
gwin->bw,
@@ -799,9 +797,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
case CMID_URLOPENTAB:
error = nsurl_create(userdata, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY | BW_CREATE_TAB,
url,
hlcache_handle_get_url(gwin->bw->current_content),
gwin->bw,
@@ -824,8 +820,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
url,
hlcache_handle_get_url(gwin->bw->current_content),
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -839,8 +834,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
hlcache_handle_get_url(userdata),
hlcache_handle_get_url(gwin->bw->current_content),
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -856,8 +850,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
url,
hlcache_handle_get_url(gwin->bw->current_content),
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -917,7 +910,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
}
else
{
- history_go(gwin->bw, gwin->bw->history,
+ browser_window_history_go(gwin->bw,
(struct history_entry *)userdata, false);
}
break;
@@ -932,8 +925,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1003,8 +995,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1256,8 +1247,9 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
return itemid;
}
-static bool ami_context_menu_history(const struct history *history, int x0, int y0,
- int x1, int y1, const struct history_entry *entry, void *user_data)
+static bool ami_context_menu_history(const struct browser_window *bw,
+ int x0, int y0, int x1, int y1,
+ const struct history_entry *entry, void *user_data)
{
struct gui_window_2 *gwin = (struct gui_window_2 *)user_data;
@@ -1266,7 +1258,7 @@ static bool ami_context_menu_history(const struct history *history, int x0, int
IDoMethod(ctxmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
- PMIA_Title, (ULONG)history_entry_get_title(entry),
+ PMIA_Title, (ULONG)browser_window_history_entry_get_title(entry),
PMIA_ID, CMID_HISTORY,
PMIA_UserData, entry,
TAG_DONE),
@@ -1282,7 +1274,7 @@ static uint32 ami_popup_hook(struct Hook *hook,Object *item,APTR reserved)
if(GetAttr(PMIA_ID, item, &itemid))
{
- form_select_process_selection(gwin->shared->bw->current_content,gwin->shared->control,itemid);
+ form_select_process_selection(gwin->shared->control,itemid);
}
return itemid;
diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide
index 25310bd..5aaf60a 100755
--- a/amiga/dist/NetSurf.guide
+++ b/amiga/dist/NetSurf.guide
@@ -183,6 +183,7 @@ Commands are:
@{b}OPEN URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N@{ub}
Opens URL in current window or a new window/tab if NEWWINDOW/NEWTAB is specified. Saves the location without displaying if SAVEAS and a filename is specified (SAVEAS available in 2.6325)
+Note that if the URL is non-ASCII it is expected to be encoded in UTF-8 (file: references should always be in local charset due to filesystem limitations). Usually this is not relevant, as all normalised URLs will be in their ASCII form.
@{b}SAVE FILENAME/A,W=WINDOW/K/N,T=TAB/K/N@{ub} (2.6027)
Saves current page source to FILENAME
@@ -255,6 +256,10 @@ Under OS4.1 Update 1, launch-handler is used in preference to OpenURL. The
Installer script can add the relevant configuration to launch URLs in NetSurf.
Please ensure your email application is configured in URL Prefs for mailto:
links clicked within NetSurf.
+
+Note that a helper script is installed in S:ARexx which can be used instead of
+the main executable, to stop the NetSurf executable from being loaded again if
+it is already running.
@endnode
@node hotlist "Hotlist menu"
diff --git a/amiga/download.c b/amiga/download.c
index a65fad9..fb5c109 100644
--- a/amiga/download.c
+++ b/amiga/download.c
@@ -230,11 +230,12 @@ static nserror gui_download_window_data(struct gui_download_window *dw,
static void gui_download_window_done(struct gui_download_window *dw)
{
struct dlnode *dln,*dln2 = NULL;
- struct browser_window *bw = dw->bw;
+ struct browser_window *bw;
bool queuedl = false;
STRPTR sendcmd = NULL;
if(!dw) return;
+ bw = dw->bw;
if((nsoption_bool(download_notify)) && (dw->result == AMINS_DLOAD_OK))
{
@@ -274,14 +275,14 @@ static void gui_download_window_done(struct gui_download_window *dw)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
nsurl_unref(url);
}
}
+ ami_try_quit(); /* In case the only window open was this download */
}
static void gui_download_window_error(struct gui_download_window *dw,
diff --git a/amiga/dt_anim.c b/amiga/dt_anim.c
index c844700..f2b0f76 100644
--- a/amiga/dt_anim.c
+++ b/amiga/dt_anim.c
@@ -341,7 +341,7 @@ APTR ami_colormap_to_clut(struct ColorMap *cmap)
{
int i;
UBYTE *clut = AllocVecTags(256 * 4, AVT_ClearWithValue, 0, TAG_DONE); /* NB: Was not MEMF_PRIVATE */
- ULONG colour[3 * 256];
+ ULONG colour[256 * 4];
if(!clut) return NULL;
diff --git a/amiga/file.c b/amiga/file.c
index 9500b40..91d3755 100644
--- a/amiga/file.c
+++ b/amiga/file.c
@@ -22,6 +22,7 @@
#include "amiga/filetype.h"
#include "amiga/icon.h"
#include "amiga/iff_dr2d.h"
+#include "amiga/misc.h"
#include "amiga/save_pdf.h"
#include "amiga/theme.h"
@@ -103,8 +104,7 @@ void ami_file_open(struct gui_window_2 *gwin)
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
diff --git a/amiga/font.c b/amiga/font.c
index 3430a4e..df4a188 100755
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -23,12 +23,12 @@
#include "amiga/gui.h"
#include "amiga/utf8.h"
#include "amiga/object.h"
+#include "amiga/schedule.h"
#include "utils/nsoption.h"
#include "css/css.h"
#include "css/utils.h"
#include "render/font.h"
#include "utils/log.h"
-#include "utils/schedule.h"
#include "utils/utf8.h"
#include "utils/utils.h"
@@ -831,7 +831,7 @@ void ami_init_fonts(void)
NewList(&ami_diskfontlib_list);
/* run first cleanup in ten minutes */
- schedule(60000, (schedule_callback_fn)ami_font_cleanup, ami_font_list);
+ ami_schedule(600000, ami_font_cleanup, ami_font_list);
}
void ami_close_fonts(void)
@@ -875,7 +875,7 @@ static void ami_font_cleanup(struct MinList *ami_font_list)
}while(node=nnode);
/* reschedule to run in five minutes */
- schedule(30000, (schedule_callback_fn)ami_font_cleanup, ami_font_list);
+ ami_schedule(300000, ami_font_cleanup, ami_font_list);
}
void ami_font_setdevicedpi(int id)
diff --git a/amiga/gui.c b/amiga/gui.c
index 074dfaf..5c707c5 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -19,9 +19,9 @@
/* NetSurf core includes */
#include "content/urldb.h"
#include "css/utils.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
#include "desktop/hotlist.h"
-#include "desktop/local_history.h"
#include "desktop/mouse.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
@@ -145,6 +145,8 @@
#define EXTRADOWN (IECODE_5TH_BUTTON)
#define EXTRAUP (IECODE_5TH_BUTTON | IECODE_UP_PREFIX)
+extern struct gui_utf8_table *amiga_utf8_table;
+
struct ami_gui_tb_userdata {
struct List *sblist;
struct gui_window_2 *gw;
@@ -162,6 +164,7 @@ Class *urlStringClass;
BOOL locked_screen = FALSE;
BOOL screen_closed = FALSE;
ULONG screen_signal = -1;
+
struct MsgPort *applibport = NULL;
ULONG applibsig = 0;
BOOL refresh_search_ico = FALSE;
@@ -440,8 +443,6 @@ void ami_open_resources(void)
TAG_DONE))) die(messages_get("NoMemory"));
ami_file_req_init();
- ami_help_init(NULL);
- screen_signal = AllocSignal(-1); /* for screen closure notification */
}
static UWORD ami_system_colour_scrollbar_fgpen(struct DrawInfo *drinfo)
@@ -698,7 +699,6 @@ void gui_init(int argc, char** argv)
BPTR lock = 0;
ami_open_resources(); /* alloc ports/asl reqs, open libraries/devices */
- ami_print_init();
ami_clipboard_init();
ami_openurl_open();
@@ -764,14 +764,17 @@ void ami_openscreen(void)
}
}
+ screen_signal = AllocSignal(-1);
+ LOG(("Screen signal %d", screen_signal));
scrn = OpenScreenTags(NULL,
SA_DisplayID, id,
SA_Title, nsscreentitle,
SA_Type, PUBLICSCREEN,
SA_PubName, "NetSurf",
+ SA_PubSig, screen_signal,
+ SA_PubTask, FindTask(0),
SA_LikeWorkbench, TRUE,
SA_Compositing, compositing,
- SA_PubSig, screen_signal,
TAG_DONE);
if(scrn)
@@ -833,7 +836,7 @@ static void ami_gui_commandline(int *argc, char **argv)
if(args = ReadArgs(template, rarray, NULL)) {
if(rarray[A_URL]) {
LOG(("URL %s specified on command line", rarray[A_URL]));
- temp_homepage_url = (char *)strdup((char *)rarray[A_URL]);
+ temp_homepage_url = ami_to_utf8_easy((char *)rarray[A_URL]);
}
if(rarray[A_FORCE]) {
@@ -906,8 +909,7 @@ static void gui_init2(int argc, char** argv)
if(temp_homepage_url && notalreadyrunning) {
error = nsurl_create(temp_homepage_url, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -947,13 +949,11 @@ static void gui_init2(int argc, char** argv)
if(notalreadyrunning)
{
error = nsurl_create(temp_homepage_url, &url);
-
if (error == NSERROR_OK) {
if(!first)
{
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -963,8 +963,7 @@ static void gui_init2(int argc, char** argv)
}
else
{
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
url,
NULL,
bw,
@@ -1046,8 +1045,7 @@ static void gui_init2(int argc, char** argv)
if(!bw && (nsoption_bool(startup_no_window) == false)) {
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -1066,12 +1064,12 @@ void ami_gui_history(struct gui_window_2 *gwin, bool back)
if(back == true)
{
if(browser_window_back_available(gwin->bw))
- history_back(gwin->bw, gwin->bw->history);
+ browser_window_history_back(gwin->bw, false);
}
else
{
if(browser_window_forward_available(gwin->bw))
- history_forward(gwin->bw, gwin->bw->history);
+ browser_window_history_forward(gwin->bw, false);
}
ami_update_buttons(gwin);
@@ -1464,6 +1462,7 @@ void ami_handle_msg(void)
struct browser_window *closedbw;
struct timeval curtime;
static int drag_x_move = 0, drag_y_move = 0;
+ char *utf8 = NULL;
nsurl *url;
if(IsMinListEmpty(window_list))
@@ -1481,121 +1480,60 @@ void ami_handle_msg(void)
gwin = node->objstruct;
- if(node->Type == AMINS_TVWINDOW)
- {
- if(ami_tree_event((struct treeview_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ if(node->Type == AMINS_TVWINDOW) {
+ if(ami_tree_event((struct treeview_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_FINDWINDOW)
- {
- if(ami_search_event())
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_FINDWINDOW) {
+ if(ami_search_event()) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_HISTORYWINDOW)
- {
- if(ami_history_event((struct history_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_HISTORYWINDOW) {
+ if(ami_history_event((struct history_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_PRINTWINDOW)
- {
- if(ami_print_event((struct ami_print_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_PRINTWINDOW) {
+ if(ami_print_event((struct ami_print_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_GUIOPTSWINDOW)
- {
- if(ami_gui_opts_event())
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit with conditions ;) */
- if(scrn) ami_try_quit();
- }
+ } else if(node->Type == AMINS_GUIOPTSWINDOW) {
+ if(ami_gui_opts_event()) {
+ /* last window possibly closed, so exit with conditions ;) */
+ if(scrn) ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_DLWINDOW)
- {
- if(ami_download_window_event((struct gui_download_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_DLWINDOW) {
+ if(ami_download_window_event((struct gui_download_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
- }
- else if(node->Type == AMINS_LOGINWINDOW)
- {
- if(ami_401login_event((struct gui_login_window *)gwin))
- {
- if(IsMinListEmpty(window_list))
- {
- /* last window closed, so exit */
- ami_try_quit();
- }
+ } else if(node->Type == AMINS_LOGINWINDOW) {
+ if(ami_401login_event((struct gui_login_window *)gwin)) {
+ ami_try_quit();
break;
- }
- else
- {
+ } else {
node = nnode;
continue;
}
@@ -1821,6 +1759,7 @@ void ami_handle_msg(void)
switch(result & WMHI_GADGETMASK)
{
case GID_TABS:
+ if(gwin->objects[GID_TABS] == NULL) break;
GetAttrs(gwin->objects[GID_TABS],
CLICKTAB_NodeClosed, &tabnode, TAG_DONE);
if(tabnode)
@@ -1849,24 +1788,27 @@ void ami_handle_msg(void)
GetAttr(STRINGA_TextVal,
(Object *)gwin->objects[GID_URL],
(ULONG *)&storage);
- if(search_is_url((char *)storage) == false)
- {
- storage = (ULONG)search_web_from_term((char *)storage);
- }
- {
- if (nsurl_create((char *)storage, &url) != NSERROR_OK) {
+ if(utf8 = ami_to_utf8_easy((const char *)storage)) {
+ if(search_is_url((char *)utf8) == false)
+ {
+ utf8 = search_web_from_term(utf8);
+ }
+
+ if (nsurl_create((char *)utf8, &url) != NSERROR_OK) {
warn_user("NoMemory", 0);
} else {
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
nsurl_unref(url);
}
+ ami_utf8_free(utf8);
+ } else {
+ warn_user("NoMemory", 0);
}
break;
@@ -1879,21 +1821,24 @@ void ami_handle_msg(void)
GetAttr(STRINGA_TextVal,
(Object *)gwin->objects[GID_SEARCHSTRING],
(ULONG *)&storage);
- storage = (ULONG)search_web_from_term((char *)storage);
- {
+ if(utf8 = ami_to_utf8_easy((const char *)storage)) {
+ storage = (ULONG)search_web_from_term(utf8);
+ ami_utf8_free(utf8);
+
if (nsurl_create((char *)storage, &url) != NSERROR_OK) {
warn_user("NoMemory", 0);
} else {
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
nsurl_unref(url);
}
+ } else {
+ warn_user("NoMemory", 0);
}
break;
@@ -1905,8 +1850,7 @@ void ami_handle_msg(void)
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1948,7 +1892,6 @@ void ami_handle_msg(void)
GetAttr(STRINGA_TextVal,
(Object *)gwin->objects[GID_URL],
(ULONG *)&storage);
-
if(nsurl_create((const char *)storage, &url) == NSERROR_OK) {
if(hotlist_has_url(url)) {
hotlist_remove_url(url);
@@ -1957,7 +1900,6 @@ void ami_handle_msg(void)
}
nsurl_unref(url);
}
-
ami_gui_update_hotlist_button(gwin);
break;
@@ -1993,8 +1935,7 @@ void ami_handle_msg(void)
error = nsurl_create(nsoption_charp(homepage_url), &urlns);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
urlns,
NULL,
gwin->bw,
@@ -2015,9 +1956,8 @@ void ami_handle_msg(void)
error = nsurl_create(nsoption_charp(homepage_url), &urlns);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
urlns,
NULL,
gwin->bw,
@@ -2181,7 +2121,7 @@ void ami_handle_msg(void)
break;
case RAWKEY_HELP: // help
- ami_help_open(AMI_HELP_GUI);
+ ami_help_open(AMI_HELP_GUI, scrn);
break;
}
}
@@ -2389,8 +2329,7 @@ void ami_handle_appmsg(void)
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -2399,9 +2338,8 @@ void ami_handle_appmsg(void)
}
else
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
gwin->bw,
@@ -2430,8 +2368,7 @@ void ami_handle_appmsg(void)
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -2440,9 +2377,8 @@ void ami_handle_appmsg(void)
}
else
{
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
gwin->bw,
@@ -2481,8 +2417,7 @@ void ami_handle_applib(void)
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2505,8 +2440,7 @@ void ami_handle_applib(void)
error = nsurl_create(tempurl, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2561,13 +2495,13 @@ void ami_get_msg(void)
ULONG signal;
struct TimerRequest *timermsg = NULL;
struct MsgPort *printmsgport = ami_print_get_msgport();
- ULONG printsig = 1L << printmsgport->mp_SigBit;
- ULONG signalmask = winsignal | appsig | schedulesig | rxsig | printsig | applibsig | ctrlcsig;
+ ULONG printsig = 0;
+ ULONG helpsignal = ami_help_signal();
+ if(printmsgport) printsig = 1L << printmsgport->mp_SigBit;
+ ULONG signalmask = winsignal | appsig | schedulesig | rxsig | printsig | applibsig | ctrlcsig | helpsignal;
+
+ signal = Wait(signalmask);
- signal = Wait(signalmask);
-/*
-printf("sig recvd %ld (%ld %ld %ld %ld %ld %ld)\n", signal, winsignal , appsig , schedulesig , rxsig , printsig , applibsig);
-*/
if(signal & winsignal)
ami_handle_msg();
@@ -2580,25 +2514,23 @@ printf("sig recvd %ld (%ld %ld %ld %ld %ld %ld)\n", signal, winsignal , appsig ,
if(signal & applibsig)
ami_handle_applib();
- if(signal & printsig)
- {
+ if(signal & printsig) {
while(GetMsg(printmsgport)); //ReplyMsg
ami_print_cont();
}
- if(signal & schedulesig)
- {
- if(timermsg = (struct TimerRequest *)GetMsg(msgport))
- {
+ if(signal & schedulesig) {
+ if(timermsg = (struct TimerRequest *)GetMsg(msgport)) {
ReplyMsg((struct Message *)timermsg);
schedule_run(FALSE);
}
}
+ if(signal & helpsignal)
+ ami_help_process();
+
if(signal & ctrlcsig)
- {
ami_quit_netsurf_delayed();
- }
}
static void ami_gui_fetch_callback(void *p)
@@ -2612,7 +2544,7 @@ static void ami_gui_fetch_callback(void *p)
static void gui_poll(bool active)
{
- if(active) schedule(0, ami_gui_fetch_callback, NULL);
+ if(active) ami_schedule(0, ami_gui_fetch_callback, NULL);
ami_get_msg();
}
@@ -2692,61 +2624,51 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw)
gwin->bw->window->scrollx, gwin->bw->window->scrolly);
gwin->redraw_scroll = false;
- browser_window_refresh_url_bar(gwin->bw,
- hlcache_handle_get_url(gwin->bw->current_content), gwin->bw->frag_id);
+ browser_window_refresh_url_bar(gwin->bw);
ami_gui_update_hotlist_button(gwin);
}
}
-void ami_try_quit(void)
-{
- if(nsoption_bool(close_no_quit) == false)
- {
- netsurf_quit = true;
- return;
- }
- else
- {
- if(locked_screen == FALSE)
- if(CloseScreen(scrn)) scrn = NULL;
- }
-}
-
void ami_quit_netsurf(void)
{
struct nsObject *node;
struct nsObject *nnode;
struct gui_window_2 *gwin;
- if(!IsMinListEmpty(window_list))
- {
+ if(!IsMinListEmpty(window_list)) {
node = (struct nsObject *)GetHead((struct List *)window_list);
- do
- {
+ do {
nnode=(struct nsObject *)GetSucc((struct Node *)node);
gwin = node->objstruct;
- switch(node->Type)
- {
+ switch(node->Type) {
case AMINS_TVWINDOW:
ami_tree_close((struct treeview_window *)gwin);
break;
case AMINS_WINDOW:
+ /* This also closes windows that are attached to the
+ * gui_window, such as local history and find. */
ShowWindow(gwin->win, WINDOW_BACKMOST);
ami_close_all_tabs(gwin);
break;
- }
+ case AMINS_GUIOPTSWINDOW:
+ ami_gui_opts_close();
+ break;
+
+ case AMINS_DLWINDOW:
+ ami_download_window_abort((struct gui_download_window *)gwin);
+ break;
+ }
} while(node = nnode);
win_destroyed = true;
}
- if(IsMinListEmpty(window_list))
- {
+ if(IsMinListEmpty(window_list)) {
/* last window closed, so exit */
netsurf_quit = true;
}
@@ -2778,22 +2700,50 @@ void ami_quit_netsurf_delayed(void)
}
}
-void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen)
+void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen, BOOL donotwait)
{
- ULONG scrnsig = 1 << screen_signal;
-
if(scrn == NULL) return;
- if(CloseScreen(scrn)) return;
+ if(CloseScreen(scrn) == TRUE) {
+ if(locked_screen == FALSE) {
+ FreeSignal(screen_signal);
+ screen_signal = -1;
+ scrn = NULL;
+ }
+ return;
+ }
if(locked_screen == TRUE) return;
+ if(donotwait == TRUE) return;
/* If this is our own screen, wait for visitor windows to close */
- LOG(("Waiting for visitor windows to close... (signal)"));
- Wait(scrnsig);
+ if(screen_signal != -1) {
+ ULONG scrnsig = 1 << screen_signal;
+ LOG(("Waiting for visitor windows to close... (signal)"));
+ Wait(scrnsig);
+ }
while (CloseScreen(scrn) == FALSE) {
- LOG(("Still waiting for visitor windows to close... (polling)"));
+ LOG(("Waiting for visitor windows to close... (polling)"));
Delay(50);
}
+
+ FreeSignal(screen_signal);
+ screen_signal = -1;
+ scrn = NULL;
+}
+
+void ami_try_quit(void)
+{
+ if(!IsMinListEmpty(window_list)) return;
+
+ if(nsoption_bool(close_no_quit) == false)
+ {
+ netsurf_quit = true;
+ return;
+ }
+ else
+ {
+ ami_gui_close_screen(scrn, locked_screen, TRUE);
+ }
}
static void gui_quit(void)
@@ -2816,11 +2766,11 @@ static void gui_quit(void)
ami_free_layers(&browserglob);
ami_close_fonts();
+ ami_help_free();
LOG(("Closing screen"));
- ami_gui_close_screen(scrn, locked_screen);
+ ami_gui_close_screen(scrn, locked_screen, FALSE);
FreeVec(nsscreentitle);
- FreeSignal(screen_signal);
LOG(("Freeing menu items"));
ami_context_menu_free();
@@ -2831,16 +2781,12 @@ static void gui_quit(void)
LOG(("Freeing clipboard"));
ami_clipboard_free();
- ami_print_free();
-
FreeSysObject(ASOT_PORT,appport);
FreeSysObject(ASOT_PORT,sport);
- ami_help_free();
ami_file_req_free();
-
ami_openurl_close();
- FreeStringClass(urlStringClass);
+ FreeStringClass(urlStringClass);
if(IApplication) DropInterface((struct Interface *)IApplication);
if(ApplicationBase) CloseLibrary(ApplicationBase);
@@ -3149,6 +3095,11 @@ void ami_toggletabbar(struct gui_window_2 *gwin, bool show)
IDoMethod(gwin->objects[GID_TABLAYOUT], LM_REMOVECHILD,
gwin->win, gwin->objects[GID_ADDTAB]);
+
+ /* NB: We are NULLing these, but not disposing them as
+ * that causes an Intuition deadlock (TODO) */
+ gwin->objects[GID_TABS] = NULL;
+ gwin->objects[GID_ADDTAB] = NULL;
}
FlushLayoutDomainCache((struct Gadget *)gwin->objects[GID_MAIN]);
@@ -3197,9 +3148,8 @@ nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
gwin->bw,
@@ -3210,17 +3160,14 @@ nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
warn_user(messages_get_errorcode(error), 0);
return error;
}
-
- history_destroy(bw->history);
- bw->history = history_create();
return NSERROR_OK;
}
static struct gui_window *
gui_window_create(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
struct gui_window *g = NULL;
bool closegadg=TRUE;
@@ -3240,19 +3187,16 @@ gui_window_create(struct browser_window *bw,
if (!scrn) ami_openscreenfirst();
- if (nsoption_bool(kiosk_mode)) new_tab = false;
+ if (nsoption_bool(kiosk_mode)) flags &= ~GW_CREATE_TAB;
if (nsoption_bool(resize_with_contents)) idcmp_sizeverify = 0;
bw->scale = 1.0;
- if(clone)
+ if(existing)
{
- if(clone->window)
- {
- curx=clone->window->shared->win->LeftEdge;
- cury=clone->window->shared->win->TopEdge;
- curw=clone->window->shared->win->Width;
- curh=clone->window->shared->win->Height;
- }
+ curx=existing->shared->win->LeftEdge;
+ cury=existing->shared->win->TopEdge;
+ curw=existing->shared->win->Width;
+ curh=existing->shared->win->Height;
}
g = AllocVecTags(sizeof(struct gui_window), AVT_ClearWithValue, 0, TAG_DONE);
@@ -3266,9 +3210,9 @@ gui_window_create(struct browser_window *bw,
NewList(&g->dllist);
g->deferred_rects = NewObjList();
- if(new_tab && clone)
+ if((flags & GW_CREATE_TAB) && existing)
{
- g->shared = clone->window->shared;
+ g->shared = existing->shared;
g->tab = g->shared->next_tab;
if((g->shared->tabs == 1) && (nsoption_bool(tab_always_show) == false))
@@ -3291,12 +3235,12 @@ gui_window_create(struct browser_window *bw,
}
else
{
- struct Node *insert_after = clone->window->tab_node;
+ struct Node *insert_after = existing->tab_node;
- if(clone->window->last_new_tab)
- insert_after = clone->window->last_new_tab;
+ if(existing->last_new_tab)
+ insert_after = existing->last_new_tab;
Insert(&g->shared->tab_list, g->tab_node, insert_after);
- clone->window->last_new_tab = g->tab_node;
+ existing->last_new_tab = g->tab_node;
}
RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
@@ -3611,7 +3555,7 @@ gui_window_create(struct browser_window *bw,
GA_TabCycle, TRUE,
STRINGA_Buffer, g->shared->svbuffer,
STRINGVIEW_Header, URLHistory_GetList(),
- StringEnd,
+ TAG_DONE),
LAYOUT_AddChild, g->shared->objects[GID_FAVE] = ButtonObject,
GA_ID, GID_FAVE,
@@ -4112,19 +4056,19 @@ static void ami_redraw_callback(void *p)
*/
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw)
{
- int cs = 0;
+ int ms = 0;
if(full_redraw) gwin->redraw_required = true;
if(gwin->redraw_scheduled == true) return;
- if(gwin->bw->reformat_pending) cs = nsoption_int(reformat_delay);
- schedule(cs, ami_redraw_callback, gwin);
+ if(gwin->bw->reformat_pending) ms = nsoption_int(reformat_delay) * 10;
+ ami_schedule(ms, ami_redraw_callback, gwin);
gwin->redraw_scheduled = true;
}
static void ami_schedule_redraw_remove(struct gui_window_2 *gwin)
{
- schedule_remove(ami_redraw_callback, gwin);
+ ami_schedule(-1, ami_redraw_callback, gwin);
}
static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
@@ -4962,8 +4906,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
GetSpeedButtonNodeAttrs(node, SBNA_UserData, (ULONG *)&url, TAG_DONE);
if(gwin->key_state & BROWSER_MOUSE_MOD_2) {
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_TAB,
+ browser_window_create(BW_CREATE_TAB,
url,
NULL,
gwin->bw,
@@ -4972,8 +4915,7 @@ void ami_scroller_hook(struct Hook *hook,Object *object,struct IntuiMessage *msg
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -5197,6 +5139,7 @@ static struct gui_fetch_table amiga_fetch_table = {
static struct gui_browser_table amiga_browser_table = {
.poll = gui_poll,
+ .schedule = ami_schedule,
.quit = gui_quit,
.set_search_ico = gui_set_search_ico,
@@ -5223,6 +5166,8 @@ int main(int argc, char** argv)
.clipboard = amiga_clipboard_table,
.download = amiga_download_table,
.fetch = &amiga_fetch_table,
+ .utf8 = amiga_utf8_table,
+ .search = amiga_search_table,
};
/* Open popupmenu.library just to check the version.
diff --git a/amiga/gui.h b/amiga/gui.h
index 9470660..ad18750 100755
--- a/amiga/gui.h
+++ b/amiga/gui.h
@@ -153,6 +153,7 @@ struct gui_window
void ami_get_msg(void);
void ami_close_all_tabs(struct gui_window_2 *gwin);
+void ami_try_quit(void);
void ami_quit_netsurf(void);
void ami_schedule_redraw(struct gui_window_2 *gwin, bool full_redraw);
STRPTR ami_locale_langs(void);
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index a5568da..400ced8 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -406,9 +406,12 @@ void ami_gui_opts_open(void)
BOOL proxyhostdisabled = TRUE, proxyauthdisabled = TRUE, proxybypassdisabled = FALSE;
BOOL disableanims, animspeeddisabled = FALSE, acceptlangdisabled = FALSE;
BOOL scaleselected = nsoption_bool(scale_quality), scaledisabled = FALSE;
+ BOOL ditherdisable = TRUE;
BOOL download_notify_disabled = FALSE;
BOOL ptr_disable = FALSE;
char animspeed[10];
+ char *homepage_url_lc = ami_utf8_easy(nsoption_charp(homepage_url));
+
struct TextAttr fontsans, fontserif, fontmono, fontcursive, fontfantasy;
if(gow && gow->win)
@@ -446,6 +449,9 @@ void ami_gui_opts_open(void)
screenmodeid = strtoul(nsoption_charp(screen_modeid),NULL,0);
}
+ if(ami_plot_screen_is_palettemapped() == true)
+ ditherdisable = FALSE;
+
if(nsoption_bool(http_proxy) == true)
{
proxytype = nsoption_int(http_proxy_auth) + 1;
@@ -553,7 +559,7 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_HOMEPAGE] = StringObject,
GA_ID, GID_OPTS_HOMEPAGE,
GA_RelVerify, TRUE,
- STRINGA_TextVal, nsoption_charp(homepage_url),
+ STRINGA_TextVal, homepage_url_lc,
STRINGA_BufferPos,0,
StringEnd,
CHILD_Label, LabelObject,
@@ -907,6 +913,7 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_DITHERQ] = ChooserObject,
GA_ID, GID_OPTS_DITHERQ,
GA_RelVerify, TRUE,
+ GA_Disabled, ditherdisable,
CHOOSER_PopUp, TRUE,
CHOOSER_LabelArray, ditheropts,
CHOOSER_Selected, nsoption_int(dither_quality),
@@ -1524,6 +1531,7 @@ void ami_gui_opts_open(void)
gow->node = AddObject(window_list,AMINS_GUIOPTSWINDOW);
gow->node->objstruct = gow;
}
+ ami_utf8_free(homepage_url_lc);
}
void ami_gui_opts_use(bool save)
@@ -1538,7 +1546,7 @@ void ami_gui_opts_use(bool save)
ami_update_pointer(gow->win, GUI_POINTER_WAIT);
GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_HOMEPAGE],(ULONG *)&data);
- nsoption_set_charp(homepage_url, (char *)strdup((char *)data));
+ nsoption_set_charp(homepage_url, (char *)ami_to_utf8_easy((char *)data));
GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_CONTENTLANG],(ULONG *)&data);
nsoption_set_charp(accept_language, (char *)strdup((char *)data));
@@ -1930,10 +1938,10 @@ BOOL ami_gui_opts_event(void)
case WMHI_GADGETHELP:
if((result & WMHI_GADGETMASK) == 0) {
/* Pointer not over our window */
- ami_help_open(AMI_HELP_MAIN);
+ ami_help_open(AMI_HELP_MAIN, scrn);
} else {
/* TODO: Make this sensitive to the tab the user is currently on */
- ami_help_open(AMI_HELP_PREFS);
+ ami_help_open(AMI_HELP_PREFS, scrn);
}
break;
diff --git a/amiga/gui_options.h b/amiga/gui_options.h
index 0fd0715..2b57769 100755
--- a/amiga/gui_options.h
+++ b/amiga/gui_options.h
@@ -20,6 +20,7 @@
#define AMIGA_GUI_OPTIONS_H
void ami_gui_opts_open(void);
BOOL ami_gui_opts_event(void);
+void ami_gui_opts_close(void);
char *current_user_options;
#endif
diff --git a/amiga/help.c b/amiga/help.c
index 214e59d..8914440 100755
--- a/amiga/help.c
+++ b/amiga/help.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2013-4 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -45,8 +45,9 @@ void ami_help_init(struct Screen *screen)
TAG_DONE);
}
-void ami_help_open(ULONG node)
+void ami_help_open(ULONG node, struct Screen *screen)
{
+ if(AmigaGuideObject == NULL) ami_help_init(screen);
SetAttrs(AmigaGuideObject, AMIGAGUIDE_ContextID, node, TAG_DONE);
IDoMethod(AmigaGuideObject, AGM_OPEN, NULL);
}
@@ -62,5 +63,21 @@ void ami_help_free(void)
void ami_help_new_screen(struct Screen *screen)
{
+ if(AmigaGuideObject == NULL) return;
SetAttrs(AmigaGuideObject, AMIGAGUIDE_Screen, screen, TAG_DONE);
}
+
+ULONG ami_help_signal(void)
+{
+ ULONG ag_sig = 0;
+ if(AmigaGuideObject)
+ GetAttr(AMIGAGUIDE_Signal, AmigaGuideObject, &ag_sig);
+ return ag_sig;
+}
+
+void ami_help_process(void)
+{
+ ULONG ret = IDoMethod(AmigaGuideObject, AGM_PROCESS, NULL);
+ if(ret) ami_help_free();
+}
+
diff --git a/amiga/help.h b/amiga/help.h
index 4baa2a0..e405edd 100755
--- a/amiga/help.h
+++ b/amiga/help.h
@@ -29,8 +29,10 @@ enum {
struct Screen;
-void ami_help_init(struct Screen *screen);
-void ami_help_open(ULONG node);
+void ami_help_open(ULONG node, struct Screen *screen);
void ami_help_free(void);
void ami_help_new_screen(struct Screen *screen);
+ULONG ami_help_signal(void);
+void ami_help_process(void);
#endif
+
diff --git a/amiga/history_local.c b/amiga/history_local.c
index b5aba38..1f710b2 100755
--- a/amiga/history_local.c
+++ b/amiga/history_local.c
@@ -25,8 +25,8 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "amiga/os3support.h"
#include "amiga/object.h"
@@ -52,7 +52,7 @@
#include <reaction/reaction.h>
#include <reaction/reaction_macros.h>
-static struct history *history_current = 0;
+static struct browser_window *history_bw;
/* Last position of mouse in window. */
static int mouse_x = 0;
/* Last position of mouse in window. */
@@ -78,7 +78,7 @@ void ami_history_open(struct browser_window *bw, struct history *history)
assert(history);
- history_current = history;
+ history_bw = bw;
if(!hwindow)
{
@@ -87,7 +87,7 @@ void ami_history_open(struct browser_window *bw, struct history *history)
ami_init_layers(&hwindow->gg, scrn->Width, scrn->Height);
hwindow->bw = bw;
- history_size(history, &width, &height);
+ browser_window_history_size(bw, &width, &height);
hwindow->scrollerhook.h_Entry = (void *)ami_history_scroller_hook;
hwindow->scrollerhook.h_Data = hwindow;
@@ -173,7 +173,7 @@ void ami_history_redraw(struct history_window *hw)
SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE);
RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1);
- history_redraw_rectangle(history_current, xs, ys,
+ browser_window_history_redraw_rectangle(history_bw, xs, ys,
bbox->Width + xs, bbox->Height + ys, 0, 0, &ctx);
glob = &browserglob;
@@ -210,13 +210,13 @@ bool ami_history_click(struct history_window *hw,uint16 code)
switch(code)
{
case SELECTUP:
- history_click(hw->bw,history_current,x,y,false);
+ browser_window_history_click(history_bw,x,y,false);
ami_history_redraw(hw);
ami_schedule_redraw(hw->bw->window->shared, true);
break;
case MIDDLEUP:
- history_click(hw->bw,history_current,x,y,true);
+ browser_window_history_click(history_bw,x,y,true);
ami_history_redraw(hw);
break;
@@ -265,7 +265,7 @@ BOOL ami_history_event(struct history_window *hw)
GetAttr(SCROLLER_Top, hw->objects[OID_HSCROLL], (ULONG *)&xs);
GetAttr(SCROLLER_Top, hw->objects[OID_VSCROLL], (ULONG *)&ys);
- url = history_position_url(history_current,
+ url = browser_window_history_position_url(history_bw,
hw->win->MouseX - bbox->Left + xs,
hw->win->MouseY - bbox->Top + ys);
@@ -297,7 +297,7 @@ void ami_history_update_extent(struct history_window *hw)
struct IBox *bbox;
int width, height;
- history_size(hw->bw->history, &width, &height);
+ browser_window_history_size(hw->bw, &width, &height);
GetAttr(SPACE_AreaBox,hw->objects[GID_BROWSER],(ULONG *)&bbox);
RefreshSetGadgetAttrs((APTR)hw->objects[OID_VSCROLL],hw->win,NULL,
diff --git a/amiga/menu.c b/amiga/menu.c
index 26f5c2b..13b9c9c 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -58,13 +58,13 @@
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
+#include "amiga/schedule.h"
#include "desktop/hotlist.h"
#include "desktop/browser_private.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/textinput.h"
#include "utils/messages.h"
-#include "utils/schedule.h"
+
enum {
NSA_GLYPH_SUBMENU,
@@ -482,7 +482,11 @@ struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
/* Set up scheduler to refresh the hotlist menu */
if(nsoption_int(menu_refresh) > 0)
- schedule(nsoption_int(menu_refresh), (void *)ami_menu_refresh, gwin);
+ {
+ ami_schedule(nsoption_int(menu_refresh) * 10,
+ (void *)ami_menu_refresh,
+ gwin);
+ }
return(gwin->menu);
}
@@ -698,8 +702,7 @@ static void ami_menu_item_project_newwin(struct Hook *hook, APTR window, struct
error = nsurl_create(nsoption_charp(homepage_url), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -811,8 +814,7 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I
if(url) {
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -1036,8 +1038,7 @@ static void ami_menu_item_hotlist_entries(struct Hook *hook, APTR window, struct
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
diff --git a/amiga/print.c b/amiga/print.c
index 4bfce13..93dde35 100644
--- a/amiga/print.c
+++ b/amiga/print.c
@@ -378,7 +378,8 @@ void ami_print(struct hlcache_handle *c, int copies)
double height, print_height;
float scale = nsoption_int(print_scale) / 100.0;
- if(!ami_print_info.msgport) return;
+ if(ami_print_info.msgport == NULL)
+ ami_print_init();
if(!(ami_print_info.PReq =
(struct IODRPTagsReq *)AllocSysObjectTags(ASOT_IOREQUEST,
@@ -450,7 +451,8 @@ struct MsgPort *ami_print_init(void)
void ami_print_free(void)
{
- FreeSysObject(ASOT_PORT,ami_print_info.msgport);
+ FreeSysObject(ASOT_PORT, ami_print_info.msgport);
+ ami_print_info.msgport = NULL;
}
struct MsgPort *ami_print_get_msgport(void)
@@ -491,6 +493,7 @@ void ami_print_end(void)
glob = &browserglob;
ami_print_close_device();
+ ami_print_free();
}
void ami_print_close_device(void)
diff --git a/amiga/schedule.c b/amiga/schedule.c
index d4b35a5..9aa7488 100755
--- a/amiga/schedule.c
+++ b/amiga/schedule.c
@@ -16,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "utils/schedule.h"
#include "amiga/os3support.h"
-#include "amiga/schedule.h"
#include <proto/exec.h>
#include <proto/timer.h>
@@ -27,6 +25,10 @@
#include <stdbool.h>
#include <pbl.h>
+#include "utils/errors.h"
+
+#include "amiga/schedule.h"
+
struct nscallback
{
struct TimeVal tv;
@@ -37,51 +39,18 @@ struct nscallback
PblHeap *schedule_list;
-void ami_remove_timer_event(struct nscallback *nscb);
-
-/**
- * Schedule a callback.
- *
- * \param t interval before the callback should be made / cs
- * \param callback callback function
- * \param p user parameter, passed to callback function
- *
- * The callback function will be called as soon as possible after t cs have
- * passed.
- */
-
-void schedule(int t, void (*callback)(void *p), void *p)
+static void ami_remove_timer_event(struct nscallback *nscb)
{
- struct nscallback *nscb;
- struct TimeVal tv;
- ULONG time_us = 0;
-
- if(schedule_list == NULL) return;
-
- nscb = AllocVecTagList(sizeof(struct nscallback), NULL);
if(!nscb) return;
- time_us = t*10000; /* t converted to �s */
-
- nscb->tv.Seconds = time_us / 1000000;
- nscb->tv.Microseconds = time_us % 1000000;
-
- GetSysTime(&tv);
- AddTime(&nscb->tv,&tv); // now contains time when event occurs
-
- if(nscb->treq = AllocVecTagList(sizeof(struct TimeRequest), NULL))
+ if(nscb->treq)
{
- *nscb->treq = *tioreq;
- nscb->treq->Request.io_Command=TR_ADDREQUEST;
- nscb->treq->Time.Seconds=nscb->tv.Seconds; // secs
- nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro
- SendIO((struct IORequest *)nscb->treq);
- }
-
- nscb->callback = callback;
- nscb->p = p;
+ if(CheckIO((struct IORequest *)nscb->treq)==NULL)
+ AbortIO((struct IORequest *)nscb->treq);
- pblHeapInsert(schedule_list, nscb);
+ WaitIO((struct IORequest *)nscb->treq);
+ FreeVec(nscb->treq);
+ }
}
/**
@@ -93,14 +62,22 @@ void schedule(int t, void (*callback)(void *p), void *p)
* All scheduled callbacks matching both callback and p are removed.
*/
-void schedule_remove(void (*callback)(void *p), void *p)
+static nserror schedule_remove(void (*callback)(void *p), void *p)
{
PblIterator *iterator;
struct nscallback *nscb;
bool restoreheap = false;
- if(schedule_list == NULL) return;
- if(pblHeapIsEmpty(schedule_list)) return;
+ /* check there is something on the list to remove */
+ if (schedule_list == NULL)
+ {
+ return NSERROR_OK;
+ }
+
+ if(pblHeapIsEmpty(schedule_list))
+ {
+ return NSERROR_OK;
+ }
iterator = pblHeapIterator(schedule_list);
@@ -117,10 +94,15 @@ void schedule_remove(void (*callback)(void *p), void *p)
pblIteratorFree(iterator);
- if(restoreheap) pblHeapConstruct(schedule_list);
+ if(restoreheap)
+ {
+ pblHeapConstruct(schedule_list);
+ }
+
+ return NSERROR_OK;
}
-void schedule_remove_all(void)
+static void schedule_remove_all(void)
{
PblIterator *iterator;
struct nscallback *nscb;
@@ -139,13 +121,16 @@ void schedule_remove_all(void)
pblIteratorFree(iterator);
}
-/**
- * Process events up to current time.
- * This implementation only takes the top entry off the heap, it does not
- * venture to later scheduled events until the next time it is called -
- * immediately afterwards, if we're in a timer signalled loop.
- */
+static int ami_schedule_compare(const void *prev, const void *next)
+{
+ struct nscallback *nscb1 = *(struct nscallback **)prev;
+ struct nscallback *nscb2 = *(struct nscallback **)next;
+
+ return CmpTime(&nscb1->tv, &nscb2->tv);
+}
+
+/* exported function documented in amiga/schedule.h */
void schedule_run(BOOL poll)
{
struct nscallback *nscb;
@@ -176,28 +161,7 @@ void schedule_run(BOOL poll)
callback(p);
}
-void ami_remove_timer_event(struct nscallback *nscb)
-{
- if(!nscb) return;
-
- if(nscb->treq)
- {
- if(CheckIO((struct IORequest *)nscb->treq)==NULL)
- AbortIO((struct IORequest *)nscb->treq);
-
- WaitIO((struct IORequest *)nscb->treq);
- FreeVec(nscb->treq);
- }
-}
-
-int ami_schedule_compare(const void *prev, const void *next)
-{
- struct nscallback *nscb1 = *(struct nscallback **)prev;
- struct nscallback *nscb2 = *(struct nscallback **)next;
-
- return CmpTime(&nscb1->tv, &nscb2->tv);
-}
-
+/* exported function documented in amiga/schedule.h */
BOOL ami_schedule_create(void)
{
schedule_list = pblHeapNew();
@@ -206,6 +170,7 @@ BOOL ami_schedule_create(void)
pblHeapSetCompareFunction(schedule_list, ami_schedule_compare);
}
+/* exported function documented in amiga/schedule.h */
void ami_schedule_free(void)
{
schedule_remove_all();
@@ -213,6 +178,7 @@ void ami_schedule_free(void)
schedule_list = NULL;
}
+/* exported function documented in amiga/schedule.h */
void ami_schedule_open_timer(void)
{
msgport = AllocSysObjectTags(ASOT_PORT,
@@ -231,6 +197,7 @@ void ami_schedule_open_timer(void)
ITimer = (struct TimerIFace *)GetInterface((struct Library *)TimerBase,"main",1,NULL);
}
+/* exported function documented in amiga/schedule.h */
void ami_schedule_close_timer(void)
{
if(ITimer)
@@ -242,3 +209,51 @@ void ami_schedule_close_timer(void)
FreeSysObject(ASOT_IOREQUEST,tioreq);
FreeSysObject(ASOT_PORT,msgport);
}
+
+/* exported function documented in amiga/schedule.h */
+nserror ami_schedule(int t, void (*callback)(void *p), void *p)
+{
+ struct nscallback *nscb;
+ struct TimeVal tv;
+ ULONG time_us = 0;
+
+ if(schedule_list == NULL)
+ {
+ return NSERROR_INIT_FAILED;
+ }
+
+ if(t < 0)
+ {
+ return schedule_remove(callback, p);
+ }
+
+ nscb = AllocVecTagList(sizeof(struct nscallback), NULL);
+ if(!nscb)
+ {
+ return NSERROR_NOMEM;
+ }
+
+ time_us = t * 1000; /* t converted to �s */
+
+ nscb->tv.Seconds = time_us / 1000000;
+ nscb->tv.Microseconds = time_us % 1000000;
+
+ GetSysTime(&tv);
+ AddTime(&nscb->tv,&tv); // now contains time when event occurs
+
+ if(nscb->treq = AllocVecTagList(sizeof(struct TimeRequest), NULL))
+ {
+ *nscb->treq = *tioreq;
+ nscb->treq->Request.io_Command=TR_ADDREQUEST;
+ nscb->treq->Time.Seconds=nscb->tv.Seconds; // secs
+ nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro
+ SendIO((struct IORequest *)nscb->treq);
+ }
+
+ nscb->callback = callback;
+ nscb->p = p;
+
+ pblHeapInsert(schedule_list, nscb);
+
+ return NSERROR_OK;
+}
diff --git a/amiga/schedule.h b/amiga/schedule.h
index 3eddc89..6592306 100755
--- a/amiga/schedule.h
+++ b/amiga/schedule.h
@@ -19,7 +19,6 @@
#ifndef AMIGA_SCHEDULE_H
#define AMIGA_SCHEDULE_H
#include <proto/timer.h>
-#include "utils/schedule.h"
#include "amiga/os3support.h"
struct Device *TimerBase;
@@ -28,9 +27,42 @@ struct TimerIFace *ITimer;
struct TimeRequest *tioreq;
struct MsgPort *msgport;
-void ami_schedule_open_timer(void);
-void ami_schedule_close_timer(void);
+/**
+ * Schedule a callback.
+ *
+ * \param t interval before the callback should be made / ms
+ * \param callback callback function
+ * \param p user parameter, passed to callback function
+ * \return NSERROR_OK on sucess or appropriate error on faliure
+ *
+ * The callback function will be called as soon as possible after t ms have
+ * passed.
+ */
+nserror ami_schedule(int t, void (*callback)(void *p), void *p);
+
+/**
+ * Initialise amiga scheduler
+ *
+ * /return true if initialised ok or false on error.
+ */
BOOL ami_schedule_create(void);
+
+/**
+ * Finalise amiga scheduler
+ *
+ */
void ami_schedule_free(void);
+
+/**
+ * Process events up to current time.
+ *
+ * This implementation only takes the top entry off the heap, it does not
+ * venture to later scheduled events until the next time it is called -
+ * immediately afterwards, if we're in a timer signalled loop.
+ */
void schedule_run(BOOL poll);
+
+void ami_schedule_open_timer(void);
+void ami_schedule_close_timer(void);
+
#endif
diff --git a/amiga/search.c b/amiga/search.c
index 17a2d45..5375414 100755
--- a/amiga/search.c
+++ b/amiga/search.c
@@ -69,14 +69,15 @@ static void ami_search_add_recent(const char *string, void *p);
static void ami_search_set_forward_state(bool active, void *p);
static void ami_search_set_back_state(bool active, void *p);
-static struct gui_search_callbacks ami_search_callbacks = {
- ami_search_set_forward_state,
- ami_search_set_back_state,
+static struct gui_search_table search_table = {
ami_search_set_status,
ami_search_set_hourglass,
- ami_search_add_recent
+ ami_search_add_recent,
+ ami_search_set_forward_state,
+ ami_search_set_back_state,
};
+struct gui_search_table *amiga_search_table = &search_table;
/**
* Change the displayed search status.
@@ -90,8 +91,6 @@ void ami_search_open(struct gui_window *gwin)
if(fwin)
{
browser_window_search_clear(fwin->gwin->shared->bw);
- ami_search_set_forward_state(true, NULL);
- ami_search_set_back_state(true, NULL);
fwin->gwin->shared->searchwin = NULL;
fwin->gwin = gwin;
gwin->shared->searchwin = fwin;
@@ -177,8 +176,6 @@ void ami_search_open(struct gui_window *gwin)
void ami_search_close(void)
{
browser_window_search_clear(fwin->gwin->shared->bw);
- ami_search_set_forward_state(true, NULL);
- ami_search_set_back_state(true, NULL);
fwin->gwin->shared->searchwin = NULL;
DisposeObject(fwin->objects[OID_MAIN]);
DelObject(fwin->node);
@@ -201,12 +198,7 @@ BOOL ami_search_event(void)
switch(result & WMHI_GADGETMASK)
{
case GID_SEARCHSTRING:
- browser_window_search_clear(
- fwin->gwin->shared->bw);
- ami_search_set_forward_state(
- true, NULL);
- ami_search_set_back_state(
- true, NULL);
+ browser_window_search_clear(fwin->gwin->shared->bw);
RefreshSetGadgetAttrs((struct Gadget *)fwin->objects[GID_PREV],
fwin->win, NULL,
@@ -226,7 +218,7 @@ BOOL ami_search_event(void)
ami_search_flags();
browser_window_search(
fwin->gwin->shared->bw,
- &ami_search_callbacks, NULL,
+ NULL,
flags, ami_search_string());
ActivateWindow(fwin->gwin->shared->win);
break;
@@ -237,7 +229,7 @@ BOOL ami_search_event(void)
ami_search_flags();
browser_window_search(
fwin->gwin->shared->bw,
- &ami_search_callbacks, NULL,
+ NULL,
flags, ami_search_string());
ActivateWindow(fwin->gwin->shared->win);
break;
diff --git a/amiga/search.h b/amiga/search.h
index fde7302..ce5ae7c 100755
--- a/amiga/search.h
+++ b/amiga/search.h
@@ -28,6 +28,8 @@ struct find_window {
struct gui_window *gwin;
};
+struct gui_search_table *amiga_search_table;
+
void ami_search_open(struct gui_window *gwin);
BOOL ami_search_event(void);
void ami_search_close(void);
diff --git a/amiga/theme.c b/amiga/theme.c
index 0da15ac..e00e080 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -470,10 +470,10 @@ void gui_window_stop_throbber(struct gui_window *g)
// g->shared->throbber_frame = 0;
}
-void ami_update_throbber(struct gui_window_2 *g,bool redraw)
+void ami_update_throbber(struct gui_window_2 *g, bool redraw)
{
struct IBox *bbox;
- int frame = g->throbber_frame;
+ int frame;
if(!g) return;
if(!g->objects[GID_THROBBER]) return;
@@ -481,10 +481,12 @@ void ami_update_throbber(struct gui_window_2 *g,bool redraw)
if(g->bw->window->throbbing == false)
{
frame = 0;
- g->throbber_frame=1;
+ g->throbber_frame = 1;
}
else
{
+ frame = g->throbber_frame;
+
if(!redraw)
{
if(g->throbber_update_count < throbber_update_interval)
diff --git a/amiga/tree.c b/amiga/tree.c
index 42eae4f..df6ac9b 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -322,8 +322,7 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y)
browser_window_navigate(gwin->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1391,11 +1390,11 @@ void ami_tree_redraw_request(int x, int y, int width, int height, void *data)
atrr_data->height = height;
atrr_data->twin = (struct treeview_window *)data;
- /**TODO: Queue these requests properly like the main browser code does
+ /** /todo Queue these requests properly like the main browser code does
**/
if(nsoption_bool(direct_render) == false)
- schedule(0, ami_tree_redraw_req, atrr_data);
+ ami_schedule(0, ami_tree_redraw_req, atrr_data);
else
- schedule(0, ami_tree_redraw_req_dr, atrr_data);
+ ami_schedule(0, ami_tree_redraw_req_dr, atrr_data);
}
diff --git a/amiga/utf8.c b/amiga/utf8.c
index d182492..a8e415d 100755
--- a/amiga/utf8.c
+++ b/amiga/utf8.c
@@ -18,13 +18,44 @@
#include <stdlib.h>
#include <string.h>
-
#include <sys/types.h>
+
#include "utils/utf8.h"
+#include "desktop/gui.h"
#include <proto/exec.h>
#include <proto/diskfont.h>
#include <diskfont/diskfonttag.h>
+#include "amiga/utf8.h"
+
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
+{
+ const char *encname = "ISO-8859-1";
+
+#ifdef __amigaos4__
+ LONG charset;
+
+ charset = GetDiskFontCtrl(DFCTRL_CHARSET);
+ encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
+#endif
+
+ return utf8_from_enc(string,encname,len,result,NULL);
+}
+
+nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
+{
+ const char *encname = "ISO-8859-1";
+
+#ifdef __amigaos4__
+ LONG charset;
+
+ charset = GetDiskFontCtrl(DFCTRL_CHARSET);
+ encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
+#endif
+
+ return utf8_to_enc(string,encname,len,result);
+}
+
void ami_utf8_free(char *ptr)
{
if(ptr) free(ptr);
@@ -58,32 +89,10 @@ char *ami_to_utf8_easy(const char *string)
}
}
-nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
-{
- const char *encname = "ISO-8859-1";
-
-#ifdef __amigaos4__
- LONG charset;
-
- charset = GetDiskFontCtrl(DFCTRL_CHARSET);
- encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
-#endif
-
- return utf8_from_enc(string,encname,len,result,NULL);
-}
-
-nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
-{
- const char *encname = "ISO-8859-1";
-
-#ifdef __amigaos4__
- LONG charset;
-
- charset = GetDiskFontCtrl(DFCTRL_CHARSET);
- encname = (const char *) ObtainCharsetInfo(DFCS_NUMBER, charset, DFCS_MIMENAME);
-#endif
-
- return utf8_to_enc(string,encname,len,result);
-}
+static struct gui_utf8_table utf8_table = {
+ .utf8_to_local = utf8_to_local_encoding,
+ .local_to_utf8 = utf8_from_local_encoding,
+};
+struct gui_utf8_table *amiga_utf8_table = &utf8_table;
diff --git a/amiga/utf8.h b/amiga/utf8.h
index 7956523..065a149 100755
--- a/amiga/utf8.h
+++ b/amiga/utf8.h
@@ -18,7 +18,14 @@
#ifndef AMIGA_UTF8_H
#define AMIGA_UTF8_H
+
+extern struct gui_utf8_table *ami_utf8_table;
+
char *ami_utf8_easy(const char *string);
void ami_utf8_free(char *ptr);
char *ami_to_utf8_easy(const char *string);
+
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
+nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
+
#endif
diff --git a/atari/Makefile.defaults b/atari/Makefile.defaults
index d4ef023..dcdc1d6 100644
--- a/atari/Makefile.defaults
+++ b/atari/Makefile.defaults
@@ -2,57 +2,56 @@
# Atari-specific options
# ----------------------------------------------------------------------------
- # Force using glibc internal iconv implementation instead of external libiconv
- # Valid options: YES, NO
- NETSURF_USE_LIBICONV_PLUG := NO
+# Force using glibc internal iconv implementation instead of external libiconv
+# Valid options: YES, NO
+NETSURF_USE_LIBICONV_PLUG := NO
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := NO
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := NO
- # Enable NetSurf's use of libwebp for displaying WebPs
- # Valid options: YES, NO
- NETSURF_USE_WEBP := NO
+# Enable NetSurf's use of libwebp for displaying WebPs
+# Valid options: YES, NO
+NETSURF_USE_WEBP := NO
- # Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_RSVG := AUTO
+# Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_RSVG := AUTO
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_NSSVG := AUTO
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_NSSVG := AUTO
- # Enable Spidermonkey JavaScript engine
- # Valid options: YES, NO
- NETSURF_USE_MOZJS := NO
+# Enable Spidermonkey JavaScript engine
+# Valid options: YES, NO
+NETSURF_USE_MOZJS := NO
- # enable true type fonts via freetype2
- # Valid options: YES, NO
- NETSURF_USE_ATARI_FREETYPE_FONT := YES
+# enable true type fonts via freetype2
+# Valid options: YES, NO
+NETSURF_USE_ATARI_FREETYPE_FONT := YES
- # Enable use of netsurf embedded font
- # Valid options: YES, NO
- NETSURF_USE_ATARI_NETSURF_FONT := YES
+# Enable use of netsurf embedded font
+# Valid options: YES, NO
+NETSURF_USE_ATARI_NETSURF_FONT := YES
- # Enable VDI Font rendering
- # Valid options: YES, NO
- NETSURF_USE_ATARI_VDI_FONT := NO
+# Enable VDI Font rendering
+# Valid options: YES, NO
+NETSURF_USE_ATARI_VDI_FONT := NO
- # Configure support for screen drivers with no true colour mode
- # Valid options: YES, NO
- NETSURF_USE_ATARI_8BPP_SUPPORT := NO
+# Configure support for screen drivers with no true colour mode
+# Valid options: YES, NO
+NETSURF_USE_ATARI_8BPP_SUPPORT := NO
- # Configure the CPU target
- # Valid options: 68000, 68020-60, 5475 (coldfire)
- ATARIARCH = 68020-60
+# Configure the CPU target
+# Valid options: 68000, 68020-60, 5475 (coldfire)
+ATARIARCH = 68020-60
- # enable optimizations
- # -O2 is currently broken with m68000 / m68020-60 builds
- CFLAGS += -O3
+# enable optimizations
+# -O2 is currently broken with m68000 / m68020-60 builds
+CFLAGS += -O3
- # override warning flags removing -Wall
- WARNFLAGS = -W -Wundef -Wpointer-arith \
+# override warning flags removing -Wall
+WARNFLAGS = -W -Wundef -Wpointer-arith \
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
-Wnested-externs -Wuninitialized -Wl,-t
-
diff --git a/atari/about.c b/atari/about.c
index f09dfb3..6e98058 100644
--- a/atari/about.c
+++ b/atari/about.c
@@ -170,8 +170,7 @@ void atari_about_show(void)
if (goto_url != NULL) {
nserr = nsurl_create(goto_url, &url);
if (nserr == NSERROR_OK) {
- nserr = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ nserr = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/atari/certview.c b/atari/certview.c
index 6877529..0238e5a 100644
--- a/atari/certview.c
+++ b/atari/certview.c
@@ -25,6 +25,7 @@
#include "desktop/browser.h"
#include "content/urldb.h"
+#include "content/hlcache.h"
#include "desktop/sslcert_viewer.h"
#include "desktop/gui.h"
#include "desktop/core_window.h"
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index ae918c6..aeed475 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -238,8 +238,7 @@ void context_popup(struct gui_window * gw, short x, short y)
gw->browser->bw,
hlcache_handle_get_url(ctx->ccdata.object),
hlcache_handle_get_url(gw->browser->bw->current_content),
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL
@@ -258,8 +257,7 @@ void context_popup(struct gui_window * gw, short x, short y)
gw->browser->bw,
url,
hlcache_handle_get_url(gw->browser->bw->current_content),
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL
@@ -293,11 +291,11 @@ void context_popup(struct gui_window * gw, short x, short y)
nsurl *url;
nserror error;
- error = nsurl_create(ctx->ccdata.link_url, &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
- url,
+ error = nsurl_create(ctx->ccdata.link_url, &url);
+ if (error == NSERROR_OK) {
+ error = browser_window_create(
+ BW_CREATE_HISTORY | BW_CREATE_CLONE,
+ url,
hlcache_handle_get_url(gw->browser->bw->current_content),
gw->browser->bw,
NULL
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index ee8855c..6a8376d 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -2,12 +2,12 @@
#include <cflib.h>
#include "utils/log.h"
-#include "utils/messages.h"
+#include "utils/messages.h"
#include "utils/url.h"
#include "desktop/browser.h"
#include "desktop/browser_private.h"
#include "utils/nsoption.h"
-#include "desktop/save_complete.h"
+#include "desktop/save_complete.h"
#include "atari/res/netsurf.rsh"
#include "atari/gemtk/gemtk.h"
#include "atari/deskmenu.h"
@@ -170,8 +170,7 @@ static void __CDECL menu_about(short item, short title, void *data)
error = nsurl_create(buf, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -202,8 +201,7 @@ static void __CDECL menu_new_win(short item, short title, void *data)
/* create an initial browser window */
error = nsurl_create(addr, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -224,8 +222,7 @@ static void __CDECL menu_open_url(short item, short title, void *data)
gw = input_window;
if( gw == NULL ) {
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ browser_window_create(BW_CREATE_HISTORY,
NULL,
NULL,
NULL,
@@ -256,8 +253,7 @@ static void __CDECL menu_open_file(short item, short title, void *data)
error = nsurl_create(urltxt, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/atari/download.c b/atari/download.c
index 8d4786e..dc4b727 100755
--- a/atari/download.c
+++ b/atari/download.c
@@ -28,7 +28,6 @@
#include "content/urldb.h"
#include "content/fetch.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
diff --git a/atari/encoding.c b/atari/encoding.c
index 626f57a..7a60eee 100644
--- a/atari/encoding.c
+++ b/atari/encoding.c
@@ -16,6 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
+
+#include "desktop/gui.h"
+
#include "atari/encoding.h"
@@ -67,3 +71,9 @@ int atari_to_ucs4(unsigned char atari)
}
+static struct gui_utf8_table utf8_table = {
+ .utf8_to_local = utf8_to_local_encoding,
+ .local_to_utf8 = utf8_from_local_encoding,
+};
+
+struct gui_utf8_table *atari_utf8_table = &utf8_table;
diff --git a/atari/encoding.h b/atari/encoding.h
index c85bac9..d0289b6 100644
--- a/atari/encoding.h
+++ b/atari/encoding.h
@@ -1,32 +1,37 @@
-/*
- * Copyright 2012 Ole Loots <ole(a)monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+ * Copyright 2012 Ole Loots <ole(a)monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NS_ATARI_ENCODING_H
#define NS_ATARI_ENCODING_H
-#include <inttypes.h>
-#include <assert.h>
+#include <inttypes.h>
+#include <assert.h>
#include <stdbool.h>
-#include "css/css.h"
+#include "css/css.h"
#include "render/font.h"
-#include "utils/utf8.h"
-
+#include "utils/utf8.h"
+
+struct gui_utf8_table *atari_utf8_table;
+
+nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
+
int atari_to_ucs4( unsigned char atarichar);
#endif
diff --git a/atari/gui.c b/atari/gui.c
index af5e1f8..4e077bd 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -30,16 +30,18 @@
#include <stdbool.h>
#include <hubbub/hubbub.h>
+#include "utils/url.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/nsoption.h"
#include "content/urldb.h"
#include "content/fetch.h"
#include "content/fetchers/resource.h"
#include "css/utils.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "desktop/netsurf.h"
-
-#include "utils/nsoption.h"
#include "desktop/save_complete.h"
#include "desktop/textinput.h"
#include "desktop/treeview.h"
@@ -47,11 +49,6 @@
#include "desktop/browser_private.h"
#include "desktop/mouse.h"
#include "render/font.h"
-#include "utils/schedule.h"
-#include "utils/url.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
#include "atari/gemtk/gemtk.h"
#include "atari/gui.h"
@@ -212,11 +209,11 @@ static void gui_poll(bool active)
static struct gui_window *
gui_window_create(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab) {
+ struct gui_window *existing,
+ gui_window_create_flags flags) {
struct gui_window *gw=NULL;
- LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
- (int)new_tab
+ LOG(( "gw: %p, BW: %p, existing %p, flags: %d\n" , gw, bw, existing,
+ (int)flags
));
gw = calloc(1, sizeof(struct gui_window));
@@ -224,7 +221,7 @@ gui_window_create(struct browser_window *bw,
return NULL;
LOG(("new window: %p, bw: %p\n", gw, bw));
- window_create(gw, bw, clone, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
+ window_create(gw, bw, existing, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
|WIDGET_SCROLL);
if (gw->root->win) {
GRECT pos = {
@@ -599,7 +596,7 @@ static void throbber_advance( void * data )
return;
toolbar_throbber_progress(gw->root->toolbar);
- schedule(100, throbber_advance, gw );
+ atari_schedule(1000, throbber_advance, gw );
}
static void gui_window_start_throbber(struct gui_window *w)
@@ -609,7 +606,7 @@ static void gui_window_start_throbber(struct gui_window *w)
return;
toolbar_set_throbber_state(w->root->toolbar, true);
- schedule(100, throbber_advance, w );
+ atari_schedule(1000, throbber_advance, w );
rendering = true;
}
@@ -620,7 +617,7 @@ static void gui_window_stop_throbber(struct gui_window *w)
if (w->root->toolbar->throbber.running == false)
return;
- schedule_remove(throbber_advance, w);
+ atari_schedule(-1, throbber_advance, w);
toolbar_set_throbber_state(w->root->toolbar, false);
@@ -1086,6 +1083,7 @@ static struct gui_fetch_table atari_fetch_table = {
static struct gui_browser_table atari_browser_table = {
.poll = gui_poll,
+ .schedule = atari_schedule,
.quit = gui_quit,
.cert_verify = gui_cert_verify,
@@ -1113,6 +1111,8 @@ int main(int argc, char** argv)
.clipboard = &atari_clipboard_table,
.download = atari_download_table,
.fetch = &atari_fetch_table,
+ .utf8 = atari_utf8_table,
+ .search = atari_search_table,
};
/* @todo logging file descriptor update belongs in a nslog_init callback */
@@ -1172,8 +1172,7 @@ int main(int argc, char** argv)
/* create an initial browser window */
ret = nsurl_create(addr, &url);
if (ret == NSERROR_OK) {
- ret = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ ret = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/atari/hotlist.h b/atari/hotlist.h
index d3ef022..52598f2 100644
--- a/atari/hotlist.h
+++ b/atari/hotlist.h
@@ -18,10 +18,17 @@
#ifndef NS_ATARI_HOTLIST_H
#define NS_ATARI_HOTLIST_H
+
#include <stdbool.h>
+
#include "desktop/tree.h"
#include "atari/gemtk/gemtk.h"
#include "atari/treeview.h"
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
/* The hotlist window, toolbar and treeview data. */
struct atari_hotlist {
diff --git a/atari/plot/font_vdi.c b/atari/plot/font_vdi.c
index 0c914b8..a73300c 100755
--- a/atari/plot/font_vdi.c
+++ b/atari/plot/font_vdi.c
@@ -26,6 +26,8 @@
#include "utils/utf8.h"
#include "utils/log.h"
+#include "atari/encoding.h"
+
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 8942263..b215d41 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -38,7 +38,6 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/browser_private.h"
@@ -230,7 +229,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
int window_create(struct gui_window * gw,
struct browser_window * bw,
- struct browser_window * clone,
+ struct gui_window * existing,
unsigned long inflags)
{
int err = 0;
@@ -294,8 +293,8 @@ int window_create(struct gui_window * gw,
assert(gw->browser);
gw->browser->bw = bw;
- if(clone)
- gw->browser->bw->scale = clone->scale;
+ if(existing)
+ gw->browser->bw->scale = existing->browser->bw->scale;
else
gw->browser->bw->scale = 1;
@@ -1537,7 +1536,7 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8])
if ((tmp_url != NULL)
&& nsurl_create(tmp_url, &ns_url) == NSERROR_OK) {
browser_window_navigate(gw->browser->bw, ns_url, NULL,
- BROWSER_WINDOW_HISTORY | BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL, NULL, NULL);
nsurl_unref(ns_url);
}
diff --git a/atari/rootwin.h b/atari/rootwin.h
index d2cd04a..a5b22c9 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -46,7 +46,7 @@ enum browser_area_e {
/* Creates an normal Browser window with [toolbar], [statusbar] */
int window_create(struct gui_window * gw,
struct browser_window * bw,
- struct browser_window * clone,
+ struct gui_window * existing,
unsigned long flags );
/* Destroys WinDom part of gui_window */
int window_destroy(ROOTWIN *rootwin);
diff --git a/atari/schedule.c b/atari/schedule.c
index a91c510..3bef573 100755
--- a/atari/schedule.c
+++ b/atari/schedule.c
@@ -22,12 +22,17 @@
#include <sys/time.h>
#include <time.h>
-#include "utils/schedule.h"
+#include "utils/errors.h"
+
#include "atari/schedule.h"
+#ifdef DEBUG_SCHEDULER
#include "utils/log.h"
+#else
+#define LOG(X)
+#endif
-#define CS_NOW() ((clock() * 100) / CLOCKS_PER_SEC)
+#define MS_NOW() ((clock() * 1000) / CLOCKS_PER_SEC)
/* linked list of scheduled callbacks */
static struct nscallback *schedule_list = NULL;
@@ -47,45 +52,6 @@ static int max_scheduled;
static int cur_scheduled;
/**
- * Schedule a callback.
- *
- * \param tival interval before the callback should be made / cs
- * \param callback callback function
- * \param p user parameter, passed to callback function
- *
- * The callback function will be called as soon as possible after t cs have
- * passed.
- */
-void schedule( int cs_ival, void (*callback)(void *p), void *p)
-{
- struct nscallback *nscb;
-
- /*
- remove any callback of this kind,
- other frontend do this, too. framebuffer frontend doesn't do it.
- */
- schedule_remove(callback, p);
-
- nscb = calloc(1, sizeof(struct nscallback));
-
- nscb->timeout = CS_NOW() + cs_ival;
-#ifdef DEBUG_SCHEDULER
- LOG(("adding callback %p for %p(%p) at %d cs", nscb, callback, p, nscb->timeout ));
-#endif
- nscb->callback = callback;
- nscb->p = p;
-
- /* add to list front */
- nscb->next = schedule_list;
- schedule_list = nscb;
- cur_scheduled++;
- if( cur_scheduled > max_scheduled )
- max_scheduled = cur_scheduled;
-}
-
-
-
-/**
* Unschedule a callback.
*
* \param callback callback function
@@ -94,18 +60,18 @@ void schedule( int cs_ival, void (*callback)(void *p), void *p)
* All scheduled callbacks matching both callback and p are removed.
*/
-void schedule_remove(void (*callback)(void *p), void *p)
+static nserror schedule_remove(void (*callback)(void *p), void *p)
{
struct nscallback *cur_nscb;
struct nscallback *prev_nscb;
struct nscallback *unlnk_nscb;
- if (schedule_list == NULL)
- return;
+ /* check there is something on the list to remove */
+ if (schedule_list == NULL) {
+ return NSERROR_OK;
+ }
-#ifdef DEBUG_SCHEDULER
LOG(("removing %p, %p", callback, p));
-#endif
cur_nscb = schedule_list;
prev_nscb = NULL;
@@ -114,9 +80,8 @@ void schedule_remove(void (*callback)(void *p), void *p)
if ((cur_nscb->callback == callback) &&
(cur_nscb->p == p)) {
/* item to remove */
-#ifdef DEBUG_SCHEDULER
- LOG(("callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p));
-#endif
+ LOG(("callback entry %p removing %p(%p)",
+ cur_nscb, cur_nscb->callback, cur_nscb->p));
/* remove callback */
unlnk_nscb = cur_nscb;
@@ -135,20 +100,51 @@ void schedule_remove(void (*callback)(void *p), void *p)
cur_nscb = prev_nscb->next;
}
}
+ return NSERROR_OK;
+}
+
+/* exported function documented in atari/schedule.h */
+nserror atari_schedule(int ival, void (*callback)(void *p), void *p)
+{
+ struct nscallback *nscb;
+ nserror ret;
+
+ /* remove any existing callback of this kind */
+ ret = schedule_remove(callback, p);
+ if ((ival < 0) || (ret != NSERROR_OK)) {
+ return ret;
+ }
+
+ nscb = calloc(1, sizeof(struct nscallback));
+
+ nscb->timeout = MS_NOW() + ival;
+
+ LOG(("adding callback %p for %p(%p) at %d ms",
+ nscb, callback, p, nscb->timeout ));
+
+ nscb->callback = callback;
+ nscb->p = p;
+
+ /* add to list front */
+ nscb->next = schedule_list;
+ schedule_list = nscb;
+ cur_scheduled++;
+ if( cur_scheduled > max_scheduled ) {
+ max_scheduled = cur_scheduled;
+ }
+
+ return NSERROR_OK;
}
-/**
- * Process events up to current time.
- */
-int
-schedule_run(void)
+/* exported function documented in atari/schedule.h */
+int schedule_run(void)
{
unsigned long nexttime;
struct nscallback *cur_nscb;
struct nscallback *prev_nscb;
struct nscallback *unlnk_nscb;
- unsigned long now = CS_NOW();
+ unsigned long now = MS_NOW();
if (schedule_list == NULL)
return -1;
@@ -170,9 +166,9 @@ schedule_run(void)
prev_nscb->next = unlnk_nscb->next;
}
-#ifdef DEBUG_SCHEDULER
- LOG(("callback entry %p running %p(%p)", unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p));
-#endif
+ LOG(("callback entry %p running %p(%p)",
+ unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p));
+
/* call callback */
unlnk_nscb->callback(unlnk_nscb->p);
free(unlnk_nscb);
@@ -180,9 +176,8 @@ schedule_run(void)
/* need to deal with callback modifying the list. */
if (schedule_list == NULL) {
-#ifdef DEBUG_SCHEDULER
LOG(("schedule_list == NULL"));
-#endif
+
return -1; /* no more callbacks scheduled */
}
@@ -204,21 +199,22 @@ schedule_run(void)
}
/* make rettime relative to now and convert to ms */
- nexttime = (nexttime - now)*10;
-#ifdef DEBUG_SCHEDULER
+ nexttime = nexttime - now;
+
LOG(("returning time to next event as %ldms", nexttime ));
-#endif
+
/*return next event time in milliseconds (24days max wait) */
- return ( nexttime );
+ return nexttime;
}
+/* exported function documented in atari/schedule.h */
void list_schedule(void)
{
struct timeval tv;
struct nscallback *cur_nscb;
- LOG(("schedule list at cs clock %ld", CS_NOW() ));
+ LOG(("schedule list at ms clock %ld", MS_NOW() ));
cur_nscb = schedule_list;
while (cur_nscb != NULL) {
diff --git a/atari/schedule.h b/atari/schedule.h
index e21b759..47d8c2d 100755
--- a/atari/schedule.h
+++ b/atari/schedule.h
@@ -17,10 +17,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NS_SCHEDULE_H
-#define NS_SCHEDULE_H
+#ifndef NS_ATARI_SCHEDULE_H
+#define NS_ATARI_SCHEDULE_H
-void list_schedule(void);
+/**
+ * Process events up to current time.
+ */
int schedule_run(void);
+/**
+ * Schedule a callback.
+ *
+ * \param tival interval before the callback should be made in ms
+ * \param callback callback function
+ * \param p user parameter, passed to callback function
+ *
+ * The callback function will be called as soon as possible after t ms have
+ * passed.
+ */
+nserror atari_schedule(int cs_ival, void (*callback)(void *p), void *p);
+
+/**
+ * LOG all current scheduled events.
+ */
+void list_schedule(void);
+
#endif
diff --git a/atari/search.c b/atari/search.c
index 6d8f53b..f73a04a 100644
--- a/atari/search.c
+++ b/atari/search.c
@@ -53,13 +53,16 @@ static void nsatari_search_add_recent(const char *string, void *p);
void nsatari_search_set_forward_state(bool active, void *p);
void nsatari_search_set_back_state(bool active, void *p);
-static struct gui_search_callbacks nsatari_search_callbacks = {
- nsatari_search_set_forward_state,
- nsatari_search_set_back_state,
- nsatari_search_set_status,
- nsatari_search_set_hourglass,
- nsatari_search_add_recent
-};
+static struct gui_search_table search_table = {
+ nsatari_search_set_status,
+ nsatari_search_set_hourglass,
+ nsatari_search_add_recent,
+ nsatari_search_set_forward_state,
+ nsatari_search_set_back_state,
+};
+
+struct gui_search_table *atari_search_table = &search_table;
+
/**
@@ -282,7 +285,7 @@ void nsatari_search_perform(struct s_search_form_session *s, OBJECT *obj,
else
s->state.flags &= (~SEARCH_FLAG_FORWARDS);
- browser_window_search(s->bw, &nsatari_search_callbacks, s,
+ browser_window_search(s->bw, s,
s->state.flags,
gemtk_obj_get_text(obj, TOOLBAR_TB_SRCH));
diff --git a/atari/search.h b/atari/search.h
index 00671e4..984fd37 100644
--- a/atari/search.h
+++ b/atari/search.h
@@ -49,6 +49,9 @@ typedef struct s_search_form_session * SEARCH_FORM_SESSION;
struct s_search_form_session * nsatari_search_session_create(OBJECT * obj,
struct browser_window *bw);
+
+struct gui_search_table *atari_search_table;
+
void nsatari_search_session_destroy(struct s_search_form_session *s);
void nsatari_search_perform(struct s_search_form_session *s, OBJECT *obj,
search_flags_t f);
diff --git a/atari/statusbar.c b/atari/statusbar.c
index 3bf186c..bdd4ec1 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -29,7 +29,6 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/mouse.h"
diff --git a/atari/toolbar.c b/atari/toolbar.c
index 8044d16..5a84681 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -29,9 +29,9 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
#include "desktop/mouse.h"
#include "desktop/plot_style.h"
@@ -55,6 +55,7 @@
#include "desktop/textarea.h"
#include "desktop/textinput.h"
#include "content/hlcache.h"
+#include "atari/encoding.h"
#define TB_BUTTON_WIDTH 32
@@ -714,7 +715,7 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
warn_user("NoMemory", 0);
} else {
browser_window_navigate(gw->browser->bw, url, NULL,
- BROWSER_WINDOW_HISTORY | BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL, NULL, NULL);
nsurl_unref(url);
}
@@ -946,8 +947,8 @@ void toolbar_back_click(struct s_toolbar *tb)
bw = gw->browser->bw;
assert(bw != NULL);
- if( history_back_available(bw->history) )
- history_back(bw, bw->history);
+ if( browser_window_back_available(bw) )
+ browser_window_history_back(bw, false);
}
void toolbar_reload_click(struct s_toolbar *tb)
@@ -973,8 +974,8 @@ void toolbar_forward_click(struct s_toolbar *tb)
bw = gw->browser->bw;
assert(bw != NULL);
- if (history_forward_available(bw->history))
- history_forward(bw, bw->history);
+ if (browser_window_forward_available(bw))
+ browser_window_history_forward(bw, false);
}
void toolbar_home_click(struct s_toolbar *tb)
@@ -1000,8 +1001,7 @@ void toolbar_home_click(struct s_toolbar *tb)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
diff --git a/beos/Makefile.defaults b/beos/Makefile.defaults
index d5bf6b3..303414d 100644
--- a/beos/Makefile.defaults
+++ b/beos/Makefile.defaults
@@ -2,31 +2,29 @@
# BeOS-specific options
# ----------------------------------------------------------------------------
+# Where to install the netsurf binary
+NETSURF_BEOS_BIN := /boot/apps/netsurf/
- # Where to install the netsurf binary
- NETSURF_BEOS_BIN := /boot/apps/netsurf/
+# TODO:HAIKU -- not sure if ~/.netsurf applies in beos
+# Where to search for NetSurf's resources after looking in ~/.netsurf and
+# $NETSURFRES. It must have a trailing /
+NETSURF_BEOS_RESOURCES := /boot/apps/netsurf/res/
- # TODO:HAIKU -- not sure if ~/.netsurf applies in beos
- # Where to search for NetSurf's resources after looking in ~/.netsurf and
- # $NETSURFRES. It must have a trailing /
- NETSURF_BEOS_RESOURCES := /boot/apps/netsurf/res/
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_NSSVG := YES
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_NSSVG := YES
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := AUTO
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := AUTO
+# Enable NetSurf's use of libharu for PDF export.
+# Valid options: YES, NO
+NETSURF_USE_HARU_PDF := NO
- # Enable NetSurf's use of libharu for PDF export.
- # Valid options: YES, NO
- NETSURF_USE_HARU_PDF := NO
-
- # Force using glibc internal iconv implementation instead of external libiconv
- # Valid options: YES, NO
- NETSURF_USE_LIBICONV_PLUG := NO
-
- # Optimisation levels
- CFLAGS += -O2
+# Force using glibc internal iconv implementation instead of external libiconv
+# Valid options: YES, NO
+NETSURF_USE_LIBICONV_PLUG := NO
+# Optimisation levels
+CFLAGS += -O2
diff --git a/beos/about.cpp b/beos/about.cpp
index 1c43c46..cd8070e 100644
--- a/beos/about.cpp
+++ b/beos/about.cpp
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
extern "C" {
+#include "desktop/netsurf.h"
#include "utils/log.h"
#include "utils/testament.h"
#include "utils/useragent.h"
diff --git a/beos/download.cpp b/beos/download.cpp
index 8a55e9d..af5b498 100644
--- a/beos/download.cpp
+++ b/beos/download.cpp
@@ -18,9 +18,12 @@
#define __STDBOOL_H__ 1
#include <stdbool.h>
+#include <sys/types.h>
extern "C" {
+#include "desktop/download.h"
#include "desktop/gui.h"
+#include "utils/utils.h"
}
#include "beos/download.h"
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 97117e0..365a356 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -48,6 +48,7 @@ extern "C" {
#include "content/fetch.h"
#include "content/fetchers/curl.h"
#include "content/fetchers/resource.h"
+#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/browser_private.h"
#include "desktop/gui.h"
@@ -643,8 +644,8 @@ static void gui_init(int argc, char** argv)
/* create an initial browser window */
error = nsurl_create(addr, &url);
if (error == NSERROR_OK) {
- error = browser_window_create((browser_window_nav_flags)
- (BROWSER_WINDOW_VERIFIABLE | BROWSER_WINDOW_HISTORY),
+ error = browser_window_create(
+ BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -963,35 +964,6 @@ static void nsbeos_create_ssl_verify_window(struct browser_window *bw,
CALLED();
}
-
-nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
-{
- assert(string && result);
-
- if (len == 0)
- len = strlen(string);
-
- *result = strndup(string, len);
- if (!(*result))
- return NSERROR_NOMEM;
-
- return NSERROR_OK;
-}
-
-nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
-{
- assert(string && result);
-
- if (len == 0)
- len = strlen(string);
-
- *result = strndup(string, len);
- if (!(*result))
- return NSERROR_NOMEM;
-
- return NSERROR_OK;
-}
-
static char *path_to_url(const char *path)
{
int urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
@@ -1077,6 +1049,7 @@ static struct gui_fetch_table beos_fetch_table = {
static struct gui_browser_table beos_browser_table = {
gui_poll,
+ beos_schedule,
gui_quit,
NULL, //set_search_ico
gui_launch_url,
diff --git a/beos/gui.h b/beos/gui.h
index 24223a1..642441f 100644
--- a/beos/gui.h
+++ b/beos/gui.h
@@ -51,9 +51,6 @@ virtual void AboutRequested();
virtual bool QuitRequested();
};
-
-extern void schedule_run(void);
-
extern BWindow *wndAbout;
extern BWindow *wndTooltip;
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index c673f19..35153b3 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -52,8 +52,8 @@
#include <fs_attr.h>
extern "C" {
#include "content/content.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/local_history.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "desktop/plotters.h"
@@ -62,7 +62,6 @@ extern "C" {
#include "render/font.h"
#include "render/form.h"
#include "utils/messages.h"
-#include "utils/schedule.h"
#include "utils/utils.h"
#include "utils/log.h"
}
@@ -75,7 +74,7 @@ extern "C" {
//#include "beos/completion.h"
#include "beos/throbber.h"
#include "beos/window.h"
-//#include "beos/schedule.h"
+#include "beos/schedule.h"
//#include "beos/download.h"
#define TOOLBAR_HEIGHT 32
@@ -888,10 +887,10 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
if (/*message->WasDropped() &&*/ i == 0) {
browser_window_navigate(bw, nsurl, NULL,
(browser_window_nav_flags)
- (BROWSER_WINDOW_HISTORY | BROWSER_WINDOW_VERIFIABLE),
+ (BW_NAVIGATE_HISTORY),
NULL, NULL, NULL);
} else {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ error = browser_window_create(BW_CREATE_CLONE,
nsurl,
NULL,
bw,
@@ -915,7 +914,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
for (i = 1; message->FindString("argv", i, &urltxt) >= B_OK; i++) {
error = nsurl_create(urltxt.String(), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ error = browser_window_create(BW_CREATE_CLONE,
url,
NULL,
bw,
@@ -949,8 +948,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
browser_window_navigate(bw,
nsurl,
NULL,
- (browser_window_nav_flags)(BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE),
+ (browser_window_nav_flags)(BW_NAVIGATE_HISTORY | BW_NAVIGATE_UNVERIFIABLE),
NULL,
NULL,
NULL);
@@ -974,17 +972,17 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
case B_NETPOSITIVE_BACK:
case BROWSER_NAVIGATE_BACK:
case 'back':
- if (!history_back_available(bw->history))
+ if (!browser_window_history_back_available(bw))
break;
- history_back(bw, bw->history);
+ browser_window_history_back(bw, false);
nsbeos_window_update_back_forward(scaffold);
break;
case B_NETPOSITIVE_FORWARD:
case BROWSER_NAVIGATE_FORWARD:
case 'forw':
- if (!history_forward_available(bw->history))
+ if (!browser_window_history_forward_available(bw))
break;
- history_forward(bw, bw->history);
+ browser_window_history_forward(bw, false);
nsbeos_window_update_back_forward(scaffold);
break;
case B_NETPOSITIVE_STOP:
@@ -1020,8 +1018,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
browser_window_navigate(bw,
url,
NULL,
- (browser_window_nav_flags)(BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE),
+ (browser_window_nav_flags)(BW_NAVIGATE_HISTORY),
NULL,
NULL,
NULL);
@@ -1049,8 +1046,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
browser_window_navigate(bw,
url,
NULL,
- (browser_window_nav_flags)(BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE),
+ (browser_window_nav_flags)(BW_NAVIGATE_HISTORY),
NULL,
NULL,
NULL);
@@ -1133,7 +1129,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
error = nsurl_create(text.String(), &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ error = browser_window_create(BW_CREATE_CLONE,
url,
NULL,
bw,
@@ -1269,7 +1265,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
if (nserr == NSERROR_OK) {
nserr = browser_window_navigate(bw,
url, NULL,
- (browser_window_nav_flags)(BROWSER_WINDOW_HISTORY | BROWSER_WINDOW_VERIFIABLE),
+ (browser_window_nav_flags)(BW_NAVIGATE_HISTORY),
NULL, NULL, NULL);
nsurl_unref(url);
}
@@ -1303,8 +1299,8 @@ void nsbeos_window_update_back_forward(struct beos_scaffolding *g)
if (!g->top_view->LockLooper())
return;
- g->back_button->SetEnabled(history_back_available(bw->history));
- g->forward_button->SetEnabled(history_forward_available(bw->history));
+ g->back_button->SetEnabled(browser_window_history_back_available(bw));
+ g->forward_button->SetEnabled(browser_window_history_forward_available(bw));
g->top_view->UnlockLooper();
@@ -1327,7 +1323,7 @@ void nsbeos_throb(void *p)
g->top_view->UnlockLooper();
- schedule(10, nsbeos_throb, p);
+ beos_schedule(100, nsbeos_throb, p);
}
@@ -2193,7 +2189,7 @@ void gui_window_start_throbber(struct gui_window* _g)
nsbeos_window_update_back_forward(g);
- schedule(10, nsbeos_throb, g);
+ beos_schedule(100, nsbeos_throb, g);
}
void gui_window_stop_throbber(struct gui_window* _g)
@@ -2202,7 +2198,7 @@ void gui_window_stop_throbber(struct gui_window* _g)
nsbeos_window_update_back_forward(g);
- schedule_remove(nsbeos_throb, g);
+ beos_schedule(-1, nsbeos_throb, g);
if (!g->top_view->LockLooper())
return;
diff --git a/beos/scaffolding.h b/beos/scaffolding.h
index 2dd364d..78ba142 100644
--- a/beos/scaffolding.h
+++ b/beos/scaffolding.h
@@ -25,7 +25,6 @@
#include <NetPositive.h>
extern "C" {
-#include "desktop/gui.h"
#include "desktop/plotters.h"
}
diff --git a/beos/schedule.cpp b/beos/schedule.cpp
index db0992e..62ddb0e 100644
--- a/beos/schedule.cpp
+++ b/beos/schedule.cpp
@@ -23,7 +23,8 @@
#include <List.h>
extern "C" {
-#include "utils/schedule.h"
+#include "utils/errors.h"
+#include "beos/schedule.h"
#include "desktop/browser.h"
#ifdef DEBUG_BEOS_SCHEDULE
@@ -65,7 +66,7 @@ nsbeos_schedule_kill_callback(void *_target, void *_match)
return false;
}
-void
+static void
schedule_remove(void (*callback)(void *p), void *p)
{
LOG(("schedule_remove() for %p(%p)", cb->callback, cb->context));
@@ -75,22 +76,26 @@ schedule_remove(void (*callback)(void *p), void *p)
cb_match.callback = callback;
cb_match.context = p;
-
callbacks->DoForEach(nsbeos_schedule_kill_callback, &cb_match);
}
-void
-schedule(int t, void (*callback)(void *p), void *p)
+nserror beos_schedule(int t, void (*callback)(void *p), void *p)
{
- LOG(("schedule(%d, %p, %p)", t, cb->callback, cb->context));
- if (callbacks == NULL)
+ LOG(("t:%d cb:%p p:%p", t, cb->callback, cb->context));
+
+ if (callbacks == NULL) {
callbacks = new BList;
+ }
- bigtime_t timeout = system_time() + t * 10 * 1000LL;
- const int msec_timeout = t * 10;
- _nsbeos_callback_t *cb = (_nsbeos_callback_t *)malloc(sizeof(_nsbeos_callback_t));
/* Kill any pending schedule of this kind. */
schedule_remove(callback, p);
+
+ if (t < 0) {
+ return NSERROR_OK;
+ }
+
+ bigtime_t timeout = system_time() + t * 1000LL;
+ _nsbeos_callback_t *cb = (_nsbeos_callback_t *)malloc(sizeof(_nsbeos_callback_t));
cb->callback = callback;
cb->context = p;
cb->callback_killed = cb->callback_fired = false;
@@ -99,6 +104,8 @@ schedule(int t, void (*callback)(void *p), void *p)
earliest_callback_timeout = timeout;
}
callbacks->AddItem(cb);
+
+ return NSERROR_OK;
}
bool
diff --git a/beos/schedule.h b/beos/schedule.h
index 02205ba..18f1efd 100644
--- a/beos/schedule.h
+++ b/beos/schedule.h
@@ -19,8 +19,11 @@
#ifndef NETSURF_BEOS_CALLBACK_H
#define NETSURF_BEOS_CALLBACK_H 1
-typedef void (*beos_callback)(void *p);
-
extern bigtime_t earliest_callback_timeout;
+extern "C" nserror beos_schedule(int t, void (*callback)(void *p), void *p);
+
+extern "C" bool schedule_run(void);
+
+
#endif /* NETSURF_BEOS_CALLBACK_H */
diff --git a/beos/window.cpp b/beos/window.cpp
index 5009c26..8975c18 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -26,6 +26,7 @@ extern "C" {
#include "desktop/browser_private.h"
#include "desktop/mouse.h"
#include "utils/nsoption.h"
+#include "desktop/netsurf.h"
#include "desktop/textinput.h"
#include "render/font.h"
#include "utils/log.h"
@@ -336,8 +337,8 @@ float nsbeos_get_scale_for_gui(struct gui_window *g)
/* Create a gui_window */
static struct gui_window *gui_window_create(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
struct gui_window *g; /**< what we're creating to return */
@@ -352,8 +353,8 @@ static struct gui_window *gui_window_create(struct browser_window *bw,
g->bw = bw;
g->mouse.state = 0;
g->current_pointer = GUI_POINTER_DEFAULT;
- if (clone != NULL)
- bw->scale = clone->scale;
+ if (existing != NULL)
+ bw->scale = existing->bw->scale;
else
bw->scale = (float) nsoption_int(scale) / 100;
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 2f8d9d8..64c2ef3 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -27,6 +27,8 @@
#import "desktop/hotlist.h"
#import "desktop/tree.h"
#import "utils/messages.h"
+#import "utils/utils.h"
+#import "content/hlcache.h"
@interface BookmarksController ()
- (void) noteAppWillTerminate: (NSNotification *) note;
@@ -140,14 +142,12 @@ static const char *cocoa_hotlist_path( void )
error = browser_window_navigate([tab browser],
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
} else {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index ca5808c..b0042f7 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -24,11 +24,11 @@
#import "cocoa/BrowserWindowController.h"
#import "desktop/browser_private.h"
-#import "desktop/local_history.h"
#import "desktop/plotters.h"
#import "desktop/textinput.h"
#import "utils/nsoption.h"
#import "utils/messages.h"
+#import "content/hlcache.h"
@interface BrowserView ()
@@ -580,9 +580,9 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
error = nsurl_create([[sender representedObject] UTF8String], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB |
+ BW_CREATE_CLONE,
url,
NULL,
browser,
@@ -601,8 +601,8 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
error = nsurl_create([[sender representedObject] UTF8String], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_CLONE,
url,
NULL,
browser,
@@ -622,8 +622,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
browser_window_navigate(browser,
url,
NULL,
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -687,8 +686,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
browser_window_navigate(browser,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
diff --git a/cocoa/BrowserViewController.m b/cocoa/BrowserViewController.m
index 956654a..b4e4360 100644
--- a/cocoa/BrowserViewController.m
+++ b/cocoa/BrowserViewController.m
@@ -21,8 +21,8 @@
#import "cocoa/BrowserWindowController.h"
#import "cocoa/fetch.h"
+#import "desktop/browser_history.h"
#import "desktop/browser_private.h"
-#import "desktop/local_history.h"
#import "desktop/textinput.h"
#import "utils/nsoption.h"
@@ -30,6 +30,7 @@
#import "utils/filename.h"
#import "utils/messages.h"
#import "utils/url.h"
+#import "content/hlcache.h"
@implementation BrowserViewController
@@ -78,8 +79,7 @@
browser_window_navigate(browser,
urlns,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -116,16 +116,16 @@
- (IBAction) goBack: (id) sender;
{
- if (browser && history_back_available( browser->history )) {
- history_back(browser, browser->history);
+ if (browser && browser_window_history_back_available( browser )) {
+ browser_window_history_back(browser, false);
[self updateBackForward];
}
}
- (IBAction) goForward: (id) sender;
{
- if (browser && history_forward_available( browser->history )) {
- history_forward(browser, browser->history);
+ if (browser && browser_window_history_forward_available( browser )) {
+ browser_window_history_forward(browser, false);
[self updateBackForward];
}
}
@@ -140,8 +140,7 @@
error = browser_window_navigate(browser,
urlns,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -273,8 +272,8 @@ static inline bool compare_float( float a, float b )
- (void) updateBackForward;
{
[browserView updateHistory];
- [self setCanGoBack: browser != NULL && history_back_available( browser->history )];
- [self setCanGoForward: browser != NULL && history_forward_available( browser->history )];
+ [self setCanGoBack: browser != NULL && browser_window_history_back_available( browser )];
+ [self setCanGoForward: browser != NULL && browser_window_history_forward_available( browser )];
}
- (void) contentUpdated;
@@ -288,7 +287,7 @@ struct history_add_menu_item_data {
id target;
};
-static bool history_add_menu_item_cb( const struct history *history, int x0, int y0, int x1, int y1,
+static bool history_add_menu_item_cb( const struct browser_window *bw, int x0, int y0, int x1, int y1,
const struct history_entry *page, void *user_data )
{
struct history_add_menu_item_data *data = user_data;
@@ -306,7 +305,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
++data->index;
[item setTarget: data->target];
- [item setTitle: [NSString stringWithUTF8String: history_entry_get_title( page )]];
+ [item setTitle: [NSString stringWithUTF8String: browser_window_history_entry_get_title( page )]];
[item setRepresentedObject: [NSValue valueWithPointer: page]];
return true;
@@ -315,7 +314,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
- (IBAction) historyItemSelected: (id) sender;
{
struct history_entry *entry = [[sender representedObject] pointerValue];
- history_go( browser, browser->history, entry, false );
+ browser_window_history_go( browser, entry, false );
[self updateBackForward];
}
@@ -326,7 +325,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
.menu = menu,
.target = self
};
- history_enumerate_back( browser->history, history_add_menu_item_cb, &data );
+ browser_window_history_enumerate_back( browser, history_add_menu_item_cb, &data );
while (data.index < [menu numberOfItems]) [menu removeItemAtIndex: data.index];
}
@@ -337,7 +336,7 @@ static bool history_add_menu_item_cb( const struct history *history, int x0, int
.menu = menu,
.target = self
};
- history_enumerate_forward( browser->history, history_add_menu_item_cb, &data );
+ browser_window_history_enumerate_forward( browser, history_add_menu_item_cb, &data );
while (data.index < [menu numberOfItems]) [menu removeItemAtIndex: data.index];
}
diff --git a/cocoa/BrowserWindowController.m b/cocoa/BrowserWindowController.m
index 2edb9a1..1d70778 100644
--- a/cocoa/BrowserWindowController.m
+++ b/cocoa/BrowserWindowController.m
@@ -28,6 +28,7 @@
#import "desktop/browser.h"
#import "utils/nsoption.h"
#import "utils/messages.h"
+#import "utils/utils.h"
@interface BrowserWindowController ()
@@ -160,9 +161,8 @@
error = nsurl_create(NETSURF_HOMEPAGE, &url);
}
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
[activeBrowser browser],
diff --git a/cocoa/FormSelectMenu.m b/cocoa/FormSelectMenu.m
index 3aaeae5..d1548b2 100644
--- a/cocoa/FormSelectMenu.m
+++ b/cocoa/FormSelectMenu.m
@@ -19,7 +19,7 @@
#import "cocoa/FormSelectMenu.h"
#import "cocoa/coordinates.h"
-#import "desktop/browser_private.h"
+#import "desktop/browser.h"
#import "render/form.h"
@interface FormSelectMenu ()
@@ -87,7 +87,7 @@
- (void) itemSelected: (id) sender;
{
- form_select_process_selection( browser->current_content, control, [sender tag] );
+ form_select_process_selection( control, [sender tag] );
}
- (void) menuDidClose: (NSMenu *) sender;
diff --git a/cocoa/HistoryView.m b/cocoa/HistoryView.m
index 45f7fac..7b19233 100644
--- a/cocoa/HistoryView.m
+++ b/cocoa/HistoryView.m
@@ -23,8 +23,7 @@
#import "cocoa/LocalHistoryController.h"
#import "cocoa/BrowserView.h"
-#import "desktop/browser_private.h"
-#import "desktop/local_history.h"
+#import "desktop/browser_history.h"
#import "desktop/plotters.h"
@implementation HistoryView
@@ -41,7 +40,7 @@
- (NSSize) size;
{
int width, height;
- history_size( browser->history, &width, &height );
+ browser_window_history_size( browser, &width, &height );
return cocoa_size( width, height );
}
@@ -65,14 +64,14 @@
cocoa_set_clip( rect );
- history_redraw( browser->history, &ctx );
+ browser_window_history_redraw( browser, &ctx );
}
- (void) mouseUp: (NSEvent *)theEvent;
{
const NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
const bool newWindow = [theEvent modifierFlags] & NSCommandKeyMask;
- if (history_click( browser, browser->history,
+ if (browser_window_history_click( browser,
cocoa_pt_to_px( location.x ), cocoa_pt_to_px( location.y ),
newWindow )) {
[browserView setHistoryVisible: NO];
@@ -94,7 +93,7 @@
[[NSCursor arrowCursor] set];
}
-static bool cursor_rects_cb( const struct history *history, int x0, int y0, int x1, int y1,
+static bool cursor_rects_cb( const struct browser_window *bw, int x0, int y0, int x1, int y1,
const struct history_entry *page, void *user_data )
{
HistoryView *view = user_data;
@@ -102,8 +101,8 @@ static bool cursor_rects_cb( const struct history *history, int x0, int y0, int
NSRect rect = NSIntersectionRect( [view visibleRect], cocoa_rect( x0, y0, x1, y1 ) );
if (!NSIsEmptyRect( rect )) {
- NSString *toolTip = [NSString stringWithFormat: @"%s\n%s", history_entry_get_title(page),
- history_entry_get_url( page )];
+ NSString *toolTip = [NSString stringWithFormat: @"%s\n%s", browser_window_history_entry_get_title(page),
+ browser_window_history_entry_get_url( page )];
[view addToolTipRect: rect owner: toolTip userData: nil];
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect: rect
@@ -138,7 +137,7 @@ static bool cursor_rects_cb( const struct history *history, int x0, int y0, int
[self removeTrackingArea: area];
}
- history_enumerate( browser->history, cursor_rects_cb, self );
+ browser_window_history_enumerate( browser, cursor_rects_cb, self );
[super updateTrackingAreas];
}
diff --git a/cocoa/Makefile.defaults b/cocoa/Makefile.defaults
index 2451749..501d175 100644
--- a/cocoa/Makefile.defaults
+++ b/cocoa/Makefile.defaults
@@ -2,35 +2,35 @@
# Cocoa-specific options
# ----------------------------------------------------------------------------
- # Force using glibc internal iconv implementation instead of external libiconv
- # Valid options: YES, NO
- NETSURF_USE_LIBICONV_PLUG := NO
-
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := NO
-
- # Enable NetSurf's use of libwebp for displaying WebPs
- # Valid options: YES, NO
- NETSURF_USE_WEBP := NO
-
- # Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_RSVG := AUTO
-
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_NSSVG := AUTO
-
- NETSURF_USE_BMP := NO
- NETSURF_USE_GIF := NO
- NETSURF_USE_PNG := NO
- NETSURF_USE_JPEG := NO
- NETSURF_USE_IMAGEIO := YES
-
- DEVELOPER_PATH := /Developer
- MACOSX_VERSION := 10.5
- SDK_VERSION := $(MACOSX_VERSION)
-
- # Optimisation levels
- CFLAGS += -O2
+# Force using glibc internal iconv implementation instead of external libiconv
+# Valid options: YES, NO
+NETSURF_USE_LIBICONV_PLUG := NO
+
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := NO
+
+# Enable NetSurf's use of libwebp for displaying WebPs
+# Valid options: YES, NO
+NETSURF_USE_WEBP := NO
+
+# Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_RSVG := AUTO
+
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_NSSVG := AUTO
+
+NETSURF_USE_BMP := NO
+NETSURF_USE_GIF := NO
+NETSURF_USE_PNG := NO
+NETSURF_USE_JPEG := NO
+NETSURF_USE_IMAGEIO := YES
+
+DEVELOPER_PATH := /Developer
+MACOSX_VERSION := 10.5
+SDK_VERSION := $(MACOSX_VERSION)
+
+# Optimisation levels
+CFLAGS += -O2
diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target
index 49f67f0..e6292c1 100644
--- a/cocoa/Makefile.target
+++ b/cocoa/Makefile.target
@@ -2,67 +2,66 @@
# Mac OS X target setup
# ----------------------------------------------------------------------------
- POSTEXES += NetSurf.app
+POSTEXES += NetSurf.app
- LDFLAGS += -L/usr/lib
- LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub libcss libdom)
- LDFLAGS += -L/usr/X11/lib
- LDFLAGS += -lm -lcurl -liconv
- LDFLAGS += -lssl -lcrypto
+LDFLAGS += -L/usr/lib
+LDFLAGS += $(shell $(PKG_CONFIG) --libs libhubbub libcss libdom)
+LDFLAGS += -L/usr/X11/lib
+LDFLAGS += -lm -lcurl -liconv
+LDFLAGS += -lssl -lcrypto
- CFLAGS += -O $(WARNFLAGS) -Dnscocoa \
- -D_BSD_SOURCE -D_POSIX_C_SOURCE \
+CFLAGS += -O $(WARNFLAGS) -Dnscocoa -D_BSD_SOURCE -D_POSIX_C_SOURCE \
-std=c99 -g -Os
- CFLAGS += $(shell $(PKG_CONFIG) --cflags libhubbub libcss libdom)
+CFLAGS += $(shell $(PKG_CONFIG) --cflags libhubbub libcss libdom)
- # shut up zconf.h and zlib.h
- #CFLAGS += -D_LARGEFILE64_SOURCE=1
+# shut up zconf.h and zlib.h
+#CFLAGS += -D_LARGEFILE64_SOURCE=1
ifneq ($(WITH_MACPORTS),)
LDFLAGS += -L/opt/local/lib
CFLAGS += -I/opt/local/include
endif
- # for timerisset()
- CFLAGS += -D_DARWIN_C_SOURCE
+# for timerisset()
+CFLAGS += -D_DARWIN_C_SOURCE
- MACOSX_VERSION ?= 10.5
- SDK_VERSION ?= $(MACOSX_VERSION)
- SDK_PATH ?= $(DEVELOPER_PATH)/SDKs/MacOSX$(SDK_VERSION).sdk
- SDK_FLAGS := -isysroot $(SDK_PATH) -mmacosx-version-min=$(MACOSX_VERSION)
- CFLAGS := $(SDK_FLAGS) $(CFLAGS)
- LDFLAGS := $(SDK_FLAGS) -Wl,-syslibroot,$(SDK_PATH) $(LDFLAGS)
- CXXFLAGS := $(SDK_FLAGS) $(CXXFLAGS)
+MACOSX_VERSION ?= 10.5
+SDK_VERSION ?= $(MACOSX_VERSION)
+SDK_PATH ?= $(DEVELOPER_PATH)/SDKs/MacOSX$(SDK_VERSION).sdk
+SDK_FLAGS := -isysroot $(SDK_PATH) -mmacosx-version-min=$(MACOSX_VERSION)
+CFLAGS := $(SDK_FLAGS) $(CFLAGS)
+LDFLAGS := $(SDK_FLAGS) -Wl,-syslibroot,$(SDK_PATH) $(LDFLAGS)
+CXXFLAGS := $(SDK_FLAGS) $(CXXFLAGS)
- CFLAGS += -I/usr/X11/include
- CFLAGS += -include cocoa/Prefix.pch
+CFLAGS += -I/usr/X11/include
+CFLAGS += -include cocoa/Prefix.pch
# VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c)
# TODO: this needs fixing properly everywhere
- VERSION_FULL := "3.0 (Dev)"
- VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
- VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
+VERSION_FULL := "3.0 (Dev)"
+VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
+VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
- LDFLAGS += -Wl,-framework,Cocoa -Wl,-framework,Carbon $(NETLDFLAGS)
+LDFLAGS += -Wl,-framework,Cocoa -Wl,-framework,Carbon $(NETLDFLAGS)
- NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
- NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
- NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
- NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
+NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
+NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
+NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
- $(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
- $(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF))
- $(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
- $(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,SVG))
- $(eval $(call feature_enabled,IMAGEIO,-DWITH_APPLE_IMAGE,,Apple ImageIO ))
+$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
+$(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF))
+$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
+$(eval $(call pkg_config_find_and_add_enabled,NSSVG,libsvgtiny,SVG))
+$(eval $(call feature_enabled,IMAGEIO,-DWITH_APPLE_IMAGE,,Apple ImageIO ))
- ifneq ($(UNIVERSAL),)
+ifneq ($(UNIVERSAL),)
UNIVERSAL_FLAGS := $(foreach arch,$(UNIVERSAL),-arch $(arch) )
CFLAGS += $(UNIVERSAL_FLAGS)
LDFLAGS += $(UNIVERSAL_FLAGS)
CXXFLAGS += $(UNIVERSAL_FLAGS)
- endif
+endif
# ----------------------------------------------------------------------------
# Source file setup
@@ -95,7 +94,6 @@ S_COCOA := \
schedule.m \
selection.m \
thumbnail.m \
- utf8.m \
utils.m \
ArrowBox.m \
ArrowWindow.m \
@@ -241,4 +239,3 @@ clean-package-cocoa:
$(Q)$(RM) NetSurf.dmg
$(VQ)echo " CLEAN: NetSurf.app"
$(Q)$(RM) -r NetSurf.app
-
diff --git a/cocoa/NetSurfAppDelegate.m b/cocoa/NetSurfAppDelegate.m
index 4a66212..e173535 100644
--- a/cocoa/NetSurfAppDelegate.m
+++ b/cocoa/NetSurfAppDelegate.m
@@ -24,6 +24,7 @@
#import "desktop/browser.h"
#import "utils/nsoption.h"
#import "utils/messages.h"
+#import "utils/utils.h"
@interface NetSurfAppDelegate ()
@@ -50,8 +51,7 @@
}
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -74,8 +74,7 @@
for (NSURL *url in [openPanel URLs]) {
error = nsurl_create([[url absoluteString] UTF8String], &u);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
u,
NULL,
NULL,
@@ -97,8 +96,7 @@
error = nsurl_create([urlAsString UTF8String], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -181,8 +179,7 @@
error = nsurl_create([[urltxt absoluteString] UTF8String], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m
index 5c35911..cab06a6 100644
--- a/cocoa/NetsurfApp.m
+++ b/cocoa/NetsurfApp.m
@@ -21,6 +21,7 @@
#import "cocoa/gui.h"
#import "cocoa/plotter.h"
#import "cocoa/DownloadWindowController.h"
+#import "cocoa/SearchWindowController.h"
#import "cocoa/selection.h"
#import "cocoa/fetch.h"
@@ -28,7 +29,6 @@
#import "content/urldb.h"
#import "css/utils.h"
#import "desktop/gui.h"
-#import "desktop/local_history.h"
#import "desktop/mouse.h"
#import "desktop/netsurf.h"
#import "utils/nsoption.h"
@@ -191,6 +191,7 @@ int main( int argc, char **argv )
.clipboard = cocoa_clipboard_table,
.download = cocoa_download_table,
.fetch = cocoa_fetch_table,
+ .search = cocoa_search_table,
};
cocoa_autorelease();
@@ -231,8 +232,7 @@ int main( int argc, char **argv )
error = nsurl_create(argv[i], &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/cocoa/PreferencesWindowController.m b/cocoa/PreferencesWindowController.m
index a3abe29..54e7b91 100644
--- a/cocoa/PreferencesWindowController.m
+++ b/cocoa/PreferencesWindowController.m
@@ -25,6 +25,7 @@
#import "desktop/browser_private.h"
#import "content/content.h"
#import "utils/nsoption.h"
+#import "content/hlcache.h"
@implementation PreferencesWindowController
diff --git a/cocoa/SearchWindowController.h b/cocoa/SearchWindowController.h
index a1aac2e..896983b 100644
--- a/cocoa/SearchWindowController.h
+++ b/cocoa/SearchWindowController.h
@@ -49,4 +49,6 @@ typedef enum {
- (void) search: (SearchDirection)direction;
+struct gui_search_table *cocoa_search_table;
+
@end
diff --git a/cocoa/SearchWindowController.m b/cocoa/SearchWindowController.m
index 06147fa..e4dfb73 100644
--- a/cocoa/SearchWindowController.m
+++ b/cocoa/SearchWindowController.m
@@ -20,20 +20,20 @@
#import "cocoa/SearchWindowController.h"
#import "cocoa/BrowserViewController.h"
+#import "desktop/gui.h"
#import "desktop/browser.h"
#import "desktop/search.h"
static void cocoa_search_set_back( bool active, void *p );
static void cocoa_search_set_forward( bool active, void *p );
-static struct gui_search_callbacks cocoa_search_callbacks = {
+static struct gui_search_table search_table = {
.forward_state = cocoa_search_set_forward,
.back_state = cocoa_search_set_back,
- .status = NULL,
- .hourglass = NULL,
- .add_recent = NULL
};
+struct gui_search_table *cocoa_search_table = &search_table;
+
@implementation SearchWindowController
@synthesize caseSensitive;
@@ -76,7 +76,7 @@ static struct gui_search_callbacks cocoa_search_callbacks = {
if (selectAll) flags |= SEARCH_FLAG_SHOWALL;
struct browser_window *bw = [browser browser];
- browser_window_search( bw, &cocoa_search_callbacks, self, flags, [searchString UTF8String] );
+ browser_window_search( bw, self, flags, [searchString UTF8String] );
}
- (IBAction) searchStringDidChange: (id) sender;
diff --git a/cocoa/apple_image.m b/cocoa/apple_image.m
index ab17f8a..c6f9df3 100644
--- a/cocoa/apple_image.m
+++ b/cocoa/apple_image.m
@@ -25,7 +25,8 @@
#include "image/bitmap.h"
#include "desktop/plotters.h"
#include "utils/utils.h"
-#include "utils/schedule.h"
+
+#include "cocoa/schedule.h"
typedef struct apple_image_content {
struct content base;
@@ -147,7 +148,7 @@ static void animate_image_cb( void *ptr )
data.redraw.object = &ai->base;
content_broadcast( &ai->base, CONTENT_MSG_REDRAW, data );
- schedule( ai->frameTimes[ai->currentFrame], animate_image_cb, ai );
+ cocoa_schedule(ai->frameTimes[ai->currentFrame], animate_image_cb, ai );
}
/**
@@ -190,10 +191,10 @@ bool apple_image_convert(struct content *c)
ai->frameTimes = calloc( ai->frames , sizeof(int));
for (NSUInteger i = 0; i < frames; i++) {
[image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: i]];
- ai->frameTimes[i] = 100 * [[image valueForProperty: NSImageCurrentFrameDuration] floatValue];
+ ai->frameTimes[i] = 1000 * [[image valueForProperty: NSImageCurrentFrameDuration] floatValue];
}
[image setProperty: NSImageCurrentFrame withValue: [NSNumber numberWithUnsignedInteger: 0]];
- schedule( ai->frameTimes[0], animate_image_cb, ai );
+ cocoa_schedule( ai->frameTimes[0], animate_image_cb, ai );
}
return true;
@@ -206,7 +207,7 @@ void apple_image_destroy(struct content *c)
[(id)ai_c->bitmap release];
ai_c->bitmap = NULL;
- schedule_remove( animate_image_cb, c );
+ cocoa_schedule(-1, animate_image_cb, c );
}
diff --git a/cocoa/fetch.m b/cocoa/fetch.m
index 7bf00e0..70d3805 100644
--- a/cocoa/fetch.m
+++ b/cocoa/fetch.m
@@ -19,6 +19,7 @@
#import <Cocoa/Cocoa.h>
#import "utils/log.h"
+#import "utils/nsurl.h"
#import "desktop/gui.h"
#import "cocoa/fetch.h"
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 750d9fc..9ba6144 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -25,6 +25,7 @@
#import "cocoa/BrowserWindowController.h"
#import "cocoa/FormSelectMenu.h"
#import "cocoa/fetch.h"
+#import "cocoa/schedule.h"
#import "desktop/gui.h"
#import "desktop/netsurf.h"
@@ -35,6 +36,8 @@
#import "utils/log.h"
#import "image/ico.h"
#import "content/fetchers/resource.h"
+#import "content/hlcache.h"
+#import "content/content.h"
NSString * const kCookiesFileOption = @"CookiesFile";
NSString * const kURLsFileOption = @"URLsFile";
@@ -62,21 +65,21 @@ static void gui_poll(bool active)
struct browser_window;
static struct gui_window *gui_window_create(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
BrowserWindowController *window = nil;
- if (clone != NULL) {
- bw->scale = clone->scale;
- window = [(BrowserViewController *)(clone->window) windowController];
+ if (existing != NULL) {
+ bw->scale = (float) nsoption_int(scale) / 100;
+ window = [(BrowserViewController *)(existing) windowController];
} else {
bw->scale = (float) nsoption_int(scale) / 100;
}
BrowserViewController *result = [[BrowserViewController alloc] initWithBrowser: bw];
- if (!new_tab || nil == window) {
+ if (!(flags & GW_CREATE_TAB) || nil == window) {
window = [[[BrowserWindowController alloc] init] autorelease];
[[window window] makeKeyAndOrderFront: nil];
}
@@ -292,6 +295,7 @@ struct gui_window_table *cocoa_window_table = &window_table;
static struct gui_browser_table browser_table = {
.poll = gui_poll,
+ .schedule = cocoa_schedule,
.launch_url = gui_launch_url,
.create_form_select_menu = gui_create_form_select_menu,
diff --git a/cocoa/selection.h b/cocoa/schedule.h
similarity index 91%
copy from cocoa/selection.h
copy to cocoa/schedule.h
index 67331ea..43b2c14 100644
--- a/cocoa/selection.h
+++ b/cocoa/schedule.h
@@ -16,4 +16,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-struct gui_clipboard_table *cocoa_clipboard_table;
+nserror cocoa_schedule(int t, void (*callback)(void *p), void *p);
diff --git a/cocoa/schedule.m b/cocoa/schedule.m
index 1ad75b3..f0896bd 100644
--- a/cocoa/schedule.m
+++ b/cocoa/schedule.m
@@ -17,7 +17,10 @@
*/
#import <Cocoa/Cocoa.h>
-#import "utils/schedule.h"
+
+#import "utils/errors.h"
+
+#import "cocoa/schedule.h"
@interface ScheduledCallback : NSObject {
void (*callback)( void *userData );
@@ -73,18 +76,15 @@ static NSMutableSet *timerSet = nil;
@end
-/* In platform specific schedule.c. */
-void schedule(int t, void (*callback)(void *p), void *p)
-{
- ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p];
- [cb schedule: (NSTimeInterval)t / 100];
- [cb release];
-}
-
-void schedule_remove(void (*callback)(void *p), void *p)
+/* exported interface documented in cocoa/schedule.h */
+nserror cocoa_schedule(int t, void (*callback)(void *p), void *p)
{
ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p];
[timerSet removeObject: cb];
+ if (t >= 0) {
+ [cb schedule: (NSTimeInterval)t / 1000];
+ }
[cb release];
-}
+ return NSERROR_OK;
+}
diff --git a/cocoa/utf8.m b/cocoa/utf8.m
deleted file mode 100644
index 7b69918..0000000
--- a/cocoa/utf8.m
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2011 Sven Weidauer <sven.weidauer(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/>.
- */
-
-#import <Cocoa/Cocoa.h>
-
-#import "utils/utf8.h"
-
-nserror utf8_to_local_encoding(const char *string, size_t len,
- char **result)
-{
- NSCParameterAssert( NULL != result );
-
- char *newString = malloc( len + 1 );
- if (NULL == newString) return NSERROR_NOMEM;
- memcpy( newString, string, len );
- newString[len] = 0;
- *result = newString;
- return NSERROR_OK;
-}
-
-nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
-{
- /* same function, local encoding = UTF-8 */
- return utf8_to_local_encoding( string, len, result );
-}
diff --git a/content/content.c b/content/content.c
index 1c667f1..87dcfa2 100644
--- a/content/content.c
+++ b/content/content.c
@@ -31,15 +31,13 @@
#include <string.h>
#include <strings.h>
#include <time.h>
+
#include "utils/config.h"
#include "content/content_protected.h"
#include "content/hlcache.h"
-#include "css/css.h"
#include "image/bitmap.h"
#include "desktop/browser.h"
#include "utils/nsoption.h"
-#include "render/html.h"
-#include "render/textplain.h"
#include "utils/http.h"
#include "utils/log.h"
@@ -840,15 +838,15 @@ bool content_drop_file_at_point(struct hlcache_handle *h,
}
-void content_search(struct hlcache_handle *h,
- struct gui_search_callbacks *gui_callbacks, void *gui_data,
+void content_search(struct hlcache_handle *h, void *context,
search_flags_t flags, const char *string)
{
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
- if (c->handler->search != NULL)
- c->handler->search(c, gui_callbacks, gui_data, flags, string);
+ if (c->handler->search != NULL) {
+ c->handler->search(c, context, flags, string);
+ }
}
@@ -857,8 +855,9 @@ void content_search_clear(struct hlcache_handle *h)
struct content *c = hlcache_handle_get_content(h);
assert(c != 0);
- if (c->handler->search_clear != NULL)
+ if (c->handler->search_clear != NULL) {
c->handler->search_clear(c);
+ }
}
diff --git a/content/content.h b/content/content.h
index 91a6ae9..a2d0792 100644
--- a/content/content.h
+++ b/content/content.h
@@ -266,10 +266,11 @@ bool content_scroll_at_point(struct hlcache_handle *h,
int x, int y, int scrx, int scry);
bool content_drop_file_at_point(struct hlcache_handle *h,
int x, int y, char *file);
-void content_search(struct hlcache_handle *h,
- struct gui_search_callbacks *gui_callbacks, void *gui_data,
+
+void content_search(struct hlcache_handle *h, void *context,
search_flags_t flags, const char *string);
void content_search_clear(struct hlcache_handle *h);
+
void content_debug_dump(struct hlcache_handle *h, FILE *f);
struct content_rfc5988_link *content_find_rfc5988_link(struct hlcache_handle *c,
lwc_string *rel);
diff --git a/content/content_protected.h b/content/content_protected.h
index 57ce357..f5448c8 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -73,10 +73,8 @@ struct content_handler {
int scrx, int scry);
bool (*drop_file_at_point)(struct content *c, int x, int y,
char *file);
- void (*search)(struct content *c,
- struct gui_search_callbacks *gui_callbacks,
- void *gui_data, search_flags_t flags,
- const char *string);
+ void (*search)(struct content *c, void *context, search_flags_t flags,
+ const char *string);
void (*search_clear)(struct content *c);
void (*debug_dump)(struct content *c, FILE *f);
nserror (*clone)(const struct content *old, struct content **newc);
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 90c9c13..612b77d 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -19,7 +19,7 @@
*/
/** \file
- * Fetching of data from a URL (implementation).
+ * Fetching of data from an URL (implementation).
*
* This implementation uses libcurl's 'multi' interface.
*
@@ -36,30 +36,24 @@
#include <strings.h>
#include <time.h>
#include <sys/stat.h>
+#include <openssl/ssl.h>
#include <libwapcaplet/libwapcaplet.h>
#include "utils/config.h"
-#include <openssl/ssl.h>
-#include "content/fetch.h"
-#include "content/fetchers/curl.h"
-#include "content/urldb.h"
#include "desktop/netsurf.h"
#include "desktop/gui_factory.h"
#include "utils/corestrings.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/schedule.h"
#include "utils/utils.h"
#include "utils/ring.h"
#include "utils/useragent.h"
-/* BIG FAT WARNING: This is here because curl doesn't give you an FD to
- * poll on, until it has processed a bit of the handle. So we need schedules
- * in order to make this work.
- */
-#include <desktop/browser.h>
+#include "content/fetch.h"
+#include "content/fetchers/curl.h"
+#include "content/urldb.h"
/* uncomment this to use scheduler based calling
#define FETCHER_CURLL_SCHEDULED 1
@@ -178,6 +172,25 @@ void fetch_curl_register(void)
die("Failed to initialise the fetch module "
"(curl_multi_init failed).");
+#if LIBCURL_VERSION_NUM >= 0x071e00
+ /* We've been built against 7.30.0 or later: configure caching */
+ {
+ CURLMcode mcode;
+ int maxconnects = nsoption_int(max_fetchers) +
+ nsoption_int(max_cached_fetch_handles);
+
+#undef SETOPT
+#define SETOPT(option, value) \
+ mcode = curl_multi_setopt(fetch_curl_multi, option, value); \
+ if (mcode != CURLM_OK) \
+ goto curl_multi_setopt_failed;
+
+ SETOPT(CURLMOPT_MAXCONNECTS, maxconnects);
+ SETOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, maxconnects);
+ SETOPT(CURLMOPT_MAX_HOST_CONNECTIONS, nsoption_int(max_fetchers_per_host));
+ }
+#endif
+
/* Create a curl easy handle with the options that are common to all
fetches. */
fetch_blank_curl = curl_easy_init();
@@ -269,6 +282,12 @@ void fetch_curl_register(void)
curl_easy_setopt_failed:
die("Failed to initialise the fetch module "
"(curl_easy_setopt failed).");
+
+#if LIBCURL_VERSION_NUM >= 0x071e00
+curl_multi_setopt_failed:
+ die("Failed to initialise the fetch module "
+ "(curl_multi_setopt failed).");
+#endif
}
@@ -485,7 +504,7 @@ bool fetch_curl_initiate_fetch(struct curl_fetch_info *fetch, CURL *handle)
codem = curl_multi_add_handle(fetch_curl_multi, fetch->curl_handle);
assert(codem == CURLM_OK || codem == CURLM_CALL_MULTI_PERFORM);
- schedule(1, (schedule_callback_fn)fetch_curl_poll, NULL);
+ guit->browser->schedule(10, (void *)fetch_curl_poll, NULL);
return true;
}
@@ -518,6 +537,11 @@ CURL *fetch_curl_get_handle(lwc_string *host)
void fetch_curl_cache_handle(CURL *handle, lwc_string *host)
{
+#if LIBCURL_VERSION_NUM >= 0x071e00
+ /* 7.30.0 or later has its own connection caching; suppress ours */
+ curl_easy_cleanup(handle);
+ return;
+#else
struct cache_handle *h = 0;
int c;
RING_FINDBYLWCHOST(curl_handle_ring, h, host);
@@ -555,6 +579,7 @@ void fetch_curl_cache_handle(CURL *handle, lwc_string *host)
h->handle = handle;
h->host = lwc_string_ref(host);
RING_INSERT(curl_handle_ring, h);
+#endif
}
@@ -812,7 +837,7 @@ void fetch_curl_poll(lwc_string *scheme_ignored)
#ifdef FETCHER_CURLL_SCHEDULED
if (running != 0) {
- schedule(1, (schedule_callback_fn)fetch_curl_poll, fetch_curl_poll);
+ guit->browser->schedule(10, fetch_curl_poll, fetch_curl_poll);
}
#endif
}
diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c
index b2791b4..a5c12bb 100644
--- a/content/fetchers/resource.c
+++ b/content/fetchers/resource.c
@@ -41,7 +41,6 @@
#include "content/fetch.h"
#include "content/fetchers/resource.h"
#include "content/urldb.h"
-#include "desktop/gui.h"
#include "desktop/gui_factory.h"
#include "utils/corestrings.h"
#include "utils/nsoption.h"
diff --git a/content/hlcache.c b/content/hlcache.c
index 618f4fd..16f9697 100644
--- a/content/hlcache.c
+++ b/content/hlcache.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
+#include "desktop/gui_factory.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/mimesniff.h"
@@ -31,7 +32,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/ring.h"
-#include "utils/schedule.h"
#include "utils/url.h"
#include "utils/utils.h"
@@ -146,7 +146,7 @@ static void hlcache_clean(void *ignored)
llcache_clean();
/* Re-schedule ourselves */
- schedule(hlcache->params.bg_clean_time / 10, hlcache_clean, NULL);
+ guit->browser->schedule(hlcache->params.bg_clean_time, hlcache_clean, NULL);
}
/**
@@ -536,7 +536,7 @@ hlcache_initialise(const struct hlcache_parameters *hlcache_parameters)
hlcache->params = *hlcache_parameters;
/* Schedule the cache cleanup */
- schedule(hlcache->params.bg_clean_time / 10, hlcache_clean, NULL);
+ guit->browser->schedule(hlcache->params.bg_clean_time, hlcache_clean, NULL);
return NSERROR_OK;
}
@@ -545,7 +545,7 @@ hlcache_initialise(const struct hlcache_parameters *hlcache_parameters)
void hlcache_stop(void)
{
/* Remove the hlcache_clean schedule */
- schedule_remove(hlcache_clean, NULL);
+ guit->browser->schedule(-1, hlcache_clean, NULL);
}
/* See hlcache.h for documentation */
diff --git a/content/llcache.c b/content/llcache.c
index e4baec6..112a7fa 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -38,6 +38,12 @@
/** Define to enable tracing of llcache operations. */
#undef LLCACHE_TRACE
+#ifdef LLCACHE_TRACE
+#define LLCACHE_LOG(x) LOG(x)
+#else
+#define LLCACHE_LOG(x)
+#endif
+
/** State of a low-level cache object fetch */
typedef enum {
LLCACHE_FETCH_INIT, /**< Initial state, before fetch */
@@ -75,7 +81,7 @@ typedef struct llcache_object_user {
typedef struct {
uint32_t flags; /**< Fetch flags */
nsurl *referer; /**< Referring URL, or NULL if none */
- llcache_post_data *post; /**< POST data, or NULL for GET */
+ llcache_post_data *post; /**< POST data, or NULL for GET */
struct fetch *fetch; /**< Fetch handle for this object */
@@ -123,8 +129,7 @@ struct llcache_object {
llcache_object *next; /**< Next in list */
nsurl *url; /**< Post-redirect URL for object */
- bool has_query; /**< URL has a query segment */
-
+
/** \todo We need a generic dynamic buffer object */
uint8_t *source_data; /**< Source data for object */
size_t source_len; /**< Byte length of source data */
@@ -137,7 +142,7 @@ struct llcache_object {
llcache_cache_control cache; /**< Cache control data for object */
llcache_object *candidate; /**< Object to use, if fetch determines
* that it is still fresh */
- uint32_t candidate_count; /**< Count of objects this is a
+ uint32_t candidate_count; /**< Count of objects this is a
* candidate for */
llcache_header *headers; /**< Fetch headers */
@@ -200,9 +205,7 @@ static nserror llcache_object_user_new(llcache_handle_callback cb, void *pw,
u->handle = h;
-#ifdef LLCACHE_TRACE
- LOG(("Created user %p (%p, %p, %p)", u, h, (void *) cb, pw));
-#endif
+ LLCACHE_LOG(("Created user %p (%p, %p, %p)", u, h, (void *) cb, pw));
*user = u;
@@ -219,13 +222,11 @@ static nserror llcache_object_user_new(llcache_handle_callback cb, void *pw,
*/
static nserror llcache_object_user_destroy(llcache_object_user *user)
{
-#ifdef LLCACHE_TRACE
- LOG(("Destroyed user %p", user));
-#endif
-
+ LLCACHE_LOG(("Destroyed user %p", user));
+
assert(user->next == NULL);
assert(user->prev == NULL);
-
+
if (user->handle != NULL)
free(user->handle);
@@ -241,7 +242,7 @@ static nserror llcache_object_user_destroy(llcache_object_user *user)
* \param user User to remove
* \return NSERROR_OK.
*/
-static nserror llcache_object_remove_user(llcache_object *object,
+static nserror llcache_object_remove_user(llcache_object *object,
llcache_object_user *user)
{
assert(user != NULL);
@@ -249,7 +250,7 @@ static nserror llcache_object_remove_user(llcache_object *object,
assert(object->users != NULL);
assert(user->handle == NULL || user->handle->object == object);
assert((user->prev != NULL) || (object->users == user));
-
+
if (user == object->users)
object->users = user->next;
else
@@ -257,12 +258,10 @@ static nserror llcache_object_remove_user(llcache_object *object,
if (user->next != NULL)
user->next->prev = user->prev;
-
+
user->next = user->prev = NULL;
-
-#ifdef LLCACHE_TRACE
- LOG(("Removing user %p from %p", user, object));
-#endif
+
+ LLCACHE_LOG(("Removing user %p from %p", user, object));
return NSERROR_OK;
}
@@ -279,7 +278,7 @@ static nserror llcache_send_event_to_users(llcache_object *object,
{
nserror error = NSERROR_OK;
llcache_object_user *user, *next_user;
-
+
user = object->users;
while (user != NULL) {
user->iterator_target = true;
@@ -301,7 +300,7 @@ static nserror llcache_send_event_to_users(llcache_object *object,
user = next_user;
}
-
+
return error;
}
@@ -318,9 +317,7 @@ static nserror llcache_object_new(nsurl *url, llcache_object **result)
if (obj == NULL)
return NSERROR_NOMEM;
-#ifdef LLCACHE_TRACE
- LOG(("Created object %p (%s)", obj, nsurl_access(url)));
-#endif
+ LLCACHE_LOG(("Created object %p (%s)", obj, nsurl_access(url)));
obj->url = nsurl_ref(url);
@@ -336,7 +333,7 @@ static nserror llcache_object_new(nsurl *url, llcache_object **result)
* \param clone Pointer to location to receive clone
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_post_data_clone(const llcache_post_data *orig,
+static nserror llcache_post_data_clone(const llcache_post_data *orig,
llcache_post_data **clone)
{
llcache_post_data *post_clone;
@@ -379,17 +376,31 @@ static nserror llcache_post_data_clone(const llcache_post_data *orig,
* \param value Pointer to location to receive header value
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
+static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
char **name, char **value)
{
char *n, *v;
const uint8_t *colon;
+ /* Strip leading whitespace from name */
+ while (data[0] == ' ' || data[0] == '\t' ||
+ data[0] == '\r' || data[0] == '\n') {
+ data++;
+ }
+
/* Find colon */
colon = (const uint8_t *) strchr((const char *) data, ':');
if (colon == NULL) {
/* Failed, assume a key with no value */
- n = strdup((const char *) data);
+ colon = data + strlen((const char *)data);
+
+ /* Strip trailing whitespace from name */
+ while ((colon > data) &&
+ (colon[-1] == ' ' || colon[-1] == '\t' ||
+ colon[-1] == '\r' || colon[-1] == '\n')) {
+ colon--;
+ }
+ n = strndup((const char *) data, colon - data);
if (n == NULL)
return NSERROR_NOMEM;
@@ -401,15 +412,9 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
} else {
/* Split header into name & value */
- /* Strip leading whitespace from name */
- while (data[0] == ' ' || data[0] == '\t' ||
- data[0] == '\r' || data[0] == '\n') {
- data++;
- }
-
/* Strip trailing whitespace from name */
- while (colon > data && (colon[-1] == ' ' ||
- colon[-1] == '\t' || colon[-1] == '\r' ||
+ while (colon > data && (colon[-1] == ' ' ||
+ colon[-1] == '\t' || colon[-1] == '\r' ||
colon[-1] == '\n'))
colon--;
@@ -425,12 +430,12 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
/* Skip over colon and any subsequent whitespace */
do {
colon++;
- } while (*colon == ' ' || *colon == '\t' ||
+ } while (*colon == ' ' || *colon == '\t' ||
*colon == '\r' || *colon == '\n');
/* Strip trailing whitespace from value */
- while (len > 0 && (data[len - 1] == ' ' ||
- data[len - 1] == '\t' ||
+ while (len > 0 && (data[len - 1] == ' ' ||
+ data[len - 1] == '\t' ||
data[len - 1] == '\r' ||
data[len - 1] == '\n')) {
len--;
@@ -459,11 +464,11 @@ static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
* \param value Pointer to location to receive header value
* \return NSERROR_OK on success, appropriate error otherwise
*
- * \note This function also has the side-effect of updating
+ * \note This function also has the side-effect of updating
* the cache control data for the object if an interesting
* header is encountered
*/
-static nserror llcache_fetch_parse_header(llcache_object *object,
+static nserror llcache_fetch_parse_header(llcache_object *object,
const uint8_t *data, size_t len, char **name, char **value)
{
nserror error;
@@ -499,13 +504,13 @@ static nserror llcache_fetch_parse_header(llcache_object *object,
while (*comma != '\0' && *comma != ',')
comma++;
- if (8 < comma - start && (strncasecmp(start,
- "no-cache", 8) == 0 ||
+ if (8 < comma - start && (strncasecmp(start,
+ "no-cache", 8) == 0 ||
strncasecmp(start, "no-store", 8) == 0))
/* When we get a disk cache we should
* distinguish between these two */
object->cache.no_cache = LLCACHE_VALIDATE_ALWAYS;
- else if (7 < comma - start &&
+ else if (7 < comma - start &&
strncasecmp(start, "max-age", 7) == 0) {
/* Find '=' */
while (start < comma && *start != '=')
@@ -547,7 +552,7 @@ static nserror llcache_fetch_parse_header(llcache_object *object,
#undef SKIP_ST
- return NSERROR_OK;
+ return NSERROR_OK;
}
/* Destroy headers */
@@ -581,7 +586,7 @@ static inline void llcache_invalidate_cache_control_data(llcache_object *object)
* \param len Byte length of header
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror llcache_fetch_process_header(llcache_object *object,
+static nserror llcache_fetch_process_header(llcache_object *object,
const uint8_t *data, size_t len)
{
nserror error;
@@ -589,14 +594,14 @@ static nserror llcache_fetch_process_header(llcache_object *object,
llcache_header *temp;
/* The headers for multiple HTTP responses may be delivered to us if
- * the fetch layer receives a 401 response for which it has
+ * the fetch layer receives a 401 response for which it has
* authentication credentials. This will result in a silent re-request
* after which we'll receive the actual response headers for the
* object we want to fetch (assuming that the credentials were correct
* of course)
*
- * Therefore, if the header is an HTTP response start marker, then we
- * must discard any headers we've read so far, reset the cache data
+ * Therefore, if the header is an HTTP response start marker, then we
+ * must discard any headers we've read so far, reset the cache data
* that we might have computed, and start again.
*/
/** \todo Properly parse the response line */
@@ -616,8 +621,15 @@ static nserror llcache_fetch_process_header(llcache_object *object,
return error;
}
+ /* deal with empty header */
+ if (name[0] == 0) {
+ free(name);
+ free(value);
+ return NSERROR_OK;
+ }
+
/* Append header data to the object's headers array */
- temp = realloc(object->headers, (object->num_headers + 1) *
+ temp = realloc(object->headers, (object->num_headers + 1) *
sizeof(llcache_header));
if (temp == NULL) {
free(name);
@@ -642,7 +654,7 @@ static nserror llcache_fetch_process_header(llcache_object *object,
* \return NSERROR_OK on success, appropriate error otherwise
*
* \pre The fetch parameters in object->fetch must be populated
- */
+ */
static nserror llcache_object_refetch(llcache_object *object)
{
const char *urlenc = NULL;
@@ -663,7 +675,7 @@ static nserror llcache_object_refetch(llcache_object *object)
return NSERROR_NOMEM;
if (object->cache.etag != NULL) {
- const size_t len = SLEN("If-None-Match: ") +
+ const size_t len = SLEN("If-None-Match: ") +
strlen(object->cache.etag) + 1;
headers[header_idx] = malloc(len);
@@ -703,9 +715,7 @@ static nserror llcache_object_refetch(llcache_object *object)
/* Reset fetch state */
object->fetch.state = LLCACHE_FETCH_INIT;
-#ifdef LLCACHE_TRACE
- LOG(("Refetching %p", object));
-#endif
+ LLCACHE_LOG(("Refetching %p", object));
/* Kick off fetch */
object->fetch.fetch = fetch_start(object->url, object->fetch.referer,
@@ -739,7 +749,7 @@ static nserror llcache_object_refetch(llcache_object *object)
* \return NSERROR_OK on success, appropriate error otherwise
*
* \pre object::url must contain the URL to fetch
- * \pre If there is a freshness validation candidate,
+ * \pre If there is a freshness validation candidate,
* object::candidate and object::cache must be filled in
* \pre There must not be a fetch in progress for \a object
*/
@@ -751,9 +761,7 @@ static nserror llcache_object_fetch(llcache_object *object, uint32_t flags,
nsurl *referer_clone = NULL;
llcache_post_data *post_clone = NULL;
-#ifdef LLCACHE_TRACE
- LOG(("Starting fetch for %p", object));
-#endif
+ LLCACHE_LOG(("Starting fetch for %p", object));
if (post != NULL) {
error = llcache_post_data_clone(post, &post_clone);
@@ -786,9 +794,7 @@ static nserror llcache_object_destroy(llcache_object *object)
{
size_t i;
-#ifdef LLCACHE_TRACE
- LOG(("Destroying object %p", object));
-#endif
+ LLCACHE_LOG(("Destroying object %p", object));
nsurl_unref(object->url);
free(object->source_data);
@@ -872,9 +878,7 @@ llcache_object_rfc2616_remaining_lifetime(const llcache_cache_control *cd)
else
freshness_lifetime = 0;
-#ifdef LLCACHE_TRACE
- LOG(("%d:%d", freshness_lifetime, current_age));
-#endif
+ LLCACHE_LOG(("%d:%d", freshness_lifetime, current_age));
if ((cd->no_cache == LLCACHE_VALIDATE_FRESH) &&
(freshness_lifetime > current_age)) {
@@ -903,17 +907,15 @@ static bool llcache_object_is_fresh(const llcache_object *object)
remaining_lifetime = llcache_object_rfc2616_remaining_lifetime(cd);
-#ifdef LLCACHE_TRACE
- LOG(("%p: (%d > 0 || %d != %d)", object,
+ LLCACHE_LOG(("%p: (%d > 0 || %d != %d)", object,
remaining_lifetime,
object->fetch.state, LLCACHE_FETCH_COMPLETE));
-#endif
/* The object is fresh if:
* - it was not forbidden from being returned from the cache
* unvalidated.
*
- * - it has remaining lifetime or still being fetched.
+ * - it has remaining lifetime or still being fetched.
*/
return ((cd->no_cache == LLCACHE_VALIDATE_FRESH) &&
((remaining_lifetime > 0) ||
@@ -970,7 +972,7 @@ static nserror llcache_object_clone_cache_data(llcache_object *source,
if (source->cache.no_cache != LLCACHE_VALIDATE_FRESH)
destination->cache.no_cache = source->cache.no_cache;
-
+
if (source->cache.last_modified != 0)
destination->cache.last_modified = source->cache.last_modified;
@@ -995,14 +997,13 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
nserror error;
llcache_object *obj, *newest = NULL;
-#ifdef LLCACHE_TRACE
- LOG(("Searching cache for %s (%x %s %p)", url, flags, referer, post));
-#endif
+ LLCACHE_LOG(("Searching cache for %s (%x %p %p)",
+ nsurl_access(url), flags, referer, post));
/* Search for the most recently fetched matching object */
for (obj = llcache->cached_objects; obj != NULL; obj = obj->next) {
- if ((newest == NULL ||
+ if ((newest == NULL ||
obj->cache.req_time > newest->cache.req_time) &&
nsurl_compare(obj->url, url,
NSURL_COMPLETE) == true) {
@@ -1014,9 +1015,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
/* Found a suitable object, and it's still fresh, so use it */
obj = newest;
-#ifdef LLCACHE_TRACE
- LOG(("Found fresh %p", obj));
-#endif
+ LLCACHE_LOG(("Found fresh %p", obj));
/* The client needs to catch up with the object's state.
* This will occur the next time that llcache_poll is called.
@@ -1029,16 +1028,14 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
if (error != NSERROR_OK)
return error;
-#ifdef LLCACHE_TRACE
- LOG(("Found candidate %p (%p)", obj, newest));
-#endif
+ LLCACHE_LOG(("Found candidate %p (%p)", obj, newest));
/* Clone candidate's cache data */
error = llcache_object_clone_cache_data(newest, obj, true);
if (error != NSERROR_OK) {
llcache_object_destroy(obj);
return error;
- }
+ }
/* Record candidate, so we can fall back if it is still fresh */
newest->candidate_count++;
@@ -1062,9 +1059,7 @@ static nserror llcache_object_retrieve_from_cache(nsurl *url, uint32_t flags,
if (error != NSERROR_OK)
return error;
-#ifdef LLCACHE_TRACE
- LOG(("Not found %p", obj));
-#endif
+ LLCACHE_LOG(("Not found %p", obj));
/* Attempt to kick-off fetch */
error = llcache_object_fetch(obj, flags, referer, post,
@@ -1100,33 +1095,45 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
{
nserror error;
llcache_object *obj;
- bool has_query;
nsurl *defragmented_url;
+ bool uncachable = false;
-#ifdef LLCACHE_TRACE
- LOG(("Retrieve %s (%x, %s, %p)", url, flags, referer, post));
-#endif
-
- /**
- * Caching Rules:
- *
- * 1) Forced fetches are never cached
- * 2) POST requests are never cached
- */
+ LLCACHE_LOG(("Retrieve %s (%x, %p, %p)",
+ nsurl_access(url), flags, referer, post));
- /* Look for a query segment */
- has_query = nsurl_has_component(url, NSURL_QUERY);
/* Get rid of any url fragment */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- error = nsurl_defragment(url, &defragmented_url);
- if (error != NSERROR_OK)
- return error;
+ error = nsurl_defragment(url, &defragmented_url);
+ if (error != NSERROR_OK)
+ return error;
+
+ /* determine if content is cachable */
+ if ((flags & LLCACHE_RETRIEVE_FORCE_FETCH) != 0) {
+ /* Forced fetches are never cached */
+ uncachable = true;
+ } else if (post != NULL) {
+ /* POST requests are never cached */
+ uncachable = true;
} else {
- defragmented_url = nsurl_ref(url);
+ /* only http and https schemes are cached */
+ lwc_string *scheme;
+ bool match;
+
+ scheme = nsurl_get_component(defragmented_url, NSURL_SCHEME);
+
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_http,
+ &match) == lwc_error_ok &&
+ (match == false)) {
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_https,
+ &match) == lwc_error_ok &&
+ (match == false)) {
+ uncachable = true;
+ }
+ }
}
- if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) {
+
+ if (uncachable) {
/* Create new object */
error = llcache_object_new(defragmented_url, &obj);
if (error != NSERROR_OK) {
@@ -1135,7 +1142,7 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
}
/* Attempt to kick-off fetch */
- error = llcache_object_fetch(obj, flags, referer, post,
+ error = llcache_object_fetch(obj, flags, referer, post,
redirect_count);
if (error != NSERROR_OK) {
llcache_object_destroy(obj);
@@ -1155,17 +1162,13 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
/* Returned object is already in the cached list */
}
-
- obj->has_query = has_query;
-#ifdef LLCACHE_TRACE
- LOG(("Retrieved %p", obj));
-#endif
-
+ LLCACHE_LOG(("Retrieved %p", obj));
+
*result = obj;
-
+
nsurl_unref(defragmented_url);
-
+
return NSERROR_OK;
}
@@ -1192,9 +1195,7 @@ static nserror llcache_object_add_user(llcache_object *object,
object->users->prev = user;
object->users = user;
-#ifdef LLCACHE_TRACE
- LOG(("Adding user %p to %p", user, object));
-#endif
+ LLCACHE_LOG(("Adding user %p to %p", user, object));
return NSERROR_OK;
}
@@ -1225,13 +1226,13 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Abort fetch for this object */
fetch_abort(object->fetch.fetch);
object->fetch.fetch = NULL;
-
+
/* Invalidate the cache control data */
llcache_invalidate_cache_control_data(object);
/* And mark it complete */
object->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
/* Forcibly stop redirecting if we've followed too many redirects */
#define REDIRECT_LIMIT 10
if (object->fetch.redirect_count > REDIRECT_LIMIT) {
@@ -1239,7 +1240,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
event.type = LLCACHE_EVENT_ERROR;
event.data.msg = messages_get("BadRedirect");
-
+
return llcache_send_event_to_users(object, &event);
}
#undef REDIRECT_LIMIT
@@ -1306,7 +1307,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Attempt to fetch target URL */
error = llcache_object_retrieve(url, object->fetch.flags,
- object->fetch.referer, post,
+ object->fetch.referer, post,
object->fetch.redirect_count + 1, &dest);
/* No longer require url */
@@ -1326,7 +1327,7 @@ static nserror llcache_fetch_redirect(llcache_object *object, const char *target
/* Dest is now our object */
*replacement = dest;
- return NSERROR_OK;
+ return NSERROR_OK;
}
/**
@@ -1373,14 +1374,14 @@ static nserror llcache_fetch_notmodified(llcache_object *object,
object->candidate->candidate_count--;
/* Clone our cache control data into the candidate */
- llcache_object_clone_cache_data(object, object->candidate,
+ llcache_object_clone_cache_data(object, object->candidate,
false);
/* Bring candidate's cache data up to date */
llcache_object_cache_update(object->candidate);
/* Revert no-cache to normal, if required */
- if (object->candidate->cache.no_cache ==
+ if (object->candidate->cache.no_cache ==
LLCACHE_VALIDATE_ONCE) {
- object->candidate->cache.no_cache =
+ object->candidate->cache.no_cache =
LLCACHE_VALIDATE_FRESH;
}
@@ -1415,7 +1416,7 @@ static nserror llcache_fetch_notmodified(llcache_object *object,
* \param len Byte length of data
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-static nserror llcache_fetch_process_data(llcache_object *object, const uint8_t *data,
+static nserror llcache_fetch_process_data(llcache_object *object, const uint8_t *data,
size_t len)
{
/* Resize source buffer if it's too small */
@@ -1464,7 +1465,7 @@ static nserror llcache_query_handle_response(bool proceed, void *cbpw)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
return llcache_send_event_to_users(object, &event);
}
@@ -1511,7 +1512,7 @@ static nserror llcache_fetch_auth(llcache_object *object, const char *realm)
object->fetch.outstanding_query = true;
- error = llcache->query_cb(&query, llcache->query_cb_pw,
+ error = llcache->query_cb(&query, llcache->query_cb_pw,
llcache_query_handle_response, object);
} else {
llcache_event event;
@@ -1523,7 +1524,7 @@ static nserror llcache_fetch_auth(llcache_object *object, const char *realm)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
}
} else {
@@ -1578,7 +1579,7 @@ static nserror llcache_fetch_cert_error(llcache_object *object,
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
}
@@ -1612,7 +1613,7 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
event.data.msg = messages_get("FetchFailed");
-
+
error = llcache_send_event_to_users(object, &event);
} else {
/* Flag that we've tried to downgrade, so that if the
@@ -1636,17 +1637,15 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
llcache_object *object = p;
llcache_event event;
-#ifdef LLCACHE_TRACE
- LOG(("Fetch event %d for %p", msg->type, object));
-#endif
+ LLCACHE_LOG(("Fetch event %d for %p", msg->type, object));
switch (msg->type) {
case FETCH_HEADER:
/* Received a fetch header */
object->fetch.state = LLCACHE_FETCH_HEADERS;
- error = llcache_fetch_process_header(object,
- msg->data.header_or_data.buf,
+ error = llcache_fetch_process_header(object,
+ msg->data.header_or_data.buf,
msg->data.header_or_data.len);
break;
@@ -1660,7 +1659,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->candidate = NULL;
}
- error = llcache_fetch_redirect(object,
+ error = llcache_fetch_redirect(object,
msg->data.redirect, &object);
break;
case FETCH_NOTMODIFIED:
@@ -1672,7 +1671,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
case FETCH_DATA:
/* Received some data */
if (object->fetch.state != LLCACHE_FETCH_DATA) {
- /* On entry into this state, check if we need to
+ /* On entry into this state, check if we need to
* invalidate the cache control data. We are guaranteed
* to have received all response headers.
*
@@ -1687,7 +1686,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
long http_code = fetch_http_code(object->fetch.fetch);
if ((http_code != 200 && http_code != 203) ||
- (object->has_query &&
+ (nsurl_has_component(object->url, NSURL_QUERY) &&
(object->cache.max_age == INVALID_AGE &&
object->cache.expires == 0))) {
/* Invalidate cache control data */
@@ -1703,7 +1702,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->fetch.state = LLCACHE_FETCH_DATA;
- error = llcache_fetch_process_data(object,
+ error = llcache_fetch_process_data(object,
msg->data.header_or_data.buf,
msg->data.header_or_data.len);
break;
@@ -1716,7 +1715,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->fetch.fetch = NULL;
/* Shrink source buffer to required size */
- temp = realloc(object->source_data,
+ temp = realloc(object->source_data,
object->source_len);
/* If source_len is 0, then temp may be NULL */
if (temp != NULL || object->source_len == 0) {
@@ -1748,9 +1747,9 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
event.type = LLCACHE_EVENT_ERROR;
event.data.msg = msg->data.error;
-
+
error = llcache_send_event_to_users(object, &event);
-
+
break;
case FETCH_PROGRESS:
/* Progress update */
@@ -1758,7 +1757,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
event.data.msg = msg->data.progress;
error = llcache_send_event_to_users(object, &event);
-
+
break;
/* Events requiring action */
@@ -1782,8 +1781,8 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
object->candidate = NULL;
}
- error = llcache_fetch_cert_error(object,
- msg->data.cert_err.certs,
+ error = llcache_fetch_cert_error(object,
+ msg->data.cert_err.certs,
msg->data.cert_err.num_certs);
break;
case FETCH_SSL_ERR:
@@ -1892,7 +1891,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
#endif
/**
- * State transitions and event emission for users.
+ * State transitions and event emission for users.
* Rows: user state. Cols: object state.
*
* User\Obj INIT HEADERS DATA COMPLETE
@@ -1924,8 +1923,8 @@ static nserror llcache_object_notify_users(llcache_object *object)
user->iterator_target = true;
/* A note on the computation of next_user:
- *
- * Within this loop, we may make a number of calls to
+ *
+ * Within this loop, we may make a number of calls to
* client code. Our contract with clients is that they
* can do whatever they like from within their callback
* handlers. This is so that we limit the pain of
@@ -1936,7 +1935,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
* user list. In the common case, the user they attempt
* to remove is the current iteration target, and we
* already protect against that causing problems here.
- * However, no such protection exists if the client
+ * However, no such protection exists if the client
* attempts to remove other users from this object's
* user list.
*
@@ -1957,13 +1956,13 @@ static nserror llcache_object_notify_users(llcache_object *object)
emitted_notify = true;
}
- LOG(("User %p state: %d Object state: %d",
+ LOG(("User %p state: %d Object state: %d",
user, handle->state, objstate));
}
#endif
/* User: INIT, Obj: HEADERS, DATA, COMPLETE => User->HEADERS */
- if (handle->state == LLCACHE_FETCH_INIT &&
+ if (handle->state == LLCACHE_FETCH_INIT &&
objstate > LLCACHE_FETCH_INIT) {
handle->state = LLCACHE_FETCH_HEADERS;
}
@@ -1991,7 +1990,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->state = LLCACHE_FETCH_HEADERS;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the event next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2010,15 +2009,15 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* Construct HAD_DATA event */
event.type = LLCACHE_EVENT_HAD_DATA;
- event.data.data.buf =
+ event.data.data.buf =
object->source_data + handle->bytes;
- event.data.data.len =
+ event.data.data.len =
object->source_len - handle->bytes;
/* Update record of last byte emitted */
- if (object->fetch.flags &
+ if (object->fetch.flags &
LLCACHE_RETRIEVE_STREAM_DATA) {
- /* Streaming, so reset to zero to
+ /* Streaming, so reset to zero to
* minimise amount of cached source data.
* Additionally, we don't support replay
* when streaming. */
@@ -2044,7 +2043,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->bytes = orig_handle_read;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the data next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2077,7 +2076,7 @@ static nserror llcache_object_notify_users(llcache_object *object)
/* User requested replay */
handle->state = LLCACHE_FETCH_DATA;
- /* Continue with the next user -- we'll
+ /* Continue with the next user -- we'll
* reemit the event next time round */
user->iterator_target = false;
next_user = user->next;
@@ -2116,37 +2115,35 @@ static nserror llcache_object_snapshot(llcache_object *object,
{
llcache_object *newobj;
nserror error;
-
+
error = llcache_object_new(object->url, &newobj);
-
+
if (error != NSERROR_OK)
return error;
-
- newobj->has_query = object->has_query;
newobj->source_alloc = newobj->source_len = object->source_len;
-
+
if (object->source_len > 0) {
newobj->source_data = malloc(newobj->source_alloc);
if (newobj->source_data == NULL) {
llcache_object_destroy(newobj);
return NSERROR_NOMEM;
}
- memcpy(newobj->source_data, object->source_data,
+ memcpy(newobj->source_data, object->source_data,
newobj->source_len);
}
-
+
if (object->num_headers > 0) {
- newobj->headers = calloc(sizeof(llcache_header),
+ newobj->headers = calloc(sizeof(llcache_header),
object->num_headers);
if (newobj->headers == NULL) {
llcache_object_destroy(newobj);
return NSERROR_NOMEM;
}
while (newobj->num_headers < object->num_headers) {
- llcache_header *nh =
+ llcache_header *nh =
&(newobj->headers[newobj->num_headers]);
- llcache_header *oh =
+ llcache_header *oh =
&(object->headers[newobj->num_headers]);
newobj->num_headers += 1;
nh->name = strdup(oh->name);
@@ -2157,11 +2154,11 @@ static nserror llcache_object_snapshot(llcache_object *object,
}
}
}
-
+
newobj->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
*snapshot = newobj;
-
+
return NSERROR_OK;
}
@@ -2180,12 +2177,10 @@ void llcache_clean(void)
uint32_t llcache_size = 0;
int remaining_lifetime;
-#ifdef LLCACHE_TRACE
- LOG(("Attempting cache clean"));
-#endif
+ LLCACHE_LOG(("Attempting cache clean"));
/* Candidates for cleaning are (in order of priority):
- *
+ *
* 1) Uncacheable objects with no users
* 2) Stale cacheable objects with no users or pending fetches
* 3) Fresh cacheable objects with no users or pending fetches
@@ -2196,14 +2191,13 @@ void llcache_clean(void)
next = object->next;
/* The candidate count of uncacheable objects is always 0 */
- if ((object->users == NULL) &&
+ if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
(object->fetch.outstanding_query == false)) {
-#ifdef LLCACHE_TRACE
- LOG(("Found victim %p", object));
-#endif
- llcache_object_remove_from_list(object,
+ LLCACHE_LOG(("Found victim %p", object));
+
+ llcache_object_remove_from_list(object,
&llcache->uncached_objects);
llcache_object_destroy(object);
} else {
@@ -2227,9 +2221,8 @@ void llcache_clean(void)
llcache_size += object->source_len + sizeof(*object);
} else {
/* object is not fresh */
-#ifdef LLCACHE_TRACE
- LOG(("Found stale cacheable object (%p) with no users or pending fetches", object));
-#endif
+ LLCACHE_LOG(("Found stale cacheable object (%p) with no users or pending fetches", object));
+
llcache_object_remove_from_list(object,
&llcache->cached_objects);
llcache_object_destroy(object);
@@ -2243,18 +2236,17 @@ void llcache_clean(void)
* fetches, only if the cache exceeds the configured size.
*/
if (llcache->limit < llcache_size) {
- for (object = llcache->cached_objects; object != NULL;
+ for (object = llcache->cached_objects; object != NULL;
object = next) {
next = object->next;
- if ((object->users == NULL) &&
+ if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
(object->fetch.outstanding_query == false)) {
-#ifdef LLCACHE_TRACE
- LOG(("Found victim %p", object));
-#endif
- llcache_size -=
+ LLCACHE_LOG(("Found victim %p", object));
+
+ llcache_size -=
object->source_len + sizeof(*object);
llcache_object_remove_from_list(object,
@@ -2264,14 +2256,11 @@ void llcache_clean(void)
}
}
-#ifdef LLCACHE_TRACE
- LOG(("Size: %u", llcache_size));
-#endif
-
+ LLCACHE_LOG(("Size: %u", llcache_size));
}
/* See llcache.h for documentation */
-nserror
+nserror
llcache_initialise(llcache_query_callback cb, void *pw, uint32_t llcache_limit)
{
llcache = calloc(1, sizeof(struct llcache_s));
@@ -2330,7 +2319,7 @@ void llcache_finalise(void)
}
/* Fetch system has already been destroyed */
- object->fetch.fetch = NULL;
+ object->fetch.fetch = NULL;
llcache_object_destroy(object);
}
@@ -2343,11 +2332,11 @@ void llcache_finalise(void)
nserror llcache_poll(void)
{
llcache_object *object;
-
+
fetch_poll();
-
+
/* Catch new users up with state of objects */
- for (object = llcache->cached_objects; object != NULL;
+ for (object = llcache->cached_objects; object != NULL;
object = object->next) {
llcache_object_notify_users(object);
}
@@ -2415,7 +2404,7 @@ nserror llcache_handle_release(llcache_handle *handle)
assert(user != NULL);
if (user->iterator_target) {
- /* Can't remove / delete user object if it's
+ /* Can't remove / delete user object if it's
* the target of an iterator */
user->queued_for_delete = true;
} else {
@@ -2425,8 +2414,8 @@ nserror llcache_handle_release(llcache_handle *handle)
error = llcache_object_user_destroy(user);
}
}
-
- return error;
+
+ return error;
}
/* See llcache.h for documentation */
@@ -2434,14 +2423,14 @@ nserror llcache_handle_clone(llcache_handle *handle, llcache_handle **result)
{
nserror error;
llcache_object_user *newuser;
-
+
error = llcache_object_user_new(handle->cb, handle->pw, &newuser);
if (error == NSERROR_OK) {
llcache_object_add_user(handle->object, newuser);
newuser->handle->state = handle->state;
*result = newuser->handle;
}
-
+
return error;
}
@@ -2452,13 +2441,13 @@ nserror llcache_handle_abort(llcache_handle *handle)
llcache_object *object = handle->object, *newobject;
nserror error = NSERROR_OK;
bool all_alone = true;
-
+
/* Determine if we are the only user */
if (user->prev != NULL)
all_alone = false;
if (user->next != NULL)
all_alone = false;
-
+
if (all_alone == false) {
/* We must snapshot this object */
error = llcache_object_snapshot(object, &newobject);
@@ -2468,7 +2457,7 @@ nserror llcache_handle_abort(llcache_handle *handle)
/* Move across to the new object */
if (user->iterator_target) {
/* User is current iterator target, clone it */
- llcache_object_user *newuser =
+ llcache_object_user *newuser =
calloc(1, sizeof(llcache_object_user));
if (newuser == NULL) {
llcache_object_destroy(newobject);
@@ -2487,9 +2476,9 @@ nserror llcache_handle_abort(llcache_handle *handle)
llcache_object_remove_user(object, user);
llcache_object_add_user(newobject, user);
}
-
+
/* Add new object to uncached list */
- llcache_object_add_to_list(newobject,
+ llcache_object_add_to_list(newobject,
&llcache->uncached_objects);
} else {
/* We're the only user, so abort any fetch in progress */
@@ -2497,13 +2486,13 @@ nserror llcache_handle_abort(llcache_handle *handle)
fetch_abort(object->fetch.fetch);
object->fetch.fetch = NULL;
}
-
+
object->fetch.state = LLCACHE_FETCH_COMPLETE;
-
+
/* Invalidate cache control data */
llcache_invalidate_cache_control_data(object);
}
-
+
return error;
}
@@ -2519,7 +2508,7 @@ nserror llcache_handle_force_stream(llcache_handle *handle)
/* Forcibly uncache this object */
if (llcache_object_in_list(object, llcache->cached_objects)) {
- llcache_object_remove_from_list(object,
+ llcache_object_remove_from_list(object,
&llcache->cached_objects);
llcache_object_add_to_list(object, &llcache->uncached_objects);
}
@@ -2532,8 +2521,8 @@ nserror llcache_handle_force_stream(llcache_handle *handle)
/* See llcache.h for documentation */
nserror llcache_handle_invalidate_cache_data(llcache_handle *handle)
{
- if (handle->object != NULL && handle->object->fetch.fetch == NULL &&
- handle->object->cache.no_cache ==
+ if (handle->object != NULL && handle->object->fetch.fetch == NULL &&
+ handle->object->cache.no_cache ==
LLCACHE_VALIDATE_FRESH) {
handle->object->cache.no_cache = LLCACHE_VALIDATE_ONCE;
}
@@ -2557,7 +2546,7 @@ const uint8_t *llcache_handle_get_source_data(const llcache_handle *handle,
}
/* See llcache.h for documentation */
-const char *llcache_handle_get_header(const llcache_handle *handle,
+const char *llcache_handle_get_header(const llcache_handle *handle,
const char *key)
{
const llcache_object *object = handle->object;
@@ -2576,9 +2565,8 @@ const char *llcache_handle_get_header(const llcache_handle *handle,
}
/* See llcache.h for documentation */
-bool llcache_handle_references_same_object(const llcache_handle *a,
+bool llcache_handle_references_same_object(const llcache_handle *a,
const llcache_handle *b)
{
return a->object == b->object;
}
-
diff --git a/content/mimesniff.c b/content/mimesniff.c
index 5b2c14f..e8ebf87 100644
--- a/content/mimesniff.c
+++ b/content/mimesniff.c
@@ -155,7 +155,7 @@ static bool mimesniff__has_binary_octets(const uint8_t *data, size_t len)
static nserror mimesniff__match_mp4(const uint8_t *data, size_t len,
lwc_string **effective_type)
{
- size_t box_size, i;
+ uint32_t box_size, i;
/* ISO/IEC 14496-12:2008 $4.3 says (effectively):
*
@@ -204,7 +204,9 @@ static nserror mimesniff__match_mp4(const uint8_t *data, size_t len,
/* Search each compatible brand in the box for "mp4" */
for (i = 16; i <= box_size - 4; i += 4) {
- if (data[i] == 'm' && data[i+1] == 'p' && data[i+2] == '4') {
+ if (data[i] == 'm' &&
+ data[i+1] == 'p' &&
+ data[i+2] == '4') {
*effective_type = lwc_string_ref(video_mp4);
return NSERROR_OK;
}
diff --git a/content/urldb.c b/content/urldb.c
index f55a1c2..1e17ac5 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1806,14 +1806,9 @@ struct path_data *urldb_add_path(lwc_string *scheme, unsigned int port,
free(path_query);
if (d && !d->url) {
- /* Insert URL */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- nserror err = nsurl_defragment(url, &d->url);
- if (err != NSERROR_OK)
- return NULL;
- } else {
- d->url = nsurl_ref(url);
- }
+ /* Insert defragmented URL */
+ if (nsurl_defragment(url, &d->url) != NSERROR_OK)
+ return NULL;
}
return d;
@@ -2728,12 +2723,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
assert(url && header);
/* Get defragmented URL, as 'urlt' */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- if (nsurl_defragment(url, &urlt) != NSERROR_OK)
- return NULL;
- } else {
- urlt = nsurl_ref(url);
- }
+ if (nsurl_defragment(url, &urlt) != NSERROR_OK)
+ return NULL;
scheme = nsurl_get_component(url, NSURL_SCHEME);
if (scheme == NULL) {
diff --git a/css/css.c b/css/css.c
index 2b4f60a..94c0be3 100644
--- a/css/css.c
+++ b/css/css.c
@@ -17,23 +17,22 @@
*/
#include <assert.h>
-
#include <libwapcaplet/libwapcaplet.h>
#include <dom/dom.h>
#include "content/content_protected.h"
#include "content/fetch.h"
#include "content/hlcache.h"
-#include "css/css.h"
-#include "css/internal.h"
#include "desktop/system_colour.h"
-#include "render/html.h"
#include "utils/corestrings.h"
#include "utils/utils.h"
#include "utils/http.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "css/css.h"
+#include "css/internal.h"
+
/* Define to trace import fetches */
#undef NSCSS_IMPORT_TRACE
diff --git a/desktop/Makefile b/desktop/Makefile
index 0e2e460..a914eb3 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -12,7 +12,7 @@ desktop/version.c: testament utils/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 download.c frames.c local_history.c netsurf.c \
+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
S_BROWSER := $(addprefix desktop/,$(S_BROWSER))
diff --git a/desktop/browser.c b/desktop/browser.c
index a33c1b6..b1e4b75 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -41,15 +41,14 @@
#include "content/fetch.h"
#include "content/hlcache.h"
#include "content/urldb.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
#include "desktop/download.h"
#include "desktop/frames.h"
#include "desktop/global_history.h"
-#include "desktop/gui.h"
#include "desktop/gui_factory.h"
#include "desktop/hotlist.h"
#include "desktop/knockout.h"
-#include "desktop/local_history.h"
#include "utils/nsoption.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
@@ -64,7 +63,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
-#include "utils/schedule.h"
#include "utils/url.h"
#include "utils/utils.h"
#include "utils/utf8.h"
@@ -296,7 +294,7 @@ bool browser_window_redraw_ready(struct browser_window *bw)
return true;
}
-/* exported interface, documented in browser.h */
+/* exported interface, documented in browser_private.h */
void browser_window_update_extent(struct browser_window *bw)
{
if (bw->window != NULL)
@@ -691,62 +689,81 @@ static bool slow_script(void *ctx)
}
/* exported interface, documented in desktop/browser.h */
-
-nserror
-browser_window_create(enum browser_window_nav_flags flags,
- nsurl *url,
- nsurl *referrer,
- struct browser_window *clone,
- struct browser_window **ret_bw)
+nserror browser_window_create(enum browser_window_create_flags flags,
+ nsurl *url, nsurl *referrer,
+ struct browser_window *existing,
+ struct browser_window **bw)
{
- struct browser_window *bw;
- struct browser_window *top;
-
- /* caller must provide window to clone or be adding to history */
- assert(clone ||
- ((flags & BROWSER_WINDOW_HISTORY) != 0));
+ gui_window_create_flags gw_flags = GW_CREATE_NONE;
+ struct browser_window *ret;
+
+ /* Check parameters */
+ if (flags & (BW_CREATE_TAB | BW_CREATE_CLONE)) {
+ if (existing == NULL) {
+ assert(0 && "Failed: No existing window provided.");
+ return NSERROR_BAD_PARAMETER;
+ }
+ }
+ if (!(flags & BW_CREATE_HISTORY)) {
+ if (!(flags & BW_CREATE_CLONE) || existing == NULL) {
+ assert(0 && "Failed: Must have existing for history.");
+ return NSERROR_BAD_PARAMETER;
+ }
+ }
- if ((bw = calloc(1, sizeof(struct browser_window))) == NULL) {
+ if ((ret = calloc(1, sizeof(struct browser_window))) == NULL) {
warn_user("NoMemory", 0);
return NSERROR_NOMEM;
}
/* new javascript context for window */
- bw->jsctx = js_newcontext(nsoption_int(script_timeout),
+ ret->jsctx = js_newcontext(nsoption_int(script_timeout),
slow_script,
NULL);
/* Initialise common parts */
- browser_window_initialise_common(bw, clone);
+ browser_window_initialise_common(flags, ret, existing);
/* window characteristics */
- bw->browser_window_type = BROWSER_WINDOW_NORMAL;
- bw->scrolling = SCROLLING_YES;
- bw->border = true;
- bw->no_resize = true;
- bw->last_action = wallclock();
- bw->focus = bw;
-
- /* gui window */
- /* from the front end's pov, it clones the top level browser window,
- * so find that. */
- top = browser_window_get_root(clone);
-
- bw->window = guit->window->create(bw, top, ((flags & BROWSER_WINDOW_TAB) != 0));
-
- if (bw->window == NULL) {
- browser_window_destroy(bw);
+ ret->browser_window_type = BROWSER_WINDOW_NORMAL;
+ ret->scrolling = SCROLLING_YES;
+ ret->border = true;
+ ret->no_resize = true;
+ ret->last_action = wallclock();
+ ret->focus = ret;
+
+ /* The existing gui_window is on the top-level existing
+ * browser_window. */
+ existing = browser_window_get_root(existing);
+
+ /* Set up gui_window creation flags */
+ if (flags & BW_CREATE_TAB)
+ gw_flags |= GW_CREATE_TAB;
+ if (flags & BW_CREATE_CLONE)
+ gw_flags |= GW_CREATE_CLONE;
+
+ ret->window = guit->window->create(ret,
+ (existing != NULL) ? existing->window : NULL,
+ gw_flags);
+
+ if (ret->window == NULL) {
+ browser_window_destroy(ret);
return NSERROR_BAD_PARAMETER;
}
if (url != NULL) {
- flags |= BROWSER_WINDOW_VERIFIABLE;
- browser_window_navigate(bw, url, referrer, flags, NULL, NULL, NULL);
+ enum browser_window_nav_flags nav_flags = BW_NAVIGATE_NONE;
+ if (flags & BW_CREATE_UNVERIFIABLE)
+ nav_flags |= BW_NAVIGATE_UNVERIFIABLE;
+ if (flags & BW_CREATE_HISTORY)
+ nav_flags |= BW_NAVIGATE_HISTORY;
+ browser_window_navigate(ret, url, referrer, nav_flags, NULL,
+ NULL, NULL);
}
- if (ret_bw != NULL) {
- *ret_bw = bw;
+ if (bw != NULL) {
+ *bw = ret;
}
return NSERROR_OK;
@@ -756,18 +773,25 @@ browser_window_create(enum browser_window_nav_flags flags,
/**
* Initialise common parts of a browser window
*
- * \param bw The window to initialise
- * \param clone The window to clone, or NULL if none
+ * \param flags Flags to control operation
+ * \param bw The window to initialise
+ * \param existing The existing window if cloning, else NULL
*/
-void browser_window_initialise_common(struct browser_window *bw,
- struct browser_window *clone)
+nserror browser_window_initialise_common(enum browser_window_create_flags flags,
+ struct browser_window *bw, struct browser_window *existing)
{
+ nserror err;
assert(bw);
- if (!clone)
- bw->history = history_create();
- else
- bw->history = history_clone(clone->history);
+ if (flags & BW_CREATE_CLONE) {
+ assert(existing != NULL);
+ err = browser_window_history_clone(existing, bw);
+ } else {
+ err = browser_window_history_create(bw);
+ }
+
+ if (err != NSERROR_OK)
+ return err;
/* window characteristics */
bw->refresh_interval = -1;
@@ -786,6 +810,8 @@ void browser_window_initialise_common(struct browser_window *bw,
bw->status_text_len = 0;
bw->status_match = 0;
bw->status_miss = 0;
+
+ return NSERROR_OK;
}
/**
@@ -1088,7 +1114,7 @@ static void browser_window_refresh(void *p)
nsurl *url;
nsurl *refresh;
hlcache_handle *parent = NULL;
- enum browser_window_nav_flags flags = BROWSER_WINDOW_NONE;
+ enum browser_window_nav_flags flags = BW_NAVIGATE_UNVERIFIABLE;
assert(bw->current_content != NULL &&
(content_get_status(bw->current_content) ==
@@ -1107,7 +1133,7 @@ static void browser_window_refresh(void *p)
url = hlcache_handle_get_url(bw->current_content);
if ((url == NULL) || (nsurl_compare(url, refresh, NSURL_COMPLETE))) {
- flags |= BROWSER_WINDOW_HISTORY;
+ flags |= BW_NAVIGATE_HISTORY;
}
/* Treat an (almost) immediate refresh in a top-level browser window as
@@ -1118,7 +1144,7 @@ static void browser_window_refresh(void *p)
* all.
*/
if (bw->refresh_interval <= 100 && bw->parent == NULL) {
- flags |= BROWSER_WINDOW_VERIFIABLE;
+ flags &= ~BW_NAVIGATE_UNVERIFIABLE;
} else {
parent = bw->current_content;
}
@@ -1176,9 +1202,7 @@ static nserror browser_window_callback(hlcache_handle *c,
browser_window_convert_to_download(bw, event->data.download);
if (bw->current_content != NULL) {
- browser_window_refresh_url_bar(bw,
- hlcache_handle_get_url(bw->current_content),
- bw->frag_id);
+ browser_window_refresh_url_bar(bw);
}
break;
@@ -1228,9 +1252,7 @@ static nserror browser_window_callback(hlcache_handle *c,
if (bw->window != NULL) {
guit->window->new_content(bw->window);
- browser_window_refresh_url_bar(bw,
- hlcache_handle_get_url(bw->current_content),
- bw->frag_id);
+ browser_window_refresh_url_bar(bw);
}
/* new content; set scroll_to_top */
@@ -1271,7 +1293,7 @@ static nserror browser_window_callback(hlcache_handle *c,
* after, we only leak the thumbnails when urldb does
* not add the URL.
*/
- history_add(bw->history, c, bw->frag_id);
+ browser_window_history_add(bw, c, bw->frag_id);
}
/* frames */
@@ -1301,12 +1323,13 @@ static nserror browser_window_callback(hlcache_handle *c,
browser_window_stop_throbber(bw);
browser_window_update_favicon(c, bw, NULL);
- history_update(bw->history, c);
+ browser_window_history_update(bw, c);
hotlist_update_url(hlcache_handle_get_url(c));
- if (bw->refresh_interval != -1)
- schedule(bw->refresh_interval,
+ if (bw->refresh_interval != -1) {
+ guit->browser->schedule(bw->refresh_interval * 10,
browser_window_refresh, bw);
+ }
break;
case CONTENT_MSG_ERRORCODE:
@@ -1597,10 +1620,11 @@ void browser_window_destroy_internal(struct browser_window *bw)
LOG(("Destroying window"));
- if (bw->children != NULL || bw->iframes != NULL)
+ if (bw->children != NULL || bw->iframes != NULL) {
browser_window_destroy_children(bw);
+ }
- schedule_remove(browser_window_refresh, bw);
+ guit->browser->schedule(-1, browser_window_refresh, bw);
/* If this brower window is not the root window, and has focus, unset
* the root browser window's focus pointer. */
@@ -1672,7 +1696,7 @@ void browser_window_destroy_internal(struct browser_window *bw)
if (bw->frag_id != NULL)
lwc_string_unref(bw->frag_id);
- history_destroy(bw->history);
+ browser_window_history_destroy(bw);
free(bw->name);
free(bw->status_text);
@@ -1698,6 +1722,70 @@ void browser_window_destroy(struct browser_window *bw)
}
+/**
+ * Update URL bar for a given browser window to given URL
+ *
+ * \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)
+{
+ assert(bw);
+ assert(url);
+
+ if (bw->parent != NULL) {
+ /* Not root window; don't set a URL in GUI URL bar */
+ return;
+ }
+
+ guit->window->set_url(bw->window, nsurl_access(url));
+}
+
+
+/**
+ * Update URL bar for a given browser window to bw's content's URL
+ *
+ * \param bw Browser window to update URL bar for.
+ */
+
+void browser_window_refresh_url_bar(struct browser_window *bw)
+{
+ assert(bw);
+
+ if (bw->parent != NULL) {
+ /* Not root window; don't set a URL in GUI URL bar */
+ return;
+ }
+
+ if (bw->current_content == NULL) {
+ /* TODO: set "about:blank"? */
+ return;
+ }
+
+ if (bw->frag_id == NULL) {
+ 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(
+ hlcache_handle_get_url(bw->current_content),
+ bw->frag_id, &display_url);
+ if (error != NSERROR_OK) {
+ warn_user("NoMemory", 0);
+ return;
+ }
+
+ browser_window_refresh_url_bar_internal(bw, display_url);
+ nsurl_unref(display_url);
+ }
+}
+
+
/* exported interface documented in desktop/browser.h */
nserror browser_window_navigate(struct browser_window *bw,
nsurl *url,
@@ -1731,7 +1819,7 @@ nserror browser_window_navigate(struct browser_window *bw,
}
/* Set up retrieval parameters */
- if ((flags & BROWSER_WINDOW_VERIFIABLE) != 0) {
+ if (!(flags & BW_NAVIGATE_UNVERIFIABLE)) {
fetch_flags |= LLCACHE_RETRIEVE_VERIFIABLE;
}
@@ -1755,7 +1843,7 @@ nserror browser_window_navigate(struct browser_window *bw,
}
/* Get download out of the way */
- if ((flags & BROWSER_WINDOW_DOWNLOAD) != 0) {
+ if ((flags & BW_NAVIGATE_DOWNLOAD) != 0) {
error = browser_window_download(bw,
url,
referrer,
@@ -1800,18 +1888,15 @@ nserror browser_window_navigate(struct browser_window *bw,
nsurl_unref(referrer);
}
- if ((flags & BROWSER_WINDOW_HISTORY) != 0) {
- history_add(bw->history,
+ if ((flags & BW_NAVIGATE_HISTORY) != 0) {
+ browser_window_history_add(bw,
bw->current_content, bw->frag_id);
}
browser_window_update(bw, false);
if (bw->current_content != NULL) {
- browser_window_refresh_url_bar(bw,
- hlcache_handle_get_url(
- bw->current_content),
- bw->frag_id);
+ browser_window_refresh_url_bar(bw);
}
return NSERROR_OK;
}
@@ -1824,10 +1909,10 @@ nserror browser_window_navigate(struct browser_window *bw,
LOG(("Loading '%s'", nsurl_access(url)));
browser_window_set_status(bw, messages_get("Loading"));
- bw->history_add = (flags & BROWSER_WINDOW_HISTORY);
+ bw->history_add = (flags & BW_NAVIGATE_HISTORY);
/* Verifiable fetches may trigger a download */
- if ((flags & BROWSER_WINDOW_VERIFIABLE) != 0) {
+ if (!(flags & BW_NAVIGATE_UNVERIFIABLE)) {
fetch_flags |= HLCACHE_RETRIEVE_MAY_DOWNLOAD;
}
@@ -1843,7 +1928,7 @@ 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(bw, url, NULL);
+ browser_window_refresh_url_bar_internal(bw, url);
break;
case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
@@ -1871,6 +1956,69 @@ nserror browser_window_navigate(struct browser_window *bw,
}
+/* Exported interface, documented in browser.h */
+nsurl * browser_window_get_url(struct browser_window *bw)
+{
+ assert(bw != NULL);
+
+ if (bw->current_content != NULL) {
+ return hlcache_handle_get_url(bw->current_content);
+
+ } else if (bw->loading_content != NULL) {
+ /* TODO: should we return this? */
+ return hlcache_handle_get_url(bw->loading_content);
+ }
+
+ return corestring_nsurl_about_blank;
+}
+
+
+/* Exported interface, documented in browser.h */
+struct history * browser_window_get_history(struct browser_window *bw)
+{
+ assert(bw != NULL);
+
+ return bw->history;
+}
+
+
+/* Exported interface, documented in browser.h */
+bool browser_window_has_content(struct browser_window *bw)
+{
+ assert(bw != NULL);
+
+ if (bw->current_content == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
+
+/* Exported interface, documented in browser.h */
+nserror browser_window_get_extents(struct browser_window *bw, bool scaled,
+ int *width, int *height)
+{
+ assert(bw != NULL);
+
+ if (bw->current_content == NULL) {
+ *width = 0;
+ *height = 0;
+ return NSERROR_BAD_CONTENT;
+ }
+
+ *width = content_get_width(bw->current_content);
+ *height = content_get_height(bw->current_content);
+
+ if (scaled) {
+ *width *= bw->scale;
+ *height *= bw->scale;
+ }
+
+ return NSERROR_OK;
+}
+
+
/*
* Get the dimensions of the area a browser window occupies
*
@@ -2061,7 +2209,7 @@ void browser_window_stop(struct browser_window *bw)
assert(error == NSERROR_OK);
}
- schedule_remove(browser_window_refresh, bw);
+ guit->browser->schedule(-1, browser_window_refresh, bw);
if (bw->children) {
children = bw->rows * bw->cols;
@@ -2075,9 +2223,7 @@ void browser_window_stop(struct browser_window *bw)
}
if (bw->current_content != NULL) {
- browser_window_refresh_url_bar(bw,
- hlcache_handle_get_url(bw->current_content),
- bw->frag_id);
+ browser_window_refresh_url_bar(bw);
}
browser_window_stop_throbber(bw);
@@ -2129,7 +2275,7 @@ void browser_window_reload(struct browser_window *bw, bool all)
browser_window_navigate(bw,
hlcache_handle_get_url(bw->current_content),
NULL,
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_NONE,
NULL,
NULL,
NULL);
@@ -2315,46 +2461,6 @@ float browser_window_get_scale(struct browser_window *bw)
}
-/**
- * Update URL bar for a given browser window to given URL
- *
- * \param bw Browser window to update URL bar for.
- * \param url URL for content displayed by bw, excluding any fragment.
- * \param frag Additional fragment. May be NULL if none.
- */
-
-void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url,
- lwc_string *frag)
-{
- assert(bw);
- assert(url);
-
- if (bw->parent != NULL) {
- /* Not root window; don't set a URL in GUI URL bar */
- return;
- }
-
- if (frag == NULL) {
- /* With no fragment, we may as well pass url straight through
- * saving a malloc, copy, free cycle.
- */
- guit->window->set_url(bw->window, nsurl_access(url));
- } else {
- nsurl *display_url;
- nserror error;
-
- error = nsurl_refragment(url, frag, &display_url);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return;
- }
-
- guit->window->set_url(bw->window, nsurl_access(display_url));
- nsurl_unref(display_url);
- }
-}
-
-
static void browser_window_find_target_internal(struct browser_window *bw,
const char *target, int depth, struct browser_window *page,
int *rdepth, struct browser_window **bw_target)
@@ -2455,8 +2561,9 @@ struct browser_window *browser_window_find_target(struct browser_window *bw,
* OR
* - button_2 opens in new tab and the link target is "_blank"
*/
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_TAB |
+ BW_CREATE_HISTORY |
+ BW_CREATE_CLONE,
NULL,
NULL,
bw,
@@ -2482,7 +2589,8 @@ struct browser_window *browser_window_find_target(struct browser_window *bw,
* - button_2 doesn't open in new tabs and the link target is
* "_blank"
*/
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_CLONE,
NULL,
NULL,
bw,
@@ -2521,7 +2629,7 @@ struct browser_window *browser_window_find_target(struct browser_window *bw,
if (!nsoption_bool(target_blank))
return bw;
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ error = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
NULL,
NULL,
bw,
@@ -2946,7 +3054,8 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y)
bool browser_window_back_available(struct browser_window *bw)
{
- return (bw && bw->history && history_back_available(bw->history));
+ return (bw && bw->history &&
+ browser_window_history_back_available(bw));
}
@@ -2959,7 +3068,8 @@ bool browser_window_back_available(struct browser_window *bw)
bool browser_window_forward_available(struct browser_window *bw)
{
- return (bw && bw->history && history_forward_available(bw->history));
+ return (bw && bw->history &&
+ browser_window_history_forward_available(bw));
}
diff --git a/desktop/browser.h b/desktop/browser.h
index 0ca2e00..ca99a5d 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -25,12 +25,13 @@
#define _NETSURF_DESKTOP_BROWSER_H_
#include <stdbool.h>
+#include <stdio.h>
-#include "content/content.h"
+#include "utils/types.h"
+#include "utils/nsurl.h"
+#include "desktop/plot_style.h"
#include "desktop/frame_types.h"
-#include "desktop/gui.h"
#include "desktop/mouse.h"
-#include "utils/types.h"
struct browser_window;
@@ -39,7 +40,7 @@ struct gui_window;
struct history;
struct selection;
struct fetch_multipart_data;
-
+struct form_control;
typedef enum {
DRAGGING_NONE,
@@ -61,37 +62,69 @@ typedef enum {
extern bool browser_reformat_pending;
-/** flags to browser window go */
+/** flags to browser_window_create */
+enum browser_window_create_flags {
+ /** No flags set */
+ BW_CREATE_NONE = 0,
+
+ /** this will form a new history node (don't set for back/reload/etc) */
+ BW_CREATE_HISTORY = (1 << 0),
+
+ /** New gui_window to be tab in same window as "existing" gui_window */
+ BW_CREATE_TAB = (1 << 1),
+
+ /** New gui_window to be clone of "existing" gui_window */
+ BW_CREATE_CLONE = (1 << 2),
+
+ /** Window not opened by user interaction (e.g. JS popup)
+ *
+ * rfc2965:
+ * A transaction is verifiable if the user, or a
+ * user-designated agent, has the option to review
+ * the request-URI prior to its use in the transaction.
+ * A transaction is unverifiable if the user does not
+ * have that option.
+ */
+ BW_CREATE_UNVERIFIABLE = (1 << 3),
+};
+
+/** flags to browser_window_navigate */
enum browser_window_nav_flags {
- BROWSER_WINDOW_NONE = 0,
+ /** No flags set */
+ BW_NAVIGATE_NONE = 0,
+
/** this will form a new history node (don't set for back/reload/etc) */
- BROWSER_WINDOW_HISTORY = 1,
+ BW_NAVIGATE_HISTORY = (1 << 0),
+
/** download rather than render the uri */
- BROWSER_WINDOW_DOWNLOAD = 2,
- /** this transaction is verifiable */
- BROWSER_WINDOW_VERIFIABLE = 4,
- /** open a new tab rather than a new window */
- BROWSER_WINDOW_TAB = 8,
+ BW_NAVIGATE_DOWNLOAD = (1 << 1),
+
+ /** Transation not caused by user interaction (e.g. JS-caused)
+ *
+ * rfc2965:
+ * A transaction is verifiable if the user, or a
+ * user-designated agent, has the option to review
+ * the request-URI prior to its use in the transaction.
+ * A transaction is unverifiable if the user does not
+ * have that option.
+ */
+ BW_NAVIGATE_UNVERIFIABLE = (1 << 2)
};
-void browser_window_initialise_common(struct browser_window *bw,
- struct browser_window *clone);
-
/**
* Create and open a new root browser window with the given page.
*
- * \param flags Flags to control operation
- * \param url URL to start fetching in the new window or NULL for blank
- * \param referer The referring uri or NULL if none
- * \param clone The browser window to clone
- * \param bw pointer to created browser window or untouched on error.
- * \return error code
+ * \param flags Flags to control operation
+ * \param url URL to fetch in the new window or NULL for blank
+ * \param referer The referring uri or NULL if none
+ * \param existing The an existing bw or NULL, required for some flags.
+ * \param bw Updated to created browser window or untouched on error.
+ * \return NSERROR_OK, or appropriate error otherwise.
*/
-nserror browser_window_create(enum browser_window_nav_flags flags,
- nsurl *url,
- nsurl *referrer,
- struct browser_window *clone,
- struct browser_window **bw);
+nserror browser_window_create(enum browser_window_create_flags flags,
+ nsurl *url, nsurl *referrer,
+ struct browser_window *existing,
+ struct browser_window **bw);
/**
* Start fetching a page in a browser window.
@@ -116,7 +149,47 @@ nserror browser_window_navigate(struct browser_window *bw,
enum browser_window_nav_flags flags,
char *post_urlenc,
struct fetch_multipart_data *post_multipart,
- hlcache_handle *parent);
+ struct hlcache_handle *parent);
+
+/**
+ * Get a browser window's URL.
+ *
+ * \param bw browser window
+ * \return pointer to nsurl. Doesn't create a ref for caller.
+ *
+ * Note: guaranteed to return a valid nsurl ptr, never returns NULL.
+ */
+nsurl * browser_window_get_url(struct browser_window *bw);
+
+/**
+ * Get a browser window's history object.
+ *
+ * \param bw browser window
+ * \return pointer browser window's history object
+ *
+ * Clients need history object to make use of the history_* functions.
+ */
+struct history * browser_window_get_history(struct browser_window *bw);
+
+/**
+ * Get a browser window's content extents.
+ *
+ * \param bw browser window
+ * \param scaled whether to apply current browser window scale
+ * \param width updated to content width extent in px
+ * \param width updated to content height extent in px
+ * \return NSERROR_OK, or appropriate error otherwise.
+ */
+nserror browser_window_get_extents(struct browser_window *bw, bool scaled,
+ int *width, int *height);
+
+/**
+ * Find out if a browser window is currently showing a content.
+ *
+ * \param bw browser window
+ * \return true iff browser window is showing a content, else false.
+ */
+bool browser_window_has_content(struct browser_window *bw);
void browser_window_get_dimensions(struct browser_window *bw,
int *width, int *height, bool scaled);
@@ -176,8 +249,7 @@ bool browser_window_drop_file_at_point(struct browser_window *bw,
void browser_window_set_gadget_filename(struct browser_window *bw,
struct form_control *gadget, const char *fn);
-void browser_window_refresh_url_bar(struct browser_window *bw, nsurl *url,
- lwc_string *frag);
+void browser_window_refresh_url_bar(struct browser_window *bw);
void browser_window_mouse_click(struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
@@ -243,15 +315,7 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y,
*/
bool browser_window_redraw_ready(struct browser_window *bw);
-/*
- * Update the extent of the inside of a browser window to that of the current
- * content
- *
- * \param bw browser_window to update the extent of
- */
-void browser_window_update_extent(struct browser_window *bw);
-
-/*
+/**
* Get the position of the current browser window with respect to the root or
* parent browser window
*
@@ -263,7 +327,7 @@ void browser_window_update_extent(struct browser_window *bw);
void browser_window_get_position(struct browser_window *bw, bool root,
int *pos_x, int *pos_y);
-/*
+/**
* Set the position of the current browser window with respect to the parent
* browser window
*
@@ -273,7 +337,7 @@ void browser_window_get_position(struct browser_window *bw, bool root,
*/
void browser_window_set_position(struct browser_window *bw, int x, int y);
-/*
+/**
* Scroll the browser window to display the passed area
*
* \param bw browser window to scroll
@@ -294,7 +358,7 @@ void browser_window_scroll_visible(struct browser_window *bw,
*/
void browser_window_set_scroll(struct browser_window *bw, int x, int y);
-/*
+/**
* Set drag type for a browser window, and inform front end
*
* \param bw browser window to set the type of the current drag for
@@ -304,7 +368,7 @@ void browser_window_set_scroll(struct browser_window *bw, int x, int y);
void browser_window_set_drag_type(struct browser_window *bw,
browser_drag_type type, const struct rect *rect);
-/*
+/**
* Get type of any current drag for a browser window
*
* \param bw browser window to set the type of the current drag for
@@ -312,7 +376,7 @@ void browser_window_set_drag_type(struct browser_window *bw,
*/
browser_drag_type browser_window_get_drag_type(struct browser_window *bw);
-/*
+/**
* Get the root level browser window
*
* \param bw browser window to set the type of the current drag for
diff --git a/desktop/local_history.c b/desktop/browser_history.c
similarity index 67%
rename from desktop/local_history.c
rename to desktop/browser_history.c
index d4ecfd3..8c21eed 100644
--- a/desktop/local_history.c
+++ b/desktop/browser_history.c
@@ -26,13 +26,13 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "css/css.h"
-#include "desktop/browser.h"
-#include "desktop/gui.h"
-#include "desktop/local_history.h"
+#include "desktop/browser_history.h"
+#include "desktop/browser_private.h"
#include "desktop/plotters.h"
#include "desktop/thumbnail.h"
#include "image/bitmap.h"
@@ -80,75 +80,6 @@ struct history {
int height;
};
-static struct history_entry *history_clone_entry(struct history *history,
- struct history_entry *entry);
-static void history_free_entry(struct history_entry *entry);
-static void history_layout(struct history *history);
-static int history_layout_subtree(struct history *history,
- struct history_entry *entry, int x, int y, bool shuffle);
-static bool history_redraw_entry(struct history *history,
- struct history_entry *entry,
- int x0, int y0, int x1, int y1,
- int x, int y, bool clip, const struct redraw_context *ctx);
-static struct history_entry *history_find_position(struct history_entry *entry,
- int x, int y);
-static bool history_enumerate_entry(const struct history *history,
- const struct history_entry *entry, history_enumerate_cb cb, void *ud);
-
-
-/**
- * Create a new history tree for a window.
- *
- * \return pointer to an opaque history structure, 0 on failure.
- */
-
-struct history *history_create(void)
-{
- struct history *history;
-
- history = calloc(1, sizeof *history);
- if (!history) {
- warn_user("NoMemory", 0);
- return 0;
- }
- history->width = RIGHT_MARGIN / 2;
- history->height = BOTTOM_MARGIN / 2;
- return history;
-}
-
-
-/**
- * Clone a history tree
- *
- * \param history opaque history structure, as returned by history_create()
- *
- * \return pointer to an opaque history structure, 0 on failure.
- */
-
-struct history *history_clone(struct history *history)
-{
- struct history *new_history;
-
- if (!history->start)
- return history_create();
-
- new_history = malloc(sizeof *history);
- if (!new_history)
- return 0;
- memcpy(new_history, history, sizeof *history);
-
- new_history->start = history_clone_entry(new_history,
- new_history->start);
- if (!history->start) {
- LOG(("Insufficient memory to clone history"));
- warn_user("NoMemory", 0);
- history_destroy(new_history);
- return 0;
- }
-
- return new_history;
-}
-
/**
* Clone a history entry
@@ -159,7 +90,8 @@ struct history *history_clone(struct history *history)
* \return a cloned history entry, or 0 on error
*/
-struct history_entry *history_clone_entry(struct history *history,
+static struct history_entry *browser_window_history__clone_entry(
+ struct history *history,
struct history_entry *entry)
{
struct history_entry *child;
@@ -197,7 +129,7 @@ struct history_entry *history_clone_entry(struct history *history,
/* recurse for all children */
for (child = new_entry->forward; child; child = child->next) {
- new_child = history_clone_entry(history, child);
+ new_child = browser_window_history__clone_entry(history, child);
if (new_child) {
new_child->back = new_entry;
} else {
@@ -218,31 +150,365 @@ struct history_entry *history_clone_entry(struct history *history,
new_entry->forward_last = new_child;
prev = new_child;
}
- return new_entry;
+ return new_entry;
+}
+
+
+/**
+ * Free an entry in the tree recursively.
+ */
+
+static void browser_window_history__free_entry(struct history_entry *entry)
+{
+ if (!entry)
+ return;
+ browser_window_history__free_entry(entry->forward);
+ browser_window_history__free_entry(entry->next);
+ nsurl_unref(entry->page.url);
+ if (entry->page.frag_id)
+ lwc_string_unref(entry->page.frag_id);
+ free(entry->page.title);
+ free(entry);
+}
+
+
+/**
+ * Recursively position a subtree.
+ *
+ * \param history history being laid out
+ * \param entry subtree to position
+ * \param x x position for entry
+ * \param y smallest available y
+ * \param shuffle shuffle layout
+ * \return greatest y used by subtree
+ */
+
+static int browser_window_history__layout_subtree(struct history *history,
+ struct history_entry *entry, int x, int y, bool shuffle)
+{
+ struct history_entry *child;
+ int y1 = y;
+
+ if (history->width < x + WIDTH)
+ history->width = x + WIDTH;
+
+ if (!entry->forward) {
+ entry->x = x;
+ entry->y = y;
+ if (shuffle) {
+ entry->x = rand() % 600;
+ entry->y = rand() % 400;
+ }
+ return y + HEIGHT;
+ }
+
+ /* layout child subtrees below each other */
+ for (child = entry->forward; child; child = child->next) {
+ y1 = browser_window_history__layout_subtree(history, child,
+ x + WIDTH + RIGHT_MARGIN, y1, shuffle);
+ if (child->next)
+ y1 += BOTTOM_MARGIN;
+ }
+
+ /* place ourselves in the middle */
+ entry->x = x;
+ entry->y = (y + y1) / 2 - HEIGHT / 2;
+ if (shuffle) {
+ entry->x = rand() % 600;
+ entry->y = rand() % 400;
+ }
+
+ return y1;
+}
+
+
+/**
+ * Compute node positions.
+ *
+ * \param history history to layout
+ *
+ * Each node's x and y are filled in.
+ */
+
+static void browser_window_history__layout(struct history *history)
+{
+ time_t t = time(0);
+ struct tm *tp = localtime(&t);
+ bool shuffle = tp->tm_mon == 3 && tp->tm_mday == 1;
+
+ if (!history)
+ return;
+
+ history->width = 0;
+ if (history->start)
+ history->height = browser_window_history__layout_subtree(
+ history, history->start,
+ RIGHT_MARGIN / 2, BOTTOM_MARGIN / 2,
+ shuffle);
+ else
+ history->height = 0;
+ if (shuffle) {
+ history->width = 600 + WIDTH;
+ history->height = 400 + HEIGHT;
+ }
+ history->width += RIGHT_MARGIN / 2;
+ history->height += BOTTOM_MARGIN / 2;
+}
+
+/**
+ * Recursively redraw a history_entry.
+ *
+ * \param history history containing the entry
+ * \param history_entry entry to render
+ * \param ctx current redraw context
+ */
+
+static bool browser_window_history__redraw_entry(struct history *history,
+ struct history_entry *entry,
+ int x0, int y0, int x1, int y1,
+ int x, int y, bool clip,
+ const struct redraw_context *ctx)
+{
+ const struct plotter_table *plot = ctx->plot;
+ size_t char_offset;
+ int actual_x;
+ struct history_entry *child;
+ colour c = entry == history->current ?
+ HISTORY_COLOUR_SELECTED : HISTORY_COLOUR_FOREGROUND;
+ int tailsize = 5;
+ int xoffset = x - x0;
+ int yoffset = y - y0;
+ plot_style_t pstyle_history_rect = {
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = c,
+ .stroke_width = entry == history->current ? 3 : 1,
+ };
+ plot_font_style_t fstyle = *plot_style_font;
+
+ if (clip) {
+ struct rect rect;
+ rect.x0 = x0 + xoffset;
+ rect.y0 = y0 + yoffset;
+ rect.x1 = x1 + xoffset;
+ rect.y1 = y1 + yoffset;
+ if(!plot->clip(&rect))
+ return false;
+ }
+
+ if (!plot->bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT,
+ entry->bitmap, 0xffffff, 0))
+ return false;
+ if (!plot->rectangle(entry->x - 1 + xoffset,
+ entry->y - 1 + yoffset,
+ entry->x + xoffset + WIDTH,
+ entry->y + yoffset + HEIGHT,
+ &pstyle_history_rect))
+ return false;
+
+ if (!nsfont.font_position_in_string(plot_style_font, entry->page.title,
+ strlen(entry->page.title), WIDTH,
+ &char_offset, &actual_x))
+ return false;
+
+ fstyle.background = HISTORY_COLOUR_BACKGROUND;
+ fstyle.foreground = c;
+ fstyle.weight = entry == history->current ? 900 : 400;
+
+ if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
+ entry->page.title, char_offset, &fstyle))
+ return false;
+
+ for (child = entry->forward; child; child = child->next) {
+ if (!plot->line(entry->x + WIDTH + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ entry->x + WIDTH + tailsize + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
+ return false;
+ if (!plot->line(entry->x + WIDTH + tailsize + xoffset,
+ entry->y + HEIGHT / 2 + yoffset,
+ child->x - tailsize +xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
+ return false;
+ if (!plot->line(child->x - tailsize + xoffset,
+ child->y + HEIGHT / 2 + yoffset,
+ child->x + xoffset, child->y +
+ HEIGHT / 2 + yoffset,
+ plot_style_stroke_history))
+ return false;
+ if (!browser_window_history__redraw_entry(history, child,
+ x0, y0, x1, y1, x, y, clip, ctx))
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ * Find the history entry at a position.
+ *
+ * \param entry entry to search from
+ * \param x coordinate
+ * \param y coordinate
+ * \return an entry if found, 0 if none
+ */
+
+static struct history_entry *browser_window_history__find_position(
+ struct history_entry *entry, int x, int y)
+{
+ struct history_entry *child;
+ struct history_entry *found;
+
+ if (!entry)
+ return 0;
+
+ if (entry->x <= x && x <= entry->x + WIDTH &&
+ entry->y <= y && y <= entry->y + HEIGHT)
+ return entry;
+
+ for (child = entry->forward; child; child = child->next) {
+ found = browser_window_history__find_position(child, x, y);
+ if (found)
+ return found;
+ }
+
+ return 0;
+}
+
+/**
+ * Enumerate subentries in history
+ * See also history_enumerate()
+ *
+ * \param bw The browser window to enumerate history of
+ * \param entry entry to start enumeration at
+ * \param cb callback function
+ * \param ud context pointer passed to cb
+ * \return true to continue enumeration, false to cancel
+ */
+static bool browser_window_history__enumerate_entry(
+ const struct browser_window *bw,
+ const struct history_entry *entry,
+ browser_window_history_enumerate_cb cb,
+ void *ud)
+{
+ const struct history_entry *child;
+
+ if (!cb(bw, entry->x, entry->y,
+ entry->x + WIDTH, entry->y + HEIGHT,
+ entry, ud))
+ return false;
+
+ for (child = entry->forward; child; child = child->next) {
+ if (!browser_window_history__enumerate_entry(bw, child,
+ cb, ud))
+ return false;
+ }
+
+ return true;
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+/**
+ * Create a new history tree for a browser window window.
+ *
+ * \param bw browser window to create history for.
+ *
+ * \return NSERROR_OK or appropriate error otherwise
+ */
+
+nserror browser_window_history_create(struct browser_window *bw)
+{
+ struct history *history;
+
+ bw->history = NULL;
+
+ history = calloc(1, sizeof *history);
+ if (!history) {
+ warn_user("NoMemory", 0);
+ return NSERROR_NOMEM;
+ }
+ history->width = RIGHT_MARGIN / 2;
+ history->height = BOTTOM_MARGIN / 2;
+
+ bw->history = history;
+ return NSERROR_OK;
+}
+
+
+/**
+ * Clone a bw's history tree for new bw
+ *
+ * \param existing browser window with history to clone.
+ * \param clone browser window to make cloned history for.
+ *
+ * \return NSERROR_OK or appropriate error otherwise
+ */
+
+nserror browser_window_history_clone(const struct browser_window *existing,
+ struct browser_window *clone)
+{
+ struct history *new_history;
+
+ clone->history = NULL;
+
+ if (existing == NULL || existing->history == NULL ||
+ existing->history->start == NULL)
+ /* Nothing to clone, create new history for clone window */
+ return browser_window_history_create(clone);
+
+ /* Make cloned history */
+ new_history = malloc(sizeof *new_history);
+ if (!new_history)
+ return NSERROR_NOMEM;
+
+ clone->history = new_history;
+ memcpy(new_history, existing->history, sizeof *new_history);
+
+ new_history->start = browser_window_history__clone_entry(new_history,
+ 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;
+ }
+
+ return NSERROR_OK;
}
/**
* Insert a url into the history tree.
*
- * \param history opaque history structure, as returned by history_create()
+ * \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 history_add(struct history *history, hlcache_handle *content,
- lwc_string *frag_id)
+
+void browser_window_history_add(struct browser_window *bw,
+ struct hlcache_handle *content, lwc_string *frag_id)
{
+ struct history *history;
struct history_entry *entry;
nsurl *nsurl = hlcache_handle_get_url(content);
char *title;
struct bitmap *bitmap;
- assert(history);
+ assert(bw);
+ assert(bw->history);
assert(content);
+ history = bw->history;
+
/* allocate space */
entry = malloc(sizeof *entry);
if (entry == NULL)
@@ -297,7 +563,7 @@ void history_add(struct history *history, hlcache_handle *content,
}
entry->bitmap = bitmap;
- history_layout(history);
+ browser_window_history__layout(history);
}
@@ -308,10 +574,16 @@ void history_add(struct history *history, hlcache_handle *content,
* \param content content for current entry
*/
-void history_update(struct history *history, hlcache_handle *content)
+void browser_window_history_update(struct browser_window *bw,
+ struct hlcache_handle *content)
{
+ struct history *history;
char *title;
+ assert(bw != NULL);
+
+ history = bw->history;
+
if (!history || !history->current || !history->current->bitmap)
return;
@@ -338,30 +610,17 @@ void history_update(struct history *history, hlcache_handle *content)
* \param history opaque history structure, as returned by history_create()
*/
-void history_destroy(struct history *history)
+void browser_window_history_destroy(struct browser_window *bw)
{
- if (!history)
- return;
- history_free_entry(history->start);
- free(history);
-}
+ assert(bw != NULL);
+ if (bw->history == NULL)
+ return;
-/**
- * Free an entry in the tree recursively.
- */
+ browser_window_history__free_entry(bw->history->start);
+ free(bw->history);
-void history_free_entry(struct history_entry *entry)
-{
- if (!entry)
- return;
- history_free_entry(entry->forward);
- history_free_entry(entry->next);
- nsurl_unref(entry->page.url);
- if (entry->page.frag_id)
- lwc_string_unref(entry->page.frag_id);
- free(entry->page.title);
- free(entry);
+ bw->history = NULL;
}
@@ -370,13 +629,15 @@ void history_free_entry(struct history_entry *entry)
*
* \param bw browser window
* \param history history of the window
+ * \param new_window whether to open in new window
*/
-void history_back(struct browser_window *bw, struct history *history)
+void browser_window_history_back(struct browser_window *bw, bool new_window)
{
- if (!history || !history->current || !history->current->back)
+ if (!bw || !bw->history || !bw->history->current ||
+ !bw->history->current->back)
return;
- history_go(bw, history, history->current->back, false);
+ browser_window_history_go(bw, bw->history->current->back, new_window);
}
@@ -385,13 +646,16 @@ void history_back(struct browser_window *bw, struct history *history)
*
* \param bw browser window
* \param history history of the window
+ * \param new_window whether to open in new window
*/
-void history_forward(struct browser_window *bw, struct history *history)
+void browser_window_history_forward(struct browser_window *bw, bool new_window)
{
- if (!history || !history->current || !history->current->forward_pref)
+ if (!bw || !bw->history || !bw->history->current ||
+ !bw->history->current->forward_pref)
return;
- history_go(bw, history, history->current->forward_pref, false);
+ browser_window_history_go(bw, bw->history->current->forward_pref,
+ new_window);
}
@@ -402,9 +666,10 @@ void history_forward(struct browser_window *bw, struct history *history)
* \return true if the history can go back, false otherwise
*/
-bool history_back_available(struct history *history)
+bool browser_window_history_back_available(struct browser_window *bw)
{
- return (history && history->current && history->current->back);
+ return (bw && bw->history && bw->history->current &&
+ bw->history->current->back);
}
@@ -415,25 +680,24 @@ bool history_back_available(struct history *history)
* \return true if the history can go forwards, false otherwise
*/
-bool history_forward_available(struct history *history)
+bool browser_window_history_forward_available(struct browser_window *bw)
{
- return (history && history->current && history->current->forward_pref);
+ return (bw && bw->history && bw->history->current &&
+ bw->history->current->forward_pref);
}
/* Documented in local_history.h */
-void history_go(struct browser_window *bw,
- struct history *history,
- struct history_entry *entry,
- bool new_window)
+void browser_window_history_go(struct browser_window *bw,
+ struct history_entry *entry, bool new_window)
{
+ struct history *history;
nsurl *url;
struct history_entry *current;
nserror error;
-// LOG(("%p %p %p", bw, history, entry));
-// LOG(("%s %s %s",
-// entry->page.url, entry->page.title, entry->page.frag_id));
+ assert(bw != NULL);
+ history = bw->history;
if (entry->page.frag_id) {
error = nsurl_refragment(entry->page.url,
@@ -451,16 +715,17 @@ void history_go(struct browser_window *bw,
current = history->current;
history->current = entry;
- browser_window_create(BROWSER_WINDOW_VERIFIABLE,
- url,
- NULL,
- bw,
- NULL);
+ error = browser_window_create(BW_CREATE_CLONE,
+ url, NULL, bw, NULL);
history->current = current;
+ if (error != NSERROR_OK) {
+ nsurl_unref(url);
+ return;
+ }
} else {
history->current = entry;
browser_window_navigate(bw, url, NULL,
- BROWSER_WINDOW_VERIFIABLE, NULL, NULL, NULL);
+ BW_NAVIGATE_NONE, NULL, NULL, NULL);
}
nsurl_unref(url);
@@ -468,89 +733,6 @@ void history_go(struct browser_window *bw,
/**
- * Compute node positions.
- *
- * \param history history to layout
- *
- * Each node's x and y are filled in.
- */
-
-void history_layout(struct history *history)
-{
- time_t t = time(0);
- struct tm *tp = localtime(&t);
- bool shuffle = tp->tm_mon == 3 && tp->tm_mday == 1;
-
- if (!history)
- return;
-
- history->width = 0;
- if (history->start)
- history->height = history_layout_subtree(history,
- history->start, RIGHT_MARGIN / 2, BOTTOM_MARGIN / 2,
- shuffle);
- else
- history->height = 0;
- if (shuffle) {
- history->width = 600 + WIDTH;
- history->height = 400 + HEIGHT;
- }
- history->width += RIGHT_MARGIN / 2;
- history->height += BOTTOM_MARGIN / 2;
-}
-
-
-/**
- * Recursively position a subtree.
- *
- * \param history history being laid out
- * \param entry subtree to position
- * \param x x position for entry
- * \param y smallest available y
- * \param shuffle shuffle layout
- * \return greatest y used by subtree
- */
-
-int history_layout_subtree(struct history *history,
- struct history_entry *entry, int x, int y, bool shuffle)
-{
- struct history_entry *child;
- int y1 = y;
-
- if (history->width < x + WIDTH)
- history->width = x + WIDTH;
-
- if (!entry->forward) {
- entry->x = x;
- entry->y = y;
- if (shuffle) {
- entry->x = rand() % 600;
- entry->y = rand() % 400;
- }
- return y + HEIGHT;
- }
-
- /* layout child subtrees below each other */
- for (child = entry->forward; child; child = child->next) {
- y1 = history_layout_subtree(history, child,
- x + WIDTH + RIGHT_MARGIN, y1, shuffle);
- if (child->next)
- y1 += BOTTOM_MARGIN;
- }
-
- /* place ourselves in the middle */
- entry->x = x;
- entry->y = (y + y1) / 2 - HEIGHT / 2;
- if (shuffle) {
- entry->x = rand() % 600;
- entry->y = rand() % 400;
- }
-
- return y1;
-}
-
-
-/**
* Get the dimensions of a history.
*
* \param history history to measure
@@ -558,10 +740,14 @@ int history_layout_subtree(struct history *history,
* \param height updated to height
*/
-void history_size(struct history *history, int *width, int *height)
+void browser_window_history_size(struct browser_window *bw,
+ int *width, int *height)
{
- *width = history->width;
- *height = history->height;
+ assert(bw != NULL);
+ assert(bw->history != NULL);
+
+ *width = bw->history->width;
+ *height = bw->history->height;
}
@@ -572,12 +758,18 @@ void history_size(struct history *history, int *width, int *height)
* \param ctx current redraw context
*/
-bool history_redraw(struct history *history, const struct redraw_context *ctx)
+bool browser_window_history_redraw(struct browser_window *bw,
+ const struct redraw_context *ctx)
{
+ struct history *history;
+
+ assert(bw != NULL);
+ history = bw->history;
+
if (!history->start)
return true;
- return history_redraw_entry(history, history->start, 0, 0, 0, 0, 0, 0,
- false, ctx);
+ return browser_window_history__redraw_entry(history, history->start,
+ 0, 0, 0, 0, 0, 0, false, ctx);
}
/**
@@ -593,127 +785,48 @@ bool history_redraw(struct history *history, const struct redraw_context *ctx)
* \param ctx current redraw context
*/
-bool history_redraw_rectangle(struct history *history,
+bool browser_window_history_redraw_rectangle(struct browser_window *bw,
int x0, int y0, int x1, int y1,
int x, int y, const struct redraw_context *ctx)
{
+ struct history *history;
+
+ assert(bw != NULL);
+ history = bw->history;
+
if (!history->start)
return true;
- return history_redraw_entry(history, history->start,
+ return browser_window_history__redraw_entry(history, history->start,
x0, y0, x1, y1, x, y, true, ctx);
}
-/**
- * Recursively redraw a history_entry.
- *
- * \param history history containing the entry
- * \param history_entry entry to render
- * \param ctx current redraw context
- */
-
-bool history_redraw_entry(struct history *history,
- struct history_entry *entry,
- int x0, int y0, int x1, int y1,
- int x, int y, bool clip, const struct redraw_context *ctx)
-{
- const struct plotter_table *plot = ctx->plot;
- size_t char_offset;
- int actual_x;
- struct history_entry *child;
- colour c = entry == history->current ? HISTORY_COLOUR_SELECTED : HISTORY_COLOUR_FOREGROUND;
- int tailsize = 5;
- int xoffset = x - x0;
- int yoffset = y - y0;
- plot_style_t pstyle_history_rect = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = c,
- .stroke_width = entry == history->current ? 3 : 1,
- };
- plot_font_style_t fstyle = *plot_style_font;
-
- if (clip) {
- struct rect rect;
- rect.x0 = x0 + xoffset;
- rect.y0 = y0 + yoffset;
- rect.x1 = x1 + xoffset;
- rect.y1 = y1 + yoffset;
- if(!plot->clip(&rect))
- return false;
- }
-
- if (!plot->bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT,
- entry->bitmap, 0xffffff, 0))
- return false;
- if (!plot->rectangle(entry->x - 1 + xoffset,
- entry->y - 1 + yoffset,
- entry->x + xoffset + WIDTH,
- entry->y + yoffset + HEIGHT,
- &pstyle_history_rect))
- return false;
-
- if (!nsfont.font_position_in_string(plot_style_font, entry->page.title,
- strlen(entry->page.title), WIDTH,
- &char_offset, &actual_x))
- return false;
-
- fstyle.background = HISTORY_COLOUR_BACKGROUND;
- fstyle.foreground = c;
- fstyle.weight = entry == history->current ? 900 : 400;
-
- if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset,
- entry->page.title, char_offset, &fstyle))
- return false;
-
- for (child = entry->forward; child; child = child->next) {
- if (!plot->line(entry->x + WIDTH + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
- return false;
- if (!plot->line(entry->x + WIDTH + tailsize + xoffset,
- entry->y + HEIGHT / 2 + yoffset,
- child->x - tailsize +xoffset,
- child->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
- return false;
- if (!plot->line(child->x - tailsize + xoffset,
- child->y + HEIGHT / 2 + yoffset,
- child->x + xoffset, child->y + HEIGHT / 2 + yoffset,
- plot_style_stroke_history))
- return false;
- if (!history_redraw_entry(history, child, x0, y0, x1, y1, x, y,
- clip, ctx))
- return false;
- }
-
- return true;
-}
-
/**
* Handle a mouse click in a history.
*
* \param bw browser window containing history
- * \param history history that was clicked in
* \param x click coordinate
* \param y click coordinate
* \param new_window open a new window instead of using bw
* \return true if action was taken, false if click was not on an entry
*/
-bool history_click(struct browser_window *bw, struct history *history,
+bool browser_window_history_click(struct browser_window *bw,
int x, int y, bool new_window)
{
struct history_entry *entry;
+ struct history *history;
- entry = history_find_position(history->start, x, y);
+ assert(bw != NULL);
+ history = bw->history;
+
+ entry = browser_window_history__find_position(history->start, x, y);
if (!entry)
return false;
if (entry == history->current)
return false;
- history_go(bw, history, entry, new_window);
+ browser_window_history_go(bw, entry, new_window);
return true;
}
@@ -728,126 +841,82 @@ bool history_click(struct browser_window *bw, struct history *history,
* \return URL, or 0 if no entry at (x, y)
*/
-const char *history_position_url(struct history *history, int x, int y)
+const char *browser_window_history_position_url(struct browser_window *bw,
+ int x, int y)
{
struct history_entry *entry;
+ struct history *history;
+
+ assert(bw != NULL);
+ history = bw->history;
- entry = history_find_position(history->start, x, y);
+ entry = browser_window_history__find_position(history->start, x, y);
if (!entry)
return 0;
return nsurl_access(entry->page.url);
}
-
-/**
- * Find the history entry at a position.
- *
- * \param entry entry to search from
- * \param x coordinate
- * \param y coordinate
- * \return an entry if found, 0 if none
- */
-
-struct history_entry *history_find_position(struct history_entry *entry,
- int x, int y)
+/* Documented in local_history.h */
+void browser_window_history_enumerate_forward(const struct browser_window *bw,
+ browser_window_history_enumerate_cb cb, void *user_data)
{
- struct history_entry *child;
- struct history_entry *found;
-
- if (!entry)
- return 0;
-
- if (entry->x <= x && x <= entry->x + WIDTH &&
- entry->y <= y && y <= entry->y + HEIGHT)
- return entry;
-
- for (child = entry->forward; child; child = child->next) {
- found = history_find_position(child, x, y);
- if (found)
- return found;
- }
+ struct history_entry *e;
- return 0;
-}
+ if (bw == NULL || bw->history == NULL || bw->history->current == NULL)
+ return;
-/* Documented in local_history.h */
-void history_enumerate_forward(struct history *history,
- history_enumerate_cb cb, void *user_data)
-{
- struct history_entry *entry;
-
- if (history == NULL || history->current == NULL) return;
-
- for (entry = history->current->forward_pref; entry != NULL; entry = entry->forward_pref) {
- if (!cb(history, entry->x, entry->y, entry->x + WIDTH,
- entry->y + HEIGHT, entry, user_data))
+ e = bw->history->current->forward_pref;
+ for (; e != NULL; e = e->forward_pref) {
+ if (!cb(bw, e->x, e->y, e->x + WIDTH, e->y + HEIGHT,
+ e, user_data))
break;
}
}
/* Documented in local_history.h */
-void history_enumerate_back(struct history *history,
- history_enumerate_cb cb, void *user_data)
+void browser_window_history_enumerate_back(const struct browser_window *bw,
+ browser_window_history_enumerate_cb cb, void *user_data)
{
- struct history_entry *entry;
-
- if (history == NULL || history->current == NULL) return;
-
- for (entry = history->current->back; entry != NULL; entry = entry->back) {
- if (!cb(history, entry->x, entry->y, entry->x + WIDTH,
- entry->y + HEIGHT, entry, user_data))
+ struct history_entry *e;
+
+ if (bw == NULL || bw->history == NULL || bw->history->current == NULL)
+ return;
+
+ for (e = bw->history->current->back; e != NULL; e = e->back) {
+ if (!cb(bw, e->x, e->y, e->x + WIDTH, e->y + HEIGHT,
+ e, user_data))
break;
}
}
/* Documented in local_history.h */
-void history_enumerate(const struct history *history, history_enumerate_cb cb,
- void *user_data)
-{
- history_enumerate_entry(history, history->start, cb, user_data);
-}
-
-/**
- * Enumerate subentries in history
- * See also history_enumerate()
- *
- * \param history history to enumerate
- * \param entry entry to start enumeration at
- * \param cb callback function
- * \param ud context pointer passed to cb
- * \return true to continue enumeration, false to cancel
- */
-static bool history_enumerate_entry(const struct history *history,
- const struct history_entry *entry, history_enumerate_cb cb, void *ud)
+void browser_window_history_enumerate(const struct browser_window *bw,
+ browser_window_history_enumerate_cb cb, void *user_data)
{
- const struct history_entry *child;
-
- if (!cb(history, entry->x, entry->y, entry->x + WIDTH, entry->y + HEIGHT,
- entry, ud)) return false;
-
- for (child = entry->forward; child; child = child->next) {
- if (!history_enumerate_entry(history, child, cb, ud))
- return false;
- }
-
- return true;
+ if (bw == NULL || bw->history == NULL)
+ return;
+ browser_window_history__enumerate_entry(bw,
+ bw->history->start, cb, user_data);
}
/* Documented in local_history.h */
-const char *history_entry_get_url(const struct history_entry *entry)
+const char *browser_window_history_entry_get_url(
+ const struct history_entry *entry)
{
return nsurl_access(entry->page.url);
}
/* Documented in local_history.h */
-const char *history_entry_get_fragment_id(const struct history_entry *entry)
+const char *browser_window_history_entry_get_fragment_id(
+ const struct history_entry *entry)
{
return (entry->page.frag_id) ? lwc_string_data(entry->page.frag_id) : 0;
}
/* Documented in local_history.h */
-const char *history_entry_get_title(const struct history_entry *entry)
+const char *browser_window_history_entry_get_title(
+ const struct history_entry *entry)
{
return entry->page.title;
}
diff --git a/desktop/browser_history.h b/desktop/browser_history.h
new file mode 100644
index 0000000..f3e524b
--- /dev/null
+++ b/desktop/browser_history.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2006 James Bursa <bursa(a)users.sourceforge.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Browser history tree (interface).
+ */
+
+#ifndef _NETSURF_DESKTOP_BROWSER_HISTORY_H_
+#define _NETSURF_DESKTOP_BROWSER_HISTORY_H_
+
+#include <stdbool.h>
+#include <libwapcaplet/libwapcaplet.h>
+
+#include "utils/errors.h"
+
+struct hlcache_handle;
+struct browser_window;
+struct history_entry;
+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,
+ struct hlcache_handle *content, lwc_string *frag_id);
+void 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);
+bool browser_window_history_back_available(struct browser_window *bw);
+bool browser_window_history_forward_available(struct browser_window *bw);
+void browser_window_history_size(struct browser_window *bw,
+ int *width, int *height);
+bool browser_window_history_redraw(struct browser_window *bw,
+ const struct redraw_context *ctx);
+bool browser_window_history_redraw_rectangle(struct browser_window *bw,
+ int x0, int y0, int x1, int y1, int x, int y,
+ const struct redraw_context *ctx);
+bool browser_window_history_click(struct browser_window *bw,
+ int x, int y, bool new_window);
+const char *browser_window_history_position_url(struct browser_window *bw,
+ int x, int y);
+
+/**
+ * Callback function type for history enumeration
+ *
+ * \param bw The browser window with history being enumerated
+ * \param x0, y0, x1, y1 Coordinates of entry in history tree view
+ * \param entry Current history entry
+ * \return true to continue enumeration, false to cancel enumeration
+ */
+typedef bool (*browser_window_history_enumerate_cb)(
+ const struct browser_window *bw,
+ int x0, int y0, int x1, int y1,
+ const struct history_entry *entry, void *user_data);
+
+/**
+ * Enumerate all entries in the history.
+ * Do not change the history while it is being enumerated.
+ *
+ * \param bw The browser window to enumerate history of
+ * \param cb callback function
+ * \param user_data context pointer passed to cb
+ */
+void browser_window_history_enumerate(const struct browser_window *bw,
+ browser_window_history_enumerate_cb cb, void *user_data);
+
+/**
+ * Enumerate all entries that will be reached by the 'forward' button
+ *
+ * \param bw The browser window to enumerate history of
+ * \param cb The callback function
+ * \param user_data Data passed to the callback
+ */
+void browser_window_history_enumerate_forward(const struct browser_window *bw,
+ browser_window_history_enumerate_cb cb, void *user_data);
+
+/**
+ * Enumerate all entries that will be reached by the 'back' button
+ *
+ * \param bw The browser window to enumerate history of
+ * \param cb The callback function
+ * \param user_data Data passed to the callback
+ */
+void browser_window_history_enumerate_back(const struct browser_window *bw,
+ browser_window_history_enumerate_cb cb, void *user_data);
+
+/**
+ * Returns the URL to a history entry
+ *
+ * \param entry the history entry to retrieve the URL from
+ * \return the URL
+ */
+const char *browser_window_history_entry_get_url(
+ const struct history_entry *entry);
+
+/**
+ * Returns the URL to a history entry
+ *
+ * \param entry the history entry to retrieve the fragment id from
+ * \return the fragment id
+ */
+const char *browser_window_history_entry_get_fragment_id(
+ const struct history_entry *entry);
+
+/**
+ * Returns the title of a history entry
+ *
+ * \param entry the history entry to retrieve the title from
+ * \return the title
+ */
+const char *browser_window_history_entry_get_title(
+ const struct history_entry *entry);
+
+/**
+ * Navigate to specified history entry, optionally in new window
+ *
+ * \param bw browser window
+ * \param entry entry to open
+ * \param new_window open entry in new window
+ */
+void browser_window_history_go(struct browser_window *bw,
+ struct history_entry *entry, bool new_window);
+
+#endif
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index 4412f4b..339bc46 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -163,4 +163,17 @@ struct browser_window {
int status_miss; /**< Number of times status was really updated. */
};
+
+
+nserror browser_window_initialise_common(enum browser_window_create_flags flags,
+ struct browser_window *bw, struct browser_window *existing);
+
+/**
+ * Update the extent of the inside of a browser window to that of the current
+ * content
+ *
+ * \param bw browser_window to update the extent of
+ */
+void browser_window_update_extent(struct browser_window *bw);
+
#endif
diff --git a/desktop/download.c b/desktop/download.c
index b5427b4..b458f57 100644
--- a/desktop/download.c
+++ b/desktop/download.c
@@ -23,10 +23,10 @@
#include <assert.h>
#include <stdlib.h>
+#include <string.h>
#include "content/llcache.h"
#include "desktop/download.h"
-#include "desktop/gui.h"
#include "desktop/gui_factory.h"
#include "utils/corestrings.h"
#include "utils/http.h"
diff --git a/desktop/frames.c b/desktop/frames.c
index 3f7613f..534cca4 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -28,12 +28,11 @@
#include <string.h>
#include <time.h>
#include <math.h>
+
#include "utils/config.h"
#include "content/hlcache.h"
#include "desktop/browser_private.h"
#include "desktop/frames.h"
-#include "desktop/local_history.h"
-#include "desktop/gui.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
#include "utils/log.h"
@@ -209,7 +208,8 @@ void browser_window_create_iframes(struct browser_window *bw,
window = &(bw->iframes[index++]);
/* Initialise common parts */
- browser_window_initialise_common(window, NULL);
+ browser_window_initialise_common(BW_CREATE_NONE,
+ window, NULL);
/* window characteristics */
window->browser_window_type = BROWSER_WINDOW_IFRAME;
@@ -251,7 +251,7 @@ void browser_window_create_iframes(struct browser_window *bw,
browser_window_navigate(window,
cur->url,
hlcache_handle_get_url(bw->current_content),
- BROWSER_WINDOW_NONE,
+ BW_NAVIGATE_UNVERIFIABLE,
NULL,
NULL,
bw->current_content);
@@ -314,7 +314,8 @@ void browser_window_create_frameset(struct browser_window *bw,
window = &bw->children[index];
/* Initialise common parts */
- browser_window_initialise_common(window, NULL);
+ browser_window_initialise_common(BW_CREATE_NONE,
+ window, NULL);
/* window characteristics */
if (frame->children)
@@ -387,7 +388,8 @@ void browser_window_create_frameset(struct browser_window *bw,
browser_window_navigate(window,
frame->url,
hlcache_handle_get_url(parent),
- BROWSER_WINDOW_HISTORY,
+ BW_NAVIGATE_HISTORY |
+ BW_NAVIGATE_UNVERIFIABLE,
NULL,
NULL,
parent);
diff --git a/desktop/global_history.c b/desktop/global_history.c
index 9d0e47e..c29b051 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -676,23 +676,22 @@ static nserror global_history_tree_node_entry_cb(
case TREE_MSG_NODE_LAUNCH:
{
nserror error;
- struct browser_window *clone = NULL;
- enum browser_window_nav_flags flags =
- BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB;
+ struct browser_window *existing = NULL;
+ enum browser_window_create_flags flags =
+ BW_CREATE_HISTORY;
- /* TODO: Set clone window, to window that new tab appears in */
+ /* TODO: Set existing to window that new tab appears in */
if (msg.data.node_launch.mouse &
(BROWSER_MOUSE_MOD_1 | BROWSER_MOUSE_MOD_2) ||
- clone == NULL) {
+ existing == NULL) {
/* Shift or Ctrl launch, open in new window rather
* than tab. */
- flags ^= BROWSER_WINDOW_TAB;
+ /* TODO: flags ^= BW_CREATE_TAB; */
}
- error = browser_window_create(flags, e->url, NULL, clone, NULL);
+ error = browser_window_create(flags, e->url, NULL,
+ existing, NULL);
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
}
diff --git a/desktop/gui.h b/desktop/gui.h
index da609b1..317a733 100644
--- a/desktop/gui.h
+++ b/desktop/gui.h
@@ -17,17 +17,18 @@
*/
/** \file
- * Interface to platform-specific gui functions.
+ * Interface to platform-specific gui operation tables.
*/
#ifndef _NETSURF_DESKTOP_GUI_H_
#define _NETSURF_DESKTOP_GUI_H_
-#include <stdbool.h>
+#include <stddef.h>
-#include "content/hlcache.h"
-#include "desktop/download.h"
+#include "utils/types.h"
#include "utils/errors.h"
+#include "desktop/plot_style.h"
+#include "desktop/mouse.h"
typedef enum {
GUI_SAVE_SOURCE,
@@ -53,11 +54,20 @@ typedef enum {
GDRAGGING_OTHER
} gui_drag_type;
+typedef enum {
+ GW_CREATE_NONE = 0, /* New window */
+ GW_CREATE_CLONE = (1 << 0), /* Clone existing window */
+ GW_CREATE_TAB = (1 << 1) /* In same window as existing */
+} gui_window_create_flags;
+
struct gui_window;
struct gui_download_window;
struct browser_window;
struct form_control;
struct ssl_cert_info;
+struct hlcache_handle;
+struct download_context;
+struct nsurl;
typedef struct nsnsclipboard_styles {
size_t start; /**< Start of run */
@@ -65,7 +75,8 @@ typedef struct nsnsclipboard_styles {
plot_font_style_t style; /**< Style to give text run */
} nsclipboard_styles;
-/** Graphical user interface window function table
+/**
+ * Graphical user interface window function table.
*
* function table implementing window operations
*/
@@ -73,8 +84,23 @@ struct gui_window_table {
/* Mandantory entries */
- /** create a gui window for a browsing context */
- struct gui_window *(*create)(struct browser_window *bw, struct browser_window *clone, bool new_tab);
+ /**
+ * Create and open a gui window for a browsing context.
+ *
+ * \param bw bw to create gui_window for
+ * \param existing an existing gui_window, may be NULL
+ * \param flags flags for gui window creation
+ * \return gui window, or NULL on error
+ *
+ * If GW_CREATE_CLONE or GW_CREATE_TAB flags are set, existing is
+ * non-NULL.
+ *
+ * Front end's gui_window must include a reference to the
+ * browser window passed in the bw param.
+ */
+ struct gui_window *(*create)(struct browser_window *bw,
+ struct gui_window *existing,
+ gui_window_create_flags flags);
/** destroy previously created gui window */
void (*destroy)(struct gui_window *g);
@@ -151,11 +177,13 @@ struct gui_window_table {
*/
void (*set_title)(struct gui_window *g, const char *title);
- /** set the navigation url. */
+ /**
+ * set the navigation url.
+ */
void (*set_url)(struct gui_window *g, const char *url);
/** set favicon */
- void (*set_icon)(struct gui_window *g, hlcache_handle *icon);
+ void (*set_icon)(struct gui_window *g, struct hlcache_handle *icon);
/**
* Set the status bar of a browser window.
@@ -184,7 +212,7 @@ struct gui_window_table {
/**
* Remove the caret, if present.
*
- * \param g window with caret
+ * \param g window with caret
*/
void (*remove_caret)(struct gui_window *g);
@@ -232,10 +260,10 @@ struct gui_window_table {
/**
* Called when file chooser gadget is activated
*/
- void (*file_gadget_open)(struct gui_window *g, hlcache_handle *hl, struct form_control *gadget);
+ void (*file_gadget_open)(struct gui_window *g, struct hlcache_handle *hl, struct form_control *gadget);
/** object dragged to window*/
- void (*drag_save_object)(struct gui_window *g, hlcache_handle *c, gui_save_type type);
+ void (*drag_save_object)(struct gui_window *g, struct hlcache_handle *c, gui_save_type type);
/** drag selection save */
void (*drag_save_selection)(struct gui_window *g, const char *selection);
@@ -244,11 +272,12 @@ struct gui_window_table {
void (*start_selection)(struct gui_window *g);
};
+
/**
- * function table for download windows
+ * function table for download windows.
*/
struct gui_download_table {
- struct gui_download_window *(*create)(download_context *ctx, struct gui_window *parent);
+ struct gui_download_window *(*create)(struct download_context *ctx, struct gui_window *parent);
nserror (*data)(struct gui_download_window *dw, const char *data, unsigned int size);
@@ -257,8 +286,9 @@ struct gui_download_table {
void (*done)(struct gui_download_window *dw);
};
+
/**
- * function table for clipboard operations
+ * function table for clipboard operations.
*/
struct gui_clipboard_table {
/**
@@ -280,6 +310,7 @@ struct gui_clipboard_table {
void (*set)(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
};
+
/**
* function table for fetcher operations
*/
@@ -351,7 +382,7 @@ struct gui_fetch_table {
* \return A string containing the full URL of the target object or
* NULL if no suitable resource can be found.
*/
- nsurl* (*get_resource_url)(const char *path);
+ struct nsurl* (*get_resource_url)(const char *path);
/**
* Find a MIME type for a local file
@@ -365,7 +396,81 @@ struct gui_fetch_table {
};
-/** Graphical user interface browser misc function table
+
+/**
+ * User interface utf8 characterset conversion routines.
+ */
+struct gui_utf8_table {
+ /**
+ * Convert a UTF-8 encoded string into the system local encoding
+ *
+ * \param string The string to convert
+ * \param len The length (in bytes) of the string, or 0
+ * \param result Pointer to location in which to store result
+ * \return An nserror code
+ */
+ nserror (*utf8_to_local)(const char *string, size_t len, char **result);
+
+ /**
+ * Convert a string encoded in the system local encoding to UTF-8
+ *
+ * \param string The string to convert
+ * \param len The length (in bytes) of the string, or 0
+ * \param result Pointer to location in which to store result
+ * \return An nserror code
+ */
+ nserror (*local_to_utf8)(const char *string, size_t len, char **result);
+};
+
+/**
+ * function table for page text search.
+ */
+struct gui_search_table {
+ /**
+ * Change the displayed search status.
+ *
+ * \param found search pattern matched in text
+ * \param p gui private data pointer provided with search callbacks
+ */
+ void (*status)(bool found, void *p);
+
+ /**
+ * display hourglass while searching.
+ *
+ * \param active start/stop indicator
+ * \param p gui private data pointer provided with search callbacks
+ */
+ void (*hourglass)(bool active, void *p);
+
+ /**
+ * add search string to recent searches list
+ * front has full liberty how to implement the bare notification;
+ * core gives no guarantee of the integrity of the string
+ *
+ * \param string search pattern
+ * \param p gui private data pointer provided with search callbacks
+ */
+ void (*add_recent)(const char *string, void *p);
+
+ /**
+ * activate search forwards button in gui
+ *
+ * \param active activate/inactivate
+ * \param p gui private data pointer provided with search callbacks
+ */
+ void (*forward_state)(bool active, void *p);
+
+ /**
+ * activate search back button in gui
+ *
+ * \param active activate/inactivate
+ * \param p gui private data pointer provided with search callbacks
+ */
+ void (*back_state)(bool active, void *p);
+};
+
+/**
+ * Graphical user interface browser misc function table.
*
* function table implementing GUI interface to miscelaneous browser
* functionality
@@ -379,6 +484,23 @@ struct gui_browser_table {
*/
void (*poll)(bool active);
+ /**
+ * Schedule a callback.
+ *
+ * \param t interval before the callback should be made in ms or
+ * negative value to remove any existing callback.
+ * \param callback callback function
+ * \param p user parameter passed to callback function
+ * \return NSERROR_OK on sucess or appropriate error on faliure
+ *
+ * The callback function will be called as soon as possible
+ * after the timeout has elapsed.
+ *
+ * Additional calls with the same callback and user parameter will
+ * reset the callback time to the newly specified value.
+ *
+ */
+ nserror (*schedule)(int t, void (*callback)(void *p), void *p);
/* Optional entries */
@@ -392,7 +514,7 @@ struct gui_browser_table {
* \param ico may be NULL for local calls; then access current
* cache from search_web_ico()
*/
- void (*set_search_ico)(hlcache_handle *ico);
+ void (*set_search_ico)(struct hlcache_handle *ico);
/**
* core has no fetcher for url
@@ -407,12 +529,12 @@ struct gui_browser_table {
/**
* verify certificate
*/
- void (*cert_verify)(nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw);
+ void (*cert_verify)(struct nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw);
/**
* Prompt user for login
*/
- void (*login)(nsurl *url, const char *realm,
+ void (*login)(struct nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
};
@@ -424,7 +546,12 @@ struct gui_browser_table {
*/
struct gui_table {
- /** Browser table */
+ /**
+ * Browser table.
+ *
+ * Provides miscellaneous browser functionality. The table
+ * is mandantory and must be provided.
+ */
struct gui_browser_table *browser;
/** Window table */
@@ -438,6 +565,23 @@ struct gui_table {
/** Fetcher table */
struct gui_fetch_table *fetch;
+
+ /**
+ * UTF8 table.
+ *
+ * Provides for conversion between the gui local character
+ * encoding and utf8. The table optional and may be NULL which
+ * implies the local encoding is utf8.
+ */
+ struct gui_utf8_table *utf8;
+
+ /**
+ *
+ * Page search table.
+ *
+ * Provides routines for the interactive text search on a page.
+ */
+ struct gui_search_table *search;
};
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index dfe7755..ecedf41 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/gui.h"
+#include "content/hlcache.h"
+#include "desktop/download.h"
#include "desktop/gui_factory.h"
/** The global GUI interface table */
@@ -271,6 +272,11 @@ static void gui_default_set_clipboard(const char *buffer, size_t length,
{
}
+static struct gui_clipboard_table default_clipboard_table = {
+ .get = gui_default_get_clipboard,
+ .set = gui_default_set_clipboard,
+};
+
/** verify clipboard table is valid */
static nserror verify_clipboard_register(struct gui_clipboard_table *gct)
{
@@ -289,6 +295,110 @@ static nserror verify_clipboard_register(struct gui_clipboard_table *gct)
return NSERROR_OK;
}
+/**
+ * The default utf8 conversion implementation.
+ *
+ * The default implementation assumes the local encoding is utf8
+ * allowing the conversion to be a simple copy.
+ *
+ * @param [in] string The source string.
+ * @param [in] len The \a string length or 0 to compute it.
+ * @param [out] result A pointer to the converted string.
+ * @result NSERROR_OK or NSERROR_NOMEM if memory could not be allocated.
+ */
+static nserror gui_default_utf8(const char *string, size_t len, char **result)
+{
+ assert(string && result);
+
+ if (len == 0)
+ len = strlen(string);
+
+ *result = strndup(string, len);
+ if (!(*result))
+ return NSERROR_NOMEM;
+
+ return NSERROR_OK;
+}
+
+static struct gui_utf8_table default_utf8_table = {
+ .utf8_to_local = gui_default_utf8,
+ .local_to_utf8 = gui_default_utf8,
+};
+
+/** verify clipboard table is valid */
+static nserror verify_utf8_register(struct gui_utf8_table *gut)
+{
+ /* check table is present */
+ if (gut == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* mandantory operations */
+ if (gut->utf8_to_local == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (gut->local_to_utf8 == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ return NSERROR_OK;
+}
+
+static void gui_default_status(bool found, void *p)
+{
+}
+
+static void gui_default_hourglass(bool active, void *p)
+{
+}
+
+static void gui_default_add_recent(const char *string, void *p)
+{
+}
+
+static void gui_default_forward_state(bool active, void *p)
+{
+}
+
+static void gui_default_back_state(bool active, void *p)
+{
+}
+
+static struct gui_search_table default_search_table = {
+ .status = gui_default_status,
+ .hourglass = gui_default_hourglass,
+ .add_recent = gui_default_add_recent,
+ .forward_state = gui_default_forward_state,
+ .back_state = gui_default_back_state,
+};
+
+/** verify search table is valid */
+static nserror verify_search_register(struct gui_search_table *gst)
+{
+ /* check table is present */
+ if (gst == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ /* fill in the optional entries with defaults */
+ if (gst->status == NULL) {
+ gst->status = default_search_table.status;
+ }
+ if (gst->hourglass == NULL) {
+ gst->hourglass = default_search_table.hourglass;
+ }
+ if (gst->add_recent == NULL) {
+ gst->add_recent = default_search_table.add_recent;
+ }
+ if (gst->forward_state == NULL) {
+ gst->forward_state = default_search_table.forward_state;
+ }
+ if (gst->back_state == NULL) {
+ gst->back_state = default_search_table.back_state;
+ }
+
+ return NSERROR_OK;
+}
+
static nsurl *gui_default_get_resource_url(const char *path)
{
return NULL;
@@ -369,6 +479,13 @@ 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,
+};
+
/** verify browser table is valid */
static nserror verify_browser_register(struct gui_browser_table *gbt)
{
@@ -382,6 +499,10 @@ static nserror verify_browser_register(struct gui_browser_table *gbt)
return NSERROR_BAD_PARAMETER;
}
+ if (gbt->schedule == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
/* fill in the optional entries with defaults */
if (gbt->quit == NULL) {
gbt->quit = gui_default_quit;
@@ -405,19 +526,6 @@ static nserror verify_browser_register(struct gui_browser_table *gbt)
}
-
-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 struct gui_clipboard_table default_clipboard_table = {
- .get = gui_default_get_clipboard,
- .set = gui_default_set_clipboard,
-};
-
/* exported interface documented in desktop/gui_factory.h */
nserror gui_factory_register(struct gui_table *gt)
{
@@ -471,6 +579,26 @@ nserror gui_factory_register(struct gui_table *gt)
return err;
}
+ /* utf8 table */
+ if (gt->utf8 == NULL) {
+ /* set default utf8 table */
+ gt->utf8 = &default_utf8_table;
+ }
+ err = verify_utf8_register(gt->utf8);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
+ /* search table */
+ if (gt->search == NULL) {
+ /* set default search table */
+ gt->search = &default_search_table;
+ }
+ err = verify_search_register(gt->search);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
guit = gt;
return NSERROR_OK;
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 219a348..6814f8d 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -472,23 +472,22 @@ static nserror hotlist_tree_node_entry_cb(
case TREE_MSG_NODE_LAUNCH:
{
nserror error;
- struct browser_window *clone = NULL;
- enum browser_window_nav_flags flags =
- BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB;
+ struct browser_window *existing = NULL;
+ enum browser_window_create_flags flags =
+ BW_CREATE_HISTORY;
- /* TODO: Set clone window, to window that new tab appears in */
+ /* TODO: Set existing to window that new tab appears in */
if (msg.data.node_launch.mouse &
(BROWSER_MOUSE_MOD_1 | BROWSER_MOUSE_MOD_2) ||
- clone == NULL) {
+ existing == NULL) {
/* Shift or Ctrl launch, open in new window rather
* than tab. */
- flags ^= BROWSER_WINDOW_TAB;
+ /* TODO: flags ^= BW_CREATE_TAB; */
}
- error = browser_window_create(flags, e->url, NULL, clone, NULL);
+ error = browser_window_create(flags, e->url, NULL,
+ existing, NULL);
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
}
diff --git a/desktop/local_history.h b/desktop/local_history.h
deleted file mode 100644
index c4faa85..0000000
--- a/desktop/local_history.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2006 James Bursa <bursa(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Browser history tree (interface).
- */
-
-#ifndef _NETSURF_DESKTOP_HISTORY_H_
-#define _NETSURF_DESKTOP_HISTORY_H_
-
-#include <stdbool.h>
-#include <libwapcaplet/libwapcaplet.h>
-
-struct hlcache_handle;
-struct history;
-struct browser_window;
-struct history_entry;
-struct redraw_context;
-
-struct history *history_create(void);
-struct history *history_clone(struct history *history);
-void history_add(struct history *history, struct hlcache_handle *content,
- lwc_string *frag_id);
-void history_update(struct history *history, struct hlcache_handle *content);
-void history_destroy(struct history *history);
-void history_back(struct browser_window *bw, struct history *history);
-void history_forward(struct browser_window *bw, struct history *history);
-bool history_back_available(struct history *history);
-bool history_forward_available(struct history *history);
-void history_size(struct history *history, int *width, int *height);
-bool history_redraw(struct history *history, const struct redraw_context *ctx);
-bool history_redraw_rectangle(struct history *history,
- int x0, int y0, int x1, int y1, int x, int y,
- const struct redraw_context *ctx);
-bool history_click(struct browser_window *bw, struct history *history,
- int x, int y, bool new_window);
-const char *history_position_url(struct history *history, int x, int y);
-
-/**
- * Callback function type for history enumeration
- *
- * \param history history being enumerated
- * \param x0, y0, x1, y1 Coordinates of entry in history tree view
- * \param entry Current history entry
- * \return true to continue enumeration, false to cancel enumeration
- */
-typedef bool (*history_enumerate_cb)(const struct history *history, int x0, int y0,
- int x1, int y1,
- const struct history_entry *entry, void *user_data);
-
-/**
- * Enumerate all entries in the history.
- * Do not change the history while it is being enumerated.
- *
- * \param history history to enumerate
- * \param cb callback function
- * \param user_data context pointer passed to cb
- */
-void history_enumerate(const struct history *history, history_enumerate_cb cb, void *user_data);
-
-/**
- * Enumerate all entries that will be reached by the 'forward' button
- *
- * \param history The history object to enumerate in
- * \param cb The callback function
- * \param user_data Data passed to the callback
- */
-void history_enumerate_forward( struct history *history,
- history_enumerate_cb cb, void *user_data );
-
-/**
- * Enumerate all entries that will be reached by the 'back' button
- *
- * \param history The history object to enumerate in
- * \param cb The callback function
- * \param user_data Data passed to the callback
- */
-void history_enumerate_back( struct history *history,
- history_enumerate_cb cb, void *user_data );
-
-/**
- * Returns the URL to a history entry
- *
- * \param entry the history entry to retrieve the URL from
- * \return the URL
- */
-const char *history_entry_get_url(const struct history_entry *entry);
-
-/**
- * Returns the URL to a history entry
- *
- * \param entry the history entry to retrieve the fragment id from
- * \return the fragment id
- */
-const char *history_entry_get_fragment_id(const struct history_entry *entry);
-
-/**
- * Returns the title of a history entry
- *
- * \param entry the history entry to retrieve the title from
- * \return the title
- */
-const char *history_entry_get_title(const struct history_entry *entry);
-
-/**
- * Open a history entry in the specified browser window
- *
- * \param bw browser window
- * \param history history containing entry
- * \param entry entry to open
- * \param new_window open entry in new window
- */
-void history_go(struct browser_window *bw, struct history *history,
- struct history_entry *entry, bool new_window);
-
-#endif
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 76da91a..c3653b5 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -73,7 +73,6 @@
#define HL_CACHE_CLEAN_TIME (2 * IMAGE_CACHE_CLEAN_TIME)
bool netsurf_quit = false;
-bool verbose_log = false;
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
{
diff --git a/desktop/netsurf.h b/desktop/netsurf.h
index e6858ad..77589c7 100644
--- a/desktop/netsurf.h
+++ b/desktop/netsurf.h
@@ -23,7 +23,6 @@
#include "utils/errors.h"
extern bool netsurf_quit;
-extern bool verbose_log;
extern const char * const netsurf_version;
extern const int netsurf_version_major;
extern const int netsurf_version_minor;
diff --git a/desktop/save_text.c b/desktop/save_text.c
index 38f8c53..bc4d4c5 100644
--- a/desktop/save_text.c
+++ b/desktop/save_text.c
@@ -28,14 +28,16 @@
#include <dom/dom.h>
#include "utils/config.h"
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "desktop/save_text.h"
#include "render/box.h"
#include "render/html.h"
-#include "utils/log.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
+
+#include "desktop/gui_factory.h"
+#include "desktop/save_text.h"
static void extract_text(struct box *box, bool *first,
save_text_whitespace *before, struct save_text_state *save);
@@ -69,7 +71,7 @@ void save_as_text(hlcache_handle *c, char *path)
if (!save.block)
return;
- ret = utf8_to_local_encoding(save.block, save.length, &result);
+ ret = guit->utf8->utf8_to_local(save.block, save.length, &result);
free(save.block);
if (ret != NSERROR_OK) {
diff --git a/desktop/search.c b/desktop/search.c
index 3a7c768..201d416 100644
--- a/desktop/search.c
+++ b/desktop/search.c
@@ -21,67 +21,27 @@
/** \file
* Free text search (core)
*/
-#include "utils/config.h"
-#include <ctype.h>
-#include <string.h>
-#include <dom/dom.h>
#include "content/content.h"
-#include "content/hlcache.h"
+
#include "desktop/browser_private.h"
-#include "desktop/gui.h"
-#include "utils/nsoption.h"
#include "desktop/search.h"
-#include "desktop/selection.h"
-#include "render/box.h"
-#include "render/html.h"
-#include "render/search.h"
-#include "render/textplain.h"
-#include "utils/config.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "utils/utils.h"
-
-
-
-/**
- * Starts or continues an existing search.
- *
- * \param bw the browser_window to search
- * \param callbacks callbacks vtable to update frontend according to results
- * \param gui_data a pointer returned to the callbacks
- * \param flags search flags
- * \param string string to search for
- */
-void browser_window_search(struct browser_window *bw,
- struct gui_search_callbacks *gui_callbacks, void *gui_data,
+/* exported function documented in desktop/search.h */
+void browser_window_search(struct browser_window *bw, void *context,
search_flags_t flags, const char *string)
{
- assert(gui_callbacks != NULL);
-
- if (bw == NULL || bw->current_content == NULL)
- return;
-
- content_search(bw->current_content, gui_callbacks, gui_data,
- flags, string);
+ if ((bw != NULL) &&
+ (bw->current_content != NULL)) {
+ content_search(bw->current_content, context, flags, string);
+ }
}
-
-/**
- * Clear up a search. Frees any memory used by the search
- *
- * \param bw the browser_window to search
- * \param callbacks callbacks vtable to update frontend according to results
- * \param gui_data a pointer returned to the callbacks
- * \param flags search flags
- * \param string string to search for
- */
+/* exported function documented in desktop/search.h */
void browser_window_search_clear(struct browser_window *bw)
{
- if (bw == NULL || bw->current_content == NULL)
- return;
-
- content_search_clear(bw->current_content);
+ if ((bw != NULL) &&
+ (bw->current_content != NULL)) {
+ content_search_clear(bw->current_content);
+ }
}
diff --git a/desktop/search.h b/desktop/search.h
index 8440ce9..254acde 100644
--- a/desktop/search.h
+++ b/desktop/search.h
@@ -33,54 +33,24 @@ typedef enum {
} search_flags_t;
/**
- * Change the displayed search status.
- * \param found search pattern matched in text
- * \param p gui private data pointer provided with search callbacks
- */
-typedef void (*gui_search_status)(bool found, void *p);
-
-/**
- * display hourglass while searching
- * \param active start/stop indicator
- * \param p gui private data pointer provided with search callbacks
- */
-typedef void (*gui_search_hourglass)(bool active, void *p);
-
-/**
- * add search string to recent searches list
- * front has full liberty how to implement the bare notification;
- * core gives no guarantee of the integrity of the const char *
- * \param string search pattern
- * \param p gui private data pointer provided with search callbacks
- */
-typedef void (*gui_search_add_recent)(const char *string, void *p);
-
-/**
- * activate search forwards button in gui
- * \param active activate/inactivate
- * \param p gui private data pointer provided with search callbacks
+ * Starts or continues an existing search.
+ *
+ * \param bw The browser_window to search.
+ * \param context A context pointer passed to the callbacks.
+ * \param flags Flags controlling the search operation.
+ * \param string The string being searched for.
*/
-typedef void (*gui_search_forward_state)(bool active, void *p);
+void browser_window_search(struct browser_window *bw, void *context, search_flags_t flags, const char *string);
/**
- * activate search back button in gui
- * \param active activate/inactivate
- * \param p gui private data pointer provided with search callbacks
+ * Clear up a search.
+ *
+ * Frees any memory used by the search.
+ *
+ * \param bw The browser window to clean up the search for.
+ * \param context A context pointer passed to the callbacks.
*/
-typedef void (*gui_search_back_state)(bool active, void *p);
-
-struct gui_search_callbacks {
- gui_search_forward_state forward_state;
- gui_search_back_state back_state;
- gui_search_status status;
- gui_search_hourglass hourglass;
- gui_search_add_recent add_recent;
-};
-
-void browser_window_search(struct browser_window *bw,
- struct gui_search_callbacks *gui_callbacks, void *gui_data,
- search_flags_t flags, const char *string);
void browser_window_search_clear(struct browser_window *bw);
#endif
diff --git a/desktop/searchweb.c b/desktop/searchweb.c
index b3f6162..368ad05 100644
--- a/desktop/searchweb.c
+++ b/desktop/searchweb.c
@@ -26,7 +26,6 @@
#include "content/content.h"
#include "content/hlcache.h"
#include "desktop/browser.h"
-#include "desktop/gui.h"
#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
#include "desktop/searchweb.h"
@@ -72,9 +71,8 @@ bool search_web_new_window(struct browser_window *bw, const char *searchterm)
error = nsurl_create(urltxt, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
bw,
diff --git a/desktop/selection.c b/desktop/selection.c
index 96c7e0c..34292fd 100644
--- a/desktop/selection.c
+++ b/desktop/selection.c
@@ -29,7 +29,6 @@
#include <dom/dom.h>
#include "desktop/browser_private.h"
-#include "desktop/gui.h"
#include "desktop/gui_factory.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index e0e87fb..d465af8 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -24,9 +24,9 @@
#include <assert.h>
#include <stdlib.h>
-
#include "content/fetch.h"
#include "content/urldb.h"
+#include "content/hlcache.h"
#include "desktop/sslcert_viewer.h"
#include "desktop/treeview.h"
#include "utils/messages.h"
diff --git a/desktop/textarea.c b/desktop/textarea.c
index fa0b2fd..bd35a5e 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -202,6 +202,17 @@ static void textarea_normalise_text(struct textarea *ta,
/**
+ * Reset the selection (no redraw)
+ *
+ * \param ta Text area
+ */
+static inline void textarea_reset_selection(struct textarea *ta)
+{
+ ta->sel_start = ta->sel_end = -1;
+}
+
+
+/**
* Get the caret's position
*
* \param ta Text area
@@ -1769,13 +1780,14 @@ static void textarea_setup_text_offsets(struct textarea *ta)
if (ta->flags & TEXTAREA_MULTILINE) {
/* Multiline textarea */
text_y_offset += ta->pad_top;
- text_y_offset_baseline += (ta->line_height * 3 + 2) / 4 +
- ta->pad_top;
+ text_y_offset_baseline +=
+ (ta->line_height * 3 + 2) / 4 + ta->pad_top;
} else {
/* Single line text area; text is vertically centered */
int vis_height = ta->vis_height - 2 * ta->border_width;
text_y_offset += (vis_height - ta->line_height + 1) / 2;
- text_y_offset_baseline += (vis_height * 3 + 2) / 4;
+ text_y_offset_baseline +=
+ (2 * vis_height + ta->line_height + 2) / 4;
}
ta->text_y_offset = text_y_offset;
@@ -2400,8 +2412,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
length, false, &byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
} else {
if (!textarea_replace_text(ta, caret, caret,
utf8, length, false, &byte_delta, &r))
@@ -2431,8 +2444,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
"", 0, false, &byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
} else if (caret > 0) {
b_off = utf8_prev(ta->show->data, caret);
if (!textarea_replace_text(ta, b_off, caret,
@@ -2451,8 +2465,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
"", 0, false, &byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
} else if (caret < ta->show->len - 1) {
b_off = utf8_next(ta->show->data,
ta->show->len - 1, caret);
@@ -2476,8 +2491,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
&byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
} else {
if (!textarea_replace_text(ta, caret, caret,
"\n", 1, false,
@@ -2506,8 +2522,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
false, &byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
} else {
if (!textarea_replace_text(ta,
caret, caret,
@@ -2530,9 +2547,10 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
"", 0, true, &byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
caret += byte_delta;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
}
break;
case KEY_ESCAPE:
@@ -2704,8 +2722,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
ta->sel_start, ta->sel_end,
"", 0, false, &byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
} else {
if (ta->lines[line].b_length != 0) {
/* Delete line */
@@ -2736,8 +2755,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
ta->sel_start, ta->sel_end,
"", 0, false, &byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
} else {
b_len = ta->lines[line].b_length;
b_off = ta->lines[line].b_start + b_len;
@@ -2757,8 +2777,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
ta->sel_start, ta->sel_end,
"", 0, false, &byte_delta, &r))
return false;
+ redraw = true;
caret = ta->sel_end;
- textarea_clear_selection(ta);
+ textarea_reset_selection(ta);
} else {
if (!textarea_replace_text(ta,
caret - ta->caret_pos.byte_off,
@@ -3043,7 +3064,7 @@ bool textarea_clear_selection(struct textarea *ta)
break;
/* Clear selection and redraw */
- ta->sel_start = ta->sel_end = -1;
+ textarea_reset_selection(ta);
msg.ta = ta;
msg.type = TEXTAREA_MSG_REDRAW_REQUEST;
diff --git a/desktop/textinput.c b/desktop/textinput.c
index c61b838..fd6ae9f 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -30,7 +30,6 @@
#include <dom/dom.h>
#include "desktop/browser_private.h"
-#include "desktop/gui.h"
#include "desktop/gui_factory.h"
#include "desktop/mouse.h"
#include "desktop/scrollbar.h"
diff --git a/desktop/tree.h b/desktop/tree.h
index db164c0..a411437 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -27,9 +27,11 @@
#include <stdbool.h>
#include <stdint.h>
-#include "desktop/browser.h"
+#include "desktop/mouse.h"
struct sslcert_session_data;
+struct tree;
+struct redraw_context;
extern struct sslcert_session_data *ssl_current_session;
extern const char *tree_hotlist_path;
@@ -42,9 +44,6 @@ enum tree_flags {
TREE_HOTLIST
};
-
-struct tree;
-
typedef enum {
TREE_NO_DRAG = 0,
TREE_SELECT_DRAG,
diff --git a/desktop/treeview.c b/desktop/treeview.c
index d380882..d24924a 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -20,15 +20,17 @@
* Treeview handling (implementation).
*/
+#include "utils/log.h"
#include "css/utils.h"
+#include "image/bitmap.h"
+#include "render/font.h"
+#include "content/hlcache.h"
+
#include "desktop/system_colour.h"
#include "desktop/knockout.h"
#include "desktop/plotters.h"
#include "desktop/textarea.h"
#include "desktop/treeview.h"
-#include "image/bitmap.h"
-#include "render/font.h"
-#include "utils/log.h"
/* TODO: get rid of REDRAW_MAX -- need to be able to know window size */
#define REDRAW_MAX 8000
diff --git a/framebuffer/Makefile.defaults b/framebuffer/Makefile.defaults
index 6e2a3d1..5fe8e2c 100644
--- a/framebuffer/Makefile.defaults
+++ b/framebuffer/Makefile.defaults
@@ -2,46 +2,46 @@
# Framebuffer-target-specific options
# ----------------------------------------------------------------------------
- # Optimisation levels
- CFLAGS += -O2
-
- # Framebuffer default surface provider.
- # Valid values are: x, sdl, linux, vnc, able,
- NETSURF_FB_FRONTEND := sdl
-
- # Use libharu to enable PDF export and GTK printing support.
- # Valid options: YES, NO
- NETSURF_USE_HARU_PDF := NO
-
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := AUTO
-
- # Library to use for font plotting
- # Valid options: internal, freetype
- NETSURF_FB_FONTLIB := internal
-
- # Default freetype font files
- NETSURF_FB_FONT_SANS_SERIF := DejaVuSans.ttf
- NETSURF_FB_FONT_SANS_SERIF_BOLD := DejaVuSans-Bold.ttf
- NETSURF_FB_FONT_SANS_SERIF_ITALIC := DejaVuSans-Oblique.ttf
- NETSURF_FB_FONT_SANS_SERIF_ITALIC_BOLD := DejaVuSans-BoldOblique.ttf
- NETSURF_FB_FONT_SERIF := DejaVuSerif.ttf
- NETSURF_FB_FONT_SERIF_BOLD := DejaVuSerif-Bold.ttf
- NETSURF_FB_FONT_MONOSPACE := DejaVuSansMono.ttf
- NETSURF_FB_FONT_MONOSPACE_BOLD := DejaVuSansMono-Bold.ttf
- NETSURF_FB_FONT_CURSIVE := Comic_Sans_MS.ttf
- NETSURF_FB_FONT_FANTASY := Impact.ttf
-
- # Default binary install path
- NETSURF_FRAMEBUFFER_BIN := $(PREFIX)/bin/
-
- # Default resource install path
- NETSURF_FRAMEBUFFER_RESOURCES := $(PREFIX)/share/netsurf/
-
- # Default framebuffer search path
- NETSURF_FB_RESPATH := $${HOME}/.netsurf/:$${NETSURFRES}:$(NETSURF_FRAMEBUFFER_RESOURCES):./framebuffer/res
-
- # freetype compiled in font serch path
- NETSURF_FB_FONTPATH := /usr/share/fonts/truetype/ttf-dejavu:/usr/share/fonts/truetype/msttcorefonts
+# Optimisation levels
+CFLAGS += -O2
+
+# Framebuffer default surface provider.
+# Valid values are: x, sdl, linux, vnc, able,
+NETSURF_FB_FRONTEND := sdl
+
+# Use libharu to enable PDF export and GTK printing support.
+# Valid options: YES, NO
+NETSURF_USE_HARU_PDF := NO
+
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := AUTO
+
+# Library to use for font plotting
+# Valid options: internal, freetype
+NETSURF_FB_FONTLIB := internal
+
+# Default freetype font files
+NETSURF_FB_FONT_SANS_SERIF := DejaVuSans.ttf
+NETSURF_FB_FONT_SANS_SERIF_BOLD := DejaVuSans-Bold.ttf
+NETSURF_FB_FONT_SANS_SERIF_ITALIC := DejaVuSans-Oblique.ttf
+NETSURF_FB_FONT_SANS_SERIF_ITALIC_BOLD := DejaVuSans-BoldOblique.ttf
+NETSURF_FB_FONT_SERIF := DejaVuSerif.ttf
+NETSURF_FB_FONT_SERIF_BOLD := DejaVuSerif-Bold.ttf
+NETSURF_FB_FONT_MONOSPACE := DejaVuSansMono.ttf
+NETSURF_FB_FONT_MONOSPACE_BOLD := DejaVuSansMono-Bold.ttf
+NETSURF_FB_FONT_CURSIVE := Comic_Sans_MS.ttf
+NETSURF_FB_FONT_FANTASY := Impact.ttf
+
+# Default binary install path
+NETSURF_FRAMEBUFFER_BIN := $(PREFIX)/bin/
+
+# Default resource install path
+NETSURF_FRAMEBUFFER_RESOURCES := $(PREFIX)/share/netsurf/
+
+# Default framebuffer search path
+NETSURF_FB_RESPATH := $${HOME}/.netsurf/:$${NETSURFRES}:$(NETSURF_FRAMEBUFFER_RESOURCES):./framebuffer/res
+
+# freetype compiled in font serch path
+NETSURF_FB_FONTPATH := /usr/share/fonts/truetype/ttf-dejavu:/usr/share/fonts/truetype/msttcorefonts
diff --git a/framebuffer/clipboard.c b/framebuffer/clipboard.c
index b4bd296..3729cd4 100644
--- a/framebuffer/clipboard.c
+++ b/framebuffer/clipboard.c
@@ -23,11 +23,14 @@
#include <assert.h>
#include <stdint.h>
#include <string.h>
+#include <stdlib.h>
+
+#include "utils/log.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
+
#include "framebuffer/gui.h"
#include "framebuffer/clipboard.h"
-#include "utils/log.h"
static struct gui_clipboard {
diff --git a/framebuffer/convert_image.c b/framebuffer/convert_image.c
index bf47a35..838a907 100644
--- a/framebuffer/convert_image.c
+++ b/framebuffer/convert_image.c
@@ -159,6 +159,7 @@ main(int argc, char **argv)
if (br < 0) {
printf("Error reading input: %s\n", strerror(errno));
+ fclose(f);
return 1;
}
diff --git a/framebuffer/fetch.c b/framebuffer/fetch.c
index 0c9b90f..2942c2d 100644
--- a/framebuffer/fetch.c
+++ b/framebuffer/fetch.c
@@ -21,12 +21,15 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <limits.h>
-#include "desktop/gui.h"
+#include "utils/nsurl.h"
#include "utils/url.h"
#include "utils/log.h"
#include "utils/filepath.h"
+#include "desktop/gui.h"
#include "framebuffer/findfile.h"
#include "framebuffer/fetch.h"
diff --git a/framebuffer/font.h b/framebuffer/font.h
index 5ae5bb3..6350421 100644
--- a/framebuffer/font.h
+++ b/framebuffer/font.h
@@ -21,6 +21,8 @@
#include "utils/utf8.h"
+extern struct gui_utf8_table *framebuffer_utf8_table;
+
bool fb_font_init(void);
bool fb_font_finalise(void);
diff --git a/framebuffer/font_freetype.c b/framebuffer/font_freetype.c
index eb7278c..4381db6 100644
--- a/framebuffer/font_freetype.c
+++ b/framebuffer/font_freetype.c
@@ -23,13 +23,14 @@
#include <ft2build.h>
#include FT_CACHE_H
-#include "css/css.h"
-#include "css/utils.h"
-#include "render/font.h"
#include "utils/filepath.h"
#include "utils/utf8.h"
#include "utils/log.h"
#include "utils/nsoption.h"
+#include "css/css.h"
+#include "css/utils.h"
+#include "render/font.h"
+#include "desktop/gui.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
@@ -74,30 +75,6 @@ enum fb_face_e {
static fb_faceid_t *fb_faces[FB_FACE_COUNT];
-
-nserror utf8_to_local_encoding(const char *string,
- size_t len,
- char **result)
-{
- return utf8_to_enc(string, "UTF-8", len, result);
-}
-
-nserror utf8_from_local_encoding(const char *string,
- size_t len,
- char **result)
-{
- *result = malloc(len + 1);
- if (*result == NULL) {
- return NSERROR_NOMEM;
- }
-
- memcpy(*result, string, len);
-
- (*result)[len] = '\0';
-
- return NSERROR_OK;
-}
-
/* map cache manager handle to face id */
static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *face )
{
@@ -581,6 +558,8 @@ const struct font_functions nsfont = {
nsfont_split
};
+struct gui_utf8_table *framebuffer_utf8_table = NULL;
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/framebuffer/font_internal.c b/framebuffer/font_internal.c
index 1eed006..da5ca92 100644
--- a/framebuffer/font_internal.c
+++ b/framebuffer/font_internal.c
@@ -19,12 +19,13 @@
#include <inttypes.h>
#include <string.h>
-
#include <assert.h>
-#include "css/css.h"
-#include "render/font.h"
+
#include "utils/nsoption.h"
#include "utils/utf8.h"
+#include "desktop/gui.h"
+#include "css/css.h"
+#include "render/font.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
@@ -68,7 +69,7 @@ nserror utf8_to_font_encoding(const struct fb_font_desc* font,
}
-nserror utf8_to_local_encoding(const char *string,
+static nserror utf8_to_local(const char *string,
size_t len,
char **result)
{
@@ -76,7 +77,7 @@ nserror utf8_to_local_encoding(const char *string,
}
-nserror utf8_from_local_encoding(const char *string,
+static nserror utf8_from_local(const char *string,
size_t len,
char **result)
{
@@ -183,6 +184,14 @@ const struct font_functions nsfont = {
nsfont_split
};
+static struct gui_utf8_table utf8_table = {
+ .utf8_to_local = utf8_to_local,
+ .local_to_utf8 = utf8_from_local,
+};
+
+struct gui_utf8_table *framebuffer_utf8_table = &utf8_table;
+
+
/*
* Local Variables:
* c-basic-offset:8
diff --git a/framebuffer/gui.c b/framebuffer/gui.c
index e7f456d..7d3e95c 100644
--- a/framebuffer/gui.c
+++ b/framebuffer/gui.c
@@ -31,7 +31,7 @@
#include <libnsfb_plot.h>
#include <libnsfb_event.h>
-#include "desktop/browser_private.h"
+#include "desktop/browser_history.h"
#include "desktop/gui.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
@@ -40,10 +40,7 @@
#include "utils/filepath.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/schedule.h"
#include "utils/types.h"
-#include "utils/url.h"
-#include "utils/utils.h"
#include "desktop/textinput.h"
#include "render/form.h"
@@ -58,7 +55,6 @@
#include "framebuffer/fetch.h"
#include "content/urldb.h"
-#include "desktop/local_history.h"
#include "content/fetch.h"
#define NSFB_TOOLBAR_DEFAULT_LAYOUT "blfsrutc"
@@ -124,9 +120,8 @@ static void
widget_scroll_y(struct gui_window *gw, int y, bool abs)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser);
- int content_height;
+ int content_width, content_height;
int height;
- float scale = gw->bw->scale;
LOG(("window scroll"));
if (abs) {
@@ -135,7 +130,8 @@ widget_scroll_y(struct gui_window *gw, int y, bool abs)
bwidget->pany += y;
}
- content_height = content_get_height(gw->bw->current_content) * scale;
+ browser_window_get_extents(gw->bw, true,
+ &content_width, &content_height);
height = fbtk_get_height(gw->browser);
@@ -162,9 +158,8 @@ static void
widget_scroll_x(struct gui_window *gw, int x, bool abs)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser);
- int content_width;
+ int content_width, content_height;
int width;
- float scale = gw->bw->scale;
if (abs) {
bwidget->panx = x - bwidget->scrollx;
@@ -172,7 +167,8 @@ widget_scroll_x(struct gui_window *gw, int x, bool abs)
bwidget->panx += x;
}
- content_width = content_get_width(gw->bw->current_content) * scale;
+ browser_window_get_extents(gw->bw, true,
+ &content_width, &content_height);
width = fbtk_get_width(gw->browser);
@@ -331,6 +327,7 @@ fb_redraw(fbtk_widget_t *widget,
.plot = &fb_plotters
};
nsfb_t *nsfb = fbtk_get_nsfb(widget);
+ float scale = browser_window_get_scale(bw);
LOG(("%d,%d to %d,%d",
bwidget->redraw_box.x0,
@@ -356,8 +353,8 @@ fb_redraw(fbtk_widget_t *widget,
clip.y1 = bwidget->redraw_box.y1;
browser_window_redraw(bw,
- (x - bwidget->scrollx) / bw->scale,
- (y - bwidget->scrolly) / bw->scale,
+ (x - bwidget->scrollx) / scale,
+ (y - bwidget->scrolly) / scale,
&clip, &ctx);
if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
@@ -559,7 +556,7 @@ static bool nslog_stream_configure(FILE *fptr)
-static void gui_poll(bool active)
+static void framebuffer_poll(bool active)
{
nsfb_event_t event;
int timeout; /* timeout in miliseconds */
@@ -601,7 +598,7 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
browser_mouse_state mouse;
- float scale = gw->bw->scale;
+ float scale = browser_window_get_scale(gw->bw);
int x = (cbi->x + bwidget->scrollx) / scale;
int y = (cbi->y + bwidget->scrolly) / scale;
unsigned int time_now;
@@ -753,8 +750,9 @@ fb_browser_window_move(fbtk_widget_t *widget, fbtk_callback_info *cbi)
browser_mouse_state mouse = 0;
struct gui_window *gw = cbi->context;
struct browser_widget_s *bwidget = fbtk_get_userpw(widget);
- int x = (cbi->x + bwidget->scrollx) / gw->bw->scale;
- int y = (cbi->y + bwidget->scrolly) / gw->bw->scale;
+ float scale = browser_window_get_scale(gw->bw);
+ int x = (cbi->x + bwidget->scrollx) / scale;
+ int y = (cbi->y + bwidget->scrolly) / scale;
if (gui_drag.state == GUI_DRAG_PRESSED &&
(abs(x - gui_drag.x) > 5 ||
@@ -986,8 +984,8 @@ fb_leftarrow_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- if (history_back_available(bw->history))
- history_back(bw, bw->history);
+ if (browser_window_back_available(bw))
+ browser_window_history_back(bw, false);
fb_update_back_forward(gw);
@@ -1004,8 +1002,8 @@ fb_rightarrow_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- if (history_forward_available(bw->history))
- history_forward(bw, bw->history);
+ if (browser_window_forward_available(bw))
+ browser_window_history_forward(bw, false);
fb_update_back_forward(gw);
return 1;
@@ -1092,14 +1090,8 @@ fb_url_enter(void *pw, char *text)
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
} else {
- browser_window_navigate(bw,
- url,
- NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- NULL);
+ browser_window_navigate(bw, url, NULL, BW_NAVIGATE_HISTORY,
+ NULL, NULL, NULL);
nsurl_unref(url);
}
@@ -1505,8 +1497,8 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width)
static struct gui_window *
gui_window_create(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
struct gui_window *gw;
@@ -1515,8 +1507,7 @@ gui_window_create(struct browser_window *bw,
if (gw == NULL)
return NULL;
- /* seems we need to associate the gui window with the underlying
- * browser window
+ /* associate the gui window with the underlying browser window
*/
gw->bw = bw;
@@ -1558,9 +1549,10 @@ static bool
gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(g->browser);
+ float scale = browser_window_get_scale(g->bw);
- *sx = bwidget->scrollx / g->bw->scale;
- *sy = bwidget->scrolly / g->bw->scale;
+ *sx = bwidget->scrollx / scale;
+ *sy = bwidget->scrolly / scale;
return true;
}
@@ -1569,11 +1561,12 @@ static void
gui_window_set_scroll(struct gui_window *gw, int sx, int sy)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser);
+ float scale = browser_window_get_scale(gw->bw);
assert(bwidget);
- widget_scroll_x(gw, sx * gw->bw->scale, true);
- widget_scroll_y(gw, sy * gw->bw->scale, true);
+ widget_scroll_x(gw, sx * scale, true);
+ widget_scroll_y(gw, sy * scale, true);
}
@@ -1583,26 +1576,27 @@ gui_window_get_dimensions(struct gui_window *g,
int *height,
bool scaled)
{
+ float scale = browser_window_get_scale(g->bw);
+
*width = fbtk_get_width(g->browser);
*height = fbtk_get_height(g->browser);
if (scaled) {
- *width /= g->bw->scale;
- *height /= g->bw->scale;
+ *width /= scale;
+ *height /= scale;
}
}
static void
gui_window_update_extent(struct gui_window *gw)
{
- float scale = gw->bw->scale;
+ int w, h;
+ browser_window_get_extents(gw->bw, true, &w, &h);
- fbtk_set_scroll_parameters(gw->hscroll, 0,
- content_get_width(gw->bw->current_content) * scale,
+ fbtk_set_scroll_parameters(gw->hscroll, 0, w,
fbtk_get_width(gw->browser), 100);
- fbtk_set_scroll_parameters(gw->vscroll, 0,
- content_get_height(gw->bw->current_content) * scale,
+ fbtk_set_scroll_parameters(gw->vscroll, 0, h,
fbtk_get_height(gw->browser), 100);
}
@@ -1701,7 +1695,7 @@ throbber_advance(void *pw)
if (g->throbber_index >= 0) {
fbtk_set_bitmap(g->throbber, image);
- schedule(10, throbber_advance, g);
+ framebuffer_schedule(100, throbber_advance, g);
}
}
@@ -1709,7 +1703,7 @@ static void
gui_window_start_throbber(struct gui_window *g)
{
g->throbber_index = 0;
- schedule(10, throbber_advance, g);
+ framebuffer_schedule(100, throbber_advance, g);
}
static void
@@ -1790,7 +1784,8 @@ static struct gui_window_table framebuffer_window_table = {
static struct gui_browser_table framebuffer_browser_table = {
- .poll = gui_poll,
+ .poll = framebuffer_poll,
+ .schedule = framebuffer_schedule,
.quit = gui_quit,
};
@@ -1815,6 +1810,7 @@ main(int argc, char** argv)
.window = &framebuffer_window_table,
.clipboard = framebuffer_clipboard_table,
.fetch = framebuffer_fetch_table,
+ .utf8 = framebuffer_utf8_table,
};
respaths = fb_init_resource(NETSURF_FB_RESPATH":"NETSURF_FB_FONTPATH);
@@ -1869,8 +1865,7 @@ main(int argc, char** argv)
ret = nsurl_create(feurl, &url);
if (ret == NSERROR_OK) {
- ret = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ ret = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/framebuffer/localhistory.c b/framebuffer/localhistory.c
index d482098..e972a14 100644
--- a/framebuffer/localhistory.c
+++ b/framebuffer/localhistory.c
@@ -16,44 +16,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <limits.h>
-#include <unistd.h>
-#include <assert.h>
-#include <string.h>
#include <stdbool.h>
-#include <stdlib.h>
#include <libnsfb.h>
#include <libnsfb_plot.h>
#include <libnsfb_event.h>
-#include "desktop/browser_private.h"
-#include "desktop/gui.h"
+#include "desktop/browser_history.h"
#include "desktop/plotters.h"
-#include "desktop/netsurf.h"
-#include "utils/nsoption.h"
-#include "utils/log.h"
-#include "utils/url.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "desktop/textinput.h"
-#include "render/form.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
#include "framebuffer/framebuffer.h"
-#include "framebuffer/schedule.h"
-#include "framebuffer/findfile.h"
-#include "framebuffer/image_data.h"
-#include "framebuffer/font.h"
-
-#include "content/urldb.h"
-#include "desktop/local_history.h"
-#include "content/fetch.h"
static int
localhistory_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
@@ -77,7 +51,7 @@ localhistory_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi)
nsfb_plot_rectangle_fill(fbtk_get_nsfb(widget), &rbox, 0xffffffff);
- history_redraw_rectangle(glh->bw->history,
+ browser_window_history_redraw_rectangle(glh->bw,
glh->scrollx,
glh->scrolly,
fbtk_get_width(widget) + glh->scrollx,
@@ -97,7 +71,7 @@ localhistory_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
if (cbi->event->type != NSFB_EVENT_KEY_UP)
return 0;
- history_click(glh->bw, glh->bw->history, cbi->x, cbi->y, false);
+ browser_window_history_click(glh->bw, cbi->x, cbi->y, false);
fbtk_set_mapping(glh->window, false);
diff --git a/framebuffer/schedule.c b/framebuffer/schedule.c
index 43f5318..151b6f9 100644
--- a/framebuffer/schedule.c
+++ b/framebuffer/schedule.c
@@ -20,10 +20,15 @@
#include <time.h>
#include <stdlib.h>
-#include "utils/schedule.h"
+#include "utils/log.h"
+
#include "framebuffer/schedule.h"
-#include "utils/log.h"
+#ifdef DEBUG_SCHEDULER
+#define SRLOG(x) LOG(x)
+#else
+#define SRLOG(x)
+#endif
/* linked list of scheduled callbacks */
static struct nscallback *schedule_list = NULL;
@@ -39,39 +44,6 @@ struct nscallback
void *p;
};
-
-/**
- * Schedule a callback.
- *
- * \param tival interval before the callback should be made / cs
- * \param callback callback function
- * \param p user parameter, passed to callback function
- *
- * The callback function will be called as soon as possible after t cs have
- * passed.
- */
-
-void schedule(int cs_ival, void (*callback)(void *p), void *p)
-{
- struct nscallback *nscb;
- struct timeval tv;
-
- tv.tv_sec = cs_ival / 100; /* cs to seconds */
- tv.tv_usec = (cs_ival % 100) * 10000; /* remainder to microseconds */
-
- nscb = calloc(1, sizeof(struct nscallback));
-
- gettimeofday(&nscb->tv, NULL);
- timeradd(&nscb->tv, &tv, &nscb->tv);
-
- nscb->callback = callback;
- nscb->p = p;
-
- /* add to list front */
- nscb->next = schedule_list;
- schedule_list = nscb;
-}
-
/**
* Unschedule a callback.
*
@@ -80,17 +52,18 @@ void schedule(int cs_ival, void (*callback)(void *p), void *p)
*
* All scheduled callbacks matching both callback and p are removed.
*/
-
-void schedule_remove(void (*callback)(void *p), void *p)
+static nserror schedule_remove(void (*callback)(void *p), void *p)
{
struct nscallback *cur_nscb;
struct nscallback *prev_nscb;
struct nscallback *unlnk_nscb;
- if (schedule_list == NULL)
- return;
+ /* check there is something on the list to remove */
+ if (schedule_list == NULL) {
+ return NSERROR_OK;
+ }
- LOG(("removing %p, %p", callback, p));
+ SRLOG(("removing %p, %p", callback, p));
cur_nscb = schedule_list;
prev_nscb = NULL;
@@ -100,7 +73,7 @@ void schedule_remove(void (*callback)(void *p), void *p)
(cur_nscb->p == p)) {
/* item to remove */
- LOG(("callback entry %p removing %p(%p)",
+ SRLOG(("callback entry %p removing %p(%p)",
cur_nscb, cur_nscb->callback, cur_nscb->p));
/* remove callback */
@@ -119,16 +92,45 @@ void schedule_remove(void (*callback)(void *p), void *p)
cur_nscb = prev_nscb->next;
}
}
+
+ return NSERROR_OK;
}
-/**
- * Process scheduled callbacks up to current time.
- *
- * @return The number of milliseconds untill the next scheduled event
- * or -1 for no event.
- */
-int
-schedule_run(void)
+/* exported function documented in framebuffer/schedule.h */
+nserror framebuffer_schedule(int tival, void (*callback)(void *p), void *p)
+{
+ struct nscallback *nscb;
+ struct timeval tv;
+ nserror ret;
+
+ /* ensure uniqueness of the callback and context */
+ ret = schedule_remove(callback, p);
+ if ((tival < 0) || (ret != NSERROR_OK)) {
+ return ret;
+ }
+
+ SRLOG(("Adding %p(%p) in %d", callback, p, tival));
+
+ tv.tv_sec = tival / 1000; /* miliseconds to seconds */
+ tv.tv_usec = (tival % 1000) * 1000; /* remainder to microseconds */
+
+ nscb = calloc(1, sizeof(struct nscallback));
+
+ gettimeofday(&nscb->tv, NULL);
+ timeradd(&nscb->tv, &tv, &nscb->tv);
+
+ nscb->callback = callback;
+ nscb->p = p;
+
+ /* add to list front */
+ nscb->next = schedule_list;
+ schedule_list = nscb;
+
+ return NSERROR_OK;
+}
+
+/* exported function documented in framebuffer/schedule.h */
+int schedule_run(void)
{
struct timeval tv;
struct timeval nexttime;
@@ -188,7 +190,8 @@ schedule_run(void)
/* make rettime relative to now */
timersub(&nexttime, &tv, &rettime);
- /*LOG(("returning time to next event as %ldms",(rettime.tv_sec * 1000) + (rettime.tv_usec / 1000))); */
+ SRLOG(("returning time to next event as %ldms",(rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)));
+
/* return next event time in milliseconds (24days max wait) */
return (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000);
}
diff --git a/framebuffer/schedule.h b/framebuffer/schedule.h
index 2c9b55f..4e94da6 100644
--- a/framebuffer/schedule.h
+++ b/framebuffer/schedule.h
@@ -19,7 +19,27 @@
#ifndef FRAMEBUFFER_SCHEDULE_H
#define FRAMEBUFFER_SCHEDULE_H
+/**
+ * Schedule a callback.
+ *
+ * \param tival interval before the callback should be made in ms
+ * \param callback callback function
+ * \param p user parameter, passed to callback function
+ *
+ * The callback function will be called as soon as possible after t ms have
+ * passed.
+ */
+
+nserror framebuffer_schedule(int tival, void (*callback)(void *p), void *p);
+
+/**
+ * Process scheduled callbacks up to current time.
+ *
+ * @return The number of milliseconds untill the next scheduled event
+ * or -1 for no event.
+ */
int schedule_run(void);
+
void list_schedule(void);
#endif
diff --git a/gtk/Makefile.defaults b/gtk/Makefile.defaults
index 23d4c17..6c48b0c 100644
--- a/gtk/Makefile.defaults
+++ b/gtk/Makefile.defaults
@@ -2,33 +2,33 @@
# GTK-specific options
# ----------------------------------------------------------------------------
- # Where to search for NetSurf's resources after looking in ~/.netsurf and
- # $NETSURFRES. It must have a trailing /
- NETSURF_GTK_RESOURCES := $(PREFIX)/share/netsurf/
+# Where to search for NetSurf's resources after looking in ~/.netsurf and
+# $NETSURFRES. It must have a trailing /
+NETSURF_GTK_RESOURCES := $(PREFIX)/share/netsurf/
- # Where to install the netsurf binary
- NETSURF_GTK_BIN := $(PREFIX)/bin/
+# Where to install the netsurf binary
+NETSURF_GTK_BIN := $(PREFIX)/bin/
- # Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_RSVG := AUTO
+# Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_RSVG := AUTO
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_NSSVG := AUTO
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_NSSVG := AUTO
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := AUTO
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := AUTO
- # Configuration overrides for Mac OS X
- ifeq ($(HOST),macosx)
+# Configuration overrides for Mac OS X
+ifeq ($(HOST),macosx)
NETSURF_USE_LIBICONV_PLUG := NO
NETSURF_USE_HARU_PDF := NO
- endif
+endif
- # Set default GTK version to build for (2 or 3)
- NETSURF_GTK_MAJOR := 2
+# Set default GTK version to build for (2 or 3)
+NETSURF_GTK_MAJOR := 2
- # Optimisation levels
- CFLAGS += -O2
+# Optimisation levels
+CFLAGS += -O2
diff --git a/gtk/bitmap.c b/gtk/bitmap.c
index 96e9eda..3ae2114 100644
--- a/gtk/bitmap.c
+++ b/gtk/bitmap.c
@@ -187,48 +187,76 @@ unsigned char *bitmap_get_buffer(void *vbitmap)
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
int pixel_loop;
int pixel_count;
- uint32_t *pixels;
- uint32_t pixel;
+ uint8_t *pixels;
+ uint32_t t, r, g, b;
cairo_format_t fmt;
assert(gbitmap);
cairo_surface_flush(gbitmap->surface);
- pixels = (uint32_t *)cairo_image_surface_get_data(gbitmap->surface);
+ pixels = cairo_image_surface_get_data(gbitmap->surface);
if (!gbitmap->converted)
- return (unsigned char *) pixels;
+ return pixels;
fmt = cairo_image_surface_get_format(gbitmap->surface);
pixel_count = cairo_image_surface_get_width(gbitmap->surface) *
cairo_image_surface_get_height(gbitmap->surface);
if (fmt == CAIRO_FORMAT_RGB24) {
+ /* Opaque image */
for (pixel_loop=0; pixel_loop < pixel_count; pixel_loop++) {
- pixel = pixels[pixel_loop];
- pixels[pixel_loop] = (pixel & 0xff00ff00) |
- ((pixel & 0xff) << 16) |
- ((pixel & 0xff0000) >> 16);
+ /* Cairo surface is ARGB, written in native endian */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ b = pixels[4 * pixel_loop + 0];
+ g = pixels[4 * pixel_loop + 1];
+ r = pixels[4 * pixel_loop + 2];
+ t = pixels[4 * pixel_loop + 3];
+#else
+ t = pixels[4 * pixel_loop + 0];
+ r = pixels[4 * pixel_loop + 1];
+ g = pixels[4 * pixel_loop + 2];
+ b = pixels[4 * pixel_loop + 3];
+#endif
+
+ /* Core bitmaps always have a component order of rgba,
+ * regardless of system endianness */
+ pixels[4 * pixel_loop + 0] = r;
+ pixels[4 * pixel_loop + 1] = g;
+ pixels[4 * pixel_loop + 2] = b;
+ pixels[4 * pixel_loop + 3] = t;
}
} else {
- uint32_t t, r, g, b;
+ /* Alpha image: de-multiply alpha */
for (pixel_loop=0; pixel_loop < pixel_count; pixel_loop++) {
- pixel = pixels[pixel_loop];
- t = (pixel & 0xff000000) >> 24;
- if (t == 0) {
- pixels[pixel_loop] = 0;
- } else {
- r = ((pixel & 0xff0000) >> 8) / t;
- g = ((pixel & 0xff00)) / t;
- b = ((pixel & 0xff) << 8) / t;
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ b = pixels[4 * pixel_loop + 0];
+ g = pixels[4 * pixel_loop + 1];
+ r = pixels[4 * pixel_loop + 2];
+ t = pixels[4 * pixel_loop + 3];
+#else
+ t = pixels[4 * pixel_loop + 0];
+ r = pixels[4 * pixel_loop + 1];
+ g = pixels[4 * pixel_loop + 2];
+ b = pixels[4 * pixel_loop + 3];
+#endif
+
+ if (t != 0) {
+ r = (r << 8) / t;
+ g = (g << 8) / t;
+ b = (b << 8) / t;
r = (r > 255) ? 255 : r;
g = (g > 255) ? 255 : g;
b = (b > 255) ? 255 : b;
-
- pixels[pixel_loop] = (t << 24) |
- (r) | (g << 8) | (b << 16);
+ } else {
+ r = g = b = 0;
}
+
+ pixels[4 * pixel_loop + 0] = r;
+ pixels[4 * pixel_loop + 1] = g;
+ pixels[4 * pixel_loop + 2] = b;
+ pixels[4 * pixel_loop + 3] = t;
}
}
@@ -319,8 +347,8 @@ void bitmap_modified(void *vbitmap) {
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
int pixel_loop;
int pixel_count;
- uint32_t *pixels;
- uint32_t pixel;
+ uint8_t *pixels;
+ uint32_t t, r, g, b;
cairo_format_t fmt;
assert(gbitmap);
@@ -329,7 +357,7 @@ void bitmap_modified(void *vbitmap) {
pixel_count = cairo_image_surface_get_width(gbitmap->surface) *
cairo_image_surface_get_height(gbitmap->surface);
- pixels = (uint32_t *)cairo_image_surface_get_data(gbitmap->surface);
+ pixels = cairo_image_surface_get_data(gbitmap->surface);
if (gbitmap->converted) {
cairo_surface_mark_dirty(gbitmap->surface);
@@ -337,30 +365,55 @@ void bitmap_modified(void *vbitmap) {
}
if (fmt == CAIRO_FORMAT_RGB24) {
+ /* Opaque image */
for (pixel_loop=0; pixel_loop < pixel_count; pixel_loop++) {
- pixel = pixels[pixel_loop];
- pixels[pixel_loop] = (pixel & 0xff00ff00) |
- ((pixel & 0xff) << 16) |
- ((pixel & 0xff0000) >> 16);
+ /* Core bitmaps always have a component order of rgba,
+ * regardless of system endianness */
+ r = pixels[4 * pixel_loop + 0];
+ g = pixels[4 * pixel_loop + 1];
+ b = pixels[4 * pixel_loop + 2];
+ t = pixels[4 * pixel_loop + 3];
+
+ /* Cairo surface is ARGB, written in native endian */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ pixels[4 * pixel_loop + 0] = b;
+ pixels[4 * pixel_loop + 1] = g;
+ pixels[4 * pixel_loop + 2] = r;
+ pixels[4 * pixel_loop + 3] = t;
+#else
+ pixels[4 * pixel_loop + 0] = t;
+ pixels[4 * pixel_loop + 1] = r;
+ pixels[4 * pixel_loop + 2] = g;
+ pixels[4 * pixel_loop + 3] = b;
+#endif
}
} else {
- uint8_t t, r, g, b;
+ /* Alpha image: pre-multiply alpha */
for (pixel_loop=0; pixel_loop < pixel_count; pixel_loop++) {
- pixel = pixels[pixel_loop];
- t = (pixel & 0xff000000) >> 24;
- if (t == 0) {
- pixels[pixel_loop] = 0;
+ r = pixels[4 * pixel_loop + 0];
+ g = pixels[4 * pixel_loop + 1];
+ b = pixels[4 * pixel_loop + 2];
+ t = pixels[4 * pixel_loop + 3];
+
+ if (t != 0) {
+ r = ((r * (t + 1)) >> 8) & 0xff;
+ g = ((g * (t + 1)) >> 8) & 0xff;
+ b = ((b * (t + 1)) >> 8) & 0xff;
} else {
- r = (pixel & 0xff0000) >> 16;
- g = (pixel & 0xff00) >> 8;
- b = pixel & 0xff;
-
- pixels[pixel_loop] = (t << 24) |
- ((r * t) >> 8) |
- ((g * t) >> 8) << 8 |
- ((b * t) >> 8) << 16;
-
+ r = g = b = 0;
}
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ pixels[4 * pixel_loop + 0] = b;
+ pixels[4 * pixel_loop + 1] = g;
+ pixels[4 * pixel_loop + 2] = r;
+ pixels[4 * pixel_loop + 3] = t;
+#else
+ pixels[4 * pixel_loop + 0] = t;
+ pixels[4 * pixel_loop + 1] = r;
+ pixels[4 * pixel_loop + 2] = g;
+ pixels[4 * pixel_loop + 3] = b;
+#endif
}
}
diff --git a/gtk/compat.h b/gtk/compat.h
index b8c91d9..ee2ebb2 100644
--- a/gtk/compat.h
+++ b/gtk/compat.h
@@ -23,6 +23,8 @@
#ifndef NETSURF_GTK_COMPAT_H_
#define NETSURF_GTK_COMPAT_H_
+#include <stdint.h>
+
#include <gtk/gtk.h>
void nsgtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
diff --git a/gtk/dialogs/about.c b/gtk/dialogs/about.c
index 3ebb4c0..2cd2f34 100644
--- a/gtk/dialogs/about.c
+++ b/gtk/dialogs/about.c
@@ -18,10 +18,11 @@
#include <stdint.h>
+#include "utils/utils.h"
+
#include "gtk/compat.h"
#include "gtk/gui.h"
#include "gtk/dialogs/about.h"
-#include "desktop/browser.h"
static void
@@ -36,8 +37,7 @@ nsgtk_about_dialog_credits(GtkWidget *button, gpointer data)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -59,8 +59,7 @@ nsgtk_about_dialog_licence(GtkWidget *button, gpointer data)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
diff --git a/gtk/dialogs/preferences.c b/gtk/dialogs/preferences.c
index 18c8d7b..a8ff674 100644
--- a/gtk/dialogs/preferences.c
+++ b/gtk/dialogs/preferences.c
@@ -19,12 +19,12 @@
#include <stdint.h>
#include <math.h>
-#include "desktop/browser_private.h"
-#include "utils/nsoption.h"
-#include "desktop/searchweb.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/messages.h"
+#include "desktop/browser.h"
+#include "utils/nsoption.h"
+#include "desktop/searchweb.h"
#include "gtk/compat.h"
#include "gtk/window.h"
@@ -893,13 +893,7 @@ ENTRY_SIGNALS(entryHomePageURL, homepage_url)
G_MODULE_EXPORT void
nsgtk_preferences_setCurrentPage_clicked(GtkButton *button, struct ppref *priv)
{
- const gchar *url;
-
- if (priv->bw != NULL) {
- url = nsurl_access(hlcache_handle_get_url(priv->bw->current_content));
- } else {
- url = "about:blank";
- }
+ const gchar *url = nsurl_access(browser_window_get_url(priv->bw));
if (priv->entryHomePageURL != NULL) {
gtk_entry_set_text(GTK_ENTRY(priv->entryHomePageURL), url);
diff --git a/gtk/dialogs/source.c b/gtk/dialogs/source.c
index a32bce6..326e3fb 100644
--- a/gtk/dialogs/source.c
+++ b/gtk/dialogs/source.c
@@ -16,35 +16,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdint.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <gtk/gtk.h>
-#include "desktop/browser_private.h"
-#include "desktop/netsurf.h"
-#include "desktop/print.h"
+#include "utils/log.h"
#include "utils/nsoption.h"
+#include "utils/utf8.h"
#include "utils/messages.h"
#include "utils/url.h"
#include "utils/utils.h"
-#include "utils/utf8.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser_private.h"
#include "render/html.h"
-#include "render/font.h"
+#include "content/hlcache.h"
#include "content/content.h"
-#include "content/content_type.h"
-#include "utils/log.h"
-#include "gtk/compat.h"
-#include "gtk/dialogs/source.h"
#include "gtk/dialogs/about.h"
-#include "gtk/window.h"
-#include "gtk/gui.h"
-#include "gtk/print.h"
-#include "gtk/selection.h"
#include "gtk/fetch.h"
+#include "gtk/compat.h"
+#include "gtk/gui.h"
+#include "gtk/dialogs/source.h"
struct nsgtk_source_window {
gchar *url;
@@ -207,8 +199,7 @@ void nsgtk_source_dialog_init(GtkWindow *parent, struct browser_window *bw)
return;
}
- thiswindow->url = strdup(nsurl_access(hlcache_handle_get_url(
- bw->current_content)));
+ thiswindow->url = strdup(nsurl_access(browser_window_get_url(bw)));
if (thiswindow->url == NULL) {
free(thiswindow);
free(data);
@@ -322,8 +313,7 @@ void nsgtk_source_tab_init(GtkWindow *parent, struct browser_window *bw)
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
} else {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_TAB,
url,
NULL,
bw,
diff --git a/gtk/download.c b/gtk/download.c
index 3d287d4..e49e66e 100644
--- a/gtk/download.c
+++ b/gtk/download.c
@@ -27,10 +27,12 @@
#include "utils/utils.h"
#include "utils/url.h"
#include "utils/messages.h"
+#include "utils/nsoption.h"
+#include "desktop/download.h"
#include "desktop/gui.h"
+
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
-#include "utils/nsoption.h"
#include "gtk/download.h"
#include "gtk/window.h"
#include "gtk/compat.h"
diff --git a/gtk/fetch.c b/gtk/fetch.c
index f4a42b5..8db102c 100644
--- a/gtk/fetch.c
+++ b/gtk/fetch.c
@@ -17,9 +17,12 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <ctype.h>
+#include <string.h>
#include "utils/hashtable.h"
#include "utils/url.h"
diff --git a/gtk/font_pango.c b/gtk/font_pango.c
index 6c7f159..b6569ce 100644
--- a/gtk/font_pango.c
+++ b/gtk/font_pango.c
@@ -27,8 +27,6 @@
#include <stdio.h>
#include <gtk/gtk.h>
-#include "css/css.h"
-#include "css/utils.h"
#include "gtk/font_pango.h"
#include "gtk/plotters.h"
#include "render/font.h"
diff --git a/gtk/gui.c b/gtk/gui.c
index c885ad3..fa16900 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -44,7 +44,7 @@
#include "content/fetchers/resource.h"
#include "content/hlcache.h"
#include "content/urldb.h"
-#include "desktop/browser_private.h"
+#include "desktop/browser.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
@@ -69,6 +69,7 @@
#include "gtk/window.h"
#include "gtk/schedule.h"
#include "gtk/selection.h"
+#include "gtk/search.h"
#include "render/form.h"
#include "utils/filepath.h"
@@ -462,8 +463,7 @@ static void gui_init(int argc, char** argv, char **respath)
/* create an initial browser window */
error = nsurl_create(addr, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -523,7 +523,7 @@ static bool nslog_stream_configure(FILE *fptr)
-static void gui_poll(bool active)
+static void nsgtk_poll(bool active)
{
CURLMcode code;
fd_set read_fd_set, write_fd_set, exc_fd_set;
@@ -611,8 +611,8 @@ static void gui_quit(void)
static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
gpointer user_data)
{
- form_select_process_selection(select_menu_bw->current_content,
- select_menu_control, (intptr_t)user_data);
+ form_select_process_selection(select_menu_control,
+ (intptr_t)user_data);
}
static void gui_create_form_select_menu(struct browser_window *bw,
@@ -788,37 +788,6 @@ gboolean nsgtk_ssl_delete_event(GtkWidget *w, GdkEvent *event, gpointer data)
return FALSE;
}
-nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
-{
- assert(string && result);
-
- if (len == 0)
- len = strlen(string);
-
- *result = strndup(string, len);
- if (!(*result))
- return NSERROR_NOMEM;
-
- return NSERROR_OK;
-}
-
-
-nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
-{
- assert(string && result);
-
- if (len == 0)
- len = strlen(string);
-
- *result = strndup(string, len);
- if (!(*result))
- return NSERROR_NOMEM;
-
- return NSERROR_OK;
-}
-
-
-
#ifdef WITH_PDF_EXPORT
void PDF_Password(char **owner_pass, char **user_pass, char *path)
@@ -1021,13 +990,9 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
}
-static struct gui_clipboard_table nsgtk_clipboard_table = {
- .get = gui_get_clipboard,
- .set = gui_set_clipboard,
-};
-
static struct gui_browser_table nsgtk_browser_table = {
- .poll = gui_poll,
+ .poll = nsgtk_poll,
+ .schedule = nsgtk_schedule,
.quit = gui_quit,
.set_search_ico = gui_set_search_ico,
@@ -1048,9 +1013,10 @@ int main(int argc, char** argv)
struct gui_table nsgtk_gui_table = {
.browser = &nsgtk_browser_table,
.window = nsgtk_window_table,
- .clipboard = &nsgtk_clipboard_table,
+ .clipboard = nsgtk_clipboard_table,
.download = nsgtk_download_table,
.fetch = nsgtk_fetch_table,
+ .search = nsgtk_search_table,
};
/* check home directory is available */
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 098d5e1..c5dd524 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -18,26 +18,21 @@
*/
#include <assert.h>
-#include <dirent.h>
#include <stdbool.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <errno.h>
-#include <unistd.h>
+#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include "gtk/scaffolding.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "css/utils.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "utils/log.h"
+#include "utils/nsoption.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/local_history.h"
#include "desktop/hotlist.h"
-#include "desktop/gui.h"
#include "desktop/netsurf.h"
-#include "utils/nsoption.h"
#include "desktop/plotters.h"
#include "desktop/print.h"
#include "desktop/save_complete.h"
@@ -46,44 +41,35 @@
#include "desktop/save_pdf/pdf_plotters.h"
#endif
#include "desktop/save_text.h"
-#include "desktop/search.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
-#include "desktop/tree.h"
+#include "render/font.h"
+#include "render/html.h"
+#include "content/hlcache.h"
+
+#include "gtk/compat.h"
#include "gtk/cookies.h"
#include "gtk/completion.h"
#include "gtk/dialogs/preferences.h"
#include "gtk/dialogs/about.h"
#include "gtk/dialogs/source.h"
#include "gtk/bitmap.h"
-#include "gtk/download.h"
#include "gtk/gui.h"
#include "gtk/history.h"
#include "gtk/hotlist.h"
+#include "gtk/download.h"
#include "gtk/menu.h"
#include "gtk/plotters.h"
#include "gtk/print.h"
-#include "gtk/schedule.h"
#include "gtk/search.h"
-#include "gtk/tabs.h"
#include "gtk/theme.h"
#include "gtk/throbber.h"
#include "gtk/toolbar.h"
-#include "gtk/treeview.h"
#include "gtk/window.h"
-#include "gtk/compat.h"
#include "gtk/gdk.h"
-#include "image/ico.h"
-#include "render/font.h"
-#include "render/form.h"
-#include "render/html.h"
-#include "utils/messages.h"
-#include "utils/schedule.h"
-#include "utils/utils.h"
-#include "utils/url.h"
-
-#include "utils/log.h"
-
+#include "gtk/scaffolding.h"
+#include "gtk/tabs.h"
+#include "gtk/schedule.h"
/** Macro to define a handler for menu, button and activate events. */
@@ -309,23 +295,19 @@ static void nsgtk_window_update_back_forward(struct gtk_scaffolding *g)
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
g->buttons[BACK_BUTTON]->sensitivity =
- history_back_available(bw->history);
- g->buttons[FORWARD_BUTTON]->sensitivity = history_forward_available(
- bw->history);
+ browser_window_history_back_available(bw);
+ g->buttons[FORWARD_BUTTON]->sensitivity =
+ browser_window_history_forward_available(bw);
nsgtk_scaffolding_set_sensitivity(g);
/* update the url bar, particularly necessary when tabbing */
- if (bw->current_content != NULL &&
- hlcache_handle_get_url(bw->current_content) != NULL)
- browser_window_refresh_url_bar(bw,
- hlcache_handle_get_url(bw->current_content),
- bw->frag_id);
+ browser_window_refresh_url_bar(bw);
/* update the local history window, as well as queuing a redraw
* for it.
*/
- history_size(bw->history, &width, &height);
+ browser_window_history_size(bw, &width, &height);
gtk_widget_set_size_request(GTK_WIDGET(g->history_window->drawing_area),
width, height);
gtk_widget_queue_draw(GTK_WIDGET(g->history_window->drawing_area));
@@ -346,7 +328,7 @@ static void nsgtk_throb(void *p)
gtk_image_set_from_pixbuf(g->throbber, nsgtk_throbber->framedata[
g->throb_frame]);
- schedule(10, nsgtk_throb, p);
+ nsgtk_schedule(100, nsgtk_throb, p);
}
static guint nsgtk_scaffolding_update_edit_actions_sensitivity(
@@ -451,14 +433,9 @@ gboolean nsgtk_window_url_activate_event(GtkWidget *widget, gpointer data)
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
} else {
- browser_window_navigate(bw,
- url,
- NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- NULL);
+ browser_window_navigate(bw, url, NULL,
+ BW_NAVIGATE_HISTORY, NULL,
+ NULL, NULL);
nsurl_unref(url);
}
free(urltxt);
@@ -567,8 +544,7 @@ static void nsgtk_openfile_open(const char *filename)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -595,7 +571,7 @@ MULTIHANDLER(newwindow)
error = nsurl_create(addr, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
bw,
@@ -628,8 +604,8 @@ nserror nsgtk_scaffolding_new_tab(struct gui_window *gw)
}
}
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_TAB,
+ error = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
url,
NULL,
bw,
@@ -684,8 +660,7 @@ static gboolean nsgtk_filter_directory(const GtkFileFilterInfo *info,
MULTIHANDLER(savepage)
{
- if (nsgtk_get_browser_window(g->top_level)->current_content
- == NULL)
+ if (!browser_window_has_content(nsgtk_get_browser_window(g->top_level)))
return FALSE;
GtkWidget *fc = gtk_file_chooser_dialog_new(
@@ -704,8 +679,8 @@ MULTIHANDLER(savepage)
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc), filter);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fc), filter);
- res = url_nice(nsurl_access(hlcache_handle_get_url(nsgtk_get_browser_window(
- g->top_level)->current_content)), &path, false);
+ res = url_nice(nsurl_access(browser_window_get_url(
+ nsgtk_get_browser_window(g->top_level))), &path, false);
if (res != URL_FUNC_OK) {
path = strdup(messages_get("SaveText"));
if (path == NULL) {
@@ -764,7 +739,7 @@ MULTIHANDLER(pdf)
LOG(("Print preview (generating PDF) started."));
- res = url_nice(nsurl_access(hlcache_handle_get_url(bw->current_content)),
+ res = url_nice(nsurl_access(browser_window_get_url(bw)),
&url_name, true);
if (res != URL_FUNC_OK) {
warn_user(messages_get(res == URL_FUNC_NOMEM ? "NoMemory"
@@ -826,8 +801,7 @@ MULTIHANDLER(pdf)
MULTIHANDLER(plaintext)
{
- if (nsgtk_get_browser_window(g->top_level)->current_content
- == NULL)
+ if (!browser_window_has_content(nsgtk_get_browser_window(g->top_level)))
return FALSE;
GtkWidget *fc = gtk_file_chooser_dialog_new(
@@ -839,8 +813,9 @@ MULTIHANDLER(plaintext)
char *filename;
url_func_result res;
- res = url_nice(nsurl_access(hlcache_handle_get_url(nsgtk_get_browser_window(
- g->top_level)->current_content)), &filename, false);
+ res = url_nice(nsurl_access(browser_window_get_url(
+ nsgtk_get_browser_window(g->top_level))),
+ &filename, false);
if (res != URL_FUNC_OK) {
filename = strdup(messages_get("SaveText"));
if (filename == NULL) {
@@ -977,8 +952,7 @@ MENUHANDLER(savelink)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -1004,12 +978,9 @@ MENUHANDLER(link_openwin)
error = nsurl_create(current_menu_ctx.link_url, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
- url,
- NULL,
- bw,
- NULL);
+ error = browser_window_create(
+ BW_CREATE_CLONE | BW_CREATE_HISTORY,
+ url, NULL, bw, NULL);
nsurl_unref(url);
}
if (error != NSERROR_OK) {
@@ -1037,13 +1008,9 @@ MENUHANDLER(link_opentab)
error = nsurl_create(current_menu_ctx.link_url, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_TAB,
- url,
- NULL,
- bw,
- NULL);
+ error = browser_window_create(BW_CREATE_CLONE |
+ BW_CREATE_HISTORY | BW_CREATE_TAB,
+ url, NULL, bw, NULL);
nsurl_unref(url);
}
if (error != NSERROR_OK) {
@@ -1418,9 +1385,6 @@ MULTIHANDLER(reload)
/* clear potential search effects */
browser_window_search_clear(bw);
- nsgtk_search_set_forward_state(true, bw);
- nsgtk_search_set_back_state(true, bw);
-
browser_window_reload(bw, true);
return TRUE;
@@ -1431,16 +1395,13 @@ MULTIHANDLER(back)
struct browser_window *bw =
nsgtk_get_browser_window(g->top_level);
- if ((bw == NULL) || (!history_back_available(bw->history)))
+ if ((bw == NULL) || (!browser_window_history_back_available(bw)))
return TRUE;
/* clear potential search effects */
browser_window_search_clear(bw);
- nsgtk_search_set_forward_state(true, bw);
- nsgtk_search_set_back_state(true, bw);
-
- history_back(bw, bw->history);
+ browser_window_history_back(bw, false);
nsgtk_window_update_back_forward(g);
return TRUE;
@@ -1451,16 +1412,13 @@ MULTIHANDLER(forward)
struct browser_window *bw =
nsgtk_get_browser_window(g->top_level);
- if ((bw == NULL) || (!history_forward_available(bw->history)))
+ if ((bw == NULL) || (!browser_window_history_forward_available(bw)))
return TRUE;
/* clear potential search effects */
browser_window_search_clear(bw);
- nsgtk_search_set_forward_state(true, bw);
- nsgtk_search_set_back_state(true, bw);
-
- history_forward(bw, bw->history);
+ browser_window_history_forward(bw, false);
nsgtk_window_update_back_forward(g);
return TRUE;
@@ -1484,8 +1442,7 @@ MULTIHANDLER(home)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1503,7 +1460,7 @@ MULTIHANDLER(localhistory)
/* if entries of the same url but different frag_ids have been added
* the history needs redrawing (what throbber code normally does)
*/
- history_size(bw->history, &width, &height);
+ browser_window_history_size(bw, &width, &height);
nsgtk_window_update_back_forward(g);
gtk_window_get_position(g->window, &x, &y);
gtk_window_get_size(g->window, &mainwidth, &mainheight);
@@ -1537,10 +1494,9 @@ MULTIHANDLER(addbookmarks)
{
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- if (bw == NULL || bw->current_content == NULL ||
- hlcache_handle_get_url(bw->current_content) == NULL)
+ if (bw == NULL || !browser_window_has_content(bw))
return TRUE;
- hotlist_add_url(hlcache_handle_get_url(bw->current_content));
+ hotlist_add_url(browser_window_get_url(bw));
return TRUE;
}
@@ -1602,8 +1558,7 @@ MULTIHANDLER(contents)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1624,8 +1579,7 @@ MULTIHANDLER(guide)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1646,8 +1600,7 @@ MULTIHANDLER(info)
browser_window_navigate(bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1707,7 +1660,7 @@ nsgtk_history_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data)
ctx.plot->clip(&clip);
- history_redraw(bw->history, &ctx);
+ browser_window_history_redraw(bw, &ctx);
current_widget = NULL;
@@ -1740,7 +1693,7 @@ nsgtk_history_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer g)
clip.y1 = event->area.y + event->area.height;
ctx.plot->clip(&clip);
- history_redraw(bw->history, &ctx);
+ browser_window_history_redraw(bw, &ctx);
cairo_destroy(current_cr);
@@ -1760,8 +1713,7 @@ static gboolean nsgtk_history_button_press_event(GtkWidget *widget,
LOG(("X=%g, Y=%g", event->x, event->y));
- history_click(bw, bw->history,
- event->x, event->y, false);
+ browser_window_history_click(bw, event->x, event->y, false);
return TRUE;
}
@@ -2213,7 +2165,7 @@ void gui_window_start_throbber(struct gui_window* _g)
nsgtk_window_update_back_forward(g);
- schedule(10, nsgtk_throb, g);
+ nsgtk_schedule(100, nsgtk_throb, g);
}
void gui_window_stop_throbber(struct gui_window* _g)
@@ -2222,7 +2174,7 @@ void gui_window_stop_throbber(struct gui_window* _g)
if (g == NULL)
return;
nsgtk_window_update_back_forward(g);
- schedule_remove(nsgtk_throb, g);
+ nsgtk_schedule(-1, nsgtk_throb, g);
if (g->buttons[STOP_BUTTON] != NULL)
g->buttons[STOP_BUTTON]->sensitivity = false;
if (g->buttons[RELOAD_BUTTON] != NULL)
@@ -2431,14 +2383,14 @@ void nsgtk_scaffolding_set_websearch(nsgtk_scaffolding *g, const char *content)
void nsgtk_scaffolding_toggle_search_bar_visibility(nsgtk_scaffolding *g)
{
gboolean vis;
- struct browser_window *bw =
- nsgtk_get_browser_window(g->top_level);
+ struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
+
g_object_get(G_OBJECT(g->search->bar), "visible", &vis, NULL);
if (vis) {
- if (bw != NULL)
+ if (bw != NULL) {
browser_window_search_clear(bw);
- nsgtk_search_set_forward_state(true, bw);
- nsgtk_search_set_back_state(true, bw);
+ }
+
gtk_widget_hide(GTK_WIDGET(g->search->bar));
} else {
gtk_widget_show(GTK_WIDGET(g->search->bar));
@@ -2475,9 +2427,6 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
/* clear effects of potential searches */
browser_window_search_clear(bw);
- nsgtk_search_set_forward_state(true, bw);
- nsgtk_search_set_back_state(true, bw);
-
nsgtk_scaffolding_set_icon(gw);
/* Ensure the window's title bar is updated */
@@ -2554,13 +2503,9 @@ void nsgtk_scaffolding_initial_sensitivity(struct gtk_scaffolding *g)
*/
static bool is_menu_over_link(struct gtk_scaffolding *g, gdouble x, gdouble y)
{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
-
- if ((bw->current_content != NULL) &&
- (content_get_type(bw->current_content) == CONTENT_HTML)) {
- browser_window_get_contextual_content(bw, x, y,
- ¤t_menu_ctx);
- }
+ browser_window_get_contextual_content(
+ nsgtk_get_browser_window(g->top_level),
+ x, y, ¤t_menu_ctx);
if (current_menu_ctx.link_url == NULL)
return false;
diff --git a/gtk/scaffolding.h b/gtk/scaffolding.h
index 43eb41b..285f9bb 100644
--- a/gtk/scaffolding.h
+++ b/gtk/scaffolding.h
@@ -19,15 +19,11 @@
#ifndef NETSURF_GTK_SCAFFOLDING_H
#define NETSURF_GTK_SCAFFOLDING_H 1
-#include <gtk/gtk.h>
-//#include <glade/glade.h>
-#include <glib.h>
-
-#include "desktop/gui.h"
-#include "desktop/plotters.h"
-#include "gtk/menu.h"
-#include "gtk/sexy_icon_entry.h"
+#include <stdbool.h>
+#include "utils/errors.h"
+struct hlcache_handle;
+struct gui_window;
typedef struct gtk_scaffolding nsgtk_scaffolding;
typedef enum {
@@ -182,6 +178,6 @@ void gui_window_set_title(struct gui_window *g, const char *title);
void 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);
-void gui_set_search_ico(hlcache_handle *ico);
+void gui_set_search_ico(struct hlcache_handle *ico);
#endif /* NETSURF_GTK_SCAFFOLDING_H */
diff --git a/gtk/schedule.c b/gtk/schedule.c
index 5b168b6..e28675a 100644
--- a/gtk/schedule.c
+++ b/gtk/schedule.c
@@ -20,7 +20,8 @@
#include <stdlib.h>
#include <stdbool.h>
-#include "utils/schedule.h"
+#include "utils/errors.h"
+
#include "gtk/schedule.h"
#ifdef DEBUG_GTK_SCHEDULE
@@ -71,7 +72,7 @@ nsgtk_schedule_kill_callback(void *_target, void *_match)
}
}
-void
+static void
schedule_remove(void (*callback)(void *p), void *p)
{
_nsgtk_callback_t cb_match = {
@@ -87,19 +88,27 @@ schedule_remove(void (*callback)(void *p), void *p)
nsgtk_schedule_kill_callback, &cb_match);
}
-void
-schedule(int t, void (*callback)(void *p), void *p)
+/* exported interface documented in gtk/schedule.h */
+nserror nsgtk_schedule(int t, void (*callback)(void *p), void *p)
{
- const int msec_timeout = t * 10;
- _nsgtk_callback_t *cb = malloc(sizeof(_nsgtk_callback_t));
+ _nsgtk_callback_t *cb;
+
/* Kill any pending schedule of this kind. */
schedule_remove(callback, p);
+
+ if (t < 0) {
+ return NSERROR_OK;
+ }
+
+ cb = malloc(sizeof(_nsgtk_callback_t));
cb->callback = callback;
cb->context = p;
cb->callback_killed = false;
/* Prepend is faster right now. */
queued_callbacks = g_list_prepend(queued_callbacks, cb);
- g_timeout_add(msec_timeout, nsgtk_schedule_generic_callback, cb);
+ g_timeout_add(t, nsgtk_schedule_generic_callback, cb);
+
+ return NSERROR_OK;
}
bool
diff --git a/gtk/schedule.h b/gtk/schedule.h
index c63215e..0a2d724 100644
--- a/gtk/schedule.h
+++ b/gtk/schedule.h
@@ -19,7 +19,8 @@
#ifndef NETSURF_GTK_CALLBACK_H
#define NETSURF_GTK_CALLBACK_H 1
-typedef void (*gtk_callback)(void *p);
+nserror nsgtk_schedule(int t, void (*callback)(void *p), void *p);
+
bool schedule_run(void);
#endif /* NETSURF_GTK_CALLBACK_H */
diff --git a/gtk/search.c b/gtk/search.c
index d4fbadc..44f9dde 100644
--- a/gtk/search.c
+++ b/gtk/search.c
@@ -25,14 +25,10 @@
#include <string.h>
#include <gdk/gdkkeysyms.h>
-#include "gtk/compat.h"
-#include "gtk/search.h"
-#include "gtk/scaffolding.h"
-#include "gtk/window.h"
#include "utils/config.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "desktop/browser_private.h"
+#include "desktop/browser.h"
#include "desktop/gui.h"
#include "desktop/search.h"
#include "desktop/searchweb.h"
@@ -40,25 +36,49 @@
#include "utils/messages.h"
#include "utils/utils.h"
-static void nsgtk_search_set_status(bool found, void *p);
-static void nsgtk_search_set_hourglass(bool active, void *p);
-static void nsgtk_search_add_recent(const char *string, void *p);
+#include "gtk/compat.h"
+#include "gtk/search.h"
+#include "gtk/scaffolding.h"
+#include "gtk/window.h"
-static struct gui_search_callbacks nsgtk_search_callbacks = {
- nsgtk_search_set_forward_state,
- nsgtk_search_set_back_state,
- nsgtk_search_set_status,
- nsgtk_search_set_hourglass,
- nsgtk_search_add_recent
-};
+/**
+ * activate search forwards button in gui.
+ *
+ * \param active activate/inactivate
+ * \param p the pointer sent to search_verify_new() / search_create_context()
+ */
+static void nsgtk_search_set_forward_state(bool active, struct gui_window *gw)
+{
+ if (gw != NULL && nsgtk_get_browser_window(gw) != NULL) {
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(gw);
+ gtk_widget_set_sensitive(
+ GTK_WIDGET(nsgtk_scaffolding_search(g)->buttons[1]),
+ active);
+ }
+}
+
+/**
+ * activate search back button in gui.
+ *
+ * \param active activate/inactivate
+ * \param p the pointer sent to search_verify_new() / search_create_context()
+ */
+static void nsgtk_search_set_back_state(bool active, struct gui_window *gw)
+{
+ if (gw != NULL && nsgtk_get_browser_window(gw) != NULL) {
+ struct gtk_scaffolding *g = nsgtk_get_scaffold(gw);
+ gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_search(
+ g)->buttons[0]), active);
+ }
+}
/** connected to the search forward button */
gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
{
struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
- struct browser_window *bw = nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(g));
+ struct gui_window *gw = nsgtk_scaffolding_top_level(g);
+ struct browser_window *bw = nsgtk_get_browser_window(gw);
assert(bw);
@@ -70,7 +90,7 @@ gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
nsgtk_scaffolding_search(g)->checkAll)) ?
SEARCH_FLAG_SHOWALL : 0);
- browser_window_search(bw, &nsgtk_search_callbacks, (void *)bw, flags,
+ browser_window_search(bw, gw, flags,
gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry));
return TRUE;
}
@@ -80,8 +100,8 @@ gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
{
struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
- struct browser_window *bw = nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(g));
+ struct gui_window *gw = nsgtk_scaffolding_top_level(g);
+ struct browser_window *bw = nsgtk_get_browser_window(gw);
assert(bw);
@@ -93,7 +113,7 @@ gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
nsgtk_scaffolding_search(g)->checkAll)) ?
SEARCH_FLAG_SHOWALL : 0);
- browser_window_search(bw, &nsgtk_search_callbacks, (void *)bw, flags,
+ browser_window_search(bw, gw, flags,
gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry));
return TRUE;
}
@@ -112,13 +132,13 @@ gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data)
gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
{
nsgtk_scaffolding *g = (nsgtk_scaffolding *)data;
- struct browser_window *bw = nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(g));
+ struct gui_window *gw = nsgtk_scaffolding_top_level(g);
+ struct browser_window *bw = nsgtk_get_browser_window(gw);
assert(bw != NULL);
- nsgtk_search_set_forward_state(true, (void *)bw);
- nsgtk_search_set_back_state(true, (void *)bw);
+ nsgtk_search_set_forward_state(true, gw);
+ nsgtk_search_set_back_state(true, gw);
search_flags_t flags = SEARCH_FLAG_FORWARDS |
(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
@@ -128,7 +148,7 @@ gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
nsgtk_scaffolding_search(g)->checkAll)) ?
SEARCH_FLAG_SHOWALL : 0);
- browser_window_search(bw, &nsgtk_search_callbacks, (void *)bw, flags,
+ browser_window_search(bw, gw, flags,
gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry));
return TRUE;
}
@@ -138,8 +158,8 @@ gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data)
{
nsgtk_scaffolding *g = (nsgtk_scaffolding *)data;
- struct browser_window *bw = nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(g));
+ struct gui_window *gw = nsgtk_scaffolding_top_level(g);
+ struct browser_window *bw = nsgtk_get_browser_window(gw);
assert(bw);
@@ -151,7 +171,7 @@ gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data)
nsgtk_scaffolding_search(g)->checkAll)) ?
SEARCH_FLAG_SHOWALL : 0);
- browser_window_search(bw, &nsgtk_search_callbacks, (void *)bw, flags,
+ browser_window_search(bw, gw, flags,
gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry));
return FALSE;
}
@@ -197,67 +217,11 @@ gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f,
return TRUE;
}
-/**
-* Change the displayed search status.
-* \param found search pattern matched in text
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-
-void nsgtk_search_set_status(bool found, void *p)
-{
-}
-
-/**
-* display hourglass while searching
-* \param active start/stop indicator
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-void nsgtk_search_set_hourglass(bool active, void *p)
-{
-}
-
-/**
-* add search string to recent searches list
-* front is at liberty how to implement the bare notification
-* should normally store a strdup() of the string;
-* core gives no guarantee of the integrity of the const char *
-* \param string search pattern
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-
-void nsgtk_search_add_recent(const char *string, void *p)
-{
-}
-
-/**
-* activate search forwards button in gui
-* \param active activate/inactivate
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-void nsgtk_search_set_forward_state(bool active, void *p)
-{
- struct browser_window *bw = (struct browser_window *)p;
- if ((bw != NULL) && (bw->window != NULL)) {
- struct gtk_scaffolding *g = nsgtk_get_scaffold(bw->window);
- gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_search(
- g)->buttons[1]), active);
- }
-}
-
-/**
-* activate search back button in gui
-* \param active activate/inactivate
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
+static struct gui_search_table search_table = {
+ .forward_state = (void *)nsgtk_search_set_forward_state,
+ .back_state = (void *)nsgtk_search_set_back_state,
+};
-void nsgtk_search_set_back_state(bool active, void *p)
-{
- struct browser_window *bw = (struct browser_window *)p;
- if ((bw != NULL) && (bw->window != NULL)) {
- struct gtk_scaffolding *g = nsgtk_get_scaffold(bw->window);
- gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_search(
- g)->buttons[0]), active);
- }
-}
+struct gui_search_table *nsgtk_search_table = &search_table;
diff --git a/gtk/search.h b/gtk/search.h
index 869a3cd..470ebb3 100644
--- a/gtk/search.h
+++ b/gtk/search.h
@@ -19,21 +19,18 @@
#ifndef _NETSURF_GTK_SEARCH_H_
#define _NETSURF_GTK_SEARCH_H_
-#include <gtk/gtk.h>
-#include "gtk/scaffolding.h"
+struct gui_search_table *nsgtk_search_table;
+
+struct gtk_scaffolding;
void nsgtk_search_bar_toggle_visibility(struct gtk_scaffolding * g);
gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data);
gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data);
-gboolean nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event,
- gpointer data);
+gboolean nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event, gpointer data);
gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data);
gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data);
gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data);
gboolean nsgtk_websearch_activate(GtkWidget *widget, gpointer data);
-gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f,
- gpointer data);
-void nsgtk_search_set_forward_state(bool active, void *p);
-void nsgtk_search_set_back_state(bool active, void *p);
+gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f, gpointer data);
#endif
diff --git a/gtk/selection.c b/gtk/selection.c
index 8bdc0f8..231e5fd 100644
--- a/gtk/selection.c
+++ b/gtk/selection.c
@@ -18,12 +18,12 @@
#include <string.h>
#include <gtk/gtk.h>
+#include <stdlib.h>
#include "utils/log.h"
-
-#include "desktop/gui.h"
#include "desktop/browser.h"
-#include "gtk/selection.h"
+#include "desktop/gui.h"
+
#include "gtk/window.h"
static GString *current_selection = NULL;
@@ -36,7 +36,7 @@ static GtkClipboard *clipboard;
* \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
* \param length Byte length of UTF-8 text in buffer
*/
-void gui_get_clipboard(char **buffer, size_t *length)
+static void gui_get_clipboard(char **buffer, size_t *length)
{
gchar *gtext;
@@ -72,7 +72,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
-void gui_set_clipboard(const char *buffer, size_t length,
+static void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles)
{
clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
@@ -88,3 +88,9 @@ void gui_set_clipboard(const char *buffer, size_t length,
gtk_clipboard_set_text(clipboard, current_selection->str, -1);
}
+static struct gui_clipboard_table clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+struct gui_clipboard_table *nsgtk_clipboard_table = &clipboard_table;
diff --git a/gtk/selection.h b/gtk/selection.h
index 0d3ec73..6463692 100644
--- a/gtk/selection.h
+++ b/gtk/selection.h
@@ -19,11 +19,6 @@
#ifndef GTK_SELECTION_H
#define GTK_SELECTION_H
-#include <gtk/gtk.h>
-#include "desktop/gui.h"
-
-void gui_get_clipboard(char **buffer, size_t *length);
-void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
-
+struct gui_clipboard_table *nsgtk_clipboard_table;
#endif
diff --git a/gtk/theme.c b/gtk/theme.c
index ff0144c..adc4341 100644
--- a/gtk/theme.c
+++ b/gtk/theme.c
@@ -22,21 +22,24 @@
#include <sys/stat.h>
#include <unistd.h>
+#include "utils/config.h"
+#include "utils/nsoption.h"
+#include "utils/container.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "desktop/browser.h"
#include "content/content.h"
#include "content/content_type.h"
#include "content/hlcache.h"
+
#include "gtk/compat.h"
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
#include "gtk/menu.h"
#include "gtk/theme.h"
#include "gtk/window.h"
-#include "utils/nsoption.h"
#include "gtk/dialogs/preferences.h"
-#include "utils/container.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
enum image_sets {
IMAGE_SET_MAIN_MENU = 0,
diff --git a/gtk/toolbar.c b/gtk/toolbar.c
index 8453f4e..d4a197b 100644
--- a/gtk/toolbar.c
+++ b/gtk/toolbar.c
@@ -18,7 +18,7 @@
#include <gtk/gtk.h>
-#include "desktop/browser_private.h"
+#include "desktop/browser.h"
#include "desktop/searchweb.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -421,21 +421,9 @@ void nsgtk_toolbar_close(nsgtk_scaffolding *g)
nsgtk_window_get_signalhandler(
nsgtk_scaffolding_top_level(list),
NSGTK_WINDOW_SIGNAL_REDRAW));
- if ((nsgtk_get_browser_window(nsgtk_scaffolding_top_level(
- list))->current_content != NULL) &&
- (hlcache_handle_get_url(nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(list))->
- current_content) != NULL))
- browser_window_refresh_url_bar(
- nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(list)),
- hlcache_handle_get_url(
- nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(list))->
- current_content),
- nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(list))->
- frag_id);
+ browser_window_refresh_url_bar(
+ nsgtk_get_browser_window(
+ nsgtk_scaffolding_top_level(list)));
if (list != g)
gtk_widget_set_sensitive(GTK_WIDGET(
diff --git a/gtk/treeview.c b/gtk/treeview.c
index 2a4732a..c99e9fd 100644
--- a/gtk/treeview.c
+++ b/gtk/treeview.c
@@ -35,12 +35,14 @@
#include "gtk/plotters.h"
#include "gtk/treeview.h"
#include "utils/log.h"
+#include "utils/utf8.h"
#include "utils/utils.h"
struct nsgtk_treeview {
GtkWindow *window;
GtkScrolledWindow *scrolled;
GtkDrawingArea *drawing_area;
+ GtkIMContext *input_method;
bool mouse_pressed;
int mouse_pressed_x;
int mouse_pressed_y;
@@ -52,6 +54,7 @@ struct nsgtk_treeview {
void nsgtk_treeview_destroy(struct nsgtk_treeview *tv)
{
tree_delete(tv->tree);
+ g_object_unref(tv->input_method);
gtk_widget_destroy(GTK_WIDGET(tv->window));
free(tv);
}
@@ -206,12 +209,14 @@ void nsgtk_tree_window_hide(GtkWidget *widget, gpointer g)
{
}
-gboolean nsgtk_tree_window_button_press_event(GtkWidget *widget,
+static gboolean
+nsgtk_tree_window_button_press_event(GtkWidget *widget,
GdkEventButton *event, gpointer g)
{
struct nsgtk_treeview *tw = g;
struct tree *tree = tw->tree;
+ gtk_im_context_reset(tw->input_method);
gtk_widget_grab_focus(GTK_WIDGET(tw->drawing_area));
tw->mouse_pressed = true;
@@ -243,7 +248,8 @@ gboolean nsgtk_tree_window_button_press_event(GtkWidget *widget,
return TRUE;
}
-gboolean nsgtk_tree_window_button_release_event(GtkWidget *widget,
+static gboolean
+nsgtk_tree_window_button_release_event(GtkWidget *widget,
GdkEventButton *event, gpointer g)
{
bool shift = event->state & GDK_SHIFT_MASK;
@@ -307,7 +313,8 @@ gboolean nsgtk_tree_window_button_release_event(GtkWidget *widget,
return TRUE;
}
-gboolean nsgtk_tree_window_motion_notify_event(GtkWidget *widget,
+static gboolean
+nsgtk_tree_window_motion_notify_event(GtkWidget *widget,
GdkEventMotion *event, gpointer g)
{
bool shift = event->state & GDK_SHIFT_MASK;
@@ -369,7 +376,8 @@ gboolean nsgtk_tree_window_motion_notify_event(GtkWidget *widget,
}
-gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
+static gboolean
+nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
gpointer g)
{
struct nsgtk_treeview *tw = (struct nsgtk_treeview *) g;
@@ -381,6 +389,9 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
GtkAdjustment *scroll = NULL;
gdouble hpage, vpage;
+ if (gtk_im_context_filter_keypress(tw->input_method, event))
+ return TRUE;
+
nskey = gtk_gui_gdkkey_to_nskey(event);
if (tree_keypress(tree, nskey) == true)
@@ -473,6 +484,32 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
return TRUE;
}
+static gboolean
+nsgtk_tree_window_keyrelease_event(GtkWidget *widget, GdkEventKey *event,
+ gpointer g)
+{
+ struct nsgtk_treeview *tw = (struct nsgtk_treeview *) g;
+
+ return gtk_im_context_filter_keypress(tw->input_method, event);
+}
+
+static void
+nsgtk_tree_window_input_method_commit(GtkIMContext *ctx,
+ const gchar *str, gpointer data)
+{
+ struct nsgtk_treeview *tw = (struct nsgtk_treeview *) data;
+ size_t len = strlen(str), offset = 0;
+
+ while (offset < len) {
+ uint32_t nskey = utf8_to_ucs4(str + offset, len - offset);
+
+ tree_keypress(tw->tree, nskey);
+
+ offset = utf8_next(str, len, offset);
+ }
+}
+
+
static const struct treeview_table nsgtk_tree_callbacks = {
.redraw_request = nsgtk_tree_redraw_request,
.resized = nsgtk_tree_resized,
@@ -498,6 +535,7 @@ struct nsgtk_treeview *nsgtk_treeview_create(unsigned int flags,
tv->window = window;
tv->scrolled = scrolled;
tv->drawing_area = drawing_area;
+ tv->input_method = gtk_im_multicontext_new();
tv->tree = tree_create(flags, &nsgtk_tree_callbacks, tv);
tv->mouse_state = 0;
tv->mouse_pressed = false;
@@ -510,17 +548,31 @@ struct nsgtk_treeview *nsgtk_treeview_create(unsigned int flags,
#define CONNECT(obj, sig, callback, ptr) \
g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
- CONNECT(drawing_area, "button_press_event",
+ CONNECT(drawing_area, "button-press-event",
nsgtk_tree_window_button_press_event,
tv);
- CONNECT(drawing_area, "button_release_event",
+ CONNECT(drawing_area, "button-release-event",
nsgtk_tree_window_button_release_event,
tv);
- CONNECT(drawing_area, "motion_notify_event",
+ CONNECT(drawing_area, "motion-notify-event",
nsgtk_tree_window_motion_notify_event,
tv);
- CONNECT(drawing_area, "key_press_event",
+ CONNECT(drawing_area, "key-press-event",
nsgtk_tree_window_keypress_event,
tv);
+ CONNECT(drawing_area, "key-release-event",
+ nsgtk_tree_window_keyrelease_event,
+ tv);
+
+
+ /* input method */
+ gtk_im_context_set_client_window(tv->input_method,
+ nsgtk_widget_get_window(GTK_WIDGET(tv->window)));
+ gtk_im_context_set_use_preedit(tv->input_method, FALSE);
+ /* input method signals */
+ CONNECT(tv->input_method, "commit",
+ nsgtk_tree_window_input_method_commit,
+ tv);
+
return tv;
}
diff --git a/gtk/treeview.h b/gtk/treeview.h
index 12eb180..ad8180f 100644
--- a/gtk/treeview.h
+++ b/gtk/treeview.h
@@ -24,8 +24,6 @@
#ifndef __NSGTK_TREEVIEW_H__
#define __NSGTK_TREEVIEW_H__
-#include "desktop/browser.h"
-
struct nsgtk_treeview;
struct nsgtk_treeview *nsgtk_treeview_create(unsigned int flags,
@@ -35,16 +33,6 @@ void nsgtk_treeview_destroy(struct nsgtk_treeview *tv);
struct tree *nsgtk_treeview_get_tree(struct nsgtk_treeview *tv);
-gboolean nsgtk_tree_window_expose_event(GtkWidget *, GdkEventExpose *,
- gpointer g);
void nsgtk_tree_window_hide(GtkWidget *widget, gpointer g);
-gboolean nsgtk_tree_window_button_press_event(GtkWidget *widget,
- GdkEventButton *event, gpointer g);
-gboolean nsgtk_tree_window_button_release_event(GtkWidget *widget,
- GdkEventButton *event, gpointer g);
-gboolean nsgtk_tree_window_motion_notify_event(GtkWidget *widget,
- GdkEventMotion *event, gpointer g);
-gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
- gpointer g);
#endif /*__NSGTK_TREEVIEW_H__*/
diff --git a/gtk/window.c b/gtk/window.c
index 0ba3c50..a3d6d49 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -26,14 +26,19 @@
#include <gdk/gdkkeysyms.h>
#include <gdk-pixbuf/gdk-pixdata.h>
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
+#include "utils/nsoption.h"
#include "content/hlcache.h"
#include "gtk/window.h"
#include "gtk/selection.h"
+#include "desktop/gui.h"
#include "desktop/browser_private.h"
#include "desktop/mouse.h"
-#include "utils/nsoption.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
+
#include "gtk/compat.h"
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
@@ -42,8 +47,6 @@
#include "gtk/tabs.h"
#include "gtk/bitmap.h"
#include "gtk/gdk.h"
-#include "utils/log.h"
-#include "utils/utils.h"
/* helper macro to conenct signals to callbacks */
#define CONNECT(obj, sig, callback, ptr) \
@@ -103,6 +106,9 @@ struct gui_window {
/** The icon this window should have */
GdkPixbuf *icon;
+ /** The input method to use with this window */
+ GtkIMContext *input_method;
+
/** list for cleanup */
struct gui_window *next, *prev;
};
@@ -153,7 +159,7 @@ struct gui_window *nsgtk_window_iterate(struct gui_window *g)
float nsgtk_get_scale_for_gui(struct gui_window *g)
{
- return g->bw->scale;
+ return browser_window_get_scale(g->bw);
}
#if GTK_CHECK_VERSION(3,0,0)
@@ -302,7 +308,8 @@ static gboolean nsgtk_window_motion_notify_event(GtkWidget *widget,
g->mouse.state ^= BROWSER_MOUSE_MOD_2;
browser_window_mouse_track(g->bw, g->mouse.state,
- event->x / g->bw->scale, event->y / g->bw->scale);
+ event->x / browser_window_get_scale(g->bw),
+ event->y / browser_window_get_scale(g->bw));
return TRUE;
}
@@ -312,12 +319,13 @@ static gboolean nsgtk_window_button_press_event(GtkWidget *widget,
{
struct gui_window *g = data;
+ gtk_im_context_reset(g->input_method);
gtk_widget_grab_focus(GTK_WIDGET(g->layout));
gtk_widget_hide(GTK_WIDGET(nsgtk_scaffolding_history_window(
g->scaffold)->window));
- g->mouse.pressed_x = event->x / g->bw->scale;
- g->mouse.pressed_y = event->y / g->bw->scale;
+ g->mouse.pressed_x = event->x / browser_window_get_scale(g->bw);
+ g->mouse.pressed_y = event->y / browser_window_get_scale(g->bw);
switch (event->button) {
case 1: /* Left button, usually. Pass to core as BUTTON 1. */
@@ -383,11 +391,12 @@ static gboolean nsgtk_window_button_release_event(GtkWidget *widget,
if (g->mouse.state & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) {
browser_window_mouse_click(g->bw, g->mouse.state,
- event->x / g->bw->scale,
- event->y / g->bw->scale);
+ event->x / browser_window_get_scale(g->bw),
+ event->y / browser_window_get_scale(g->bw));
} else {
- browser_window_mouse_track(g->bw, 0, event->x / g->bw->scale,
- event->y / g->bw->scale);
+ browser_window_mouse_track(g->bw, 0,
+ event->x / browser_window_get_scale(g->bw),
+ event->y / browser_window_get_scale(g->bw));
}
g->mouse.state = 0;
@@ -438,9 +447,9 @@ nsgtk_window_scroll_event(GtkWidget *widget,
deltay *= nsgtk_adjustment_get_step_increment(vscroll);
if (browser_window_scroll_at_point(g->bw,
- event->x / g->bw->scale,
- event->y / g->bw->scale,
- deltax, deltay) != true) {
+ event->x / browser_window_get_scale(g->bw),
+ event->y / browser_window_get_scale(g->bw),
+ deltax, deltay) != true) {
/* core did not handle event so change adjustments */
@@ -486,7 +495,12 @@ static gboolean nsgtk_window_keypress_event(GtkWidget *widget,
GdkEventKey *event, gpointer data)
{
struct gui_window *g = data;
- uint32_t nskey = gtk_gui_gdkkey_to_nskey(event);
+ uint32_t nskey;
+
+ if (gtk_im_context_filter_keypress(g->input_method, event))
+ return TRUE;
+
+ nskey = gtk_gui_gdkkey_to_nskey(event);
if (browser_window_key_press(g->bw, nskey))
return TRUE;
@@ -594,6 +608,31 @@ static gboolean nsgtk_window_keypress_event(GtkWidget *widget,
return TRUE;
}
+static gboolean nsgtk_window_keyrelease_event(GtkWidget *widget,
+ GdkEventKey *event, gpointer data)
+{
+ struct gui_window *g = data;
+
+ return gtk_im_context_filter_keypress(g->input_method, event);
+}
+
+
+static void nsgtk_window_input_method_commit(GtkIMContext *ctx,
+ const gchar *str, gpointer data)
+{
+ struct gui_window *g = data;
+ size_t len = strlen(str), offset = 0;
+
+ while (offset < len) {
+ uint32_t nskey = utf8_to_ucs4(str + offset, len - offset);
+
+ browser_window_key_press(g->bw, nskey);
+
+ offset = utf8_next(str, len, offset);
+ }
+}
+
+
static gboolean nsgtk_window_size_allocate_event(GtkWidget *widget,
GtkAllocation *allocation, gpointer data)
{
@@ -654,13 +693,15 @@ static void window_destroy(GtkWidget *widget, gpointer data)
struct gui_window *gw = data;
browser_window_destroy(gw->bw);
+
+ g_object_unref(gw->input_method);
}
/* Core interface documented in desktop/gui.h to create a gui_window */
static struct gui_window *
gui_window_create(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
struct gui_window *g; /**< what we're creating to return */
GError* error = NULL;
@@ -689,16 +730,17 @@ gui_window_create(struct browser_window *bw,
g->bw = bw;
g->mouse.state = 0;
g->current_pointer = GUI_POINTER_DEFAULT;
- if (clone != NULL) {
- bw->scale = clone->scale;
+ if (flags & GW_CREATE_CLONE) {
+ assert(existing != NULL);
+ bw->scale = existing->bw->scale;
} else {
- bw->scale = (float) nsoption_int(scale) / 100.0;
+ bw->scale = nsoption_int(scale) / 100;
}
/* attach scaffold */
- if (new_tab) {
- assert(clone != NULL);
- g->scaffold = clone->window->scaffold;
+ if (flags & GW_CREATE_TAB) {
+ assert(existing != NULL);
+ g->scaffold = existing->scaffold;
} else {
/* Now construct and attach a scaffold */
g->scaffold = nsgtk_new_scaffolding(g);
@@ -715,6 +757,7 @@ gui_window_create(struct browser_window *bw,
g->layout = GTK_LAYOUT(gtk_builder_get_object(xml, "layout"));
g->status_bar = GTK_LABEL(gtk_builder_get_object(xml, "status_bar"));
g->paned = GTK_PANED(gtk_builder_get_object(xml, "hpaned1"));
+ g->input_method = gtk_im_multicontext_new();
/* add new gui window to global list (push_top) */
@@ -758,6 +801,8 @@ gui_window_create(struct browser_window *bw,
nsgtk_window_button_release_event, g);
CONNECT(g->layout, "key-press-event",
nsgtk_window_keypress_event, g);
+ CONNECT(g->layout, "key-release-event",
+ nsgtk_window_keyrelease_event, g);
CONNECT(g->layout, "size-allocate",
nsgtk_window_size_allocate_event, g);
CONNECT(g->layout, "scroll-event",
@@ -774,6 +819,14 @@ gui_window_create(struct browser_window *bw,
CONNECT(g->container, "destroy",
window_destroy, g);
+ /* input method */
+ gtk_im_context_set_client_window(g->input_method,
+ nsgtk_layout_get_bin_window(g->layout));
+ gtk_im_context_set_use_preedit(g->input_method, FALSE);
+ /* input method signals */
+ CONNECT(g->input_method, "commit",
+ nsgtk_window_input_method_commit, g);
+
/* add the tab container to the scaffold notebook */
switch (temp_open_background) {
case -1:
@@ -942,18 +995,19 @@ static void gui_window_redraw_window(struct gui_window *g)
static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
{
int sx, sy;
- hlcache_handle *c = g->bw->current_content;
+ float scale;
- if (c == NULL)
+ if (!browser_window_has_content(g->bw))
return;
gui_window_get_scroll(g, &sx, &sy);
+ scale = browser_window_get_scale(g->bw);
gtk_widget_queue_draw_area(GTK_WIDGET(g->layout),
- rect->x0 * g->bw->scale - sx,
- rect->y0 * g->bw->scale - sy,
- (rect->x1 - rect->x0) * g->bw->scale,
- (rect->y1 - rect->y0) * g->bw->scale);
+ rect->x0 * scale - sx,
+ rect->y0 * scale - sy,
+ (rect->x1 - rect->x0) * scale,
+ (rect->y1 - rect->y0) * scale);
}
static void gui_window_set_status(struct gui_window *g, const char *text)
@@ -991,12 +1045,11 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
static void gui_window_update_extent(struct gui_window *g)
{
- if (!g->bw->current_content)
- return;
+ int w, h;
- gtk_layout_set_size(g->layout,
- content_get_width(g->bw->current_content) * g->bw->scale,
- content_get_height(g->bw->current_content) * g->bw->scale);
+ if (browser_window_get_extents(g->bw, true, &w, &h) == NSERROR_OK) {
+ gtk_layout_set_size(g->layout, w, h);
+ }
}
static GdkCursor *nsgtk_create_menu_cursor(void)
@@ -1101,9 +1154,21 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
{
nsgtk_redraw_caret(g);
+ y += 1;
+ height -= 1;
+
+ if (y < clip->y0) {
+ height -= clip->y0 - y;
+ y = clip->y0;
+ }
+
+ if (y + height > clip->y1) {
+ height = clip->y1 - y + 1;
+ }
+
g->caretx = x;
- g->carety = y + 1;
- g->careth = height - 2;
+ g->carety = y;
+ g->careth = height;
nsgtk_redraw_caret(g);
@@ -1123,8 +1188,9 @@ static void gui_window_get_dimensions(struct gui_window *g, int *width, int *hei
*height = alloc.height;
if (scaled) {
- *width /= g->bw->scale;
- *height /= g->bw->scale;
+ float scale = browser_window_get_scale(g->bw);
+ *width /= scale;
+ *height /= scale;
}
LOG(("width: %i", *width));
LOG(("height: %i", *height));
diff --git a/gtk/window.h b/gtk/window.h
index e242b6e..e4a4fda 100644
--- a/gtk/window.h
+++ b/gtk/window.h
@@ -19,8 +19,6 @@
#ifndef NETSURF_GTK_WINDOW_H
#define NETSURF_GTK_WINDOW_H 1
-#include "desktop/gui.h"
-#include "desktop/browser.h"
#include "gtk/scaffolding.h"
extern struct gui_window_table *nsgtk_window_table;
diff --git a/image/gif.c b/image/gif.c
index 4bd45c7..5c1b3ab 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -39,14 +39,15 @@
#include "content/hlcache.h"
#include "utils/nsoption.h"
#include "desktop/plotters.h"
-#include "image/image.h"
-#include "image/bitmap.h"
-#include "image/gif.h"
+#include "desktop/gui_factory.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/schedule.h"
#include "utils/utils.h"
+#include "image/image.h"
+#include "image/bitmap.h"
+#include "image/gif.h"
+
typedef struct nsgif_content {
struct content base;
@@ -159,7 +160,7 @@ static void nsgif_animate(void *p)
delay = gif->gif->frames[gif->current_frame].frame_delay;
if (delay < nsoption_int(minimum_gif_delay))
delay = nsoption_int(minimum_gif_delay);
- schedule(delay, nsgif_animate, gif);
+ guit->browser->schedule(delay * 10, nsgif_animate, gif);
}
if ((!nsoption_bool(animate_images)) ||
@@ -292,7 +293,9 @@ static bool nsgif_convert(struct content *c)
/* Schedule the animation if we have one */
gif->current_frame = 0;
if (gif->gif->frame_count_partial > 1)
- schedule(gif->gif->frames[0].frame_delay, nsgif_animate, c);
+ guit->browser->schedule(gif->gif->frames[0].frame_delay * 10,
+ nsgif_animate,
+ c);
/* Exit as a success */
content_set_ready(c);
@@ -351,7 +354,7 @@ static void nsgif_destroy(struct content *c)
nsgif_content *gif = (nsgif_content *) c;
/* Free all the associated memory buffers */
- schedule_remove(nsgif_animate, c);
+ guit->browser->schedule(-1, nsgif_animate, c);
gif_finalise(gif->gif);
free(gif->gif);
}
diff --git a/image/image_cache.c b/image/image_cache.c
index c136908..0512439 100644
--- a/image/image_cache.c
+++ b/image/image_cache.c
@@ -22,7 +22,7 @@
#include <stdbool.h>
#include <string.h>
-#include "utils/schedule.h"
+#include "desktop/gui_factory.h"
#include "utils/log.h"
#include "content/content_protected.h"
@@ -290,9 +290,9 @@ static void image_cache__background_update(void *p)
image_cache__clean(icache);
- schedule((icache->params.bg_clean_time / 10),
- image_cache__background_update,
- icache);
+ guit->browser->schedule(icache->params.bg_clean_time,
+ image_cache__background_update,
+ icache);
}
/* exported interface documented in image_cache.h */
@@ -372,9 +372,9 @@ image_cache_init(const struct image_cache_parameters *image_cache_parameters)
image_cache->params = *image_cache_parameters;
- schedule((image_cache->params.bg_clean_time / 10),
- image_cache__background_update,
- image_cache);
+ guit->browser->schedule(image_cache->params.bg_clean_time,
+ image_cache__background_update,
+ image_cache);
LOG(("Image cache initilised with a limit of %d hysteresis of %d",
image_cache->params.limit, image_cache->params.hysteresis));
@@ -387,7 +387,7 @@ nserror image_cache_fini(void)
{
unsigned int op_count;
- schedule_remove(image_cache__background_update, image_cache);
+ guit->browser->schedule(-1, image_cache__background_update, image_cache);
LOG(("Size at finish %d (in %d)",
image_cache->total_bitmap_size,
diff --git a/javascript/jsapi/location.bnd b/javascript/jsapi/location.bnd
index af76836..f64f633 100644
--- a/javascript/jsapi/location.bnd
+++ b/javascript/jsapi/location.bnd
@@ -62,8 +62,7 @@ operation assign %{
browser_window_navigate(bw,
joined,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -84,7 +83,7 @@ operation replace %{
browser_window_navigate(bw,
joined,
NULL,
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_NONE,
NULL,
NULL,
NULL);
@@ -129,7 +128,7 @@ setter href %{
browser_window_navigate(bw,
joined,
NULL,
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_NONE,
NULL,
NULL,
NULL);
diff --git a/monkey/Makefile.defaults b/monkey/Makefile.defaults
index 659c1e3..bbe4c6c 100644
--- a/monkey/Makefile.defaults
+++ b/monkey/Makefile.defaults
@@ -2,12 +2,13 @@
# Monkey-specific options
# ----------------------------------------------------------------------------
- # How did I get mixed up with this fucking monkey anyhow?
- NETSURF_MONKEY_RESOURCES := $(PREFIX)/share/netsurf/
- NETSURF_MONKEY_BIN := $(PREFIX)/bin/
- NETSURF_USE_RSVG := NO
- NETSURF_USE_NSSVG := NO
- NETSURF_USE_ROSPRITE := NO
- NETSURF_USE_HARU_PDF := NO
- NETSURF_USE_LIBICONV_PLUG := NO
- CFLAGS += -O2
+# How did I get mixed up with this fucking monkey anyhow?
+NETSURF_MONKEY_RESOURCES := $(PREFIX)/share/netsurf/
+NETSURF_MONKEY_BIN := $(PREFIX)/bin/
+NETSURF_USE_RSVG := NO
+NETSURF_USE_NSSVG := NO
+NETSURF_USE_ROSPRITE := NO
+NETSURF_USE_HARU_PDF := NO
+NETSURF_USE_LIBICONV_PLUG := NO
+
+CFLAGS += -O2
diff --git a/monkey/browser.c b/monkey/browser.c
index 85e25d9..e61d6de 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -89,8 +89,8 @@ monkey_kill_browser_windows(void)
static struct gui_window *
gui_window_create(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
struct gui_window *ret = calloc(sizeof(*ret), 1);
if (ret == NULL)
@@ -102,8 +102,9 @@ gui_window_create(struct browser_window *bw,
ret->width = 800;
ret->height = 600;
- fprintf(stdout, "WINDOW NEW WIN %u FOR %p CLONE %p NEWTAB %s\n",
- ret->win_num, bw, clone, new_tab ? "TRUE" : "FALSE");
+ fprintf(stdout, "WINDOW NEW WIN %u FOR %p EXISTING %p NEWTAB %s CLONE %s\n",
+ ret->win_num, bw, existing, flags & GW_CREATE_TAB ? "TRUE" : "FALSE",
+ flags & GW_CREATE_CLONE ? "TRUE" : "FALSE");
fprintf(stdout, "WINDOW SIZE WIN %u WIDTH %d HEIGHT %d\n",
ret->win_num, ret->width, ret->height);
@@ -349,8 +350,7 @@ monkey_window_handle_new(int argc, char **argv)
error = nsurl_create(argv[2], &url);
}
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -409,8 +409,7 @@ monkey_window_handle_go(int argc, char **argv)
browser_window_navigate(gw->bw,
url,
ref_url,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
diff --git a/monkey/cert.c b/monkey/cert.c
index 48359e8..6f21727 100644
--- a/monkey/cert.c
+++ b/monkey/cert.c
@@ -19,8 +19,9 @@
#include <stdlib.h>
#include <stdio.h>
-#include "desktop/gui.h"
#include "utils/ring.h"
+#include "utils/nsurl.h"
+#include "desktop/gui.h"
#include "monkey/cert.h"
diff --git a/monkey/download.c b/monkey/download.c
index d2e3b4b..721f77d 100644
--- a/monkey/download.c
+++ b/monkey/download.c
@@ -16,11 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/browser.h"
-#include "monkey/browser.h"
+#include <stdio.h>
+
+#include "desktop/gui.h"
+#include "desktop/download.h"
#include "utils/ring.h"
-#include <stdio.h>
+#include "monkey/browser.h"
static uint32_t dwin_ctr = 0;
diff --git a/monkey/main.c b/monkey/main.c
index 07ce7ee..96476d2 100644
--- a/monkey/main.c
+++ b/monkey/main.c
@@ -21,14 +21,6 @@
#include <stdlib.h>
#include "utils/nsoption.h"
-#include "monkey/poll.h"
-#include "monkey/dispatch.h"
-#include "monkey/browser.h"
-#include "monkey/cert.h"
-#include "monkey/401login.h"
-#include "monkey/filetype.h"
-#include "monkey/fetch.h"
-
#include "content/urldb.h"
#include "content/fetchers/resource.h"
#include "desktop/gui.h"
@@ -37,6 +29,15 @@
#include "utils/filepath.h"
#include "utils/url.h"
+#include "monkey/poll.h"
+#include "monkey/dispatch.h"
+#include "monkey/browser.h"
+#include "monkey/cert.h"
+#include "monkey/401login.h"
+#include "monkey/filetype.h"
+#include "monkey/fetch.h"
+#include "monkey/schedule.h"
+
char **respaths; /** resource search path vector */
/* Stolen from gtk/gui.c */
@@ -103,6 +104,7 @@ static bool nslog_stream_configure(FILE *fptr)
static struct gui_browser_table monkey_browser_table = {
.poll = monkey_poll,
+ .schedule = monkey_schedule,
.quit = monkey_quit,
.launch_url = gui_launch_url,
diff --git a/monkey/schedule.c b/monkey/schedule.c
index dd78933..e8ec1c6 100644
--- a/monkey/schedule.c
+++ b/monkey/schedule.c
@@ -20,8 +20,9 @@
#include <stdlib.h>
#include <stdbool.h>
-#include "utils/schedule.h"
-#include "gtk/schedule.h"
+#include "utils/errors.h"
+
+#include "monkey/schedule.h"
#undef DEBUG_MONKEY_SCHEDULE
@@ -74,7 +75,7 @@ nsgtk_schedule_kill_callback(void *_target, void *_match)
}
}
-void
+static void
schedule_remove(void (*callback)(void *p), void *p)
{
_nsgtk_callback_t cb_match = {
@@ -90,20 +91,27 @@ schedule_remove(void (*callback)(void *p), void *p)
nsgtk_schedule_kill_callback, &cb_match);
}
-void
-schedule(int t, void (*callback)(void *p), void *p)
+nserror monkey_schedule(int t, void (*callback)(void *p), void *p)
{
- const int msec_timeout = t * 10;
- _nsgtk_callback_t *cb = malloc(sizeof(_nsgtk_callback_t));
+ _nsgtk_callback_t *cb;
+
/* Kill any pending schedule of this kind. */
schedule_remove(callback, p);
+ if (t < 0) {
+ return NSERROR_OK;
+ }
+
+ cb = malloc(sizeof(_nsgtk_callback_t));
cb->callback = callback;
cb->context = p;
cb->callback_killed = false;
/* Prepend is faster right now. */
- LOG(("queued a callback to %p(%p) for %d msecs time", callback, p, msec_timeout));
+ LOG(("queued a callback to %p(%p) for %d msecs time", callback, p, t));
queued_callbacks = g_list_prepend(queued_callbacks, cb);
- g_timeout_add(msec_timeout, nsgtk_schedule_generic_callback, cb);
+ g_timeout_add(t, nsgtk_schedule_generic_callback, cb);
+
+ return NSERROR_OK;
+
}
bool
diff --git a/monkey/schedule.h b/monkey/schedule.h
index c63215e..44ef9bf 100644
--- a/monkey/schedule.h
+++ b/monkey/schedule.h
@@ -19,7 +19,8 @@
#ifndef NETSURF_GTK_CALLBACK_H
#define NETSURF_GTK_CALLBACK_H 1
-typedef void (*gtk_callback)(void *p);
+nserror monkey_schedule(int t, void (*callback)(void *p), void *p);
+
bool schedule_run(void);
#endif /* NETSURF_GTK_CALLBACK_H */
diff --git a/monkey/utils.c b/monkey/utils.c
index 742c300..e1a702f 100644
--- a/monkey/utils.c
+++ b/monkey/utils.c
@@ -22,10 +22,6 @@
#include "utils/config.h"
#include "utils/utils.h"
-#include "utils/url.h"
-#include "utils/utf8.h"
-
-
void warn_user(const char *warning, const char *detail)
{
@@ -37,17 +33,3 @@ void die(const char * const error)
fprintf(stderr, "DIE %s\n", error);
exit(EXIT_FAILURE);
}
-
-nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
-{
- *result = strndup(string, len);
- return (*result == NULL) ? NSERROR_NOMEM : NSERROR_OK;
-}
-
-nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
-{
- *result = strndup(string, len);
- return (*result == NULL) ? NSERROR_NOMEM : NSERROR_OK;
-}
-
-
diff --git a/render/box_construct.c b/render/box_construct.c
index ce21b70..6991025 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -31,25 +31,27 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
+
#include "utils/config.h"
#include "content/content_protected.h"
#include "css/css.h"
#include "css/utils.h"
#include "css/select.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
-#include "render/box.h"
-#include "render/box_textarea.h"
-#include "render/form.h"
-#include "render/html_internal.h"
#include "utils/corestrings.h"
#include "utils/locale.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/schedule.h"
#include "utils/talloc.h"
#include "utils/url.h"
#include "utils/utils.h"
+#include "render/box.h"
+#include "render/box_textarea.h"
+#include "render/form.h"
+#include "render/html_internal.h"
+
/**
* Context for box tree construction
*/
@@ -183,9 +185,7 @@ nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
ctx->cb = cb;
ctx->bctx = c->bctx;
- schedule(0, (schedule_callback_fn) convert_xml_to_box, ctx);
-
- return NSERROR_OK;
+ return guit->browser->schedule(0, (void *)convert_xml_to_box, ctx);
}
/* mapping from CSS display to box type
@@ -446,7 +446,7 @@ void convert_xml_to_box(struct box_construct_ctx *ctx)
} while (++num_processed < max_processed_before_yield);
/* More work to do: schedule a continuation */
- schedule(0, (schedule_callback_fn) convert_xml_to_box, ctx);
+ guit->browser->schedule(0, (void *)convert_xml_to_box, ctx);
}
/**
@@ -2391,6 +2391,7 @@ bool box_input(BOX_SPECIAL_PARAMS)
goto no_memory;
box->gadget = gadget;
gadget->box = box;
+ gadget->html = content;
if (type && dom_string_caseless_lwc_isequal(type,
corestring_lwc_password)) {
@@ -2526,6 +2527,7 @@ bool box_button(BOX_SPECIAL_PARAMS)
if (!gadget)
return false;
+ gadget->html = content;
box->gadget = gadget;
gadget->box = box;
@@ -2554,6 +2556,7 @@ bool box_select(BOX_SPECIAL_PARAMS)
if (gadget == NULL)
return false;
+ gadget->html = content;
err = dom_node_get_first_child(n, &c);
if (err != DOM_NO_ERR)
return false;
@@ -2761,6 +2764,7 @@ bool box_textarea(BOX_SPECIAL_PARAMS)
if (box->gadget == NULL)
return false;
+ box->gadget->html = content;
box->gadget->box = box;
if (!box_input_text(content, box, n))
diff --git a/render/box_textarea.c b/render/box_textarea.c
index 099dcc8..fe5a7ba 100644
--- a/render/box_textarea.c
+++ b/render/box_textarea.c
@@ -107,8 +107,8 @@ bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key)
static void box_textarea_callback(void *data, struct textarea_msg *msg)
{
struct form_textarea_data *d = data;
- struct html_content *html = d->html;
struct form_control *gadget = d->gadget;
+ struct html_content *html = d->gadget->html;
struct box *box = gadget->box;
switch (msg->type) {
@@ -119,7 +119,7 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
union html_drag_owner drag_owner;
drag_owner.no_owner = true;
- html_set_drag_type(d->html, drag_type, drag_owner,
+ html_set_drag_type(html, drag_type, drag_owner,
NULL);
} else {
/* Textarea drag started */
@@ -146,7 +146,7 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
break;
}
- html_set_drag_type(d->html, drag_type, drag_owner,
+ html_set_drag_type(html, drag_type, drag_owner,
&rect);
}
break;
@@ -171,7 +171,7 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
union html_selection_owner sel_owner;
sel_owner.textarea = box;
- html_set_selection(d->html, HTML_SELECTION_TEXTAREA,
+ html_set_selection(html, HTML_SELECTION_TEXTAREA,
sel_owner,
msg->data.selection.read_only);
} else {
@@ -179,7 +179,7 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
union html_selection_owner sel_owner;
sel_owner.none = true;
- html_set_selection(d->html, HTML_SELECTION_NONE,
+ html_set_selection(html, HTML_SELECTION_NONE,
sel_owner, true);
}
break;
@@ -191,12 +191,12 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
if (msg->data.caret.type == TEXTAREA_CARET_HIDE) {
union html_focus_owner focus_owner;
focus_owner.textarea = box;
- html_set_focus(d->html, HTML_FOCUS_TEXTAREA,
+ html_set_focus(html, HTML_FOCUS_TEXTAREA,
focus_owner, true, 0, 0, 0, NULL);
} else {
union html_focus_owner focus_owner;
focus_owner.textarea = box;
- html_set_focus(d->html, HTML_FOCUS_TEXTAREA,
+ html_set_focus(html, HTML_FOCUS_TEXTAREA,
focus_owner, false,
msg->data.caret.pos.x,
msg->data.caret.pos.y,
@@ -206,7 +206,7 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg)
break;
case TEXTAREA_MSG_TEXT_MODIFIED:
- form_gadget_update_value(d->html, gadget,
+ form_gadget_update_value(gadget,
strndup(msg->data.modified.text,
msg->data.modified.len));
break;
@@ -277,7 +277,6 @@ bool box_textarea_create_textarea(html_content *html,
if (read_only)
ta_flags |= TEXTAREA_READONLY;
- gadget->data.text.data.html = html;
gadget->data.text.data.gadget = gadget;
font_plot_style_from_css(gadget->box->style, &fstyle);
diff --git a/render/form.c b/render/form.c
index c9d74a1..518d2f6 100644
--- a/render/form.c
+++ b/render/form.c
@@ -32,12 +32,11 @@
#include <stdio.h>
#include <string.h>
#include <dom/dom.h>
+
#include "content/fetch.h"
#include "content/hlcache.h"
#include "css/css.h"
#include "css/utils.h"
-#include "desktop/browser.h"
-#include "desktop/gui.h"
#include "desktop/mouse.h"
#include "desktop/knockout.h"
#include "desktop/plot_style.h"
@@ -104,6 +103,7 @@ static void form_select_menu_scroll_callback(void *client_data,
* \param method method and enctype
* \param charset acceptable encodings for form submission, or NULL
* \param doc_charset encoding of containing document, or NULL
+ * \param html HTML content containing form
* \return a new structure, or NULL on memory exhaustion
*/
struct form *form_new(void *node, const char *action, const char *target,
@@ -154,6 +154,7 @@ struct form *form_new(void *node, const char *action, const char *target,
return form;
}
+
/**
* Free a form, and any controls it owns.
*
@@ -1382,14 +1383,11 @@ static void form__select_process_selection(html_content *html,
}
-void form_select_process_selection(hlcache_handle *h,
- struct form_control *control, int item)
+void form_select_process_selection(struct form_control *control, int item)
{
- assert(h != NULL);
+ assert(control != NULL);
- form__select_process_selection(
- (html_content *)hlcache_handle_get_content(h),
- control, item);
+ form__select_process_selection(control->html, control, item);
}
/**
@@ -1617,12 +1615,10 @@ void form_select_menu_callback(void *client_data,
* \param radio form control of type GADGET_RADIO
*/
-void form_radio_set(html_content *html,
- struct form_control *radio)
+void form_radio_set(struct form_control *radio)
{
struct form_control *control;
- assert(html);
assert(radio);
if (!radio->form)
return;
@@ -1642,13 +1638,13 @@ void form_radio_set(html_content *html,
if (control->selected) {
control->selected = false;
dom_html_input_element_set_checked(control->node, false);
- html__redraw_a_box(html, control->box);
+ html__redraw_a_box(radio->html, control->box);
}
}
radio->selected = true;
dom_html_input_element_set_checked(radio->node, true);
- html__redraw_a_box(html, radio->box);
+ html__redraw_a_box(radio->html, radio->box);
}
@@ -1703,8 +1699,7 @@ void form_submit(nsurl *page_url, struct browser_window *target,
browser_window_navigate(target,
action_query,
page_url,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1724,8 +1719,7 @@ void form_submit(nsurl *page_url, struct browser_window *target,
browser_window_navigate(target,
action_url,
page_url,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
data,
NULL,
NULL);
@@ -1735,8 +1729,7 @@ void form_submit(nsurl *page_url, struct browser_window *target,
browser_window_navigate(target,
action_url,
page_url,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
success,
NULL);
@@ -1749,8 +1742,7 @@ void form_submit(nsurl *page_url, struct browser_window *target,
free(data);
}
-void form_gadget_update_value(struct html_content *html,
- struct form_control *control, char *value)
+void form_gadget_update_value(struct form_control *control, char *value)
{
switch (control->type) {
case GADGET_HIDDEN:
diff --git a/render/form.h b/render/form.h
index 78211ee..f072b80 100644
--- a/render/form.h
+++ b/render/form.h
@@ -35,6 +35,7 @@ struct form_option;
struct form_select_menu;
struct html_content;
struct dom_string;
+struct content;
/** Form submit method. */
typedef enum {
@@ -76,13 +77,13 @@ typedef enum {
/** Data for textarea */
struct form_textarea_data {
- struct html_content *html;
struct form_control *gadget;
};
/** Form control. */
struct form_control {
void *node; /**< Corresponding DOM node */
+ struct html_content *html; /**< HTML content containing control */
form_control_type type; /**< Type of control */
@@ -186,13 +187,11 @@ void form_select_mouse_drag_end(struct form_control *control,
browser_mouse_state mouse, int x, int y);
void form_select_get_dimensions(struct form_control *control,
int *width, int *height);
-void form_select_process_selection(hlcache_handle *h,
- struct form_control *control, int item);
+void form_select_process_selection(struct form_control *control, int item);
void form_submit(nsurl *page_url, struct browser_window *target,
struct form *form, struct form_control *submit_button);
-void form_radio_set(struct html_content *html, struct form_control *radio);
+void form_radio_set(struct form_control *radio);
-void form_gadget_update_value(struct html_content *html,
- struct form_control *control, char *value);
+void form_gadget_update_value(struct form_control *control, char *value);
#endif
diff --git a/render/html.c b/render/html.c
index bd23aac..95037a2 100644
--- a/render/html.c
+++ b/render/html.c
@@ -29,14 +29,26 @@
#include <stdlib.h>
#include "utils/config.h"
+#include "utils/corestrings.h"
+#include "utils/http.h"
+#include "utils/libdom.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/talloc.h"
+#include "utils/url.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
+#include "utils/nsoption.h"
#include "content/content_protected.h"
#include "content/fetch.h"
#include "content/hlcache.h"
-#include "utils/nsoption.h"
#include "desktop/selection.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
#include "image/bitmap.h"
+#include "javascript/js.h"
+#include "desktop/gui_factory.h"
+
#include "render/box.h"
#include "render/font.h"
#include "render/form.h"
@@ -44,17 +56,6 @@
#include "render/imagemap.h"
#include "render/layout.h"
#include "render/search.h"
-#include "javascript/js.h"
-#include "utils/corestrings.h"
-#include "utils/http.h"
-#include "utils/libdom.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/schedule.h"
-#include "utils/talloc.h"
-#include "utils/url.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
#define CHUNK 4096
@@ -589,6 +590,7 @@ void html_finish_conversion(html_content *c)
error = dom_to_box(html, c, html_box_convert_done);
if (error != NSERROR_OK) {
+ LOG(("box conversion failed"));
dom_node_unref(html);
html_object_free_objects(c);
content_broadcast_errorcode(&c->base, error);
@@ -729,6 +731,7 @@ html_create_html_data(html_content *c, const http_parameter *params)
dom_hubbub_error error;
c->parser = NULL;
+ c->parse_completed = false;
c->document = NULL;
c->quirks = DOM_DOCUMENT_QUIRKS_MODE_NONE;
c->encoding = NULL;
@@ -1068,16 +1071,35 @@ html_begin_conversion(html_content *htmlc)
dom_string *node_name = NULL;
dom_hubbub_error error;
- LOG(("Completing parse"));
- /* complete parsing */
- error = dom_hubbub_parser_completed(htmlc->parser);
- if (error != DOM_HUBBUB_OK) {
- LOG(("Parsing failed"));
+ /* The act of completing the parse can result in additional data
+ * being flushed through the parser. This may result in new style or
+ * script nodes, upon which the conversion depends. Thus, once we
+ * have completed the parse, we must check again to see if we can
+ * begin the conversion. If we can't, we must stop and wait for the
+ * new styles/scripts to be processed. Once they have been processed,
+ * we will be called again to begin the conversion for real. Thus,
+ * we must also ensure that we don't attempt to complete the parse
+ * multiple times, so store a flag to indicate that parsing is
+ * complete to avoid repeating the completion pointlessly.
+ */
+ if (htmlc->parse_completed == false) {
+ LOG(("Completing parse"));
+ /* complete parsing */
+ error = dom_hubbub_parser_completed(htmlc->parser);
+ if (error != DOM_HUBBUB_OK) {
+ LOG(("Parsing failed"));
+
+ content_broadcast_errorcode(&htmlc->base,
+ libdom_hubbub_error_to_nserror(error));
- content_broadcast_errorcode(&htmlc->base,
- libdom_hubbub_error_to_nserror(error));
+ return false;
+ }
+ htmlc->parse_completed = true;
+ }
- return false;
+ if (html_can_begin_conversion(htmlc) == false) {
+ /* We can't proceed (see commentary above) */
+ return true;
}
/* Give up processing if we've been aborted */
@@ -1769,16 +1791,16 @@ static void html__set_file_gadget_filename(struct content *c,
char *utf8_fn, *oldfile = NULL;
html_content *html = (html_content *)c;
struct box *file_box = gadget->box;
-
- ret = utf8_from_local_encoding(fn,0, &utf8_fn);
+
+ ret = guit->utf8->local_to_utf8(fn, 0, &utf8_fn);
if (ret != NSERROR_OK) {
assert(ret != NSERROR_BAD_ENCODING);
- LOG(("utf8_from_local_encoding failed"));
+ LOG(("utf8 to local encoding conversion failed"));
/* Load was for us - just no memory */
return;
}
- form_gadget_update_value(html, gadget, utf8_fn);
+ form_gadget_update_value(gadget, utf8_fn);
/* corestring_dom___ns_key_file_name_node_data */
if (dom_node_set_user_data((dom_node *)file_box->gadget->node,
@@ -1865,7 +1887,7 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file)
/* Handle the drop */
if (file_box) {
/* File dropped on file input */
- html__set_file_gadget_filename(c, box->gadget, file);
+ html__set_file_gadget_filename(c, file_box->gadget, file);
} else {
/* File dropped on text input */
@@ -1915,11 +1937,11 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file)
/* TODO: Sniff for text? */
/* Convert to UTF-8 */
- ret = utf8_from_local_encoding(buffer, file_len, &utf8_buff);
+ ret = guit->utf8->local_to_utf8(buffer, file_len, &utf8_buff);
if (ret != NSERROR_OK) {
/* bad encoding shouldn't happen */
assert(ret != NSERROR_BAD_ENCODING);
- LOG(("utf8_from_local_encoding failed"));
+ LOG(("local to utf8 encoding failed"));
free(buffer);
warn_user("NoMemory", NULL);
return true;
diff --git a/render/html_css.c b/render/html_css.c
index ad24804..b4c25ba 100644
--- a/render/html_css.c
+++ b/render/html_css.c
@@ -28,12 +28,13 @@
#include <stdlib.h>
#include "content/hlcache.h"
+#include "desktop/gui_factory.h"
#include "utils/nsoption.h"
-#include "render/html_internal.h"
#include "utils/corestrings.h"
#include "utils/config.h"
#include "utils/log.h"
-#include "utils/schedule.h"
+
+#include "render/html_internal.h"
static nsurl *html_default_stylesheet_url;
static nsurl *html_adblock_stylesheet_url;
@@ -307,7 +308,7 @@ static void html_css_process_modified_styles(void *pw)
/* If we failed to process any sheet, schedule a retry */
if (all_done == false) {
- schedule(100, html_css_process_modified_styles, c);
+ guit->browser->schedule(1000, html_css_process_modified_styles, c);
}
}
@@ -332,7 +333,7 @@ bool html_css_update_style(html_content *c, dom_node *style)
s->modified = true;
- schedule(0, html_css_process_modified_styles, c);
+ guit->browser->schedule(0, html_css_process_modified_styles, c);
return true;
}
@@ -462,7 +463,7 @@ nserror html_css_free_stylesheets(html_content *html)
{
unsigned int i;
- schedule_remove(html_css_process_modified_styles, html);
+ guit->browser->schedule(-1, html_css_process_modified_styles, html);
for (i = 0; i != html->stylesheet_count; i++) {
if (html->stylesheets[i].sheet != NULL) {
diff --git a/render/html_interaction.c b/render/html_interaction.c
index 415e7b1..e030e57 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -29,6 +29,7 @@
#include <dom/dom.h>
#include "content/content.h"
+#include "content/hlcache.h"
#include "desktop/browser.h"
#include "desktop/gui_factory.h"
#include "desktop/frames.h"
@@ -670,7 +671,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
case GADGET_RADIO:
status = messages_get("FormRadio");
if (mouse & BROWSER_MOUSE_CLICK_1)
- form_radio_set(html, gadget);
+ form_radio_set(gadget);
break;
case GADGET_IMAGE:
if (mouse & BROWSER_MOUSE_CLICK_1) {
@@ -822,8 +823,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
browser_window_navigate(bw,
url,
content_get_url(c),
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -1002,8 +1002,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
browser_window_navigate(browser_window_find_target(bw, target, mouse),
url,
content_get_url(c),
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1073,13 +1072,11 @@ bool html_keypress(struct content *c, uint32_t key)
* Handle search.
*
* \param c content of type HTML
- * \param gui_callbacks vtable for updating front end
- * \param gui_data front end private data
+ * \param context front end private data
* \param flags search flags
* \param string search string
*/
-void html_search(struct content *c,
- struct gui_search_callbacks *gui_callbacks, void *gui_data,
+void html_search(struct content *c, void *context,
search_flags_t flags, const char *string)
{
html_content *html = (html_content *)c;
@@ -1104,8 +1101,7 @@ void html_search(struct content *c,
html->search = NULL;
}
- html->search = search_create_context(c, CONTENT_HTML,
- gui_callbacks, gui_data);
+ html->search = search_create_context(c, CONTENT_HTML, context);
if (html->search == NULL)
return;
@@ -1136,8 +1132,9 @@ void html_search_clear(struct content *c)
free(html->search_string);
html->search_string = NULL;
- if (html->search != NULL)
+ if (html->search != NULL) {
search_destroy_context(html->search);
+ }
html->search = NULL;
}
@@ -1264,6 +1261,7 @@ void html_set_focus(html_content *html, html_focus_type focus_type,
union content_msg_data msg_data;
int x_off = 0;
int y_off = 0;
+ struct rect cr;
bool textarea_lost_focus = html->focus_type == HTML_FOCUS_TEXTAREA &&
focus_type != HTML_FOCUS_TEXTAREA;
@@ -1294,7 +1292,6 @@ void html_set_focus(html_content *html, html_focus_type focus_type,
} else if (focus_type != HTML_FOCUS_SELF && hide_caret) {
msg_data.caret.type = CONTENT_CARET_HIDE;
} else {
- struct rect cr;
if (clip != NULL) {
cr = *clip;
cr.x0 += x_off;
diff --git a/render/html_internal.h b/render/html_internal.h
index 43fce9b..05a085e 100644
--- a/render/html_internal.h
+++ b/render/html_internal.h
@@ -71,6 +71,7 @@ typedef struct html_content {
struct content base;
dom_hubbub_parser *parser; /**< Parser object handle */
+ bool parse_completed; /**< Whether the parse has been completed */
/** Document tree */
dom_document *document;
@@ -253,8 +254,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
bool html_keypress(struct content *c, uint32_t key);
void html_overflow_scroll_callback(void *client_data,
struct scrollbar_msg_data *scrollbar_data);
-void html_search(struct content *c,
- struct gui_search_callbacks *gui_callbacks, void *gui_data,
+void html_search(struct content *c, void *context,
search_flags_t flags, const char *string);
void html_search_clear(struct content *c);
diff --git a/render/html_object.c b/render/html_object.c
index e76919d..6499f24 100644
--- a/render/html_object.c
+++ b/render/html_object.c
@@ -31,12 +31,13 @@
#include "css/utils.h"
#include "utils/nsoption.h"
#include "desktop/scrollbar.h"
-#include "render/box.h"
-#include "render/html_internal.h"
+#include "desktop/gui_factory.h"
#include "utils/corestrings.h"
#include "utils/config.h"
#include "utils/log.h"
-#include "utils/schedule.h"
+
+#include "render/box.h"
+#include "render/html_internal.h"
/* break reference loop */
static void html_object_refresh(void *p);
@@ -335,7 +336,7 @@ html_object_callback(hlcache_handle *object,
case CONTENT_MSG_REFRESH:
if (content_get_type(object) == CONTENT_HTML) {
/* only for HTML objects */
- schedule(event->data.delay * 100,
+ guit->browser->schedule(event->data.delay * 1000,
html_object_refresh, o);
}
@@ -534,7 +535,7 @@ static bool html_replace_object(struct content_html_object *object, nsurl *url)
}
/**
- * schedule() callback for object refresh
+ * schedule callback for object refresh
*/
static void html_object_refresh(void *p)
@@ -630,8 +631,9 @@ nserror html_object_close_objects(html_content *html)
if (content_get_type(object->content) == CONTENT_NONE)
continue;
- if (content_get_type(object->content) == CONTENT_HTML)
- schedule_remove(html_object_refresh, object);
+ if (content_get_type(object->content) == CONTENT_HTML) {
+ guit->browser->schedule(-1, html_object_refresh, object);
+ }
content_close(object->content);
}
@@ -646,9 +648,9 @@ nserror html_object_free_objects(html_content *html)
if (victim->content != NULL) {
LOG(("object %p", victim->content));
- if (content_get_type(victim->content) == CONTENT_HTML)
- schedule_remove(html_object_refresh, victim);
-
+ if (content_get_type(victim->content) == CONTENT_HTML) {
+ guit->browser->schedule(-1, html_object_refresh, victim);
+ }
hlcache_handle_release(victim->content);
}
diff --git a/render/search.c b/render/search.c
index 895cff0..3bec9e1 100644
--- a/render/search.c
+++ b/render/search.c
@@ -21,28 +21,26 @@
/** \file
* Free text search (core)
*/
-#include "utils/config.h"
#include <ctype.h>
#include <string.h>
-
#include <dom/dom.h>
+#include "utils/config.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "desktop/gui.h"
#include "desktop/selection.h"
+#include "desktop/gui_factory.h"
+
#include "render/box.h"
#include "render/html.h"
#include "render/html_internal.h"
#include "render/search.h"
#include "render/textplain.h"
-#include "utils/config.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "utils/utils.h"
-
#ifndef NOF_ELEMENTS
#define NOF_ELEMENTS(array) (sizeof(array)/sizeof(*(array)))
@@ -63,7 +61,6 @@ struct list_entry {
};
struct search_context {
- struct gui_search_callbacks *gui;
void *gui_p;
struct content *c;
struct list_entry *found;
@@ -77,8 +74,7 @@ struct search_context {
/* Exported function documented in search.h */
struct search_context * search_create_context(struct content *c,
- content_type type, struct gui_search_callbacks *callbacks,
- void *gui_data)
+ content_type type, void *gui_data)
{
struct search_context *context;
struct list_entry *search_head;
@@ -115,7 +111,6 @@ struct search_context * search_create_context(struct content *c,
context->newsearch = true;
context->c = c;
context->is_html = (type == CONTENT_HTML) ? true : false;
- context->gui = callbacks;
context->gui_p = gui_data;
return context;
@@ -469,8 +464,7 @@ static void search_text(const char *string, int string_len,
context->string[string_len] = '\0';
}
- if ((context->gui != NULL) && (context->gui->hourglass != NULL))
- context->gui->hourglass(true, context->gui_p);
+ guit->search->hourglass(true, context->gui_p);
if (context->is_html == true) {
res = find_occurrences_html(string, string_len,
@@ -482,14 +476,10 @@ static void search_text(const char *string, int string_len,
if (!res) {
free_matches(context);
- if ((context->gui != NULL) &&
- (context->gui->hourglass != NULL))
- context->gui->hourglass(false, context->gui_p);
+ guit->search->hourglass(false, context->gui_p);
return;
}
- if ((context->gui != NULL) &&
- (context->gui->hourglass != NULL))
- context->gui->hourglass(false, context->gui_p);
+ guit->search->hourglass(false, context->gui_p);
context->prev_case_sens = case_sensitive;
@@ -508,20 +498,14 @@ static void search_text(const char *string, int string_len,
}
}
- if (context->gui == NULL)
- return;
- if (context->gui->status != NULL)
- context->gui->status((context->current != NULL),
- context->gui_p);
+ guit->search->status((context->current != NULL), context->gui_p);
search_show_all(showall, context);
- if (context->gui->back_state != NULL)
- context->gui->back_state((context->current != NULL) &&
+ guit->search->back_state((context->current != NULL) &&
(context->current->prev != NULL),
context->gui_p);
- if (context->gui->forward_state != NULL)
- context->gui->forward_state((context->current != NULL) &&
+ guit->search->forward_state((context->current != NULL) &&
(context->current->next != NULL),
context->gui_p);
@@ -558,13 +542,12 @@ void search_step(struct search_context *context, search_flags_t flags,
int string_len;
int i = 0;
- if ((context == NULL) || (context->gui == NULL)) {
+ if (context == NULL) {
warn_user("SearchError", 0);
return;
}
- if (context->gui->add_recent != NULL)
- context->gui->add_recent(string, context->gui_p);
+ guit->search->add_recent(string, context->gui_p);
string_len = strlen(string);
for (i = 0; i < string_len; i++)
@@ -573,12 +556,10 @@ void search_step(struct search_context *context, search_flags_t flags,
if (i >= string_len) {
union content_msg_data msg_data;
free_matches(context);
- if (context->gui->status != NULL)
- context->gui->status(true, context->gui_p);
- if (context->gui->back_state != NULL)
- context->gui->back_state(false, context->gui_p);
- if (context->gui->forward_state != NULL)
- context->gui->forward_state(false, context->gui_p);
+
+ guit->search->status(true, context->gui_p);
+ guit->search->back_state(false, context->gui_p);
+ guit->search->forward_state(false, context->gui_p);
msg_data.scroll.area = false;
msg_data.scroll.x0 = 0;
@@ -654,11 +635,14 @@ void search_destroy_context(struct search_context *context)
{
assert(context != NULL);
- if ((context->string != NULL) && (context->gui != NULL) &&
- (context->gui->add_recent != NULL)) {
- context->gui->add_recent(context->string, context->gui_p);
+ if (context->string != NULL) {
+ guit->search->add_recent(context->string, context->gui_p);
free(context->string);
}
+
+ guit->search->forward_state(true, context->gui_p);
+ guit->search->back_state(true, context->gui_p);
+
free_matches(context);
free(context);
}
diff --git a/render/search.h b/render/search.h
index 43c93b3..a8354e7 100644
--- a/render/search.h
+++ b/render/search.h
@@ -36,8 +36,7 @@ struct search_context;
* \return true for success
*/
struct search_context * search_create_context(struct content *c,
- content_type type, struct gui_search_callbacks *callbacks,
- void *gui_data);
+ content_type type, void *context);
/**
* Ends the search process, invalidating all state
diff --git a/render/textplain.c b/render/textplain.c
index 5254e6a..e08a045 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -35,7 +35,6 @@
#include "css/css.h"
#include "css/utils.h"
#include "desktop/browser.h"
-#include "desktop/gui.h"
#include "utils/nsoption.h"
#include "desktop/plotters.h"
#include "desktop/search.h"
@@ -113,8 +112,7 @@ static void textplain_mouse_track(struct content *c, struct browser_window *bw,
static void textplain_mouse_action(struct content *c, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
static bool textplain_keypress(struct content *c, uint32_t key);
-static void textplain_search(struct content *c,
- struct gui_search_callbacks *gui_callbacks, void *gui_data,
+static void textplain_search(struct content *c, void *gui_data,
search_flags_t flags, const char *string);
static void textplain_search_clear(struct content *c);
static void textplain_reformat(struct content *c, int width, int height);
@@ -761,8 +759,7 @@ bool textplain_keypress(struct content *c, uint32_t key)
* \param flags search flags
* \param string search string
*/
-void textplain_search(struct content *c,
- struct gui_search_callbacks *gui_callbacks, void *gui_data,
+void textplain_search(struct content *c, void *gui_data,
search_flags_t flags, const char *string)
{
textplain_content *text = (textplain_content *) c;
@@ -788,7 +785,7 @@ void textplain_search(struct content *c,
}
text->search = search_create_context(c, CONTENT_TEXTPLAIN,
- gui_callbacks, gui_data);
+ gui_data);
if (text->search == NULL)
return;
diff --git a/resources/FatMessages b/resources/FatMessages
index ff5a761..74f03e4 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -5681,11 +5681,11 @@ de.all.ScaleQuality:Skalieren hoher Qualität
fr.all.ScaleQuality:Higher quality scaling
it.all.ScaleQuality:Massima qualità di visualizzazione
nl.all.ScaleQuality:Higher quality scaling
-en.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-de.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-fr.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-it.ami.DitherQuality:Qualità dither (<= solo modi a 8-bit)
-nl.ami.DitherQuality:Dither quality (<= 8-bit modes only)
+en.ami.DitherQuality:Dither quality
+de.ami.DitherQuality:Dither quality
+fr.ami.DitherQuality:Dither quality
+it.ami.DitherQuality:Qualità dither
+nl.ami.DitherQuality:Dither quality
en.ami.Low:Low
de.ami.Low:Low
fr.ami.Low:Low
diff --git a/riscos/Makefile.defaults b/riscos/Makefile.defaults
index f48024f..8081e5c 100644
--- a/riscos/Makefile.defaults
+++ b/riscos/Makefile.defaults
@@ -2,30 +2,29 @@
# RISC OS-specific options
# ----------------------------------------------------------------------------
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO
- NETSURF_USE_NSSVG := YES
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO
+NETSURF_USE_NSSVG := YES
- # Enable NetSurf's support for displaying RISC OS Draw files
- # Valid options: YES, NO
- NETSURF_USE_DRAW := YES
+# Enable NetSurf's support for displaying RISC OS Draw files
+# Valid options: YES, NO
+NETSURF_USE_DRAW := YES
- # Enable NetSurf's support for displaying RISC OS Sprites
- # Valid options: YES, NO
- NETSURF_USE_SPRITE := YES
+# Enable NetSurf's support for displaying RISC OS Sprites
+# Valid options: YES, NO
+NETSURF_USE_SPRITE := YES
- # Enable NetSurf's use of AWRender for displaying ArtWorks files
- # Valid options: YES, NO
- NETSURF_USE_ARTWORKS := YES
+# Enable NetSurf's use of AWRender for displaying ArtWorks files
+# Valid options: YES, NO
+NETSURF_USE_ARTWORKS := YES
- # Enable NetSurf's support for the Acorn plugin protocol
- # Valid options: YES, NO
- NETSURF_USE_PLUGINS := NO
+# Enable NetSurf's support for the Acorn plugin protocol
+# Valid options: YES, NO
+NETSURF_USE_PLUGINS := NO
- # Enable NetSurf's use of pencil for Drawfile export
- # Valid options: YES, NO
- NETSURF_USE_DRAW_EXPORT := YES
-
- # Optimisation levels
- CFLAGS += -O2
+# Enable NetSurf's use of pencil for Drawfile export
+# Valid options: YES, NO
+NETSURF_USE_DRAW_EXPORT := YES
+# Optimisation levels
+CFLAGS += -O2
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 4347023..d259c87 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -775,8 +775,7 @@ bool ro_gui_dialog_openurl_apply(wimp_w w) {
error = nsurl_create(url2, &url);
free(url2);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/riscos/download.c b/riscos/download.c
index 526f301..6cba17e 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -41,22 +41,26 @@
#include "oslib/osgbpb.h"
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
+
#include "desktop/gui.h"
#include "desktop/netsurf.h"
-#include "riscos/dialog.h"
+#include "desktop/download.h"
#include "utils/nsoption.h"
-#include "riscos/mouse.h"
-#include "riscos/save.h"
-#include "riscos/query.h"
-#include "riscos/wimp.h"
-#include "riscos/wimp_event.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/schedule.h"
#include "utils/url.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "riscos/gui.h"
+#include "riscos/dialog.h"
+#include "riscos/mouse.h"
+#include "riscos/save.h"
+#include "riscos/query.h"
+#include "riscos/wimp.h"
+#include "riscos/wimp_event.h"
+#include "riscos/ucstables.h"
+
#define ICON_DOWNLOAD_ICON 0
#define ICON_DOWNLOAD_URL 1
#define ICON_DOWNLOAD_PATH 2
@@ -375,6 +379,8 @@ static struct gui_download_window *gui_download_window_create(download_context *
snprintf(dw->path, RO_DOWNLOAD_MAX_PATH_LEN, "%s",
filename);
+ free(filename);
+
err = utf8_to_local_encoding(dw->path, 0, &local_path);
if (err != NSERROR_OK) {
/* badenc should never happen */
@@ -452,7 +458,7 @@ static void gui_download_window_error(struct gui_download_window *dw,
dw->ctx = NULL;
dw->error = true;
- schedule_remove(ro_gui_download_update_status_wrapper, dw);
+ riscos_schedule(-1, ro_gui_download_update_status_wrapper, dw);
/* place error message in status icon in red */
strncpy(dw->status, error_msg, sizeof dw->status);
@@ -712,15 +718,16 @@ void ro_gui_download_update_status(struct gui_download_window *dw)
warn_user("WimpError", error->errmess);
}
- if (dw->ctx)
- schedule(100, ro_gui_download_update_status_wrapper, dw);
- else
- schedule_remove(ro_gui_download_update_status_wrapper, dw);
+ if (dw->ctx) {
+ riscos_schedule(1000, ro_gui_download_update_status_wrapper, dw);
+ } else {
+ riscos_schedule(-1, ro_gui_download_update_status_wrapper, dw);
+ }
}
/**
- * Wrapper for ro_gui_download_update_status(), suitable for schedule().
+ * Wrapper for ro_gui_download_update_status(), suitable for riscos_schedule().
*/
void ro_gui_download_update_status_wrapper(void *p)
@@ -792,10 +799,11 @@ static void gui_download_window_done(struct gui_download_window *dw)
warn_user("SaveError", error->errmess);
}
- if (dw->send_dataload)
+ if (dw->send_dataload) {
ro_gui_download_send_dataload(dw);
+ }
- schedule(200, ro_gui_download_window_destroy_wrapper, dw);
+ riscos_schedule(2000, ro_gui_download_window_destroy_wrapper, dw);
}
}
@@ -886,7 +894,7 @@ bool ro_gui_download_keypress(wimp_key *key)
!nsoption_bool(confirm_overwrite)) && !dw->ctx)
{
/* finished already */
- schedule(200, ro_gui_download_window_destroy_wrapper, dw);
+ riscos_schedule(2000, ro_gui_download_window_destroy_wrapper, dw);
}
return true;
}
@@ -982,7 +990,7 @@ void ro_gui_download_datasave_ack(wimp_message *message)
ro_gui_download_send_dataload(dw);
- schedule(200, ro_gui_download_window_destroy_wrapper, dw);
+ riscos_schedule(2000, ro_gui_download_window_destroy_wrapper, dw);
}
}
@@ -1414,7 +1422,7 @@ void ro_gui_download_send_dataload(struct gui_download_window *dw)
warn_user("WimpError", error->errmess);
}
- schedule(200, ro_gui_download_window_destroy_wrapper, dw);
+ riscos_schedule(2000, ro_gui_download_window_destroy_wrapper, dw);
}
@@ -1477,8 +1485,8 @@ bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit)
return false;
}
- schedule_remove(ro_gui_download_update_status_wrapper, dw);
- schedule_remove(ro_gui_download_window_destroy_wrapper, dw);
+ riscos_schedule(-1, ro_gui_download_update_status_wrapper, dw);
+ riscos_schedule(-1, ro_gui_download_window_destroy_wrapper, dw);
/* remove from list */
if (dw->prev)
@@ -1531,7 +1539,7 @@ bool ro_gui_download_window_destroy(struct gui_download_window *dw, bool quit)
/**
- * Wrapper for ro_gui_download_window_destroy(), suitable for schedule().
+ * Wrapper for ro_gui_download_window_destroy(), suitable for riscos_schedule().
*/
void ro_gui_download_window_destroy_wrapper(void *p)
@@ -1610,7 +1618,7 @@ void ro_gui_download_overwrite_confirmed(query_id id, enum query_response res, v
ro_gui_download_send_dataload(dw);
- schedule(200, ro_gui_download_window_destroy_wrapper, dw);
+ riscos_schedule(2000, ro_gui_download_window_destroy_wrapper, dw);
}
}
diff --git a/riscos/gui.c b/riscos/gui.c
index e862e93..05325c5 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -50,7 +50,13 @@
#include "oslib/wimpspriteop.h"
#include "oslib/uri.h"
#include "rufl.h"
+
#include "utils/config.h"
+#include "utils/filename.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
@@ -61,6 +67,7 @@
#include "desktop/save_complete.h"
#include "desktop/treeview.h"
#include "render/font.h"
+
#include "riscos/content-handlers/artworks.h"
#include "riscos/bitmap.h"
#include "riscos/buffer.h"
@@ -92,12 +99,7 @@
#include "riscos/wimp_event.h"
#include "riscos/wimputils.h"
#include "riscos/window.h"
-#include "utils/filename.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "utils/utils.h"
-
+#include "riscos/ucstables.h"
#ifndef FILETYPE_ACORN_URI
@@ -939,8 +941,7 @@ static void gui_init2(int argc, char** argv)
errorns = nsurl_create(url, &urlns);
if (errorns == NSERROR_OK) {
- errorns = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ errorns = browser_window_create(BW_CREATE_HISTORY,
urlns,
NULL,
NULL,
@@ -1076,7 +1077,7 @@ void ro_gui_cleanup(void)
* \param active return as soon as possible
*/
-void gui_poll(bool active)
+static void riscos_poll(bool active)
{
wimp_event_no event;
wimp_block block;
@@ -1115,8 +1116,9 @@ void gui_poll(bool active)
* from gui_multitask(). Scheduled callbacks must only be run from the
* top-level.
*/
- if (event == wimp_NULL_REASON_CODE)
+ if (event == wimp_NULL_REASON_CODE) {
schedule_run();
+ }
ro_gui_window_update_boxes();
@@ -1514,8 +1516,7 @@ void ro_msg_dataload(wimp_message *message)
error = browser_window_navigate(g->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1527,9 +1528,7 @@ void ro_msg_dataload(wimp_message *message)
ro_gui_hotlist_url_drop(message, urltxt);
#endif
} else {
- error = browser_window_create(
- BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -1595,6 +1594,7 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
/* URI */
if (!ro_gui_uri_file_parse_line(fp, line))
goto uri_syntax_error;
+
url = strdup(line);
if (!url) {
warn_user("NoMemory", 0);
@@ -1604,7 +1604,7 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
/* title */
if (!ro_gui_uri_file_parse_line(fp, line))
- goto uri_syntax_error;
+ goto uri_free;
if (uri_title && line[0] && ((line[0] != '*') || line[1])) {
*uri_title = strdup(line);
if (!*uri_title) /* non-fatal */
@@ -1614,6 +1614,9 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
return url;
+uri_free:
+ free(url);
+
uri_syntax_error:
fclose(fp);
warn_user("URIError", 0);
@@ -1904,8 +1907,7 @@ void ro_msg_dataopen(wimp_message *message)
free(url);
if (error == NSERROR_OK) {
/* create a new window with the file */
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
urlns,
NULL,
NULL,
@@ -2348,10 +2350,6 @@ static bool path_add_part(char *path, int length, const char *newpart)
return true;
}
-static struct gui_clipboard_table riscos_clipboard_table = {
- .get = gui_get_clipboard,
- .set = gui_set_clipboard,
-};
static struct gui_fetch_table riscos_fetch_table = {
.filename_from_path = filename_from_path,
@@ -2365,7 +2363,8 @@ static struct gui_fetch_table riscos_fetch_table = {
};
static struct gui_browser_table riscos_browser_table = {
- .poll = gui_poll,
+ .poll = riscos_poll,
+ .schedule = riscos_schedule,
.quit = gui_quit,
.launch_url = gui_launch_url,
@@ -2388,9 +2387,11 @@ int main(int argc, char** argv)
struct gui_table riscos_gui_table = {
.browser = &riscos_browser_table,
.window = riscos_window_table,
- .clipboard = &riscos_clipboard_table,
+ .clipboard = riscos_clipboard_table,
.download = riscos_download_table,
.fetch = &riscos_fetch_table,
+ .utf8 = riscos_utf8_table,
+ .search = riscos_search_table,
};
/* Consult NetSurf$Logging environment variable to decide if logging
diff --git a/riscos/gui.h b/riscos/gui.h
index 051834a..548d030 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -51,6 +51,7 @@ struct tree;
struct node;
struct history;
struct css_style;
+struct ssl_cert_info;
extern wimp_t task_handle; /**< RISC OS wimp task handle. */
@@ -122,7 +123,6 @@ void ro_gui_dump_browser_window(struct browser_window *bw);
void ro_gui_drag_box_start(wimp_pointer *pointer);
bool ro_gui_prequit(void);
const char *ro_gui_default_language(void);
-void gui_poll(bool active); /* exported for riscos/wimp_event.c:722 */
char *url_to_path(const char *url);
/* in download.c */
@@ -168,8 +168,7 @@ void gui_create_form_select_menu(struct browser_window *bw, struct form_control
/* in history.c */
void ro_gui_history_init(void);
-void ro_gui_history_open(struct browser_window *bw, struct history *history,
- bool pointer);
+void ro_gui_history_open(struct gui_window *g, bool pointer);
/* in filetype.c */
const char *fetch_filetype(const char *unix_path);
@@ -183,11 +182,28 @@ bits ro_filetype_from_unix_path(const char *unix_path);
/* in schedule.c */
extern bool sched_active;
extern os_t sched_time;
+
+/**
+ * Process events up to current time.
+ */
bool schedule_run(void);
+/**
+ * Schedule a callback.
+ *
+ * \param t interval before the callback should be made in ms
+ * \param callback callback function
+ * \param p user parameter, passed to callback function
+ *
+ * The callback function will be called as soon as possible after t ms have
+ * passed.
+ */
+nserror riscos_schedule(int t, void (*callback)(void *p), void *p);
+
/* in search.c */
void ro_gui_search_init(void);
void ro_gui_search_prepare(struct browser_window *g);
+struct gui_search_table *riscos_search_table;
/* in print.c */
void ro_gui_print_init(void);
@@ -212,10 +228,6 @@ extern int ro_plot_origin_y;
/* in theme_install.c */
bool ro_gui_theme_install_apply(wimp_w w);
-/* in textselection.c */
-void gui_get_clipboard(char **buffer, size_t *length);
-void gui_set_clipboard(const char *buffer, size_t length, nsclipboard_styles styles[], int n_styles);
-
/* in sslcert.c */
void gui_cert_verify(nsurl *url,
const struct ssl_cert_info *certs, unsigned long num,
diff --git a/riscos/gui/progress_bar.c b/riscos/gui/progress_bar.c
index 4457976..f5b4731 100644
--- a/riscos/gui/progress_bar.c
+++ b/riscos/gui/progress_bar.c
@@ -29,10 +29,11 @@
#include "oslib/osspriteop.h"
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
+
#include "desktop/plotters.h"
#include "utils/log.h"
-#include "utils/schedule.h"
#include "utils/utils.h"
+
#include "riscos/gui.h"
#include "riscos/tinct.h"
#include "riscos/wimp_event.h"
@@ -159,8 +160,9 @@ void ro_gui_progress_bar_destroy(struct progress_bar *pb)
os_error *error;
assert(pb);
- if (pb->animating)
- schedule_remove(ro_gui_progress_bar_animate, pb);
+ if (pb->animating) {
+ riscos_schedule(-1, ro_gui_progress_bar_animate, pb);
+ }
ro_gui_wimp_event_finalise(pb->w);
error = xwimp_delete_window(pb->w);
if (error) {
@@ -292,12 +294,14 @@ void ro_gui_progress_bar_update(struct progress_bar *pb, int width, int height)
/* update the animation state */
if ((pb->value == 0) || (pb->value == pb->range)) {
- if (pb->animating)
- schedule_remove(ro_gui_progress_bar_animate, pb);
+ if (pb->animating) {
+ riscos_schedule(-1, ro_gui_progress_bar_animate, pb);
+ }
pb->animating = false;
} else {
- if (!pb->animating)
- schedule(20, ro_gui_progress_bar_animate, pb);
+ if (!pb->animating) {
+ riscos_schedule(200, ro_gui_progress_bar_animate, pb);
+ }
pb->animating = true;
}
@@ -372,8 +376,9 @@ void ro_gui_progress_bar_animate(void *p)
if (pb->offset < 0)
pb->offset += progress_width * 2;
- if (pb->animating)
- schedule(20, ro_gui_progress_bar_animate, pb);
+ if (pb->animating) {
+ riscos_schedule(200, ro_gui_progress_bar_animate, pb);
+ }
redraw.w = pb->w;
redraw.box = pb->visible;
diff --git a/riscos/gui/status_bar.c b/riscos/gui/status_bar.c
index 899fe99..46a511f 100644
--- a/riscos/gui/status_bar.c
+++ b/riscos/gui/status_bar.c
@@ -30,7 +30,6 @@
#include "oslib/wimpspriteop.h"
#include "desktop/plotters.h"
#include "utils/log.h"
-#include "utils/schedule.h"
#include "utils/utils.h"
#include "riscos/gui.h"
#include "riscos/wimp.h"
@@ -171,7 +170,7 @@ void ro_gui_status_bar_destroy(struct status_bar *sb)
ro_gui_progress_bar_destroy(sb->pb);
/* Remove any scheduled redraw callbacks */
- schedule_remove(ro_gui_status_bar_redraw_callback, (void *) sb);
+ riscos_schedule(-1, ro_gui_status_bar_redraw_callback, (void *) sb);
free(sb);
}
@@ -331,7 +330,7 @@ void ro_gui_status_bar_set_text(struct status_bar *sb, const char *text)
* { callback, handle } pair is registered at once.
*/
if (sb->visible && text != NULL) {
- schedule(1, ro_gui_status_bar_redraw_callback, (void *) sb);
+ riscos_schedule(10, ro_gui_status_bar_redraw_callback, sb);
}
}
diff --git a/riscos/gui/url_bar.c b/riscos/gui/url_bar.c
index 681824d..b757df3 100644
--- a/riscos/gui/url_bar.c
+++ b/riscos/gui/url_bar.c
@@ -30,6 +30,14 @@
#include "oslib/os.h"
#include "oslib/osspriteop.h"
#include "oslib/wimp.h"
+
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
+#include "content/hlcache.h"
+#include "content/content.h"
+
#include "riscos/gui.h"
#include "riscos/hotlist.h"
#include "riscos/gui/url_bar.h"
@@ -38,10 +46,7 @@
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/window.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
+#include "riscos/ucstables.h"
#define URLBAR_HEIGHT 52
#define URLBAR_FAVICON_SIZE 16
@@ -852,8 +857,7 @@ bool ro_gui_url_bar_menu_select(struct url_bar *url_bar, wimp_i i,
browser_window_navigate(g->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
diff --git a/riscos/help.c b/riscos/help.c
index 9da52f3..3c74e54 100644
--- a/riscos/help.c
+++ b/riscos/help.c
@@ -44,6 +44,7 @@
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "riscos/ucstables.h"
/* Recognised help keys
diff --git a/riscos/history.c b/riscos/history.c
index a4aedc6..c5bdfcb 100644
--- a/riscos/history.c
+++ b/riscos/history.c
@@ -27,10 +27,9 @@
#include <stdlib.h>
#include <string.h>
#include "oslib/wimp.h"
-#include "desktop/local_history.h"
+#include "desktop/browser_history.h"
#include "desktop/plotters.h"
#include "riscos/dialog.h"
-#include "desktop/browser_private.h"
#include "utils/nsoption.h"
#include "riscos/gui.h"
#include "riscos/mouse.h"
@@ -43,7 +42,6 @@
static struct browser_window *history_bw;
-static struct history *history_current = 0;
/* Last position of mouse in window. */
static int mouse_x = 0;
/* Last position of mouse in window. */
@@ -82,20 +80,20 @@ void ro_gui_history_init(void)
* \param at_pointer open the window at the pointer
*/
-void ro_gui_history_open(struct browser_window *bw,
- struct history *history, bool at_pointer)
+void ro_gui_history_open(struct gui_window *g, bool at_pointer)
{
+ struct browser_window *bw;
int width, height;
os_box box = {0, 0, 0, 0};
wimp_window_state state;
os_error *error;
- assert(history);
-
- history_current = history;
+ assert(g != NULL);
+ assert(g->bw != NULL);
+ bw = g->bw;
history_bw = bw;
- history_size(history, &width, &height);
+ browser_window_history_size(bw, &width, &height);
width *= 2;
height *= 2;
@@ -132,8 +130,7 @@ void ro_gui_history_open(struct browser_window *bw,
return;
}
- ro_gui_dialog_open_persistent(bw->window->window, history_window,
- at_pointer);
+ ro_gui_dialog_open_persistent(g->window, history_window, at_pointer);
}
@@ -161,7 +158,7 @@ void ro_gui_history_redraw(wimp_draw *redraw)
while (more) {
ro_plot_origin_x = redraw->box.x0 - redraw->xscroll;
ro_plot_origin_y = redraw->box.y1 - redraw->yscroll;
- history_redraw(history_current, &ctx);
+ browser_window_history_redraw(history_bw, &ctx);
error = xwimp_get_rectangle(redraw, &more);
if (error) {
LOG(("xwimp_get_rectangle: 0x%x: %s",
@@ -237,7 +234,7 @@ void ro_gui_history_mouse_at(wimp_pointer *pointer, void *data)
x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / 2;
y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / 2;
- url = history_position_url(history_current, x, y);
+ url = browser_window_history_position_url(history_bw, x, y);
if (!url) {
/* not over a tree entry => close tooltip window. */
error = xwimp_close_window(dialog_tooltip);
@@ -348,7 +345,7 @@ bool ro_gui_history_click(wimp_pointer *pointer)
x = (pointer->pos.x - (state.visible.x0 - state.xscroll)) / 2;
y = -(pointer->pos.y - (state.visible.y1 - state.yscroll)) / 2;
- history_click(history_bw, history_current, x, y,
+ browser_window_history_click(history_bw, x, y,
pointer->buttons == wimp_CLICK_ADJUST);
return true;
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 7910353..14e90fb 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -30,27 +30,29 @@
#include "oslib/osfile.h"
#include "oslib/osmodule.h"
#include "oslib/wimp.h"
+
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/hotlist.h"
#include "desktop/tree.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/url.h"
+#include "utils/nsoption.h"
+
+#include "riscos/gui.h"
#include "riscos/dialog.h"
#include "riscos/hotlist.h"
#include "riscos/menus.h"
#include "riscos/message.h"
-#include "utils/nsoption.h"
#include "riscos/save.h"
#include "riscos/toolbar.h"
#include "riscos/treeview.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/query.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/schedule.h"
-#include "utils/utils.h"
-#include "utils/url.h"
static void ro_gui_hotlist_toolbar_update_buttons(void);
static void ro_gui_hotlist_toolbar_save_buttons(char *config);
@@ -543,7 +545,7 @@ void ro_gui_hotlist_add_page(nsurl *url)
* message didn't bounce.
*/
- schedule(0, ro_gui_hotlist_scheduled_callback, NULL);
+ riscos_schedule(0, ro_gui_hotlist_scheduled_callback, NULL);
}
@@ -569,7 +571,7 @@ static void ro_gui_hotlist_addurl_bounce(wimp_message *message)
/* There's no longer any need to listen for the next Null poll. */
- schedule_remove(ro_gui_hotlist_scheduled_callback, NULL);
+ riscos_schedule(-1, ro_gui_hotlist_scheduled_callback, NULL);
}
diff --git a/riscos/iconbar.c b/riscos/iconbar.c
index f6c0942..e0949b3 100644
--- a/riscos/iconbar.c
+++ b/riscos/iconbar.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <time.h>
#include <features.h>
+
#include "oslib/os.h"
#include "oslib/osbyte.h"
#include "oslib/wimp.h"
@@ -37,6 +38,7 @@
#include "riscos/global_history.h"
#include "riscos/hotlist.h"
#include "riscos/iconbar.h"
+#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "utils/nsoption.h"
#include "riscos/wimp_event.h"
@@ -133,8 +135,7 @@ bool ro_gui_iconbar_click(wimp_pointer *pointer)
/* create an initial browser window */
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -204,9 +205,7 @@ bool ro_gui_iconbar_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case HELP_OPEN_CONTENTS:
error = nsurl_create("http://www.netsurf-browser.org/documentation/", &url);
if (error == NSERROR_OK) {
- error = browser_window_create(
- BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/riscos/menus.c b/riscos/menus.c
index d8e2f2c..2ed06c3 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -31,15 +31,21 @@
#include "oslib/osgbpb.h"
#include "oslib/territory.h"
#include "oslib/wimp.h"
+
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "utils/utils.h"
+#include "utils/utf8.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/cookie_manager.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/textinput.h"
+
#include "riscos/dialog.h"
#include "riscos/configure.h"
#include "riscos/cookies.h"
@@ -56,11 +62,7 @@
#include "riscos/url_suggest.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "utils/utils.h"
-#include "utils/utf8.h"
+#include "riscos/ucstables.h"
struct menu_definition_entry {
menu_action action; /**< menu action */
diff --git a/riscos/mouse.c b/riscos/mouse.c
index a20965e..e934c1c 100644
--- a/riscos/mouse.c
+++ b/riscos/mouse.c
@@ -163,9 +163,11 @@ void ro_mouse_drag_end(wimp_dragged *dragged)
* Start tracking the mouse in a window, providing a function to be called on
* null polls and optionally one to be called when it leaves the window.
*
- * \param *drag_end Callback for when the pointer leaves the window, or
- * NULL for none.
- * \param *drag_track Callback for mouse tracking while the pointer remains
+ * \param *poll_end Callback for when the pointer leaves the window, or
+ * NULL for none. Claimants can receive *leaving==NULL if
+ * a new tracker is started before a PointerLeaving event
+ * is received.
+ * \param *poll_track Callback for mouse tracking while the pointer remains
* in the window, or NULL for none.
* \param *data Data to be passed to the callback functions, or NULL.
*/
@@ -175,12 +177,31 @@ void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
void *data)
{
/* It should never be possible for the mouse to be in two windows
- * at the same time!
+ * at the same time! However, some third-party extensions to RISC OS
+ * appear to make this possible (MouseAxess being one), so in the
+ * event that there's still a claimant we tidy them up first and then
+ * log the fact in case there are any unexpected consequences.
+ *
+ * NB: The Poll End callback will get called with *leaving == NULL in
+ * this situation, as there's no PointerLeaving event to pass on.
*/
- assert(ro_mouse_poll_end_callback == NULL &&
- ro_mouse_poll_track_callback == NULL &&
- ro_mouse_poll_data == NULL);
+ if (ro_mouse_poll_end_callback != NULL ||
+ ro_mouse_poll_track_callback != NULL ||
+ ro_mouse_poll_data != NULL) {
+ if (ro_mouse_poll_end_callback != NULL &&
+ ro_mouse_ignore_leaving_event == false)
+ ro_mouse_poll_end_callback(NULL, ro_mouse_poll_data);
+
+ LOG(("Unexpected mouse track termination."));
+
+ ro_mouse_ignore_leaving_event = false;
+ ro_mouse_poll_end_callback = NULL;
+ ro_mouse_poll_track_callback = NULL;
+ ro_mouse_poll_data = NULL;
+ }
+
+ /* Now record details of the new claimant. */
ro_mouse_poll_end_callback = poll_end;
ro_mouse_poll_track_callback = poll_track;
diff --git a/riscos/mouse.h b/riscos/mouse.h
index bcb3b50..8a7405a 100644
--- a/riscos/mouse.h
+++ b/riscos/mouse.h
@@ -65,9 +65,11 @@ void ro_mouse_drag_end(wimp_dragged *dragged);
* Start tracking the mouse in a window, providing a function to be called on
* null polls and optionally one to be called when it leaves the window.
*
- * \param *drag_end Callback for when the pointer leaves the window, or
- * NULL for none.
- * \param *drag_track Callback for mouse tracking while the pointer remains
+ * \param *poll_end Callback for when the pointer leaves the window, or
+ * NULL for none. Claimants can receive *leaving==NULL if
+ * a new tracker is started before a PointerLeaving event
+ * is received.
+ * \param *poll_track Callback for mouse tracking while the pointer remains
* in the window, or NULL for none.
* \param *data Data to be passed to the callback functions, or NULL.
*/
diff --git a/riscos/query.c b/riscos/query.c
index 2268494..2be2e2a 100644
--- a/riscos/query.c
+++ b/riscos/query.c
@@ -29,6 +29,7 @@
#include "utils/messages.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "riscos/ucstables.h"
#define ICON_QUERY_MESSAGE 0
#define ICON_QUERY_YES 1
diff --git a/riscos/save.c b/riscos/save.c
index cc12344..fa638d3 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -35,6 +35,13 @@
#include "oslib/osspriteop.h"
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
+
+#include "utils/config.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/url.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "desktop/hotlist.h"
@@ -43,8 +50,10 @@
#include "desktop/save_complete.h"
#include "desktop/save_text.h"
#include "desktop/thumbnail.h"
+#include "desktop/gui.h"
#include "image/bitmap.h"
#include "render/form.h"
+
#include "riscos/bitmap.h"
#include "riscos/dialog.h"
#include "riscos/gui.h"
@@ -60,12 +69,7 @@
#include "riscos/thumbnail.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
-#include "utils/config.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
+#include "riscos/ucstables.h"
//typedef enum
//{
diff --git a/riscos/save.h b/riscos/save.h
index 0c91766..7e509cf 100644
--- a/riscos/save.h
+++ b/riscos/save.h
@@ -27,7 +27,7 @@
#include "oslib/wimp.h"
#include "desktop/gui.h"
-void gui_drag_save_object(struct gui_window *g, hlcache_handle *c, gui_save_type save_type);
+void gui_drag_save_object(struct gui_window *g, struct hlcache_handle *c, gui_save_type save_type);
void gui_drag_save_selection(struct gui_window *g, const char *selection);
wimp_w ro_gui_saveas_create(const char *template_name);
diff --git a/riscos/schedule.c b/riscos/schedule.c
index 257f2e7..5129005 100644
--- a/riscos/schedule.c
+++ b/riscos/schedule.c
@@ -24,10 +24,11 @@
#include <stdbool.h>
#include <stdlib.h>
+
#include "oslib/os.h"
-#include "riscos/gui.h"
#include "utils/log.h"
-#include "utils/schedule.h"
+
+#include "riscos/gui.h"
/** Entry in the queue of scheduled callbacks. */
@@ -50,25 +51,53 @@ bool sched_active = false;
/** Time of soonest scheduled event (valid only if sched_active is true). */
os_t sched_time;
-
/**
- * Schedule a callback.
+ * Unschedule a callback.
*
- * \param t interval before the callback should be made / cs
* \param callback callback function
* \param p user parameter, passed to callback function
*
- * The callback function will be called as soon as possible after t cs have
- * passed.
+ * All scheduled callbacks matching both callback and p are removed.
*/
-void schedule(int t, void (*callback)(void *p), void *p)
+static nserror schedule_remove(void (*callback)(void *p), void *p)
+{
+ struct sched_entry *entry, *next;
+
+ for (entry = &sched_queue; entry->next; entry = entry->next) {
+ if (entry->next->callback != callback || entry->next->p != p)
+ continue;
+ next = entry->next;
+ entry->next = entry->next->next;
+ free(next);
+ if (!entry->next)
+ break;
+ }
+
+ if (sched_queue.next) {
+ sched_active = true;
+ sched_time = sched_queue.next->time;
+ } else {
+ sched_active = false;
+ }
+
+ return NSERROR_OK;
+}
+
+/* exported function documented in riscos/gui.h */
+nserror riscos_schedule(int t, void (*callback)(void *p), void *p)
{
struct sched_entry *entry;
struct sched_entry *queue;
os_t time;
+ nserror ret;
- schedule_remove(callback, p);
+ ret = schedule_remove(callback, p);
+ if ((t < 0) || (ret != NSERROR_OK)) {
+ return ret;
+ }
+
+ t = t / 10; /* convert to centiseconds */
time = os_read_monotonic_time() + t;
@@ -91,44 +120,12 @@ void schedule(int t, void (*callback)(void *p), void *p)
sched_active = true;
sched_time = sched_queue.next->time;
-}
-
-/**
- * Unschedule a callback.
- *
- * \param callback callback function
- * \param p user parameter, passed to callback function
- *
- * All scheduled callbacks matching both callback and p are removed.
- */
-
-void schedule_remove(void (*callback)(void *p), void *p)
-{
- struct sched_entry *entry, *next;
-
- for (entry = &sched_queue; entry->next; entry = entry->next) {
- if (entry->next->callback != callback || entry->next->p != p)
- continue;
- next = entry->next;
- entry->next = entry->next->next;
- free(next);
- if (!entry->next)
- break;
- }
-
- if (sched_queue.next) {
- sched_active = true;
- sched_time = sched_queue.next->time;
- } else
- sched_active = false;
+ return NSERROR_OK;
}
-/**
- * Process events up to current time.
- */
-
+/* exported function documented in riscos/gui.h */
bool schedule_run(void)
{
struct sched_entry *entry;
@@ -144,8 +141,9 @@ bool schedule_run(void)
p = entry->p;
sched_queue.next = entry->next;
free(entry);
- /* The callback may call schedule() or schedule_remove(), so
- * leave the queue in a safe state. */
+ /* The callback may call riscos_schedule(), so leave
+ * the queue in a safe state.
+ */
callback(p);
}
diff --git a/riscos/search.c b/riscos/search.c
index 3d3b7ba..230edc2 100644
--- a/riscos/search.c
+++ b/riscos/search.c
@@ -76,14 +76,16 @@ static void ro_gui_search_set_status(bool found, void *p);
static void ro_gui_search_set_hourglass(bool active, void *p);
static void ro_gui_search_add_recent(const char *string, void *p);
-static struct gui_search_callbacks ro_gui_search_callbacks = {
- ro_gui_search_set_forward_state,
- ro_gui_search_set_back_state,
+static struct gui_search_table search_table = {
ro_gui_search_set_status,
ro_gui_search_set_hourglass,
- ro_gui_search_add_recent
+ ro_gui_search_add_recent,
+ ro_gui_search_set_forward_state,
+ ro_gui_search_set_back_state,
};
+struct gui_search_table *riscos_search_table = &search_table;
+
void ro_gui_search_init(void)
{
dialog_search = ro_gui_dialog_create("search");
@@ -122,8 +124,7 @@ bool ro_gui_search_next(wimp_w w)
search_data.search_insert = true;
search_flags_t flags = SEARCH_FLAG_FORWARDS |
ro_gui_search_update_flags();
- browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL, flags,
+ browser_window_search(search_data.search_window, NULL, flags,
ro_gui_get_icon_string(dialog_search,
ICON_SEARCH_TEXT));
return false;
@@ -163,8 +164,7 @@ bool ro_gui_search_click(wimp_pointer *pointer)
search_data.search_insert = true;
flags = ~SEARCH_FLAG_FORWARDS &
ro_gui_search_update_flags();
- browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL,
+ browser_window_search(search_data.search_window, NULL,
flags,
ro_gui_get_icon_string(dialog_search,
ICON_SEARCH_TEXT));
@@ -172,8 +172,7 @@ bool ro_gui_search_click(wimp_pointer *pointer)
case ICON_SEARCH_CASE_SENSITIVE:
flags = SEARCH_FLAG_FORWARDS |
ro_gui_search_update_flags();
- browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL,
+ browser_window_search(search_data.search_window, NULL,
flags,
ro_gui_get_icon_string(dialog_search,
ICON_SEARCH_TEXT));
@@ -182,8 +181,7 @@ bool ro_gui_search_click(wimp_pointer *pointer)
flags = ro_gui_get_icon_selected_state(
pointer->w, pointer->i) ?
SEARCH_FLAG_SHOWALL : SEARCH_FLAG_NONE;
- browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL,
+ browser_window_search(search_data.search_window, NULL,
flags,
ro_gui_get_icon_string(dialog_search,
ICON_SEARCH_TEXT));
@@ -313,8 +311,7 @@ bool ro_gui_search_keypress(wimp_key *key)
case 1: {
flags = ro_gui_search_update_flags()
^ SEARCH_FLAG_SHOWALL;
- browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL,
+ browser_window_search(search_data.search_window, NULL,
flags,
ro_gui_get_icon_string(dialog_search,
ICON_SEARCH_TEXT));
@@ -327,8 +324,7 @@ bool ro_gui_search_keypress(wimp_key *key)
ICON_SEARCH_CASE_SENSITIVE, !state);
flags = SEARCH_FLAG_FORWARDS |
ro_gui_search_update_flags();
- browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL,
+ browser_window_search(search_data.search_window, NULL,
flags,
ro_gui_get_icon_string(dialog_search,
ICON_SEARCH_TEXT));
@@ -337,8 +333,7 @@ bool ro_gui_search_keypress(wimp_key *key)
search_data.search_insert = true;
flags = ~SEARCH_FLAG_FORWARDS &
ro_gui_search_update_flags();
- browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL,
+ browser_window_search(search_data.search_window, NULL,
flags,
ro_gui_get_icon_string(dialog_search,
ICON_SEARCH_TEXT));
@@ -347,8 +342,7 @@ bool ro_gui_search_keypress(wimp_key *key)
search_data.search_insert = true;
flags = SEARCH_FLAG_FORWARDS |
ro_gui_search_update_flags();
- browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL,
+ browser_window_search(search_data.search_window, NULL,
flags,
ro_gui_get_icon_string(dialog_search,
ICON_SEARCH_TEXT));
@@ -360,10 +354,6 @@ bool ro_gui_search_keypress(wimp_key *key)
* a new search */
browser_window_search_clear(
search_data.search_window);
- ro_gui_search_set_forward_state(true,
- search_data.search_window);
- ro_gui_search_set_back_state(true,
- search_data.search_window);
search_data.search_insert = true;
}
if (key->c == 8 || /* backspace */
@@ -376,7 +366,7 @@ bool ro_gui_search_keypress(wimp_key *key)
ro_gui_search_set_back_state(true,
search_data.search_window);
browser_window_search(search_data.search_window,
- &ro_gui_search_callbacks, NULL,
+ NULL,
flags,
ro_gui_get_icon_string(
dialog_search,
@@ -396,8 +386,6 @@ bool ro_gui_search_keypress(wimp_key *key)
void ro_gui_search_end(wimp_w w)
{
browser_window_search_clear(search_data.search_window);
- ro_gui_search_set_forward_state(true, search_data.search_window);
- ro_gui_search_set_back_state(true, search_data.search_window);
}
/**
diff --git a/riscos/textselection.c b/riscos/textselection.c
index c070754..5215a62 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -25,25 +25,28 @@
#include <string.h>
#include "oslib/osfile.h"
#include "oslib/wimp.h"
+
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
#include "content/hlcache.h"
#include "desktop/gui.h"
#include "desktop/textinput.h"
+
#include "riscos/gui.h"
#include "riscos/menus.h"
#include "riscos/message.h"
#include "riscos/mouse.h"
#include "riscos/save.h"
#include "riscos/textselection.h"
-#include "utils/log.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
+#include "riscos/ucstables.h"
+
#ifndef wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX
#define wimp_DRAG_CLAIM_SUPPRESS_DRAGBOX ((wimp_drag_claim_flags) 0x2u)
#endif
-
/** Receive of Dragging message has claimed it */
static bool dragging_claimed = false;
static wimp_t dragging_claimant;
@@ -194,7 +197,7 @@ static void ro_gui_selection_drag_end(wimp_dragged *drag, void *data)
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
-void gui_set_clipboard(const char *buffer, size_t length,
+static void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles)
{
char *new_cb;
@@ -245,7 +248,7 @@ void gui_set_clipboard(const char *buffer, size_t length,
* \param buffer UTF-8 text, allocated by front end, ownership yielded to core
* \param length Byte length of UTF-8 text in buffer
*/
-void gui_get_clipboard(char **buffer, size_t *length)
+static void gui_get_clipboard(char **buffer, size_t *length)
{
*buffer = NULL;
*length = 0;
@@ -652,3 +655,10 @@ void ro_gui_dragging_bounced(wimp_message *message)
{
dragging_claimed = false;
}
+
+static struct gui_clipboard_table clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+struct gui_clipboard_table *riscos_clipboard_table = &clipboard_table;
diff --git a/riscos/textselection.h b/riscos/textselection.h
index a4f436d..400e3dd 100644
--- a/riscos/textselection.h
+++ b/riscos/textselection.h
@@ -24,7 +24,8 @@
#define _NETSURF_RISCOS_TEXTSELECTION_H_
#include "oslib/wimp.h"
-#include "desktop/gui.h"
+
+struct gui_clipboard_table *riscos_clipboard_table;
void gui_start_selection(struct gui_window *g);
diff --git a/riscos/toolbar.c b/riscos/toolbar.c
index 93c4438..d64db2d 100644
--- a/riscos/toolbar.c
+++ b/riscos/toolbar.c
@@ -1579,7 +1579,7 @@ bool ro_toolbar_set_button_order(struct toolbar *toolbar, char order[])
void ro_toolbar_set_button_shaded_state(struct toolbar *toolbar,
button_bar_action action, bool shaded)
{
- if (toolbar == NULL && toolbar->buttons == NULL)
+ if (toolbar == NULL || toolbar->buttons == NULL)
return;
ro_gui_button_bar_shade_button(toolbar->buttons, action, shaded);
@@ -1686,7 +1686,7 @@ void ro_toolbar_set_content_favicon(struct toolbar *toolbar,
void ro_toolbar_update_urlsuggest(struct toolbar *toolbar)
{
- if (toolbar != NULL && toolbar->url != NULL)
+ if (toolbar == NULL || toolbar->url == NULL)
return;
ro_gui_url_bar_update_urlsuggest(toolbar->url);
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 4cf3d42..0c16626 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -435,14 +435,15 @@ void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more)
};
while (more) {
- ro_plot_origin_x = redraw->box.x0 + tv->origin.x -
- redraw->xscroll;
- ro_plot_origin_y = redraw->box.y1 + tv->origin.y -
- redraw->yscroll;
if (tv != NULL && tv->tree != NULL) {
struct rect clip;
+ ro_plot_origin_x = redraw->box.x0 + tv->origin.x -
+ redraw->xscroll;
+ ro_plot_origin_y = redraw->box.y1 + tv->origin.y -
+ redraw->yscroll;
+
clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
clip.y0 = (ro_plot_origin_y - redraw->clip.y1) / 2;
diff --git a/riscos/ucstables.c b/riscos/ucstables.c
index b9f196d..f9b6b36 100644
--- a/riscos/ucstables.c
+++ b/riscos/ucstables.c
@@ -27,10 +27,13 @@
#include <oslib/territory.h>
#include "utils/config.h"
-#include "riscos/ucstables.h"
+#include "utils/errors.h"
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "desktop/gui.h"
+
+#include "riscos/ucstables.h"
/* Common values (ASCII) */
#define common \
@@ -478,7 +481,7 @@ nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
/* get encoding name */
enc = (alphabet <= CONT_ENC_END ? localencodings[alphabet - 100]
: (alphabet == 120 ?
- localencodings[CONT_ENC_END + 1]
+ localencodings[CONT_ENC_END - 100 + 1]
: localencodings[0]));
/* create output buffer */
@@ -588,7 +591,7 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
/* get encoding name */
enc = (alphabet <= CONT_ENC_END ? localencodings[alphabet - 100]
: (alphabet == 120 ?
- localencodings[CONT_ENC_END + 1]
+ localencodings[CONT_ENC_END - 100 + 1]
: localencodings[0]));
/* create output buffer (oversized) */
@@ -684,3 +687,10 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
return NSERROR_OK;
}
+
+static struct gui_utf8_table utf8_table = {
+ .utf8_to_local = utf8_to_local_encoding,
+ .local_to_utf8 = utf8_from_local_encoding,
+};
+
+struct gui_utf8_table *riscos_utf8_table = &utf8_table;
diff --git a/riscos/ucstables.h b/riscos/ucstables.h
index 0be0658..e5d8382 100644
--- a/riscos/ucstables.h
+++ b/riscos/ucstables.h
@@ -21,4 +21,9 @@
* This is only used if nothing claims Service_International,8
*/
+struct gui_utf8_table *riscos_utf8_table;
+
+nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
+
const int *ucstable_from_alphabet(int alphabet);
diff --git a/riscos/uri.c b/riscos/uri.c
index 70f75bc..bf789ee 100644
--- a/riscos/uri.c
+++ b/riscos/uri.c
@@ -74,8 +74,7 @@ void ro_uri_message_received(wimp_message *msg)
error = nsurl_create(uri_requested, &url);
free(uri_requested);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/riscos/url_complete.c b/riscos/url_complete.c
index 01774f6..4a5d2d5 100644
--- a/riscos/url_complete.c
+++ b/riscos/url_complete.c
@@ -734,8 +734,7 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer)
browser_window_navigate(g->bw,
url_complete_matches[url_complete_matches_selection],
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
diff --git a/riscos/url_protocol.c b/riscos/url_protocol.c
index 171b620..76d4031 100644
--- a/riscos/url_protocol.c
+++ b/riscos/url_protocol.c
@@ -126,8 +126,7 @@ void ro_url_message_received(wimp_message *message)
}
/* create new browser window */
- errorns = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ errorns = browser_window_create(BW_CREATE_HISTORY,
nsurl,
NULL,
NULL,
diff --git a/riscos/wimp.c b/riscos/wimp.c
index 2e48891..f59fa67 100644
--- a/riscos/wimp.c
+++ b/riscos/wimp.c
@@ -40,6 +40,7 @@
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "riscos/ucstables.h"
static void ro_gui_wimp_cache_furniture_sizes(wimp_w w);
diff --git a/riscos/window.c b/riscos/window.c
index b7146eb..771f3f5 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -40,16 +40,24 @@
#include "oslib/osspriteop.h"
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
+
#include "utils/config.h"
+#include "utils/nsoption.h"
+#include "utils/log.h"
+#include "utils/talloc.h"
+#include "utils/url.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
+#include "utils/messages.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "css/css.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
#include "desktop/cookie_manager.h"
#include "desktop/scrollbar.h"
#include "desktop/frames.h"
-#include "desktop/local_history.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
#include "desktop/textinput.h"
@@ -58,6 +66,7 @@
#include "desktop/gui.h"
#include "render/form.h"
#include "render/html.h"
+
#include "riscos/bitmap.h"
#include "riscos/buffer.h"
#include "riscos/cookies.h"
@@ -69,7 +78,6 @@
#include "riscos/hotlist.h"
#include "riscos/menus.h"
#include "riscos/mouse.h"
-#include "utils/nsoption.h"
#include "riscos/oslib_pre7.h"
#include "riscos/save.h"
#include "riscos/content-handlers/sprite.h"
@@ -82,12 +90,7 @@
#include "riscos/wimp_event.h"
#include "riscos/wimputils.h"
#include "riscos/window.h"
-#include "utils/log.h"
-#include "utils/talloc.h"
-#include "utils/url.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
-#include "utils/messages.h"
+#include "riscos/ucstables.h"
void gui_window_redraw_window(struct gui_window *g);
@@ -132,8 +135,6 @@ static bool ro_gui_window_navigate_up(struct gui_window *g, const char *url);
static void ro_gui_window_action_home(struct gui_window *g);
static void ro_gui_window_action_new_window(struct gui_window *g);
static void ro_gui_window_action_local_history(struct gui_window *g);
-static void ro_gui_window_action_navigate_back_new(struct gui_window *g);
-static void ro_gui_window_action_navigate_forward_new(struct gui_window *g);
static void ro_gui_window_action_save(struct gui_window *g,
gui_save_type save_type);
static void ro_gui_window_action_search(struct gui_window *g);
@@ -151,8 +152,9 @@ static void ro_gui_window_update_theme(void *data, bool ok);
static bool ro_gui_window_import_text(struct gui_window *g,
const char *filename);
-static void ro_gui_window_clone_options(struct browser_window *new_bw,
- struct browser_window *old_bw);
+static void ro_gui_window_clone_options(
+ struct gui_window *new_gui,
+ struct gui_window *old_gui);
static bool ro_gui_window_prepare_form_select_menu(struct browser_window *bw,
struct form_control *control);
@@ -399,13 +401,15 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
/**
* Create and open a new browser window.
*
- * \param bw browser_window structure to update
- * \param clone the browser window to clone options from, or NULL for default
- * \return gui_window, or 0 on error and error reported
+ * \param bw bw to create gui_window for
+ * \param existing an existing gui_window, may be NULL
+ * \param flags flags for gui window creation
+ * \return gui window, or NULL on error
*/
static struct gui_window *gui_window_create(struct browser_window *bw,
- struct browser_window *clone, bool new_tab)
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
int screen_width, screen_height, win_width, win_height, scroll_width;
static int window_count = 2;
@@ -414,7 +418,6 @@ static struct gui_window *gui_window_create(struct browser_window *bw,
os_error *error;
bool open_centred = true;
struct gui_window *g;
- struct browser_window *top;
g = malloc(sizeof *g);
if (!g) {
@@ -431,9 +434,10 @@ static struct gui_window *gui_window_create(struct browser_window *bw,
g->iconise_icon = -1;
/* Set the window position */
- if (clone && clone->window && nsoption_bool(window_size_clone)) {
- for (top = clone; top->parent; top = top->parent);
- state.w = top->window->window;
+ if (existing != NULL &&
+ flags & GW_CREATE_CLONE &&
+ nsoption_bool(window_size_clone)) {
+ state.w = existing->window;
error = xwimp_get_window_state(&state);
if (error) {
LOG(("xwimp_get_window_state: 0x%x: %s",
@@ -592,7 +596,8 @@ static struct gui_window *gui_window_create(struct browser_window *bw,
/* Set the window options */
bw->window = g;
- ro_gui_window_clone_options(bw, clone);
+ bw->scale = ((float)nsoption_int(scale)) / 100;
+ ro_gui_window_clone_options(g, existing);
ro_gui_window_update_toolbar_buttons(g);
/* Open the window at the top of the stack */
@@ -731,8 +736,8 @@ void gui_window_redraw_window(struct gui_window *g)
/**
* Redraw an area of a window.
*
- * \param g gui_window
- * \param data content_msg_data union with filled in redraw data
+ * \param g The window to update
+ * \param rect The area of the window to update.
*/
static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
@@ -1292,8 +1297,9 @@ static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
/**
* Save the specified content as a link.
*
- * \param g gui_window containing the content
- * \param c the content to save
+ * \param g The window containing the content
+ * \param url The url of the link
+ * \param title The title of the link
*/
static void gui_window_save_link(struct gui_window *g, const char *url,
const char *title)
@@ -1315,11 +1321,9 @@ void gui_window_set_extent(struct gui_window *g, int width, int height)
{
int screen_width;
int toolbar_height = 0;
- hlcache_handle *h;
wimp_window_state state;
os_error *error;
- h = g->bw->current_content;
if (g->toolbar)
toolbar_height = ro_toolbar_full_height(g->toolbar);
@@ -1351,9 +1355,11 @@ void gui_window_set_extent(struct gui_window *g, int width, int height)
height -= ro_get_hscroll_height(g->window);
height -= ro_get_title_height(g->window);
}
- if (h) {
- width = max(width, content_get_width(h) * 2 * g->bw->scale);
- height = max(height, content_get_height(h) * 2 * g->bw->scale);
+ if (browser_window_has_content(g->bw)) {
+ int w, h;
+ browser_window_get_extents(g->bw, true, &w, &h);
+ width = max(width, w * 2);
+ height = max(height, h * 2);
}
os_box extent = { 0, -height, width, toolbar_height };
error = xwimp_set_extent(g->window, &extent);
@@ -1774,15 +1780,12 @@ bool ro_gui_window_click(wimp_pointer *pointer)
bool ro_gui_window_keypress(wimp_key *key)
{
struct gui_window *g;
- hlcache_handle *h;
uint32_t c = (uint32_t) key->c;
g = (struct gui_window *) ro_gui_wimp_event_get_user_data(key->w);
if (g == NULL)
return false;
- h = g->bw->current_content;
-
/* First send the key to the browser window, eg. form fields. */
if ((unsigned)c < 0x20 || (0x7f <= c && c <= 0x9f) ||
@@ -1920,8 +1923,7 @@ bool ro_gui_window_handle_local_keypress(struct gui_window *g, wimp_key *key,
{
error = nsurl_create("http://www.netsurf-browser.org/documentation/", &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2402,9 +2404,9 @@ bool ro_gui_window_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_menu_set_entry_shaded(menu, HOTLIST_ADD_URL, h == NULL);
ro_gui_menu_set_entry_shaded(menu, HISTORY_SHOW_LOCAL,
- (bw == NULL || (bw->history == NULL) ||
- !(h != NULL || history_back_available(bw->history) ||
- history_forward_available(bw->history))));
+ (bw == NULL ||
+ !(h != NULL || browser_window_back_available(bw) ||
+ browser_window_forward_available(bw))));
/* Help Submenu */
@@ -2670,8 +2672,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case HELP_OPEN_CONTENTS:
error = nsurl_create("http://www.netsurf-browser.org/documentation/", &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2683,8 +2684,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case HELP_OPEN_GUIDE:
error = nsurl_create("http://www.netsurf-browser.org/documentation/guide", &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2696,8 +2696,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case HELP_OPEN_INFORMATION:
error = nsurl_create("http://www.netsurf-browser.org/documentation/info", &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2709,8 +2708,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case HELP_OPEN_CREDITS:
error = nsurl_create("about:credits", &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2722,8 +2720,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
case HELP_OPEN_LICENCE:
error = nsurl_create("about:licence", &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -2834,8 +2831,7 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
error = browser_window_navigate(bw,
url,
hlcache_handle_get_url(h),
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_DOWNLOAD,
NULL,
NULL,
NULL);
@@ -2848,8 +2844,9 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
if (current_menu_url != NULL) {
error = nsurl_create(current_menu_url, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(
+ BW_CREATE_HISTORY |
+ BW_CREATE_CLONE,
url,
hlcache_handle_get_url(h),
bw,
@@ -2941,12 +2938,12 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_window_action_home(g);
break;
case BROWSER_NAVIGATE_BACK:
- if (bw != NULL && bw->history != NULL)
- history_back(bw, bw->history);
+ if (bw != NULL)
+ browser_window_history_back(bw, false);
break;
case BROWSER_NAVIGATE_FORWARD:
- if (bw != NULL && bw->history != NULL)
- history_forward(bw, bw->history);
+ if (bw != NULL)
+ browser_window_history_forward(bw, false);
break;
case BROWSER_NAVIGATE_UP:
if (bw != NULL && h != NULL)
@@ -3106,7 +3103,7 @@ void ro_gui_window_scroll(wimp_scroll *scroll)
inc = 0.02; /* RO5 sends the msg 5 times;
* don't ask me why
*
- * \TODO -- this is liable to break if
+ * @todo this is liable to break if
* HID is configured optimally for
* frame scrolling. *5 appears to be
* an artifact of non-HID mode scrolling.
@@ -3639,21 +3636,23 @@ void ro_gui_window_toolbar_click(void *data,
switch (action.button) {
case TOOLBAR_BUTTON_BACK:
- if (g->bw != NULL && g->bw->history != NULL)
- history_back(g->bw, g->bw->history);
+ if (g->bw != NULL)
+ browser_window_history_back(g->bw, false);
break;
case TOOLBAR_BUTTON_BACK_NEW:
- ro_gui_window_action_navigate_back_new(g);
+ if (g->bw != NULL)
+ browser_window_history_back(g->bw, true);
break;
case TOOLBAR_BUTTON_FORWARD:
- if (g->bw != NULL && g->bw->history != NULL)
- history_forward(g->bw, g->bw->history);
+ if (g->bw != NULL)
+ browser_window_history_forward(g->bw, false);
break;
case TOOLBAR_BUTTON_FORWARD_NEW:
- ro_gui_window_action_navigate_forward_new(g);
+ if (g->bw != NULL)
+ browser_window_history_forward(g->bw, true);
break;
case TOOLBAR_BUTTON_STOP:
@@ -3723,7 +3722,8 @@ void ro_gui_window_toolbar_click(void *data,
hlcache_handle *h = g->bw->current_content;
nserror error;
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ error = browser_window_create(
+ BW_CREATE_HISTORY | BW_CREATE_CLONE,
NULL,
NULL,
g->bw,
@@ -3752,8 +3752,8 @@ void ro_gui_window_toolbar_click(void *data,
/**
* Handle Message_DataLoad (file dragged in) for a toolbar
*
- * \TODO -- This belongs in the toolbar module, and should be moved there
- * once the module is able to usefully handle its own events.
+ * @todo This belongs in the toolbar module, and should be moved there
+ * once the module is able to usefully handle its own events.
*
* \param g window
* \param message Message_DataLoad block
@@ -4005,8 +4005,7 @@ void ro_gui_window_launch_url(struct gui_window *g, const char *url1)
browser_window_navigate(g->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY | BW_NAVIGATE_UNVERIFIABLE,
NULL,
NULL,
NULL);
@@ -4046,8 +4045,7 @@ bool ro_gui_window_navigate_up(struct gui_window *g, const char *url)
browser_window_navigate(g->bw,
parent,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -4083,8 +4081,7 @@ void ro_gui_window_action_home(struct gui_window *g)
error = browser_window_navigate(g->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -4097,62 +4094,6 @@ void ro_gui_window_action_home(struct gui_window *g)
/**
- * Navigate back from a browser window into a new window.
- *
- * \param *g The browser window to act on.
- */
-
-void ro_gui_window_action_navigate_back_new(struct gui_window *g)
-{
- struct browser_window *new_bw;
- nserror error;
-
- if (g == NULL || g->bw == NULL)
- return;
-
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- g->bw,
- &new_bw);
-
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- history_back(new_bw, new_bw->history);
- }
-}
-
-
-/**
- * Navigate forward from a browser window into a new window.
- *
- * \param *g The browser window to act on.
- */
-
-void ro_gui_window_action_navigate_forward_new(struct gui_window *g)
-{
- struct browser_window *new_bw;
- nserror error;
-
- if (g == NULL || g->bw == NULL)
- return;
-
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- g->bw,
- &new_bw);
-
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- history_forward(new_bw, new_bw->history);
- }
-}
-
-
-/**
* Open a new browser window.
*
* \param *g The browser window to act on.
@@ -4165,7 +4106,7 @@ void ro_gui_window_action_new_window(struct gui_window *g)
if (g == NULL || g->bw == NULL || g->bw->current_content == NULL)
return;
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ error = browser_window_create(BW_CREATE_CLONE,
hlcache_handle_get_url(g->bw->current_content),
NULL,
g->bw,
@@ -4186,7 +4127,7 @@ void ro_gui_window_action_new_window(struct gui_window *g)
void ro_gui_window_action_local_history(struct gui_window *g)
{
if (g != NULL && g->bw != NULL && g->bw->history != NULL)
- ro_gui_history_open(g->bw, g->bw->history, true);
+ ro_gui_history_open(g, true);
}
@@ -4607,11 +4548,10 @@ void ro_gui_window_update_theme(void *data, bool ok)
*/
/**
- * Import text file into window or its toolbar
+ * Import text file into window
*
* \param g gui window containing textarea
* \param filename pathname of file to be imported
- * \param toolbar true iff imported to toolbar rather than main window
* \return true iff successful
*/
@@ -4689,29 +4629,19 @@ bool ro_gui_window_import_text(struct gui_window *g, const char *filename)
/**
* Clones a browser window's options.
*
- * \param new_bw the new browser window
- * \param old_bw the browser window to clone from, or NULL for default
+ * \param new_gui the new gui window
+ * \param old_gui the gui window to clone from, or NULL for default
*/
-void ro_gui_window_clone_options(struct browser_window *new_bw,
- struct browser_window *old_bw)
+void ro_gui_window_clone_options(
+ struct gui_window *new_gui,
+ struct gui_window *old_gui)
{
- struct gui_window *old_gui = NULL;
- struct gui_window *new_gui;
-
- assert(new_bw);
-
- /* Get our GUIs
- */
- new_gui = new_bw->window;
-
- if (old_bw)
- old_gui = old_bw->window;
+ assert(new_gui);
/* Clone the basic options
*/
if (!old_gui) {
- new_bw->scale = ((float)nsoption_int(scale)) / 100;
new_gui->option.buffer_animations = nsoption_bool(buffer_animations);
new_gui->option.buffer_everything = nsoption_bool(buffer_everything);
} else {
@@ -4915,9 +4845,7 @@ void ro_gui_window_process_form_select_menu(struct gui_window *g,
assert(g != NULL);
if (selection->items[0] >= 0)
- form_select_process_selection(
- ro_gui_select_menu_bw->current_content,
- gui_form_select_control,
+ form_select_process_selection(gui_form_select_control,
selection->items[0]);
}
@@ -4946,8 +4874,8 @@ struct gui_window *ro_gui_window_lookup(wimp_w window)
/**
* Convert a toolbar RISC OS window handle to a gui_window.
*
- * \param w RISC OS window handle of a toolbar
- * \return pointer to a structure if found, 0 otherwise
+ * \param window RISC OS window handle of a toolbar
+ * \return pointer to a structure if found, NULL otherwise
*/
struct gui_window *ro_gui_toolbar_lookup(wimp_w window)
diff --git a/test/Makefile b/test/Makefile
index ecd2b50..acf9d4e 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -22,9 +22,9 @@ urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) -O2
urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
-nsurl_SRCS := utils/log.c utils/nsurl.c test/nsurl.c
-nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet)
-nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet)
+nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c test/nsurl.c
+nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom)
+nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
nsoption_CFLAGS := -Dnsgtk
diff --git a/test/nsurl.c b/test/nsurl.c
index 66bc057..3e859d9 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -6,12 +6,10 @@
#include <libwapcaplet/libwapcaplet.h>
#include "desktop/netsurf.h"
+#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/nsurl.h"
-/* desktop/netsurf.h */
-bool verbose_log = true;
-
struct test_pairs {
const char* test;
const char* res;
@@ -30,9 +28,10 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw)
}
static const struct test_pairs create_tests[] = {
- { "http:", "http:" },
- { "http:/", "http:" },
- { "http://", "http:" },
+ { "", NULL },
+ { "http:", NULL },
+ { "http:/", NULL },
+ { "http://", NULL },
{ "http:a", "http://a/" },
{ "http:a/", "http://a/" },
{ "http:a/b", "http://a/b" },
@@ -182,6 +181,13 @@ int main(void)
const struct test_triplets *ttest;
int passed = 0;
int count = 0;
+ nserror err;
+
+ verbose_log = true;
+
+ if (corestrings_init() != NSERROR_OK) {
+ assert(0 && "Failed to init corestrings.");
+ }
/* Create base URL */
if (nsurl_create("http://a/b/c/d;p?q", &base) != NSERROR_OK) {
@@ -228,8 +234,22 @@ int main(void)
/* Create tests */
LOG(("Testing nsurl_create"));
for (test = create_tests; test->test != NULL; test++) {
- if (nsurl_create(test->test, &base) != NSERROR_OK) {
- LOG(("Failed to create URL:\n\t\t%s.", test->test));
+ err = nsurl_create(test->test, &base);
+ if (err != NSERROR_OK || test->res == NULL) {
+ if (test->res == NULL && err != NSERROR_OK) {
+ LOG(("\tPASS: \"%s\"\t--> BAD INPUT",
+ test->test));
+ passed++;
+ } else if (test->res != NULL && err != NSERROR_OK) {
+ LOG(("Failed to create URL:\n\t\t%s.",
+ test->test));
+ } else {
+ LOG(("\tFAIL: \"%s\"\t--> %s",
+ test->test, nsurl_access(base)));
+ LOG(("\t\tExpecting BAD INPUT"));
+ }
+ if (err == NSERROR_OK)
+ nsurl_unref(base);
} else {
if (strcmp(nsurl_access(base), test->res) == 0) {
LOG(("\tPASS: \"%s\"\t--> %s",
@@ -286,6 +306,8 @@ int main(void)
LOG(("Failed %d out of %d", count - passed, count));
}
+ corestrings_fini();
+
LOG(("Remaining lwc strings:"));
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
diff --git a/utils/corestrings.c b/utils/corestrings.c
index c51a38f..db6d72e 100644
--- a/utils/corestrings.c
+++ b/utils/corestrings.c
@@ -268,6 +268,9 @@ dom_string *corestring_dom___ns_key_libcss_node_data;
dom_string *corestring_dom___ns_key_file_name_node_data;
dom_string *corestring_dom___ns_key_image_coords_node_data;
+/* nsurl URLs */
+nsurl *corestring_nsurl_about_blank;
+
/*
* Free the core strings
*/
@@ -535,6 +538,10 @@ void corestrings_fini(void)
CSS_DOM_STRING_UNREF(__ns_key_file_name_node_data);
CSS_DOM_STRING_UNREF(__ns_key_image_coords_node_data);
#undef CSS_DOM_STRING_UNREF
+
+ /* nsurl URLs */
+ if (corestring_nsurl_about_blank != NULL)
+ nsurl_unref(corestring_nsurl_about_blank);
}
@@ -856,6 +863,11 @@ nserror corestrings_init(void)
goto error;
}
+ error = nsurl_create("about:blank", &corestring_nsurl_about_blank);
+ if (error != NSERROR_OK) {
+ goto error;
+ }
+
return NSERROR_OK;
error:
diff --git a/utils/corestrings.h b/utils/corestrings.h
index 1f34ada..2a1f88b 100644
--- a/utils/corestrings.h
+++ b/utils/corestrings.h
@@ -24,6 +24,7 @@
#define NETSURF_UTILS_CORESTRINGS_H_
#include <libwapcaplet/libwapcaplet.h>
+#include "utils/nsurl.h"
#include "utils/errors.h"
nserror corestrings_init(void);
@@ -279,5 +280,7 @@ extern struct dom_string *corestring_dom___ns_key_libcss_node_data;
extern struct dom_string *corestring_dom___ns_key_file_name_node_data;
extern struct dom_string *corestring_dom___ns_key_image_coords_node_data;
+/* URLs */
+extern nsurl *corestring_nsurl_about_blank;
#endif
diff --git a/utils/errors.h b/utils/errors.h
index 244de0a..c38e4b9 100644
--- a/utils/errors.h
+++ b/utils/errors.h
@@ -67,6 +67,8 @@ typedef enum {
NSERROR_BAD_URL, /**< Bad URL */
+ NSERROR_BAD_CONTENT, /**< Bad Content */
+
NSERROR_FRAME_DEPTH /**< Exceeded frame depth */
} nserror;
diff --git a/utils/libdom.c b/utils/libdom.c
index a1465af..245c9b2 100644
--- a/utils/libdom.c
+++ b/utils/libdom.c
@@ -50,58 +50,42 @@ bool libdom_treewalk(dom_node *root,
break;
}
- if (next != NULL) { /* 1. children */
+ if (next != NULL) {
+ /* 1. Got children */
dom_node_unref(node);
node = next;
} else {
- exc = dom_node_get_next_sibling(node, &next);
- if (exc != DOM_NO_ERR) {
- dom_node_unref(node);
- break;
- }
-
- if (next != NULL) { /* 2. siblings */
- dom_node_unref(node);
- node = next;
- } else { /* 3. ancestor siblings */
- while (node != NULL) {
- exc = dom_node_get_next_sibling(node,
- &next);
- if (exc != DOM_NO_ERR) {
- dom_node_unref(node);
- node = NULL;
- break;
- }
-
- if (next != NULL) {
- dom_node_unref(next);
- break;
- }
-
- exc = dom_node_get_parent_node(node,
- &next);
- if (exc != DOM_NO_ERR) {
- dom_node_unref(node);
- node = NULL;
- break;
- }
-
+ /* No children; siblings & ancestor's siblings */
+ while (node != NULL) {
+ exc = dom_node_get_next_sibling(node, &next);
+ if (exc != DOM_NO_ERR) {
dom_node_unref(node);
- node = next;
+ node = NULL;
+ break;
}
- if (node == NULL)
+ if (next != NULL) {
+ /* 2. Got sibling */
break;
+ }
- exc = dom_node_get_next_sibling(node, &next);
+ exc = dom_node_get_parent_node(node, &next);
if (exc != DOM_NO_ERR) {
dom_node_unref(node);
+ node = NULL;
break;
}
+ /* 3. Try parent */
dom_node_unref(node);
node = next;
}
+
+ if (node == NULL)
+ break;
+
+ dom_node_unref(node);
+ node = next;
}
assert(node != NULL);
diff --git a/utils/log.c b/utils/log.c
index 2aa39ee..8ec42c1 100644
--- a/utils/log.c
+++ b/utils/log.c
@@ -23,10 +23,11 @@
#include <stdarg.h>
#include <stdio.h>
#include <sys/time.h>
-#include "desktop/netsurf.h"
#include "utils/log.h"
+bool verbose_log = false;
+
nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
{
nserror ret = NSERROR_OK;
diff --git a/utils/log.h b/utils/log.h
index ed953f3..673419b 100644
--- a/utils/log.h
+++ b/utils/log.h
@@ -21,9 +21,12 @@
#define _NETSURF_LOG_H_
#include <stdio.h>
-#include "desktop/netsurf.h"
+#include <stdbool.h>
+
#include "utils/errors.h"
+extern bool verbose_log;
+
/**
* Ensures the FILE handle is available to write logging to.
*
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 77cbc6d..c99b0d3 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1221,6 +1221,39 @@ static void nsurl_calc_hash(nsurl *url)
}
+/**
+ * Destroy components
+ *
+ * \param c url components
+ */
+static void nsurl_destroy_components(struct nsurl_components *c)
+{
+ if (c->scheme)
+ lwc_string_unref(c->scheme);
+
+ if (c->username)
+ lwc_string_unref(c->username);
+
+ if (c->password)
+ lwc_string_unref(c->password);
+
+ if (c->host)
+ lwc_string_unref(c->host);
+
+ if (c->port)
+ lwc_string_unref(c->port);
+
+ if (c->path)
+ lwc_string_unref(c->path);
+
+ if (c->query)
+ lwc_string_unref(c->query);
+
+ if (c->fragment)
+ lwc_string_unref(c->fragment);
+}
+
+
#ifdef NSURL_DEBUG
/**
* Dump a NetSurf URL's internal components
@@ -1272,6 +1305,7 @@ nserror nsurl_create(const char * const url_s, nsurl **url)
struct nsurl_component_lengths str_len = { 0, 0, 0, 0, 0, 0, 0, 0 };
enum nsurl_string_flags str_flags = 0;
nserror e = NSERROR_OK;
+ bool match;
assert(url_s != NULL);
@@ -1300,8 +1334,22 @@ nserror nsurl_create(const char * const url_s, nsurl **url)
/* Finished with buffer */
free(buff);
- if (e != NSERROR_OK)
+ if (e != NSERROR_OK) {
+ nsurl_destroy_components(&c);
return NSERROR_NOMEM;
+ }
+
+ /* Validate URL */
+ if ((lwc_string_isequal(c.scheme, corestring_lwc_http,
+ &match) == lwc_error_ok && match == true) ||
+ (lwc_string_isequal(c.scheme, corestring_lwc_https,
+ &match) == lwc_error_ok && match == true)) {
+ /* http, https must have host */
+ if (c.host == NULL) {
+ nsurl_destroy_components(&c);
+ return NSERROR_BAD_URL;
+ }
+ }
/* Get the string length and find which parts of url are present */
nsurl__get_string_data(&c, NSURL_WITH_FRAGMENT, &length,
@@ -1309,8 +1357,10 @@ nserror nsurl_create(const char * const url_s, nsurl **url)
/* Create NetSurf URL object */
*url = malloc(sizeof(nsurl) + length + 1); /* Add 1 for \0 */
- if (*url == NULL)
+ if (*url == NULL) {
+ nsurl_destroy_components(&c);
return NSERROR_NOMEM;
+ }
(*url)->components = c;
(*url)->length = length;
@@ -1353,29 +1403,7 @@ void nsurl_unref(nsurl *url)
#endif
/* Release lwc strings */
- if (url->components.scheme)
- lwc_string_unref(url->components.scheme);
-
- if (url->components.username)
- lwc_string_unref(url->components.username);
-
- if (url->components.password)
- lwc_string_unref(url->components.password);
-
- if (url->components.host)
- lwc_string_unref(url->components.host);
-
- if (url->components.port)
- lwc_string_unref(url->components.port);
-
- if (url->components.path)
- lwc_string_unref(url->components.path);
-
- if (url->components.query)
- lwc_string_unref(url->components.query);
-
- if (url->components.fragment)
- lwc_string_unref(url->components.fragment);
+ nsurl_destroy_components(&url->components);
/* Free the NetSurf URL */
free(url);
@@ -1883,6 +1911,15 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
size_t length;
char *pos;
+ /* check for source url having no fragment already */
+ if (url->components.fragment == NULL) {
+ *no_frag = (nsurl *)url;
+
+ (*no_frag)->count++;
+
+ return NSERROR_OK;
+ }
+
/* Find the change in length from url to new_url */
length = url->length;
if (url->components.fragment != NULL) {
@@ -2004,8 +2041,9 @@ nserror nsurl_refragment(const nsurl *url, lwc_string *frag, nsurl **new_url)
nserror nsurl_replace_query(const nsurl *url, const char *query,
nsurl **new_url)
{
- int query_len;
- int base_len;
+ int query_len; /* Length of new query string, including '?' */
+ int frag_len = 0; /* Length of fragment, including '#' */
+ int base_len; /* Length of URL up to start of query */
char *pos;
size_t len;
lwc_string *lwc_query;
@@ -2023,11 +2061,12 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
base_len -= lwc_string_length(url->components.query);
}
if (url->components.fragment != NULL) {
- base_len -= 1 + lwc_string_length(url->components.fragment);
+ frag_len = 1 + lwc_string_length(url->components.fragment);
+ base_len -= frag_len;
}
/* Set new_url's length */
- len = base_len + query_len;
+ len = base_len + query_len + frag_len;
/* Create NetSurf URL object */
*new_url = malloc(sizeof(nsurl) + len + 1); /* Add 1 for \0 */
@@ -2050,10 +2089,9 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
pos += query_len;
if (url->components.fragment != NULL) {
const char *frag = lwc_string_data(url->components.fragment);
- size_t frag_len = lwc_string_length(url->components.fragment);
*pos = '#';
- memcpy(++pos, frag, frag_len);
- pos += frag_len;
+ memcpy(++pos, frag, frag_len - 1);
+ pos += frag_len - 1;
}
*pos = '\0';
diff --git a/utils/schedule.h b/utils/schedule.h
deleted file mode 100644
index b5fe386..0000000
--- a/utils/schedule.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2011 Daniel Silverstone <dsilvers(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
- * Job scheduler (interface).
- */
-
-#ifndef _NETSURF_UTILS_SCHEDULE_H_
-#define _NETSURF_UTILS_SCHEDULE_H_
-
-/* In platform specific schedule.c. */
-typedef void (*schedule_callback_fn)(void *p);
-
-void schedule(int t, schedule_callback_fn callback, void *p);
-void schedule_remove(schedule_callback_fn callback, void *p);
-
-#endif
diff --git a/utils/utf8.c b/utils/utf8.c
index ab7bbae..cc8039c 100644
--- a/utils/utf8.c
+++ b/utils/utf8.c
@@ -29,6 +29,8 @@
#include <parserutils/charset/utf8.h>
+#include "desktop/gui_factory.h"
+
#include "utils/config.h"
#include "utils/log.h"
#include "utils/utf8.h"
@@ -463,8 +465,7 @@ bool utf8_save_text(const char *utf8_text, const char *path)
char *conv;
FILE *out;
- ret = utf8_to_local_encoding(utf8_text, strlen(utf8_text), &conv);
-
+ ret = guit->utf8->utf8_to_local(utf8_text, strlen(utf8_text), &conv);
if (ret != NSERROR_OK) {
LOG(("failed to convert to local encoding, return %d", ret));
return false;
diff --git a/utils/utf8.h b/utils/utf8.h
index 7c450b5..7509dde 100644
--- a/utils/utf8.h
+++ b/utils/utf8.h
@@ -161,9 +161,4 @@ bool utf8_save_text(const char *utf8_text, const char *path);
*/
nserror utf8_finalise(void);
-/* These two are platform specific */
-nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
-nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
-
-
#endif
diff --git a/windows/Makefile.defaults b/windows/Makefile.defaults
index 10c9abb..85472ba 100644
--- a/windows/Makefile.defaults
+++ b/windows/Makefile.defaults
@@ -2,20 +2,20 @@
# windows-specific options
# ----------------------------------------------------------------------------
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := NO
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := NO
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO
- NETSURF_USE_NSSVG := NO
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO
+NETSURF_USE_NSSVG := NO
- # Force using glibc internal iconv implementation instead of external libiconv
- # Valid options: YES, NO
- NETSURF_USE_LIBICONV_PLUG := NO
+# Force using glibc internal iconv implementation instead of external libiconv
+# Valid options: YES, NO
+NETSURF_USE_LIBICONV_PLUG := NO
- # no pdf support
- NETSURF_USE_HARU_PDF := NO
+# no pdf support
+NETSURF_USE_HARU_PDF := NO
- # Optimisation levels
- CFLAGS += -O2
+# Optimisation levels
+CFLAGS += -O2
diff --git a/windows/download.c b/windows/download.c
index 189baa8..fe2a092 100644
--- a/windows/download.c
+++ b/windows/download.c
@@ -26,14 +26,16 @@
#include "content/fetch.h"
#include "desktop/gui.h"
-#include "utils/schedule.h"
+#include "desktop/download.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
#include "utils/utils.h"
+
#include "windows/download.h"
#include "windows/gui.h"
#include "windows/resourceid.h"
+#include "windows/schedule.h"
static bool downloading = false;
static struct gui_download_window *download1;
@@ -181,7 +183,7 @@ void nsws_download_update_label(void *p)
{
struct gui_download_window *w = p;
if (w->hwnd == NULL) {
- schedule_remove(nsws_download_update_label, p);
+ win32_schedule(-1, nsws_download_update_label, p);
return;
}
HWND sub = GetDlgItem(w->hwnd, IDC_DOWNLOAD_LABEL);
@@ -221,21 +223,23 @@ void nsws_download_update_label(void *p)
w->time_left = NULL;
}
SendMessage(sub, WM_SETTEXT, (WPARAM)0, (LPARAM)label);
- if (w->progress < 10000)
- schedule(50, nsws_download_update_label, p);
+ if (w->progress < 10000) {
+ win32_schedule(500, nsws_download_update_label, p);
+ }
}
void nsws_download_update_progress(void *p)
{
struct gui_download_window *w = p;
if (w->hwnd == NULL) {
- schedule_remove(nsws_download_update_progress, p);
+ win32_schedule(-1, nsws_download_update_progress, p);
return;
}
HWND sub = GetDlgItem(w->hwnd, IDC_DOWNLOAD_PROGRESS);
SendMessage(sub, PBM_SETPOS, (WPARAM)(w->progress / 100), 0);
- if (w->progress < 10000)
- schedule(50, nsws_download_update_progress, p);
+ if (w->progress < 10000) {
+ win32_schedule(500, nsws_download_update_progress, p);
+ }
}
void nsws_download_clear_data(struct gui_download_window *w)
@@ -254,8 +258,8 @@ void nsws_download_clear_data(struct gui_download_window *w)
free(w->total_size);
if (w->file != NULL)
fclose(w->file);
- schedule_remove(nsws_download_update_progress, (void *)w);
- schedule_remove(nsws_download_update_label, (void *)w);
+ win32_schedule(-1, nsws_download_update_progress, (void *)w);
+ win32_schedule(-1, nsws_download_update_label, (void *)w);
}
diff --git a/windows/font.c b/windows/font.c
index 98269a3..09adeed 100644
--- a/windows/font.c
+++ b/windows/font.c
@@ -43,14 +43,14 @@ nserror utf8_to_font_encoding(const struct font_desc* font,
return utf8_to_enc(string, font->encoding, len, result);
}
-nserror utf8_to_local_encoding(const char *string,
+static nserror utf8_to_local_encoding(const char *string,
size_t len,
char **result)
{
return utf8_to_enc(string, "UCS-2", len, result);
}
-nserror utf8_from_local_encoding(const char *string, size_t len,
+static nserror utf8_from_local_encoding(const char *string, size_t len,
char **result)
{
assert(string && result);
@@ -234,3 +234,10 @@ const struct font_functions nsfont = {
nsfont_position_in_string,
nsfont_split
};
+
+static struct gui_utf8_table utf8_table = {
+ .utf8_to_local = utf8_to_local_encoding,
+ .local_to_utf8 = utf8_from_local_encoding,
+};
+
+struct gui_utf8_table *win32_utf8_table = &utf8_table;
diff --git a/windows/gui.c b/windows/gui.c
index 6ac4f61..8270c13 100644
--- a/windows/gui.c
+++ b/windows/gui.c
@@ -32,8 +32,8 @@
#include "content/urldb.h"
#include "content/fetch.h"
#include "css/utils.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/local_history.h"
#include "desktop/mouse.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
@@ -78,7 +78,7 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy);
static bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
-static void gui_poll(bool active)
+static void win32_poll(bool active)
{
MSG Msg; /* message from system */
BOOL bRet; /* message fetch result */
@@ -133,8 +133,7 @@ nsws_window_go(HWND hwnd, const char *urltxt)
browser_window_navigate(gw->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -343,8 +342,8 @@ static void nsws_window_update_forward_back(struct gui_window *w)
if (w->bw == NULL)
return;
- bool forward = history_forward_available(w->bw->history);
- bool back = history_back_available(w->bw->history);
+ bool forward = browser_window_history_forward_available(w->bw);
+ bool back = browser_window_history_back_available(w->bw);
if (w->mainmenu != NULL) {
EnableMenuItem(w->mainmenu, IDM_NAV_FORWARD,
@@ -762,7 +761,7 @@ nsws_window_command(HWND hwnd,
break;
case IDM_FILE_OPEN_WINDOW:
- browser_window_create(BROWSER_WINDOW_VERIFIABLE,
+ browser_window_create(BW_CREATE_NONE,
NULL,
NULL,
gw->bw,
@@ -852,16 +851,16 @@ nsws_window_command(HWND hwnd,
case IDM_NAV_BACK:
if ((gw->bw != NULL) &&
- (history_back_available(gw->bw->history))) {
- history_back(gw->bw, gw->bw->history);
+ (browser_window_history_back_available(gw->bw))) {
+ browser_window_history_back(gw->bw, false);
}
nsws_window_update_forward_back(gw);
break;
case IDM_NAV_FORWARD:
if ((gw->bw != NULL) &&
- (history_forward_available(gw->bw->history))) {
- history_forward(gw->bw, gw->bw->history);
+ (browser_window_history_forward_available(gw->bw))) {
+ browser_window_history_forward(gw->bw, false);
}
nsws_window_update_forward_back(gw);
break;
@@ -876,8 +875,7 @@ nsws_window_command(HWND hwnd,
browser_window_navigate(gw->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1045,8 +1043,7 @@ nsws_window_command(HWND hwnd,
browser_window_navigate(gw->bw,
url,
NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
+ BW_NAVIGATE_HISTORY,
NULL,
NULL,
NULL);
@@ -1232,8 +1229,8 @@ static HWND nsws_window_create(struct gui_window *gw)
*/
static struct gui_window *
gui_window_create(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab)
+ struct gui_window *existing,
+ gui_window_create_flags flags)
{
struct gui_window *gw;
@@ -1891,7 +1888,8 @@ struct gui_fetch_table *win32_fetch_table = &fetch_table;
static struct gui_browser_table browser_table = {
- .poll = gui_poll,
+ .poll = win32_poll,
+ .schedule = win32_schedule,
};
struct gui_browser_table *win32_browser_table = &browser_table;
diff --git a/windows/gui.h b/windows/gui.h
index 1ff849d..d8e1b1d 100644
--- a/windows/gui.h
+++ b/windows/gui.h
@@ -28,6 +28,7 @@ extern struct gui_window_table *win32_window_table;
extern struct gui_clipboard_table *win32_clipboard_table;
extern struct gui_fetch_table *win32_fetch_table;
extern struct gui_browser_table *win32_browser_table;
+extern struct gui_utf8_table *win32_utf8_table;
extern HINSTANCE hInstance;
diff --git a/windows/localhistory.c b/windows/localhistory.c
index 0b29871..fb582b4 100644
--- a/windows/localhistory.c
+++ b/windows/localhistory.c
@@ -22,8 +22,7 @@
#include <windowsx.h>
#include <commctrl.h>
-#include "desktop/browser_private.h"
-#include "desktop/local_history.h"
+#include "desktop/browser_history.h"
#include "desktop/plotters.h"
#include "utils/utils.h"
#include "utils/log.h"
@@ -56,7 +55,7 @@ static void nsws_localhistory_scroll_check(struct nsws_localhistory *l, struct g
if ((gw->bw == NULL) || (l->hwnd == NULL))
return;
- history_size(gw->bw->history, &(l->width), &(l->height));
+ browser_window_history_size(gw->bw, &(l->width), &(l->height));
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
@@ -97,7 +96,7 @@ static void nsws_localhistory_up(struct nsws_localhistory *l, struct gui_window
tmp_hdc = plot_hdc;
plot_hdc = GetDC(l->hwnd);
- history_redraw(gw->bw->history, &ctx);
+ browser_window_history_redraw(gw->bw, &ctx);
ReleaseDC(l->hwnd, plot_hdc);
@@ -167,8 +166,7 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
- if (history_click(gw->bw,
- gw->bw->history,
+ if (browser_window_history_click(gw->bw,
gw->localhistory->hscroll + x,
gw->localhistory->vscroll + y,
false)) {
@@ -180,8 +178,6 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
case WM_MOUSEMOVE:
x = GET_X_LPARAM(lparam);
y = GET_Y_LPARAM(lparam);
-/* if (gw->bw != NULL)
- history_hover(gw->bw->history, x, y, (void *)hwnd);*/
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
@@ -287,7 +283,7 @@ nsws_localhistory_event_callback(HWND hwnd, UINT msg,
tmp_hdc = plot_hdc;
plot_hdc = hdc;
- history_redraw_rectangle(gw->bw->history,
+ browser_window_history_redraw_rectangle(gw->bw,
gw->localhistory->hscroll + ps.rcPaint.left,
gw->localhistory->vscroll + ps.rcPaint.top,
gw->localhistory->hscroll + (ps.rcPaint.right - ps.rcPaint.left),
@@ -347,8 +343,8 @@ struct nsws_localhistory *nsws_window_create_localhistory(struct gui_window *gw)
localhistory->width = 0;
localhistory->height = 0;
- if ((gw->bw != NULL) && (gw->bw->history != NULL)) {
- history_size(gw->bw->history,
+ if (gw->bw != NULL) {
+ browser_window_history_size(gw->bw,
&(localhistory->width),
&(localhistory->height));
}
diff --git a/windows/main.c b/windows/main.c
index 94e0eee..19cd44a 100644
--- a/windows/main.c
+++ b/windows/main.c
@@ -111,6 +111,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
.clipboard = win32_clipboard_table,
.download = win32_download_table,
.fetch = win32_fetch_table,
+ .utf8 = win32_utf8_table,
};
win32_fetch_table->get_resource_url = gui_get_resource_url;
@@ -188,8 +189,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
error = nsurl_create(addr, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/windows/schedule.c b/windows/schedule.c
index 3181c55..4aac981 100644
--- a/windows/schedule.c
+++ b/windows/schedule.c
@@ -19,11 +19,17 @@
#include <sys/time.h>
#include <time.h>
-#include "utils/schedule.h"
-#include "windows/schedule.h"
-
#include "utils/log.h"
#include "utils/utils.h"
+#include "utils/errors.h"
+
+#include "windows/schedule.h"
+
+#ifdef DEBUG_SCHEDULER
+#define SRLOG(x) LOG(x)
+#else
+#define SRLOG(x)
+#endif
/* linked list of scheduled callbacks */
static struct nscallback *schedule_list = NULL;
@@ -41,39 +47,6 @@ struct nscallback
/**
- * Schedule a callback.
- *
- * \param tival interval before the callback should be made / cs
- * \param callback callback function
- * \param p user parameter, passed to callback function
- *
- * The callback function will be called as soon as possible after t cs have
- * passed.
- */
-void schedule(int cs_ival, void (*callback)(void *p), void *p)
-{
- struct nscallback *nscb;
- struct timeval tv;
-
- tv.tv_sec = cs_ival / 100; /* cs to seconds */
- tv.tv_usec = (cs_ival % 100) * 10000; /* remainder to microseconds */
-
- nscb = calloc(1, sizeof(struct nscallback));
-
- LOG(("adding callback %p for %p(%p) at %d cs", nscb, callback, p, cs_ival));
-
- gettimeofday(&nscb->tv, NULL);
- timeradd(&nscb->tv, &tv, &nscb->tv);
-
- nscb->callback = callback;
- nscb->p = p;
-
- /* add to list front */
- nscb->next = schedule_list;
- schedule_list = nscb;
-}
-
-/**
* Unschedule a callback.
*
* \param callback callback function
@@ -82,16 +55,18 @@ void schedule(int cs_ival, void (*callback)(void *p), void *p)
* All scheduled callbacks matching both callback and p are removed.
*/
-void schedule_remove(void (*callback)(void *p), void *p)
+static nserror schedule_remove(void (*callback)(void *p), void *p)
{
struct nscallback *cur_nscb;
struct nscallback *prev_nscb;
struct nscallback *unlnk_nscb;
- if (schedule_list == NULL)
- return;
+ /* check there is something on the list to remove */
+ if (schedule_list == NULL) {
+ return NSERROR_OK;
+ }
- LOG(("removing %p, %p", callback, p));
+ SRLOG(("removing %p, %p", callback, p));
cur_nscb = schedule_list;
prev_nscb = NULL;
@@ -101,7 +76,7 @@ void schedule_remove(void (*callback)(void *p), void *p)
(cur_nscb->p == p)) {
/* item to remove */
- LOG(("callback entry %p removing %p(%p)",
+ SRLOG(("callback entry %p removing %p(%p)",
cur_nscb, cur_nscb->callback, cur_nscb->p));
/* remove callback */
@@ -120,8 +95,44 @@ void schedule_remove(void (*callback)(void *p), void *p)
cur_nscb = prev_nscb->next;
}
}
+ return NSERROR_OK;
}
+/* exported interface documented in windows/schedule.h */
+nserror win32_schedule(int ival, void (*callback)(void *p), void *p)
+{
+ struct nscallback *nscb;
+ struct timeval tv;
+ nserror ret;
+
+ ret = schedule_remove(callback, p);
+ if ((ival < 0) || (ret != NSERROR_OK)) {
+ return ret;
+ }
+
+ tv.tv_sec = ival / 1000; /* miliseconds to seconds */
+ tv.tv_usec = (ival % 1000) * 1000; /* remainder to microseconds */
+
+ nscb = calloc(1, sizeof(struct nscallback));
+ if (nscb == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ SRLOG(("adding callback %p for %p(%p) at %d cs",
+ nscb, callback, p, ival));
+
+ gettimeofday(&nscb->tv, NULL);
+ timeradd(&nscb->tv, &tv, &nscb->tv);
+
+ nscb->callback = callback;
+ nscb->p = p;
+
+ /* add to list front */
+ nscb->next = schedule_list;
+ schedule_list = nscb;
+
+ return NSERROR_OK;
+}
/* exported interface documented in schedule.h */
int
@@ -157,7 +168,7 @@ schedule_run(void)
prev_nscb->next = unlnk_nscb->next;
}
- LOG(("callback entry %p running %p(%p)",
+ SRLOG(("callback entry %p running %p(%p)",
unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p));
/* call callback */
unlnk_nscb->callback(unlnk_nscb->p);
@@ -190,9 +201,9 @@ schedule_run(void)
/* make returned time relative to now */
timersub(&nexttime, &tv, &rettime);
-#if defined(DEBUG_SCHEDULER)
- LOG(("returning time to next event as %ldms",(rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)));
-#endif
+ SRLOG(("returning time to next event as %ldms",
+ (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000)));
+
/* return next event time in milliseconds (24days max wait) */
return (rettime.tv_sec * 1000) + (rettime.tv_usec / 1000);
}
diff --git a/windows/schedule.h b/windows/schedule.h
index e6a5d10..6d47b2d 100644
--- a/windows/schedule.h
+++ b/windows/schedule.h
@@ -16,8 +16,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FRAMEBUFFER_SCHEDULE_H
-#define FRAMEBUFFER_SCHEDULE_H
+#ifndef WINDOWS_SCHEDULE_H
+#define WINDOWS_SCHEDULE_H
+
+/**
+ * Schedule a callback.
+ *
+ * \param ival interval before the callback should be made in ms
+ * \param callback callback function
+ * \param p user parameter, passed to callback function
+ *
+ * The callback function will be called as soon as possible after t ms have
+ * passed.
+ */
+nserror win32_schedule(int ival, void (*callback)(void *p), void *p);
/**
* Process scheduled callbacks up to current time.
--
NetSurf Browser
9 years, 1 month
netsurf: branch master updated. release/3.0-1184-gf0f05d6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f0f05d691ba748314e57d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f0f05d691ba748314e57da7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f0f05d691ba748314e57da754...
The branch, master has been updated
via f0f05d691ba748314e57da754518dfbad6a7a339 (commit)
via fb072686c1b52f9f50ccff7241eff1e85a2dd97b (commit)
via 5324cd9abdf34c6568c7051a97c33a8934fcd89b (commit)
via 4575698f0f8b570f3c32e05cd3cbeb2d4f8ff237 (commit)
via a741ceadb89d09d7604a411ed04c0d92928ce814 (commit)
from b91c28b8d1ecf1ace615ff12e11adadf4f330b9a (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=f0f05d691ba748314e5...
commit f0f05d691ba748314e57da754518dfbad6a7a339
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix cppcheck nullPointer
diff --git a/amiga/download.c b/amiga/download.c
index 0f8ae4c..fb5c109 100644
--- a/amiga/download.c
+++ b/amiga/download.c
@@ -230,11 +230,12 @@ static nserror gui_download_window_data(struct gui_download_window *dw,
static void gui_download_window_done(struct gui_download_window *dw)
{
struct dlnode *dln,*dln2 = NULL;
- struct browser_window *bw = dw->bw;
+ struct browser_window *bw;
bool queuedl = false;
STRPTR sendcmd = NULL;
if(!dw) return;
+ bw = dw->bw;
if((nsoption_bool(download_notify)) && (dw->result == AMINS_DLOAD_OK))
{
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=fb072686c1b52f9f50c...
commit fb072686c1b52f9f50ccff7241eff1e85a2dd97b
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix cppcheck syntaxError
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 3bff4c2..dde283b 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -269,7 +269,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
PMIA_CommKey, "B",
TAG_DONE),
- TAG_DONE),
+ PMEND,
TAG_DONE),
~0);
break;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5324cd9abdf34c6568c...
commit 5324cd9abdf34c6568c7051a97c33a8934fcd89b
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix cppcheck nullPointer
diff --git a/amiga/theme.c b/amiga/theme.c
index 0da15ac..e00e080 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -470,10 +470,10 @@ void gui_window_stop_throbber(struct gui_window *g)
// g->shared->throbber_frame = 0;
}
-void ami_update_throbber(struct gui_window_2 *g,bool redraw)
+void ami_update_throbber(struct gui_window_2 *g, bool redraw)
{
struct IBox *bbox;
- int frame = g->throbber_frame;
+ int frame;
if(!g) return;
if(!g->objects[GID_THROBBER]) return;
@@ -481,10 +481,12 @@ void ami_update_throbber(struct gui_window_2 *g,bool redraw)
if(g->bw->window->throbbing == false)
{
frame = 0;
- g->throbber_frame=1;
+ g->throbber_frame = 1;
}
else
{
+ frame = g->throbber_frame;
+
if(!redraw)
{
if(g->throbber_update_count < throbber_update_interval)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4575698f0f8b570f3c3...
commit 4575698f0f8b570f3c32e05cd3cbeb2d4f8ff237
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix cppcheck syntaxError
diff --git a/amiga/gui.c b/amiga/gui.c
index 0af7a1a..5c707c5 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -3555,7 +3555,7 @@ gui_window_create(struct browser_window *bw,
GA_TabCycle, TRUE,
STRINGA_Buffer, g->shared->svbuffer,
STRINGVIEW_Header, URLHistory_GetList(),
- StringEnd,
+ TAG_DONE),
LAYOUT_AddChild, g->shared->objects[GID_FAVE] = ButtonObject,
GA_ID, GID_FAVE,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a741ceadb89d09d7604...
commit a741ceadb89d09d7604a411ed04c0d92928ce814
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix cppcheck bufferAccessOutOfBounds
diff --git a/amiga/dt_anim.c b/amiga/dt_anim.c
index c844700..f2b0f76 100644
--- a/amiga/dt_anim.c
+++ b/amiga/dt_anim.c
@@ -341,7 +341,7 @@ APTR ami_colormap_to_clut(struct ColorMap *cmap)
{
int i;
UBYTE *clut = AllocVecTags(256 * 4, AVT_ClearWithValue, 0, TAG_DONE); /* NB: Was not MEMF_PRIVATE */
- ULONG colour[3 * 256];
+ ULONG colour[256 * 4];
if(!clut) return NULL;
-----------------------------------------------------------------------
Summary of changes:
amiga/context_menu.c | 2 +-
amiga/download.c | 3 ++-
amiga/dt_anim.c | 2 +-
amiga/gui.c | 2 +-
amiga/theme.c | 8 +++++---
5 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 3bff4c2..dde283b 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -269,7 +269,7 @@ void ami_context_menu_add_submenu(Object *ctxmenuobj, ULONG cmsub, void *userdat
PMIA_UserData, nsurl_access(hlcache_handle_get_url(userdata)),
PMIA_CommKey, "B",
TAG_DONE),
- TAG_DONE),
+ PMEND,
TAG_DONE),
~0);
break;
diff --git a/amiga/download.c b/amiga/download.c
index 0f8ae4c..fb5c109 100644
--- a/amiga/download.c
+++ b/amiga/download.c
@@ -230,11 +230,12 @@ static nserror gui_download_window_data(struct gui_download_window *dw,
static void gui_download_window_done(struct gui_download_window *dw)
{
struct dlnode *dln,*dln2 = NULL;
- struct browser_window *bw = dw->bw;
+ struct browser_window *bw;
bool queuedl = false;
STRPTR sendcmd = NULL;
if(!dw) return;
+ bw = dw->bw;
if((nsoption_bool(download_notify)) && (dw->result == AMINS_DLOAD_OK))
{
diff --git a/amiga/dt_anim.c b/amiga/dt_anim.c
index c844700..f2b0f76 100644
--- a/amiga/dt_anim.c
+++ b/amiga/dt_anim.c
@@ -341,7 +341,7 @@ APTR ami_colormap_to_clut(struct ColorMap *cmap)
{
int i;
UBYTE *clut = AllocVecTags(256 * 4, AVT_ClearWithValue, 0, TAG_DONE); /* NB: Was not MEMF_PRIVATE */
- ULONG colour[3 * 256];
+ ULONG colour[256 * 4];
if(!clut) return NULL;
diff --git a/amiga/gui.c b/amiga/gui.c
index 0af7a1a..5c707c5 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -3555,7 +3555,7 @@ gui_window_create(struct browser_window *bw,
GA_TabCycle, TRUE,
STRINGA_Buffer, g->shared->svbuffer,
STRINGVIEW_Header, URLHistory_GetList(),
- StringEnd,
+ TAG_DONE),
LAYOUT_AddChild, g->shared->objects[GID_FAVE] = ButtonObject,
GA_ID, GID_FAVE,
diff --git a/amiga/theme.c b/amiga/theme.c
index 0da15ac..e00e080 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -470,10 +470,10 @@ void gui_window_stop_throbber(struct gui_window *g)
// g->shared->throbber_frame = 0;
}
-void ami_update_throbber(struct gui_window_2 *g,bool redraw)
+void ami_update_throbber(struct gui_window_2 *g, bool redraw)
{
struct IBox *bbox;
- int frame = g->throbber_frame;
+ int frame;
if(!g) return;
if(!g->objects[GID_THROBBER]) return;
@@ -481,10 +481,12 @@ void ami_update_throbber(struct gui_window_2 *g,bool redraw)
if(g->bw->window->throbbing == false)
{
frame = 0;
- g->throbber_frame=1;
+ g->throbber_frame = 1;
}
else
{
+ frame = g->throbber_frame;
+
if(!redraw)
{
if(g->throbber_update_count < throbber_update_interval)
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.0-1179-gb91c28b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/b91c28b8d1ecf1ace615f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/b91c28b8d1ecf1ace615ff1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/b91c28b8d1ecf1ace615ff12e...
The branch, master has been updated
via b91c28b8d1ecf1ace615ff12e11adadf4f330b9a (commit)
via 88a99d9722f6c61cf8a338002d7a38622a1168ef (commit)
from 527bc23bdba33f1db6194c5d95f41f8a6b603bd5 (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=b91c28b8d1ecf1ace61...
commit b91c28b8d1ecf1ace615ff12e11adadf4f330b9a
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix logic error found by cppcheck.
diff --git a/riscos/toolbar.c b/riscos/toolbar.c
index 34d6171..d64db2d 100644
--- a/riscos/toolbar.c
+++ b/riscos/toolbar.c
@@ -1686,7 +1686,7 @@ void ro_toolbar_set_content_favicon(struct toolbar *toolbar,
void ro_toolbar_update_urlsuggest(struct toolbar *toolbar)
{
- if (toolbar != NULL && toolbar->url != NULL)
+ if (toolbar == NULL || toolbar->url == NULL)
return;
ro_gui_url_bar_update_urlsuggest(toolbar->url);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=88a99d9722f6c61cf8a...
commit 88a99d9722f6c61cf8a338002d7a38622a1168ef
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix logic error found by cppcheck.
diff --git a/riscos/toolbar.c b/riscos/toolbar.c
index 93c4438..34d6171 100644
--- a/riscos/toolbar.c
+++ b/riscos/toolbar.c
@@ -1579,7 +1579,7 @@ bool ro_toolbar_set_button_order(struct toolbar *toolbar, char order[])
void ro_toolbar_set_button_shaded_state(struct toolbar *toolbar,
button_bar_action action, bool shaded)
{
- if (toolbar == NULL && toolbar->buttons == NULL)
+ if (toolbar == NULL || toolbar->buttons == NULL)
return;
ro_gui_button_bar_shade_button(toolbar->buttons, action, shaded);
-----------------------------------------------------------------------
Summary of changes:
riscos/toolbar.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/riscos/toolbar.c b/riscos/toolbar.c
index 93c4438..d64db2d 100644
--- a/riscos/toolbar.c
+++ b/riscos/toolbar.c
@@ -1579,7 +1579,7 @@ bool ro_toolbar_set_button_order(struct toolbar *toolbar, char order[])
void ro_toolbar_set_button_shaded_state(struct toolbar *toolbar,
button_bar_action action, bool shaded)
{
- if (toolbar == NULL && toolbar->buttons == NULL)
+ if (toolbar == NULL || toolbar->buttons == NULL)
return;
ro_gui_button_bar_shade_button(toolbar->buttons, action, shaded);
@@ -1686,7 +1686,7 @@ void ro_toolbar_set_content_favicon(struct toolbar *toolbar,
void ro_toolbar_update_urlsuggest(struct toolbar *toolbar)
{
- if (toolbar != NULL && toolbar->url != NULL)
+ if (toolbar == NULL || toolbar->url == NULL)
return;
ro_gui_url_bar_update_urlsuggest(toolbar->url);
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.0-1177-g527bc23
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/527bc23bdba33f1db6194...
...commit http://git.netsurf-browser.org/netsurf.git/commit/527bc23bdba33f1db6194c5...
...tree http://git.netsurf-browser.org/netsurf.git/tree/527bc23bdba33f1db6194c5d9...
The branch, master has been updated
via 527bc23bdba33f1db6194c5d95f41f8a6b603bd5 (commit)
from 979b59887f6e868908519640fc795db0070371f7 (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=527bc23bdba33f1db61...
commit 527bc23bdba33f1db6194c5d95f41f8a6b603bd5
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Avoid potential NULL ptr deref found by cppcheck.
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 4cf3d42..0c16626 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -435,14 +435,15 @@ void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more)
};
while (more) {
- ro_plot_origin_x = redraw->box.x0 + tv->origin.x -
- redraw->xscroll;
- ro_plot_origin_y = redraw->box.y1 + tv->origin.y -
- redraw->yscroll;
if (tv != NULL && tv->tree != NULL) {
struct rect clip;
+ ro_plot_origin_x = redraw->box.x0 + tv->origin.x -
+ redraw->xscroll;
+ ro_plot_origin_y = redraw->box.y1 + tv->origin.y -
+ redraw->yscroll;
+
clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
clip.y0 = (ro_plot_origin_y - redraw->clip.y1) / 2;
-----------------------------------------------------------------------
Summary of changes:
riscos/treeview.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 4cf3d42..0c16626 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -435,14 +435,15 @@ void ro_treeview_redraw_loop(wimp_draw *redraw, ro_treeview *tv, osbool more)
};
while (more) {
- ro_plot_origin_x = redraw->box.x0 + tv->origin.x -
- redraw->xscroll;
- ro_plot_origin_y = redraw->box.y1 + tv->origin.y -
- redraw->yscroll;
if (tv != NULL && tv->tree != NULL) {
struct rect clip;
+ ro_plot_origin_x = redraw->box.x0 + tv->origin.x -
+ redraw->xscroll;
+ ro_plot_origin_y = redraw->box.y1 + tv->origin.y -
+ redraw->yscroll;
+
clip.x0 = (redraw->clip.x0 - ro_plot_origin_x) / 2;
clip.y0 = (ro_plot_origin_y - redraw->clip.y1) / 2;
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.0-1176-g979b598
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/979b59887f6e868908519...
...commit http://git.netsurf-browser.org/netsurf.git/commit/979b59887f6e86890851964...
...tree http://git.netsurf-browser.org/netsurf.git/tree/979b59887f6e868908519640f...
The branch, master has been updated
via 979b59887f6e868908519640fc795db0070371f7 (commit)
via a9fb42e71bc55ad4b498beaf2202c09cc37c5056 (commit)
via 442d1cb3cffe60253ab1481c0168d1708644fc97 (commit)
from 3445483e7838719d3feb0a6daf0fa9290b0cfb3f (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=979b59887f6e8689085...
commit 979b59887f6e868908519640fc795db0070371f7
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix leak of url found by cppcheck.
diff --git a/riscos/gui.c b/riscos/gui.c
index 4f9856b..05325c5 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -1594,6 +1594,7 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
/* URI */
if (!ro_gui_uri_file_parse_line(fp, line))
goto uri_syntax_error;
+
url = strdup(line);
if (!url) {
warn_user("NoMemory", 0);
@@ -1603,7 +1604,7 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
/* title */
if (!ro_gui_uri_file_parse_line(fp, line))
- goto uri_syntax_error;
+ goto uri_free;
if (uri_title && line[0] && ((line[0] != '*') || line[1])) {
*uri_title = strdup(line);
if (!*uri_title) /* non-fatal */
@@ -1613,6 +1614,9 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
return url;
+uri_free:
+ free(url);
+
uri_syntax_error:
fclose(fp);
warn_user("URIError", 0);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a9fb42e71bc55ad4b49...
commit a9fb42e71bc55ad4b498beaf2202c09cc37c5056
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix leak of filename found by cppcheck.
diff --git a/riscos/download.c b/riscos/download.c
index 804a664..6cba17e 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -379,6 +379,8 @@ static struct gui_download_window *gui_download_window_create(download_context *
snprintf(dw->path, RO_DOWNLOAD_MAX_PATH_LEN, "%s",
filename);
+ free(filename);
+
err = utf8_to_local_encoding(dw->path, 0, &local_path);
if (err != NSERROR_OK) {
/* badenc should never happen */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=442d1cb3cffe60253ab...
commit 442d1cb3cffe60253ab1481c0168d1708644fc97
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix out of bounds array accesses for Cyrillic2 found by cppcheck.
diff --git a/riscos/ucstables.c b/riscos/ucstables.c
index cc6fe05..f9b6b36 100644
--- a/riscos/ucstables.c
+++ b/riscos/ucstables.c
@@ -481,7 +481,7 @@ nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
/* get encoding name */
enc = (alphabet <= CONT_ENC_END ? localencodings[alphabet - 100]
: (alphabet == 120 ?
- localencodings[CONT_ENC_END + 1]
+ localencodings[CONT_ENC_END - 100 + 1]
: localencodings[0]));
/* create output buffer */
@@ -591,7 +591,7 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
/* get encoding name */
enc = (alphabet <= CONT_ENC_END ? localencodings[alphabet - 100]
: (alphabet == 120 ?
- localencodings[CONT_ENC_END + 1]
+ localencodings[CONT_ENC_END - 100 + 1]
: localencodings[0]));
/* create output buffer (oversized) */
-----------------------------------------------------------------------
Summary of changes:
riscos/download.c | 2 ++
riscos/gui.c | 6 +++++-
riscos/ucstables.c | 4 ++--
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/riscos/download.c b/riscos/download.c
index 804a664..6cba17e 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -379,6 +379,8 @@ static struct gui_download_window *gui_download_window_create(download_context *
snprintf(dw->path, RO_DOWNLOAD_MAX_PATH_LEN, "%s",
filename);
+ free(filename);
+
err = utf8_to_local_encoding(dw->path, 0, &local_path);
if (err != NSERROR_OK) {
/* badenc should never happen */
diff --git a/riscos/gui.c b/riscos/gui.c
index 4f9856b..05325c5 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -1594,6 +1594,7 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
/* URI */
if (!ro_gui_uri_file_parse_line(fp, line))
goto uri_syntax_error;
+
url = strdup(line);
if (!url) {
warn_user("NoMemory", 0);
@@ -1603,7 +1604,7 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
/* title */
if (!ro_gui_uri_file_parse_line(fp, line))
- goto uri_syntax_error;
+ goto uri_free;
if (uri_title && line[0] && ((line[0] != '*') || line[1])) {
*uri_title = strdup(line);
if (!*uri_title) /* non-fatal */
@@ -1613,6 +1614,9 @@ char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
return url;
+uri_free:
+ free(url);
+
uri_syntax_error:
fclose(fp);
warn_user("URIError", 0);
diff --git a/riscos/ucstables.c b/riscos/ucstables.c
index cc6fe05..f9b6b36 100644
--- a/riscos/ucstables.c
+++ b/riscos/ucstables.c
@@ -481,7 +481,7 @@ nserror utf8_to_local_encoding(const char *string, size_t len, char **result)
/* get encoding name */
enc = (alphabet <= CONT_ENC_END ? localencodings[alphabet - 100]
: (alphabet == 120 ?
- localencodings[CONT_ENC_END + 1]
+ localencodings[CONT_ENC_END - 100 + 1]
: localencodings[0]));
/* create output buffer */
@@ -591,7 +591,7 @@ nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
/* get encoding name */
enc = (alphabet <= CONT_ENC_END ? localencodings[alphabet - 100]
: (alphabet == 120 ?
- localencodings[CONT_ENC_END + 1]
+ localencodings[CONT_ENC_END - 100 + 1]
: localencodings[0]));
/* create output buffer (oversized) */
--
NetSurf Browser
9 years, 2 months
netsurf: branch master updated. release/3.0-1173-g3445483
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3445483e7838719d3feb0...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3445483e7838719d3feb0a6...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3445483e7838719d3feb0a6da...
The branch, master has been updated
via 3445483e7838719d3feb0a6daf0fa9290b0cfb3f (commit)
from 9c60417f73868e2cd8e0db951020110ee8c295fc (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=3445483e7838719d3fe...
commit 3445483e7838719d3feb0a6daf0fa9290b0cfb3f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Close file on error path.
diff --git a/framebuffer/convert_image.c b/framebuffer/convert_image.c
index bf47a35..838a907 100644
--- a/framebuffer/convert_image.c
+++ b/framebuffer/convert_image.c
@@ -159,6 +159,7 @@ main(int argc, char **argv)
if (br < 0) {
printf("Error reading input: %s\n", strerror(errno));
+ fclose(f);
return 1;
}
-----------------------------------------------------------------------
Summary of changes:
framebuffer/convert_image.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/framebuffer/convert_image.c b/framebuffer/convert_image.c
index bf47a35..838a907 100644
--- a/framebuffer/convert_image.c
+++ b/framebuffer/convert_image.c
@@ -159,6 +159,7 @@ main(int argc, char **argv)
if (br < 0) {
printf("Error reading input: %s\n", strerror(errno));
+ fclose(f);
return 1;
}
--
NetSurf Browser
9 years, 2 months