netsurf: branch chris/extmem updated. release/3.6-136-g36b26b8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/36b26b861f375de5b2be3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/36b26b861f375de5b2be3ff...
...tree http://git.netsurf-browser.org/netsurf.git/tree/36b26b861f375de5b2be3ff9d...
The branch, chris/extmem has been updated
discards 53a5c4f6b679885948984b0a99f5195be3dd4345 (commit)
discards fe5263c8f70ae399e270f0e2a6453024f24cee99 (commit)
discards 5161c335b4accd0ca9a0095c488189a9a133e278 (commit)
discards e0e9fbf29427fbf065e2cd9f8f54a98efcec44a7 (commit)
discards d4cba8e4f7513f8757073347268c1dc8dffb33d4 (commit)
discards a46338a6488fb7b14060c59035e350cb21dafbbe (commit)
discards d448d44a95a7905953fdc766744dc90f6f9e0391 (commit)
discards 38bf24325504cb5375455d49bfada27fc0d37384 (commit)
discards 16a56a451d095483bc4e081da3eb5b40bdc04254 (commit)
discards 4db40c3f27d0ade8fc76f57cd383e5ff52ad7c93 (commit)
discards ce3b92b65fc9a6503ea9f3a01155a9ecd521bed0 (commit)
discards 5d705f521dd09415de4fe29d1695a6924971b8ce (commit)
via 36b26b861f375de5b2be3ff9de37288049f05a26 (commit)
via 43bbdc520dd054acdf46088fbbee5d4a3b638d24 (commit)
via b7551fec72372df4cb40384818da5419904e4c98 (commit)
via 570212add2ec6b70474eb49b74259d7c73733c03 (commit)
via adac4d98bb9acdeb76725c946e53ff0e2c0235df (commit)
via 982a59744f634aee73dc11d4a30c93b4652a1e7e (commit)
via 205abcf18950bf3ee8600c4a4e4945b096985f9e (commit)
via 937dce4f2eef86c563bb93ded5c355c1446bf88c (commit)
via 493036a920aba5cf470637b7aa2ca69f7f57b41c (commit)
via a83afda7918cdb7ebc28db204ceb3e0f3d1cb0d3 (commit)
via 0804c43bf1afa0cb9d851ceb89e29ec8096f272f (commit)
via 5382ad2aa69b6ef8e479c5714052086eba8133b5 (commit)
via 48f868a9555be385f156e9396079ad5d0ee388f6 (commit)
via 76673bbf655592a62d21acfec860d5bf181bc848 (commit)
via 5e523b608a330c2c10f20a8913b7bad85388d475 (commit)
via 9df30eb78fc024448c39182a5d9fb0053c6ef137 (commit)
via d8eec1b048fe7c7cac4a0bd3bb4f31203524ee79 (commit)
via d9c8d1c70cac756d47586e2abf2dfbb9a1d96b59 (commit)
via d90e82d3f1c0ed0cdd665899c754b655f661976d (commit)
via 4893a9f9af8013fb81cdb81a4d49043719d0b851 (commit)
via 6ba5edaede1a04db5e374d94e8fd8d4d1fbc3f0a (commit)
via 47379c04442c805af95ba16b9932fbdb549a7594 (commit)
via 9379a64c6dfab6046ba56b8cdb299c4da3d6c3f2 (commit)
via 7ca75a4cee083ded7f3607bba5e841c430556d93 (commit)
via 7fc6e6c0c0053e5ca4f4e09e8f4457a8125a167c (commit)
via 32d2dda01c097be6a214499afa91d99bd198559e (commit)
via c60ab801f3cdd4cb7519245a9084fa7c6d4f66a8 (commit)
via 512a4335dae3fc27675cc6ba4ccfd219f20bfdba (commit)
via 354656b442cb9583fe8f690e9aa3e58ff50b6dce (commit)
via 4e5e9f1f5af2e526a87f38936aed0c4c100b5051 (commit)
via b6be869f19994070ec522d19455ea7eb47965be4 (commit)
via ded1979fa1b77ea6261df7a7f6f9177bde433f2d (commit)
via 7750d926adf3740448ec2fada2e207a4b5bd5851 (commit)
via 93fdbcc6de0d82323a67bc4c2d560f90a1f396cd (commit)
via b93ae2c28f2e1d3d4e0d20c5a5d09c930c49fb88 (commit)
via fb0cdfed79e5d55cf25a4e7866f0b084fde4ed2b (commit)
via 5f32f9ddd61ebd873ebb825c6e32d82e8965d840 (commit)
via e7598fb0b5c83fddca34d9f1adeb3c0989ce9ae5 (commit)
via 7b7b1507d01b3e078790150d6b5f59ebaf0b45c3 (commit)
via 2917af0a967bda993b8c1c5f194eea0b9881b6be (commit)
via 7aa1dd601e40d0684efbdd53b6ce5109846fcc37 (commit)
via 16b8d524e89e575230a46746bb117bc7f2a4f265 (commit)
via 07456db2dc6fc59a952e0160cb03ba494a05e05d (commit)
via 743637a8d2105df6ffc464a3cb4753cdc8c1401f (commit)
via 49b1b0b3a51092d7612e496ae6bc8d7d8651425b (commit)
via 96e073a29777bbe927f0bc7187f7032d3f51e68b (commit)
via af6139bcb5845d4cdbc852b113ac8fabcee29097 (commit)
via 337f9948d51d48f8b2a01694e07ea1bf4fa337af (commit)
via 72d3bec792c614783d6333267852675f14f7bf94 (commit)
via af3a78060fc18d1544b0d411d2d7584fcac9f3df (commit)
via 05a35725d19f9b5a2c8e347d638fb00dff21962f (commit)
via e2bad05338d5575bf485fbb509d496c5de012a64 (commit)
via c7cf2d18de0ac03ce4c6276072bc89fd847e3c22 (commit)
via c8c7de976a107c8e3362702f294f4f4d9c5ab7e4 (commit)
via 770c277ccc182f504be0a316390d59c05a59e041 (commit)
via 539d5da5c4b814322cfac07b825a2b222951dacd (commit)
via 7c03ae91fd8a99576cd5f0b8e5311f990ae5739b (commit)
via f68a3f9d61bf66640071ec2f32f7b2ed09215a87 (commit)
via f27cc16d426708c9267dcb290d4a32f2a5dcb686 (commit)
via d2742077b95cdc574c0b88284e5d04243de0ff9d (commit)
via b227be8cd2108405793e117fa150808dd6120f29 (commit)
via 71983d527ea86da0e8c8e2195715b9ca55b0de13 (commit)
via 54f01c7d7bb8a0b505ac6fabef252d332152f29d (commit)
via 6c441fd4b1a8d9be2a84b4ea9ba2a4e90857be3e (commit)
via 7a5b50be940de2d6156e756482a2297014fb620b (commit)
via 9d77dc83bdd86f3a46ff00102a43c46718dac00b (commit)
via f04103398b284b9defb85c98d3079b0dfc43a15e (commit)
via 407e58406b7a89b9c15a7e40c9b2bc26b866f31e (commit)
via 7318b5b65a2831b6cc6e87b51b6dcedc5a946c78 (commit)
via 4ad375c3b0e3f65416c02ca7b126b2e7fe375db1 (commit)
via ba0895121b44b21d351ee69a07613f524f322617 (commit)
via 9d694f56bbe28ba61eeeffd7472a4b7962a513c0 (commit)
via 433418a8e9655fe19ab704129ee652b7316dc343 (commit)
via 34a587849c9999f12d4199d744e7c72204369eab (commit)
via 68e8152f3eb95395cd47e0d703ed709e4ddaef89 (commit)
via 8f9a652774bbf1bdb469e0e7280a28983559b90d (commit)
via ecf2fdf6122eb6c11b66d08ab2d7b4079a1df108 (commit)
via 74d7c2d2c2b2161701c1f0258bbfc7feb753ac1e (commit)
via a440907b78f430ff7428e48f6fb0532db5f00cd5 (commit)
via c0a15de1e4609e942c037c340c5fed3c5bce839d (commit)
via 2b6a416970f3eff764f4a053cdade46566ce7dc7 (commit)
via f38b72a5833bfd9967308d6667c45c58a0ed10b8 (commit)
via 2dd97b0b8e1f363542dddb403d515cce132b7f29 (commit)
via 4b91c43003cdcbca09a72ce408d1e8cb93ad83e6 (commit)
via 2fe884be6532bb86ed8e2f2aa3d278ebaee6a406 (commit)
via 71afaacc80c6d94e1406249c61c338a4131d24a7 (commit)
via 2a9e89de751b6a6600feee2bc3960affb73c6988 (commit)
via 54e31b65d14dd1e228106eae0c60ab42802a97ed (commit)
via 4a93beb0393a8abddeb606cbb29a99bc1d73b67e (commit)
via 0bc32aa654271fd592d36fabf272e3fa0ca0a450 (commit)
via 4fb38f574a303d53fb3e4560e76163e4e97687b3 (commit)
via a76a36915c7d348582f905629fa0840a88b02edb (commit)
via c4b8857789e3f79a2ae0f7abe108999bf323b01a (commit)
via 20432237883a04677f30f1758979fa0a4b9111e3 (commit)
via f8f802cda5f54c0c2b1acd51efc08aa7d4afad1b (commit)
via af1f1f375d0f0fdaf885f72fdbcd873f2203d227 (commit)
via 67b7854737f23f76b700a6fe76ce6060435f5cff (commit)
via 811d7b71758917919a0c94b1289bd5608119ccc5 (commit)
via 540c6ee0ef432dfad375d64afa2c67d410f826d5 (commit)
via cd3720d5b63147fb97f3b7cdd056d3e8e6cc5586 (commit)
via 3f88c12315556d6f5f928c7e6a5e56357899ece7 (commit)
via 356e92c604ec6ab218302cfc1704f04ae171ddeb (commit)
via 30ca72b32eba20793b2888be35992fdc5dae375b (commit)
via b5fd0ae1ed4558b50cb7e3002e8f0c7042a4617d (commit)
via 31b1c72ddc66512c3a9cef4e59b94bdafc713ad4 (commit)
via 35146ef0c8f72526683f306a07d5cc70a070fe85 (commit)
via bcce8cc7b41f869fa2b022f85622cd389082d0f5 (commit)
via f679a9b1d6b652e06c24d543c7c5921753e3071b (commit)
via d436992eb2a28e2e056e96e42072b13d89b44a0b (commit)
via 5ce3b934571906c012567d898d83c652fad30567 (commit)
via 17128fd0ad119c801a17e06da1fd8b351fb17f21 (commit)
via b3042f6c1fcb708d8663f4ab51865fe6a1f8bec3 (commit)
via 9ff13d64c4ea9b3539f9b162bc8c70f2a30f288e (commit)
via 8828bdc7021714621ebef63e847c2998658b4863 (commit)
via 8acb224e90a03175133f8b295229b6f0e096177d (commit)
via 4bd4f3e82bc77c18ae38a8db94c0ad74747930b0 (commit)
via e8a9e3744523671228fef385ce7e1e11f93283b0 (commit)
via 3ab8032f1679c2a3526ccd458eb130c0d0f917bc (commit)
via eab6c0c99e29e10a3ac409b8de7c0e39ef918358 (commit)
via 15a68714919c64edc04d6e26679fabb490bdf9a2 (commit)
via 0513782fe3bb2884d0f63fb11c69f06055332388 (commit)
via 05fa29ba8bc2dbfaa9af7ed1263554c7cdc9214d (commit)
via 4f0c9b6c610d1eb9a5bcccf6dbf3f53410df9432 (commit)
via faf4c1fb6012941134046db14370f60748184b05 (commit)
via 2c6f2f4ef5a50c36676308f6663c0d21edc6aa70 (commit)
via a8bd2af7103bca7145f8c566ec46f27e2be8d182 (commit)
via 61a00c3832332bc27b991d3e20702a7f900e5098 (commit)
via 81a7e0cbe9851c2388e53950a6db3e75b1156ead (commit)
via cdde777d9cf157460201c59c5cc05c7479c3f830 (commit)
via 4b1b79582c5de530100b4ddb909163a6fb9b23c8 (commit)
via 6951d2327b0f0b6999f66452d5c38d74136cdb12 (commit)
via ec239402eac198af635f14970bf411e5690dd02e (commit)
via d3c7d410a87f02956523b64bc5af380804e67690 (commit)
via b3d98a4d7daa0bff45b113ed9757ce04378a31e7 (commit)
via 1fb06929d9769077296a4e0464443fa755c3916b (commit)
via f8b95e83bbcb3309c8c5d83c55d20b5479a29c4b (commit)
via c56ecfd924b16d15bf74385c4d556a6b7002e8a6 (commit)
via 75005f92201fdcb89cbcb699dc27f11b293787d3 (commit)
via 461cf1530811a2f7de7792690567da6f4f7289f0 (commit)
via c1a0001226d918571006a87dd22e13dd32f80e84 (commit)
via f3a1b49dd83f31399ae5eadfd80744d0cbdeeb0a (commit)
via 076e54e1e5bfabba7cf2cba02ba13a86f3dc9ba1 (commit)
via 67796f2f7719bab44df4299587fc57f43886a47f (commit)
via c2da6cbd25101cba9ae31a8fdebc253a61ff79cc (commit)
via 2a937ae040d56864d2e6f29bdd682113cf40d9f6 (commit)
via 387fd203936c7623ed9a2a503eef3bb47418dffc (commit)
via 71d3e7b4ca25f08eb97e93edf4740282d8475d25 (commit)
via a2388a91cf9ceb7efb203a7b4d6d250395cdb744 (commit)
via 3ecced92f335f80a372cf3fb0ab1c6f7c564cebb (commit)
via 57715fc70cef09e39b9f8b6277b02304d4281a95 (commit)
via 489f6f1fa32f8017659529f2dc6a26780f8bb277 (commit)
via 3940a078b118b0b81b1d799d8b83a8753aa0d3ea (commit)
via 2adf0a9c44a0ebb0dc9060aa5f3e27f65e21875d (commit)
via af5f4a570453c2d0b1dcfd06044ad3abb3bd4325 (commit)
via f814edee75db5158f8fbb1930e25e0877d5448de (commit)
via 90541333c052b1c89a3f97c1adecf62aeb178668 (commit)
via 5e1236a8e7f31d8ded05b5e710009145d79dea6e (commit)
via 43e91251ad7844961f75c8af0ce7605c6e33f09b (commit)
via 601d9da66d173152fcc095d271b08b43a02ca905 (commit)
via 7d808e95496b8f2175537f03dd2edd6bb58156c9 (commit)
via 10afe5f61585db3944c70808af36b74da09ae061 (commit)
via fab01f4f1a11e0e2db971247a3dd8e00ccb9bcbe (commit)
via b42d253f8697f8d2afa0d25367aa722f4a0c0812 (commit)
via 22d917c92d3f49379a57bad3dcd4b87817717848 (commit)
via d8dd2e245704144bae938497643d9d8bc828ebf0 (commit)
via 1de0ebf2e50603859ec18cfd94472b3041d381e8 (commit)
via 975931a4f664c5d1423a98a193759874eec99201 (commit)
via e652eed4933c9b1f39246dd31ead25c107628fbe (commit)
via b18c7aaa89919222122f31aeafaf8bf10eebafdc (commit)
via a2396edde4f9746cfeb416ece9e20916de3216a4 (commit)
via 0dcfc2fc5dbc7b65cb0234dfbf340a22bd625638 (commit)
via f89ec1df3707d9897ffc2827297e9c9e4843f016 (commit)
via 7b78ef336122f28c2d2b4cce253683941a31b797 (commit)
via 1ef1edc9e0bc001f3324bc7fa616c4bd0cc79466 (commit)
via 608a18caff8d1b994ab24fa74b64885e67e6348e (commit)
via b78e887ba097decb2fc774ab70f2bd8a671f9928 (commit)
via bd4377d693a8082168c618ad1da172daebcd1662 (commit)
via e582497322428f72343115f055e9e198047fe3b4 (commit)
via c830d14d0bd06dda4eaf7de27ae97b826173afe1 (commit)
via fa5e6fcdf90907e238ea74edf4ffdba7656fb163 (commit)
via ca12878c2f0c1617a1b86a0c54b3a94b88c1caa6 (commit)
via 9d858085c31a668aae89c696fef1a684c50cb8c6 (commit)
via 315c0b0c60de10bea1f05be568ee271afe0f28d1 (commit)
via 1776a0e61e7e52c9e366103f7af129d1fc554fdb (commit)
via 6efe60ee1d00d61362a52c92b2c6404b88321769 (commit)
via 17de8d91ac51f487a8a7fc95bd9fc5edfd2d30cc (commit)
via 11d2921bbfca6c00ec1d68bdb6ddd25beacbec3d (commit)
via a91c7cdf04436af33aa6e8656889add097ca15e8 (commit)
via fa1af79e7ca9cd2e0923f21bb6fd7069cf827f12 (commit)
via e0c3e929f50396b8598fdcdbd9a1d2aa35ed2162 (commit)
via 92601c26aef50f924df63161305888a96b70383c (commit)
via 26c568af15eb266d188909c848406c07563286db (commit)
via 1f96c0a413c26db03cd2921ef795972c47997747 (commit)
via 7cbff32f92596119896582925978016e9d672f58 (commit)
via e34b783b8d22194873b8493fc75a4b93723c4b4b (commit)
via 08e88124d790da0bef5573dba722951d3878463e (commit)
via 2dba1d064d86912dddda2f7ff8915130ebe0ccc2 (commit)
via b00a43139e174ec01fa12a225f4a468c8ed4cf40 (commit)
via 1beb1e938fe979fb8051126218295fbd878ad9b0 (commit)
via 7b5639d9821ca94865e25bc7c53fb3f93108c455 (commit)
via 239205033ccdd215c1fcc058be2c844ea03e4870 (commit)
via cd0ed2249437a849f5a865eef35b24934b748672 (commit)
via 91d621521580a783b24194a341978dad67b9d6e5 (commit)
via a64f8eb8a02d6b8816aa5a1d159405bf7aaa1e7e (commit)
via 9800c5f298f2a6387cf8ef9341e9b01f35fcb2a6 (commit)
via c71b1ec91bb4a51e434c323a82bf4fbc046d932a (commit)
via 8f8cda2b48d1063366302204559c1ed3362656bc (commit)
via a8a6098f689a936307ca11cc922a8fc535654007 (commit)
via 5aa2feaa06fc7850a4c4892293b1174a8d4ed92c (commit)
via 7543833037e1e44f8f4b6ce950c4d7833bd93c42 (commit)
via 404b522119daf6d49687a304c9fa2693e8e8f81a (commit)
via 2d5db505e70336e56e739d56d8ca358fc6bc4a6a (commit)
via 30646c31454cb3effc7bba66ae74f0a4a708ebe0 (commit)
via 72277de6ead1324bbd7fa512e772d92e1f4b0951 (commit)
via e8e15b91333c8528eb398557c33cca6a0a82fb6d (commit)
via 923cc06f98d32946d384016f385fad47525a269f (commit)
via 02360ec7be6b061513f07638d015da066afef7dc (commit)
via 0e5824c8e851ee6fd29868eddd3be2b738f3351e (commit)
via a815ad62502669e9a2b689f6f609eb03008a4ca4 (commit)
via c95cca4ca6e806f1e2a3a829ce0dda655fdc886d (commit)
via 59b108498a5c45b3fbab4fed5bfe55881e9ef1ad (commit)
via 91f4f89d4c864c6ce0170d60a13a29aed56fea5d (commit)
via fe00eac8cb0740b74ec2f586d98e741c84299d90 (commit)
via 78d53fff1f7cd6dc3a40c01ac3b31b0eb7ab7e21 (commit)
via f23405f667e7514cff93ebc83cb6d1f7ab9005c0 (commit)
via a1668f6c1e0c9e88f62f6082c6206c4d33f25cce (commit)
via efeeacca8621076f285ead0fc7e95d61938daea6 (commit)
via 16b66d3af521e79c8c003fb51ca6b8c64fec4d86 (commit)
via 477b65eac08a8b28c7dc4607ae51af28a31b90fc (commit)
via 6a3f7a386ed7912d19971dec9235ad98692c22c1 (commit)
via 0b67394618b38a299dab9b65b66d7981f0df46e0 (commit)
via c80551b64b57b6200bd0ea012dd14118725ad64d (commit)
via 5f65b1caa705f07a0efbeb9cebcfc27800525a7e (commit)
via a0d51e5f686a21de91b9ef44ed74dc8116ef3b46 (commit)
via ab7e5c293677ef736064b0e222c2b9ed5b654f12 (commit)
via 68b20a382d3c2fe23ebdd152ed39c0290bcc6fa7 (commit)
via 1457a049bb9e77cd85fda95ce492a4d79f536f4a (commit)
via ebb2a33b0b68104920abbfa2c447595d2c3a2010 (commit)
via 9aecf47408f22f4f0a01e41648f25e1a7307b332 (commit)
via b63443b243bec435c1650aef2068299674b2a209 (commit)
via 4b14f9ff37b4c0614a8f039aa393aa3c6bb86c97 (commit)
via cd488602073a1775c41a60d582854feec63cb676 (commit)
via 1ca5b7332c2b10b671e6844b79ed58d50337ce52 (commit)
via 94de23dce9b4cb490bcaf08433c6ba75abf4a29c (commit)
via 9176d3233fc395f579a33484ed714649e1fd8f46 (commit)
via 6a2675557690a7eeab7b5c4ca70a80fd194e6466 (commit)
via 115985f069247d5eb6c5955de7de110114db9ca4 (commit)
via d35ad1b8e707f9dc8ccad5b11efc4eec0302f3ad (commit)
via 24c195910506e99b7d9152524aeaef042da1dedf (commit)
via 747958c14caa03f48fdd3256d63601b513ca499c (commit)
via 54860ee6b8fe1ad33977eca490200929ea9cfac5 (commit)
via 5830a4c0402da9acdcf20b62b359d762dd8c235b (commit)
via 4bc029340eb0576eb40b8766be67b31e139bf385 (commit)
via 958fb6aa5ea5ca93c5b099633ba72ee509a47547 (commit)
via 4448fa6cbf9aade05d02f5e04b9137d4c775a79a (commit)
via 1158536bffb35ebaeca1b6bc7d4f39e49725a660 (commit)
via 4b90528d3c1871118ed55c76b105805c8a63d539 (commit)
via 655b619fd4fe3c1f09973b51f67e579c2bd89c00 (commit)
via c1aec1cfa0d5fa64dff2d177800797d7e3d8c15c (commit)
via 05d2b9a92cd718a38aed647400159c6c40a743d2 (commit)
via aa10f2f1efd9e910b675381c7be3d363c019e06a (commit)
via 4394587ab0e9bcb51b6d482497c11c72da0723de (commit)
via 0e76523e4c12120870a03a5f51143c6283c2704e (commit)
via cc3c1eb99b01ea2dbcb5751a37f2d0eed6744354 (commit)
via 35d9baa14e40bbf65d6c947561033b05adfd2c1a (commit)
via 8547452232e1cc7664fe3af7cbcfc4cead9d7d92 (commit)
via 597d167b9d06d417872db81c8d328318e1b0d85a (commit)
via 124d3fe9f05f0c80dc75bcfec2b23302c8a1974a (commit)
via c0f4bbb3083b56bf4f1e089a40ab059233b88495 (commit)
via 40ae120360a956daa6e29260d0a4f584632f212d (commit)
via 62b76bf31aa79db6b16e9c6601b89f821bf970f1 (commit)
via b2a78c5c6e28957aa1f3e22dc23516cd8b251caf (commit)
via afc79d5912a34b4e5471722ffbf1ec0f8459a2a7 (commit)
via f17e88e7098a5b1c817184e6bf59dcc5d9073ae9 (commit)
via 189b7b45fb9805d1beae9506cac2c001bd680470 (commit)
via 73b81a59ccaf09f695a643eae06fb510ec4559b4 (commit)
via e8df81fdb3ab94977c42a4a0fed082602308f3c6 (commit)
via 5a73f0797fe8b3c1350bc57405e789517478bc36 (commit)
via eb5e0599afe3bae86a375acea4d8ca106594c45b (commit)
via 908db8a51d21163e8c7607538834693b4e2ae490 (commit)
via 378d975474315e98fe545a644f5499575d556f9d (commit)
via af191bbcc91512650ee5a2db5e1b25a20e410919 (commit)
via e0d531b824ce00b2b7c6f3c444f0855774c12f11 (commit)
via b939afe3fc70be446d9ffd6e6071a4af5cf98a8a (commit)
via 51725592c96b3cb94aa70761b10960c738815534 (commit)
via ca5b165c85e1e8cc7df286b6a0a9a061de99bcaa (commit)
via ea84f67035ea9899086223c540a79ffec328caef (commit)
via 0f5d7cfcd2daade443ea0695275171247e2cfc22 (commit)
via 8dbb61d2f57b32483d67434e9ac169b5f14e7460 (commit)
via 3303c005eedd67c5b973c64f2515b28f9a7f56d2 (commit)
via 2d41d6c933cec1a0660bc71aaa115b41dcfdfbed (commit)
via 0c7649d030d980755d9659574214f104368fc6a0 (commit)
via a122b94efde125202388d135e36eb86e6d25d093 (commit)
via 7bff70e7466dd80603922ba0dfdad1725cce41a6 (commit)
via 7417a21bb1f0e8e00958319f60d8c12a9502a353 (commit)
via e88d82f87f8dda23fa87cf730abebff5078ee629 (commit)
via b4e21b76fd0b8b4a048f0d8125bc5a36c0ca8d42 (commit)
via fa2e3b778465cd496aedde8e187038835a765c4f (commit)
via cf753f20cc2a8506c831a5cedd933e3e78417261 (commit)
via a543206075d86cc7c4ea3db96b96e94a12cf8c7f (commit)
via 7202ff2f649561dd98cb721bdf88b4735127bba9 (commit)
via 90a260a2ccf33a399c87b1619d3b82e19b84020f (commit)
via f9870c41f5404be33a15fe75f8a431053782597b (commit)
via 83f95fe05e98464ffa832df6f17ca619cc173bc2 (commit)
via 9ee6e90de5394042bdd082cc1ddc7837387ad770 (commit)
via d03f0ee04e8b2fe800bf66082c7afbbb45de9d09 (commit)
via 78d45e9b828f74667a5e002b46a330fca893fb6d (commit)
via 6239b32d92069595da0ba788311a3f9e4e71e690 (commit)
via 36a2a77a8e09fd56dfaea0efb1af627e14b4ceae (commit)
via d0a1ee7ac0137a1ab51551649ce9f3f1522e4a39 (commit)
via 794f12e4b5236cb686f61fa18968455b4c960d66 (commit)
via bb87d63f0299df524c861e523f22ee6efb17af4c (commit)
via 7fe13d5afada707cd2f7fd6e33d288bef3383474 (commit)
via 6a9a8d6127e3fd677dc8ad28d14b4d84b3dfdc40 (commit)
via df8aeb4a88210b5ce0738b08d96f619f6ce6bfea (commit)
via c9daec556780610d5d4a25f35d06a288294da744 (commit)
via 39dcd22b05342e639c587de8e1af382e7dee2454 (commit)
via d39f98065a7c52c63e3c037a0a64f94186c3ce00 (commit)
via ddcc914a3ffe02edaeafa93eecf54a77daf8a4cd (commit)
via dc633bc154b913f8f5b6ce33ee34eb1dcfee75d4 (commit)
via 796974521786d65f1117cf22c23bb1592a27b6f0 (commit)
via 59b29930d7c89c53f85d4536bb3657b1c0bd2736 (commit)
via eb9571ede701defafd2b9685138826a719124b5b (commit)
via bada456d49c31944861ea08636d439c0ffffec0b (commit)
via ea00b378744f98e38b0c00e97a5c78d9d76d6dd3 (commit)
via 61979923c146b4456d24e794a44c08adc334cff6 (commit)
via ea9932dd00cc5384bc9f19d2addf683712983a4f (commit)
via 65bf58e4a1999fca0de1279e143f714acc19fe8d (commit)
via 313c48b8a15b6ebe683ceb8a995c62e2e0e97616 (commit)
via 6c8225d3ab17f25aa1e8ed7f22533772c8d98245 (commit)
via 65175b4362e01a7bf2f373dc100b7fb0ec4cf44c (commit)
via 8066d1c8b4ef4e8e19d22aa2d92950339271b351 (commit)
via 0758af6631674d2ca88ca127c4b42842821ab7d0 (commit)
via 85d76a0e045b9e98c16e4398995af62cec1f3d0b (commit)
via 0ae788752cdeb259eaadb756a18e9065da1c6d22 (commit)
via 012b7977139b506220e8dffa4367877dbe6f2594 (commit)
via 690066bb56e49fb21c66b47cdbe33ca6e51e16ec (commit)
via 4f59f5309f6648e3c1508b53560bbf541e67ebde (commit)
via 8dd5b560a5fb9ab59062b9f6c629df036f007c64 (commit)
via c313524998377db92e5387d209e1ea79fbc30ba6 (commit)
via c523bb47a0c884f58ab267eb9ad699ccbed907d5 (commit)
via be1ff548cb3c877335bfd6cf389b4d01283d6f41 (commit)
via 47ccd9855db44881339e68093655247a78fd8598 (commit)
via 767b73f5c703e447a3041423ff220a88a7c0c569 (commit)
via a468b409901236ecf77f0cbd81dfeda96cebc758 (commit)
via ab6c03f3112ef01e41a8a1e931a6990636edbae4 (commit)
via d3cfbc30778647d287e9ee47359f18de716c9633 (commit)
via 7051b9e563f7cdf5e09e65a33b5ac0152061e541 (commit)
via 14bf4b47a5ea36ba329e5910f3aa1d26cc452be9 (commit)
via 75dcf093940c04a6c685dba35a278e35da018727 (commit)
via 66d0f14b32d11042872f6bfe33152521bf470e6a (commit)
via a60c4749ff734168d773d1b527b83ce7ce6d83a1 (commit)
via 976eca99580339c8cbb81819b54134de9ac8b97e (commit)
via 22d84a587b299f028dbff4d3f8d8ecd56b275c2f (commit)
via 7dcc725ae2e9351d4b8fb5350b0157cd4699d9fb (commit)
via f236e7d6b7a80a3d95e278fdfa127be6fc1f7ea0 (commit)
via 3153335fdecc9b5d3e7a55d4416790504f9d96c3 (commit)
via 8fdf262683dab03fb01941f74cfa698b1f9d6834 (commit)
via 042fcb82b83d19bf08afd3367235ac71a60b3850 (commit)
via 9754539e2275e33af34b5de9d343b85e8122d871 (commit)
via 0fad46cd0f21af5b896e7a6ee1f3b45fdf2a091a (commit)
via 9c8d60792f42b5dd6b56e38bfc10467d1a5d22a7 (commit)
via 8861923455a294927398c3207c12ed3e2d6f350e (commit)
via cba3a1468c07d4bd192967e43b05edc567306dd0 (commit)
via de3194d1feda216361bbc98032d3c2b4f43a6817 (commit)
via 3743c78d5629ff5b1400e4a52a6325004de340fd (commit)
via 7f8e453a18a75f3a4f129d4e743c5b861fbe77c5 (commit)
via 5074190c0172678b77039534b17eb765700774a1 (commit)
via cf73e369efbb0c8b7f715e5c0a77e00e4c6fc570 (commit)
via 0c53ad0e67b7e643df676d03721ca5d0691f711e (commit)
via 76a68d7dd02f3819e4e60cd9febfd45e20821e14 (commit)
via d923e109cd56c553c8e87cdb8bdab5085e68cc73 (commit)
via 88ae1ff267c541ded537672ac7b7f29308ad701d (commit)
via df2b14ed5f26f6aabaad548d38a24a724b242047 (commit)
via ccccf76ff841bbd9df517a184b14c3706491c6ce (commit)
via 26acc5d5c72ac8968758a0975dcd3f506fbcab15 (commit)
via a4ed8bf4c9900e0361636dd95a98cf26a54a2e8a (commit)
via e1dea53d2aa5e44df2fa17fd18885ffd901b1fba (commit)
via 0bbb4f5a2a9d4fa3f29bcd9fc041646fc68a54be (commit)
via fcde28d97f3863d8be4f6245e20f6471c9bfacb6 (commit)
via 148748b82c29160224486af7eed0d62f37031cb6 (commit)
via aa53519bcd5b716306e0fb0ec2a89d953128bc85 (commit)
via 667605869fba31c48e61736f89efe4126d27db0c (commit)
via 7fc0a4c481d7adad14a42740037d50b2f9e1cdc1 (commit)
via 8711fbe47dd0381efd09717b719b79be3d819f49 (commit)
via a996bee9facdce826c5fc3a819dd0ce362d80e95 (commit)
via c041393e66b4a75cfc1165e184be77cc974a63cb (commit)
via 9ce71876ce500e242e2384c21abb38a8f431138b (commit)
via 527756cca0471a55389a3494d35f9b1b13f20b7e (commit)
via fe7eb85614244d5e0659c88431fbd9726fa33051 (commit)
via aa5090c85b6890f79d340ad2de6219237f2d6c4c (commit)
via c821ed2bbd91e1b4fe2b74c01cce1a4106f37655 (commit)
via d240bec03627f5a26cd70e83a58483c69834f7c2 (commit)
via 1eb86d9df2d6897d11b712f21d4ac23390fbdc70 (commit)
via 903c4dbef9fae1e24a66a8ff7b745c799f6726cd (commit)
via 2dab078f21db7dec5a29079daf9a5f0a06a6e0bd (commit)
via 6722943b81c0dba84ed187b2d117cc92972117ed (commit)
via c25eb6b7e7a08d7e2aaf33994c2c24053cf47b82 (commit)
via cab33679f828a9113d2ef8d05cad9d3f5c783e67 (commit)
via 3224d7121aff91ab8d888831dc493ef621e3dd39 (commit)
via 93be8d805e7e1f32638015770446476fef22ceac (commit)
via 8c00da9ec6abafca3111aa6c488301664d6904db (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (53a5c4f6b679885948984b0a99f5195be3dd4345)
\
N -- N -- N (36b26b861f375de5b2be3ff9de37288049f05a26)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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=36b26b861f375de5b2b...
commit 36b26b861f375de5b2be3ff9de37288049f05a26
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Update to test ExtMem on OS4.1FEU1
Mostly works, but falls over when there are lots of tiny GIF anims on screen
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 8c0f0b3..fe84a94 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -230,11 +230,6 @@ void amiga_bitmap_destroy(void *bitmap)
ami_memory_clear_free(bm->pixdata);
}
-<<<<<<< HEAD
-=======
- if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
-
->>>>>>> Fix merge error
if(bm->url) nsurl_unref(bm->url);
if(bm->title) free(bm->title);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=43bbdc520dd054acdf4...
commit 43bbdc520dd054acdf46088fbbee5d4a3b638d24
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Fix merge error
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 06d1f1f..8c0f0b3 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -129,7 +129,7 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
bitmap->pixdata = NULL;
UBYTE *pixdata = amiga_bitmap_get_buffer(bitmap);
- memset(bitmap->pixdata, 0xff, bitmap->size);
+ memset(pixdata, 0xff, bitmap->size);
} else
#endif
{
@@ -230,6 +230,11 @@ void amiga_bitmap_destroy(void *bitmap)
ami_memory_clear_free(bm->pixdata);
}
+<<<<<<< HEAD
+=======
+ if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
+
+>>>>>>> Fix merge error
if(bm->url) nsurl_unref(bm->url);
if(bm->title) free(bm->title);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b7551fec72372df4cb4...
commit b7551fec72372df4cb40384818da5419904e4c98
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
NULL iextmem
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 02d8116..06d1f1f 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -129,7 +129,7 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
bitmap->pixdata = NULL;
UBYTE *pixdata = amiga_bitmap_get_buffer(bitmap);
- memset(pixdata, 0xff, bitmap->size);
+ memset(bitmap->pixdata, 0xff, bitmap->size);
} else
#endif
{
@@ -222,6 +222,7 @@ void amiga_bitmap_destroy(void *bitmap)
ami_schedule(-1, amiga_bitmap_unmap_buffer, bm);
amiga_bitmap_unmap_buffer(bm);
FreeSysObject(ASOT_EXTMEM, bm->iextmem);
+ bm->iextmem = NULL;
} else
#endif
{
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=570212add2ec6b70474...
commit 570212add2ec6b70474eb49b74259d7c73733c03
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Don't map an extmem area is it is already mapped, just extend the lifetime
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 3ce74a3..02d8116 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -174,9 +174,11 @@ unsigned char *amiga_bitmap_get_buffer(void *bitmap)
struct bitmap *bm = bitmap;
#ifdef __amigaos4__
- if((nsoption_bool(use_extmem) == true) && (bm->pixdata == NULL)) {
- LOG("Mapping ExtMem object %p for bitmap %p", bm->iextmem, bm);
- bm->pixdata = bm->iextmem->Map(NULL, bm->size, 0LL, 0);
+ if(nsoption_bool(use_extmem) == true) {
+ if(bm->pixdata == NULL) {
+ LOG("Mapping ExtMem object %p for bitmap %p", bm->iextmem, bm);
+ bm->pixdata = bm->iextmem->Map(NULL, bm->size, 0LL, 0);
+ }
/* unmap the buffer after one second */
ami_schedule(1000, amiga_bitmap_unmap_buffer, bm);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=adac4d98bb9acdeb767...
commit adac4d98bb9acdeb76725c946e53ff0e2c0235df
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
More logging
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index fb30ab5..3ce74a3 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -702,6 +702,7 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
int width, int height, struct BitMap *friendbm)
{
if(bitmap == NULL) return NULL;
+ LOG("Getting native BitMap for %p", bitmap);
if(__builtin_expect(ami_plot_screen_is_palettemapped() == true, 0)) {
return ami_bitmap_get_palettemapped(bitmap, width, height, friendbm);
@@ -719,6 +720,8 @@ void ami_bitmap_fini(void)
static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
{
#ifdef __amigaos4__
+ LOG("Entering bitmap_render");
+
struct redraw_context ctx = {
.interactive = false,
.background_images = true,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=982a59744f634aee73d...
commit 982a59744f634aee73dc11d4a30c93b4652a1e7e
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Revert "Disable ExtMem in palette-mapped modes"
This reverts commit 4db40c3f27d0ade8fc76f57cd383e5ff52ad7c93.
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index f485e0b..a51d8c2 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -545,10 +545,6 @@ static void ami_set_screen_defaults(struct Screen *screen)
nsoption_default_set_int(redraw_tile_size_x, screen->Width);
nsoption_default_set_int(redraw_tile_size_y, screen->Height);
- if((screen != NULL) && (GetBitMapAttr(screen->RastPort.BitMap, BMA_DEPTH) < 24)) {
- nsoption_set_bool(use_extmem, false);
- }
-
/* set system colours for amiga ui */
colour_option_from_pen(FILLPEN, NSOPTION_sys_colour_ActiveBorder, screen, 0x00000000);
colour_option_from_pen(FILLPEN, NSOPTION_sys_colour_ActiveCaption, screen, 0x00dddddd);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=205abcf18950bf3ee86...
commit 205abcf18950bf3ee8600c4a4e4945b096985f9e
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Debug logging
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index b81e7d6..fb30ab5 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -161,6 +161,7 @@ static void amiga_bitmap_unmap_buffer(void *p)
struct bitmap *bm = p;
if((nsoption_bool(use_extmem) == true) && (bm->pixdata != NULL)) {
+ LOG("Unmapping ExtMem object %p for bitmap %p", bm->iextmem, bm);
bm->iextmem->Unmap(bm->pixdata, bm->size);
bm->pixdata = NULL;
}
@@ -174,6 +175,7 @@ unsigned char *amiga_bitmap_get_buffer(void *bitmap)
#ifdef __amigaos4__
if((nsoption_bool(use_extmem) == true) && (bm->pixdata == NULL)) {
+ LOG("Mapping ExtMem object %p for bitmap %p", bm->iextmem, bm);
bm->pixdata = bm->iextmem->Map(NULL, bm->size, 0LL, 0);
/* unmap the buffer after one second */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=937dce4f2eef86c563b...
commit 937dce4f2eef86c563bb93ded5c355c1446bf88c
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Schedule unmapping the extmem object to ensure it releases main memory
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 84c555c..b81e7d6 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -58,6 +58,7 @@
#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/rtg.h"
+#include "amiga/schedule.h"
// disable use of "triangle mode" for scaling
#ifdef AMI_NS_TRIANGLE_SCALING
@@ -154,9 +155,11 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
return bitmap;
}
-static inline void amiga_bitmap_unmap_buffer(struct bitmap *bm)
+static void amiga_bitmap_unmap_buffer(void *p)
{
#ifdef __amigaos4__
+ struct bitmap *bm = p;
+
if((nsoption_bool(use_extmem) == true) && (bm->pixdata != NULL)) {
bm->iextmem->Unmap(bm->pixdata, bm->size);
bm->pixdata = NULL;
@@ -172,6 +175,9 @@ unsigned char *amiga_bitmap_get_buffer(void *bitmap)
#ifdef __amigaos4__
if((nsoption_bool(use_extmem) == true) && (bm->pixdata == NULL)) {
bm->pixdata = bm->iextmem->Map(NULL, bm->size, 0LL, 0);
+
+ /* unmap the buffer after one second */
+ ami_schedule(1000, amiga_bitmap_unmap_buffer, bm);
}
#endif
@@ -209,6 +215,7 @@ void amiga_bitmap_destroy(void *bitmap)
#ifdef __amigaos4__
if(nsoption_bool(use_extmem) == true) {
+ ami_schedule(-1, amiga_bitmap_unmap_buffer, bm);
amiga_bitmap_unmap_buffer(bm);
FreeSysObject(ASOT_EXTMEM, bm->iextmem);
} else
@@ -268,9 +275,7 @@ void amiga_bitmap_modified(void *bitmap)
amiga_bitmap_unmap_buffer(bm);
#endif
- if((bm->nativebm))
- ami_rtg_freebitmap(bm->nativebm);
-
+ if(bm->nativebm) ami_rtg_freebitmap(bm->nativebm);
if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
bm->nativebm = NULL;
@@ -437,10 +442,6 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap)
bitmap_get_width(bitmap), bitmap_get_height(bitmap));
}
-#ifdef __amigaos4__
- amiga_bitmap_unmap_buffer(bitmap);
-#endif
-
return dto;
}
@@ -470,10 +471,6 @@ struct bitmap *ami_bitmap_from_datatype(char *filename)
DisposeDTObject(dto);
}
-#ifdef __amigaos4__
- amiga_bitmap_unmap_buffer(bm);
-#endif
-
return bm;
}
@@ -645,10 +642,6 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap,
}
}
-#ifdef __amigaos4__
- amiga_bitmap_unmap_buffer(bitmap);
-#endif
-
return tbm;
}
@@ -768,10 +761,6 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
ami_free_layers(&bm_globals);
amiga_bitmap_set_opaque(bitmap, true);
-#ifdef __amigaos4__
- amiga_bitmap_unmap_buffer(bitmap);
-#endif
-
/* Restore previous render area. This is set when plotting starts,
* but if bitmap_render is called *during* a browser render then
* having an invalid pointer here causes NetSurf to crash.
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=493036a920aba5cf470...
commit 493036a920aba5cf470637b7aa2ca69f7f57b41c
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Documentation
diff --git a/frontends/amiga/dist/NetSurf.guide b/frontends/amiga/dist/NetSurf.guide
index dd2f46d..8fc6cc3 100755
--- a/frontends/amiga/dist/NetSurf.guide
+++ b/frontends/amiga/dist/NetSurf.guide
@@ -145,7 +145,7 @@ There are a couple of Amiga-specific options which can only be changed directly
@{b}web_search_width@{ub} Defaults to 0. Larger values will increase the size of the web search gadget next to the URL bar.
@{b}mask_alpha@{ub} Threshold to use when determining which alpha values to convert to full transparency (0 - 255, where 255 will convert even opaque pixels to transparent). Defaults to 0. This is only used in palette-mapped modes where alpha blending is not currently supported.
@{b}tab_new_session{ub} If NetSurf is already running, this will cause any passed URLs to open in a new tab rather than a new window.
-
+@{b}use_extmem@{ub} Defaults to 0 (disabled). Setting to 1 will make NetSurf use Extended Memory to store uncompressed images. OS4 only; does not work on Pegasus 2.
@{b}url_file@{ub} Path to URL database file
@{b}hotlist_file@{ub} Path to Hotlist file
@{b}arexx_dir@{ub} Path to ARexx scripts dir
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a83afda7918cdb7ebc2...
commit a83afda7918cdb7ebc28db204ceb3e0f3d1cb0d3
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Disable ExtMem in palette-mapped modes
Something handling palette mapped images causes a freeze.
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index a51d8c2..f485e0b 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -545,6 +545,10 @@ static void ami_set_screen_defaults(struct Screen *screen)
nsoption_default_set_int(redraw_tile_size_x, screen->Width);
nsoption_default_set_int(redraw_tile_size_y, screen->Height);
+ if((screen != NULL) && (GetBitMapAttr(screen->RastPort.BitMap, BMA_DEPTH) < 24)) {
+ nsoption_set_bool(use_extmem, false);
+ }
+
/* set system colours for amiga ui */
colour_option_from_pen(FILLPEN, NSOPTION_sys_colour_ActiveBorder, screen, 0x00000000);
colour_option_from_pen(FILLPEN, NSOPTION_sys_colour_ActiveCaption, screen, 0x00dddddd);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=0804c43bf1afa0cb9d8...
commit 0804c43bf1afa0cb9d851ceb89e29ec8096f272f
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Allocate uncompressed bitmap data in extended memory.
This currently isn't working correctly - it simply freezes at some point after loading the page.
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index c6e23b2..84c555c 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -40,6 +40,7 @@
#endif
#ifdef __amigaos4__
+#include <exec/extmem.h>
#include <sys/param.h>
#endif
#include "assert.h"
@@ -67,6 +68,8 @@ struct bitmap {
int width;
int height;
UBYTE *pixdata;
+ struct ExtMemIFace *iextmem;
+ uint32 size;
bool opaque;
int native;
struct BitMap *nativebm;
@@ -113,7 +116,25 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
bitmap = ami_memory_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
if(bitmap == NULL) return NULL;
- bitmap->pixdata = ami_memory_clear_alloc(width*height*4, 0xff);
+ bitmap->size = width * height * 4;
+
+#ifdef __amigaos4__
+ if(nsoption_bool(use_extmem) == true) {
+ uint64 size64 = bitmap->size;
+ bitmap->iextmem = AllocSysObjectTags(ASOT_EXTMEM,
+ ASOEXTMEM_Size, &size64,
+ ASOEXTMEM_AllocationPolicy, EXTMEMPOLICY_IMMEDIATE,
+ TAG_END);
+
+ bitmap->pixdata = NULL;
+ UBYTE *pixdata = amiga_bitmap_get_buffer(bitmap);
+ memset(pixdata, 0xff, bitmap->size);
+ } else
+#endif
+ {
+ bitmap->pixdata = ami_memory_clear_alloc(bitmap->size, 0xff);
+ }
+
bitmap->width = width;
bitmap->height = height;
@@ -133,11 +154,27 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
return bitmap;
}
+static inline void amiga_bitmap_unmap_buffer(struct bitmap *bm)
+{
+#ifdef __amigaos4__
+ if((nsoption_bool(use_extmem) == true) && (bm->pixdata != NULL)) {
+ bm->iextmem->Unmap(bm->pixdata, bm->size);
+ bm->pixdata = NULL;
+ }
+#endif
+}
/* exported function documented in amiga/bitmap.h */
unsigned char *amiga_bitmap_get_buffer(void *bitmap)
{
struct bitmap *bm = bitmap;
+
+#ifdef __amigaos4__
+ if((nsoption_bool(use_extmem) == true) && (bm->pixdata == NULL)) {
+ bm->pixdata = bm->iextmem->Map(NULL, bm->size, 0LL, 0);
+ }
+#endif
+
return bm->pixdata;
}
@@ -169,8 +206,17 @@ void amiga_bitmap_destroy(void *bitmap)
}
if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
- if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
- ami_memory_clear_free(bm->pixdata);
+
+#ifdef __amigaos4__
+ if(nsoption_bool(use_extmem) == true) {
+ amiga_bitmap_unmap_buffer(bm);
+ FreeSysObject(ASOT_EXTMEM, bm->iextmem);
+ } else
+#endif
+ {
+ if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
+ ami_memory_clear_free(bm->pixdata);
+ }
if(bm->url) nsurl_unref(bm->url);
if(bm->title) free(bm->title);
@@ -218,7 +264,11 @@ void amiga_bitmap_modified(void *bitmap)
{
struct bitmap *bm = bitmap;
- if((bm->nativebm)) // && (bm->native == AMI_NSBM_TRUECOLOUR))
+#ifdef __amigaos4__
+ amiga_bitmap_unmap_buffer(bm);
+#endif
+
+ if((bm->nativebm))
ami_rtg_freebitmap(bm->nativebm);
if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
@@ -387,6 +437,10 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap)
bitmap_get_width(bitmap), bitmap_get_height(bitmap));
}
+#ifdef __amigaos4__
+ amiga_bitmap_unmap_buffer(bitmap);
+#endif
+
return dto;
}
@@ -416,6 +470,10 @@ struct bitmap *ami_bitmap_from_datatype(char *filename)
DisposeDTObject(dto);
}
+#ifdef __amigaos4__
+ amiga_bitmap_unmap_buffer(bm);
+#endif
+
return bm;
}
@@ -587,6 +645,10 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap,
}
}
+#ifdef __amigaos4__
+ amiga_bitmap_unmap_buffer(bitmap);
+#endif
+
return tbm;
}
@@ -706,6 +768,10 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
ami_free_layers(&bm_globals);
amiga_bitmap_set_opaque(bitmap, true);
+#ifdef __amigaos4__
+ amiga_bitmap_unmap_buffer(bitmap);
+#endif
+
/* Restore previous render area. This is set when plotting starts,
* but if bitmap_render is called *during* a browser render then
* having an invalid pointer here causes NetSurf to crash.
diff --git a/frontends/amiga/options.h b/frontends/amiga/options.h
index 3aa8451..b5b2b3b 100644
--- a/frontends/amiga/options.h
+++ b/frontends/amiga/options.h
@@ -89,8 +89,11 @@ NSOPTION_INTEGER(monitor_aspect_x, 0)
NSOPTION_INTEGER(monitor_aspect_y, 0)
NSOPTION_BOOL(accept_lang_locale, true)
NSOPTION_STRING(local_charset, "ISO-8859-1")
+#ifdef __amigaos4__
+/* Options relevant for OS4 only */
+NSOPTION_BOOL(use_extmem, true)
+#else
/* Options relevant for OS3 only */
-#ifndef __amigaos4__
NSOPTION_BOOL(friend_bitmap, false)
#endif
-----------------------------------------------------------------------
Summary of changes:
!NetSurf/Resources/CSS,f79 | 7 +-
!NetSurf/Resources/en/credits.html,faf | 2 +-
!NetSurf/Resources/en/licence.html,faf | 18 +-
!NetSurf/Resources/nl/credits.html,faf | 2 +-
!NetSurf/Resources/nl/licence.html,faf | 19 +-
!NetSurf/Resources/nl/welcome.html,faf | 1 -
.gitignore | 1 -
Docs/Doxyfile | 9 +-
Docs/PACKAGING-GTK | 27 +-
Docs/UnimplementedJavascript.txt | 1 -
Docs/core-window-interface | 677 +++++
Docs/env.sh | 28 +-
Docs/source-object-backing-store | 46 +-
Docs/unit-testing | 166 ++
Makefile | 95 +-
Makefile.config.example | 7 +-
Makefile.defaults | 19 +-
content/Makefile | 7 +
content/backing_store.h | 22 +-
content/content.c | 19 +-
content/content.h | 181 +-
content/content_factory.h | 2 +-
content/content_protected.h | 25 +-
content/fetch.c | 32 +-
content/fetch.h | 26 +
content/fetchers.h | 32 +-
content/fetchers/Makefile | 6 +-
content/fetchers/about.c | 1 -
content/fetchers/curl.c | 438 ++--
content/fetchers/data.c | 33 +-
content/fetchers/file.c | 8 +-
content/fetchers/resource.c | 2 +-
content/fs_backing_store.c | 82 +-
content/handlers/Makefile | 16 +
{css => content/handlers/css}/Makefile | 1 -
{css => content/handlers/css}/css.c | 55 +-
{css => content/handlers/css}/css.h | 20 +-
{css => content/handlers/css}/dump.c | 199 +-
{css => content/handlers/css}/dump.h | 8 +-
{css => content/handlers/css}/hints.c | 30 +-
{css => content/handlers/css}/hints.h | 14 +-
{css => content/handlers/css}/internal.c | 20 +-
{css => content/handlers/css}/internal.h | 16 +-
{css => content/handlers/css}/select.c | 136 +-
{css => content/handlers/css}/select.h | 3 +-
{css => content/handlers/css}/utils.c | 43 +-
css/css.h => content/handlers/css/utils.h | 37 +-
{image => content/handlers/image}/Makefile | 2 +-
{image => content/handlers/image}/bmp.c | 20 +-
{image => content/handlers/image}/bmp.h | 0
{image => content/handlers/image}/gif.c | 6 +-
{image => content/handlers/image}/gif.h | 0
{image => content/handlers/image}/ico.c | 4 +-
{image => content/handlers/image}/ico.h | 0
{image => content/handlers/image}/image.c | 6 +-
{image => content/handlers/image}/image.h | 2 +
{image => content/handlers/image}/image_cache.c | 101 +-
{image => content/handlers/image}/image_cache.h | 1 +
{image => content/handlers/image}/jpeg.c | 9 +-
{image => content/handlers/image}/jpeg.h | 0
{image => content/handlers/image}/nssprite.c | 8 +-
{image => content/handlers/image}/nssprite.h | 0
{image => content/handlers/image}/png.c | 15 +-
{image => content/handlers/image}/png.h | 0
{image => content/handlers/image}/rsvg.c | 6 +-
{image => content/handlers/image}/rsvg.h | 0
{image => content/handlers/image}/svg.c | 7 +-
{image => content/handlers/image}/svg.h | 0
{image => content/handlers/image}/video.c | 1 +
{image => content/handlers/image}/video.h | 0
content/handlers/javascript/Makefile | 18 +
.../handlers/javascript}/WebIDL/Makefile | 0
.../handlers/javascript}/WebIDL/console.idl | 0
.../handlers/javascript}/WebIDL/cssom.idl | 0
.../handlers/javascript}/WebIDL/dom-parsing.idl | 0
.../handlers/javascript}/WebIDL/dom.idl | 0
.../handlers/javascript}/WebIDL/html.idl | 0
.../handlers/javascript}/WebIDL/uievents.idl | 0
.../handlers/javascript}/WebIDL/urlutils.idl | 0
.../handlers/javascript}/content.c | 0
.../handlers/javascript}/content.h | 0
.../handlers/javascript}/duktape/Console.bnd | 0
.../handlers/javascript}/duktape/Document.bnd | 2 +-
.../handlers/javascript}/duktape/Element.bnd | 0
.../handlers/javascript}/duktape/Event.bnd | 0
.../javascript}/duktape/HTMLAnchorElement.bnd | 0
.../javascript}/duktape/HTMLAppletElement.bnd | 0
.../javascript}/duktape/HTMLAreaElement.bnd | 0
.../handlers/javascript}/duktape/HTMLBRElement.bnd | 0
.../javascript}/duktape/HTMLBaseElement.bnd | 0
.../javascript}/duktape/HTMLBodyElement.bnd | 0
.../javascript}/duktape/HTMLButtonElement.bnd | 0
.../javascript}/duktape/HTMLCollection.bnd | 0
.../javascript}/duktape/HTMLDivElement.bnd | 0
.../handlers/javascript}/duktape/HTMLElement.bnd | 0
.../javascript}/duktape/HTMLFontElement.bnd | 0
.../javascript}/duktape/HTMLFormElement.bnd | 0
.../javascript}/duktape/HTMLFrameElement.bnd | 0
.../javascript}/duktape/HTMLFrameSetElement.bnd | 0
.../handlers/javascript}/duktape/HTMLHRElement.bnd | 0
.../javascript}/duktape/HTMLHTMLElement.bnd | 0
.../javascript}/duktape/HTMLHeadingElement.bnd | 0
.../javascript}/duktape/HTMLIFrameElement.bnd | 0
.../javascript}/duktape/HTMLImageElement.bnd | 0
.../javascript}/duktape/HTMLInputElement.bnd | 0
.../handlers/javascript}/duktape/HTMLLIElement.bnd | 0
.../javascript}/duktape/HTMLLabelElement.bnd | 0
.../javascript}/duktape/HTMLLegendElement.bnd | 0
.../javascript}/duktape/HTMLLinkElement.bnd | 0
.../javascript}/duktape/HTMLMapElement.bnd | 0
.../javascript}/duktape/HTMLMarqueeElement.bnd | 0
.../javascript}/duktape/HTMLMenuElement.bnd | 0
.../javascript}/duktape/HTMLMetaElement.bnd | 0
.../javascript}/duktape/HTMLOListElement.bnd | 0
.../javascript}/duktape/HTMLObjectElement.bnd | 0
.../javascript}/duktape/HTMLOptionElement.bnd | 0
.../javascript}/duktape/HTMLParagraphElement.bnd | 0
.../javascript}/duktape/HTMLParamElement.bnd | 0
.../javascript}/duktape/HTMLPreElement.bnd | 0
.../javascript}/duktape/HTMLQuoteElement.bnd | 0
.../javascript}/duktape/HTMLScriptElement.bnd | 0
.../javascript}/duktape/HTMLSelectElement.bnd | 0
.../javascript}/duktape/HTMLStyleElement.bnd | 0
.../duktape/HTMLTableCaptionElement.bnd | 0
.../javascript}/duktape/HTMLTableCellElement.bnd | 0
.../javascript}/duktape/HTMLTableColElement.bnd | 0
.../javascript}/duktape/HTMLTableElement.bnd | 0
.../javascript}/duktape/HTMLTableRowElement.bnd | 0
.../duktape/HTMLTableSectionElement.bnd | 0
.../javascript}/duktape/HTMLTextAreaElement.bnd | 0
.../javascript}/duktape/HTMLTitleElement.bnd | 0
.../handlers/javascript}/duktape/Location.bnd | 2 +-
.../handlers/javascript}/duktape/Makefile | 13 +-
.../handlers/javascript}/duktape/Navigator.bnd | 0
.../handlers/javascript}/duktape/Node.bnd | 0
.../handlers/javascript}/duktape/NodeList.bnd | 0
.../handlers/javascript}/duktape/Window.bnd | 3 +-
.../handlers/javascript}/duktape/duk_config.h | 59 +-
.../handlers/javascript}/duktape/duk_custom.h | 0
.../handlers/javascript}/duktape/dukky.c | 0
.../handlers/javascript}/duktape/dukky.h | 0
.../handlers/javascript}/duktape/duktape.c | 557 ++--
.../handlers/javascript}/duktape/duktape.h | 43 +-
.../handlers/javascript}/duktape/netsurf.bnd | 0
.../handlers/javascript}/fetcher.c | 0
.../handlers/javascript}/fetcher.h | 0
{javascript => content/handlers/javascript}/js.h | 0
.../handlers/javascript}/none/Makefile | 0
.../handlers/javascript}/none/none.c | 0
content/hlcache.c | 15 +-
content/hlcache.h | 9 +-
content/llcache.c | 105 +-
content/llcache.h | 2 +-
content/urldb.c | 124 +-
content/urldb.h | 214 +-
desktop/Makefile | 4 +-
desktop/browser.c | 64 +-
desktop/browser_history.c | 10 +-
desktop/browser_private.h | 5 +-
desktop/cookie_manager.c | 163 +-
desktop/cookie_manager.h | 9 +-
desktop/download.c | 2 +-
desktop/font_haru.c | 3 -
desktop/frame_types.h | 5 +-
desktop/frames.c | 19 +-
desktop/frames.h | 2 +
desktop/global_history.c | 18 +-
desktop/global_history.h | 11 +-
desktop/gui_factory.c | 26 +-
desktop/hotlist.c | 58 +-
desktop/hotlist.h | 47 +-
desktop/knockout.c | 4 +-
desktop/knockout.h | 2 +-
desktop/mouse.c | 2 +-
desktop/mouse.h | 117 -
desktop/netsurf.c | 22 +-
desktop/options.h | 5 +-
desktop/plot_style.c | 2 +-
desktop/plot_style.h | 2 +-
desktop/print.c | 172 +-
desktop/print.h | 3 +-
desktop/save_complete.c | 52 +-
desktop/save_pdf.c | 13 +-
desktop/save_text.c | 7 +-
desktop/scrollbar.c | 6 +-
desktop/searchweb.c | 15 +-
desktop/selection.c | 10 +-
desktop/selection.h | 2 +-
desktop/sslcert_viewer.c | 15 +-
desktop/sslcert_viewer.h | 5 +-
desktop/system_colour.c | 4 +-
desktop/textarea.c | 14 +-
desktop/textarea.h | 4 +
desktop/textinput.c | 9 +-
desktop/textinput.h | 56 +-
desktop/treeview.c | 230 +-
desktop/treeview.h | 37 +-
desktop/version.c | 4 +-
frontends/Makefile | 2 +
frontends/amiga/Makefile | 80 +-
frontends/amiga/Makefile.defaults | 12 +-
frontends/amiga/arexx.c | 143 +-
frontends/amiga/arexx.h | 6 +-
frontends/amiga/bitmap.c | 154 +-
frontends/amiga/bitmap.h | 16 +-
frontends/amiga/clipboard.c | 25 +-
frontends/amiga/cookies.c | 6 +-
frontends/amiga/cookies.h | 4 +-
frontends/amiga/ctxmenu.c | 10 +-
desktop/tree.c => frontends/amiga/desktop-tree.c | 46 +-
desktop/tree.h => frontends/amiga/desktop-tree.h | 2 +-
frontends/amiga/dist/Install | 4 +-
frontends/amiga/dist/NetSurf.guide | 11 +-
frontends/amiga/download.c | 46 +-
frontends/amiga/download.h | 2 -
frontends/amiga/drag.c | 44 +-
frontends/amiga/drag.h | 17 +-
frontends/amiga/dt_anim.c | 15 +-
frontends/amiga/dt_picture.c | 7 +-
frontends/amiga/dt_sound.c | 20 +-
frontends/amiga/file.c | 20 +-
frontends/amiga/filetype.c | 22 +-
frontends/amiga/filetype.h | 6 +-
frontends/amiga/font.c | 6 +-
frontends/amiga/font.h | 4 +-
frontends/amiga/font_bullet.c | 51 +-
frontends/amiga/font_cache.c | 4 +-
frontends/amiga/font_cache.h | 6 +-
frontends/amiga/font_diskfont.c | 44 +-
frontends/amiga/font_diskfont.h | 1 +
frontends/amiga/font_scan.c | 14 +-
frontends/amiga/gui.c | 1785 ++++++-------
frontends/amiga/gui.h | 98 +-
frontends/amiga/gui_options.c | 61 +-
frontends/amiga/gui_options.h | 4 -
frontends/amiga/help.c | 4 +-
frontends/amiga/history.c | 6 +-
frontends/amiga/history.h | 4 +-
frontends/amiga/history_local.c | 51 +-
frontends/amiga/history_local.h | 13 +-
frontends/amiga/hotlist.c | 5 +-
frontends/amiga/hotlist.h | 12 +-
frontends/amiga/icon.c | 42 +-
frontends/amiga/iff_dr2d.c | 42 +-
frontends/amiga/launch.c | 32 +-
frontends/amiga/libs.c | 13 +-
frontends/amiga/login.c | 30 +-
frontends/amiga/login.h | 4 +-
frontends/amiga/memory.c | 169 ++
frontends/amiga/memory.h | 68 +
frontends/amiga/menu.c | 81 +-
frontends/amiga/menu.h | 26 +-
frontends/amiga/misc.c | 79 +-
frontends/amiga/misc.h | 9 -
frontends/amiga/nsoption.c | 59 +
frontends/amiga/{font_diskfont.h => nsoption.h} | 11 +-
frontends/amiga/object.c | 42 +-
frontends/amiga/options.h | 5 +-
frontends/amiga/os3support.c | 336 +--
frontends/amiga/os3support.h | 1 -
frontends/amiga/pkg/SearchEngines | 2 +
frontends/amiga/pkg/netsurf.readme | 4 +-
frontends/amiga/pkg/netsurf_os3.readme | 4 +-
frontends/amiga/plotters.c | 89 +-
frontends/amiga/plotters.h | 6 +-
frontends/amiga/plugin_hack.c | 17 +-
frontends/amiga/print.c | 55 +-
frontends/amiga/print.h | 10 +-
frontends/amiga/resources/SearchEngines | 22 -
frontends/amiga/schedule.c | 186 +-
frontends/amiga/schedule.h | 1 +
frontends/amiga/search.c | 44 +-
frontends/amiga/search.h | 25 +-
frontends/amiga/selectmenu.c | 4 +-
frontends/amiga/selectmenu.h | 2 -
frontends/amiga/sslcert.c | 12 +-
frontends/amiga/sslcert.h | 2 +-
frontends/amiga/stringview/urlhistory.c | 7 +-
frontends/amiga/theme.c | 81 +-
frontends/amiga/theme.h | 10 +-
frontends/amiga/tree.c | 49 +-
frontends/amiga/tree.h | 5 +-
frontends/amiga/utf8.c | 55 +-
frontends/amiga/version.c | 12 +-
frontends/atari/Makefile.defaults | 4 -
frontends/atari/about.c | 2 +-
frontends/atari/bitmap.c | 4 +-
frontends/atari/certview.c | 3 -
frontends/atari/cookies.c | 5 +-
frontends/atari/ctxmenu.c | 9 +-
frontends/atari/deskmenu.c | 4 +-
frontends/atari/download.c | 8 +-
frontends/atari/encoding.c | 2 +-
frontends/atari/file.c | 10 +-
frontends/atari/filetype.c | 1 -
frontends/atari/font.c | 10 +-
frontends/atari/gui.c | 33 +-
frontends/atari/gui.h | 2 +-
frontends/atari/history.c | 3 +-
frontends/atari/hotlist.c | 13 +-
frontends/atari/hotlist.h | 1 -
frontends/atari/login.c | 4 -
frontends/atari/misc.c | 13 +-
frontends/atari/plot/font_freetype.c | 2 +-
frontends/atari/plot/font_internal.c | 2 +-
frontends/atari/plot/fontplot.c | 2 +-
frontends/atari/plot/plot.c | 2701 ++++++++++----------
frontends/atari/plot/plot.h | 6 +-
frontends/atari/rootwin.c | 21 +-
frontends/atari/search.c | 4 +-
frontends/atari/statusbar.c | 4 +-
frontends/atari/toolbar.c | 14 +-
frontends/atari/treeview.c | 6 +-
frontends/atari/treeview.h | 3 +-
frontends/atari/verify_ssl.c | 3 +-
frontends/beos/Makefile | 2 +-
frontends/beos/about.cpp | 2 +-
frontends/beos/bitmap.cpp | 10 +-
frontends/beos/cookies.cpp | 9 +-
frontends/beos/download.cpp | 2 +-
frontends/beos/fetch_rsrc.cpp | 23 +-
frontends/beos/filetype.cpp | 3 +-
frontends/beos/font.cpp | 2 +-
frontends/beos/gui.cpp | 67 +-
frontends/beos/gui.h | 17 +-
frontends/beos/login.cpp | 42 +-
frontends/beos/plotters.cpp | 2 +-
frontends/beos/scaffolding.cpp | 108 +-
frontends/beos/scaffolding.h | 2 +-
frontends/beos/schedule.cpp | 4 +-
frontends/beos/window.cpp | 46 +-
frontends/cocoa/BookmarksController.m | 7 +-
frontends/cocoa/BrowserView.m | 11 +-
frontends/cocoa/BrowserViewController.m | 7 +-
frontends/cocoa/BrowserWindowController.m | 2 +-
frontends/cocoa/DownloadWindowController.m | 2 +-
frontends/cocoa/FormSelectMenu.m | 5 +-
frontends/cocoa/HistoryView.m | 2 +-
frontends/cocoa/Makefile | 1 +
frontends/cocoa/NetSurfAppDelegate.m | 2 +-
frontends/cocoa/NetsurfApp.m | 15 +-
frontends/cocoa/PreferencesWindowController.m | 5 +-
frontends/cocoa/SearchWindowController.m | 4 +-
frontends/cocoa/Tree.h | 2 +-
frontends/cocoa/Tree.m | 4 +-
frontends/cocoa/TreeView.m | 4 +-
frontends/cocoa/URLFieldCell.m | 3 +-
frontends/cocoa/apple_image.m | 8 +-
frontends/cocoa/bitmap.m | 9 +-
frontends/cocoa/coordinates.h | 3 -
desktop/tree.h => frontends/cocoa/desktop-tree.h | 2 +-
desktop/tree.c => frontends/cocoa/desktop-tree.m | 34 +-
frontends/cocoa/fetch.m | 2 +-
frontends/cocoa/font.m | 10 +-
frontends/cocoa/gui.m | 22 +-
frontends/cocoa/plotter.h | 1 -
frontends/cocoa/plotter.m | 5 +-
frontends/cocoa/selection.m | 2 +-
frontends/framebuffer/Makefile | 6 +-
frontends/framebuffer/bitmap.c | 6 +-
frontends/framebuffer/clipboard.c | 4 +-
frontends/framebuffer/convert_image.c | 331 ++-
frontends/framebuffer/fbtk.h | 2 +
frontends/framebuffer/fbtk/bitmap.c | 2 +-
frontends/framebuffer/fbtk/event.c | 4 +-
frontends/framebuffer/fbtk/fbtk.c | 4 +-
frontends/framebuffer/fbtk/fill.c | 2 +-
frontends/framebuffer/fbtk/osk.c | 2 +-
frontends/framebuffer/fbtk/scroll.c | 2 +-
frontends/framebuffer/fbtk/text.c | 4 +-
frontends/framebuffer/fbtk/window.c | 2 +-
frontends/framebuffer/fetch.c | 4 +-
frontends/framebuffer/font_freetype.c | 6 +-
frontends/framebuffer/font_internal.c | 4 +-
frontends/framebuffer/framebuffer.c | 6 +-
frontends/framebuffer/gui.c | 16 +-
frontends/framebuffer/localhistory.c | 2 +-
frontends/gtk/Makefile | 35 +-
frontends/gtk/Makefile.defaults | 2 +-
frontends/gtk/about.c | 6 +-
frontends/gtk/bitmap.c | 8 +-
frontends/gtk/completion.c | 5 +-
frontends/gtk/cookies.c | 285 ++-
frontends/gtk/cookies.h | 12 +-
frontends/gtk/corewindow.c | 731 ++++++
frontends/gtk/corewindow.h | 104 +
frontends/gtk/download.c | 2 +-
frontends/gtk/fetch.c | 48 +-
frontends/gtk/global_history.c | 397 +++
frontends/gtk/{history.h => global_history.h} | 22 +-
frontends/gtk/gui.c | 119 +-
frontends/gtk/history.c | 273 --
frontends/gtk/hotlist.c | 329 ++-
frontends/gtk/hotlist.h | 21 +-
frontends/gtk/layout_pango.c | 2 +-
frontends/gtk/login.c | 2 +-
frontends/gtk/plotters.c | 2 +-
frontends/gtk/preferences.c | 2 +-
frontends/gtk/print.c | 6 +-
frontends/gtk/res/netsurf-gtk.desktop | 2 +-
frontends/gtk/scaffolding.c | 38 +-
frontends/gtk/search.c | 7 +-
frontends/gtk/selection.c | 4 +-
frontends/gtk/ssl_cert.c | 266 +-
frontends/gtk/ssl_cert.h | 3 +-
frontends/gtk/tabs.c | 3 +-
frontends/gtk/toolbar.c | 85 +-
frontends/gtk/treeview.c | 586 -----
frontends/gtk/treeview.h | 38 -
frontends/gtk/viewdata.c | 6 +-
frontends/gtk/viewsource.c | 5 +-
frontends/gtk/window.c | 22 +-
frontends/monkey/bitmap.c | 2 +-
frontends/monkey/browser.c | 13 +-
frontends/monkey/browser.h | 4 +-
frontends/monkey/cert.c | 7 +-
frontends/monkey/cert.h | 2 +-
frontends/monkey/download.c | 3 +-
frontends/monkey/fetch.c | 2 +-
frontends/monkey/filetype.c | 59 +-
frontends/monkey/layout.c | 2 +-
frontends/monkey/main.c | 15 +-
frontends/monkey/plot.c | 2 +-
frontends/riscos/401login.c | 6 +-
frontends/riscos/Makefile | 15 +-
frontends/riscos/bitmap.c | 6 +-
frontends/riscos/content-handlers/artworks.c | 4 +-
frontends/riscos/content-handlers/draw.c | 4 +-
frontends/riscos/content-handlers/sprite.c | 4 +-
frontends/riscos/cookies.c | 520 ++--
frontends/riscos/cookies.h | 49 +-
frontends/riscos/corewindow.c | 935 +++++++
frontends/riscos/corewindow.h | 139 +
frontends/riscos/dialog.c | 15 +-
frontends/riscos/download.c | 15 +-
frontends/riscos/filetype.c | 8 +-
frontends/riscos/filetype.h | 2 +-
frontends/riscos/font.c | 2 +-
frontends/riscos/global_history.c | 541 ++--
frontends/riscos/global_history.h | 40 +-
frontends/riscos/gui.c | 95 +-
frontends/riscos/gui.h | 5 -
frontends/riscos/gui/button_bar.h | 24 -
frontends/riscos/gui/progress_bar.c | 2 +-
frontends/riscos/gui/status_bar.c | 2 +-
frontends/riscos/gui/url_bar.c | 31 +-
frontends/riscos/gui/url_bar.h | 1 +
frontends/riscos/help.c | 12 +-
frontends/riscos/history.c | 2 +-
frontends/riscos/hotlist.c | 875 ++++---
frontends/riscos/hotlist.h | 59 +-
frontends/riscos/iconbar.c | 18 +-
frontends/riscos/menus.c | 7 +-
frontends/riscos/plotters.c | 2 +-
frontends/riscos/print.c | 16 +-
frontends/riscos/save.c | 1621 ++++++------
frontends/riscos/save_draw.c | 7 +-
frontends/riscos/save_pdf.c | 8 +-
frontends/riscos/search.c | 10 +-
frontends/riscos/sslcert.c | 515 ++--
frontends/riscos/sslcert.h | 27 +-
frontends/riscos/textarea.c | 1 -
frontends/riscos/textselection.c | 15 +-
frontends/riscos/theme.c | 3 +-
frontends/riscos/theme_install.c | 11 +-
frontends/riscos/toolbar.c | 3 -
frontends/riscos/treeview.c | 1279 ---------
frontends/riscos/treeview.h | 55 -
frontends/riscos/ucstables.c | 2 +-
frontends/riscos/uri.c | 7 +-
frontends/riscos/url_complete.c | 10 +-
frontends/riscos/url_protocol.c | 7 +-
frontends/riscos/url_suggest.c | 8 +-
frontends/riscos/wimp.c | 12 -
frontends/riscos/window.c | 62 +-
frontends/windows/Makefile | 10 +-
frontends/windows/bitmap.c | 6 +-
frontends/windows/cookies.c | 190 ++
frontends/{gtk/download.h => windows/cookies.h} | 34 +-
frontends/windows/corewindow.c | 479 ++++
frontends/windows/corewindow.h | 110 +
frontends/windows/download.c | 282 +-
frontends/windows/drawable.c | 7 +-
frontends/windows/file.c | 7 +-
frontends/windows/filetype.c | 2 +-
frontends/windows/findfile.c | 3 -
frontends/windows/font.c | 4 +-
frontends/windows/font.h | 4 +-
frontends/windows/global_history.c | 190 ++
.../{gtk/download.h => windows/global_history.h} | 27 +-
frontends/windows/gui.c | 14 +-
frontends/windows/gui.h | 7 +-
frontends/windows/hotlist.c | 194 ++
frontends/{gtk/download.h => windows/hotlist.h} | 28 +-
frontends/windows/localhistory.c | 45 +-
frontends/windows/main.c | 195 +-
frontends/{beos => windows}/options.h | 15 +-
frontends/windows/plot.c | 6 +-
frontends/windows/pointers.c | 4 +-
frontends/windows/prefs.c | 21 +-
frontends/windows/prefs.h | 8 +
frontends/windows/res/resource.rc | 12 +-
frontends/windows/resourceid.h | 84 +-
frontends/windows/ssl_cert.c | 439 ++++
frontends/{gtk => windows}/ssl_cert.h | 23 +-
frontends/windows/window.c | 874 ++++---
frontends/windows/window.h | 23 +-
{image => include/netsurf}/bitmap.h | 4 +-
.../browser.h => include/netsurf/browser_window.h | 13 +-
.../gui_clipboard.h => include/netsurf/clipboard.h | 4 +-
include/netsurf/content.h | 190 ++
{content => include/netsurf}/content_type.h | 33 +-
include/netsurf/cookie_db.h | 98 +
{desktop => include/netsurf}/core_window.h | 41 +-
css/utils.h => include/netsurf/css.h | 17 +-
.../gui_download.h => include/netsurf/download.h | 4 +-
desktop/gui_fetch.h => include/netsurf/fetch.h | 4 +-
{render => include/netsurf}/form.h | 11 +-
desktop/textinput.h => include/netsurf/keypress.h | 40 +-
desktop/gui_layout.h => include/netsurf/layout.h | 4 +-
desktop/gui_misc.h => include/netsurf/misc.h | 7 +-
include/netsurf/mouse.h | 135 +
{desktop => include/netsurf}/netsurf.h | 4 +-
{desktop => include/netsurf}/plotters.h | 9 +-
desktop/gui_search.h => include/netsurf/search.h | 4 +-
include/netsurf/url_db.h | 130 +
desktop/gui_utf8.h => include/netsurf/utf8.h | 4 +-
desktop/gui_window.h => include/netsurf/window.h | 49 +-
javascript/Makefile | 34 -
javascript/jsapi/Makefile | 53 -
javascript/jsapi/comment.bnd | 47 -
javascript/jsapi/console.bnd | 47 -
javascript/jsapi/dom.bnd | 172 --
javascript/jsapi/event.bnd | 37 -
javascript/jsapi/htmlcollection.bnd | 93 -
javascript/jsapi/htmldocument.bnd | 596 -----
javascript/jsapi/htmlelement.bnd | 721 ------
javascript/jsapi/jsapi.c | 613 -----
javascript/jsapi/jsapi.h | 396 ---
javascript/jsapi/location.bnd | 224 --
javascript/jsapi/navigator.bnd | 121 -
javascript/jsapi/node.bnd | 35 -
javascript/jsapi/nodelist.bnd | 99 -
javascript/jsapi/text.bnd | 47 -
javascript/jsapi/window.bnd | 402 ---
render/box.c | 7 +-
render/box.h | 18 +-
render/box_construct.c | 184 +-
render/box_normalise.c | 6 +-
render/box_textarea.c | 6 +-
render/font.c | 3 +-
render/form.c | 40 +-
render/form_internal.h | 4 +-
render/html.c | 30 +-
render/html.h | 8 +-
render/html_css.c | 44 +-
render/html_forms.c | 3 +-
render/html_interaction.c | 14 +-
render/html_internal.h | 6 +-
render/html_object.c | 3 +-
render/html_redraw.c | 16 +-
render/html_script.c | 2 +
render/imagemap.c | 3 +-
render/layout.c | 10 +-
render/layout.h | 2 +-
render/search.c | 4 +-
render/table.c | 7 +-
render/textplain.c | 10 +-
render/textplain.h | 2 +-
resources/FatMessages | 15 +
test/Makefile | 38 +-
test/bloom.c | 111 +-
test/data/Choices | 16 +
test/data/{Choices => Choices-all} | 66 +-
test/data/Choices-full | 20 +
test/data/Choices-short | 17 +
test/data/Messages | Bin 0 -> 8687 bytes
test/data/cookies | 38 +
test/data/urldb | 101 +
test/hashtable.c | 4 +-
test/llcache.c | 15 +-
test/message_data_inline.h | 727 ++++++
test/messages.c | 141 +
test/nsoption.c | 695 ++++-
test/nsurl.c | 2 +-
test/time.c | 435 ++++
test/urldbtest.c | 729 +++++-
test/urlescape.c | 318 +++
test/utils.c | 209 ++
utils/Makefile | 24 +-
utils/ascii.h | 358 +++
utils/base64.c | 442 ----
utils/base64.h | 45 -
utils/corestrings.c | 7 +-
utils/corestrings.h | 1 +
utils/file.c | 7 +-
utils/genpubsuffix.pl | 378 ---
utils/idna.c | 4 +-
utils/jenkins-build.sh | 68 +-
utils/locale.c | 53 -
utils/locale.h | 42 -
utils/messages.c | 25 +
utils/messages.h | 6 +
utils/nsoption.c | 69 +-
utils/nsoption.h | 4 +
utils/nsurl.c | 127 +-
test-netsurf => utils/test-netsurf | 0
utils/time.c | 1007 ++++++++
utils/url.c | 167 +-
utils/url.h | 27 +-
utils/utf8.c | 2 +-
utils/utils.c | 114 +-
612 files changed, 22523 insertions(+), 16902 deletions(-)
create mode 100644 Docs/core-window-interface
create mode 100644 Docs/unit-testing
create mode 100644 content/handlers/Makefile
rename {css => content/handlers/css}/Makefile (67%)
rename {css => content/handlers/css}/css.c (94%)
copy {css => content/handlers/css}/css.h (73%)
rename {css => content/handlers/css}/dump.c (98%)
rename {css => content/handlers/css}/dump.h (84%)
rename {css => content/handlers/css}/hints.c (98%)
rename {css => content/handlers/css}/hints.h (79%)
rename {css => content/handlers/css}/internal.c (80%)
rename {css => content/handlers/css}/internal.h (65%)
rename {css => content/handlers/css}/select.c (96%)
rename {css => content/handlers/css}/select.h (98%)
rename {css => content/handlers/css}/utils.c (82%)
rename css/css.h => content/handlers/css/utils.h (51%)
rename {image => content/handlers/image}/Makefile (90%)
rename {image => content/handlers/image}/bmp.c (94%)
rename {image => content/handlers/image}/bmp.h (100%)
rename {image => content/handlers/image}/gif.c (99%)
rename {image => content/handlers/image}/gif.h (100%)
rename {image => content/handlers/image}/ico.c (98%)
rename {image => content/handlers/image}/ico.h (100%)
rename {image => content/handlers/image}/image.c (97%)
rename {image => content/handlers/image}/image.h (97%)
rename {image => content/handlers/image}/image_cache.c (90%)
rename {image => content/handlers/image}/image_cache.h (99%)
rename {image => content/handlers/image}/jpeg.c (99%)
rename {image => content/handlers/image}/jpeg.h (100%)
rename {image => content/handlers/image}/nssprite.c (97%)
rename {image => content/handlers/image}/nssprite.h (100%)
rename {image => content/handlers/image}/png.c (98%)
rename {image => content/handlers/image}/png.h (100%)
rename {image => content/handlers/image}/rsvg.c (98%)
rename {image => content/handlers/image}/rsvg.h (100%)
rename {image => content/handlers/image}/svg.c (98%)
rename {image => content/handlers/image}/svg.h (100%)
rename {image => content/handlers/image}/video.c (99%)
rename {image => content/handlers/image}/video.h (100%)
create mode 100644 content/handlers/javascript/Makefile
rename {javascript => content/handlers/javascript}/WebIDL/Makefile (100%)
rename {javascript => content/handlers/javascript}/WebIDL/console.idl (100%)
rename {javascript => content/handlers/javascript}/WebIDL/cssom.idl (100%)
rename {javascript => content/handlers/javascript}/WebIDL/dom-parsing.idl (100%)
rename {javascript => content/handlers/javascript}/WebIDL/dom.idl (100%)
rename {javascript => content/handlers/javascript}/WebIDL/html.idl (100%)
rename {javascript => content/handlers/javascript}/WebIDL/uievents.idl (100%)
rename {javascript => content/handlers/javascript}/WebIDL/urlutils.idl (100%)
rename {javascript => content/handlers/javascript}/content.c (100%)
rename {javascript => content/handlers/javascript}/content.h (100%)
rename {javascript => content/handlers/javascript}/duktape/Console.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/Document.bnd (99%)
rename {javascript => content/handlers/javascript}/duktape/Element.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/Event.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLAnchorElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLAppletElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLAreaElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLBRElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLBaseElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLBodyElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLButtonElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLCollection.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLDivElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLFontElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLFormElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLFrameElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLFrameSetElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLHRElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLHTMLElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLHeadingElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLIFrameElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLImageElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLInputElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLLIElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLLabelElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLLegendElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLLinkElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLMapElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLMarqueeElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLMenuElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLMetaElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLOListElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLObjectElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLOptionElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLParagraphElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLParamElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLPreElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLQuoteElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLScriptElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLSelectElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLStyleElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLTableCaptionElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLTableCellElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLTableColElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLTableElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLTableRowElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLTableSectionElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLTextAreaElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/HTMLTitleElement.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/Location.bnd (99%)
rename {javascript => content/handlers/javascript}/duktape/Makefile (57%)
rename {javascript => content/handlers/javascript}/duktape/Navigator.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/Node.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/NodeList.bnd (100%)
rename {javascript => content/handlers/javascript}/duktape/Window.bnd (97%)
rename {javascript => content/handlers/javascript}/duktape/duk_config.h (97%)
rename {javascript => content/handlers/javascript}/duktape/duk_custom.h (100%)
rename {javascript => content/handlers/javascript}/duktape/dukky.c (100%)
rename {javascript => content/handlers/javascript}/duktape/dukky.h (100%)
rename {javascript => content/handlers/javascript}/duktape/duktape.c (99%)
rename {javascript => content/handlers/javascript}/duktape/duktape.h (98%)
rename {javascript => content/handlers/javascript}/duktape/netsurf.bnd (100%)
rename {javascript => content/handlers/javascript}/fetcher.c (100%)
rename {javascript => content/handlers/javascript}/fetcher.h (100%)
rename {javascript => content/handlers/javascript}/js.h (100%)
rename {javascript => content/handlers/javascript}/none/Makefile (100%)
rename {javascript => content/handlers/javascript}/none/none.c (100%)
delete mode 100644 desktop/mouse.h
copy desktop/tree.c => frontends/amiga/desktop-tree.c (96%)
copy desktop/tree.h => frontends/amiga/desktop-tree.h (99%)
create mode 100755 frontends/amiga/memory.c
create mode 100644 frontends/amiga/memory.h
create mode 100644 frontends/amiga/nsoption.c
copy frontends/amiga/{font_diskfont.h => nsoption.h} (75%)
create mode 100644 frontends/amiga/pkg/SearchEngines
delete mode 100644 frontends/amiga/resources/SearchEngines
mode change 100755 => 100644 frontends/amiga/schedule.c
rename desktop/tree.h => frontends/cocoa/desktop-tree.h (99%)
rename desktop/tree.c => frontends/cocoa/desktop-tree.m (96%)
create mode 100644 frontends/gtk/corewindow.c
create mode 100644 frontends/gtk/corewindow.h
create mode 100644 frontends/gtk/global_history.c
rename frontends/gtk/{history.h => global_history.h} (70%)
delete mode 100644 frontends/gtk/history.c
delete mode 100644 frontends/gtk/treeview.c
delete mode 100644 frontends/gtk/treeview.h
create mode 100644 frontends/riscos/corewindow.c
create mode 100644 frontends/riscos/corewindow.h
delete mode 100644 frontends/riscos/treeview.c
delete mode 100644 frontends/riscos/treeview.h
create mode 100644 frontends/windows/cookies.c
copy frontends/{gtk/download.h => windows/cookies.h} (51%)
create mode 100644 frontends/windows/corewindow.c
create mode 100644 frontends/windows/corewindow.h
create mode 100644 frontends/windows/global_history.c
copy frontends/{gtk/download.h => windows/global_history.h} (61%)
create mode 100644 frontends/windows/hotlist.c
copy frontends/{gtk/download.h => windows/hotlist.h} (60%)
copy frontends/{beos => windows}/options.h (70%)
create mode 100644 frontends/windows/ssl_cert.c
copy frontends/{gtk => windows}/ssl_cert.h (59%)
rename {image => include/netsurf}/bitmap.h (98%)
rename desktop/browser.h => include/netsurf/browser_window.h (98%)
rename desktop/gui_clipboard.h => include/netsurf/clipboard.h (95%)
create mode 100644 include/netsurf/content.h
rename {content => include/netsurf}/content_type.h (61%)
create mode 100644 include/netsurf/cookie_db.h
rename {desktop => include/netsurf}/core_window.h (61%)
rename css/utils.h => include/netsurf/css.h (82%)
rename desktop/gui_download.h => include/netsurf/download.h (93%)
rename desktop/gui_fetch.h => include/netsurf/fetch.h (97%)
rename {render => include/netsurf}/form.h (91%)
copy desktop/textinput.h => include/netsurf/keypress.h (58%)
rename desktop/gui_layout.h => include/netsurf/layout.h (97%)
rename desktop/gui_misc.h => include/netsurf/misc.h (91%)
create mode 100644 include/netsurf/mouse.h
rename {desktop => include/netsurf}/netsurf.h (95%)
rename {desktop => include/netsurf}/plotters.h (97%)
rename desktop/gui_search.h => include/netsurf/search.h (96%)
create mode 100644 include/netsurf/url_db.h
rename desktop/gui_utf8.h => include/netsurf/utf8.h (95%)
rename desktop/gui_window.h => include/netsurf/window.h (87%)
delete mode 100644 javascript/Makefile
delete mode 100644 javascript/jsapi/Makefile
delete mode 100644 javascript/jsapi/comment.bnd
delete mode 100644 javascript/jsapi/console.bnd
delete mode 100644 javascript/jsapi/dom.bnd
delete mode 100644 javascript/jsapi/event.bnd
delete mode 100644 javascript/jsapi/htmlcollection.bnd
delete mode 100644 javascript/jsapi/htmldocument.bnd
delete mode 100644 javascript/jsapi/htmlelement.bnd
delete mode 100644 javascript/jsapi/jsapi.c
delete mode 100644 javascript/jsapi/jsapi.h
delete mode 100644 javascript/jsapi/location.bnd
delete mode 100644 javascript/jsapi/navigator.bnd
delete mode 100644 javascript/jsapi/node.bnd
delete mode 100644 javascript/jsapi/nodelist.bnd
delete mode 100644 javascript/jsapi/text.bnd
delete mode 100644 javascript/jsapi/window.bnd
copy test/data/{Choices => Choices-all} (59%)
create mode 100644 test/data/Choices-full
create mode 100644 test/data/Choices-short
create mode 100644 test/data/Messages
create mode 100644 test/data/cookies
create mode 100644 test/data/urldb
create mode 100644 test/message_data_inline.h
create mode 100644 test/messages.c
create mode 100644 test/time.c
create mode 100644 test/urlescape.c
create mode 100644 test/utils.c
create mode 100644 utils/ascii.h
delete mode 100644 utils/base64.c
delete mode 100644 utils/base64.h
delete mode 100644 utils/genpubsuffix.pl
delete mode 100644 utils/locale.c
delete mode 100644 utils/locale.h
rename test-netsurf => utils/test-netsurf (100%)
create mode 100644 utils/time.c
diff --git a/!NetSurf/Resources/CSS,f79 b/!NetSurf/Resources/CSS,f79
index 3892aff..44268d6 100644
--- a/!NetSurf/Resources/CSS,f79
+++ b/!NetSurf/Resources/CSS,f79
@@ -87,8 +87,6 @@ tr { display: table-row; vertical-align: inherit; }
td, th { display: table-cell; vertical-align: inherit; padding: 1px; }
th { font-weight: bold; text-align: center; }
-td[nowrap], th[nowrap] { white-space: nowrap; }
-
a:link { color: #00f; text-decoration: underline; }
a:visited { color: #609; }
@@ -104,9 +102,8 @@ small { font-size: .83em; }
strike, s { text-decoration: line-through; }
u { text-decoration: underline; }
-hr { display: block; background-color: #000; height: 1px;
- margin: 4px auto; border: 1px #d9d9d9 inset; }
-hr[noshade] { background-color: #888; height: 2px; border: none; }
+hr { display: block; margin: 0.5em auto; border: 1px inset #888; }
+hr[noshade] { border-style: solid; }
noframes { display: none; }
diff --git a/!NetSurf/Resources/en/credits.html,faf b/!NetSurf/Resources/en/credits.html,faf
index 96327e7..b7098df 100644
--- a/!NetSurf/Resources/en/credits.html,faf
+++ b/!NetSurf/Resources/en/credits.html,faf
@@ -92,7 +92,7 @@ div#DevList ul {
</div>
<div class="footer">
-<p>Copyright 2003–2011 The NetSurf Developers</p>
+<p>Copyright 2003–2016 The NetSurf Developers</p>
</div>
</body>
diff --git a/!NetSurf/Resources/en/licence.html,faf b/!NetSurf/Resources/en/licence.html,faf
index 7b3aef6..da0df45 100644
--- a/!NetSurf/Resources/en/licence.html,faf
+++ b/!NetSurf/Resources/en/licence.html,faf
@@ -60,25 +60,25 @@ version.</p>
<dl class="components">
<dt><a href="http://www.netsurf-browser.org/">NetSurf</a></dt>
<dd>
-<span>© 2002–2011 The NetSurf Developers</span>
+<span>© 2002–2016 The NetSurf Developers</span>
<span><a href="#gplv2">GPLv2</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/libcss/">LibCSS</a></dt>
<dd>
-<span>© 2007–2011 John-Mark Bell</span>
+<span>© 2007–2016 John-Mark Bell</span>
<span><a href="#mit">MIT</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/hubbub/">Hubbub</a></dt>
<dd>
-<span>© 2007–2011 John-Mark Bell<br>© 2008–2009 Andrew Sidwell</span>
+<span>© 2007–2016 John-Mark Bell<br>© 2008–2009 Andrew Sidwell</span>
<span><a href="#mit">MIT</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/libparserutils/">LibParserUtils</a></dt>
<dd>
-<span>© 2007–2011 John-Mark Bell</span>
+<span>© 2007–2016 John-Mark Bell</span>
<span><a href="#mit">MIT</a></span>
</dd>
@@ -102,19 +102,19 @@ version.</p>
<dt><a href="http://www.netsurf-browser.org/projects/libsvgtiny">Libsvgtiny</a></dt>
<dd>
-<span>© 2008–2009 James Bursa</span>
+<span>© 2008–2009 James Bursa<br>© 2016 Michael Drake</span>
<span><a href="#mit">MIT</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/libnsbmp/">Libnsbmp</a></dt>
<dd>
-<span>© 2006 Richard Wilson<br>© 2008 Sean Fox</span>
+<span>© 2006 Richard Wilson<br>© 2008 Sean Fox<br>© 2016 Vincent Sanders</span>
<span><a href="#mit">MIT</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/libnsfb/">Libnsfb</a></dt>
<dd>
-<span>© 2009–2011 Vincent Sanders<br>© 2009–2011 Michael Drake</span>
+<span>© 2009–2016 Vincent Sanders<br>© 2009–2016 Michael Drake</span>
<span><a href="#mit">MIT</a></span>
</dd>
@@ -126,7 +126,7 @@ version.</p>
<dt><a href="http://www.netsurf-browser.org/projects/libwapcaplet">LibWapcaplet</a></dt>
<dd>
-<span>© 2009–2011 NetSurf Browser Project, Daniel Silverstone</span>
+<span>© 2009–2016 NetSurf Browser Project, Daniel Silverstone</span>
<span><a href="#mit">MIT</a></span>
</dd>
</dl>
@@ -1865,7 +1865,7 @@ PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
</div>
<div class="footer">
-<p>Copyright 2003–2011 The NetSurf Developers</p>
+<p>Copyright 2003–2016 The NetSurf Developers</p>
</div>
</body>
diff --git a/!NetSurf/Resources/nl/credits.html,faf b/!NetSurf/Resources/nl/credits.html,faf
index 163751f..3cae27a 100644
--- a/!NetSurf/Resources/nl/credits.html,faf
+++ b/!NetSurf/Resources/nl/credits.html,faf
@@ -96,7 +96,7 @@ div#DevList ul {
</div>
<div class="footer">
-<p>Auteursrecht 2003–2015 De NetSurf-ontwikkelaars</p>
+<p>Auteursrecht 2003–2016 De NetSurf-ontwikkelaars</p>
</div>
</body>
diff --git a/!NetSurf/Resources/nl/licence.html,faf b/!NetSurf/Resources/nl/licence.html,faf
index d0c1650..d3272c7 100644
--- a/!NetSurf/Resources/nl/licence.html,faf
+++ b/!NetSurf/Resources/nl/licence.html,faf
@@ -63,25 +63,25 @@ dan verwijder deze uitzonderingverklaring uit uw eigen versie.</p>
<dl class="components">
<dt><a href="http://www.netsurf-browser.org/">NetSurf</a></dt>
<dd>
-<span>© 2002–2011 De NetSurf-ontwikkerlaars</span>
+<span>© 2002–2016 De NetSurf-ontwikkerlaars</span>
<span><a href="#gplv2">GPLv2</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/libcss/">LibCSS</a></dt>
<dd>
-<span>© 2007–2011 John-Mark Bell</span>
+<span>© 2007–2016 John-Mark Bell</span>
<span><a href="#mit">MIT</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/hubbub/">Hubbub</a></dt>
<dd>
-<span>© 2007–2011 John-Mark Bell<br>© 2008–2009 Andrew Sidwell</span>
+<span>© 2007–2016 John-Mark Bell<br>© 2008–2009 Andrew Sidwell</span>
<span><a href="#mit">MIT</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/libparserutils/">LibParserUtils</a></dt>
<dd>
-<span>© 2007–2011 John-Mark Bell</span>
+<span>© 2007–2016 John-Mark Bell</span>
<span><a href="#mit">MIT</a></span>
</dd>
@@ -105,19 +105,19 @@ dan verwijder deze uitzonderingverklaring uit uw eigen versie.</p>
<dt><a href="http://www.netsurf-browser.org/projects/libsvgtiny">Libsvgtiny</a></dt>
<dd>
-<span>© 2008–2009 James Bursa</span>
+<span>© 2008–2009 James Bursa<br>© 2016 Michael Drake</span>
<span><a href="#mit">MIT</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/libnsbmp/">Libnsbmp</a></dt>
<dd>
-<span>© 2006 Richard Wilson<br>© 2008 Sean Fox</span>
+<span>© 2006 Richard Wilson<br>© 2008 Sean Fox<br>© 2016 Vincent Sanders</span>
<span><a href="#mit">MIT</a></span>
</dd>
<dt><a href="http://www.netsurf-browser.org/projects/libnsfb/">Libnsfb</a></dt>
<dd>
-<span>© 2009–2011 Vincent Sanders<br>© 2009–2011 Michael Drake</span>
+<span>© 2009–2016 Vincent Sanders<br>© 2009–2016 Michael Drake</span>
<span><a href="#mit">MIT</a></span>
</dd>
@@ -129,11 +129,12 @@ dan verwijder deze uitzonderingverklaring uit uw eigen versie.</p>
<dt><a href="http://www.netsurf-browser.org/projects/libwapcaplet">LibWapcaplet</a></dt>
<dd>
-<span>© 2009–2011 NetSurf Browser Project, Daniel Silverstone</span>
+<span>© 2009–2016 NetSurf Browser Project, Daniel Silverstone</span>
<span><a href="#mit">MIT</a></span>
</dd>
</dl>
+
<h3>Onderdelen van derden</h3>
<dl class="components">
@@ -1871,7 +1872,7 @@ PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
</div>
<div class="footer">
-<p>Auteursrecht 2003–2015 De NetSurf-ontwikkelaars</p>
+<p>Auteursrecht 2003–2016 De NetSurf-ontwikkelaars</p>
</div>
</body>
diff --git a/!NetSurf/Resources/nl/welcome.html,faf b/!NetSurf/Resources/nl/welcome.html,faf
index f35260b..aec47e7 100644
--- a/!NetSurf/Resources/nl/welcome.html,faf
+++ b/!NetSurf/Resources/nl/welcome.html,faf
@@ -3,7 +3,6 @@
<head>
<title>Welkom bij NetSurf</title>
<style type="text/css">html,body{margin:0;padding:0;}body{color:#000;background:#fff;font-family:sans-serif;margin:0 auto;}a:link{text-decoration:underline;color:#00f;}a:visited{text-decoration:underline;color:#60a;}a:hover{text-decoration:none;}a:active{text-decoration:underline;color:#f00;}.banner{margin:0;padding:0;background:#94adff;text-align:left;}.banner img{border:none;color:#000;height:86px;width:308px;display:block;}.onlycontent{margin:0 1em;}.nslinks{display:table;width:100%;margin:0;border-spacing:0;padding:0;background:#ccd8ff;font-size:88%;}.nslinks li{display:table-cell;text-align:center;padding:0.2em 0.3em 0.3em;vertical-align:middle;}.nslinks li+li{border-left:2px solid #b1c3ff;}.version{padding:0;margin:1.2em auto 0;width:90%;color:#444;font-size:160%;}.intro{width: 90%;margin:1em auto;color:#666;}.websearch{margin:1.5em auto;padding:1.2em 0.3em;background:#d8e2ff;border:2px solid #c5d3ff;width:80%;text-align:center;}input[type=text]{border:2px solid #b6c7ff;background:#f9faff;color:#000;margin:2px;}input[type=submit]{border:2px outset #cedaff;color:#000;background:#cedaff;margin:2px;}.links{display:table;width:80%;margin:0 auto 3em;font-size:94%;}.links p{display:table-cell;}.links ul{padding-left:0.8em;margin-top:-1em;}.links ul+ul{padding-left:1em;}.footer{font-style:italic;color:#666;text-align:right;}.footer p{margin-top:1.5em;padding-top:0.4em;border-top:2px solid #94adff;}</style>
-<link rel="icon" type="image/png" href="http://www.netsurf-browser.org/webimages/favicon.png">
</head>
<body>
diff --git a/.gitignore b/.gitignore
index 3b674ff..b16d6f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,6 @@
\!NetSurf/Resources/nl/Templates,fec
\!NetSurf/Resources/nl/Messages
\!NetSurf/Resources/it/Messages
-frontends/windows/res/preferences
frontends/gtk/res/en/Messages
frontends/gtk/res/fr/Messages
frontends/gtk/res/de/Messages
diff --git a/Docs/Doxyfile b/Docs/Doxyfile
index 15ca480..e2cb563 100644
--- a/Docs/Doxyfile
+++ b/Docs/Doxyfile
@@ -672,16 +672,17 @@ INPUT = frontends/amiga \
frontends/riscos/templates \
frontends/riscos/scripts \
frontends/windows \
- css \
+ include/netsurf \
render \
desktop \
content \
content/fetchers \
- javascript \
- javascript/jsapi \
+ content/handlers/image \
+ content/handlers/css \
+ content/handlers/javascript \
+ content/handlers/javascript/duktape \
utils \
utils/http \
- image \
Docs/UnimplementedJavascript.txt
# This tag can be used to specify the character encoding of the source files
diff --git a/Docs/PACKAGING-GTK b/Docs/PACKAGING-GTK
index 67e63b2..8f67522 100644
--- a/Docs/PACKAGING-GTK
+++ b/Docs/PACKAGING-GTK
@@ -39,19 +39,30 @@
gtk/res/ (dereferencing the symlinks, obviously) to /usr/share/netsurf (or
wherever your packaging policy suggests).
- You will need to tell NetSurf where to find its resources. NetSurf searches
- three locations by default when trying to load them, in this order:
+ You will need to tell NetSurf where to find its run time loaded
+ resources. NetSurf searches three locations by default when trying
+ to load them, in this order:
1. ~/.netsurf/
+
+ This entry allows the user some flexibility in changing what
+ resources NetSurf uses by placing resources in their home
+ directory.
+
2. $NETSURFRES/
- 3. /usr/share/netsurf/
- The second one is how the netsurf launcher script controls it. The third
- location is controlled by the NETSURF_GTK_RESOURCES option in
- Makefile.config, and this is the recommended way for packagers to change
- the location it searches, as this still allows the user some flexibility in
- changing what NetSurf uses.
+ This entry allows the user or packager to control resource
+ aquisition through the environment. This entry is how the
+ developer launcher script controls resource location.
+
+ 3. NETSURF_GTK_RES_PATH option
+ This location is controlled by the option in Makefile.config
+ (defaulting to ${PREFIX}/share/netsurf/ ). This configuration
+ is the recommended way for packagers to change the location
+ NetSurf finds external resources. The first path element of the
+ NETSURF_GTK_RES_PATH option is used in the install target as
+ the destination for installed resources.
User agent string
===================
diff --git a/Docs/UnimplementedJavascript.txt b/Docs/UnimplementedJavascript.txt
index cb50699..2b3a7d9 100644
--- a/Docs/UnimplementedJavascript.txt
+++ b/Docs/UnimplementedJavascript.txt
@@ -630,7 +630,6 @@ getter HTMLElement::onerror(user);\n
setter HTMLElement::onerror(user);\n
getter HTMLElement::spellcheck(boolean);\n
setter HTMLElement::spellcheck(boolean);\n
-getter HTMLElement::style(user);\n
getter HTMLElement::tabIndex(long);\n
setter HTMLElement::tabIndex(long);\n
getter HTMLElement::translate(boolean);\n
diff --git a/Docs/core-window-interface b/Docs/core-window-interface
new file mode 100644
index 0000000..0267f37
--- /dev/null
+++ b/Docs/core-window-interface
@@ -0,0 +1,677 @@
+Core Window Interface
+=====================
+
+The NetSurf core provides an optional API to frontend implementations
+which allows a number of "standard" window content interfaces to be
+provided.
+
+The currently available user interfaces are:
+
+ - Cookies
+ - Global history
+ - Hotlist
+ - SSL certificate view
+
+Although not currently included in future additional user interfaces
+will be available for:
+
+ - local history
+ - browser render
+
+To be clear these are generic implementations of this functionality
+that any frontend may use. Frontends are free to implement these
+interfaces in any manner as they see fit, the corewindow interface
+simply provides a default.
+
+core window API
+---------------
+
+The API is fairly simple and simply involves passing a callback table
+and context pointer to the interface element being constructed.
+
+The header that defines the callback interface is netsurf/core_window.h
+
+The callback table contains five function pointer interfaces which the
+frontend must implement for the core.
+
+ - redraw_request
+ request a redraw an area of a window
+
+ - update_size
+ Update the limits of the window
+
+ - scroll_visible
+ Scroll the window to make area visible
+
+ - get_window_dimensions
+ Get window viewport dimensions
+
+ - drag_status
+ Inform corewindow owner of drag status
+
+Each callback will be passed the context pointer for the corewindow
+instance and the relevant additional information necessary to perform
+the operation.
+
+Each exported user interface element wraps this generic interface with
+a concrete implementation. For example the SSL certificate viewer is
+initialised with:
+
+nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
+ void *core_window_handle,
+ struct sslcert_session_data *ssl_d);
+
+This call creates a context which will display and navigate the ssl
+session data passed. The frontend must service the callbacks from the
+core to provide the necessary interactions with the frontend windowing
+system.
+
+These actions should ideally use the standard frontend window
+processing. So for the GTK frontend when the core calls the redraw
+operation it simply marks the area passed as damaged (using
+gtk_widget_queue_draw_area()) and lets the standard expose event cause
+the redraw to occour.
+
+If the frontend needs to redraw an area of a window (perhaps an expose
+event occoured) it must call the corewindoe API wrappers
+implementation e.g in the case of ssl certificate viewer
+
+void sslcert_viewer_redraw(struct sslcert_session_data *ssl_d,
+ int x, int y, struct rect *clip,
+ const struct redraw_context *ctx);
+
+which will perform the plot operations required to update an area of
+the window for that SSL data.
+
+Usage
+-----
+
+The usage pattern that is expected is for a frontend to create a core
+window impementation that implements the necessary five API in a
+generic way and allows the frontend to provide the specific
+specialisation for each of the user interface elements it wishes to
+use (cookies, SSL viewer etc).
+
+The GTK frontend for example:
+
+has source corewindow.[ch] which implement the five core callbacks
+using generic GTK operations (redraw_request calls
+gtk_widget_queue_draw_area() etc.) and then provides additional
+operations on a GTK drawing area object to attach expose event
+processing, keypress processing etc.
+
+The GTK corewindow (not to be confused with the core window API
+itself, this is purely the gtk wrapper) is used by ssl_cert.c which
+creates a nsgtk_crtvrfy_window structure containing the
+nsgtk_corewindow structure. It attaches actual GTK window handles to
+this structure and populates elements of nsgtk_corewindow and then
+calls sslcert_viewer_init() directly.
+
+frontend skeleton
+-----------------
+
+An example core window implementation for a frontend ssl certficiate
+viewer is presented here. This implements the suggested usage above
+and provides generic corewindow helpers.
+
+
+frontends/example/corewindow.h
+------------------------------
+
+/*
+ * Copyright 2016 Vincent Sanders <vince(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/>.
+ */
+
+#ifndef EXAMPLE_COREWINDOW_H
+#define EXAMPLE_COREWINDOW_H
+
+#include "netsurf/core_window.h"
+
+/**
+ * example core window state
+ */
+struct example_corewindow {
+
+
+ /*
+ * Any variables common to any frontend window would go here.
+ * e.g. drawing area handles, toolkit pointers or other state
+ */
+ example_toolkit_widget *tk_widget;
+
+
+
+ /** drag status set by core */
+ core_window_drag_status drag_staus;
+
+ /** table of callbacks for core window operations */
+ struct core_window_callback_table *cb_table;
+
+ /**
+ * callback to draw on drawable area of example core window
+ *
+ * \param example_cw The example core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+ nserror (*draw)(struct example_corewindow *example_cw, struct rect *r);
+
+ /**
+ * callback for keypress on example core window
+ *
+ * \param example_cw The example core window structure.
+ * \param nskey The netsurf key code.
+ * \return NSERROR_OK if key processed,
+ * NSERROR_NOT_IMPLEMENTED if key not processed
+ * otherwise apropriate error code
+ */
+ nserror (*key)(struct example_corewindow *example_cw, uint32_t nskey);
+
+ /**
+ * callback for mouse event on example core window
+ *
+ * \param example_cw The example core window structure.
+ * \param mouse_state mouse state
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on sucess otherwise apropriate error code.
+ */
+ nserror (*mouse)(struct example_corewindow *example_cw, browser_mouse_state mouse_state, int x, int y);
+};
+
+/**
+ * initialise elements of example core window.
+ *
+ * As a pre-requisite the draw, key and mouse callbacks must be defined
+ *
+ * \param example_cw A example core window structure to initialise
+ * \return NSERROR_OK on successful initialisation otherwise error code.
+ */
+nserror example_corewindow_init(struct example_corewindow *example_cw);
+
+/**
+ * finalise elements of example core window.
+ *
+ * \param example_cw A example core window structure to initialise
+ * \return NSERROR_OK on successful finalisation otherwise error code.
+ */
+nserror example_corewindow_fini(struct example_corewindow *example_cw);
+
+#endif
+
+frontends/example/corewindow.c
+------------------------------
+
+/*
+ * Copyright 2016 Vincent Sanders <vince(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
+ * EXAMPLE generic core window interface.
+ *
+ * Provides interface for core renderers to the example toolkit drawable area.
+ *
+ * This module is an object that must be encapsulated. Client users
+ * should embed a struct example_corewindow at the beginning of their
+ * context for this display surface, fill in relevant data and then
+ * call example_corewindow_init()
+ *
+ * The example core window structure requires the callback for draw, key and
+ * mouse operations.
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <math.h>
+
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/messages.h"
+#include "utils/utf8.h"
+#include "netsurf/keypress.h"
+#include "netsurf/mouse.h"
+#include "desktop/plot_style.h"
+
+/* extremely likely there will be additional headers required in a real frontend */
+#include "example/corewindow.h"
+
+
+/* toolkit event handlers that do generic things and call internal callbacks */
+
+
+static bool
+example_cw_mouse_press_event(toolkit_widget *widget, toolkit_button bt, int x, int y, void *ctx)
+{
+ struct example_corewindow *example_cw = (struct example_corewindow *)ctx;
+
+ example_cw->mouse(example_cw, state, x, y);
+
+ return true;
+}
+
+static bool
+example_cw_keyrelease_event(toolkit_widget *widget, void *ctx)
+{
+ struct example_corewindow *example_cw = (struct example_corewindow *)ctx;
+
+ example_cw->key(example_cw, keycode);
+
+ return true;
+}
+
+
+
+/* signal handler for toolkit window redraw */
+static bool
+example_cw_draw_event(toolkit_widget *widget,
+ toolkit_area *tk_area,
+ void *ctx)
+{
+ struct example_corewindow *example_cw = (struct example_corewindow *)ctx;
+ struct rect clip;
+
+ clip.x0 = tk_area.x;
+ clip.y0 = tk_area.y;
+ clip.x1 = tk_area.width;
+ clip.y1 = tk_area.height;
+
+ example_cw->draw(example_cw, &clip);
+
+ return true;
+}
+
+
+/**
+ * callback from core to request a redraw
+ */
+static void
+example_cw_redraw_request(struct core_window *cw, const struct rect *r)
+{
+ struct example_corewindow *example_cw = (struct example_corewindow *)cw;
+
+ toolkit_widget_queue_draw_area(example_cw->widget,
+ r->x0, r->y0,
+ r->x1 - r->x0, r->y1 - r->y0);
+}
+
+
+static void
+example_cw_update_size(struct core_window *cw, int width, int height)
+{
+ struct example_corewindow *example_cw = (struct example_corewindow *)cw;
+
+ toolkit_widget_set_size_request(EXAMPLE_WIDGET(example_cw->drawing_area),
+ width, height);
+}
+
+
+static void
+example_cw_scroll_visible(struct core_window *cw, const struct rect *r)
+{
+ struct example_corewindow *example_cw = (struct example_corewindow *)cw;
+
+ toolkit_scroll_widget(example_cw->widget, r);
+}
+
+
+static void
+example_cw_get_window_dimensions(struct core_window *cw, int *width, int *height)
+{
+ struct example_corewindow *example_cw = (struct example_corewindow *)cw;
+
+ *width = toolkit_get_widget_width(example_cw->widget);
+ *height = toolkit_get_widget_height(example_cw->widget);
+}
+
+
+static void
+example_cw_drag_status(struct core_window *cw, core_window_drag_status ds)
+{
+ struct example_corewindow *example_cw = (struct example_corewindow *)cw;
+ example_cw->drag_staus = ds;
+}
+
+
+struct core_window_callback_table example_cw_cb_table = {
+ .redraw_request = example_cw_redraw_request,
+ .update_size = example_cw_update_size,
+ .scroll_visible = example_cw_scroll_visible,
+ .get_window_dimensions = example_cw_get_window_dimensions,
+ .drag_status = example_cw_drag_status
+};
+
+/* exported function documented example/corewindow.h */
+nserror example_corewindow_init(struct example_corewindow *example_cw)
+{
+ /* setup the core window callback table */
+ example_cw->cb_table = &example_cw_cb_table;
+
+ /* frontend toolkit specific method of causing example_cw_draw_event to be called when a drawing operation is required */
+ toolkit_connect_draw_event(example_cw->tk_widget,
+ example_cw_draw_event,
+ example_cw);
+
+ /* frontend toolkit specific method of causing example_cw_button_press_event to be called when a button press occours */
+ toolkit_connect_button_press_event(example_cw->tk_widget,
+ example_cw_button_press_event,
+ example_cw);
+
+ /* frontend toolkit specific method of causing example_cw_button_release_event to be called when a button release occours */
+ toolkit_connect_button_release_event(example_cw->tk_widget,
+ example_cw_button_release_event,
+ example_cw);
+
+ /* frontend toolkit specific method of causing example_cw_motion_notify_event to be called when there is motion over the widget */
+ toolkit_connect_motion_event(example_cw->tk_widget,
+ example_cw_motion_notify_event,
+ example_cw);
+
+ /* frontend toolkit specific method of causing example_cw_key_press_event to be called when a key press occours */
+ toolkit_connect_button_press_event(example_cw->tk_widget,
+ example_cw_key_press_event,
+ example_cw);
+
+ /* frontend toolkit specific method of causing example_cw_key_release_event to be called when a key release occours */
+ toolkit_connect_button_release_event(example_cw->tk_widget,
+ example_cw_key_release_event,
+ example_cw);
+
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in example/corewindow.h */
+nserror example_corewindow_fini(struct example_corewindow *example_cw)
+{
+ return NSERROR_OK;
+}
+
+
+frontends/example/ssl_cert.h
+----------------------------
+
+/*
+ * Copyright 2016 Vincent Sanders <vince(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/>.
+ */
+
+#ifndef NETSURF_EXAMPLE_SSL_CERT_H
+#define NETSURF_EXAMPLE_SSL_CERT_H 1
+
+struct nsurl;
+struct ssl_cert_info;
+
+/**
+ * Prompt the user to verify a certificate with issuse.
+ *
+ * \param url The URL being verified.
+ * \param certs The certificate to be verified
+ * \param num The number of certificates to be verified.
+ * \param cb Callback upon user decision.
+ * \param cbpw Context pointer passed to cb
+ * \return NSERROR_OK or error code if prompt creation failed.
+ */
+nserror example_cert_verify(struct nsurl *url, const struct ssl_cert_info *certs, unsigned long num, nserror (*cb)(bool proceed, void *pw), void *cbpw);
+
+#endif
+
+frontends/example/ssl_cert.c
+----------------------------
+
+/*
+ * Copyright 2015 Vincent Sanders <vince(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
+ * Implementation of example certificate viewing using example core windows.
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "utils/log.h"
+#include "netsurf/keypress.h"
+#include "netsurf/plotters.h"
+#include "desktop/sslcert_viewer.h"
+
+#include "example/corewindow.h"
+
+
+/**
+ * EXAMPLE certificate viewing window context
+ */
+struct example_crtvrfy_window {
+ /** example core window context */
+ struct example_corewindow core;
+
+ /** SSL certificate viewer context data */
+ struct sslcert_session_data *ssl_data;
+};
+
+/**
+ * destroy a previously created certificate view
+ */
+static nserror example_crtvrfy_destroy(struct example_crtvrfy_window *crtvrfy_win)
+{
+ nserror res;
+
+ res = sslcert_viewer_fini(crtvrfy_win->ssl_data);
+ if (res == NSERROR_OK) {
+ res = example_corewindow_fini(&crtvrfy_win->core);
+ toolkit_windown_destroy(crtvrfy_win->window);
+ free(crtvrfy_win);
+ }
+ return res;
+}
+
+static void
+example_crtvrfy_accept(ExampleButton *w, gpointer data)
+{
+ struct example_crtvrfy_window *crtvrfy_win;
+ crtvrfy_win = (struct example_crtvrfy_window *)data;
+
+ sslcert_viewer_accept(crtvrfy_win->ssl_data);
+
+ example_crtvrfy_destroy(crtvrfy_win);
+}
+
+static void
+example_crtvrfy_reject(ExampleWidget *w, gpointer data)
+{
+ struct example_crtvrfy_window *crtvrfy_win;
+ crtvrfy_win = (struct example_crtvrfy_window *)data;
+
+ sslcert_viewer_reject(crtvrfy_win->ssl_data);
+
+ example_crtvrfy_destroy(crtvrfy_win);
+}
+
+
+/**
+ * callback for mouse action for certificate verify on core window
+ *
+ * \param example_cw The example core window structure.
+ * \param mouse_state netsurf mouse state on event
+ * \param x location of event
+ * \param y location of event
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+example_crtvrfy_mouse(struct example_corewindow *example_cw,
+ browser_mouse_state mouse_state,
+ int x, int y)
+{
+ struct example_crtvrfy_window *crtvrfy_win;
+ /* technically degenerate container of */
+ crtvrfy_win = (struct example_crtvrfy_window *)example_cw;
+
+ sslcert_viewer_mouse_action(crtvrfy_win->ssl_data, mouse_state, x, y);
+
+ return NSERROR_OK;
+}
+
+/**
+ * callback for keypress for certificate verify on core window
+ *
+ * \param example_cw The example core window structure.
+ * \param nskey The netsurf key code
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+example_crtvrfy_key(struct example_corewindow *example_cw, uint32_t nskey)
+{
+ struct example_crtvrfy_window *crtvrfy_win;
+
+ /* technically degenerate container of */
+ crtvrfy_win = (struct example_crtvrfy_window *)example_cw;
+
+ if (sslcert_viewer_keypress(crtvrfy_win->ssl_data, nskey)) {
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_IMPLEMENTED;
+}
+
+/**
+ * callback on draw event for certificate verify on core window
+ *
+ * \param example_cw The example core window structure.
+ * \param r The rectangle of the window that needs updating.
+ * \return NSERROR_OK on success otherwise apropriate error code
+ */
+static nserror
+example_crtvrfy_draw(struct example_corewindow *example_cw, struct rect *r)
+{
+ struct redraw_context ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &example_plotters
+ };
+ struct example_crtvrfy_window *crtvrfy_win;
+
+ /* technically degenerate container of */
+ crtvrfy_win = (struct example_crtvrfy_window *)example_cw;
+
+ sslcert_viewer_redraw(crtvrfy_win->ssl_data, 0, 0, r, &ctx);
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in example/ssl_cert.h */
+nserror example_cert_verify(struct nsurl *url,
+ const struct ssl_cert_info *certs,
+ unsigned long num,
+ nserror (*cb)(bool proceed, void *pw),
+ void *cbpw)
+{
+ struct example_crtvrfy_window *ncwin;
+ nserror res;
+
+ ncwin = malloc(sizeof(struct example_crtvrfy_window));
+ if (ncwin == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ res = toolkit_create_window(&ncwin->window);
+ if (res != NSERROR_OK) {
+ LOG("SSL UI builder init failed");
+ free(ncwin);
+ return res;
+ }
+
+ /* store the widget that the toolkit is drawing into */
+ ncwin->core.widget = toolkit_get_widget(ncwin->window, "SSLDrawingArea"));
+
+ /* would typicaly setup toolkit accept/reject buttons etc. here */
+ toolkit_connect_button_press(ncwin->tk_accept_button,
+ example_crtvrfy_accept,
+ ncwin);
+
+
+ /* initialise example core window */
+ ncwin->core.draw = example_crtvrfy_draw;
+ ncwin->core.key = example_crtvrfy_key;
+ ncwin->core.mouse = example_crtvrfy_mouse;
+
+ res = example_corewindow_init(&ncwin->core);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ /* initialise certificate viewing interface */
+ res = sslcert_viewer_create_session_data(num, url, cb, cbpw, certs,
+ &ncwin->ssl_data);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ res = sslcert_viewer_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin,
+ ncwin->ssl_data);
+ if (res != NSERROR_OK) {
+ free(ncwin);
+ return res;
+ }
+
+ toolkit_widget_show(ncwin->window);
+
+ return NSERROR_OK;
+}
diff --git a/Docs/env.sh b/Docs/env.sh
index b067da1..9cfc956 100644
--- a/Docs/env.sh
+++ b/Docs/env.sh
@@ -26,6 +26,26 @@ if [ "x${HOST}" = "x" ]; then
else
HOST=${TARGET_ABI}
fi
+else
+ HOST_CC_LIST="${HOST}-cc ${HOST}-gcc /opt/netsurf/${HOST}/cross/bin/${HOST}-cc /opt/netsurf/${HOST}/cross/bin/${HOST}-gcc"
+ for HOST_CC_V in $(echo ${HOST_CC_LIST});do
+ HOST_CC=$(/bin/which ${HOST_CC_V})
+ if [ "x${HOST_CC}" != "x" ];then
+ break
+ fi
+ done
+ if [ "x${HOST_CC}" = "x" ];then
+ echo "Unable to execute host compiler for HOST=${HOST}. is it set correctly?"
+ return 1
+ fi
+
+ HOST_CC_MACHINE=$(${HOST_CC} -dumpmachine 2>/dev/null)
+
+ if [ "${HOST_CC_MACHINE}" != "${HOST}" ];then
+ echo "Compiler dumpmachine differes from HOST setting"
+ return 2
+ fi
+ unset HOST_CC_LIST HOST_CC_V HOST_CC HOST_CC_MACHINE
fi
if [ "x${TARGET_WORKSPACE}" = "x" ]; then
@@ -70,7 +90,7 @@ NS_GIT="git://git.netsurf-browser.org"
NS_BUILDSYSTEM="buildsystem"
# internal libraries all frontends require (order is important)
-NS_INTERNAL_LIBS="libwapcaplet libparserutils libhubbub libdom libcss libnsgif libnsbmp libutf8proc libnsutils"
+NS_INTERNAL_LIBS="libwapcaplet libparserutils libhubbub libdom libcss libnsgif libnsbmp libutf8proc libnsutils libnspsl"
# The browser itself
NS_BROWSER="netsurf"
@@ -108,6 +128,12 @@ case "${HOST}" in
# default additional internal libraries
NS_FRONTEND_LIBS="libsvgtiny"
;;
+ m68k-unknown-amigaos)
+ # default tools required to build the browser
+ NS_TOOLS="nsgenbind"
+ # default additional internal libraries
+ NS_FRONTEND_LIBS="libsvgtiny"
+ ;;
*-unknown-freebsd*)
# tools required to build the browser for freebsd
NS_TOOLS=""
diff --git a/Docs/source-object-backing-store b/Docs/source-object-backing-store
index 5d4d304..0fb3614 100644
--- a/Docs/source-object-backing-store
+++ b/Docs/source-object-backing-store
@@ -5,30 +5,30 @@ Introduction
------------
The source object cache provides a system to extend the life of source
-objects (html files, images etc.) after they are no longer immediately
+objects (HTML files, images etc.) after they are no longer immediately
being used.
Only fetch types where we have well defined rules on caching are
considered, in practice this limits us to HTTP(S). The section in
RFC2616 [1] on caching specifies these rules.
-To futher extend the objects lifetime they can be pushed into a
+To further extend the objects lifetime they can be pushed into a
backing store where the objects are available for reuse less quickly
-than from RAM but faster than retriving from the network again.
+than from RAM but faster than retrieving from the network again.
The backing store implementation provides a key:value infrastructure
-with a simple store, retrive and invalidate interface.
+with a simple store, retrieve and invalidate interface.
Generic filesystem backing store
--------------------------------
Although the backing store interface is fully pluggable a generic
implementation based on storing objects on the filesystem in a
-heirachy of directories.
+hierarchy of directories.
-The option to alter the backing store format exists and is controled
+The option to alter the backing store format exists and is controlled
by a version field. It is implementation defined what happens if a
-version mis-match occours.
+version mis-match occurs.
As the backing store only holds cache data one should not expect a
great deal of effort to be expended converting formats (i.e. the cache
@@ -37,23 +37,23 @@ may simply be discarded).
Layout version 1.1
------------------
-An object has an identifier value generated from the url (NetSurf
-backing stores uses the url as the unique key). The value used is
+An object has an identifier value generated from the URL (NetSurf
+backing stores uses the URL as the unique key). The value used is
obtained using nsurl_hash() which is currently a 32 bit FNV so is
directly usable.
This identifier is adequate to ensure the collision rate for the
-hashed url values (a collision for every 2^16 urls added) is
+hashed URL values (a collision for every 2^16 URLs added) is
sufficiently low the overhead of returning the wrong object (which
-backing stores are permitted to do) is not significat.
+backing stores are permitted to do) is not significant.
An entry list is maintained which contains all the metadata about a
given identifier. This list is limited in length to constrain the
-resources necessary to maintain it. It is made persistant to avoid the
+resources necessary to maintain it. It is made persistent to avoid the
overhead of reconstructing it at initialisation and to keep the data
used to improve the eviction decisions.
-Each object is stored and retrived directly into the filesystem using
+Each object is stored and retrieved directly into the filesystem using
a filename generated from a RFC4648 base32 encoding of an address
value. The objects address is derived from the identifier by cropping
it to a shorter length.
@@ -63,7 +63,7 @@ uses storage directly proportional to the size of the address length.
The cropping length is stored in the control file with the default
values set at compile time. This allows existing backing stores to
-continue operating with existing data independantly of new default
+continue operating with existing data independently of new default
setting. This setting gives some ability to tune the default cache
index size to values suitable for a specific host operating system.
@@ -88,7 +88,7 @@ Version 1.0
The version 1 layout was identical to the 1.1 except base64url
encoding was used, this proved problematic as some systems filesystems
-were case insensitive so upper and lower case letetrs collided.
+were case insensitive so upper and lower case letters collided.
There is no upgrade provision from the previous version simply delete
the cache directory.
@@ -112,7 +112,7 @@ Each control file table entry is 28 bytes and consists of
- signed 64 bit value for last use time
- 32bit full url hash allowing for index reconstruction and
- addiitonal collision detection. Also the possibility of increasing
+ additional collision detection. Also the possibility of increasing
the ADDRESS_LENGTH although this would require renaming all the
existing files in the cache and is not currently implemented.
@@ -134,8 +134,8 @@ Address to entry index
An entry index is held in RAM that allows looking up the address to
map to an entry in the control file.
-The index is the only data structure whose size is directly depndant
-on the length of the hash specificaly:
+The index is the only data structure whose size is directly dependant
+on the length of the hash specifically:
(2 ^ (ADDRESS_BITS - 3)) * ENTRY_BITS) in bytes
@@ -152,9 +152,9 @@ list is limited to 448kilobytes.
The typical values for RISC OS would set ADDRESS_BITS to 18. This
spreads the entries over 262144 hash values which uses 512 kilobytes
for the index. Limiting the hash space like this reduces the
-efectiveness of the cache.
+effectiveness of the cache.
-A small ADDRESS_LENGTH causes a collision (two urls with the same
+A small ADDRESS_LENGTH causes a collision (two URLs with the same
address) to happen roughly for every 2 ^ (ADDRESS_BITS / 2) = 2 ^ 9 =
512 objects stored. This roughly translates to a cache miss due to
collision every ten pages navigated to.
@@ -164,7 +164,7 @@ Larger systems
In general ENTRY_BITS set to 16 as this limits the store to 65536
objects which given the average size of an object at 8 kilobytes
-yeilds half a gigabyte of disc used which is judged to be sufficient.
+yields half a gigabyte of disc used which is judged to be sufficient.
For larger systems e.g. those using GTK frontend we would most likely
select ADDRESS_BITS as 22 resulting in a collision every 2048 objects
@@ -176,11 +176,11 @@ Typical values
Example 1
~~~~~~~~~
-For a store with 1034 objects genrated from a random navigation of
+For a store with 1034 objects generated from a random navigation of
pages linked from the about:welcome page.
Metadata total size is 593608 bytes an average of 574 bytes. The
-majority of the storage is used to hold the urls and headers.
+majority of the storage is used to hold the URLs and headers.
Data total size is 9180475 bytes a mean of 8879 bytes 1648726 in the
largest 10 entries which if excluded gives 7355 bytes average size
diff --git a/Docs/unit-testing b/Docs/unit-testing
new file mode 100644
index 0000000..49d82ed
--- /dev/null
+++ b/Docs/unit-testing
@@ -0,0 +1,166 @@
+NetSurf Unit Testing
+====================
+
+Overview
+--------
+
+NetSurf has unit tests integrated in the test directory. These tests
+use the check unit test framework for C [1].
+
+The tests are in a logical hierachy of "suite", "case" and individual
+"test". Historicaly we have split suites of tests into separate test
+programs although the framework does not madate this and some test
+programs contain more than one suite.
+
+
+Execution
+---------
+
+The test programs are executed by using the standard "test" target
+from the top level make invocation. The "coverage" target additionally
+generates code coverage reports allowing visibility on how much of a
+code module is being exercised.
+
+The check library must be installed to run the tests and the CI system
+automatically executes all enabled tests and generates coverage
+reports for each commit.
+
+Adding tests
+------------
+
+The test/Makefile defines each indiviadual test program that should be
+built and executed in the TESTS variable.
+
+The test program source files are defined in a xxx_SRCS variable and
+the make rules will then ensure the target program is built and
+executed.
+
+Each individual test program requires a main function which creates
+one (or more) suites. The suites are added to a test runner and then
+executed and the results reported.
+
+int main(int argc, char **argv)
+{
+ int number_failed;
+ SRunner *sr;
+
+ sr = srunner_create(foo_suite_create());
+ //srunner_add_suite(sr, bar_suite_create());
+
+ srunner_run_all(sr, CK_ENV);
+
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+Suite creation is done with a sub function to logically split suite
+code into sub modules. Each suite has test cases added to it.
+
+Suite *foo_suite_create(void)
+{
+ Suite *s;
+ s = suite_create("foo");
+
+ suite_add_tcase(s, baz_case_create());
+ suite_add_tcase(s, qux_case_create());
+
+ return s;
+}
+
+Test cases include the actual tests to be performed within each case.
+
+TCase *baz_case_create(void)
+{
+ TCase *tc;
+ tc = tcase_create("Baz");
+
+ tcase_add_test(tc, xxyz_test);
+ tcase_add_test(tc, zzyx_test);
+
+ return tc;
+}
+
+A test case may optionally have a fixture which is code that is
+executed before and after each test case. Unchecked fixtures are
+executed once before the test process forks for each test whereas
+checked fixtures are executed for each and every test.
+
+static void fixture_setup(void)
+{
+}
+
+static void fixture_teardown(void)
+{
+}
+
+TCase *qux_case_create(void)
+{
+ TCase *tc;
+
+ /* Matching entry tests */
+ tc = tcase_create("Match");
+
+ tcase_add_checked_fixture(tc,
+ fixture_setup,
+ fixture_teardown);
+
+ tcase_add_test(tc, zzz_test);
+
+ return tc;
+}
+
+Additionally test cases can contain tests executed in a loop. The test
+recives a single integer as a parameter named _i which iterates
+between values specified in the case setup.
+
+TCase *baz_case_create(void)
+{
+ TCase *tc;
+ tc = tcase_create("Baz");
+
+ tcase_add_loop_test(tc, looping_test, 0, 5);
+
+ return tc;
+}
+
+It is also possible to create tests which will generate a signal. The
+most commonly used of these is to check asserts in API calls.
+
+TCase *baz_case_create(void)
+{
+ TCase *tc;
+ tc = tcase_create("Baz");
+
+ tcase_add_test_raise_signal(tc, assert_test, 6);
+
+ return tc;
+}
+
+
+Actual test code is self contained in a function which uses the
+ck_assert macros to test results. The check framework requires each
+test to use the START_TEST and END_TEST macros when definig them.
+
+/**
+ * url access leaf test
+ */
+START_TEST(nsurl_access_leaf_test)
+{
+ nserror err;
+ nsurl *res_url;
+ const struct test_triplets *tst = &access_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(nsurl_access_leaf(res_url), tst->res);
+
+ nsurl_unref(res_url);
+}
+END_TEST
+
+
+[1] https://libcheck.github.io/check/
diff --git a/Makefile b/Makefile
index 4af0a03..2596e7a 100644
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,6 @@ HOST := $(shell uname -s)
# TODO: Ideally, we want the equivalent of s/[^A-Za-z0-9]/_/g here
HOST := $(subst .,_,$(subst -,_,$(subst /,_,$(HOST))))
-
ifeq ($(HOST),)
HOST := riscos
$(warning Build platform determination failed but that's a known problem for RISC OS so we're assuming a native RISC OS build.)
@@ -74,7 +73,7 @@ ifeq ($(HOST),beos)
TARGET := beos
endif
ifeq ($(TARGET),haiku)
- TARGET := beos
+ override TARGET := beos
endif
endif
@@ -117,7 +116,7 @@ ifeq ($(TARGET),)
endif
# valid values for the TARGET
-VLDTARGET := riscos gtk beos amiga amigaos3 framebuffer windows atari cocoa monkey
+VLDTARGET := riscos gtk gtk3 beos amiga amigaos3 framebuffer windows atari cocoa monkey
# Check for valid TARGET
ifeq ($(filter $(VLDTARGET),$(TARGET)),)
@@ -287,7 +286,7 @@ else
CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
endif
else
- ifeq ($(findstring framebuffer,$(TARGET)),framebuffer)
+ ifeq ($(TARGET),framebuffer)
ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
PKG_CONFIG := pkg-config
else
@@ -298,9 +297,29 @@ else
CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
endif
+
else
- # All native targets (GTK)
- PKG_CONFIG := pkg-config
+ # All native targets
+
+ # use native package config
+ PKG_CONFIG := pkg-config
+
+ # gtk target processing
+ ifeq ($(TARGET),gtk3)
+ override TARGET := gtk
+ override NETSURF_GTK_MAJOR := 3
+ SUBTARGET = $(NETSURF_GTK_MAJOR)
+ else
+ ifeq ($(TARGET),gtk)
+ ifeq ($(origin NETSURF_GTK_MAJOR),undefined)
+ override NETSURF_GTK_MAJOR := 2
+ else
+ ifneq ($(NETSURF_GTK_MAJOR),2)
+ SUBTARGET = $(NETSURF_GTK_MAJOR)
+ endif
+ endif
+ endif
+ endif
endif
endif
endif
@@ -511,14 +530,6 @@ $(eval $(call pkg_config_find_and_add,libcss,CSS))
$(eval $(call pkg_config_find_and_add,libdom,DOM))
$(eval $(call pkg_config_find_and_add,libnsutils,nsutils))
$(eval $(call pkg_config_find_and_add,libutf8proc,utf8proc))
-$(eval $(call pkg_config_find_and_add,openssl,OpenSSL))
-# freemint does not support pkg-config for libcurl
-ifeq ($(HOST),mint)
- CFLAGS += $(shell curl-config --cflags)
- LDFLAGS += $(shell curl-config --libs)
-else
- $(eval $(call pkg_config_find_and_add,libcurl,Curl))
-endif
# Common libraries without pkg-config support
LDFLAGS += -lz
@@ -529,18 +540,34 @@ LDFLAGS += -lz
NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+NETSURF_FEATURE_CURL_CFLAGS := -DWITH_CURL
NETSURF_FEATURE_NSSVG_CFLAGS := -DWITH_NS_SVG
+NETSURF_FEATURE_OPENSSL_CFLAGS := -DWITH_OPENSSL
NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
+NETSURF_FEATURE_NSPSL_CFLAGS := -DWITH_NSPSL
+
+# libcurl and openssl ordering matters as if libcurl requires ssl it
+# needs to come first in link order to ensure its symbols can be
+# resolved by the subsequent openssl
+
+# freemint does not support pkg-config for libcurl
+ifeq ($(HOST),mint)
+ CFLAGS += $(shell curl-config --cflags)
+ LDFLAGS += $(shell curl-config --libs)
+else
+ $(eval $(call pkg_config_find_and_add_enabled,CURL,libcurl,Curl))
+endif
+$(eval $(call pkg_config_find_and_add_enabled,OPENSSL,openssl,OpenSSL))
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
$(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,NSSVG,libsvgtiny,SVG))
$(eval $(call pkg_config_find_and_add_enabled,ROSPRITE,librosprite,Sprite))
+$(eval $(call pkg_config_find_and_add_enabled,NSPSL,libnspsl,PSL))
-# add top level and build directory to include search path
-CFLAGS += -I. -Ifrontends -I$(OBJROOT)
-CXXFLAGS += -I. -Ifrontends -I$(OBJROOT)
+# List of directories in which headers are searched for
+INCLUDE_DIRS :=. include $(OBJROOT)
# export the user agent format
CFLAGS += -DNETSURF_UA_FORMAT_STRING=\"$(NETSURF_UA_FORMAT_STRING)\"
@@ -585,12 +612,6 @@ include frontends/Makefile
# Content sources
include content/Makefile
-# Content fetchers sources
-include content/fetchers/Makefile
-
-# CSS sources
-include css/Makefile
-
# render sources
include render/Makefile
@@ -603,15 +624,9 @@ include utils/http/Makefile
# Desktop sources
include desktop/Makefile
-# Javascript source
-include javascript/Makefile
-
-# Image content handler sources
-include image/Makefile
-
# S_COMMON are sources common to all builds
-S_COMMON := $(S_CONTENT) $(S_FETCHERS) $(S_CSS) $(S_RENDER) $(S_UTILS) \
- $(S_HTTP) $(S_DESKTOP) $(S_JAVASCRIPT)
+S_COMMON := $(S_CONTENT) $(S_FETCHERS) $(S_RENDER) $(S_UTILS) $(S_HTTP) \
+ $(S_DESKTOP) $(S_JAVASCRIPT_BINDING)
# ----------------------------------------------------------------------------
@@ -637,7 +652,7 @@ MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
endef
-# geenrate the message file rules
+# generate the message file rules
$(eval $(foreach LANG,$(MESSAGES_LANGUAGES), \
$(call split_messages,$(LANG))))
@@ -660,6 +675,9 @@ endif
OBJECTS := $(sort $(addprefix $(OBJROOT)/,$(subst /,_,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(patsubst %.m,%.o,$(patsubst %.s,%.o,$(SOURCES))))))))
+# Include directory flags
+IFLAGS = $(addprefix -I,$(INCLUDE_DIRS))
+
$(EXETARGET): $(OBJECTS) $(RESOURCES) $(MESSAGES)
$(VQ)echo " LINK: $(EXETARGET)"
ifneq ($(TARGET)$(SUBTARGET),riscos-elf)
@@ -669,9 +687,6 @@ else
$(Q)$(ELF2AIF) $(EXETARGET:,ff8=,e1f) $(EXETARGET)
$(Q)$(RM) $(EXETARGET:,ff8=,e1f)
endif
-ifeq ($(TARGET),windows)
- $(Q)$(TOUCH) frontends/windows/res/preferences
-endif
ifeq ($(NETSURF_STRIP_BINARY),YES)
$(VQ)echo " STRIP: $(EXETARGET)"
$(Q)$(STRIP) $(EXETARGET)
@@ -744,12 +759,12 @@ define compile_target_c
$$(DEPROOT)/$(3) $$(OBJROOT)/$(2): $$(OBJROOT)/created
$$(VQ)echo " DEP: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(CC) $$(CFLAGS) -MM \
+ $$(Q)$$(CC) $$(IFLAGS) $$(CFLAGS) -MM \
$(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
> $$(DEPROOT)/$(3)
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
+ $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
endef
else
@@ -758,7 +773,7 @@ $$(DEPROOT)/$(3) $$(OBJROOT)/$(2): $$(OBJROOT)/created
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
+ $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
-MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
-MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
@@ -769,12 +784,12 @@ define compile_target_cpp
$$(DEPROOT)/$(3) $$(OBJROOT)/$(2): $$(OBJROOT)/created
$$(VQ)echo " DEP: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(CC) $$(CFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
+ $$(Q)$$(CC) $$(IFLAGS) $$(CXXFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
$(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
> $$(DEPROOT)/$(3)
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
+ $$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(IFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
endef
diff --git a/Makefile.config.example b/Makefile.config.example
index 686ffea..aeddc10 100644
--- a/Makefile.config.example
+++ b/Makefile.config.example
@@ -28,11 +28,8 @@
### following line
# override NETSURF_FB_FONTLIB := freetype
-### To enable/disable JavaScript support, uncomment the appropriate line below.
-# override NETSURF_USE_JS := NO
-# override NETSURF_USE_JS := YES
-# override NETSURF_USE_MOZJS := NO
-# override NETSURF_USE_MOZJS := YES
+### To disable JavaScript support, uncomment the appropriate line below.
+# override NETSURF_USE_DUKTAPE := NO
### To change flags to javascript binding generator
# GBFLAGS:=-g
diff --git a/Makefile.defaults b/Makefile.defaults
index 196e192..619b8db 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -31,6 +31,14 @@
# Options relating to all versions of NetSurf
# ----------------------------------------------------------------------------
+# Enable NetSurf's use of libcurl for fetching over http(s)
+# Valid options: YES, NO (highly recommended)
+NETSURF_USE_CURL := YES
+
+# Enable NetSurf's use of openssl for fetching over https
+# Valid options: YES, NO
+NETSURF_USE_OPENSSL := YES
+
# Enable NetSurf's use of libnsbmp for displaying BMPs and ICOs
# Valid options: YES, NO
NETSURF_USE_BMP := YES
@@ -51,12 +59,8 @@ NETSURF_USE_PNG := YES
# Valid options: YES, NO
NETSURF_USE_VIDEO := NO
-# Enable NetSurf's use of spidermonkey for javascript
-# Valid options: YES, NO, AUTO
-NETSURF_USE_JS := NO
-# Javascript support in older debian/ubuntu versions
-NETSURF_USE_MOZJS := NO
-# Or use duktape
+# Enable NetSurf's use of duktape for javascript
+# Valid options: YES, NO
NETSURF_USE_DUKTAPE := YES
# Enable NetSurf's use of libharu for PDF export and GTK printing support.
@@ -65,6 +69,9 @@ NETSURF_USE_DUKTAPE := YES
# Valid options: YES, NO
NETSURF_USE_HARU_PDF := NO
+# Enable the use of the Public suffix library to detect supercookies
+NETSURF_USE_NSPSL := AUTO
+
# Enable stripping the NetSurf binary
# Valid options: YES, NO
NETSURF_STRIP_BINARY := NO
diff --git a/content/Makefile b/content/Makefile
index ab257ea..b4353ba 100644
--- a/content/Makefile
+++ b/content/Makefile
@@ -8,4 +8,11 @@ ifeq ($(NETSURF_FS_BACKING_STORE),YES)
S_CONTENT += fs_backing_store.c
endif
+
+# Content fetchers sources
+include content/fetchers/Makefile
+
+# Content handlers
+include content/handlers/Makefile
+
S_CONTENT := $(addprefix content/,$(S_CONTENT))
diff --git a/content/backing_store.h b/content/backing_store.h
index 4e29511..3a1ae8f 100644
--- a/content/backing_store.h
+++ b/content/backing_store.h
@@ -38,7 +38,7 @@ enum backing_store_flags {
* low level cache backing store operation table
*
* The low level cache (source objects) has the capability to make
- * objects and their metadata (headers etc) persistant by writing to a
+ * objects and their metadata (headers etc) persistent by writing to a
* backing store using these operations.
*/
struct gui_llcache_table {
@@ -46,14 +46,14 @@ struct gui_llcache_table {
* Initialise the backing store.
*
* @param parameters to configure backing store.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
nserror (*initialise)(const struct llcache_store_parameters *parameters);
/**
* Finalise the backing store.
*
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
nserror (*finalise)(void);
@@ -72,16 +72,16 @@ struct gui_llcache_table {
* been completely written on return.
*
* @param[in] url The url is used as the unique primary key for the data.
- * @param[in] flags The flags to control how the obejct is stored.
+ * @param[in] flags The flags to control how the object is stored.
* @param[in] data The objects data.
* @param[in] datalen The length of the \a data.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
nserror (*store)(struct nsurl *url, enum backing_store_flags flags,
uint8_t *data, const size_t datalen);
/**
- * Retrive an object from the backing store.
+ * Retrieve an object from the backing store.
*
* The backing store will manage its own memory and the
* allocations returned in \a data *must* not be altered.
@@ -91,10 +91,10 @@ struct gui_llcache_table {
* calling the release method.
*
* @param[in] url The url is used as the unique primary key for the data.
- * @param[in] flags The flags to control how the object is retrived.
- * @param[out] data The retrived objects data.
+ * @param[in] flags The flags to control how the object is retrieved.
+ * @param[out] data The retrieved objects data.
* @param[out] datalen The length of the \a data retrieved.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
nserror (*fetch)(struct nsurl *url, enum backing_store_flags flags,
uint8_t **data, size_t *datalen);
@@ -104,7 +104,7 @@ struct gui_llcache_table {
*
* @param url The url is used as the unique primary key to invalidate.
* @param[in] flags The flags to control how the object data is released.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
nserror (*release)(struct nsurl *url, enum backing_store_flags flags);
@@ -117,7 +117,7 @@ struct gui_llcache_table {
* If the entry had data allocated it will be released.
*
* @param url The url is used as the unique primary key to invalidate.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
nserror (*invalidate)(struct nsurl *url);
diff --git a/content/content.c b/content/content.c
index e112f38..f650af2 100644
--- a/content/content.c
+++ b/content/content.c
@@ -28,11 +28,11 @@
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "desktop/plotters.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
#include "desktop/knockout.h"
#include "desktop/gui_internal.h"
-#include "desktop/browser.h"
-#include "image/bitmap.h"
#include "content/content_protected.h"
#include "content/content_debug.h"
@@ -543,12 +543,8 @@ void content__request_redraw(struct content *c,
content_broadcast(c, CONTENT_MSG_REDRAW, data);
}
-/**
- * Display content on screen with optional tiling.
- *
- * Calls the redraw function for the content.
- */
+/* exported interface, documented in content/content.h */
bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
const struct rect *clip, const struct redraw_context *ctx)
{
@@ -1051,12 +1047,7 @@ bool content__add_rfc5988_link(struct content *c,
-/**
- * Retrieve URL associated with content
- *
- * \param c Content to retrieve URL from
- * \return Pointer to URL, or NULL if not found.
- */
+/* exported interface documented in content/content.h */
nsurl *content_get_url(struct content *c)
{
if (c == NULL)
diff --git a/content/content.h b/content/content.h
index cdd7283..308b211 100644
--- a/content/content.h
+++ b/content/content.h
@@ -17,8 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Content handling (interface).
+/**
+ * \file
+ * Content handling interface.
*
* The content functions manipulate struct contents, which correspond to URLs.
*/
@@ -30,10 +31,8 @@
#include "utils/errors.h"
#include "content/content_factory.h"
-#include "content/content_type.h"
#include "desktop/search.h" /* search flags enum */
-#include "desktop/mouse.h" /* mouse state enums */
-#include "desktop/plot_style.h" /* color typedef */
+#include "netsurf/mouse.h" /* mouse state enums */
struct browser_window;
struct browser_window_features;
@@ -81,18 +80,6 @@ typedef enum {
CONTENT_MSG_GADGETCLICK/**< A gadget has been clicked on (mainly for file) */
} content_msg;
-/** Debugging dump operations */
-enum content_debug {
- CONTENT_DEBUG_RENDER, /** Debug the contents rendering. */
- CONTENT_DEBUG_DOM, /** Debug the contents Document Object. */
- CONTENT_DEBUG_REDRAW /** Debug redraw operations. */
-};
-
-/** Content encoding informstion types */
-enum content_encoding_type {
- CONTENT_ENCODING_NORMAL, /** The content encoding */
- CONTENT_ENCODING_SOURCE /** The content encoding source */
-};
/** RFC5988 metadata link */
struct content_rfc5988_link {
@@ -208,44 +195,35 @@ union content_msg_data {
} gadget_click;
};
-/** parameters to content redraw */
-struct content_redraw_data {
- int x; /**< coordinate for top-left of redraw */
- int y; /**< coordinate for top-left of redraw */
- /** dimensions to render content at
- * (for scaling contents with intrinsic dimensions) */
- int width; /**< horizontal dimension */
- int height; /**< vertical dimension */
+/* The following are for hlcache */
+void content_destroy(struct content *c);
- /** The background colour */
- colour background_colour;
- /** Scale for redraw
- * (for scaling contents without intrinsic dimensions) */
- float scale; /**< Scale factor for redraw */
+bool content_add_user(struct content *h, void (*callback)(struct content *c, content_msg msg, union content_msg_data data, void *pw), void *pw);
- bool repeat_x; /**< whether content is tiled in x direction */
- bool repeat_y; /**< whether content is tiled in y direction */
-};
-/* The following are for hlcache */
-void content_destroy(struct content *c);
+void content_remove_user(struct content *c, void (*callback)(struct content *c, content_msg msg, union content_msg_data data, void *pw), void *pw);
-bool content_add_user(struct content *h,
- void (*callback)(struct content *c, content_msg msg,
- union content_msg_data data, void *pw),
- void *pw);
-void content_remove_user(struct content *c,
- void (*callback)(struct content *c, content_msg msg,
- union content_msg_data data, void *pw),
- void *pw);
uint32_t content_count_users(struct content *c);
+
+
bool content_matches_quirks(struct content *c, bool quirks);
+
+
bool content_is_shareable(struct content *c);
+/* only used by cocoa apple image handling and for getting nsurl of content */
const struct llcache_handle *content_get_llcache_handle(struct content *c);
+
+
+/**
+ * Retrieve URL associated with content
+ *
+ * \param c Content to retrieve URL from
+ * \return Pointer to URL, or NULL if not found.
+ */
struct nsurl *content_get_url(struct content *c);
struct content *content_clone(struct content *c);
@@ -254,42 +232,29 @@ nserror content_abort(struct content *c);
/* Client functions */
bool content_can_reformat(struct hlcache_handle *h);
+
void content_reformat(struct hlcache_handle *h, bool background,
int width, int height);
+
void content_request_redraw(struct hlcache_handle *h,
int x, int y, int width, int height);
+
void content_mouse_track(struct hlcache_handle *h, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
+
void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw,
browser_mouse_state mouse, int x, int y);
-bool content_keypress(struct hlcache_handle *h, uint32_t key);
-bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data,
- const struct rect *clip, const struct redraw_context *ctx);
+bool content_keypress(struct hlcache_handle *h, uint32_t key);
-/**
- * Redraw a content with scale set for horizontal fit.
- *
- * Redraws the content at a specified width and height with the
- * content drawing scaled to fit within the area.
- *
- * \param content The content to redraw
- * \param width The target width
- * \param height The target height
- * \param ctx current redraw context
- * \return true if successful, false otherwise
- *
- * The thumbnail is guaranteed to be filled to its width/height extents, so
- * there is no need to render a solid background first.
- *
- * Units for width and height are pixels.
- */
-bool content_scaled_redraw(struct hlcache_handle *content, int width, int height, const struct redraw_context *ctx);
void content_open(struct hlcache_handle *h, struct browser_window *bw,
struct content *page, struct object_params *params);
+
void content_close(struct hlcache_handle *h);
+
void content_clear_selection(struct hlcache_handle *h);
+
char * content_get_selection(struct hlcache_handle *h);
/**
@@ -305,13 +270,16 @@ nserror content_get_contextual_content(struct hlcache_handle *h,
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, void *context,
search_flags_t flags, const char *string);
+
void content_search_clear(struct hlcache_handle *h);
+
/**
* Control debug con a content.
*
@@ -320,6 +288,7 @@ void content_search_clear(struct hlcache_handle *h);
*/
nserror content_debug(struct hlcache_handle *h, enum content_debug op);
+
/**
* find link in content that matches the rel string.
*
@@ -328,34 +297,8 @@ nserror content_debug(struct hlcache_handle *h, enum content_debug op);
* \return A matching rfc5988 link or NULL if none is found.
*
*/
-struct content_rfc5988_link *content_find_rfc5988_link(struct hlcache_handle *h,
- lwc_string *rel);
+struct content_rfc5988_link *content_find_rfc5988_link(struct hlcache_handle *h, lwc_string *rel);
-/* Member accessors */
-
-/**
- * Retrieve computed type of content
- *
- * \param h handle to the content to retrieve tyoe of.
- * \return Computed content type
- */
-content_type content_get_type(struct hlcache_handle *h);
-
-/**
- * Retrieve mime-type of content
- *
- * \param h handle to the content to retrieve mime type from
- * \return Pointer to referenced mime type, or NULL if not found.
- */
-lwc_string *content_get_mime_type(struct hlcache_handle *h);
-
-/**
- * Retrieve title associated with content
- *
- * \param h handle to the content to retrieve title from
- * \return Pointer to title, or NULL if not found.
- */
-const char *content_get_title(struct hlcache_handle *h);
/**
* Retrieve status of content
@@ -365,6 +308,7 @@ const char *content_get_title(struct hlcache_handle *h);
*/
content_status content_get_status(struct hlcache_handle *h);
+
/**
* Retrieve status of content
*
@@ -373,6 +317,7 @@ content_status content_get_status(struct hlcache_handle *h);
*/
content_status content__get_status(struct content *c);
+
/**
* Retrieve status message associated with content
*
@@ -381,21 +326,6 @@ content_status content__get_status(struct content *c);
*/
const char *content_get_status_message(struct hlcache_handle *h);
-/**
- * Retrieve width of content
- *
- * \param h handle to the content to get width of.
- * \return Content width
- */
-int content_get_width(struct hlcache_handle *h);
-
-/**
- * Retrieve height of content
- *
- * \param h handle to the content to get height of.
- * \return Content height
- */
-int content_get_height(struct hlcache_handle *h);
/**
* Retrieve available width of content
@@ -405,26 +335,6 @@ int content_get_height(struct hlcache_handle *h);
*/
int content_get_available_width(struct hlcache_handle *h);
-/**
- * Retrieve source of content
- *
- * \param h Content handle to retrieve source of
- * \param size Pointer to location to receive byte size of source
- * \return Pointer to source data
- */
-const char *content_get_source_data(struct hlcache_handle *h,
- unsigned long *size);
-
-/**
- * Invalidate content reuse data.
- *
- * causes subsequent requests for content URL to query server to
- * determine if content can be reused. This is required behaviour for
- * forced reloads etc.
- *
- * \param h Content handle to invalidate.
- */
-void content_invalidate_reuse_data(struct hlcache_handle *h);
/**
* Retrieve the refresh URL for a content
@@ -434,13 +344,6 @@ void content_invalidate_reuse_data(struct hlcache_handle *h);
*/
struct nsurl *content_get_refresh_url(struct hlcache_handle *h);
-/**
- * Retrieve the bitmap contained in an image content
- *
- * \param h handle to the content.
- * \return Pointer to bitmap, or NULL if none.
- */
-struct bitmap *content_get_bitmap(struct hlcache_handle *h);
/**
* Determine if a content is opaque from handle
@@ -451,6 +354,7 @@ struct bitmap *content_get_bitmap(struct hlcache_handle *h);
*/
bool content_get_opaque(struct hlcache_handle *h);
+
/**
* Retrieve quirkiness of a content
*
@@ -459,14 +363,6 @@ bool content_get_opaque(struct hlcache_handle *h);
*/
bool content_get_quirks(struct hlcache_handle *h);
-/**
- * Retrieve the encoding of a content
- *
- * \param h handle to the content.
- * \param op encoding operation.
- * \return Pointer to content info or NULL if none.
- */
-const char *content_get_encoding(struct hlcache_handle *h, enum content_encoding_type op);
/**
* Return whether a content is currently locked
@@ -476,4 +372,7 @@ const char *content_get_encoding(struct hlcache_handle *h, enum content_encoding
*/
bool content_is_locked(struct hlcache_handle *h);
+
+
+
#endif
diff --git a/content/content_factory.h b/content/content_factory.h
index 22205dc..9beeb19 100644
--- a/content/content_factory.h
+++ b/content/content_factory.h
@@ -23,7 +23,7 @@
#include <libwapcaplet/libwapcaplet.h>
-#include "content/content_type.h"
+#include "netsurf/content_type.h"
#include "utils/errors.h"
#define CONTENT_FACTORY_REGISTER_TYPES(HNAME, HTYPELIST, HHANDLER) \
diff --git a/content/content_protected.h b/content/content_protected.h
index fb810bd..ef38cb1 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -26,29 +26,22 @@
#ifndef _NETSURF_CONTENT_CONTENT_PROTECTED_H_
#define _NETSURF_CONTENT_CONTENT_PROTECTED_H_
-#include <stdint.h>
-#include <time.h>
#include <stdio.h>
-#include "utils/config.h"
+#include "utils/nsurl.h"
+#include "netsurf/content_type.h"
#include "content/content.h"
-#include "content/content_factory.h"
-#include "content/llcache.h"
-#include "utils/errors.h"
-
-struct bitmap;
-struct content;
-struct rect;
-struct redraw_context;
+
+struct content_redraw_data;
struct http_parameter;
struct content_handler {
void (*fini)(void);
- nserror (*create)(const content_handler *handler,
+ nserror (*create)(const struct content_handler *handler,
lwc_string *imime_type,
const struct http_parameter *params,
- llcache_handle *llcache,
+ struct llcache_handle *llcache,
const char *fallback_charset, bool quirks,
struct content **c);
@@ -108,11 +101,11 @@ struct content_user
/** Corresponds to a single URL. */
struct content {
- llcache_handle *llcache; /**< Low-level cache object */
+ struct llcache_handle *llcache; /**< Low-level cache object */
lwc_string *mime_type; /**< Original MIME type of data */
- const content_handler *handler; /**< Handler for content */
+ const struct content_handler *handler; /**< Handler for content */
content_status status; /**< Current status. */
@@ -161,7 +154,7 @@ struct content {
extern const char * const content_type_name[];
extern const char * const content_status_name[];
-nserror content__init(struct content *c, const content_handler *handler,
+nserror content__init(struct content *c, const struct content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
struct llcache_handle *llcache, const char *fallback_charset,
bool quirks);
diff --git a/content/fetch.c b/content/fetch.c
index 9c2933b..93c7de2 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -39,7 +39,6 @@
#include <strings.h>
#include <time.h>
#include <libwapcaplet/libwapcaplet.h>
-#include <curl/curl.h>
#include "utils/config.h"
#include "utils/corestrings.h"
@@ -49,7 +48,7 @@
#include "utils/nsurl.h"
#include "utils/utils.h"
#include "utils/ring.h"
-#include "desktop/gui_misc.h"
+#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "content/fetch.h"
@@ -291,10 +290,12 @@ nserror fetcher_init(void)
{
nserror ret;
+#ifdef WITH_CURL
ret = fetch_curl_register();
if (ret != NSERROR_OK) {
return ret;
}
+#endif
ret = fetch_data_register();
if (ret != NSERROR_OK) {
@@ -380,14 +381,14 @@ fetcher_add(lwc_string *scheme, const struct fetcher_operation_table *ops)
return NSERROR_OK;
}
-/* exported interface documented in content/fetchers.h */
-nserror fetcher_fdset(fd_set *read_fd_set,
+/* exported interface documented in content/fetch.h */
+nserror
+fetch_fdset(fd_set *read_fd_set,
fd_set *write_fd_set,
fd_set *except_fd_set,
int *maxfd_out)
{
- CURLMcode code;
- int maxfd;
+ int maxfd = -1;
int fetcherd; /* fetcher index */
if (!fetch_dispatch_jobs()) {
@@ -408,12 +409,19 @@ nserror fetcher_fdset(fd_set *read_fd_set,
FD_ZERO(read_fd_set);
FD_ZERO(write_fd_set);
FD_ZERO(except_fd_set);
- code = curl_multi_fdset(fetch_curl_multi,
- read_fd_set,
- write_fd_set,
- except_fd_set,
- &maxfd);
- assert(code == CURLM_OK);
+
+ for (fetcherd = 0; fetcherd < MAX_FETCHERS; fetcherd++) {
+ if ((fetchers[fetcherd].refcount > 0) &&
+ (fetchers[fetcherd].ops.fdset != NULL)) {
+ /* fetcher present */
+ int fetcher_maxfd;
+ fetcher_maxfd = fetchers[fetcherd].ops.fdset(
+ fetchers[fetcherd].scheme, read_fd_set,
+ write_fd_set, except_fd_set);
+ if (fetcher_maxfd > maxfd)
+ maxfd = fetcher_maxfd;
+ }
+ }
if (maxfd >= 0) {
/* change the scheduled poll to happen is a 1000ms as
diff --git a/content/fetch.h b/content/fetch.h
index 3c1f1cc..51e08cf 100644
--- a/content/fetch.h
+++ b/content/fetch.h
@@ -27,6 +27,7 @@
#include "utils/config.h"
#include "utils/nsurl.h"
+#include "utils/inet.h"
struct content;
struct fetch;
@@ -210,5 +211,30 @@ const char *fetch_get_referer_to_send(struct fetch *fetch);
*/
void fetch_set_cookie(struct fetch *fetch, const char *data);
+/**
+ * Get the set of file descriptors the fetchers are currently using.
+ *
+ * This obtains the file descriptors the fetch system is using to
+ * obtain data. It will cause the fetchers to make progress, if
+ * possible, potentially completing fetches before requiring activity
+ * on file descriptors.
+ *
+ * If a set of descriptors is returned (maxfd is not -1) The caller is
+ * expected to wait on them (with select etc.) and continue to obtain
+ * the fdset with this call. This will switch the fetchers from polled
+ * mode to waiting for network activity which is much more efficient.
+ *
+ * \note If the caller does not subsequently obtain the fdset again
+ * the fetchers will fall back to the less efficient polled
+ * operation. The fallback to polled operation will only occour after
+ * a timeout which introduces additional delay.
+ *
+ * \param[out] read_fd_set The fd set for read.
+ * \param[out] write_fd_set The fd set for write.
+ * \param[out] except_fd_set The fd set for exceptions.
+ * \param[out] maxfd The highest fd number in the set or -1 if no fd available.
+ * \return NSERROR_OK on success or appropriate error code.
+ */
+nserror fetch_fdset(fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *maxfd);
#endif
diff --git a/content/fetchers.h b/content/fetchers.h
index 92b11dc..6392e24 100644
--- a/content/fetchers.h
+++ b/content/fetchers.h
@@ -91,6 +91,12 @@ struct fetcher_operation_table {
void (*poll)(lwc_string *scheme);
/**
+ * update an fdset with the FDs needed to poll cleanly
+ */
+ int (*fdset)(lwc_string *scheme, fd_set *read_set, fd_set *write_set,
+ fd_set *error_set);
+
+ /**
* Finalise the fetcher.
*/
void (*finalise)(lwc_string *scheme);
@@ -123,30 +129,4 @@ nserror fetcher_init(void);
void fetcher_quit(void);
-/**
- * Get the set of file descriptors the fetchers are currently using.
- *
- * This obtains the file descriptors the fetch system is using to
- * obtain data. It will cause the fetchers to make progress, if
- * possible, potentially completing fetches before requiring activity
- * on file descriptors.
- *
- * If a set of descriptors is returned (maxfd is not -1) The caller is
- * expected to wait on them (with select etc.) and continue to obtain
- * the fdset with this call. This will switch the fetchers from polled
- * mode to waiting for network activity which is much more efficient.
- *
- * \note If the caller does not subsequently obtain the fdset again
- * the fetchers will fall back to the less efficient polled
- * operation. The fallback to polled operation will only occour after
- * a timeout which introduces additional delay.
- *
- * \param[out] read_fd_set The fd set for read.
- * \param[out] write_fd_set The fd set for write.
- * \param[out] except_fd_set The fd set for exceptions.
- * \param[out] maxfd The highest fd number in the set or -1 if no fd available.
- * \return NSERROR_OK on success or appropriate error code.
- */
-nserror fetcher_fdset(fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, int *maxfd);
-
#endif
diff --git a/content/fetchers/Makefile b/content/fetchers/Makefile
index 8551542..9c84793 100644
--- a/content/fetchers/Makefile
+++ b/content/fetchers/Makefile
@@ -1,8 +1,10 @@
# Content fetchers sources
-S_FETCHERS := curl.c data.c file.c about.c resource.c
+S_FETCHERS_YES := data.c file.c about.c resource.c
+S_FETCHERS_NO :=
+S_FETCHERS_$(NETSURF_USE_CURL) += curl.c
-S_FETCHERS := $(addprefix content/fetchers/,$(S_FETCHERS))
+S_FETCHERS := $(addprefix content/fetchers/,$(S_FETCHERS_YES))
# The following files depend on the testament
content/fetchers/about.c: testament $(OBJROOT)/testament.h
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index 605d3a8..4d14020 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -40,7 +40,6 @@
#include "content/fetch.h"
#include "content/fetchers.h"
#include "content/fetchers/about.h"
-#include "content/content_type.h"
#include "image/image_cache.h"
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index b94a3f2..7d0e40c 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -52,8 +52,8 @@
#include "utils/useragent.h"
#include "utils/file.h"
#include "utils/string.h"
-#include "desktop/gui_fetch.h"
-#include "desktop/gui_misc.h"
+#include "netsurf/fetch.h"
+#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "content/fetch.h"
@@ -64,6 +64,9 @@
/** maximum number of progress notifications per second */
#define UPDATES_PER_SECOND 2
+/** maximum number of X509 certificates in chain for TLS connection */
+#define MAX_CERTS 10
+
/** SSL certificate info */
struct cert_info {
X509 *cert; /**< Pointer to certificate */
@@ -89,29 +92,63 @@ struct curl_fetch_info {
char *post_urlenc; /**< Url encoded POST string, or 0. */
long http_code; /**< HTTP result code from cURL. */
struct curl_httppost *post_multipart; /**< Multipart post data, or 0. */
-#define MAX_CERTS 10
- struct cert_info cert_data[MAX_CERTS]; /**< HTTPS certificate data */
uint64_t last_progress_update; /**< Time of last progress update */
+ int cert_depth; /**< deepest certificate in use */
+ struct cert_info cert_data[MAX_CERTS]; /**< HTTPS certificate data */
};
+/** curl handle cache entry */
struct cache_handle {
CURL *handle; /**< The cached cURL handle */
- lwc_string *host; /**< The host for which this handle is cached */
+ lwc_string *host; /**< The host for which this handle is cached */
struct cache_handle *r_prev; /**< Previous cached handle in ring. */
struct cache_handle *r_next; /**< Next cached handle in ring. */
};
-CURLM *fetch_curl_multi; /**< Global cURL multi handle. */
+/** Global cURL multi handle. */
+CURLM *fetch_curl_multi;
+
/** Curl handle with default options set; not used for transfers. */
static CURL *fetch_blank_curl;
-static struct cache_handle *curl_handle_ring = 0; /**< Ring of cached handles */
+
+/** Ring of cached handles */
+static struct cache_handle *curl_handle_ring = 0;
+
+/** Count of how many schemes the curl fetcher is handling */
static int curl_fetchers_registered = 0;
+
+/** Flag for runtime detection of openssl usage */
static bool curl_with_openssl;
-static char fetch_error_buffer[CURL_ERROR_SIZE]; /**< Error buffer for cURL. */
-static char fetch_proxy_userpwd[100]; /**< Proxy authentication details. */
+/** Error buffer for cURL. */
+static char fetch_error_buffer[CURL_ERROR_SIZE];
+/** Proxy authentication details. */
+static char fetch_proxy_userpwd[100];
+
+
+/* OpenSSL 1.0.x to 1.1.0 certificate reference counting changed
+ * LibreSSL declares its OpenSSL version as 2.1 but only supports the old way
+ */
+#if (defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x1010000fL))
+static int ns_X509_up_ref(X509 *cert)
+{
+ cert->references++;
+ return 1;
+}
+
+static void ns_X509_free(X509 *cert)
+{
+ cert->references--;
+ if (cert->references == 0) {
+ X509_free(cert);
+ }
+}
+#else
+#define ns_X509_up_ref X509_up_ref
+#define ns_X509_free X509_free
+#endif
/**
* Initialise a cURL fetcher.
@@ -243,6 +280,7 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control)
return post;
}
+
/**
* Start fetching data for the given URL.
*
@@ -302,17 +340,22 @@ fetch_curl_setup(struct fetch *parent_fetch,
fetch->realm = NULL;
fetch->post_urlenc = NULL;
fetch->post_multipart = NULL;
- if (post_urlenc)
+ if (post_urlenc) {
fetch->post_urlenc = strdup(post_urlenc);
- else if (post_multipart)
+ } else if (post_multipart) {
fetch->post_multipart = fetch_curl_post_convert(post_multipart);
- memset(fetch->cert_data, 0, sizeof(fetch->cert_data));
+ }
fetch->last_progress_update = 0;
- if (fetch->host == NULL ||
- (post_multipart != NULL && fetch->post_multipart == NULL) ||
- (post_urlenc != NULL && fetch->post_urlenc == NULL))
+ /* TLS defaults */
+ memset(fetch->cert_data, 0, sizeof(fetch->cert_data));
+ fetch->cert_depth = -1;
+
+ if ((fetch->host == NULL) ||
+ (post_multipart != NULL && fetch->post_multipart == NULL) ||
+ (post_urlenc != NULL && fetch->post_urlenc == NULL)) {
goto failed;
+ }
#define APPEND(list, value) \
slist = curl_slist_append(list, value); \
@@ -374,32 +417,80 @@ failed:
/**
* OpenSSL Certificate verification callback
- * Stores certificate details in fetch struct.
+ *
+ * Called for each certificate in a chain being verified. OpenSSL
+ * calls this in deepest first order from the certificate authority to
+ * the peer certificate at position 0.
+ *
+ * Each certificate is stored in the fetch context the first time it
+ * is presented. If an error is encountered it is only returned for
+ * the peer certificate at position 0 allowing the enumeration of the
+ * entire chain not stopping early at the depth of the erroring
+ * certificate.
+ *
+ * \param verify_ok 0 if the caller has already determined the chain
+ * has errors else 1
+ * \param x509_ctx certificate context being verified
+ * \return 1 to indicate verification should continue and 0 to indicate
+ * verification should stop.
*/
static int
-fetch_curl_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
+fetch_curl_verify_callback(int verify_ok, X509_STORE_CTX *x509_ctx)
{
- X509 *cert = X509_STORE_CTX_get_current_cert(x509_ctx);
- int depth = X509_STORE_CTX_get_error_depth(x509_ctx);
- int err = X509_STORE_CTX_get_error(x509_ctx);
- struct curl_fetch_info *f = X509_STORE_CTX_get_app_data(x509_ctx);
+ int depth;
+ struct curl_fetch_info *fetch;
+
+ depth = X509_STORE_CTX_get_error_depth(x509_ctx);
+ fetch = X509_STORE_CTX_get_app_data(x509_ctx);
+
+ /* record the max depth */
+ if (depth > fetch->cert_depth) {
+ fetch->cert_depth = depth;
+ }
+
+ /* certificate chain is excessively deep so fail verification */
+ if (depth >= MAX_CERTS) {
+ X509_STORE_CTX_set_error(x509_ctx,
+ X509_V_ERR_CERT_CHAIN_TOO_LONG);
+ return 0;
+ }
/* save the certificate by incrementing the reference count and
* keeping a pointer.
*/
- if (depth < MAX_CERTS && !f->cert_data[depth].cert) {
- f->cert_data[depth].cert = cert;
- f->cert_data[depth].err = err;
- cert->references++;
+ if (!fetch->cert_data[depth].cert) {
+ fetch->cert_data[depth].cert = X509_STORE_CTX_get_current_cert(x509_ctx);
+ ns_X509_up_ref(fetch->cert_data[depth].cert);
+ fetch->cert_data[depth].err = X509_STORE_CTX_get_error(x509_ctx);
+ }
+
+ /* allow certificate chain to be completed */
+ if (depth > 0) {
+ verify_ok = 1;
+ } else {
+ /* search for deeper certificates in the chain with errors */
+ for (depth = fetch->cert_depth; depth > 0; depth--) {
+ if (fetch->cert_data[depth].err != 0) {
+ /* error in previous certificate so fail verification */
+ verify_ok = 0;
+ X509_STORE_CTX_set_error(x509_ctx, fetch->cert_data[depth].err);
+ }
+ }
}
- return preverify_ok;
+ return verify_ok;
}
/**
* OpenSSL certificate chain verification callback
- * Verifies certificate chain, setting up context for fetch_curl_verify_callback
+ *
+ * Verifies certificate chain by calling standard implementation after
+ * setting up context for the certificate callback.
+ *
+ * \param x509_ctx The certificate store to validate
+ * \param parm The fetch context.
+ * \return 1 to indicate verification success and 0 to indicate verification failure.
*/
static int fetch_curl_cert_verify_callback(X509_STORE_CTX *x509_ctx, void *parm)
{
@@ -408,9 +499,10 @@ static int fetch_curl_cert_verify_callback(X509_STORE_CTX *x509_ctx, void *parm)
/* Store fetch struct in context for verify callback */
ok = X509_STORE_CTX_set_app_data(x509_ctx, parm);
- /* and verify the certificate chain */
- if (ok)
+ /* verify the certificate chain using standard call */
+ if (ok) {
ok = X509_verify_cert(x509_ctx);
+ }
return ok;
}
@@ -431,7 +523,10 @@ fetch_curl_sslctxfun(CURL *curl_handle, void *_sslctx, void *parm)
SSL_CTX *sslctx = _sslctx;
long options = SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
+ /* set verify callback for each certificate in chain */
SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, fetch_curl_verify_callback);
+
+ /* set callback used to verify certificate chain */
SSL_CTX_set_cert_verify_callback(sslctx,
fetch_curl_cert_verify_callback,
parm);
@@ -626,7 +721,6 @@ static bool fetch_curl_start(void *vfetch)
/**
* Cache a CURL handle for the provided host (if wanted)
*/
-
static void fetch_curl_cache_handle(CURL *handle, lwc_string *host)
{
#if LIBCURL_VERSION_NUM >= 0x071e00
@@ -726,23 +820,24 @@ static void fetch_curl_free(void *vf)
struct curl_fetch_info *f = (struct curl_fetch_info *)vf;
int i;
- if (f->curl_handle)
+ if (f->curl_handle) {
curl_easy_cleanup(f->curl_handle);
+ }
nsurl_unref(f->url);
lwc_string_unref(f->host);
free(f->location);
free(f->cookie_string);
free(f->realm);
- if (f->headers)
+ if (f->headers) {
curl_slist_free_all(f->headers);
+ }
free(f->post_urlenc);
- if (f->post_multipart)
+ if (f->post_multipart) {
curl_formfree(f->post_multipart);
+ }
for (i = 0; i < MAX_CERTS && f->cert_data[i].cert; i++) {
- f->cert_data[i].cert->references--;
- if (f->cert_data[i].cert->references == 0)
- X509_free(f->cert_data[i].cert);
+ ns_X509_free(f->cert_data[i].cert);
}
free(f);
@@ -810,6 +905,114 @@ static bool fetch_curl_process_headers(struct curl_fetch_info *f)
return false;
}
+/**
+ * setup callback to allow the user to examine certificates which have
+ * failed to validate during fetch.
+ */
+static void
+curl_start_cert_validate(struct curl_fetch_info *f,
+ struct cert_info *certs)
+{
+ int depth;
+ BIO *mem;
+ BUF_MEM *buf;
+ struct ssl_cert_info ssl_certs[MAX_CERTS];
+ fetch_msg msg;
+
+ for (depth = 0; depth <= f->cert_depth; depth++) {
+ assert(certs[depth].cert != NULL);
+
+ /* get certificate version */
+ ssl_certs[depth].version = X509_get_version(certs[depth].cert);
+
+ /* not before date */
+ mem = BIO_new(BIO_s_mem());
+ ASN1_TIME_print(mem, X509_get_notBefore(certs[depth].cert));
+ BIO_get_mem_ptr(mem, &buf);
+ (void) BIO_set_close(mem, BIO_NOCLOSE);
+ BIO_free(mem);
+ memcpy(ssl_certs[depth].not_before,
+ buf->data,
+ min(sizeof(ssl_certs[depth].not_before) - 1,
+ (unsigned)buf->length));
+ ssl_certs[depth].not_before[min(sizeof(ssl_certs[depth].not_before) - 1,
+ (unsigned)buf->length)] = 0;
+ BUF_MEM_free(buf);
+
+ /* not after date */
+ mem = BIO_new(BIO_s_mem());
+ ASN1_TIME_print(mem,
+ X509_get_notAfter(certs[depth].cert));
+ BIO_get_mem_ptr(mem, &buf);
+ (void) BIO_set_close(mem, BIO_NOCLOSE);
+ BIO_free(mem);
+ memcpy(ssl_certs[depth].not_after,
+ buf->data,
+ min(sizeof(ssl_certs[depth].not_after) - 1,
+ (unsigned)buf->length));
+ ssl_certs[depth].not_after[min(sizeof(ssl_certs[depth].not_after) - 1,
+ (unsigned)buf->length)] = 0;
+ BUF_MEM_free(buf);
+
+ /* signature type */
+ ssl_certs[depth].sig_type =
+ X509_get_signature_type(certs[depth].cert);
+
+ /* serial number */
+ ssl_certs[depth].serial =
+ ASN1_INTEGER_get(
+ X509_get_serialNumber(certs[depth].cert));
+
+ /* issuer name */
+ mem = BIO_new(BIO_s_mem());
+ X509_NAME_print_ex(mem,
+ X509_get_issuer_name(certs[depth].cert),
+ 0, XN_FLAG_SEP_CPLUS_SPC |
+ XN_FLAG_DN_REV | XN_FLAG_FN_NONE);
+ BIO_get_mem_ptr(mem, &buf);
+ (void) BIO_set_close(mem, BIO_NOCLOSE);
+ BIO_free(mem);
+ memcpy(ssl_certs[depth].issuer,
+ buf->data,
+ min(sizeof(ssl_certs[depth].issuer) - 1,
+ (unsigned) buf->length));
+ ssl_certs[depth].issuer[min(sizeof(ssl_certs[depth].issuer) - 1,
+ (unsigned) buf->length)] = 0;
+ BUF_MEM_free(buf);
+
+ /* subject */
+ mem = BIO_new(BIO_s_mem());
+ X509_NAME_print_ex(mem,
+ X509_get_subject_name(certs[depth].cert),
+ 0,
+ XN_FLAG_SEP_CPLUS_SPC |
+ XN_FLAG_DN_REV |
+ XN_FLAG_FN_NONE);
+ BIO_get_mem_ptr(mem, &buf);
+ (void) BIO_set_close(mem, BIO_NOCLOSE);
+ BIO_free(mem);
+ memcpy(ssl_certs[depth].subject,
+ buf->data,
+ min(sizeof(ssl_certs[depth].subject) - 1,
+ (unsigned)buf->length));
+ ssl_certs[depth].subject[min(sizeof(ssl_certs[depth].subject) - 1,
+ (unsigned) buf->length)] = 0;
+ BUF_MEM_free(buf);
+
+ /* type of certificate */
+ ssl_certs[depth].cert_type =
+ X509_certificate_type(certs[depth].cert,
+ X509_get_pubkey(certs[depth].cert));
+
+ /* and clean up */
+ ns_X509_free(certs[depth].cert);
+ }
+
+ msg.type = FETCH_CERT_ERR;
+ msg.data.cert_err.certs = ssl_certs;
+ msg.data.cert_err.num_certs = depth;
+ fetch_send_callback(&msg, f->fetch_handle);
+}
/**
* Handle a completed fetch (CURLMSG_DONE from curl_multi_info_read()).
@@ -819,7 +1022,6 @@ static bool fetch_curl_process_headers(struct curl_fetch_info *f)
*/
static void fetch_curl_done(CURL *curl_handle, CURLcode result)
{
- fetch_msg msg;
bool finished = false;
bool error = false;
bool cert = false;
@@ -828,7 +1030,6 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result)
char **_hideous_hack = (char **) (void *) &f;
CURLcode code;
struct cert_info certs[MAX_CERTS];
- memset(certs, 0, sizeof(certs));
/* find the structure associated with this fetch */
/* For some reason, cURL thinks CURLINFO_PRIVATE should be a string?! */
@@ -838,8 +1039,9 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result)
abort_fetch = f->abort;
LOG("done %s", nsurl_access(f->url));
- if (abort_fetch == false && (result == CURLE_OK ||
- (result == CURLE_WRITE_ERROR && f->stopped == false))) {
+ if ((abort_fetch == false) &&
+ (result == CURLE_OK ||
+ ((result == CURLE_WRITE_ERROR) && (f->stopped == false)))) {
/* fetch completed normally or the server fed us a junk gzip
* stream (usually in the form of garbage at the end of the
* stream). Curl will have fed us all but the last chunk of
@@ -850,15 +1052,16 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result)
* the content handlers to cope.
*/
if (f->stopped ||
- (!f->had_headers &&
- fetch_curl_process_headers(f)))
+ (!f->had_headers && fetch_curl_process_headers(f))) {
; /* redirect with no body or similar */
- else
+ } else {
finished = true;
+ }
} else if (result == CURLE_PARTIAL_FILE) {
/* CURLE_PARTIAL_FILE occurs if the received body of a
* response is smaller than that specified in the
- * Content-Length header. */
+ * Content-Length header.
+ */
if (!f->had_headers && fetch_curl_process_headers(f))
; /* redirect with partial body, or similar */
else {
@@ -866,10 +1069,15 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result)
}
} else if (result == CURLE_WRITE_ERROR && f->stopped) {
/* CURLE_WRITE_ERROR occurs when fetch_curl_data
- * returns 0, which we use to abort intentionally */
+ * returns 0, which we use to abort intentionally
+ */
;
} else if (result == CURLE_SSL_PEER_CERTIFICATE ||
result == CURLE_SSL_CACERT) {
+ /* CURLE_SSL_PEER_CERTIFICATE renamed to
+ * CURLE_PEER_FAILED_VERIFICATION
+ */
+ memset(certs, 0, sizeof(certs));
memcpy(certs, f->cert_data, sizeof(certs));
memset(f->cert_data, 0, sizeof(f->cert_data));
cert = true;
@@ -880,104 +1088,17 @@ static void fetch_curl_done(CURL *curl_handle, CURLcode result)
fetch_curl_stop(f);
- if (abort_fetch)
+ if (abort_fetch) {
; /* fetch was aborted: no callback */
- else if (finished) {
+ } else if (finished) {
+ fetch_msg msg;
msg.type = FETCH_FINISHED;
fetch_send_callback(&msg, f->fetch_handle);
} else if (cert) {
- int i;
- BIO *mem;
- BUF_MEM *buf;
- struct ssl_cert_info ssl_certs[MAX_CERTS];
-
- for (i = 0; i < MAX_CERTS && certs[i].cert; i++) {
- ssl_certs[i].version =
- X509_get_version(certs[i].cert);
-
- mem = BIO_new(BIO_s_mem());
- ASN1_TIME_print(mem,
- X509_get_notBefore(certs[i].cert));
- BIO_get_mem_ptr(mem, &buf);
- (void) BIO_set_close(mem, BIO_NOCLOSE);
- BIO_free(mem);
- memcpy(ssl_certs[i].not_before,
- buf->data,
- min(sizeof(ssl_certs[i].not_before) - 1,
- (unsigned)buf->length));
- ssl_certs[i].not_before[min(sizeof(ssl_certs[i].not_before) - 1,
- (unsigned)buf->length)] = 0;
- BUF_MEM_free(buf);
-
- mem = BIO_new(BIO_s_mem());
- ASN1_TIME_print(mem,
- X509_get_notAfter(certs[i].cert));
- BIO_get_mem_ptr(mem, &buf);
- (void) BIO_set_close(mem, BIO_NOCLOSE);
- BIO_free(mem);
- memcpy(ssl_certs[i].not_after,
- buf->data,
- min(sizeof(ssl_certs[i].not_after) - 1,
- (unsigned)buf->length));
- ssl_certs[i].not_after[min(sizeof(ssl_certs[i].not_after) - 1,
- (unsigned)buf->length)] = 0;
-
- BUF_MEM_free(buf);
-
- ssl_certs[i].sig_type =
- X509_get_signature_type(certs[i].cert);
- ssl_certs[i].serial =
- ASN1_INTEGER_get(
- X509_get_serialNumber(certs[i].cert));
- mem = BIO_new(BIO_s_mem());
- X509_NAME_print_ex(mem,
- X509_get_issuer_name(certs[i].cert),
- 0, XN_FLAG_SEP_CPLUS_SPC |
- XN_FLAG_DN_REV | XN_FLAG_FN_NONE);
- BIO_get_mem_ptr(mem, &buf);
- (void) BIO_set_close(mem, BIO_NOCLOSE);
- BIO_free(mem);
- memcpy(ssl_certs[i].issuer,
- buf->data,
- min(sizeof(ssl_certs[i].issuer) - 1,
- (unsigned) buf->length));
- ssl_certs[i].issuer[min(sizeof(ssl_certs[i].issuer) - 1,
- (unsigned) buf->length)] = 0;
- BUF_MEM_free(buf);
-
- mem = BIO_new(BIO_s_mem());
- X509_NAME_print_ex(mem,
- X509_get_subject_name(certs[i].cert),
- 0,
- XN_FLAG_SEP_CPLUS_SPC |
- XN_FLAG_DN_REV |
- XN_FLAG_FN_NONE);
- BIO_get_mem_ptr(mem, &buf);
- (void) BIO_set_close(mem, BIO_NOCLOSE);
- BIO_free(mem);
- memcpy(ssl_certs[i].subject,
- buf->data,
- min(sizeof(ssl_certs[i].subject) - 1,
- (unsigned)buf->length));
- ssl_certs[i].subject[min(sizeof(ssl_certs[i].subject) - 1,
- (unsigned) buf->length)] = 0;
- BUF_MEM_free(buf);
-
- ssl_certs[i].cert_type =
- X509_certificate_type(certs[i].cert,
- X509_get_pubkey(certs[i].cert));
-
- /* and clean up */
- certs[i].cert->references--;
- if (certs[i].cert->references == 0)
- X509_free(certs[i].cert);
- }
-
- msg.type = FETCH_CERT_ERR;
- msg.data.cert_err.certs = ssl_certs;
- msg.data.cert_err.num_certs = i;
- fetch_send_callback(&msg, f->fetch_handle);
+ /* user needs to validate certificate with issue */
+ curl_start_cert_validate(f, certs);
} else if (error) {
+ fetch_msg msg;
switch (result) {
case CURLE_SSL_CONNECT_ERROR:
msg.type = FETCH_SSL_ERR;
@@ -1080,9 +1201,12 @@ static void fetch_curl_poll(lwc_string *scheme_ignored)
/**
* Callback function for fetch progress.
*/
-
-static int fetch_curl_progress(void *clientp, double dltotal, double dlnow,
- double ultotal, double ulnow)
+static int
+fetch_curl_progress(void *clientp,
+ double dltotal,
+ double dlnow,
+ double ultotal,
+ double ulnow)
{
static char fetch_progress_buffer[256]; /**< Progress buffer for cURL */
struct curl_fetch_info *f = (struct curl_fetch_info *) clientp;
@@ -1147,8 +1271,7 @@ static size_t fetch_curl_data(char *data, size_t size, size_t nmemb, void *_f)
fetch_msg msg;
/* ensure we only have to get this information once */
- if (!f->http_code)
- {
+ if (!f->http_code) {
code = curl_easy_getinfo(f->curl_handle, CURLINFO_HTTP_CODE,
&f->http_code);
fetch_set_http_code(f->fetch_handle, f->http_code);
@@ -1158,8 +1281,7 @@ static size_t fetch_curl_data(char *data, size_t size, size_t nmemb, void *_f)
/* ignore body if this is a 401 reply by skipping it and reset
* the HTTP response code to enable follow up fetches.
*/
- if (f->http_code == 401)
- {
+ if (f->http_code == 401) {
f->http_code = 0;
return size * nmemb;
}
@@ -1189,8 +1311,8 @@ static size_t fetch_curl_data(char *data, size_t size, size_t nmemb, void *_f)
*
* See RFC 2616 4.2.
*/
-static size_t fetch_curl_header(char *data, size_t size, size_t nmemb,
- void *_f)
+static size_t
+fetch_curl_header(char *data, size_t size, size_t nmemb, void *_f)
{
struct curl_fetch_info *f = _f;
int i;
@@ -1268,6 +1390,23 @@ static size_t fetch_curl_header(char *data, size_t size, size_t nmemb,
#undef SKIP_ST
}
+static int fetch_curl_fdset(lwc_string *scheme, fd_set *read_set,
+ fd_set *write_set, fd_set *error_set)
+{
+ CURLMcode code;
+ int maxfd = -1;
+
+ code = curl_multi_fdset(fetch_curl_multi,
+ read_set,
+ write_set,
+ error_set,
+ &maxfd);
+ assert(code == CURLM_OK);
+
+ return maxfd;
+}
+
+
/* exported function documented in content/fetchers/curl.h */
nserror fetch_curl_register(void)
@@ -1284,6 +1423,7 @@ nserror fetch_curl_register(void)
.abort = fetch_curl_abort,
.free = fetch_curl_free,
.poll = fetch_curl_poll,
+ .fdset = fetch_curl_fdset,
.finalise = fetch_curl_finalise
};
@@ -1321,8 +1461,8 @@ nserror fetch_curl_register(void)
#endif
/* Create a curl easy handle with the options that are common to all
- fetches.
- */
+ * fetches.
+ */
fetch_blank_curl = curl_easy_init();
if (!fetch_blank_curl) {
LOG("curl_easy_init failed");
diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index 84d0aa3..139d09a 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -24,15 +24,15 @@
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
-#include <curl/curl.h> /* for URL unescaping functions */
#include <libwapcaplet/libwapcaplet.h>
+#include <nsutils/base64.h>
+#include "utils/url.h"
#include "utils/nsurl.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/ring.h"
-#include "utils/base64.h"
#include "content/fetch.h"
#include "content/fetchers.h"
@@ -54,21 +54,16 @@ struct fetch_data_context {
static struct fetch_data_context *ring = NULL;
-static CURL *curl;
-
static bool fetch_data_initialise(lwc_string *scheme)
{
LOG("fetch_data_initialise called for %s", lwc_string_data(scheme));
- if ( (curl = curl_easy_init()) == NULL)
- return false;
- else
- return true;
+
+ return true;
}
static void fetch_data_finalise(lwc_string *scheme)
{
LOG("fetch_data_finalise called for %s", lwc_string_data(scheme));
- curl_easy_cleanup(curl);
}
static bool fetch_data_can_fetch(const nsurl *url)
@@ -138,11 +133,12 @@ static void fetch_data_send_callback(const fetch_msg *msg,
static bool fetch_data_process(struct fetch_data_context *c)
{
+ nserror res;
fetch_msg msg;
char *params;
char *comma;
char *unescaped;
- int unescaped_len;
+ size_t unescaped_len;
/* format of a data: URL is:
* data:[<mimetype>][;base64],<data>
@@ -197,8 +193,8 @@ static bool fetch_data_process(struct fetch_data_context *c)
/* URL unescape the data first, just incase some insane page
* decides to nest URL and base64 encoding. Like, say, Acid2.
*/
- unescaped = curl_easy_unescape(curl, comma + 1, 0, &unescaped_len);
- if (unescaped == NULL) {
+ res = url_unescape(comma + 1, 0, &unescaped_len, &unescaped);
+ if (res != NSERROR_OK) {
msg.type = FETCH_ERROR;
msg.data.error = "Unable to URL decode data: URL";
fetch_data_send_callback(&msg, c);
@@ -206,12 +202,15 @@ static bool fetch_data_process(struct fetch_data_context *c)
}
if (c->base64) {
- base64_decode_alloc(unescaped, unescaped_len, &c->data, &c->datalen);
- if (c->data == NULL) {
+ if ((nsu_base64_decode_alloc((uint8_t *)unescaped,
+ unescaped_len,
+ (uint8_t **)&c->data,
+ &c->datalen) != NSUERROR_OK) ||
+ (c->data == NULL)) {
msg.type = FETCH_ERROR;
msg.data.error = "Unable to Base64 decode data: URL";
fetch_data_send_callback(&msg, c);
- curl_free(unescaped);
+ free(unescaped);
return false;
}
} else {
@@ -221,14 +220,14 @@ static bool fetch_data_process(struct fetch_data_context *c)
msg.data.error =
"Unable to allocate memory for data: URL";
fetch_data_send_callback(&msg, c);
- curl_free(unescaped);
+ free(unescaped);
return false;
}
c->datalen = unescaped_len;
memcpy(c->data, unescaped, unescaped_len);
}
- curl_free(unescaped);
+ free(unescaped);
return true;
}
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index 8cfe3a0..6ffa638 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -20,6 +20,8 @@
* \file
*
* file scheme URL handling. Based on the data fetcher by Rob Kendrick
+ *
+ * output dates and directory ordering are affected by the current locale
*/
#include "utils/config.h"
@@ -49,7 +51,7 @@
#include "utils/utils.h"
#include "utils/ring.h"
#include "utils/file.h"
-#include "desktop/gui_fetch.h"
+#include "netsurf/fetch.h"
#include "desktop/gui_internal.h"
#include "content/dirlist.h"
@@ -536,7 +538,9 @@ process_dir_ent(struct fetch_file_context *ctx,
datebuf[0] = 0;
timebuf[0] = 0;
} else {
- /* Get date in output format */
+ /* Get date in output format. a (day of week) and b
+ * (month) are both affected by the locale
+ */
if (strftime((char *)&datebuf, sizeof datebuf, "%a %d %b %Y",
localtime(&ent_stat.st_mtime)) == 0) {
datebuf[0] = '-';
diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c
index 72ed887..21ad8c7 100644
--- a/content/fetchers/resource.c
+++ b/content/fetchers/resource.c
@@ -35,7 +35,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/ring.h"
-#include "desktop/gui_fetch.h"
+#include "netsurf/fetch.h"
#include "desktop/gui_internal.h"
#include "content/fetch.h"
diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c
index 0c76596..635f917 100644
--- a/content/fs_backing_store.c
+++ b/content/fs_backing_store.c
@@ -27,9 +27,9 @@
*
* \todo Implement mmap retrieval where supported.
*
- * \todo Implement static retrival for metadata objects as their heap
+ * \todo Implement static retrieval for metadata objects as their heap
* lifetime is typically very short, though this may be obsoleted
- * by a small object storage stratagy.
+ * by a small object storage strategy.
*
*/
@@ -50,7 +50,7 @@
#include "utils/utils.h"
#include "utils/messages.h"
#include "desktop/gui_internal.h"
-#include "desktop/gui_misc.h"
+#include "netsurf/misc.h"
#include "content/backing_store.h"
@@ -63,7 +63,7 @@
/** Backing store file format version */
#define CONTROL_VERSION 130
-/** Number of milliseconds after a update before control data maintinance is performed */
+/** Number of milliseconds after a update before control data maintenance is performed */
#define CONTROL_MAINT_TIME 10000
/** Get address from ident */
@@ -100,7 +100,7 @@
#define BLOCK_USE_MAP_SIZE (1 << (BLOCK_ENTRY_COUNT - 3))
/**
- * The type used to store index values refering to store entries. Care
+ * The type used to store index values referring to store entries. Care
* must be taken with this type as it is used to build address to
* entry mapping so changing the size will have large impacts on
* memory usage.
@@ -109,7 +109,7 @@ typedef uint16_t entry_index_t;
/**
* The type used as a binary identifier for each entry derived from
- * the url. A larger identifier will have fewer collisions but
+ * the URL. A larger identifier will have fewer collisions but
* requires proportionately more storage.
*/
typedef uint32_t entry_ident_t;
@@ -184,7 +184,7 @@ struct store_entry_element {
* @note Order is important to avoid excessive structure packing overhead.
*/
struct store_entry {
- int64_t last_used; /**< unix time the entry was last used */
+ int64_t last_used; /**< UNIX time the entry was last used */
entry_ident_t ident; /**< entry identifier */
uint16_t use_count; /**< number of times this entry has been accessed */
uint8_t flags; /**< entry flags */
@@ -227,7 +227,7 @@ struct store_state {
unsigned int entry_bits; /**< log2 number of bits in entry index. */
unsigned int last_entry; /**< index of last usable entry. */
- /** flag indicating if the entries have been made persistant
+ /** flag indicating if the entries have been made persistent
* since they were last changed.
*/
bool entries_dirty;
@@ -235,9 +235,9 @@ struct store_state {
/**
* URL identifier to entry index mapping.
*
- * This is an open coded index on the entries url field and
- * provides a computationaly inexpensive way to go from the
- * url to an entry.
+ * This is an open coded index on the entries URL field and
+ * provides a computationally inexpensive way to go from the
+ * URL to an entry.
*/
entry_index_t *addrmap;
@@ -246,12 +246,12 @@ struct store_state {
struct block_file blocks[ENTRY_ELEM_COUNT][BLOCK_FILE_COUNT];
/** flag indicating if the block file use maps have been made
- * persistant since they were last changed.
+ * persistent since they were last changed.
*/
bool blocks_dirty;
/** flag indicating if a block file has been opened for update
- * since maintinance was previously done.
+ * since maintenance was previously done.
*/
bool blocks_opened;
@@ -283,8 +283,8 @@ struct store_state *storestate;
*
* @param[in] state The store state to use.
* @param[in, out] bse Pointer to the entry to be removed.
- * @return NSERROR_OK and \a bse updated on succes or NSERROR_NOT_FOUND
- * if no entry coresponds to the url.
+ * @return NSERROR_OK and \a bse updated on success or NSERROR_NOT_FOUND
+ * if no entry corresponds to the URL.
*/
static nserror
remove_store_entry(struct store_state *state, struct store_entry **bse)
@@ -460,7 +460,7 @@ store_fname(struct store_state *state,
* @param state The store state to use.
* @param bse The entry to invalidate.
* @param elem_idx The element index to invalidate.
- * @return NSERROR_OK on sucess or error code on failure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
invalidate_element(struct store_state *state,
@@ -500,7 +500,7 @@ invalidate_element(struct store_state *state,
*
* @param state The store state to use.
* @param bse The entry to invalidate.
- * @return NSERROR_OK on sucess or error code on failure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
invalidate_entry(struct store_state *state, struct store_entry *bse)
@@ -554,7 +554,7 @@ static int compar(const void *va, const void *vb)
const struct store_entry *b = &BS_ENTRY(*(entry_ident_t *)vb, storestate);
/* consider the allocation flags - if an entry has an
- * allocation it is considered more valuble as it cannot be
+ * allocation it is considered more valuable as it cannot be
* freed.
*/
if ((a->elem[ENTRY_ELEM_DATA].flags == ENTRY_ELEM_FLAG_NONE) &&
@@ -670,7 +670,7 @@ static nserror store_evict(struct store_state *state)
* Serialise entry index out to storage.
*
* @param state The backing store state to serialise.
- * @return NSERROR_OK on sucess or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror write_entries(struct store_state *state)
{
@@ -735,7 +735,7 @@ static nserror write_entries(struct store_state *state)
* Serialise block file use map out to storage.
*
* \param state The backing store state to serialise.
- * \return NSERROR_OK on sucess or error code on faliure.
+ * \return NSERROR_OK on success or error code on failure.
*/
static nserror write_blocks(struct store_state *state)
{
@@ -812,11 +812,11 @@ wr_err:
* Ensures block files are of the correct extent
*
* block files have their extent set to their maximum size to ensure
- * subsequent reads and writes do not need to extend teh file and are
+ * subsequent reads and writes do not need to extend the file and are
* therefore faster.
*
* \param state The backing store state to set block extent for.
- * \return NSERROR_OK on sucess or error code on faliure.
+ * \return NSERROR_OK on success or error code on failure.
*/
static nserror set_block_extents(struct store_state *state)
{
@@ -849,7 +849,7 @@ static nserror set_block_extents(struct store_state *state)
}
/**
- * maintinance of control structures.
+ * maintenance of control structures.
*
* callback scheduled when control data has been update. Currently
* this is for when the entries table is dirty and requires
@@ -959,7 +959,7 @@ static block_index_t alloc_block(struct store_state *state, int elem_idx)
* @param datalen The length of data in \a data
* @param bse Pointer used to return value.
* @return NSERROR_OK and \a bse updated on success or NSERROR_NOT_FOUND
- * if no entry coresponds to the url.
+ * if no entry corresponds to the url.
*/
static nserror
set_store_entry(struct store_state *state,
@@ -1045,12 +1045,12 @@ set_store_entry(struct store_state *state,
elem->size = datalen;
state->total_alloc += elem->size;
- /* if the elemnt will fit in a small block attempt to allocate one */
+ /* if the element will fit in a small block attempt to allocate one */
if (elem->size <= (1U << log2_block_size[elem_idx])) {
elem->block = alloc_block(state, elem_idx);
}
- /* ensure control maintinance scheduled. */
+ /* ensure control maintenance scheduled. */
state->entries_dirty = true;
guit->misc->schedule(CONTROL_MAINT_TIME, control_maintinance, state);
@@ -1118,7 +1118,7 @@ store_open(struct store_state *state,
* we also compute the total storage in use.
*
* @param state The backing store global state.
- * @return NSERROR_OK on sucess or NSERROR_NOMEM if the map storage
+ * @return NSERROR_OK on success or NSERROR_NOMEM if the map storage
* could not be allocated.
*/
static nserror
@@ -1163,7 +1163,7 @@ build_entrymap(struct store_state *state)
* Unlink entries file
*
* @param state The backing store state.
- * @return NSERROR_OK on sucess or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
unlink_entries(struct store_state *state)
@@ -1186,7 +1186,7 @@ unlink_entries(struct store_state *state)
* Read description entries into memory.
*
* @param state The backing store state to put the loaded entries in.
- * @return NSERROR_OK on sucess or error code on faliure.
+ * @return NSERROR_OK on success or error code on faliure.
*/
static nserror
read_entries(struct store_state *state)
@@ -1236,7 +1236,7 @@ read_entries(struct store_state *state)
* Read block file usage bitmaps.
*
* @param state The backing store state to put the loaded entries in.
- * @return NSERROR_OK on sucess or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
read_blocks(struct store_state *state)
@@ -1275,7 +1275,7 @@ read_blocks(struct store_state *state)
} else {
LOG("Initialising block use map to defaults");
- /* ensure block 0 (invalid sentinal) is skipped */
+ /* ensure block 0 (invalid sentinel) is skipped */
state->blocks[ENTRY_ELEM_DATA][0].use_map[0] = 1;
state->blocks[ENTRY_ELEM_META][0].use_map[0] = 1;
}
@@ -1293,7 +1293,7 @@ read_blocks(struct store_state *state)
* Write the cache tag file.
*
* @param state The cache state.
- * @return NSERROR_OK on sucess or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
write_cache_tag(struct store_state *state)
@@ -1330,7 +1330,7 @@ write_cache_tag(struct store_state *state)
* Write the control file for the current state.
*
* @param state The state to write to the control file.
- * @return NSERROR_OK on sucess or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
write_control(struct store_state *state)
@@ -1375,7 +1375,7 @@ write_control(struct store_state *state)
* Read and parse the control file.
*
* @param state The state to read from the control file.
- * @return NSERROR_OK on sucess or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
read_control(struct store_state *state)
@@ -1461,7 +1461,7 @@ control_error: /* problem with the control file */
* Initialise the backing store.
*
* @param parameters to configure backing store.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
initialise(const struct llcache_store_parameters *parameters)
@@ -1732,7 +1732,7 @@ static nserror store_write_file(struct store_state *state,
* @param bsflags The flags to control how the object is stored.
* @param data The objects source data.
* @param datalen The length of the \a data.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
store(nsurl *url,
@@ -1893,13 +1893,13 @@ static nserror store_read_file(struct store_state *state,
}
/**
- * Retrive an object from the backing store.
+ * Retrieve an object from the backing store.
*
* @param[in] url The url is used as the unique primary key for the data.
* @param[in] bsflags The flags to control how the object is retrieved.
* @param[out] data_out The objects data.
* @param[out] datalen_out The length of the \a data retrieved.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
fetch(nsurl *url,
@@ -1926,7 +1926,7 @@ fetch(nsurl *url,
}
storestate->hit_count++;
- LOG("retriving cache data for url:%s", nsurl_access(url));
+ LOG("retrieving cache data for url:%s", nsurl_access(url));
/* calculate the entry element index */
if ((bsflags & BACKING_STORE_META) != 0) {
@@ -1984,7 +1984,7 @@ fetch(nsurl *url,
*
* @param[in] url The url is used as the unique primary key to invalidate.
* @param[in] bsflags The flags to control how the object data is released.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror release(nsurl *url, enum backing_store_flags bsflags)
{
@@ -2032,7 +2032,7 @@ static nserror release(nsurl *url, enum backing_store_flags bsflags)
* be returned as a result to the fetch or meta operations.
*
* @param url The url is used as the unique primary key to invalidate.
- * @return NSERROR_OK on success or error code on faliure.
+ * @return NSERROR_OK on success or error code on failure.
*/
static nserror
invalidate(nsurl *url)
diff --git a/content/handlers/Makefile b/content/handlers/Makefile
new file mode 100644
index 0000000..2f2da3a
--- /dev/null
+++ b/content/handlers/Makefile
@@ -0,0 +1,16 @@
+# Image content handler sources
+include content/handlers/image/Makefile
+
+S_IMAGE := $(addprefix content/handlers/image/,$(S_IMAGE))
+
+# CSS sources
+include content/handlers/css/Makefile
+
+S_CONTENT += $(addprefix handlers/css/,$(S_CSS))
+
+# Javascript source
+include content/handlers/javascript/Makefile
+
+S_CONTENT += $(addprefix handlers/javascript/,$(S_JAVASCRIPT))
+
+INCLUDE_DIRS += content/handlers
diff --git a/css/Makefile b/content/handlers/css/Makefile
similarity index 67%
rename from css/Makefile
rename to content/handlers/css/Makefile
index 127dbaa..bbfc8d7 100644
--- a/css/Makefile
+++ b/content/handlers/css/Makefile
@@ -2,4 +2,3 @@
S_CSS := css.c dump.c internal.c hints.c select.c utils.c
-S_CSS := $(addprefix css/,$(S_CSS))
diff --git a/css/css.c b/content/handlers/css/css.c
similarity index 94%
rename from css/css.c
rename to content/handlers/css/css.c
index 66dc6d4..997eb51 100644
--- a/css/css.c
+++ b/content/handlers/css/css.c
@@ -76,11 +76,11 @@ typedef struct nscss_content
*/
typedef struct {
struct content_css_data *css; /**< Object containing import */
- uint32_t index; /**< Index into parent sheet's
+ uint32_t index; /**< Index into parent sheet's
* imports array */
} nscss_import_ctx;
-static bool nscss_process_data(struct content *c, const char *data,
+static bool nscss_process_data(struct content *c, const char *data,
unsigned int size);
static bool nscss_convert(struct content *c);
static void nscss_destroy(struct content *c);
@@ -91,13 +91,13 @@ static content_type nscss_content_type(void);
static nserror nscss_create_css_data(struct content_css_data *c,
const char *url, const char *charset, bool quirks,
nscss_done_callback done, void *pw);
-static css_error nscss_process_css_data(struct content_css_data *c, const char *data,
+static css_error nscss_process_css_data(struct content_css_data *c, const char *data,
unsigned int size);
static css_error nscss_convert_css_data(struct content_css_data *c);
static void nscss_destroy_css_data(struct content_css_data *c);
static void nscss_content_done(struct content_css_data *css, void *pw);
-static css_error nscss_handle_import(void *pw, css_stylesheet *parent,
+static css_error nscss_handle_import(void *pw, css_stylesheet *parent,
lwc_string *url, uint64_t media);
static nserror nscss_import(hlcache_handle *handle,
const hlcache_event *event, void *pw);
@@ -151,7 +151,7 @@ nscss_create(const content_handler *handler,
}
/* Find charset specified on HTTP layer, if any */
- error = http_parameter_list_find_item(params, corestring_lwc_charset,
+ error = http_parameter_list_find_item(params, corestring_lwc_charset,
&charset_value);
if (error != NSERROR_OK || lwc_string_length(charset_value) == 0) {
/* No charset specified, use fallback, if any */
@@ -167,8 +167,8 @@ nscss_create(const content_handler *handler,
xnsbase = nsurl_access(content_get_url(&result->base));
}
- error = nscss_create_css_data(&result->data,
- xnsbase, charset, result->base.quirks,
+ error = nscss_create_css_data(&result->data,
+ xnsbase, charset, result->base.quirks,
nscss_content_done, result);
if (error != NSERROR_OK) {
msg_data.error = messages_get("NoMemory");
@@ -273,7 +273,7 @@ bool nscss_process_data(struct content *c, const char *data, unsigned int size)
static css_error nscss_process_css_data(struct content_css_data *c,
const char *data, unsigned int size)
{
- return css_stylesheet_append_data(c->sheet,
+ return css_stylesheet_append_data(c->sheet,
(const uint8_t *) data, size);
}
@@ -316,7 +316,7 @@ static css_error nscss_convert_css_data(struct content_css_data *c)
/* We must not have registered any imports yet */
assert(c->next_to_register == (uint32_t) -1);
- /* Start registering, until we find one that
+ /* Start registering, until we find one that
* hasn't finished fetching */
c->next_to_register = 0;
error = nscss_register_imports(c);
@@ -396,7 +396,7 @@ nserror nscss_clone(const struct content *old, struct content **newc)
/* Simply replay create/process/convert */
error = nscss_create_css_data(&new_css->data,
nsurl_access(content_get_url(&new_css->base)),
- old_css->data.charset,
+ old_css->data.charset,
new_css->base.quirks,
nscss_content_done, new_css);
if (error != NSERROR_OK) {
@@ -430,12 +430,7 @@ bool nscss_matches_quirks(const struct content *c, bool quirks)
return c->quirks == quirks;
}
-/**
- * Retrieve the stylesheet object associated with a CSS content
- *
- * \param h Stylesheet content
- * \return Pointer to stylesheet object
- */
+/* exported interface documented in netsurf/css.h */
css_stylesheet *nscss_get_stylesheet(struct hlcache_handle *h)
{
nscss_content *c = (nscss_content *) hlcache_handle_get_content(h);
@@ -445,13 +440,7 @@ css_stylesheet *nscss_get_stylesheet(struct hlcache_handle *h)
return c->data.sheet;
}
-/**
- * Retrieve imported stylesheets
- *
- * \param h Stylesheet containing imports
- * \param n Pointer to location to receive number of imports
- * \return Pointer to array of imported stylesheets
- */
+/* exported interface documented in netsurf/css.h */
struct nscss_import *nscss_get_imports(hlcache_handle *h, uint32_t *n)
{
nscss_content *c = (nscss_content *) hlcache_handle_get_content(h);
@@ -562,7 +551,7 @@ css_error nscss_handle_import(void *pw, css_stylesheet *parent,
ctx->index = c->import_count;
/* Increase space in table */
- imports = realloc(c->imports, (c->import_count + 1) *
+ imports = realloc(c->imports, (c->import_count + 1) *
sizeof(struct nscss_import));
if (imports == NULL) {
free(ctx);
@@ -710,12 +699,12 @@ css_error nscss_register_imports(struct content_css_data *c)
/* Register imported sheets */
for (index = c->next_to_register; index < c->import_count; index++) {
- /* Stop registering if we encounter one whose fetch hasn't
- * completed yet. We'll resume at this point when it has
+ /* Stop registering if we encounter one whose fetch hasn't
+ * completed yet. We'll resume at this point when it has
* completed.
*/
- if (c->imports[index].c != NULL &&
- content_get_status(c->imports[index].c) !=
+ if (c->imports[index].c != NULL &&
+ content_get_status(c->imports[index].c) !=
CONTENT_STATUS_DONE) {
break;
}
@@ -751,7 +740,7 @@ css_error nscss_register_import(struct content_css_data *c,
css_error error;
if (import != NULL) {
- nscss_content *s =
+ nscss_content *s =
(nscss_content *) hlcache_handle_get_content(import);
sheet = s->data.sheet;
} else {
@@ -822,16 +811,14 @@ static const content_handler css_content_handler = {
.no_share = false,
};
-/**
- * Initialise the CSS content handler
- */
+/* exported interface documented in netsurf/css.h */
nserror nscss_init(void)
{
nserror error;
- error = content_factory_register_handler("text/css",
+ error = content_factory_register_handler("text/css",
&css_content_handler);
- if (error != NSERROR_OK)
+ if (error != NSERROR_OK)
goto error;
error = css_hint_init();
diff --git a/css/css.h b/content/handlers/css/css.h
similarity index 73%
copy from css/css.h
copy to content/handlers/css/css.h
index be8d4bc..4b38829 100644
--- a/css/css.h
+++ b/content/handlers/css/css.h
@@ -35,10 +35,28 @@ struct nscss_import {
uint64_t media; /**< Media types that sheet applies to */
};
+/**
+ * Initialise the CSS content handler
+ *
+ * \return NSERROR_OK on success or error code on faliure
+ */
nserror nscss_init(void);
+/**
+ * Retrieve the stylesheet object associated with a CSS content
+ *
+ * \param h Stylesheet content
+ * \return Pointer to stylesheet object
+ */
css_stylesheet *nscss_get_stylesheet(struct hlcache_handle *h);
+
+/**
+ * Retrieve imported stylesheets
+ *
+ * \param h Stylesheet containing imports
+ * \param n Pointer to location to receive number of imports
+ * \return Pointer to array of imported stylesheets
+ */
struct nscss_import *nscss_get_imports(struct hlcache_handle *h, uint32_t *n);
#endif
-
diff --git a/css/dump.c b/content/handlers/css/dump.c
similarity index 98%
rename from css/dump.c
rename to content/handlers/css/dump.c
index d3ebc94..1ad188c 100644
--- a/css/dump.c
+++ b/content/handlers/css/dump.c
@@ -17,19 +17,105 @@
*/
#include <stdio.h>
+#include <libcss/libcss.h>
#include "css/dump.h"
-static void dump_css_fixed(FILE *stream, css_fixed f);
-static void dump_css_number(FILE *stream, css_fixed val);
-static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit);
+/**
+ * Dump a fixed point value to the stream in a textual form.
+ *
+ * \param stream Stream to write to
+ * \param f Value to write
+ */
+static void dump_css_fixed(FILE *stream, css_fixed f)
+{
+#define NSCSS_ABS(x) (uint32_t)((x) < 0 ? -(x) : (x))
+ uint32_t uintpart = FIXTOINT(NSCSS_ABS(f));
+ /* + 500 to ensure round to nearest (division will truncate) */
+ uint32_t fracpart = ((NSCSS_ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10);
+#undef NSCSS_ABS
+
+ fprintf(stream, "%s%d.%03d", f < 0 ? "-" : "", uintpart, fracpart);
+}
/**
- * Dump a computed style \a style to the give file handle \a stream.
+ * Dump a numeric value to the stream in a textual form.
*
* \param stream Stream to write to
- * \param style Computed style to dump
+ * \param val Value to write
*/
+static void dump_css_number(FILE *stream, css_fixed val)
+{
+ if (INTTOFIX(FIXTOINT(val)) == val)
+ fprintf(stream, "%d", FIXTOINT(val));
+ else
+ dump_css_fixed(stream, val);
+}
+
+/**
+ * Dump a dimension to the stream in a textual form.
+ *
+ * \param stream Stream to write to
+ * \param val Value to write
+ * \param unit Unit to write
+ */
+static void dump_css_unit(FILE *stream, css_fixed val, css_unit unit)
+{
+ dump_css_number(stream, val);
+
+ switch (unit) {
+ case CSS_UNIT_PX:
+ fprintf(stream, "px");
+ break;
+ case CSS_UNIT_EX:
+ fprintf(stream, "ex");
+ break;
+ case CSS_UNIT_EM:
+ fprintf(stream, "em");
+ break;
+ case CSS_UNIT_IN:
+ fprintf(stream, "in");
+ break;
+ case CSS_UNIT_CM:
+ fprintf(stream, "cm");
+ break;
+ case CSS_UNIT_MM:
+ fprintf(stream, "mm");
+ break;
+ case CSS_UNIT_PT:
+ fprintf(stream, "pt");
+ break;
+ case CSS_UNIT_PC:
+ fprintf(stream, "pc");
+ break;
+ case CSS_UNIT_PCT:
+ fprintf(stream, "%%");
+ break;
+ case CSS_UNIT_DEG:
+ fprintf(stream, "deg");
+ break;
+ case CSS_UNIT_GRAD:
+ fprintf(stream, "grad");
+ break;
+ case CSS_UNIT_RAD:
+ fprintf(stream, "rad");
+ break;
+ case CSS_UNIT_MS:
+ fprintf(stream, "ms");
+ break;
+ case CSS_UNIT_S:
+ fprintf(stream, "s");
+ break;
+ case CSS_UNIT_HZ:
+ fprintf(stream, "Hz");
+ break;
+ case CSS_UNIT_KHZ:
+ fprintf(stream, "kHz");
+ break;
+ }
+}
+
+/* exported interface documented in content/handlers/css/dump.h */
void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
{
uint8_t val;
@@ -74,7 +160,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
val = css_computed_background_image(style, &url);
if (val == CSS_BACKGROUND_IMAGE_IMAGE && url != NULL) {
fprintf(stream, "background-image: url('%.*s') ",
- (int) lwc_string_length(url),
+ (int) lwc_string_length(url),
lwc_string_data(url));
} else if (val == CSS_BACKGROUND_IMAGE_NONE) {
fprintf(stream, "background-image: none ");
@@ -1008,7 +1094,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
val = css_computed_list_style_image(style, &url);
if (url != NULL) {
fprintf(stream, "list-style-image: url('%.*s') ",
- (int) lwc_string_length(url),
+ (int) lwc_string_length(url),
lwc_string_data(url));
} else if (val == CSS_LIST_STYLE_IMAGE_NONE) {
fprintf(stream, "list-style-image: none ");
@@ -1705,102 +1791,3 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
fprintf(stream, "}");
}
-
-/******************************************************************************
- * Helper functions for nscss_dump_computed_style *
- ******************************************************************************/
-
-/**
- * Dump a fixed point value to the stream in a textual form.
- *
- * \param stream Stream to write to
- * \param f Value to write
- */
-void dump_css_fixed(FILE *stream, css_fixed f)
-{
-#define NSCSS_ABS(x) (uint32_t)((x) < 0 ? -(x) : (x))
- uint32_t uintpart = FIXTOINT(NSCSS_ABS(f));
- /* + 500 to ensure round to nearest (division will truncate) */
- uint32_t fracpart = ((NSCSS_ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10);
-#undef NSCSS_ABS
-
- fprintf(stream, "%s%d.%03d", f < 0 ? "-" : "", uintpart, fracpart);
-}
-
-/**
- * Dump a numeric value to the stream in a textual form.
- *
- * \param stream Stream to write to
- * \param val Value to write
- */
-void dump_css_number(FILE *stream, css_fixed val)
-{
- if (INTTOFIX(FIXTOINT(val)) == val)
- fprintf(stream, "%d", FIXTOINT(val));
- else
- dump_css_fixed(stream, val);
-}
-
-/**
- * Dump a dimension to the stream in a textual form.
- *
- * \param stream Stream to write to
- * \param val Value to write
- * \param unit Unit to write
- */
-void dump_css_unit(FILE *stream, css_fixed val, css_unit unit)
-{
- dump_css_number(stream, val);
-
- switch (unit) {
- case CSS_UNIT_PX:
- fprintf(stream, "px");
- break;
- case CSS_UNIT_EX:
- fprintf(stream, "ex");
- break;
- case CSS_UNIT_EM:
- fprintf(stream, "em");
- break;
- case CSS_UNIT_IN:
- fprintf(stream, "in");
- break;
- case CSS_UNIT_CM:
- fprintf(stream, "cm");
- break;
- case CSS_UNIT_MM:
- fprintf(stream, "mm");
- break;
- case CSS_UNIT_PT:
- fprintf(stream, "pt");
- break;
- case CSS_UNIT_PC:
- fprintf(stream, "pc");
- break;
- case CSS_UNIT_PCT:
- fprintf(stream, "%%");
- break;
- case CSS_UNIT_DEG:
- fprintf(stream, "deg");
- break;
- case CSS_UNIT_GRAD:
- fprintf(stream, "grad");
- break;
- case CSS_UNIT_RAD:
- fprintf(stream, "rad");
- break;
- case CSS_UNIT_MS:
- fprintf(stream, "ms");
- break;
- case CSS_UNIT_S:
- fprintf(stream, "s");
- break;
- case CSS_UNIT_HZ:
- fprintf(stream, "Hz");
- break;
- case CSS_UNIT_KHZ:
- fprintf(stream, "kHz");
- break;
- }
-}
-
diff --git a/css/dump.h b/content/handlers/css/dump.h
similarity index 84%
rename from css/dump.h
rename to content/handlers/css/dump.h
index 25d283e..470e564 100644
--- a/css/dump.h
+++ b/content/handlers/css/dump.h
@@ -19,8 +19,12 @@
#ifndef NETSURF_CSS_DUMP_H_
#define NETSURF_CSS_DUMP_H_
-#include "css/css.h"
-
+/**
+ * Dump a computed style \a style to the give file handle \a stream.
+ *
+ * \param stream Stream to write to
+ * \param style Computed style to dump
+ */
void nscss_dump_computed_style(FILE *stream, const css_computed_style *style);
#endif
diff --git a/css/hints.c b/content/handlers/css/hints.c
similarity index 98%
rename from css/hints.c
rename to content/handlers/css/hints.c
index 3561539..a962123 100644
--- a/css/hints.c
+++ b/content/handlers/css/hints.c
@@ -445,13 +445,7 @@ static bool parse_named_colour(const char *name, css_color *result)
return entry != NULL;
}
-/**
- * Parser for colours specified in attribute values.
- *
- * \param data Data to parse (NUL-terminated)
- * \param result Pointer to location to receive resulting css_color
- * \return true on success, false on invalid input
- */
+/* exported interface documented in content/handlers/css/hints.h */
bool nscss_parse_colour(const char *data, css_color *result)
{
size_t len = strlen(data);
@@ -512,7 +506,7 @@ bool nscss_parse_colour(const char *data, css_color *result)
* \param unit Pointer to location to receive unit
* \return True on success, false on failure
*/
-static bool parse_font_size(const char *size, uint8_t *val,
+static bool parse_font_size(const char *size, uint8_t *val,
css_fixed *len, css_unit *unit)
{
static const uint8_t size_map[] = {
@@ -564,7 +558,7 @@ static bool parse_font_size(const char *size, uint8_t *val,
if (value == 7) {
/* Manufacture xxx-large */
- *len = FDIV(FMUL(INTTOFIX(3), INTTOFIX(nsoption_int(font_size))),
+ *len = FDIV(FMUL(INTTOFIX(3), INTTOFIX(nsoption_int(font_size))),
F_10);
} else {
/* Len is irrelevant */
@@ -1503,6 +1497,22 @@ static void css_hint_bg_image(
}
}
+static void css_hint_white_space_nowrap(
+ nscss_select_ctx *ctx,
+ dom_node *node)
+{
+ struct css_hint *hint = &(hint_ctx.hints[hint_ctx.len]);
+ dom_exception err;
+ bool nowrap;
+
+ err = dom_element_has_attribute(node, corestring_dom_nowrap, &nowrap);
+ if (err == DOM_NO_ERR && nowrap == true) {
+ hint->prop = CSS_PROP_WHITE_SPACE;
+ hint->status = CSS_WHITE_SPACE_NOWRAP;
+ hint = css_hint_advance(hint);
+ }
+}
+
/* Exported function, documeted in css/hints.h */
css_error node_presentational_hint(void *pw, void *node,
@@ -1523,6 +1533,7 @@ css_error node_presentational_hint(void *pw, void *node,
case DOM_HTML_ELEMENT_TYPE_TD:
css_hint_width(pw, node);
css_hint_table_cell_border_padding(pw, node);
+ css_hint_white_space_nowrap(pw, node);
/* fallthrough */
case DOM_HTML_ELEMENT_TYPE_TR:
css_hint_height(pw, node);
@@ -1608,4 +1619,3 @@ css_error node_presentational_hint(void *pw, void *node,
return CSS_OK;
}
-
diff --git a/css/hints.h b/content/handlers/css/hints.h
similarity index 79%
rename from css/hints.h
rename to content/handlers/css/hints.h
index fda1bec..3d44d21 100644
--- a/css/hints.h
+++ b/content/handlers/css/hints.h
@@ -21,19 +21,18 @@
#include <stdint.h>
-#include "css/css.h"
+#include <libcss/libcss.h>
nserror css_hint_init(void);
void css_hint_fini(void);
-
/**
* Callback to retrieve presentational hints for a node
*
* \param[in] pw HTML document
* \param[in] node DOM node
- * \param[out] nhints number of hints retrived
- * \param[out] hints retrived hints
+ * \param[out] nhints number of hints retrieved
+ * \param[out] hints retrieved hints
* \return CSS_OK on success,
* CSS_PROPERTY_NOT_SET if there is no hint for the requested property,
* CSS_NOMEM on memory exhaustion.
@@ -44,6 +43,13 @@ css_error node_presentational_hint(
uint32_t *nhints,
css_hint **hints);
+/**
+ * Parser for colours specified in attribute values.
+ *
+ * \param data Data to parse (NUL-terminated)
+ * \param result Pointer to location to receive resulting css_color
+ * \return true on success, false on invalid input
+ */
bool nscss_parse_colour(const char *data, css_color *result);
#endif
diff --git a/css/internal.c b/content/handlers/css/internal.c
similarity index 80%
rename from css/internal.c
rename to content/handlers/css/internal.c
index 46c529b..14ad00c 100644
--- a/css/internal.c
+++ b/content/handlers/css/internal.c
@@ -17,23 +17,14 @@
*/
#include <string.h>
-
-#include "css/internal.h"
+#include <libcss/libcss.h>
#include "utils/nsurl.h"
-/**
- * URL resolution callback for libcss
- *
- * \param pw Resolution context
- * \param base Base URI
- * \param rel Relative URL
- * \param abs Pointer to location to receive resolved URL
- * \return CSS_OK on success,
- * CSS_NOMEM on memory exhaustion,
- * CSS_INVALID if resolution failed.
- */
-css_error nscss_resolve_url(void *pw, const char *base,
+#include "css/internal.h"
+
+/* exported interface documented in content/handlers/css/internal.h */
+css_error nscss_resolve_url(void *pw, const char *base,
lwc_string *rel, lwc_string **abs)
{
lwc_error lerror;
@@ -70,4 +61,3 @@ css_error nscss_resolve_url(void *pw, const char *base,
return CSS_OK;
}
-
diff --git a/css/internal.h b/content/handlers/css/internal.h
similarity index 65%
rename from css/internal.h
rename to content/handlers/css/internal.h
index 0344d6b..5c539c8 100644
--- a/css/internal.h
+++ b/content/handlers/css/internal.h
@@ -19,9 +19,17 @@
#ifndef NETSURF_CSS_INTERNAL_H_
#define NETSURF_CSS_INTERNAL_H_
-#include "css/css.h"
-
-css_error nscss_resolve_url(void *pw, const char *base,
- lwc_string *rel, lwc_string **abs);
+/**
+ * URL resolution callback for libcss
+ *
+ * \param pw Resolution context
+ * \param base Base URI
+ * \param rel Relative URL
+ * \param abs Pointer to location to receive resolved URL
+ * \return CSS_OK on success,
+ * CSS_NOMEM on memory exhaustion,
+ * CSS_INVALID if resolution failed.
+ */
+css_error nscss_resolve_url(void *pw, const char *base, lwc_string *rel, lwc_string **abs);
#endif
diff --git a/css/select.c b/content/handlers/css/select.c
similarity index 96%
rename from css/select.c
rename to content/handlers/css/select.c
index a929cf1..aaede77 100644
--- a/css/select.c
+++ b/content/handlers/css/select.c
@@ -20,11 +20,12 @@
#include <string.h>
#include <strings.h>
-#include "content/urldb.h"
-#include "desktop/system_colour.h"
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/log.h"
+#include "utils/nsurl.h"
+#include "netsurf/url_db.h"
+#include "desktop/system_colour.h"
#include "css/internal.h"
#include "css/hints.h"
@@ -252,6 +253,7 @@ static void nscss_dom_user_data_handler(dom_node_operation operation,
css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
uint64_t media, const css_stylesheet *inline_style)
{
+ css_computed_style *composed;
css_select_results *styles;
int pseudo_element;
css_error error;
@@ -265,7 +267,7 @@ css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
return NULL;
}
- /* If there's a parent style, compose with partial to obtain
+ /* If there's a parent style, compose with partial to obtain
* complete computed style for element */
if (ctx->parent_style != NULL) {
/* Complete the computed style, by composing with the parent
@@ -273,11 +275,16 @@ css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
error = css_computed_style_compose(ctx->parent_style,
styles->styles[CSS_PSEUDO_ELEMENT_NONE],
nscss_compute_font_size, NULL,
- styles->styles[CSS_PSEUDO_ELEMENT_NONE]);
+ &composed);
if (error != CSS_OK) {
css_select_results_destroy(styles);
return NULL;
}
+
+ /* Replace select_results style with composed style */
+ css_computed_style_destroy(
+ styles->styles[CSS_PSEUDO_ELEMENT_NONE]);
+ styles->styles[CSS_PSEUDO_ELEMENT_NONE] = composed;
}
for (pseudo_element = CSS_PSEUDO_ELEMENT_NONE + 1;
@@ -300,40 +307,20 @@ css_select_results *nscss_get_style(nscss_select_ctx *ctx, dom_node *n,
styles->styles[CSS_PSEUDO_ELEMENT_NONE],
styles->styles[pseudo_element],
nscss_compute_font_size, NULL,
- styles->styles[pseudo_element]);
+ &composed);
if (error != CSS_OK) {
/* TODO: perhaps this shouldn't be quite so
* catastrophic? */
css_select_results_destroy(styles);
return NULL;
}
- }
-
- return styles;
-}
-
-/**
- * Get an initial style
- *
- * \param ctx CSS selection context
- * \return Pointer to partial computed style, or NULL on failure
- */
-static css_computed_style *nscss_get_initial_style(nscss_select_ctx *ctx)
-{
- css_computed_style *style;
- css_error error;
- error = css_computed_style_create(&style);
- if (error != CSS_OK)
- return NULL;
-
- error = css_computed_style_initialise(style, &selection_handler, ctx);
- if (error != CSS_OK) {
- css_computed_style_destroy(style);
- return NULL;
+ /* Replace select_results style with composed style */
+ css_computed_style_destroy(styles->styles[pseudo_element]);
+ styles->styles[pseudo_element] = composed;
}
- return style;
+ return styles;
}
/**
@@ -346,21 +333,26 @@ static css_computed_style *nscss_get_initial_style(nscss_select_ctx *ctx)
css_computed_style *nscss_get_blank_style(nscss_select_ctx *ctx,
const css_computed_style *parent)
{
- css_computed_style *partial;
+ css_computed_style *partial, *composed;
css_error error;
- partial = nscss_get_initial_style(ctx);
- if (partial == NULL)
+ error = css_select_default_style(ctx->ctx,
+ &selection_handler, ctx, &partial);
+ if (error != CSS_OK) {
return NULL;
+ }
+ /* TODO: Do we really need to compose? Initial style shouldn't
+ * have any inherited properties. */
error = css_computed_style_compose(parent, partial,
- nscss_compute_font_size, NULL, partial);
+ nscss_compute_font_size, NULL, &composed);
+ css_computed_style_destroy(partial);
if (error != CSS_OK) {
- css_computed_style_destroy(partial);
+ css_computed_style_destroy(composed);
return NULL;
}
- return partial;
+ return composed;
}
/**
@@ -498,7 +490,7 @@ css_error node_name(void *pw, void *node, css_qname *qname)
* be allocated using the same allocator as used by libcss during style
* selection.
*/
-css_error node_classes(void *pw, void *node,
+css_error node_classes(void *pw, void *node,
lwc_string ***classes, uint32_t *n_classes)
{
dom_node *n = node;
@@ -697,7 +689,7 @@ css_error named_generic_sibling_node(void *pw, void *node,
return CSS_OK;
}
- if (dom_string_caseless_lwc_isequal(name,
+ if (dom_string_caseless_lwc_isequal(name,
qname->name)) {
dom_string_unref(name);
dom_node_unref(n);
@@ -844,7 +836,7 @@ css_error node_has_class(void *pw, void *node,
dom_node *n = node;
dom_exception err;
- /** \todo: Ensure that libdom performs case-insensitive
+ /** \todo: Ensure that libdom performs case-insensitive
* matching in quirks mode */
err = dom_element_has_class(n, name, match);
@@ -907,7 +899,7 @@ css_error node_has_attribute(void *pw, void *node,
dom_exception err;
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -953,7 +945,7 @@ css_error node_has_attribute_equal(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1005,7 +997,7 @@ css_error node_has_attribute_dashmatch(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1073,7 +1065,7 @@ css_error node_has_attribute_includes(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1141,7 +1133,7 @@ css_error node_has_attribute_prefix(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1163,7 +1155,7 @@ css_error node_has_attribute_prefix(void *pw, void *node,
const char *data = (const char *) dom_string_data(atr_val);
size_t len = dom_string_byte_length(atr_val);
- if ((len >= vlen) &&
+ if ((len >= vlen) &&
(strncasecmp(data, lwc_string_data(value), vlen) == 0)) {
*match = true;
}
@@ -1205,7 +1197,7 @@ css_error node_has_attribute_suffix(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1226,10 +1218,10 @@ css_error node_has_attribute_suffix(void *pw, void *node,
if (*match == false) {
const char *data = (const char *) dom_string_data(atr_val);
size_t len = dom_string_byte_length(atr_val);
-
+
const char *start = (char *) data + len - vlen;
- if ((len >= vlen) &&
+ if ((len >= vlen) &&
(strncasecmp(start, lwc_string_data(value), vlen) == 0)) {
*match = true;
}
@@ -1273,7 +1265,7 @@ css_error node_has_attribute_substring(void *pw, void *node,
}
err = dom_string_create_interned(
- (const uint8_t *) lwc_string_data(qname->name),
+ (const uint8_t *) lwc_string_data(qname->name),
lwc_string_length(qname->name), &name);
if (err != DOM_NO_ERR)
return CSS_NOMEM;
@@ -1299,7 +1291,7 @@ css_error node_has_attribute_substring(void *pw, void *node,
if (len >= vlen) {
while (start <= last_start) {
- if (strncasecmp(start, vdata,
+ if (strncasecmp(start, vdata,
vlen) == 0) {
*match = true;
break;
@@ -1348,38 +1340,38 @@ css_error node_is_root(void *pw, void *node, bool *match)
if (type != DOM_DOCUMENT_NODE) {
*match = false;
return CSS_OK;
- }
+ }
}
-
+
*match = true;
return CSS_OK;
}
-static int
-node_count_siblings_check(dom_node *node,
- bool check_name,
+static int
+node_count_siblings_check(dom_node *node,
+ bool check_name,
dom_string *name)
{
dom_node_type type;
int ret = 0;
dom_exception exc;
- if (node == NULL)
+ if (node == NULL)
return 0;
exc = dom_node_get_node_type(node, &type);
if ((exc != DOM_NO_ERR) || (type != DOM_ELEMENT_NODE)) {
return 0;
}
-
+
if (check_name) {
dom_string *node_name = NULL;
exc = dom_node_get_node_name(node, &node_name);
if ((exc == DOM_NO_ERR) && (node_name != NULL)) {
- if (dom_string_caseless_isequal(name,
+ if (dom_string_caseless_isequal(name,
node_name)) {
ret = 1;
}
@@ -1388,10 +1380,10 @@ node_count_siblings_check(dom_node *node,
} else {
ret = 1;
}
-
+
return ret;
}
-
+
/**
* Callback to count a node's siblings.
*
@@ -1418,16 +1410,16 @@ css_error node_count_siblings(void *pw, void *n, bool same_name,
return CSS_NOMEM;
}
}
-
+
if (after) {
dom_node *node = dom_node_ref(n);
dom_node *next;
-
+
do {
exc = dom_node_get_next_sibling(node, &next);
if ((exc != DOM_NO_ERR))
break;
-
+
dom_node_unref(node);
node = next;
@@ -1436,12 +1428,12 @@ css_error node_count_siblings(void *pw, void *n, bool same_name,
} else {
dom_node *node = dom_node_ref(n);
dom_node *next;
-
+
do {
exc = dom_node_get_previous_sibling(node, &next);
if ((exc != DOM_NO_ERR))
break;
-
+
dom_node_unref(node);
node = next;
@@ -1451,7 +1443,7 @@ css_error node_count_siblings(void *pw, void *n, bool same_name,
}
if (node_name != NULL) {
- dom_string_unref(node_name);
+ dom_string_unref(node_name);
}
*count = cnt;
@@ -1472,14 +1464,14 @@ css_error node_is_empty(void *pw, void *node, bool *match)
{
dom_node *n = node, *next;
dom_exception err;
-
+
*match = true;
-
+
err = dom_node_get_first_child(n, &n);
if (err != DOM_NO_ERR) {
return CSS_BADPARM;
}
-
+
while (n != NULL) {
dom_node_type ntype;
err = dom_node_get_node_type(n, &ntype);
@@ -1487,14 +1479,14 @@ css_error node_is_empty(void *pw, void *node, bool *match)
dom_node_unref(n);
return CSS_BADPARM;
}
-
+
if (ntype == DOM_ELEMENT_NODE ||
ntype == DOM_TEXT_NODE) {
*match = false;
dom_node_unref(n);
break;
}
-
+
err = dom_node_get_next_sibling(n, &next);
if (err != DOM_NO_ERR) {
dom_node_unref(n);
@@ -1503,7 +1495,7 @@ css_error node_is_empty(void *pw, void *node, bool *match)
dom_node_unref(n);
n = next;
}
-
+
return CSS_OK;
}
@@ -1531,7 +1523,7 @@ css_error node_is_link(void *pw, void *n, bool *match)
if (dom_string_caseless_lwc_isequal(node_name, corestring_lwc_a)) {
bool has_href;
exc = dom_element_has_attribute(node, corestring_dom_href,
- &has_href);
+ &has_href);
if ((exc == DOM_NO_ERR) && (has_href)) {
*match = true;
} else {
diff --git a/css/select.h b/content/handlers/css/select.h
similarity index 98%
rename from css/select.h
rename to content/handlers/css/select.h
index 0e0be95..abfb858 100644
--- a/css/select.h
+++ b/content/handlers/css/select.h
@@ -23,7 +23,7 @@
#include <dom/dom.h>
-#include "css/css.h"
+#include <libcss/libcss.h>
struct content;
struct nsurl;
@@ -52,6 +52,7 @@ css_computed_style *nscss_get_blank_style(nscss_select_ctx *ctx,
css_error named_ancestor_node(void *pw, void *node,
const css_qname *qname, void **ancestor);
+
css_error node_is_visited(void *pw, void *node, bool *match);
#endif
diff --git a/css/utils.c b/content/handlers/css/utils.c
similarity index 82%
rename from css/utils.c
rename to content/handlers/css/utils.c
index 9bf743c..5c7cbd9 100644
--- a/css/utils.c
+++ b/content/handlers/css/utils.c
@@ -19,21 +19,15 @@
#include <assert.h>
-#include "css/utils.h"
-
#include "utils/nsoption.h"
#include "utils/log.h"
+#include "css/utils.h"
+
/** Screen DPI in fixed point units: defaults to 90, which RISC OS uses */
css_fixed nscss_screen_dpi = F_90;
-/**
- * Convert an absolute CSS length to points.
- *
- * \param length Length to convert
- * \param unit Corresponding unit
- * \return length in points
- */
+/* exported interface documented in content/handlers/css/utils.h */
css_fixed nscss_len2pt(css_fixed length, css_unit unit)
{
/* Length must not be relative */
@@ -46,10 +40,10 @@ css_fixed nscss_len2pt(css_fixed length, css_unit unit)
/* 1in = 72pt */
case CSS_UNIT_IN: return FMUL(length, F_72);
/* 1in = 2.54cm => 1cm = (72/2.54)pt */
- case CSS_UNIT_CM: return FMUL(length,
+ case CSS_UNIT_CM: return FMUL(length,
FDIV(F_72, FLTTOFIX(2.54)));
/* 1in = 25.4mm => 1mm = (72/25.4)pt */
- case CSS_UNIT_MM: return FMUL(length,
+ case CSS_UNIT_MM: return FMUL(length,
FDIV(F_72, FLTTOFIX(25.4)));
case CSS_UNIT_PT: return length;
/* 1pc = 12pt */
@@ -61,16 +55,8 @@ css_fixed nscss_len2pt(css_fixed length, css_unit unit)
}
-/**
- * Convert a CSS length to pixels.
- *
- * \param length Length to convert
- * \param unit Corresponding unit
- * \param style Computed style applying to length. May be NULL if unit is
- * neither em nor ex
- * \return length in pixels
- */
-css_fixed nscss_len2px(css_fixed length, css_unit unit,
+/* exported interface documented in content/handlers/css/utils.h */
+css_fixed nscss_len2px(css_fixed length, css_unit unit,
const css_computed_style *style)
{
/* We assume the screen and any other output has the same dpi */
@@ -95,7 +81,7 @@ css_fixed nscss_len2px(css_fixed length, css_unit unit,
font_size = FDIV(INTTOFIX(nsoption_int(font_min_size)), F_10);
}
- /* Convert to pixels (manually, to maximise precision)
+ /* Convert to pixels (manually, to maximise precision)
* 1in = 72pt => 1pt = (DPI/72)px */
px_per_unit = FDIV(FMUL(font_size, nscss_screen_dpi), F_72);
@@ -104,27 +90,27 @@ css_fixed nscss_len2px(css_fixed length, css_unit unit,
px_per_unit = FMUL(px_per_unit, FLTTOFIX(0.6));
}
break;
- case CSS_UNIT_PX:
+ case CSS_UNIT_PX:
px_per_unit = F_1;
break;
/* 1in = DPIpx */
- case CSS_UNIT_IN:
+ case CSS_UNIT_IN:
px_per_unit = nscss_screen_dpi;
break;
/* 1in = 2.54cm => 1cm = (DPI/2.54)px */
- case CSS_UNIT_CM:
+ case CSS_UNIT_CM:
px_per_unit = FDIV(nscss_screen_dpi, FLTTOFIX(2.54));
break;
/* 1in = 25.4mm => 1mm = (DPI/25.4)px */
- case CSS_UNIT_MM:
+ case CSS_UNIT_MM:
px_per_unit = FDIV(nscss_screen_dpi, FLTTOFIX(25.4));
break;
/* 1in = 72pt => 1pt = (DPI/72)px */
- case CSS_UNIT_PT:
+ case CSS_UNIT_PT:
px_per_unit = FDIV(nscss_screen_dpi, F_72);
break;
/* 1pc = 12pt => 1in = 6pc => 1pc = (DPI/6)px */
- case CSS_UNIT_PC:
+ case CSS_UNIT_PC:
px_per_unit = FDIV(nscss_screen_dpi, INTTOFIX(6));
break;
default:
@@ -139,4 +125,3 @@ css_fixed nscss_len2px(css_fixed length, css_unit unit,
/* Calculate total number of pixels */
return FMUL(length, TRUNCATEFIX(px_per_unit));
}
-
diff --git a/css/css.h b/content/handlers/css/utils.h
similarity index 51%
rename from css/css.h
rename to content/handlers/css/utils.h
index be8d4bc..58a5ea6 100644
--- a/css/css.h
+++ b/content/handlers/css/utils.h
@@ -16,29 +16,34 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef netsurf_css_css_h_
-#define netsurf_css_css_h_
-
-#include <stdint.h>
+#ifndef NETSURF_CSS_UTILS_H_
+#define NETSURF_CSS_UTILS_H_
#include <libcss/libcss.h>
-#include "utils/errors.h"
+#include "netsurf/css.h"
-struct hlcache_handle;
+/** DPI of the screen, in fixed point units */
+extern css_fixed nscss_screen_dpi;
/**
- * Imported stylesheet record
+ * Convert an absolute CSS length to points.
+ *
+ * \param[in] length Absolute CSS length.
+ * \param[in] unit Unit of the length.
+ * \return length in points
*/
-struct nscss_import {
- struct hlcache_handle *c; /**< Content containing sheet */
- uint64_t media; /**< Media types that sheet applies to */
-};
+css_fixed nscss_len2pt(css_fixed length, css_unit unit);
-nserror nscss_init(void);
-
-css_stylesheet *nscss_get_stylesheet(struct hlcache_handle *h);
-struct nscss_import *nscss_get_imports(struct hlcache_handle *h, uint32_t *n);
+/**
+ * Convert a CSS length to pixels.
+ *
+ * \param length Length to convert
+ * \param unit Corresponding unit
+ * \param style Computed style applying to length. May be NULL if unit is
+ * neither em nor ex
+ * \return length in pixels
+ */
+css_fixed nscss_len2px(css_fixed length, css_unit unit, const css_computed_style *style);
#endif
-
diff --git a/image/Makefile b/content/handlers/image/Makefile
similarity index 90%
rename from image/Makefile
rename to content/handlers/image/Makefile
index 5851a1c..541cd2c 100644
--- a/image/Makefile
+++ b/content/handlers/image/Makefile
@@ -12,4 +12,4 @@ S_IMAGE_$(NETSURF_USE_NSSVG) += svg.c
S_IMAGE_$(NETSURF_USE_RSVG) += rsvg.c
S_IMAGE_$(NETSURF_USE_VIDEO) += video.c
-S_IMAGE := $(addprefix image/,$(S_IMAGE_YES))
+S_IMAGE := $(S_IMAGE_YES)
diff --git a/image/bmp.c b/content/handlers/image/bmp.c
similarity index 94%
rename from image/bmp.c
rename to content/handlers/image/bmp.c
index 2468b4d..5970f8b 100644
--- a/image/bmp.c
+++ b/content/handlers/image/bmp.c
@@ -28,11 +28,13 @@
#include "utils/utils.h"
#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
#include "desktop/gui_internal.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
#include "image/bmp.h"
/** bmp context. */
@@ -164,7 +166,6 @@ static bool nsbmp_convert(struct content *c)
/* exit as a success */
bmp->bitmap = bmp->bmp->bitmap;
- guit->bitmap->modified(bmp->bitmap);
content_set_ready(c);
content_set_done(c);
@@ -180,11 +181,18 @@ static bool nsbmp_redraw(struct content *c, struct content_redraw_data *data,
nsbmp_content *bmp = (nsbmp_content *) c;
bitmap_flags_t flags = BITMAPF_NONE;
- if (bmp->bmp->decoded == false)
- if (bmp_decode(bmp->bmp) != BMP_OK)
+ if (bmp->bmp->decoded == false) {
+ bmp_result res;
+ res = bmp_decode(bmp->bmp);
+ /* allow short or incomplete image data giving a partial image*/
+ if ((res != BMP_OK) &&
+ (res != BMP_INSUFFICIENT_DATA) &&
+ (res != BMP_DATA_ERROR)) {
return false;
+ }
- bmp->bitmap = bmp->bmp->bitmap;
+ guit->bitmap->modified(bmp->bitmap);
+ }
if (data->repeat_x)
flags |= BITMAPF_REPEAT_X;
diff --git a/image/bmp.h b/content/handlers/image/bmp.h
similarity index 100%
rename from image/bmp.h
rename to content/handlers/image/bmp.h
diff --git a/image/gif.c b/content/handlers/image/gif.c
similarity index 99%
rename from image/gif.c
rename to content/handlers/image/gif.c
index 878a42a..c4f0394 100644
--- a/image/gif.c
+++ b/content/handlers/image/gif.c
@@ -39,12 +39,14 @@
#include "utils/utils.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
+#include "netsurf/misc.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
-#include "desktop/gui_misc.h"
#include "desktop/gui_internal.h"
#include "image/image.h"
-#include "image/bitmap.h"
#include "image/gif.h"
typedef struct nsgif_content {
diff --git a/image/gif.h b/content/handlers/image/gif.h
similarity index 100%
rename from image/gif.h
rename to content/handlers/image/gif.h
diff --git a/image/ico.c b/content/handlers/image/ico.c
similarity index 98%
rename from image/ico.c
rename to content/handlers/image/ico.c
index 5f453bc..b14ea7f 100644
--- a/image/ico.c
+++ b/content/handlers/image/ico.c
@@ -27,11 +27,13 @@
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
#include "desktop/gui_internal.h"
#include "image/image.h"
-#include "image/bitmap.h"
#include "image/ico.h"
typedef struct nsico_content {
diff --git a/image/ico.h b/content/handlers/image/ico.h
similarity index 100%
rename from image/ico.h
rename to content/handlers/image/ico.h
diff --git a/image/image.c b/content/handlers/image/image.c
similarity index 97%
rename from image/image.c
rename to content/handlers/image/image.c
index b9bcf1e..e7cc921 100644
--- a/image/image.c
+++ b/content/handlers/image/image.c
@@ -22,11 +22,11 @@
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "content/content.h"
-#include "desktop/plotters.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
#include "desktop/gui_internal.h"
-#include "image/bitmap.h"
#include "image/bmp.h"
#include "image/gif.h"
#include "image/ico.h"
diff --git a/image/image.h b/content/handlers/image/image.h
similarity index 97%
rename from image/image.h
rename to content/handlers/image/image.h
index eb94825..dac586c 100644
--- a/image/image.h
+++ b/content/handlers/image/image.h
@@ -25,6 +25,8 @@
#include "utils/errors.h"
+struct content_redraw_data;
+
/** Initialise the content handlers for image types.
*/
nserror image_init(void);
diff --git a/image/image_cache.c b/content/handlers/image/image_cache.c
similarity index 90%
rename from image/image_cache.c
rename to content/handlers/image/image_cache.c
index 9f217f8..9c7ce22 100644
--- a/image/image_cache.c
+++ b/content/handlers/image/image_cache.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Cache implementation for bitmap images decoded into frontend format.
+ */
+
#include <assert.h>
#include <inttypes.h>
#include <stdint.h>
@@ -25,30 +30,35 @@
#include "utils/utils.h"
#include "utils/log.h"
+#include "netsurf/misc.h"
+#include "netsurf/bitmap.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
-#include "desktop/gui_misc.h"
#include "desktop/gui_internal.h"
-#include "image/bitmap.h"
#include "image/image_cache.h"
#include "image/image.h"
-/** Age of an entry within the cache
+/**
+ * Age of an entry within the cache
*
* type deffed away so it can be readily changed later perhaps to a
* wallclock time structure.
*/
typedef unsigned int cache_age;
-/** Image cache entry
+/**
+ * Image cache entry
*/
struct image_cache_entry_s {
- struct image_cache_entry_s *next; /* next cache entry in list */
- struct image_cache_entry_s *prev; /* previous cache entry in list */
-
- struct content *content; /** content is used as a key */
- struct bitmap *bitmap; /** associated bitmap entry */
- /** Conversion routine */
+ struct image_cache_entry_s *next; /**< next cache entry in list */
+ struct image_cache_entry_s *prev; /**< previous cache entry in list */
+
+ /** content is used as a key */
+ struct content *content;
+ /** associated bitmap entry */
+ struct bitmap *bitmap;
+ /** routine to convert content into bitmap */
image_cache_convert_fn *convert;
/* Statistics for replacement algorithm */
@@ -61,7 +71,8 @@ struct image_cache_entry_s {
int conversion_count; /**< Number of times image has been converted */
};
-/** Current state of the cache.
+/**
+ * Current state of the cache.
*
* Global state of the cache. entries "age" is determined based on a
* monotonically incrementing operation count. This avoids issues with
@@ -89,12 +100,12 @@ struct image_cache_s {
/** Maximum size of bitmaps allocated at any one time */
size_t max_bitmap_size;
- /** The number of objects when maximum bitmap usage occoured */
+ /** The number of objects when maximum bitmap usage occurred */
int max_bitmap_size_count;
/** Maximum count of bitmaps allocated at any one time */
int max_bitmap_count;
- /** The size of the bitmaps when the max count occoured */
+ /** The size of the bitmaps when the max count occurred */
size_t max_bitmap_count_size;
/** Bitmap was not available at plot time required conversion */
@@ -129,7 +140,11 @@ struct image_cache_s {
static struct image_cache_s *image_cache = NULL;
-/** Find the nth cache entry
+/**
+ * Find a cache entry by index.
+ *
+ * \param entryn index of cache entry
+ * \return cache entry at index or NULL if not found.
*/
static struct image_cache_entry_s *image_cache__findn(int entryn)
{
@@ -143,7 +158,12 @@ static struct image_cache_entry_s *image_cache__findn(int entryn)
return found;
}
-/** Find the cache entry for a content
+
+/**
+ * Find the cache entry for a content
+ *
+ * \param c The content to get an entry for
+ * \return The image cache entry or NULL if not found.
*/
static struct image_cache_entry_s *image_cache__find(const struct content *c)
{
@@ -156,6 +176,11 @@ static struct image_cache_entry_s *image_cache__find(const struct content *c)
return found;
}
+/**
+ * Update the image cache statistics with an entry.
+ *
+ * \param centry The image cache entry to update the stats with.
+ */
static void image_cache_stats_bitmap_add(struct image_cache_entry_s *centry)
{
centry->bitmap_age = image_cache->current_age;
@@ -222,11 +247,20 @@ static void image_cache__unlink(struct image_cache_entry_s *centry)
}
}
+/**
+ * free bitmap from an image cache entry
+ *
+ * \param centry The image cache entry to free bitmap from.
+ */
static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
{
if (centry->bitmap != NULL) {
#ifdef IMAGE_CACHE_VERBOSE
- LOG("Freeing bitmap %p size %d age %d redraw count %d", centry->bitmap, centry->bitmap_size, image_cache->current_age - centry->bitmap_age, centry->redraw_count);
+ LOG("Freeing bitmap %p size %d age %d redraw count %d",
+ centry->bitmap,
+ centry->bitmap_size,
+ image_cache->current_age - centry->bitmap_age,
+ centry->redraw_count);
#endif
guit->bitmap->destroy(centry->bitmap);
centry->bitmap = NULL;
@@ -239,7 +273,11 @@ static void image_cache__free_bitmap(struct image_cache_entry_s *centry)
}
-/* free cache entry */
+/**
+ * free image cache entry
+ *
+ * \param centry The image cache entry to free.
+ */
static void image_cache__free_entry(struct image_cache_entry_s *centry)
{
#ifdef IMAGE_CACHE_VERBOSE
@@ -257,7 +295,11 @@ static void image_cache__free_entry(struct image_cache_entry_s *centry)
free(centry);
}
-/** Cache cleaner */
+/**
+ * Image cache cleaner
+ *
+ * \param icache The image cache context.
+ */
static void image_cache__clean(struct image_cache_s *icache)
{
struct image_cache_entry_s *centry = icache->entries;
@@ -276,7 +318,11 @@ static void image_cache__clean(struct image_cache_s *icache)
}
}
-/** Cache background scheduled callback. */
+/**
+ * Cache background scheduled callback.
+ *
+ * \param p The image cache context.
+ */
static void image_cache__background_update(void *p)
{
struct image_cache_s *icache = p;
@@ -376,7 +422,7 @@ image_cache_init(const struct image_cache_parameters *image_cache_parameters)
image_cache__background_update,
image_cache);
- LOG("Image cache initilised with a limit of %" PRIsizet " hysteresis of %"PRIsizet,
+ LOG("Image cache initialised with a limit of %" PRIsizet " hysteresis of %"PRIsizet,
image_cache->params.limit, image_cache->params.hysteresis);
return NSERROR_OK;
@@ -677,7 +723,7 @@ int image_cache_snentryf(char *string, size_t size, unsigned int entryn,
case 'U':
slen += snprintf(string + slen, size - slen,
- "%s", nsurl_access(llcache_handle_get_url(centry->content->llcache)));
+ "%s", nsurl_access(llcache_handle_get_url(centry->content->llcache)));
break;
case 'o':
@@ -689,20 +735,20 @@ int image_cache_snentryf(char *string, size_t size, unsigned int entryn,
centry->content->
llcache),
NSURL_HOST);
-
+
slen += snprintf(string + slen,
size - slen, "%s",
- lwc_string_data(
- origin));
+ lwc_string_data(
+ origin));
lwc_string_unref(origin);
} else {
slen += snprintf(string + slen,
size - slen, "%s",
- "localhost");
+ "localhost");
}
break;
-
+
case 's':
if (centry->bitmap != NULL) {
slen += snprintf(string + slen,
@@ -773,6 +819,7 @@ bool image_cache_redraw(struct content *c,
return image_bitmap_plot(centry->bitmap, data, clip, ctx);
}
+/* exported interface documented in image_cache.h */
void image_cache_destroy(struct content *content)
{
struct image_cache_entry_s *centry;
@@ -786,11 +833,13 @@ void image_cache_destroy(struct content *content)
}
}
+/* exported interface documented in image_cache.h */
void *image_cache_get_internal(const struct content *c, void *context)
{
return image_cache_get_bitmap(c);
}
+/* exported interface documented in image_cache.h */
content_type image_cache_content_type(void)
{
return CONTENT_IMAGE;
diff --git a/image/image_cache.h b/content/handlers/image/image_cache.h
similarity index 99%
rename from image/image_cache.h
rename to content/handlers/image/image_cache.h
index 2f1a5ca..d57a3a9 100644
--- a/image/image_cache.h
+++ b/content/handlers/image/image_cache.h
@@ -38,6 +38,7 @@
#define NETSURF_IMAGE_IMAGE_CACHE_H_
#include "utils/errors.h"
+#include "netsurf/content_type.h"
struct content_redraw_data;
struct redraw_context;
diff --git a/image/jpeg.c b/content/handlers/image/jpeg.c
similarity index 99%
rename from image/jpeg.c
rename to content/handlers/image/jpeg.c
index cf265b4..5ae9e70 100644
--- a/image/jpeg.c
+++ b/content/handlers/image/jpeg.c
@@ -30,15 +30,16 @@
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "netsurf/bitmap.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
#include "desktop/gui_internal.h"
#include "image/image_cache.h"
-#include "image/bitmap.h"
#define JPEG_INTERNAL_OPTIONS
#include "jpeglib.h"
-#include "image/jpeg.h"
+#include "jpeg.h"
/** absolute minimum size of a jpeg below which it is not even worth
* trying to read header data
@@ -201,8 +202,8 @@ jpeg_cache_convert(struct content *c)
return bitmap;
}
- jpeg_create_decompress(&cinfo);
cinfo.client_data = &setjmp_buffer;
+ jpeg_create_decompress(&cinfo);
/* setup data source */
source_mgr.next_input_byte = source_data;
@@ -304,8 +305,8 @@ static bool nsjpeg_convert(struct content *c)
return false;
}
- jpeg_create_decompress(&cinfo);
cinfo.client_data = &setjmp_buffer;
+ jpeg_create_decompress(&cinfo);
source_mgr.next_input_byte = (unsigned char *) data;
source_mgr.bytes_in_buffer = size;
cinfo.src = &source_mgr;
diff --git a/image/jpeg.h b/content/handlers/image/jpeg.h
similarity index 100%
rename from image/jpeg.h
rename to content/handlers/image/jpeg.h
diff --git a/image/nssprite.c b/content/handlers/image/nssprite.c
similarity index 97%
rename from image/nssprite.c
rename to content/handlers/image/nssprite.c
index 0fe2527..c902fc3 100644
--- a/image/nssprite.c
+++ b/content/handlers/image/nssprite.c
@@ -28,11 +28,13 @@
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
#include "desktop/gui_internal.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
#include "image/nssprite.h"
typedef struct nssprite_content {
@@ -62,7 +64,7 @@ typedef struct nssprite_content {
static nserror nssprite_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
+ struct llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
{
nssprite_content *sprite;
diff --git a/image/nssprite.h b/content/handlers/image/nssprite.h
similarity index 100%
rename from image/nssprite.h
rename to content/handlers/image/nssprite.h
diff --git a/image/png.c b/content/handlers/image/png.c
similarity index 98%
rename from image/png.c
rename to content/handlers/image/png.c
index 11903cb..93185c1 100644
--- a/image/png.c
+++ b/content/handlers/image/png.c
@@ -25,11 +25,12 @@
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
+#include "netsurf/bitmap.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
#include "desktop/gui_internal.h"
#include "image/image_cache.h"
-#include "image/bitmap.h"
#include "image/png.h"
/* accommodate for old versions of libpng (beware security holes!) */
@@ -277,10 +278,14 @@ static nserror nspng_create_png_data(nspng_content *png_c)
return NSERROR_OK;
}
-static nserror nspng_create(const content_handler *handler,
- lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
- bool quirks, struct content **c)
+static nserror
+nspng_create(const content_handler *handler,
+ lwc_string *imime_type,
+ const struct http_parameter *params,
+ struct llcache_handle *llcache,
+ const char *fallback_charset,
+ bool quirks,
+ struct content **c)
{
nspng_content *png_c;
nserror error;
diff --git a/image/png.h b/content/handlers/image/png.h
similarity index 100%
rename from image/png.h
rename to content/handlers/image/png.h
diff --git a/image/rsvg.c b/content/handlers/image/rsvg.c
similarity index 98%
rename from image/rsvg.c
rename to content/handlers/image/rsvg.c
index b781125..1bf4b44 100644
--- a/image/rsvg.c
+++ b/content/handlers/image/rsvg.c
@@ -41,11 +41,13 @@
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
-#include "desktop/plotters.h"
#include "desktop/gui_internal.h"
-#include "image/bitmap.h"
#include "image/rsvg.h"
typedef struct rsvg_content {
diff --git a/image/rsvg.h b/content/handlers/image/rsvg.h
similarity index 100%
rename from image/rsvg.h
rename to content/handlers/image/rsvg.h
diff --git a/image/svg.c b/content/handlers/image/svg.c
similarity index 98%
rename from image/svg.c
rename to content/handlers/image/svg.c
index 63cdb3b..94c4858 100644
--- a/image/svg.c
+++ b/content/handlers/image/svg.c
@@ -23,14 +23,15 @@
#include <assert.h>
#include <limits.h>
#include <string.h>
+#include <stdlib.h>
#include <svgtiny.h>
#include "utils/messages.h"
#include "utils/utils.h"
+#include "netsurf/plotters.h"
+#include "netsurf/content.h"
#include "content/content_protected.h"
-#include "css/css.h"
-#include "desktop/plotters.h"
#include "image/svg.h"
@@ -71,7 +72,7 @@ no_memory:
static nserror svg_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
+ struct llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
{
svg_content *svg;
diff --git a/image/svg.h b/content/handlers/image/svg.h
similarity index 100%
rename from image/svg.h
rename to content/handlers/image/svg.h
diff --git a/image/video.c b/content/handlers/image/video.c
similarity index 99%
rename from image/video.c
rename to content/handlers/image/video.c
index 1cbbeeb..707d39d 100644
--- a/image/video.c
+++ b/content/handlers/image/video.c
@@ -20,6 +20,7 @@
#include "content/content_factory.h"
#include "content/content_protected.h"
+
#include "image/video.h"
typedef struct nsvideo_content {
diff --git a/image/video.h b/content/handlers/image/video.h
similarity index 100%
rename from image/video.h
rename to content/handlers/image/video.h
diff --git a/content/handlers/javascript/Makefile b/content/handlers/javascript/Makefile
new file mode 100644
index 0000000..5cd0fc3
--- /dev/null
+++ b/content/handlers/javascript/Makefile
@@ -0,0 +1,18 @@
+#
+# NetSurf javascript source file inclusion
+#
+# Included by Makefile
+#
+
+S_JAVASCRIPT_BINDING:=
+
+ifeq ($(NETSURF_USE_DUKTAPE),YES)
+# Duktape
+include content/handlers/javascript/duktape/Makefile
+else
+# None
+include content/handlers/javascript/none/Makefile
+endif
+
+# Fetcher for javascript scheme is always required
+S_JAVASCRIPT += fetcher.c
diff --git a/javascript/WebIDL/Makefile b/content/handlers/javascript/WebIDL/Makefile
similarity index 100%
rename from javascript/WebIDL/Makefile
rename to content/handlers/javascript/WebIDL/Makefile
diff --git a/javascript/WebIDL/console.idl b/content/handlers/javascript/WebIDL/console.idl
similarity index 100%
rename from javascript/WebIDL/console.idl
rename to content/handlers/javascript/WebIDL/console.idl
diff --git a/javascript/WebIDL/cssom.idl b/content/handlers/javascript/WebIDL/cssom.idl
similarity index 100%
rename from javascript/WebIDL/cssom.idl
rename to content/handlers/javascript/WebIDL/cssom.idl
diff --git a/javascript/WebIDL/dom-parsing.idl b/content/handlers/javascript/WebIDL/dom-parsing.idl
similarity index 100%
rename from javascript/WebIDL/dom-parsing.idl
rename to content/handlers/javascript/WebIDL/dom-parsing.idl
diff --git a/javascript/WebIDL/dom.idl b/content/handlers/javascript/WebIDL/dom.idl
similarity index 100%
rename from javascript/WebIDL/dom.idl
rename to content/handlers/javascript/WebIDL/dom.idl
diff --git a/javascript/WebIDL/html.idl b/content/handlers/javascript/WebIDL/html.idl
similarity index 100%
rename from javascript/WebIDL/html.idl
rename to content/handlers/javascript/WebIDL/html.idl
diff --git a/javascript/WebIDL/uievents.idl b/content/handlers/javascript/WebIDL/uievents.idl
similarity index 100%
rename from javascript/WebIDL/uievents.idl
rename to content/handlers/javascript/WebIDL/uievents.idl
diff --git a/javascript/WebIDL/urlutils.idl b/content/handlers/javascript/WebIDL/urlutils.idl
similarity index 100%
rename from javascript/WebIDL/urlutils.idl
rename to content/handlers/javascript/WebIDL/urlutils.idl
diff --git a/javascript/content.c b/content/handlers/javascript/content.c
similarity index 100%
rename from javascript/content.c
rename to content/handlers/javascript/content.c
diff --git a/javascript/content.h b/content/handlers/javascript/content.h
similarity index 100%
rename from javascript/content.h
rename to content/handlers/javascript/content.h
diff --git a/javascript/duktape/Console.bnd b/content/handlers/javascript/duktape/Console.bnd
similarity index 100%
rename from javascript/duktape/Console.bnd
rename to content/handlers/javascript/duktape/Console.bnd
diff --git a/javascript/duktape/Document.bnd b/content/handlers/javascript/duktape/Document.bnd
similarity index 99%
rename from javascript/duktape/Document.bnd
rename to content/handlers/javascript/duktape/Document.bnd
index e15f75f..8658aec 100644
--- a/javascript/duktape/Document.bnd
+++ b/content/handlers/javascript/duktape/Document.bnd
@@ -13,7 +13,7 @@ prologue Document()
#include "utils/corestrings.h"
#include "utils/libdom.h"
#include "utils/utils.h"
-
+#include "content/hlcache.h"
#include "render/html_internal.h"
#include "content/urldb.h"
diff --git a/javascript/duktape/Element.bnd b/content/handlers/javascript/duktape/Element.bnd
similarity index 100%
rename from javascript/duktape/Element.bnd
rename to content/handlers/javascript/duktape/Element.bnd
diff --git a/javascript/duktape/Event.bnd b/content/handlers/javascript/duktape/Event.bnd
similarity index 100%
rename from javascript/duktape/Event.bnd
rename to content/handlers/javascript/duktape/Event.bnd
diff --git a/javascript/duktape/HTMLAnchorElement.bnd b/content/handlers/javascript/duktape/HTMLAnchorElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLAnchorElement.bnd
rename to content/handlers/javascript/duktape/HTMLAnchorElement.bnd
diff --git a/javascript/duktape/HTMLAppletElement.bnd b/content/handlers/javascript/duktape/HTMLAppletElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLAppletElement.bnd
rename to content/handlers/javascript/duktape/HTMLAppletElement.bnd
diff --git a/javascript/duktape/HTMLAreaElement.bnd b/content/handlers/javascript/duktape/HTMLAreaElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLAreaElement.bnd
rename to content/handlers/javascript/duktape/HTMLAreaElement.bnd
diff --git a/javascript/duktape/HTMLBRElement.bnd b/content/handlers/javascript/duktape/HTMLBRElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLBRElement.bnd
rename to content/handlers/javascript/duktape/HTMLBRElement.bnd
diff --git a/javascript/duktape/HTMLBaseElement.bnd b/content/handlers/javascript/duktape/HTMLBaseElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLBaseElement.bnd
rename to content/handlers/javascript/duktape/HTMLBaseElement.bnd
diff --git a/javascript/duktape/HTMLBodyElement.bnd b/content/handlers/javascript/duktape/HTMLBodyElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLBodyElement.bnd
rename to content/handlers/javascript/duktape/HTMLBodyElement.bnd
diff --git a/javascript/duktape/HTMLButtonElement.bnd b/content/handlers/javascript/duktape/HTMLButtonElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLButtonElement.bnd
rename to content/handlers/javascript/duktape/HTMLButtonElement.bnd
diff --git a/javascript/duktape/HTMLCollection.bnd b/content/handlers/javascript/duktape/HTMLCollection.bnd
similarity index 100%
rename from javascript/duktape/HTMLCollection.bnd
rename to content/handlers/javascript/duktape/HTMLCollection.bnd
diff --git a/javascript/duktape/HTMLDivElement.bnd b/content/handlers/javascript/duktape/HTMLDivElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLDivElement.bnd
rename to content/handlers/javascript/duktape/HTMLDivElement.bnd
diff --git a/javascript/duktape/HTMLElement.bnd b/content/handlers/javascript/duktape/HTMLElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLElement.bnd
rename to content/handlers/javascript/duktape/HTMLElement.bnd
diff --git a/javascript/duktape/HTMLFontElement.bnd b/content/handlers/javascript/duktape/HTMLFontElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLFontElement.bnd
rename to content/handlers/javascript/duktape/HTMLFontElement.bnd
diff --git a/javascript/duktape/HTMLFormElement.bnd b/content/handlers/javascript/duktape/HTMLFormElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLFormElement.bnd
rename to content/handlers/javascript/duktape/HTMLFormElement.bnd
diff --git a/javascript/duktape/HTMLFrameElement.bnd b/content/handlers/javascript/duktape/HTMLFrameElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLFrameElement.bnd
rename to content/handlers/javascript/duktape/HTMLFrameElement.bnd
diff --git a/javascript/duktape/HTMLFrameSetElement.bnd b/content/handlers/javascript/duktape/HTMLFrameSetElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLFrameSetElement.bnd
rename to content/handlers/javascript/duktape/HTMLFrameSetElement.bnd
diff --git a/javascript/duktape/HTMLHRElement.bnd b/content/handlers/javascript/duktape/HTMLHRElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLHRElement.bnd
rename to content/handlers/javascript/duktape/HTMLHRElement.bnd
diff --git a/javascript/duktape/HTMLHTMLElement.bnd b/content/handlers/javascript/duktape/HTMLHTMLElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLHTMLElement.bnd
rename to content/handlers/javascript/duktape/HTMLHTMLElement.bnd
diff --git a/javascript/duktape/HTMLHeadingElement.bnd b/content/handlers/javascript/duktape/HTMLHeadingElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLHeadingElement.bnd
rename to content/handlers/javascript/duktape/HTMLHeadingElement.bnd
diff --git a/javascript/duktape/HTMLIFrameElement.bnd b/content/handlers/javascript/duktape/HTMLIFrameElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLIFrameElement.bnd
rename to content/handlers/javascript/duktape/HTMLIFrameElement.bnd
diff --git a/javascript/duktape/HTMLImageElement.bnd b/content/handlers/javascript/duktape/HTMLImageElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLImageElement.bnd
rename to content/handlers/javascript/duktape/HTMLImageElement.bnd
diff --git a/javascript/duktape/HTMLInputElement.bnd b/content/handlers/javascript/duktape/HTMLInputElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLInputElement.bnd
rename to content/handlers/javascript/duktape/HTMLInputElement.bnd
diff --git a/javascript/duktape/HTMLLIElement.bnd b/content/handlers/javascript/duktape/HTMLLIElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLLIElement.bnd
rename to content/handlers/javascript/duktape/HTMLLIElement.bnd
diff --git a/javascript/duktape/HTMLLabelElement.bnd b/content/handlers/javascript/duktape/HTMLLabelElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLLabelElement.bnd
rename to content/handlers/javascript/duktape/HTMLLabelElement.bnd
diff --git a/javascript/duktape/HTMLLegendElement.bnd b/content/handlers/javascript/duktape/HTMLLegendElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLLegendElement.bnd
rename to content/handlers/javascript/duktape/HTMLLegendElement.bnd
diff --git a/javascript/duktape/HTMLLinkElement.bnd b/content/handlers/javascript/duktape/HTMLLinkElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLLinkElement.bnd
rename to content/handlers/javascript/duktape/HTMLLinkElement.bnd
diff --git a/javascript/duktape/HTMLMapElement.bnd b/content/handlers/javascript/duktape/HTMLMapElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLMapElement.bnd
rename to content/handlers/javascript/duktape/HTMLMapElement.bnd
diff --git a/javascript/duktape/HTMLMarqueeElement.bnd b/content/handlers/javascript/duktape/HTMLMarqueeElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLMarqueeElement.bnd
rename to content/handlers/javascript/duktape/HTMLMarqueeElement.bnd
diff --git a/javascript/duktape/HTMLMenuElement.bnd b/content/handlers/javascript/duktape/HTMLMenuElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLMenuElement.bnd
rename to content/handlers/javascript/duktape/HTMLMenuElement.bnd
diff --git a/javascript/duktape/HTMLMetaElement.bnd b/content/handlers/javascript/duktape/HTMLMetaElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLMetaElement.bnd
rename to content/handlers/javascript/duktape/HTMLMetaElement.bnd
diff --git a/javascript/duktape/HTMLOListElement.bnd b/content/handlers/javascript/duktape/HTMLOListElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLOListElement.bnd
rename to content/handlers/javascript/duktape/HTMLOListElement.bnd
diff --git a/javascript/duktape/HTMLObjectElement.bnd b/content/handlers/javascript/duktape/HTMLObjectElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLObjectElement.bnd
rename to content/handlers/javascript/duktape/HTMLObjectElement.bnd
diff --git a/javascript/duktape/HTMLOptionElement.bnd b/content/handlers/javascript/duktape/HTMLOptionElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLOptionElement.bnd
rename to content/handlers/javascript/duktape/HTMLOptionElement.bnd
diff --git a/javascript/duktape/HTMLParagraphElement.bnd b/content/handlers/javascript/duktape/HTMLParagraphElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLParagraphElement.bnd
rename to content/handlers/javascript/duktape/HTMLParagraphElement.bnd
diff --git a/javascript/duktape/HTMLParamElement.bnd b/content/handlers/javascript/duktape/HTMLParamElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLParamElement.bnd
rename to content/handlers/javascript/duktape/HTMLParamElement.bnd
diff --git a/javascript/duktape/HTMLPreElement.bnd b/content/handlers/javascript/duktape/HTMLPreElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLPreElement.bnd
rename to content/handlers/javascript/duktape/HTMLPreElement.bnd
diff --git a/javascript/duktape/HTMLQuoteElement.bnd b/content/handlers/javascript/duktape/HTMLQuoteElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLQuoteElement.bnd
rename to content/handlers/javascript/duktape/HTMLQuoteElement.bnd
diff --git a/javascript/duktape/HTMLScriptElement.bnd b/content/handlers/javascript/duktape/HTMLScriptElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLScriptElement.bnd
rename to content/handlers/javascript/duktape/HTMLScriptElement.bnd
diff --git a/javascript/duktape/HTMLSelectElement.bnd b/content/handlers/javascript/duktape/HTMLSelectElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLSelectElement.bnd
rename to content/handlers/javascript/duktape/HTMLSelectElement.bnd
diff --git a/javascript/duktape/HTMLStyleElement.bnd b/content/handlers/javascript/duktape/HTMLStyleElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLStyleElement.bnd
rename to content/handlers/javascript/duktape/HTMLStyleElement.bnd
diff --git a/javascript/duktape/HTMLTableCaptionElement.bnd b/content/handlers/javascript/duktape/HTMLTableCaptionElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLTableCaptionElement.bnd
rename to content/handlers/javascript/duktape/HTMLTableCaptionElement.bnd
diff --git a/javascript/duktape/HTMLTableCellElement.bnd b/content/handlers/javascript/duktape/HTMLTableCellElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLTableCellElement.bnd
rename to content/handlers/javascript/duktape/HTMLTableCellElement.bnd
diff --git a/javascript/duktape/HTMLTableColElement.bnd b/content/handlers/javascript/duktape/HTMLTableColElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLTableColElement.bnd
rename to content/handlers/javascript/duktape/HTMLTableColElement.bnd
diff --git a/javascript/duktape/HTMLTableElement.bnd b/content/handlers/javascript/duktape/HTMLTableElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLTableElement.bnd
rename to content/handlers/javascript/duktape/HTMLTableElement.bnd
diff --git a/javascript/duktape/HTMLTableRowElement.bnd b/content/handlers/javascript/duktape/HTMLTableRowElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLTableRowElement.bnd
rename to content/handlers/javascript/duktape/HTMLTableRowElement.bnd
diff --git a/javascript/duktape/HTMLTableSectionElement.bnd b/content/handlers/javascript/duktape/HTMLTableSectionElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLTableSectionElement.bnd
rename to content/handlers/javascript/duktape/HTMLTableSectionElement.bnd
diff --git a/javascript/duktape/HTMLTextAreaElement.bnd b/content/handlers/javascript/duktape/HTMLTextAreaElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLTextAreaElement.bnd
rename to content/handlers/javascript/duktape/HTMLTextAreaElement.bnd
diff --git a/javascript/duktape/HTMLTitleElement.bnd b/content/handlers/javascript/duktape/HTMLTitleElement.bnd
similarity index 100%
rename from javascript/duktape/HTMLTitleElement.bnd
rename to content/handlers/javascript/duktape/HTMLTitleElement.bnd
diff --git a/javascript/duktape/Location.bnd b/content/handlers/javascript/duktape/Location.bnd
similarity index 99%
rename from javascript/duktape/Location.bnd
rename to content/handlers/javascript/duktape/Location.bnd
index fbb0e4a..ca7e905 100644
--- a/javascript/duktape/Location.bnd
+++ b/content/handlers/javascript/duktape/Location.bnd
@@ -15,7 +15,7 @@ class Location {
prologue Location()
%{
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
%}
init Location(nsurl *url)
diff --git a/javascript/duktape/Makefile b/content/handlers/javascript/duktape/Makefile
similarity index 57%
rename from javascript/duktape/Makefile
rename to content/handlers/javascript/duktape/Makefile
index 89353c3..37e33d5 100644
--- a/javascript/duktape/Makefile
+++ b/content/handlers/javascript/duktape/Makefile
@@ -4,27 +4,26 @@
# Included by javascript/Makefile
#
-javascript/dukky.c: $(OBJROOT)/duktape/binding.h
+content/handlers/javascript/dukky.c: $(OBJROOT)/duktape/binding.h
-BINDINGS := $(wildcard javascript/duktape/*.bnd)
+BINDINGS := $(wildcard content/handlers/javascript/duktape/*.bnd)
# ensure genbind generates debugging files
GBFLAGS+=-D
-$(OBJROOT)/duktape/binding.h $(OBJROOT)/duktape/Makefile: javascript/duktape/netsurf.bnd $(BINDINGS)
+$(OBJROOT)/duktape/binding.h $(OBJROOT)/duktape/Makefile: content/handlers/javascript/duktape/netsurf.bnd $(BINDINGS)
$(Q)mkdir -p $(OBJROOT)/duktape
$(VQ)echo " GENBIND: $<"
- $(Q)nsgenbind $(GBFLAGS) -I javascript/WebIDL $< $(OBJROOT)/duktape
- $(VQ)echo " GENBIND: completed"
+ $(Q)nsgenbind $(GBFLAGS) -I content/handlers/javascript/WebIDL $< $(OBJROOT)/duktape
# create unimplemented report for doxygen
-Docs/UnimplementedJavascript.txt: javascript/duktape/netsurf.bnd $(BINDINGS)
+Docs/UnimplementedJavascript.txt: content/handlers/javascript/duktape/netsurf.bnd $(BINDINGS)
$(Q)mkdir -p $(OBJROOT)/duktape
$(VQ)echo "/** \page unimplemented Unimplemented javascript bindings" > $@
$(VQ)echo "This is a list of all the binding methods, getters and setters without an implementation in a binding." >> $@
$(VQ)echo "" >> $@
$(VQ)echo " GENBIND: $<"
- $(Q)nsgenbind $(GBFLAGS) -Wunimplemented -I javascript/WebIDL $< $(OBJROOT)/duktape 2>&1 >/dev/null | grep "Unimplemented" | cut -d' ' -f4- | sort -k 2 | awk '{print $$0"\\n" }' >> $@
+ $(Q)nsgenbind $(GBFLAGS) -Wunimplemented -I content/handlers/javascript/WebIDL $< $(OBJROOT)/duktape 2>&1 >/dev/null | grep "Unimplemented" | cut -d' ' -f4- | sort -k 2 | awk '{print $$0"\\n" }' >> $@
$(VQ)echo "*/" >> $@
ifeq ($(filter $(MAKECMDGOALS),clean test coverage),)
diff --git a/javascript/duktape/Navigator.bnd b/content/handlers/javascript/duktape/Navigator.bnd
similarity index 100%
rename from javascript/duktape/Navigator.bnd
rename to content/handlers/javascript/duktape/Navigator.bnd
diff --git a/javascript/duktape/Node.bnd b/content/handlers/javascript/duktape/Node.bnd
similarity index 100%
rename from javascript/duktape/Node.bnd
rename to content/handlers/javascript/duktape/Node.bnd
diff --git a/javascript/duktape/NodeList.bnd b/content/handlers/javascript/duktape/NodeList.bnd
similarity index 100%
rename from javascript/duktape/NodeList.bnd
rename to content/handlers/javascript/duktape/NodeList.bnd
diff --git a/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd
similarity index 97%
rename from javascript/duktape/Window.bnd
rename to content/handlers/javascript/duktape/Window.bnd
index 81d5280..4895878 100644
--- a/javascript/duktape/Window.bnd
+++ b/content/handlers/javascript/duktape/Window.bnd
@@ -13,7 +13,8 @@ class Window {
private struct html_content * htmlc;
prologue %{
#include "utils/nsurl.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
+#include "content/hlcache.h"
#include "render/html.h"
#include "render/html_internal.h"
%};
diff --git a/javascript/duktape/duk_config.h b/content/handlers/javascript/duktape/duk_config.h
similarity index 97%
rename from javascript/duktape/duk_config.h
rename to content/handlers/javascript/duktape/duk_config.h
index a3da70a..f9c95ae 100644
--- a/javascript/duktape/duk_config.h
+++ b/content/handlers/javascript/duktape/duk_config.h
@@ -1,9 +1,9 @@
/*
* duk_config.h configuration header generated by genconfig.py.
*
- * Git commit: 83d557704ee63f68ab40b6fcb00995c9b3d6777c
- * Git describe: v1.5.0
- * Git branch: master
+ * Git commit: 17e3d86cf8b4788bd0d37658f833ab440ce43a1c
+ * Git describe: v1.6.0
+ * Git branch: HEAD
*
* Supported platforms:
* - Mac OSX, iPhone, Darwin
@@ -918,12 +918,27 @@
#define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern
#define DUK_EXTERNAL __attribute__ ((visibility("default")))
#if defined(DUK_SINGLE_FILE)
+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
+/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and
+ * Clang. Based on documentation it should suffice to have the attribute
+ * in the declaration only, but in practice some warnings are generated unless
+ * the attribute is also applied to the definition.
+ */
+#define DUK_INTERNAL_DECL static __attribute__ ((unused))
+#define DUK_INTERNAL static __attribute__ ((unused))
+#else
#define DUK_INTERNAL_DECL static
#define DUK_INTERNAL static
+#endif
+#else
+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
+#define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern
+#define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused))
#else
#define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern
#define DUK_INTERNAL __attribute__ ((visibility("hidden")))
#endif
+#endif
#define DUK_LOCAL_DECL static
#define DUK_LOCAL static
#endif
@@ -1012,12 +1027,27 @@
#define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern
#define DUK_EXTERNAL __attribute__ ((visibility("default")))
#if defined(DUK_SINGLE_FILE)
+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
+/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and
+ * Clang. Based on documentation it should suffice to have the attribute
+ * in the declaration only, but in practice some warnings are generated unless
+ * the attribute is also applied to the definition.
+ */
+#define DUK_INTERNAL_DECL static __attribute__ ((unused))
+#define DUK_INTERNAL static __attribute__ ((unused))
+#else
#define DUK_INTERNAL_DECL static
#define DUK_INTERNAL static
+#endif
+#else
+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
+#define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern
+#define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused))
#else
#define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern
#define DUK_INTERNAL __attribute__ ((visibility("hidden")))
#endif
+#endif
#define DUK_LOCAL_DECL static
#define DUK_LOCAL static
#endif
@@ -1174,12 +1204,27 @@
#define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern
#define DUK_EXTERNAL __attribute__ ((visibility("default")))
#if defined(DUK_SINGLE_FILE)
+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
+/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and
+ * Clang. Based on documentation it should suffice to have the attribute
+ * in the declaration only, but in practice some warnings are generated unless
+ * the attribute is also applied to the definition.
+ */
+#define DUK_INTERNAL_DECL static __attribute__ ((unused))
+#define DUK_INTERNAL static __attribute__ ((unused))
+#else
#define DUK_INTERNAL_DECL static
#define DUK_INTERNAL static
+#endif
+#else
+#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)
+#define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) __attribute__ ((unused)) extern
+#define DUK_INTERNAL __attribute__ ((visibility("hidden"))) __attribute__ ((unused))
#else
#define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern
#define DUK_INTERNAL __attribute__ ((visibility("hidden")))
#endif
+#endif
#define DUK_LOCAL_DECL static
#define DUK_LOCAL static
@@ -2077,7 +2122,13 @@ typedef FILE duk_file;
/* Missing some obvious constants. */
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC)
-/* VBCC is missing the built-ins even in C99 mode (perhaps a header issue) */
+/* VBCC is missing the built-ins even in C99 mode (perhaps a header issue). */
+#define DUK_F_USE_REPL_ALL
+#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_M68K)
+/* AmigaOS + M68K seems to have math issues even when using GCC cross
+ * compilation. Use replacements for all AmigaOS versions on M68K
+ * regardless of compiler.
+ */
#define DUK_F_USE_REPL_ALL
#elif defined(DUK_F_FREEBSD) && defined(DUK_F_CLANG)
/* Placeholder fix for (detection is wider than necessary):
diff --git a/javascript/duktape/duk_custom.h b/content/handlers/javascript/duktape/duk_custom.h
similarity index 100%
rename from javascript/duktape/duk_custom.h
rename to content/handlers/javascript/duktape/duk_custom.h
diff --git a/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c
similarity index 100%
rename from javascript/duktape/dukky.c
rename to content/handlers/javascript/duktape/dukky.c
diff --git a/javascript/duktape/dukky.h b/content/handlers/javascript/duktape/dukky.h
similarity index 100%
rename from javascript/duktape/dukky.h
rename to content/handlers/javascript/duktape/dukky.h
diff --git a/javascript/duktape/duktape.c b/content/handlers/javascript/duktape/duktape.c
similarity index 99%
rename from javascript/duktape/duktape.c
rename to content/handlers/javascript/duktape/duktape.c
index eb4c77a..b64383b 100644
--- a/javascript/duktape/duktape.c
+++ b/content/handlers/javascript/duktape/duktape.c
@@ -1,10 +1,10 @@
/* Omit from static analysis. */
#ifndef __clang_analyzer__
/*
- * Single source autogenerated distributable for Duktape 1.5.0.
+ * Single source autogenerated distributable for Duktape 1.6.0.
*
- * Git commit 83d557704ee63f68ab40b6fcb00995c9b3d6777c (v1.5.0).
- * Git branch master.
+ * Git commit 17e3d86cf8b4788bd0d37658f833ab440ce43a1c (v1.6.0).
+ * Git branch HEAD.
*
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and
* licensing information.
@@ -1631,9 +1631,9 @@ DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[149];
#endif /* !DUK_SINGLE_FILE */
#if defined(DUK_USE_BUILTIN_INITJS)
#if !defined(DUK_SINGLE_FILE)
-DUK_INTERNAL_DECL const duk_uint8_t duk_initjs_data[187];
+DUK_INTERNAL_DECL const duk_uint8_t duk_initjs_data[204];
#endif /* !DUK_SINGLE_FILE */
-#define DUK_BUILTIN_INITJS_DATA_LENGTH 187
+#define DUK_BUILTIN_INITJS_DATA_LENGTH 204
#endif /* DUK_USE_BUILTIN_INITJS */
#define DUK_BIDX_GLOBAL 0
#define DUK_BIDX_GLOBAL_ENV 1
@@ -7891,7 +7891,7 @@ DUK_INTERNAL_DECL duk_bool_t duk_fb_is_full(duk_fixedbuffer *fb);
#define DUK_ERROR_UNSUPPORTED(thr,msg) do { \
DUK_ERROR((thr), DUK_ERR_UNSUPPORTED_ERROR, (msg)); \
} while (0)
-#ifndef DUK_USE_BYTECODE_DUMP_SUPPORT
+#if !defined(DUK_USE_BYTECODE_DUMP_SUPPORT)
#define DUK_ERROR_UNSUPPORTED_DEFMSG(thr) do { \
duk_err_unsupported_defmsg((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \
} while (0)
@@ -8013,7 +8013,7 @@ DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_api_index(duk_hthread *thr, const ch
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_api(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message));
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_range(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message));
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_unimplemented_defmsg(duk_hthread *thr, const char *filename, duk_int_t linenumber));
-#ifndef DUK_USE_BYTECODE_DUMP_SUPPORT
+#if !defined(DUK_USE_BYTECODE_DUMP_SUPPORT)
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_unsupported_defmsg(duk_hthread *thr, const char *filename, duk_int_t linenumber));
#endif
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_internal_defmsg(duk_hthread *thr, const char *filename, duk_int_t linenumber));
@@ -9221,7 +9221,7 @@ DUK_INTERNAL const duk_c_function duk_bi_native_functions[149] = {
duk_bi_typedarray_set,
};
#if defined(DUK_USE_BUILTIN_INITJS)
-DUK_INTERNAL const duk_uint8_t duk_initjs_data[187] = {
+DUK_INTERNAL const duk_uint8_t duk_initjs_data[204] = {
40,102,117,110,99,116,105,111,110,40,100,44,97,41,123,102,117,110,99,116,
105,111,110,32,98,40,97,44,98,44,99,41,123,79,98,106,101,99,116,46,100,101,
102,105,110,101,80,114,111,112,101,114,116,121,40,97,44,98,44,123,118,97,
@@ -9229,8 +9229,9 @@ DUK_INTERNAL const duk_uint8_t duk_initjs_data[187] = {
109,101,114,97,98,108,101,58,33,49,44,99,111,110,102,105,103,117,114,97,98,
108,101,58,33,48,125,41,125,98,40,97,46,76,111,103,103,101,114,44,34,99,
108,111,103,34,44,110,101,119,32,97,46,76,111,103,103,101,114,40,34,67,34,
-41,41,59,98,40,97,44,34,109,111,100,76,111,97,100,101,100,34,44,123,125,41,
-125,41,40,116,104,105,115,44,68,117,107,116,97,112,101,41,59,10,0,
+41,41,59,98,40,97,44,34,109,111,100,76,111,97,100,101,100,34,44,79,98,106,
+101,99,116,46,99,114,101,97,116,101,40,110,117,108,108,41,41,125,41,40,116,
+104,105,115,44,68,117,107,116,97,112,101,41,59,10,0,
};
#endif /* DUK_USE_BUILTIN_INITJS */
#if defined(DUK_USE_DOUBLE_LE)
@@ -9354,7 +9355,7 @@ DUK_INTERNAL const duk_uint8_t duk_builtins_data[3833] = {
88,119,100,223,181,68,16,94,91,250,238,200,160,80,0,152,31,61,59,148,10,0,
21,4,231,199,151,69,2,128,5,192,250,97,220,160,80,0,192,127,255,128,20,23,
134,30,92,242,164,34,19,207,167,45,59,179,233,205,229,37,129,127,255,0,0,
-191,255,128,0,63,255,197,131,246,203,203,158,157,251,160,0,0,0,0,0,65,98,
+191,255,128,0,63,255,197,131,246,203,203,158,157,251,160,0,0,0,0,0,90,98,
32,3,166,156,30,53,32,249,165,131,76,223,159,62,94,70,172,114,16,176,144,
60,56,250,19,18,5,159,25,89,32,121,180,238,42,30,129,229,221,140,164,122,7,
147,46,50,129,232,62,61,251,120,97,199,208,156,129,83,127,0,50,250,69,3,
@@ -9534,7 +9535,7 @@ DUK_INTERNAL const duk_uint8_t duk_builtins_data[3833] = {
88,119,100,223,181,68,16,94,91,250,238,200,160,80,0,152,31,61,59,148,10,0,
21,4,231,199,151,69,2,128,5,192,250,97,220,160,80,0,192,127,255,128,20,23,
134,30,92,242,164,34,19,207,167,45,59,179,233,205,229,37,129,127,255,0,0,
-191,255,128,0,63,255,197,131,246,203,203,158,157,251,160,32,98,65,0,0,0,0,
+191,255,128,0,63,255,197,131,246,203,203,158,157,251,160,32,98,90,0,0,0,0,
0,3,166,156,30,53,32,249,165,131,76,223,159,62,94,70,172,114,16,176,144,60,
56,250,19,18,5,159,25,89,32,121,180,238,42,30,129,229,221,140,164,122,7,
147,46,50,129,232,62,61,251,120,97,199,208,156,129,83,127,0,50,250,69,3,
@@ -9714,7 +9715,7 @@ DUK_INTERNAL const duk_uint8_t duk_builtins_data[3833] = {
88,119,100,223,181,68,16,94,91,250,238,200,160,80,0,152,31,61,59,148,10,0,
21,4,231,199,151,69,2,128,5,192,250,97,220,160,80,0,192,127,255,128,20,23,
134,30,92,242,164,34,19,207,167,45,59,179,233,205,229,37,129,127,255,0,0,
-191,255,128,0,63,255,197,131,246,203,203,158,157,251,160,0,65,98,32,0,0,0,
+191,255,128,0,63,255,197,131,246,203,203,158,157,251,160,0,90,98,32,0,0,0,
0,3,166,156,30,53,32,249,165,131,76,223,159,62,94,70,172,114,16,176,144,60,
56,250,19,18,5,159,25,89,32,121,180,238,42,30,129,229,221,140,164,122,7,
147,46,50,129,232,62,61,251,120,97,199,208,156,129,83,127,0,50,250,69,3,
@@ -9838,7 +9839,7 @@ DUK_INTERNAL void duk_err_api(duk_hthread *thr, const char *filename, duk_int_t
DUK_INTERNAL void duk_err_unimplemented_defmsg(duk_hthread *thr, const char *filename, duk_int_t linenumber) {
DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_UNIMPLEMENTED_ERROR, DUK_STR_UNIMPLEMENTED);
}
-#ifndef DUK_USE_BYTECODE_DUMP_SUPPORT
+#if !defined(DUK_USE_BYTECODE_DUMP_SUPPORT)
DUK_INTERNAL void duk_err_unsupported_defmsg(duk_hthread *thr, const char *filename, duk_int_t linenumber) {
DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_UNSUPPORTED_ERROR, DUK_STR_UNSUPPORTED);
}
@@ -12675,21 +12676,41 @@ DUK_EXTERNAL void duk_new(duk_context *ctx, duk_idx_t nargs) {
duk_dup(ctx, idx_cons);
for (;;) {
- cons = duk_get_hobject(ctx, -1);
- if (cons == NULL || !DUK_HOBJECT_HAS_CONSTRUCTABLE(cons)) {
- /* Checking constructability from anything else than the
- * initial constructor is not strictly necessary, but a
- * nice sanity check.
- */
- goto not_constructable;
- }
- if (!DUK_HOBJECT_HAS_BOUND(cons)) {
+ duk_tval *tv;
+ tv = DUK_GET_TVAL_NEGIDX(ctx, -1);
+ DUK_ASSERT(tv != NULL);
+
+ if (DUK_TVAL_IS_OBJECT(tv)) {
+ cons = DUK_TVAL_GET_OBJECT(tv);
+ DUK_ASSERT(cons != NULL);
+ if (!DUK_HOBJECT_IS_CALLABLE(cons) || !DUK_HOBJECT_HAS_CONSTRUCTABLE(cons)) {
+ /* Checking callability of the immediate target
+ * is important, same for constructability.
+ * Checking it for functions down the bound
+ * function chain is not strictly necessary
+ * because .bind() should normally reject them.
+ * But it's good to check anyway because it's
+ * technically possible to edit the bound function
+ * chain via internal keys.
+ */
+ goto not_constructable;
+ }
+ if (!DUK_HOBJECT_HAS_BOUND(cons)) {
+ break;
+ }
+ } else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {
+ /* Lightfuncs cannot be bound. */
break;
+ } else {
+ /* Anything else is not constructable. */
+ goto not_constructable;
}
duk_get_prop_stridx(ctx, -1, DUK_STRIDX_INT_TARGET); /* -> [... cons target] */
duk_remove(ctx, -2); /* -> [... target] */
}
- DUK_ASSERT(cons != NULL && !DUK_HOBJECT_HAS_BOUND(cons));
+ DUK_ASSERT(duk_is_callable(ctx, -1));
+ DUK_ASSERT(duk_is_lightfunc(ctx, -1) ||
+ (duk_get_hobject(ctx, -1) != NULL && !DUK_HOBJECT_HAS_BOUND(duk_get_hobject(ctx, -1))));
/* [... constructor arg1 ... argN final_cons] */
@@ -14027,6 +14048,15 @@ DUK_EXTERNAL void duk_debugger_pause(duk_context *ctx) {
/* include removed: duk_internal.h */
+typedef struct duk_internal_thread_state duk_internal_thread_state;
+
+struct duk_internal_thread_state {
+ duk_ljstate lj;
+ duk_bool_t handling_error;
+ duk_hthread *curr_thread;
+ duk_int_t call_recursion_depth;
+};
+
DUK_EXTERNAL
duk_context *duk_create_heap(duk_alloc_function alloc_func,
duk_realloc_function realloc_func,
@@ -14092,6 +14122,57 @@ DUK_EXTERNAL void duk_destroy_heap(duk_context *ctx) {
duk_heap_free(heap);
}
+DUK_EXTERNAL void duk_suspend(duk_context *ctx, duk_thread_state *state) {
+ duk_hthread *thr = (duk_hthread *) ctx;
+ duk_internal_thread_state *snapshot = (duk_internal_thread_state *) (void *) state;
+ duk_heap *heap;
+ duk_ljstate *lj;
+
+ DUK_ASSERT_CTX_VALID(ctx);
+ DUK_ASSERT(thr != NULL);
+ DUK_ASSERT(thr->heap != NULL);
+ DUK_ASSERT(state != NULL); /* unvalidated */
+
+ heap = thr->heap;
+ lj = &heap->lj;
+
+ duk_push_tval(ctx, &lj->value1);
+ duk_push_tval(ctx, &lj->value2);
+
+ DUK_MEMCPY((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate));
+ snapshot->handling_error = heap->handling_error;
+ snapshot->curr_thread = heap->curr_thread;
+ snapshot->call_recursion_depth = heap->call_recursion_depth;
+
+ lj->jmpbuf_ptr = NULL;
+ lj->type = DUK_LJ_TYPE_UNKNOWN;
+ DUK_TVAL_SET_UNDEFINED(&lj->value1);
+ DUK_TVAL_SET_UNDEFINED(&lj->value2);
+ heap->handling_error = 0;
+ heap->curr_thread = NULL;
+ heap->call_recursion_depth = 0;
+}
+
+DUK_EXTERNAL void duk_resume(duk_context *ctx, const duk_thread_state *state) {
+ duk_hthread *thr = (duk_hthread *) ctx;
+ const duk_internal_thread_state *snapshot = (const duk_internal_thread_state *) (const void *) state;
+ duk_heap *heap;
+
+ DUK_ASSERT_CTX_VALID(ctx);
+ DUK_ASSERT(thr != NULL);
+ DUK_ASSERT(thr->heap != NULL);
+ DUK_ASSERT(state != NULL); /* unvalidated */
+
+ heap = thr->heap;
+
+ DUK_MEMCPY((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate));
+ heap->handling_error = snapshot->handling_error;
+ heap->curr_thread = snapshot->curr_thread;
+ heap->call_recursion_depth = snapshot->call_recursion_depth;
+
+ duk_pop_2(ctx);
+}
+
/* XXX: better place for this */
DUK_EXTERNAL void duk_set_global_object(duk_context *ctx) {
duk_hthread *thr = (duk_hthread *) ctx;
@@ -14397,7 +14478,7 @@ DUK_INTERNAL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t
return rc;
}
-DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index) {
+DUK_LOCAL duk_bool_t duk__put_prop_shared(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t idx_key) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_tval *tv_obj;
duk_tval *tv_key;
@@ -14405,16 +14486,19 @@ DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index) {
duk_small_int_t throw_flag;
duk_bool_t rc;
- DUK_ASSERT_CTX_VALID(ctx);
-
/* Note: copying tv_obj and tv_key to locals to shield against a valstack
* resize is not necessary for a property put right now (putprop protects
* against it internally).
*/
- tv_obj = duk_require_tval(ctx, obj_index);
- tv_key = duk_require_tval(ctx, -2);
- tv_val = duk_require_tval(ctx, -1);
+ /* Key and value indices are either (-2, -1) or (-1, -2). Given idx_key,
+ * idx_val is always (idx_key ^ 0x01).
+ */
+ DUK_ASSERT((idx_key == -2 && (idx_key ^ 1) == -1) ||
+ (idx_key == -1 && (idx_key ^ 1) == -2));
+ tv_obj = duk_require_tval(ctx, obj_idx);
+ tv_key = duk_require_tval(ctx, idx_key);
+ tv_val = duk_require_tval(ctx, idx_key ^ 1);
throw_flag = duk_is_strict_call(ctx);
rc = duk_hobject_putprop(thr, tv_obj, tv_key, tv_val, throw_flag);
@@ -14424,26 +14508,33 @@ DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index) {
return rc; /* 1 if property found, 0 otherwise */
}
-DUK_EXTERNAL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key) {
+DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx) {
+ DUK_ASSERT_CTX_VALID(ctx);
+ return duk__put_prop_shared(ctx, obj_idx, -2);
+}
+
+DUK_EXTERNAL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {
DUK_ASSERT_CTX_VALID(ctx);
DUK_ASSERT(key != NULL);
- obj_index = duk_require_normalize_index(ctx, obj_index);
- duk_push_string(ctx, key);
- duk_swap_top(ctx, -2); /* [val key] -> [key val] */
- return duk_put_prop(ctx, obj_index);
+ /* Careful here and with other duk_put_prop_xxx() helpers: the
+ * target object and the property value may be in the same value
+ * stack slot (unusual, but still conceptually clear).
+ */
+ obj_idx = duk_normalize_index(ctx, obj_idx);
+ (void) duk_push_string(ctx, key);
+ return duk__put_prop_shared(ctx, obj_idx, -1);
}
-DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index) {
+DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {
DUK_ASSERT_CTX_VALID(ctx);
- obj_index = duk_require_normalize_index(ctx, obj_index);
- duk_push_uarridx(ctx, arr_index);
- duk_swap_top(ctx, -2); /* [val key] -> [key val] */
- return duk_put_prop(ctx, obj_index);
+ obj_idx = duk_require_normalize_index(ctx, obj_idx);
+ duk_push_uarridx(ctx, arr_idx);
+ return duk__put_prop_shared(ctx, obj_idx, -1);
}
-DUK_INTERNAL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx) {
+DUK_INTERNAL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx) {
duk_hthread *thr = (duk_hthread *) ctx;
DUK_ASSERT_CTX_VALID(ctx);
@@ -14451,10 +14542,9 @@ DUK_INTERNAL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_inde
DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS);
DUK_UNREF(thr);
- obj_index = duk_require_normalize_index(ctx, obj_index);
+ obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
- duk_swap_top(ctx, -2); /* [val key] -> [key val] */
- return duk_put_prop(ctx, obj_index);
+ return duk__put_prop_shared(ctx, obj_idx, -1);
}
DUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index) {
@@ -26600,6 +26690,10 @@ DUK_INTERNAL duk_ret_t duk_bi_duktape_object_info(duk_context *ctx) {
hdr_size = (duk_small_uint_t) sizeof(duk_hnativefunction);
} else if (DUK_HOBJECT_IS_THREAD(h_obj)) {
hdr_size = (duk_small_uint_t) sizeof(duk_hthread);
+#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
+ } else if (DUK_HOBJECT_IS_BUFFEROBJECT(h_obj)) {
+ hdr_size = (duk_small_uint_t) sizeof(duk_hbufferobject);
+#endif
} else {
hdr_size = (duk_small_uint_t) sizeof(duk_hobject);
}
@@ -30800,7 +30894,7 @@ DUK_LOCAL void duk__enc_array(duk_json_enc_ctx *js_ctx) {
DUK_LOCAL duk_bool_t duk__enc_value(duk_json_enc_ctx *js_ctx, duk_idx_t idx_holder) {
duk_context *ctx = (duk_context *) js_ctx->thr;
duk_hthread *thr = (duk_hthread *) ctx;
- duk_hobject *h;
+ duk_hobject *h_tmp;
duk_tval *tv;
duk_tval *tv_holder;
duk_tval *tv_key;
@@ -30822,12 +30916,12 @@ DUK_LOCAL duk_bool_t duk__enc_value(duk_json_enc_ctx *js_ctx, duk_idx_t idx_hold
DUK_DDD(DUK_DDDPRINT("value=%!T", (duk_tval *) duk_get_tval(ctx, -1)));
- h = duk_get_hobject_or_lfunc_coerce(ctx, -1);
- if (h != NULL) {
+ h_tmp = duk_get_hobject_or_lfunc_coerce(ctx, -1);
+ if (h_tmp != NULL) {
duk_get_prop_stridx(ctx, -1, DUK_STRIDX_TO_JSON);
- h = duk_get_hobject_or_lfunc_coerce(ctx, -1); /* toJSON() can also be a lightfunc */
+ h_tmp = duk_get_hobject_or_lfunc_coerce(ctx, -1); /* toJSON() can also be a lightfunc */
- if (h != NULL && DUK_HOBJECT_IS_CALLABLE(h)) {
+ if (h_tmp != NULL && DUK_HOBJECT_IS_CALLABLE(h_tmp)) {
DUK_DDD(DUK_DDDPRINT("value is object, has callable toJSON() -> call it"));
/* XXX: duk_dup_unvalidated(ctx, -2) etc. */
duk_dup(ctx, -2); /* -> [ ... key val toJSON val ] */
@@ -30860,6 +30954,8 @@ DUK_LOCAL duk_bool_t duk__enc_value(duk_json_enc_ctx *js_ctx, duk_idx_t idx_hold
tv = DUK_GET_TVAL_NEGIDX(ctx, -1);
if (DUK_TVAL_IS_OBJECT(tv)) {
+ duk_hobject *h;
+
h = DUK_TVAL_GET_OBJECT(tv);
DUK_ASSERT(h != NULL);
@@ -31365,12 +31461,17 @@ DUK_LOCAL duk_bool_t duk__json_stringify_fast_value(duk_json_enc_ctx *js_ctx, du
* standard JSON (and no JX/JC support here now).
*/
DUK_D(DUK_DPRINT("gap in array, no conflicting inherited property, remain on fast path"));
+#if defined(DUK_USE_JX)
+ DUK__EMIT_STRIDX(js_ctx, js_ctx->stridx_custom_undefined);
+#else
DUK__EMIT_STRIDX(js_ctx, DUK_STRIDX_LC_NULL);
+#endif
} else {
if (duk__json_stringify_fast_value(js_ctx, tv_val) == 0) {
DUK__EMIT_STRIDX(js_ctx, DUK_STRIDX_LC_NULL);
}
}
+
DUK__EMIT_1(js_ctx, DUK_ASC_COMMA);
emitted = 1;
}
@@ -31703,6 +31804,7 @@ void duk_bi_json_stringify_helper(duk_context *ctx,
* combinations properly.
*/
#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
+ js_ctx->stridx_custom_undefined = DUK_STRIDX_LC_NULL; /* standard JSON; array gaps */
#if defined(DUK_USE_JX)
if (flags & DUK_JSON_FLAG_EXT_CUSTOM) {
js_ctx->stridx_custom_undefined = DUK_STRIDX_LC_UNDEFINED;
@@ -33905,7 +34007,7 @@ DUK_INTERNAL duk_ret_t duk_bi_string_constructor_from_char_code(duk_context *ctx
cp = (duk_ucodepoint_t) duk_to_uint32(ctx, i);
DUK_BW_WRITE_ENSURE_XUTF8(thr, bw, cp);
#else
- cp = (duk_ucodepoint_t) duk_to_uint32(ctx, i);
+ cp = (duk_ucodepoint_t) duk_to_uint16(ctx, i);
DUK_BW_WRITE_ENSURE_CESU8(thr, bw, cp);
#endif
}
@@ -38612,7 +38714,7 @@ DUK_LOCAL void duk__debug_dump_strtab_probe(duk_hthread *thr, duk_heap *heap) {
for (i = 0; i < heap->st_size; i++) {
#if defined(DUK_USE_HEAPPTR16)
- h = DUK_USE_HEAPPTR_DEC16(heap->strtable16[i]);
+ h = DUK_USE_HEAPPTR_DEC16(heap->heap_udata, heap->strtable16[i]);
#else
h = heap->strtable[i];
#endif
@@ -42010,18 +42112,23 @@ DUK_LOCAL void duk__mark_hobject(duk_heap *heap, duk_hobject *h) {
duk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HCOMPILEDFUNCTION_GET_DATA(heap, f));
- tv = DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(heap, f);
- tv_end = DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(heap, f);
- while (tv < tv_end) {
- duk__mark_tval(heap, tv);
- tv++;
- }
+ if (DUK_HCOMPILEDFUNCTION_GET_DATA(heap, f) != NULL) {
+ tv = DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(heap, f);
+ tv_end = DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(heap, f);
+ while (tv < tv_end) {
+ duk__mark_tval(heap, tv);
+ tv++;
+ }
- fn = DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(heap, f);
- fn_end = DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(heap, f);
- while (fn < fn_end) {
- duk__mark_heaphdr(heap, (duk_heaphdr *) *fn);
- fn++;
+ fn = DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(heap, f);
+ fn_end = DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(heap, f);
+ while (fn < fn_end) {
+ duk__mark_heaphdr(heap, (duk_heaphdr *) *fn);
+ fn++;
+ }
+ } else {
+ /* May happen in some out-of-memory corner cases. */
+ DUK_D(DUK_DPRINT("duk_hcompiledfunction 'data' is NULL, skipping marking"));
}
} else if (DUK_HOBJECT_IS_NATIVEFUNCTION(h)) {
duk_hnativefunction *f = (duk_hnativefunction *) h;
@@ -42578,7 +42685,7 @@ DUK_LOCAL void duk__sweep_stringtable_probe(duk_heap *heap, duk_size_t *out_coun
for (i = 0; i < heap->st_size; i++) {
#if defined(DUK_USE_HEAPPTR16)
- h = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->strtable16[i]);
+ h = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, heap->strtable16[i]);
#else
h = heap->strtable[i];
#endif
@@ -43236,6 +43343,9 @@ DUK_INTERNAL duk_bool_t duk_heap_mark_and_sweep(duk_heap *heap, duk_small_uint_t
/* XXX: stringtable emergency compaction? */
+ /* XXX: remove this feature entirely? it would only matter for
+ * emergency GC. Disable for lowest memory builds.
+ */
#if defined(DUK_USE_MS_STRINGTABLE_RESIZE)
if (!(flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE)) {
DUK_DD(DUK_DDPRINT("resize stringtable: %p", (void *) heap));
@@ -43898,20 +44008,23 @@ DUK_LOCAL void duk__refcount_finalize_hobject(duk_hthread *thr, duk_hobject *h)
duk_tval *tv, *tv_end;
duk_hobject **funcs, **funcs_end;
- DUK_ASSERT(DUK_HCOMPILEDFUNCTION_GET_DATA(thr->heap, f) != NULL); /* compiled functions must be created 'atomically' */
-
- tv = DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(thr->heap, f);
- tv_end = DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(thr->heap, f);
- while (tv < tv_end) {
- duk_tval_decref(thr, tv);
- tv++;
- }
+ if (DUK_HCOMPILEDFUNCTION_GET_DATA(thr->heap, f) != NULL) {
+ tv = DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(thr->heap, f);
+ tv_end = DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(thr->heap, f);
+ while (tv < tv_end) {
+ duk_tval_decref(thr, tv);
+ tv++;
+ }
- funcs = DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(thr->heap, f);
- funcs_end = DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(thr->heap, f);
- while (funcs < funcs_end) {
- duk_heaphdr_decref(thr, (duk_heaphdr *) *funcs);
- funcs++;
+ funcs = DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(thr->heap, f);
+ funcs_end = DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(thr->heap, f);
+ while (funcs < funcs_end) {
+ duk_heaphdr_decref(thr, (duk_heaphdr *) *funcs);
+ funcs++;
+ }
+ } else {
+ /* May happen in some out-of-memory corner cases. */
+ DUK_D(DUK_DPRINT("duk_hcompiledfunction 'data' is NULL, skipping decref"));
}
duk_heaphdr_decref(thr, (duk_heaphdr *) DUK_HCOMPILEDFUNCTION_GET_DATA(thr->heap, f));
@@ -44730,6 +44843,15 @@ DUK_INTERNAL duk_uint_fast32_t duk_heap_strcache_offset_char2byte(duk_hthread *t
#define DUK__DELETED_MARKER(heap) DUK_STRTAB_DELETED_MARKER((heap))
#endif
+#if defined(DUK_USE_MARK_AND_SWEEP)
+#define DUK__PREVENT_MS_SIDE_EFFECTS(heap) do { \
+ (heap)->mark_and_sweep_base_flags |= \
+ DUK_MS_FLAG_NO_STRINGTABLE_RESIZE | /* avoid recursive string table call */ \
+ DUK_MS_FLAG_NO_FINALIZERS | /* avoid pressure to add/remove strings, invalidation of call data argument, etc. */ \
+ DUK_MS_FLAG_NO_OBJECT_COMPACTION; /* avoid array abandoning which interns strings */ \
+ } while (0)
+#endif
+
/*
* Create a hstring and insert into the heap. The created object
* is directly garbage collectable with reference count zero.
@@ -44766,7 +44888,7 @@ duk_hstring *duk__alloc_init_hstring(duk_heap *heap,
goto alloc_error;
}
DUK_MEMZERO(res, sizeof(duk_hstring_external));
-#ifdef DUK_USE_EXPLICIT_NULL_INIT
+#if defined(DUK_USE_EXPLICIT_NULL_INIT)
DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr);
#endif
DUK_HEAPHDR_SET_TYPE_AND_FLAGS(&res->hdr, DUK_HTYPE_STRING, DUK_HSTRING_FLAG_EXTDATA);
@@ -44780,7 +44902,7 @@ duk_hstring *duk__alloc_init_hstring(duk_heap *heap,
goto alloc_error;
}
DUK_MEMZERO(res, sizeof(duk_hstring));
-#ifdef DUK_USE_EXPLICIT_NULL_INIT
+#if defined(DUK_USE_EXPLICIT_NULL_INIT)
DUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr);
#endif
DUK_HEAPHDR_SET_TYPE_AND_FLAGS(&res->hdr, DUK_HTYPE_STRING, 0);
@@ -45356,10 +45478,7 @@ DUK_LOCAL void duk__remove_matching_hstring_probe(duk_heap *heap, duk_hstring **
}
DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe(duk_heap *heap, duk_uint32_t new_size) {
-#ifdef DUK_USE_MARK_AND_SWEEP
- duk_small_uint_t prev_mark_and_sweep_base_flags;
-#endif
-#ifdef DUK_USE_DEBUG
+#if defined(DUK_USE_DEBUG)
duk_uint32_t old_used = heap->st_used;
#endif
duk_uint32_t old_size = heap->st_size;
@@ -45373,7 +45492,7 @@ DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe(duk_heap *heap, duk_uint32_t n
duk_uint32_t new_used = 0;
duk_uint32_t i;
-#ifdef DUK_USE_DEBUG
+#if defined(DUK_USE_DEBUG)
DUK_UNREF(old_used); /* unused with some debug level combinations */
#endif
@@ -45387,23 +45506,18 @@ DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe(duk_heap *heap, duk_uint32_t n
DUK_ASSERT(new_size > (duk_uint32_t) duk__count_used_probe(heap)); /* required for rehash to succeed, equality not that useful */
DUK_ASSERT(old_entries);
-#ifdef DUK_USE_MARK_AND_SWEEP
- DUK_ASSERT((heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE) == 0);
-#endif
/*
* The attempt to allocate may cause a GC. Such a GC must not attempt to resize
* the stringtable (though it can be swept); finalizer execution and object
* compaction must also be postponed to avoid the pressure to add strings to the
- * string table.
+ * string table. Call site must prevent these.
*/
-#ifdef DUK_USE_MARK_AND_SWEEP
- prev_mark_and_sweep_base_flags = heap->mark_and_sweep_base_flags;
- heap->mark_and_sweep_base_flags |= \
- DUK_MS_FLAG_NO_STRINGTABLE_RESIZE | /* avoid recursive call here */
- DUK_MS_FLAG_NO_FINALIZERS | /* avoid pressure to add/remove strings */
- DUK_MS_FLAG_NO_OBJECT_COMPACTION; /* avoid array abandoning which interns strings */
+#if defined(DUK_USE_MARK_AND_SWEEP)
+ DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE);
+ DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_FINALIZERS);
+ DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_OBJECT_COMPACTION);
#endif
#if defined(DUK_USE_HEAPPTR16)
@@ -45412,15 +45526,11 @@ DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe(duk_heap *heap, duk_uint32_t n
new_entries = (duk_hstring **) DUK_ALLOC(heap, sizeof(duk_hstring *) * new_size);
#endif
-#ifdef DUK_USE_MARK_AND_SWEEP
- heap->mark_and_sweep_base_flags = prev_mark_and_sweep_base_flags;
-#endif
-
if (!new_entries) {
goto resize_error;
}
-#ifdef DUK_USE_EXPLICIT_NULL_INIT
+#if defined(DUK_USE_EXPLICIT_NULL_INIT)
for (i = 0; i < new_size; i++) {
#if defined(DUK_USE_HEAPPTR16)
new_entries[i] = heap->heapptr_null16;
@@ -45556,10 +45666,24 @@ DUK_INTERNAL void duk_heap_dump_strtab(duk_heap *heap) {
DUK_LOCAL duk_hstring *duk__do_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {
duk_hstring *res;
const duk_uint8_t *extdata;
+#if defined(DUK_USE_MARK_AND_SWEEP)
+ duk_small_uint_t prev_mark_and_sweep_base_flags;
+#endif
+
+ /* Prevent any side effects on the string table and the caller provided
+ * str/blen arguments while interning is in progress. For example, if
+ * the caller provided str/blen from a dynamic buffer, a finalizer might
+ * resize that dynamic buffer, invalidating the call arguments.
+ */
+#if defined(DUK_USE_MARK_AND_SWEEP)
+ DUK_ASSERT((heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE) == 0);
+ prev_mark_and_sweep_base_flags = heap->mark_and_sweep_base_flags;
+ DUK__PREVENT_MS_SIDE_EFFECTS(heap);
+#endif
#if defined(DUK_USE_STRTAB_PROBE)
if (duk__recheck_strtab_size_probe(heap, heap->st_used + 1)) {
- return NULL;
+ goto failed;
}
#endif
@@ -45587,14 +45711,14 @@ DUK_LOCAL duk_hstring *duk__do_intern(duk_heap *heap, const duk_uint8_t *str, du
#endif
res = duk__alloc_init_hstring(heap, str, blen, strhash, extdata);
if (!res) {
- return NULL;
+ goto failed;
}
#if defined(DUK_USE_STRTAB_CHAIN)
if (duk__insert_hstring_chain(heap, res)) {
/* failed */
DUK_FREE(heap, res);
- return NULL;
+ goto failed;
}
#elif defined(DUK_USE_STRTAB_PROBE)
/* guaranteed to succeed */
@@ -45616,7 +45740,15 @@ DUK_LOCAL duk_hstring *duk__do_intern(duk_heap *heap, const duk_uint8_t *str, du
* operations which require allocation (and possible gc).
*/
+ done:
+#if defined(DUK_USE_MARK_AND_SWEEP)
+ heap->mark_and_sweep_base_flags = prev_mark_and_sweep_base_flags;
+#endif
return res;
+
+ failed:
+ res = NULL;
+ goto done;
}
DUK_LOCAL duk_hstring *duk__do_lookup(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t *out_strhash) {
@@ -45752,16 +45884,24 @@ DUK_INTERNAL void duk_heap_string_remove(duk_heap *heap, duk_hstring *h) {
#if defined(DUK_USE_MARK_AND_SWEEP) && defined(DUK_USE_MS_STRINGTABLE_RESIZE)
DUK_INTERNAL void duk_heap_force_strtab_resize(duk_heap *heap) {
+ duk_small_uint_t prev_mark_and_sweep_base_flags;
/* Force a resize so that DELETED entries are eliminated.
* Another option would be duk__recheck_strtab_size_probe();
* but since that happens on every intern anyway, this whole
* check can now be disabled.
*/
+
+ DUK_ASSERT((heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE) == 0);
+ prev_mark_and_sweep_base_flags = heap->mark_and_sweep_base_flags;
+ DUK__PREVENT_MS_SIDE_EFFECTS(heap);
+
#if defined(DUK_USE_STRTAB_CHAIN)
DUK_UNREF(heap);
#elif defined(DUK_USE_STRTAB_PROBE)
- duk__resize_strtab_probe(heap);
+ (void) duk__resize_strtab_probe(heap);
#endif
+
+ heap->mark_and_sweep_base_flags = prev_mark_and_sweep_base_flags;
}
#endif
@@ -46814,8 +46954,13 @@ DUK_INTERNAL duk_bool_t duk_hobject_prototype_chain_contains(duk_hthread *thr, d
duk_uint_t sanity;
DUK_ASSERT(thr != NULL);
- DUK_ASSERT(h != NULL);
- /* allow 'p' to be NULL; then the result is always false */
+
+ /* False if the object is NULL or the prototype 'p' is NULL.
+ * In particular, false if both are NULL (don't compare equal).
+ */
+ if (h == NULL || p == NULL) {
+ return 0;
+ }
sanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;
do {
@@ -51302,8 +51447,17 @@ DUK_INTERNAL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *o
DUK_TVAL_SET_UNUSED_UPDREF(thr, tv); /* side effects */
goto success;
} else {
+ duk_hobject *h_get = NULL;
+ duk_hobject *h_set = NULL;
+ duk_tval tv_tmp;
+
DUK_ASSERT(desc.a_idx < 0);
+ /* Set property slot to an empty state. Careful not to invoke
+ * any side effects while using desc.e_idx so that it doesn't
+ * get invalidated by a finalizer mutating our object.
+ */
+
/* remove hash entry (no decref) */
#if defined(DUK_USE_HOBJECT_HASH_PART)
if (desc.h_idx >= 0) {
@@ -51324,21 +51478,17 @@ DUK_INTERNAL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *o
DUK_DDD(DUK_DDDPRINT("before removing value, e_idx %ld, key %p, key at slot %p",
(long) desc.e_idx, (void *) key, (void *) DUK_HOBJECT_E_GET_KEY(thr->heap, obj, desc.e_idx)));
DUK_DDD(DUK_DDDPRINT("removing value at e_idx %ld", (long) desc.e_idx));
+ DUK_MEMSET((void *) &tv_tmp, 0, sizeof(tv_tmp));
+ DUK_TVAL_SET_UNDEFINED(&tv_tmp);
if (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, desc.e_idx)) {
- duk_hobject *tmp;
-
- tmp = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, desc.e_idx);
+ h_get = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, desc.e_idx);
+ h_set = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, desc.e_idx);
DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, desc.e_idx, NULL);
- DUK_UNREF(tmp);
- DUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp); /* side effects */
-
- tmp = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, desc.e_idx);
DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, desc.e_idx, NULL);
- DUK_UNREF(tmp);
- DUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp); /* side effects */
} else {
tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, desc.e_idx);
- DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv); /* side effects */
+ DUK_TVAL_SET_TVAL(&tv_tmp, tv);
+ DUK_TVAL_SET_UNDEFINED(tv);
}
#if 0
/* Not strictly necessary because if key == NULL, flag MUST be ignored. */
@@ -51351,7 +51501,14 @@ DUK_INTERNAL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *o
DUK_DDD(DUK_DDDPRINT("removing key at e_idx %ld", (long) desc.e_idx));
DUK_ASSERT(key == DUK_HOBJECT_E_GET_KEY(thr->heap, obj, desc.e_idx));
DUK_HOBJECT_E_SET_KEY(thr->heap, obj, desc.e_idx, NULL);
- DUK_HSTRING_DECREF(thr, key); /* side effects */
+
+ /* Do decrefs only with safe pointers to avoid side effects
+ * disturbing e_idx.
+ */
+ DUK_TVAL_DECREF(thr, &tv_tmp);
+ DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_get);
+ DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_set);
+ DUK_HSTRING_DECREF(thr, key);
goto success;
}
@@ -52525,6 +52682,7 @@ void duk_hobject_define_property_helper(duk_context *ctx,
} else {
duk_bool_t rc;
duk_tval *tv1;
+ duk_tval tv_tmp;
/* curr is data, desc is accessor */
if (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {
@@ -52544,9 +52702,12 @@ void duk_hobject_define_property_helper(duk_context *ctx,
DUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));
+ /* Avoid side effects that might disturb curr.e_idx until
+ * we're done editing the slot.
+ */
tv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx);
- /* XXX: just decref */
- DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv1); /* side effects */
+ DUK_TVAL_SET_TVAL(&tv_tmp, tv1);
+ DUK_TVAL_SET_UNDEFINED(tv1);
DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, curr.e_idx, NULL);
DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, curr.e_idx, NULL);
@@ -52556,6 +52717,8 @@ void duk_hobject_define_property_helper(duk_context *ctx,
DUK_DDD(DUK_DDDPRINT("flags after data->accessor conversion: 0x%02lx",
(unsigned long) DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, curr.e_idx)));
+ DUK_TVAL_DECREF(thr, &tv_tmp); /* side effects */
+
/* re-lookup to update curr.flags
* XXX: would be faster to update directly
*/
@@ -52571,7 +52734,8 @@ void duk_hobject_define_property_helper(duk_context *ctx,
if (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {
duk_bool_t rc;
- duk_hobject *tmp;
+ duk_hobject *h_get;
+ duk_hobject *h_set;
/* curr is accessor, desc is data */
if (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {
@@ -52583,15 +52747,14 @@ void duk_hobject_define_property_helper(duk_context *ctx,
DUK_DDD(DUK_DDDPRINT("convert property to data property"));
+ /* Avoid side effects that might disturb curr.e_idx until
+ * we're done editing the slot.
+ */
DUK_ASSERT(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));
- tmp = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, curr.e_idx);
- DUK_UNREF(tmp);
+ h_get = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, curr.e_idx);
DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, curr.e_idx, NULL);
- DUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp); /* side effects */
- tmp = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, curr.e_idx);
- DUK_UNREF(tmp);
+ h_set = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, curr.e_idx);
DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, curr.e_idx, NULL);
- DUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp); /* side effects */
DUK_TVAL_SET_UNDEFINED(DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx));
DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(thr->heap, obj, curr.e_idx);
@@ -52600,6 +52763,9 @@ void duk_hobject_define_property_helper(duk_context *ctx,
DUK_DDD(DUK_DDDPRINT("flags after accessor->data conversion: 0x%02lx",
(unsigned long) DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, curr.e_idx)));
+ DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_get); /* side effects */
+ DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_set); /* side effects */
+
/* re-lookup to update curr.flags
* XXX: would be faster to update directly
*/
@@ -59710,6 +59876,7 @@ DUK_LOCAL void duk__ivalue_toplain_raw(duk_compiler_ctx *comp_ctx, duk_ivalue *x
}
case DUK_IVAL_NONE:
default: {
+ DUK_D(DUK_DPRINT("invalid ivalue type: %ld", (long) x->t));
break;
}
}
@@ -61679,13 +61846,24 @@ DUK_LOCAL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_i
* left-hand-side values (e.g. as in "f() = 1") must NOT cause a
* SyntaxError, but rather a run-time ReferenceError.
*
- * Assignment expression value is conceptually the LHS/RHS value
- * copied into a fresh temporary so that it won't change even if
- * LHS/RHS values change (e.g. when they're identifiers). Doing this
- * concretely produces inefficient bytecode, so we try to avoid the
- * extra temporary for some known-to-be-safe cases. Currently the
- * only safe case we detect is a "top level assignment", for example
- * "x = y + z;", where the assignment expression value is ignored.
+ * When evaluating X <op>= Y, the LHS (X) is conceptually evaluated
+ * to a temporary first. The RHS is then evaluated. Finally, the
+ * <op> is applied to the initial value of RHS (not the value after
+ * RHS evaluation), and written to X. Doing so concretely generates
+ * inefficient code so we'd like to avoid the temporary when possible.
+ * See: https://github.com/svaarala/duktape/pull/992.
+ *
+ * The expression value (final LHS value, written to RHS) is
+ * conceptually copied into a fresh temporary so that it won't
+ * change even if the LHS/RHS values change in outer expressions.
+ * For example, it'd be generally incorrect for the expression value
+ * to be the RHS register binding, unless there's a guarantee that it
+ * won't change during further expression evaluation. Using the
+ * temporary concretely produces inefficient bytecode, so we try to
+ * avoid the extra temporary for some known-to-be-safe cases.
+ * Currently the only safe case we detect is a "top level assignment",
+ * for example "x = y + z;", where the assignment expression value is
+ * ignored.
* See: test-dev-assign-expr.js and test-bug-assign-mutate-gh381.js.
*/
@@ -61705,7 +61883,9 @@ DUK_LOCAL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_i
* is a reg-bound identifier. The RHS ('res') is right associative
* so it has consumed all other assignment level operations; the
* only relevant lower binding power construct is comma operator
- * which will ignore the expression value provided here.
+ * which will ignore the expression value provided here. Usually
+ * the top level assignment expression value is ignored, but it
+ * is relevant for e.g. eval code.
*/
toplevel_assign = (comp_ctx->curr_func.nud_count == 1 && /* one token before */
comp_ctx->curr_func.led_count == 1); /* one operator (= assign) */
@@ -61721,23 +61901,17 @@ DUK_LOCAL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_i
DUK_ASSERT(left->x1.t == DUK_ISPEC_VALUE); /* LHS is already side effect free */
- /* Keep the RHS as an unresolved ivalue for now, so it
- * can be a plain value or a unary/binary operation here.
- * We resolve it before finishing but doing it later allows
- * better bytecode in some cases.
- */
- duk__expr(comp_ctx, res, args_rbp /*rbp_flags*/);
-
h_varname = duk_get_hstring(ctx, left->x1.valstack_idx);
DUK_ASSERT(h_varname != NULL);
if (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {
- /* E5 Section 11.13.1 (and others for other assignments), step 4 */
+ /* E5 Section 11.13.1 (and others for other assignments), step 4. */
goto syntax_error_lvalue;
}
duk_dup(ctx, left->x1.valstack_idx);
(void) duk__lookup_lhs(comp_ctx, ®_varbind, &rc_varname);
if (args_op == DUK_OP_NONE) {
+ duk__expr(comp_ctx, res, args_rbp /*rbp_flags*/);
if (toplevel_assign) {
/* Any 'res' will do. */
DUK_DDD(DUK_DDDPRINT("plain assignment, toplevel assign, use as is"));
@@ -61751,42 +61925,98 @@ DUK_LOCAL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_i
}
}
} else {
- duk__ivalue_toregconst(comp_ctx, res);
- DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
+ /* For X <op>= Y we need to evaluate the pre-op
+ * value of X before evaluating the RHS: the RHS
+ * can change X, but when we do <op> we must use
+ * the pre-op value.
+ */
+ duk_reg_t reg_temp;
+
+ reg_temp = DUK__ALLOCTEMP(comp_ctx);
if (reg_varbind >= 0) {
duk_reg_t reg_res;
+ duk_reg_t reg_src;
+ duk_int_t pc_temp_load;
+ duk_int_t pc_before_rhs;
+ duk_int_t pc_after_rhs;
if (toplevel_assign) {
/* 'reg_varbind' is the operation result and can also
* become the expression value for top level assignments
* such as: "var x; x += y;".
*/
+ DUK_DD(DUK_DDPRINT("<op>= expression is top level, write directly to reg_varbind"));
reg_res = reg_varbind;
} else {
/* Not safe to use 'reg_varbind' as assignment expression
* value, so go through a temp.
*/
- reg_res = DUK__ALLOCTEMP(comp_ctx);
+ DUK_DD(DUK_DDPRINT("<op>= expression is not top level, write to reg_temp"));
+ reg_res = reg_temp; /* reg_res should be smallest possible */
+ reg_temp = DUK__ALLOCTEMP(comp_ctx);
+ }
+
+ /* Try to optimize X <op>= Y for reg-bound
+ * variables. Detect side-effect free RHS
+ * narrowly by seeing whether it emits code.
+ * If not, rewind the code emitter and overwrite
+ * the unnecessary temp reg load.
+ */
+
+ pc_temp_load = duk__get_current_pc(comp_ctx);
+ duk__emit_a_bc(comp_ctx,
+ DUK_OP_LDREG,
+ (duk_regconst_t) reg_temp,
+ reg_varbind);
+
+ pc_before_rhs = duk__get_current_pc(comp_ctx);
+ duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
+ DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
+ pc_after_rhs = duk__get_current_pc(comp_ctx);
+
+ DUK_DD(DUK_DDPRINT("pc_temp_load=%ld, pc_before_rhs=%ld, pc_after_rhs=%ld",
+ (long) pc_temp_load, (long) pc_before_rhs,
+ (long) pc_after_rhs));
+
+ if (pc_after_rhs == pc_before_rhs) {
+ /* Note: if the reg_temp load generated shuffling
+ * instructions, we may need to rewind more than
+ * one instruction, so use explicit PC computation.
+ */
+ DUK_DD(DUK_DDPRINT("rhs is side effect free, rewind and avoid unnecessary temp for reg-based <op>="));
+ DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (pc_temp_load - pc_before_rhs) * sizeof(duk_compiler_instr));
+ reg_src = reg_varbind;
+ } else {
+ DUK_DD(DUK_DDPRINT("rhs evaluation emitted code, not sure if rhs is side effect free; use temp reg for LHS"));
+ reg_src = reg_temp;
}
duk__emit_a_b_c(comp_ctx,
args_op,
(duk_regconst_t) reg_res,
- (duk_regconst_t) reg_varbind,
+ (duk_regconst_t) reg_src,
res->x1.regconst);
+
res->x1.regconst = (duk_regconst_t) reg_res;
+
+ /* Ensure compact use of temps. */
+ if (DUK__ISTEMP(comp_ctx, reg_res)) {
+ DUK__SETTEMP(comp_ctx, reg_res + 1);
+ }
} else {
/* When LHS is not register bound, always go through a
* temporary. No optimization for top level assignment.
*/
- duk_reg_t reg_temp;
- reg_temp = DUK__ALLOCTEMP(comp_ctx);
duk__emit_a_bc(comp_ctx,
DUK_OP_GETVAR,
(duk_regconst_t) reg_temp,
rc_varname);
+
+ duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
+ DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
+
duk__emit_a_b_c(comp_ctx,
args_op,
(duk_regconst_t) reg_temp,
@@ -61872,10 +62102,10 @@ DUK_LOCAL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_i
DUK__IVAL_FLAG_REQUIRE_TEMP | DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);
/* Evaluate RHS only when LHS is safe. */
- duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
- DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
if (args_op == DUK_OP_NONE) {
+ duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
+ DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
rc_res = res->x1.regconst;
} else {
reg_temp = DUK__ALLOCTEMP(comp_ctx);
@@ -61884,6 +62114,10 @@ DUK_LOCAL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_i
(duk_regconst_t) reg_temp,
(duk_regconst_t) reg_obj,
rc_key);
+
+ duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
+ DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
+
duk__emit_a_b_c(comp_ctx,
args_op,
(duk_regconst_t) reg_temp,
@@ -61915,17 +62149,18 @@ DUK_LOCAL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_i
duk_regconst_t rc_res;
- /* first evaluate LHS fully to ensure all side effects are out */
+ /* First evaluate LHS fully to ensure all side effects are out. */
duk__ivalue_toplain_ignore(comp_ctx, left);
- /* then evaluate RHS fully (its value becomes the expression value too) */
+ /* Then evaluate RHS fully (its value becomes the expression value too).
+ * Technically we'd need the side effect safety check here too, but because
+ * we always throw using INVLHS the result doesn't matter.
+ */
rc_res = duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
duk__emit_extraop_only(comp_ctx,
DUK_EXTRAOP_INVLHS);
- /* XXX: this value is irrelevant because of INVLHS? */
-
res->t = DUK_IVAL_PLAIN;
res->x1.t = DUK_ISPEC_REGCONST;
res->x1.regconst = rc_res;
@@ -71127,7 +71362,12 @@ DUK_LOCAL void duk__inc_data_inner_refcounts(duk_hthread *thr, duk_hcompiledfunc
duk_tval *tv, *tv_end;
duk_hobject **funcs, **funcs_end;
- DUK_ASSERT(DUK_HCOMPILEDFUNCTION_GET_DATA(thr->heap, f) != NULL); /* compiled functions must be created 'atomically' */
+ /* If function creation fails due to out-of-memory, the data buffer
+ * pointer may be NULL in some cases. That's actually possible for
+ * GC code, but shouldn't be possible here because the incomplete
+ * function will be unwound from the value stack and never instantiated.
+ */
+ DUK_ASSERT(DUK_HCOMPILEDFUNCTION_GET_DATA(thr->heap, f) != NULL);
DUK_UNREF(thr);
tv = DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(thr->heap, f);
@@ -78941,6 +79181,7 @@ DUK_LOCAL void duk__regexp_match_helper(duk_hthread *thr, duk_small_int_t force_
duk_hobject *h_regexp;
duk_hstring *h_bytecode;
duk_hstring *h_input;
+ duk_uint8_t *p_buf;
const duk_uint8_t *pc;
const duk_uint8_t *sp;
duk_small_int_t match = 0;
@@ -79011,17 +79252,21 @@ DUK_LOCAL void duk__regexp_match_helper(duk_hthread *thr, duk_small_int_t force_
DUK_ASSERT(re_ctx.nsaved >= 2);
DUK_ASSERT((re_ctx.nsaved % 2) == 0);
- duk_push_fixed_buffer(ctx, sizeof(duk_uint8_t *) * re_ctx.nsaved);
+ p_buf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, sizeof(duk_uint8_t *) * re_ctx.nsaved);
+ DUK_UNREF(p_buf);
re_ctx.saved = (const duk_uint8_t **) duk_get_buffer(ctx, -1, NULL);
DUK_ASSERT(re_ctx.saved != NULL);
/* [ ... re_obj input bc saved_buf ] */
- /* buffer is automatically zeroed */
-#ifdef DUK_USE_EXPLICIT_NULL_INIT
+#if defined(DUK_USE_EXPLICIT_NULL_INIT)
for (i = 0; i < re_ctx.nsaved; i++) {
re_ctx.saved[i] = (duk_uint8_t *) NULL;
}
+#elif defined(DUK_USE_ZERO_BUFFER_DATA)
+ /* buffer is automatically zeroed */
+#else
+ DUK_MEMZERO((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved);
#endif
DUK_DDD(DUK_DDDPRINT("regexp ctx initialized, flags=0x%08lx, nsaved=%ld, recursion_limit=%ld, steps_limit=%ld",
diff --git a/javascript/duktape/duktape.h b/content/handlers/javascript/duktape/duktape.h
similarity index 98%
rename from javascript/duktape/duktape.h
rename to content/handlers/javascript/duktape/duktape.h
index a727187..eb47a70 100644
--- a/javascript/duktape/duktape.h
+++ b/content/handlers/javascript/duktape/duktape.h
@@ -1,13 +1,13 @@
/*
- * Duktape public API for Duktape 1.5.0.
+ * Duktape public API for Duktape 1.6.0.
*
* See the API reference for documentation on call semantics.
* The exposed API is inside the DUK_API_PUBLIC_H_INCLUDED
* include guard. Other parts of the header are Duktape
* internal and related to platform/compiler/feature detection.
*
- * Git commit 83d557704ee63f68ab40b6fcb00995c9b3d6777c (v1.5.0).
- * Git branch master.
+ * Git commit 17e3d86cf8b4788bd0d37658f833ab440ce43a1c (v1.6.0).
+ * Git branch HEAD.
*
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and
* licensing information.
@@ -163,6 +163,7 @@ extern "C" {
* in Duktape web documentation.
*/
+struct duk_thread_state;
struct duk_memory_functions;
struct duk_function_list_entry;
struct duk_number_list_entry;
@@ -170,6 +171,7 @@ struct duk_number_list_entry;
/* duk_context is now defined in duk_config.h because it may also be
* referenced there by prototypes.
*/
+typedef struct duk_thread_state duk_thread_state;
typedef struct duk_memory_functions duk_memory_functions;
typedef struct duk_function_list_entry duk_function_list_entry;
typedef struct duk_number_list_entry duk_number_list_entry;
@@ -190,6 +192,14 @@ typedef void (*duk_debug_write_flush_function) (void *udata);
typedef duk_idx_t (*duk_debug_request_function) (duk_context *ctx, void *udata, duk_idx_t nvalues);
typedef void (*duk_debug_detached_function) (void *udata);
+struct duk_thread_state {
+ /* XXX: Enough space to hold internal suspend/resume structure.
+ * This is rather awkward and to be fixed when the internal
+ * structure is visible for the public API header.
+ */
+ char data[128];
+};
+
struct duk_memory_functions {
duk_alloc_function alloc_func;
duk_realloc_function realloc_func;
@@ -218,16 +228,16 @@ struct duk_number_list_entry {
* have 99 for patch level (e.g. 0.10.99 would be a development version
* after 0.10.0 but before the next official release).
*/
-#define DUK_VERSION 10500L
+#define DUK_VERSION 10600L
/* Git commit, describe, and branch for Duktape build. Useful for
* non-official snapshot builds so that application code can easily log
* which Duktape snapshot was used. Not available in the Ecmascript
* environment.
*/
-#define DUK_GIT_COMMIT "83d557704ee63f68ab40b6fcb00995c9b3d6777c"
-#define DUK_GIT_DESCRIBE "v1.5.0"
-#define DUK_GIT_BRANCH "master"
+#define DUK_GIT_COMMIT "17e3d86cf8b4788bd0d37658f833ab440ce43a1c"
+#define DUK_GIT_DESCRIBE "v1.6.0"
+#define DUK_GIT_BRANCH "HEAD"
/* Duktape debug protocol version used by this build. */
#define DUK_DEBUG_PROTOCOL_VERSION 1
@@ -397,6 +407,9 @@ duk_context *duk_create_heap(duk_alloc_function alloc_func,
duk_fatal_function fatal_handler);
DUK_EXTERNAL_DECL void duk_destroy_heap(duk_context *ctx);
+DUK_EXTERNAL_DECL void duk_suspend(duk_context *ctx, duk_thread_state *state);
+DUK_EXTERNAL_DECL void duk_resume(duk_context *ctx, const duk_thread_state *state);
+
#define duk_create_heap_default() \
duk_create_heap(NULL, NULL, NULL, NULL, NULL)
@@ -426,7 +439,7 @@ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_raw(duk_context *ctx, duk_errc
#ifdef DUK_API_VARIADIC_MACROS
#define duk_error(ctx,err_code,...) \
- duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), __VA_ARGS__)
+ duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)
#else
DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));
/* One problem with this macro is that expressions like the following fail
@@ -434,14 +447,14 @@ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_er
* they make little sense anyway.
*/
#define duk_error \
- (duk_api_global_filename = (const char *) (__FILE__), \
- duk_api_global_line = (duk_int_t) (__LINE__), \
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
duk_error_stash) /* last value is func pointer, arguments follow in parens */
#endif
DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap));
#define duk_error_va(ctx,err_code,fmt,ap) \
- duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), (fmt), (ap))
+ duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))
/*
* Other state related functions
@@ -547,19 +560,19 @@ DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_raw(duk_context *ctx, duk_errc
#ifdef DUK_API_VARIADIC_MACROS
#define duk_push_error_object(ctx,err_code,...) \
- duk_push_error_object_raw((ctx), (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), __VA_ARGS__)
+ duk_push_error_object_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)
#else
DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);
/* Note: parentheses are required so that the comma expression works in assignments. */
#define duk_push_error_object \
- (duk_api_global_filename = (const char *) (__FILE__), \
- duk_api_global_line = (duk_int_t) (__LINE__), \
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
duk_push_error_object_stash) /* last value is func pointer, arguments follow in parens */
#endif
DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap);
#define duk_push_error_object_va(ctx,err_code,fmt,ap) \
- duk_push_error_object_va_raw((ctx), (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), (fmt), (ap))
+ duk_push_error_object_va_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))
#define DUK_BUF_FLAG_DYNAMIC (1 << 0) /* internal flag: dynamic buffer */
#define DUK_BUF_FLAG_EXTERNAL (1 << 1) /* internal flag: external buffer */
diff --git a/javascript/duktape/netsurf.bnd b/content/handlers/javascript/duktape/netsurf.bnd
similarity index 100%
rename from javascript/duktape/netsurf.bnd
rename to content/handlers/javascript/duktape/netsurf.bnd
diff --git a/javascript/fetcher.c b/content/handlers/javascript/fetcher.c
similarity index 100%
rename from javascript/fetcher.c
rename to content/handlers/javascript/fetcher.c
diff --git a/javascript/fetcher.h b/content/handlers/javascript/fetcher.h
similarity index 100%
rename from javascript/fetcher.h
rename to content/handlers/javascript/fetcher.h
diff --git a/javascript/js.h b/content/handlers/javascript/js.h
similarity index 100%
rename from javascript/js.h
rename to content/handlers/javascript/js.h
diff --git a/javascript/none/Makefile b/content/handlers/javascript/none/Makefile
similarity index 100%
rename from javascript/none/Makefile
rename to content/handlers/javascript/none/Makefile
diff --git a/javascript/none/none.c b/content/handlers/javascript/none/none.c
similarity index 100%
rename from javascript/none/none.c
rename to content/handlers/javascript/none/none.c
diff --git a/content/hlcache.c b/content/hlcache.c
index 06d9f6d..95edd21 100644
--- a/content/hlcache.c
+++ b/content/hlcache.c
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * High-level resource cache (implementation)
+/**
+ * \file
+ * High-level resource cache implementation.
*/
#include <assert.h>
@@ -29,10 +30,10 @@
#include "utils/messages.h"
#include "utils/ring.h"
#include "utils/utils.h"
-#include "desktop/gui_misc.h"
+#include "netsurf/misc.h"
+#include "netsurf/content.h"
#include "desktop/gui_internal.h"
-#include "content/content.h"
#include "content/mimesniff.h"
#include "content/hlcache.h"
@@ -86,7 +87,7 @@ struct hlcache_s {
/** Ring of retrieval contexts */
hlcache_retrieval_ctx *retrieval_ctx_ring;
- /* statsistics */
+ /* statistics */
unsigned int hit_count;
unsigned int miss_count;
};
@@ -665,12 +666,12 @@ nserror hlcache_handle_retrieve(nsurl *url, uint32_t flags,
hlcache_llcache_callback, ctx,
&ctx->llcache);
if (error != NSERROR_OK) {
- /* error retriving handle so free context and return error */
+ /* error retrieving handle so free context and return error */
free((char *) ctx->child.charset);
free(ctx->handle);
free(ctx);
} else {
- /* successfuly started fetch so add new context to list */
+ /* successfully started fetch so add new context to list */
RING_INSERT(hlcache->retrieval_ctx_ring, ctx);
*result = ctx->handle;
diff --git a/content/hlcache.h b/content/hlcache.h
index e0bf416..3d9f41c 100644
--- a/content/hlcache.h
+++ b/content/hlcache.h
@@ -39,7 +39,7 @@ typedef struct hlcache_child_context {
} hlcache_child_context;
/** High-level cache event */
-typedef struct {
+typedef struct hlcache_event {
content_msg type; /**< Event type */
union content_msg_data data; /**< Event data */
} hlcache_event;
@@ -175,12 +175,5 @@ struct content *hlcache_handle_get_content(const hlcache_handle *handle);
*/
nserror hlcache_handle_clone(hlcache_handle *handle, hlcache_handle **result);
-/**
- * Retrieve the URL associated with a high level cache handle
- *
- * \param handle The handle to inspect
- * \return Pointer to URL.
- */
-nsurl *hlcache_handle_get_url(const hlcache_handle *handle);
#endif
diff --git a/content/llcache.c b/content/llcache.c
index 9381ce9..4bd6eb3 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -22,7 +22,7 @@
* Low-level resource cache implementation
*
* This is the implementation of the low level cache. This cache
- * stores source objects in memory and may use a persistant backing
+ * stores source objects in memory and may use a persistent backing
* store to extend their lifetime.
*
* \todo fix writeout conditions and ordering.
@@ -47,7 +47,7 @@
#include "utils/nsurl.h"
#include "utils/utils.h"
#include "utils/time.h"
-#include "desktop/gui_misc.h"
+#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "content/fetch.h"
@@ -201,8 +201,8 @@ struct llcache_object {
llcache_header *headers; /**< Fetch headers */
size_t num_headers; /**< Number of fetch headers */
- /* Instrumentation. These elemnts are strictly for information
- * to improve the cache performance and to provide performace
+ /* Instrumentation. These elements are strictly for information
+ * to improve the cache performance and to provide performance
* metrics. The values are non-authorative and must not be used to
* determine object lifetime etc.
*/
@@ -268,7 +268,7 @@ struct llcache_s {
uint64_t total_written;
/**
- * Total nuber of miliseconds taken to write to backing store.
+ * Total number of milliseconds taken to write to backing store.
*/
uint64_t total_elapsed;
@@ -804,7 +804,7 @@ static nserror llcache_fetch_process_header(llcache_object *object,
*
* sets up headers and attempts to start an actual fetch from the
* fetchers system updating the llcache object with the new fetch on
- * sucessful start.
+ * successful start.
*
* \pre The fetch parameters in object->fetch must be populated
*
@@ -876,7 +876,7 @@ static nserror llcache_object_refetch(llcache_object *object)
/* Reset fetch state */
object->fetch.state = LLCACHE_FETCH_INIT;
- LLCACHE_LOG("Refetching %p", object);
+ LLCACHE_LOG("Re-fetching %p", object);
/* Kick off fetch */
res = fetch_start(object->url,
@@ -1173,27 +1173,27 @@ llcache_object_remove_from_list(llcache_object *object, llcache_object **list)
}
/**
- * Retrieve source data for an object from persistant store if necessary.
+ * Retrieve source data for an object from persistent store if necessary.
*
- * If an objects source data has been placed in the persistant store
- * and the in memory copy released this will attempt to retrive the
+ * If an objects source data has been placed in the persistent store
+ * and the in memory copy released this will attempt to retrieve the
* source data.
*
* \param object the object to operate on.
- * \return apropriate error code.
+ * \return appropriate error code.
*/
static nserror llcache_persist_retrieve(llcache_object *object)
{
/* ensure the source data is present if necessary */
if ((object->source_data != NULL) ||
(object->store_state != LLCACHE_STATE_DISC)) {
- /* source data does not require retriving from
- * persistant store.
+ /* source data does not require retrieving from
+ * persistent store.
*/
return NSERROR_OK;
}
- /* Source data for the object may be in the persiatant store */
+ /* Source data for the object may be in the persistent store */
return guit->llcache->fetch(object->url,
BACKING_STORE_NONE,
&object->source_data,
@@ -1205,7 +1205,7 @@ static nserror llcache_persist_retrieve(llcache_object *object)
*
* The metadata includes object headers.
*
- * \param object The cache object to serialise teh metadata of.
+ * \param object The cache object to serialise the metadata of.
* \param data_out Where the serialised buffer will be placed.
* \param datasize_out The size of the serialised data.
* \return NSERROR_OK on success with \a data_out and \a datasize_out
@@ -1347,15 +1347,15 @@ operror:
/**
* Deserialisation of an objects metadata.
*
- * Attempt to retrive and deserialise the metadata for an object from
+ * Attempt to retrieve and deserialise the metadata for an object from
* the backing store.
*
- * This must only update object if it is sucessful otherwise difficult
+ * This must only update object if it is successful otherwise difficult
* to debug crashes happen later by using bad leftover object state.
*
* \param object The object to retrieve the metadata for.
- * \return NSERROR_OK if the metatdata was retrived and deserialised
- * or error code if url is not in persistant storage or in
+ * \return NSERROR_OK if the metatdata was retrieved and deserialised
+ * or error code if URL is not in persistent storage or in
* event of deserialisation error.
*/
static nserror
@@ -1376,7 +1376,7 @@ llcache_process_metadata(llcache_object *object)
size_t num_headers;
size_t hloop;
- LOG("Retriving metadata");
+ LOG("Retrieving metadata");
/* attempt to retrieve object metadata from the backing store */
res = guit->llcache->fetch(object->url,
@@ -1387,7 +1387,7 @@ llcache_process_metadata(llcache_object *object)
return res;
}
- LOG("Processing retrived data");
+ LOG("Processing retrieved data");
/* metadata line 1 is the url the metadata referrs to */
line = 1;
@@ -1405,7 +1405,7 @@ llcache_process_metadata(llcache_object *object)
if (nsurl_compare(object->url, metadataurl, NSURL_COMPLETE) != true) {
/* backing store returned the wrong object for the
- * request. This may occour if the backing store had
+ * request. This may occur if the backing store had
* a collision in its storage method. We cope with this
* by simply skipping caching of this object.
*/
@@ -1511,14 +1511,14 @@ format_error:
}
/**
- * Attempt to retrieve an object from persistant storage.
+ * Attempt to retrieve an object from persistent storage.
*
- * \param object The object to populate from persistant store.
+ * \param object The object to populate from persistent store.
* \param flags Fetch flags.
* \param referer The referring url.
* \param post Post data for fetch.
* \param redirect_count how many times this fetch has been redirected.
- * \return NSERROR_OK if the object was sucessfully retrived from the
+ * \return NSERROR_OK if the object was successfully retrieved from the
* cache else appropriate error code.
*/
static nserror
@@ -1572,7 +1572,7 @@ llcache_object_fetch_persistant(llcache_object *object,
* \param referer Referring URL, or NULL if none
* \param post POST data, or NULL for a GET request
* \param redirect_count Number of redirects followed so far
- * \param result Pointer to location to recieve retrieved object
+ * \param result Pointer to location to receive retrieved object
* \return NSERROR_OK on success, appropriate error otherwise
*/
static nserror
@@ -1602,7 +1602,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
}
/* No viable object found in cache create one and attempt to
- * pull from persistant store.
+ * pull from persistent store.
*/
if (newest == NULL) {
LLCACHE_LOG("No viable object found in llcache");
@@ -1611,12 +1611,12 @@ llcache_object_retrieve_from_cache(nsurl *url,
if (error != NSERROR_OK)
return error;
- /* attempt to retrieve object from persistant store */
+ /* attempt to retrieve object from persistent store */
error = llcache_object_fetch_persistant(obj, flags, referer, post, redirect_count);
if (error == NSERROR_OK) {
- LLCACHE_LOG("retrived object from persistant store");
+ LLCACHE_LOG("retrieved object from persistent store");
- /* set newest object from persistant store which
+ /* set newest object from persistent store which
* will cause the normal object handling to be used.
*/
newest = obj;
@@ -1625,7 +1625,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
llcache_object_add_to_list(obj, &llcache->cached_objects);
}
- /* else no object found and unretrivable from cache,
+ /* else no object found and irretrievable from cache,
* fall through with newest unset to start fetch
*/
}
@@ -1641,19 +1641,19 @@ llcache_object_retrieve_from_cache(nsurl *url,
/* ensure the source data is present */
error = llcache_persist_retrieve(newest);
if (error == NSERROR_OK) {
- /* source data was sucessfully retrived from
- * persistant store
+ /* source data was successfully retrieved from
+ * persistent store
*/
*result = newest;
return NSERROR_OK;
}
- /* retrival of source data from persistant store
+ /* retrieval of source data from persistent store
* failed, destroy cache object and fall though to
* cache miss to re-fetch
*/
- LLCACHE_LOG("Persistant retrival failed for %p", newest);
+ LLCACHE_LOG("Persistent retrieval failed for %p", newest);
llcache_object_remove_from_list(newest, &llcache->cached_objects);
llcache_object_destroy(newest);
@@ -1704,9 +1704,9 @@ llcache_object_retrieve_from_cache(nsurl *url,
return NSERROR_OK;
}
- LLCACHE_LOG("Persistant retrival failed for %p", newest);
+ LLCACHE_LOG("Persistent retrieval failed for %p", newest);
- /* retrival of source data from persistant store
+ /* retrieval of source data from persistent store
* failed, destroy cache object and fall though to
* cache miss to re-retch
*/
@@ -1743,7 +1743,7 @@ llcache_object_retrieve_from_cache(nsurl *url,
* \param referer Referring URL, or NULL if none
* \param post POST data, or NULL for a GET request
* \param redirect_count Number of redirects followed so far
- * \param result Pointer to location to recieve retrieved object
+ * \param result Pointer to location to receive retrieved object
* \return NSERROR_OK on success, appropriate error otherwise
*/
static nserror
@@ -2214,6 +2214,11 @@ static nserror llcache_fetch_auth(llcache_object *object, const char *realm)
error = llcache->query_cb(&query, llcache->query_cb_pw,
llcache_query_handle_response, object);
+ if (error != NSERROR_OK) {
+ /* do not continue if error querying user */
+ error = llcache_query_handle_response(false,
+ object);
+ }
} else {
llcache_event event;
@@ -2269,6 +2274,10 @@ static nserror llcache_fetch_cert_error(llcache_object *object,
error = llcache->query_cb(&query, llcache->query_cb_pw,
llcache_query_handle_response, object);
+ if (error != NSERROR_OK) {
+ /* do not continue if error querying user */
+ error = llcache_query_handle_response(false, object);
+ }
} else {
llcache_event event;
@@ -2363,7 +2372,7 @@ build_candidate_list(struct llcache_object ***lst_out, int *lst_len_out)
/* cacehable objects with no pending fetches, not
* already on disc and with sufficient lifetime to
- * make disc cache worthwile
+ * make disc cache worthwhile
*/
if ((object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
@@ -2517,20 +2526,20 @@ static void llcache_persist(void *p)
ret = build_candidate_list(&lst, &lst_count);
if (ret != NSERROR_OK) {
- LLCACHE_LOG("Unable to construct candidate list for persisatnt writeout");
+ LLCACHE_LOG("Unable to construct candidate list for persistent writeout");
return;
}
write_limit = (llcache->maximum_bandwidth * llcache->time_quantum) / 1000;
- /* obtained a candidate list, make each object persistant in turn */
+ /* obtained a candidate list, make each object persistent in turn */
for (idx = 0; idx < lst_count; idx++) {
ret = write_backing_store(lst[idx], &written, &elapsed);
if (ret != NSERROR_OK) {
continue;
}
- /* sucessfully wrote object to backing store */
+ /* successfully wrote object to backing store */
total_written += written;
total_elapsed += elapsed;
total_bandwidth = (total_written * 1000) / total_elapsed;
@@ -3129,7 +3138,7 @@ llcache_object_snapshot(llcache_object *object, llcache_object **snapshot)
/**
* total ram usage of object
*
- * \param object The object to caclulate the total RAM usage of.
+ * \param object The object to calculate the total RAM usage of.
* \return The total RAM usage in bytes.
*/
static inline uint32_t
@@ -3244,7 +3253,7 @@ void llcache_clean(bool purge)
}
/* if the cache limit is exceeded try to make some objects
- * persistant so their RAM can be reclaimed in the next
+ * persistent so their RAM can be reclaimed in the next
* step
*/
if (limit < llcache_size) {
@@ -3252,7 +3261,7 @@ void llcache_clean(bool purge)
}
/* Source data of fresh cacheable objects with no users, no
- * pending fetches and pushed to persistant store while the
+ * pending fetches and pushed to persistent store while the
* cache exceeds the configured size.
*/
for (object = llcache->cached_objects;
@@ -3277,8 +3286,8 @@ void llcache_clean(bool purge)
}
/* Fresh cacheable objects with no users, no pending fetches
- * and pushed to persistant store while the cache exceeds
- * the configured size. Efectively just the llcache object metadata.
+ * and pushed to persistent store while the cache exceeds
+ * the configured size. Effectively just the llcache object metadata.
*/
for (object = llcache->cached_objects;
((limit < llcache_size) && (object != NULL));
@@ -3308,7 +3317,7 @@ void llcache_clean(bool purge)
/* Fresh cacheable objects with no users or pending fetches
* while the cache exceeds the configured size. These are the
- * most valuble objects as replacing them is a full network
+ * most valuable objects as replacing them is a full network
* fetch
*/
for (object = llcache->cached_objects;
diff --git a/content/llcache.h b/content/llcache.h
index cce9a79..796db66 100644
--- a/content/llcache.h
+++ b/content/llcache.h
@@ -37,7 +37,7 @@ struct fetch_multipart_data;
typedef struct llcache_handle llcache_handle;
/** POST data object for low-level cache requests */
-typedef struct {
+typedef struct llcache_post_data {
enum {
LLCACHE_POST_URL_ENCODED,
LLCACHE_POST_MULTIPART
diff --git a/content/urldb.c b/content/urldb.c
index 0b59e1f..b6eaf63 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -88,13 +88,15 @@
*/
#include <assert.h>
-#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <time.h>
+#ifdef WITH_NSPSL
+#include <nspsl.h>
+#endif
#include "utils/inet.h"
#include "utils/nsoption.h"
@@ -104,14 +106,25 @@
#include "utils/utils.h"
#include "utils/bloom.h"
#include "utils/time.h"
-#include "image/bitmap.h"
+#include "utils/nsurl.h"
+#include "utils/ascii.h"
+#include "netsurf/bitmap.h"
#include "desktop/cookie_manager.h"
#include "desktop/gui_internal.h"
#include "content/content.h"
#include "content/urldb.h"
+/**
+ * cookie entry.
+ *
+ * \warn This *must* be kept in sync with the public interface in
+ * netsurf/cookie_db.h
+ */
struct cookie_internal_data {
+ struct cookie_internal_data *prev; /**< Previous in list */
+ struct cookie_internal_data *next; /**< Next in list */
+
char *name; /**< Cookie name */
char *value; /**< Cookie value */
bool value_was_quoted; /**< Value was quoted in Set-Cookie: */
@@ -124,12 +137,10 @@ struct cookie_internal_data {
time_t last_used; /**< Last used time */
bool secure; /**< Only send for HTTPS requests */
bool http_only; /**< Only expose to HTTP(S) requests */
- cookie_version version; /**< Specification compliance */
+ enum cookie_version version; /**< Specification compliance */
bool no_destroy; /**< Never destroy this cookie,
* unless it's expired */
- struct cookie_internal_data *prev; /**< Previous in list */
- struct cookie_internal_data *next; /**< Next in list */
};
/* A protection space is defined as a tuple canonical_root_url and realm.
@@ -1021,10 +1032,11 @@ static struct search_node **urldb_get_search_tree_direct(const char *host)
{
assert(host);
- if (urldb__host_is_ip_address(host))
+ if (urldb__host_is_ip_address(host)) {
return &search_trees[ST_IP];
- else if (isalpha(*host))
- return &search_trees[ST_DN + tolower(*host) - 'a'];
+ } else if (ascii_is_alpha(*host)) {
+ return &search_trees[ST_DN + ascii_to_lower(*host) - 'a'];
+ }
return &search_trees[ST_EE];
}
@@ -1341,25 +1353,37 @@ static void urldb_dump_hosts(struct host_part *parent)
static void urldb_dump_search(struct search_node *parent, int depth)
{
const struct host_part *h;
- int i;
-
+ int i; /* index into string */
+ char s[1024];
+ int r;
+ int sl = sizeof(s) - 2;
+
if (parent == &empty)
return;
urldb_dump_search(parent->left, depth + 1);
- for (i = 0; i != depth; i++)
- fputc(' ', stderr);
+ for (i = 0; i != depth; i++) {
+ s[i] = ' ';
+ }
for (h = parent->data; h; h = h->parent) {
- if (h->part)
- fprintf(stderr, "%s", h->part);
+ if (h->part) {
+ r = snprintf(&s[i], sl - i, "%s", h->part);
+ if ((i + r) > sl) {
+ break;
+ }
+ i += r;
+ }
- if (h->parent && h->parent->parent)
- fputc('.', stderr);
+ if (h->parent && h->parent->parent) {
+ s[i]='.';
+ i++;
+ }
}
+ s[i]= 0;
- fputc('\n', stderr);
+ LOG("%s", s);
urldb_dump_search(parent->right, depth + 1);
}
@@ -1593,9 +1617,11 @@ static bool urldb_parse_avpair(struct cookie_internal_data *c, char *n,
/* Strip dayname from date (these are hugely variable
* and liable to break the parser. They also serve no
* useful purpose) */
- for (datenoday = v; *datenoday && !isdigit(*datenoday);
- datenoday++)
- ; /* do nothing */
+ for (datenoday = v;
+ *datenoday && !ascii_is_digit(*datenoday);
+ datenoday++) {
+ /* do nothing */
+ }
res = nsc_strntimet(datenoday, strlen(datenoday), &expires);
if (res != NSERROR_OK) {
@@ -2466,8 +2492,10 @@ void urldb_destroy(void)
/* Clean up search trees */
for (i = 0; i < NUM_SEARCH_TREES; i++) {
- if (search_trees[i] != &empty)
+ if (search_trees[i] != &empty) {
urldb_destroy_search_tree(search_trees[i]);
+ search_trees[i] = ∅
+ }
}
/* And database */
@@ -2475,10 +2503,13 @@ void urldb_destroy(void)
b = a->next;
urldb_destroy_host_tree(a);
}
+ memset(&db_root, 0, sizeof(db_root));
/* And the bloom filter */
- if (url_bloom != NULL)
+ if (url_bloom != NULL) {
bloom_destroy(url_bloom);
+ url_bloom = NULL;
+ }
}
@@ -2787,8 +2818,16 @@ bool urldb_add_url(nsurl *url)
h = urldb_add_host(host_str);
/* Get path entry */
- p = (h != NULL) ? urldb_add_path(scheme, port_int, h, path_query,
- fragment, url) : NULL;
+ if (h != NULL) {
+ p = urldb_add_path(scheme,
+ port_int,
+ h,
+ path_query,
+ fragment,
+ url);
+ } else {
+ p = NULL;
+ }
lwc_string_unref(scheme);
if (fragment != NULL)
@@ -3060,23 +3099,29 @@ bool urldb_get_cert_permissions(nsurl *url)
/* exported interface documented in content/urldb.h */
-void urldb_set_thumbnail(nsurl *url, struct bitmap *bitmap)
+bool urldb_set_thumbnail(nsurl *url, struct bitmap *bitmap)
{
struct path_data *p;
assert(url);
- p = urldb_find_url(url);
- if (p != NULL) {
+ /* add url, in case it's missing */
+ urldb_add_url(url);
- LOG("Setting bitmap on %s", nsurl_access(url));
+ p = urldb_find_url(url);
+ if (p == NULL) {
+ return false;
+ }
- if (p->thumb && p->thumb != bitmap) {
- guit->bitmap->destroy(p->thumb);
- }
+ LOG("Setting bitmap on %s", nsurl_access(url));
- p->thumb = bitmap;
+ if ((p->thumb) && (p->thumb != bitmap)) {
+ guit->bitmap->destroy(p->thumb);
}
+
+ p->thumb = bitmap;
+
+ return true;
}
@@ -3311,6 +3356,7 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
do {
struct cookie_internal_data *c;
+ const char *suffix;
char *dot;
size_t len;
@@ -3337,6 +3383,19 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
goto error;
}
+#ifdef WITH_NSPSL
+ /* check domain is not a public suffix */
+ dot = c->domain;
+ if (*dot == '.') {
+ dot++;
+ }
+ suffix = nspsl_getpublicsuffix(dot);
+ if (suffix == NULL) {
+ LOG("domain %s was a public suffix domain", dot);
+ urldb_free_cookie(c);
+ goto error;
+ }
+#else
/* 4.3.2:ii Cookie domain must contain embedded dots */
dot = strchr(c->domain + 1, '.');
if (!dot || *(dot + 1) == '\0') {
@@ -3344,6 +3403,7 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
urldb_free_cookie(c);
goto error;
}
+#endif
/* Domain match fetch host with cookie domain */
if (strcasecmp(lwc_string_data(host), c->domain) != 0) {
diff --git a/content/urldb.h b/content/urldb.h
index d7ca8b0..9ff3a8d 100644
--- a/content/urldb.h
+++ b/content/urldb.h
@@ -16,53 +16,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Unified URL information database (interface)
+/**
+ * \file
+ * Unified URL information database internal interface.
*/
#ifndef _NETSURF_CONTENT_URLDB_H_
#define _NETSURF_CONTENT_URLDB_H_
-#include <stdbool.h>
-#include <time.h>
-#include "utils/nsurl.h"
-#include "content/content_type.h"
-
-typedef enum {
- COOKIE_NETSCAPE = 0,
- COOKIE_RFC2109 = 1,
- COOKIE_RFC2965 = 2
-} cookie_version;
-
-struct url_data {
- const char *title; /**< Resource title */
- unsigned int visits; /**< Visit count */
- time_t last_visit; /**< Last visit time */
- content_type type; /**< Type of resource */
-};
-
-struct cookie_data {
- const char *name; /**< Cookie name */
- const char *value; /**< Cookie value */
- const bool value_was_quoted; /**< Value was quoted in Set-Cookie: */
- const char *comment; /**< Cookie comment */
- const bool domain_from_set; /**< Domain came from Set-Cookie: header */
- const char *domain; /**< Domain */
- const bool path_from_set; /**< Path came from Set-Cookie: header */
- const char *path; /**< Path */
- const time_t expires; /**< Expiry timestamp, or 1 for session */
- const time_t last_used; /**< Last used time */
- const bool secure; /**< Only send for HTTPS requests */
- const bool http_only; /**< Only expose to HTTP(S) requests */
- cookie_version version; /**< Specification compliance */
- const bool no_destroy; /**< Never destroy this cookie,
- * unless it's expired */
-
- const struct cookie_data *prev; /**< Previous in list */
- const struct cookie_data *next; /**< Next in list */
-};
-
-struct bitmap;
+#include <libwapcaplet/libwapcaplet.h>
+
+#include "netsurf/url_db.h"
+#include "netsurf/cookie_db.h"
/**
* Destroy urldb
@@ -70,32 +35,14 @@ struct bitmap;
void urldb_destroy(void);
-/* Persistence support */
-
-/**
- * Import an URL database from file, replacing any existing database
- *
- * \param filename Name of file containing data
- */
-nserror urldb_load(const char *filename);
-
-/**
- * Export the current database to file
- *
- * \param filename Name of file to export to
- */
-nserror urldb_save(const char *filename);
-
/**
* Set the cross-session persistence of the entry for an URL
*
* \param url Absolute URL to persist
* \param persist True to persist, false otherwise
*/
-void urldb_set_url_persistence(nsurl *url, bool persist);
-
+void urldb_set_url_persistence(struct nsurl *url, bool persist);
-/* URL insertion */
/**
* Insert an URL into the database
@@ -103,10 +50,8 @@ void urldb_set_url_persistence(nsurl *url, bool persist);
* \param url Absolute URL to insert
* \return true on success, false otherwise
*/
-bool urldb_add_url(nsurl *url);
-
+bool urldb_add_url(struct nsurl *url);
-/* URL data modification / lookup */
/**
* Set an URL's title string, replacing any existing one
@@ -114,7 +59,8 @@ bool urldb_add_url(nsurl *url);
* \param url The URL to look for
* \param title The title string to use (copied)
*/
-void urldb_set_url_title(nsurl *url, const char *title);
+void urldb_set_url_title(struct nsurl *url, const char *title);
+
/**
* Set an URL's content type
@@ -122,29 +68,24 @@ void urldb_set_url_title(nsurl *url, const char *title);
* \param url The URL to look for
* \param type The type to set
*/
-void urldb_set_url_content_type(nsurl *url, content_type type);
+void urldb_set_url_content_type(struct nsurl *url, content_type type);
+
/**
* Update an URL's visit data
*
* \param url The URL to update
*/
-void urldb_update_url_visit_data(nsurl *url);
+void urldb_update_url_visit_data(struct nsurl *url);
+
/**
* Reset an URL's visit statistics
*
* \param url The URL to reset
*/
-void urldb_reset_url_visit_data(nsurl *url);
+void urldb_reset_url_visit_data(struct nsurl *url);
-/**
- * Find data for an URL.
- *
- * \param url Absolute URL to look for
- * \return Pointer to result struct, or NULL
- */
-const struct url_data *urldb_get_url_data(nsurl *url);
/**
* Extract an URL from the db
@@ -152,41 +93,9 @@ const struct url_data *urldb_get_url_data(nsurl *url);
* \param url URL to extract
* \return Pointer to database's copy of URL or NULL if not found
*/
-nsurl *urldb_get_url(nsurl *url);
-
-
-/* Authentication modification / lookup */
-
-/**
- * Set authentication data for an URL
- *
- * \param url The URL to consider
- * \param realm The authentication realm
- * \param auth The authentication details (in form username:password)
- */
-void urldb_set_auth_details(nsurl *url, const char *realm, const char *auth);
-
-/**
- * Look up authentication details in database
- *
- * \param url Absolute URL to search for
- * \param realm When non-NULL, it is realm which can be used to determine
- * the protection space when that's not been done before for given URL.
- * \return Pointer to authentication details, or NULL if not found
- */
-const char *urldb_get_auth_details(nsurl *url, const char *realm);
+struct nsurl *urldb_get_url(struct nsurl *url);
-/* SSL certificate permissions */
-
-/**
- * Set certificate verification permissions
- *
- * \param url URL to consider
- * \param permit Set to true to allow invalid certificates
- */
-void urldb_set_cert_permissions(nsurl *url, bool permit);
-
/**
* Retrieve certificate verification permissions from database
*
@@ -194,59 +103,18 @@ void urldb_set_cert_permissions(nsurl *url, bool permit);
* \return true to permit connections to hosts with invalid certificates,
* false otherwise.
*/
-bool urldb_get_cert_permissions(nsurl *url);
+bool urldb_get_cert_permissions(struct nsurl *url);
-/* Thumbnail handling */
-
/**
* Set thumbnail for url, replacing any existing thumbnail
*
* \param url Absolute URL to consider
* \param bitmap Opaque pointer to thumbnail data, or NULL to invalidate
+ * \return true on sucessful setting else false
*/
-void urldb_set_thumbnail(nsurl *url, struct bitmap *bitmap);
+bool urldb_set_thumbnail(struct nsurl *url, struct bitmap *bitmap);
-/**
- * Retrieve thumbnail data for given URL
- *
- * \param url Absolute URL to search for
- * \return Pointer to thumbnail data, or NULL if not found.
- */
-struct bitmap *urldb_get_thumbnail(nsurl *url);
-
-
-/* URL completion */
-
-/**
- * Iterate over entries in the database which match the given prefix
- *
- * \param prefix Prefix to match
- * \param callback Callback function
- */
-void urldb_iterate_partial(const char *prefix,
- bool (*callback)(nsurl *url, const struct url_data *data));
-
-
-/* Iteration */
-
-/**
- * Iterate over all entries in database
- *
- * \param callback Function to callback for each entry
- */
-void urldb_iterate_entries(bool (*callback)(nsurl *url,
- const struct url_data *data));
-
-/**
- * Iterate over all cookies in database
- *
- * \param callback Function to callback for each entry
- */
-void urldb_iterate_cookies(bool (*callback)(const struct cookie_data *cookie));
-
-
-/* Cookies */
/**
* Parse Set-Cookie header and insert cookie(s) into database
@@ -256,7 +124,8 @@ void urldb_iterate_cookies(bool (*callback)(const struct cookie_data *cookie));
* \param referer Referring resource, or 0 for verifiable transaction
* \return true on success, false otherwise
*/
-bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer);
+bool urldb_set_cookie(const char *header, struct nsurl *url, struct nsurl *referer);
+
/**
* Retrieve cookies for an URL
@@ -265,41 +134,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer);
* \param include_http_only Whether to include HTTP(S) only cookies.
* \return Cookies string for libcurl (on heap), or NULL on error/no cookies
*/
-char *urldb_get_cookie(nsurl *url, bool include_http_only);
+char *urldb_get_cookie(struct nsurl *url, bool include_http_only);
-/**
- * Delete a cookie
- *
- * \param domain The cookie's domain
- * \param path The cookie's path
- * \param name The cookie's name
- */
-void urldb_delete_cookie(const char *domain, const char *path, const char *name);
-
-/**
- * Load a cookie file into the database
- *
- * \param filename File to load
- */
-void urldb_load_cookies(const char *filename);
-
-/**
- * Save persistent cookies to file
- *
- * \param filename Path to save to
- */
-void urldb_save_cookies(const char *filename);
-
-
-/* Debug */
-
-/**
- * Dump URL database to stderr
- */
-void urldb_dump(void);
-
-
-/* test harness only */
/**
* Add a host to the database, creating any intermediate entries
@@ -309,6 +145,7 @@ void urldb_dump(void);
*/
struct host_part *urldb_add_host(const char *host);
+
/**
* Add a path to the database, creating any intermediate entries
*
@@ -322,6 +159,7 @@ struct host_part *urldb_add_host(const char *host);
*/
struct path_data *urldb_add_path(lwc_string *scheme, unsigned int port,
const struct host_part *host, char *path_query,
- lwc_string *fragment, nsurl *url);
+ lwc_string *fragment, struct nsurl *url);
+
#endif
diff --git a/desktop/Makefile b/desktop/Makefile
index f7f660d..2dcd616 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -2,8 +2,8 @@
S_DESKTOP := cookie_manager.c knockout.c hotlist.c mouse.c \
plot_style.c print.c search.c searchweb.c scrollbar.c \
- sslcert_viewer.c textarea.c tree.c version.c \
- system_colour.c global_history.c treeview.c
+ sslcert_viewer.c textarea.c version.c system_colour.c \
+ global_history.c treeview.c
S_DESKTOP := $(addprefix desktop/,$(S_DESKTOP))
diff --git a/desktop/browser.c b/desktop/browser.c
index 4cd017d..d3648d7 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -47,16 +47,18 @@
#include "utils/utils.h"
#include "utils/utf8.h"
#include "utils/nsoption.h"
-#include "content/content.h"
+#include "netsurf/misc.h"
+#include "netsurf/window.h"
+#include "netsurf/content.h"
+#include "netsurf/plotters.h"
#include "content/content_debug.h"
#include "content/fetch.h"
#include "content/hlcache.h"
#include "content/urldb.h"
+#include "css/utils.h"
#include "render/form_internal.h"
#include "render/html.h"
#include "render/box.h"
-#include "curl/curl.h"
-#include "css/utils.h"
#include "javascript/js.h"
#include "desktop/browser_history.h"
@@ -68,11 +70,9 @@
#include "desktop/knockout.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
-#include "desktop/plotters.h"
#include "desktop/theme.h"
-#include "desktop/gui_misc.h"
-#include "desktop/gui_window.h"
#include "desktop/gui_internal.h"
+#include "desktop/textinput.h"
/** maximum frame depth */
@@ -497,7 +497,7 @@ char * browser_window_get_selection(struct browser_window *bw)
return content_get_selection(bw->selection.bw->current_content);
}
-/* exported interface, documented in desktop/browser.h */
+/* exported interface, documented in netsurf/browser_window.h */
bool browser_window_can_search(struct browser_window *bw)
{
if (bw == NULL || bw->current_content == NULL)
@@ -515,14 +515,14 @@ bool browser_window_can_search(struct browser_window *bw)
}
-/* exported interface, documented in desktop/browser.h */
+/* exported interface, documented in netsurf/browser_window.h */
bool browser_window_is_frameset(struct browser_window *bw)
{
return (bw->children != NULL);
}
-/* exported interface, documented in desktop/browser.h */
+/* exported interface, documented in netsurf/browser_window.h */
nserror browser_window_get_scrollbar_type(struct browser_window *bw,
browser_scrolling *h, browser_scrolling *v)
{
@@ -762,7 +762,7 @@ bool browser_window_drop_file_at_point(struct browser_window *bw,
return false;
}
-/* exported interface, documented in desktop/browser.h */
+/* exported interface, documented in netsurf/browser_window.h */
void browser_window_set_gadget_filename(struct browser_window *bw,
struct form_control *gadget, const char *fn)
{
@@ -802,7 +802,7 @@ static bool slow_script(void *ctx)
return true;
}
-/* exported interface, documented in desktop/browser.h */
+/* exported interface, documented in netsurf/browser_window.h */
nserror browser_window_create(enum browser_window_create_flags flags,
nsurl *url, nsurl *referrer,
struct browser_window *existing,
@@ -1872,7 +1872,7 @@ browser_window_refresh_url_bar_internal(struct browser_window *bw, nsurl *url)
}
-/* exported interface, documented in desktop/browser.h */
+/* exported interface, documented in netsurf/browser_window.h */
void browser_window_destroy(struct browser_window *bw)
{
/* can't destoy child windows on their own */
@@ -1883,7 +1883,7 @@ void browser_window_destroy(struct browser_window *bw)
free(bw);
}
-/* exported interface, documented in desktop/browser.h */
+/* exported interface, documented in netsurf/browser_window.h */
nserror browser_window_refresh_url_bar(struct browser_window *bw)
{
nserror ret;
@@ -1919,7 +1919,7 @@ nserror browser_window_refresh_url_bar(struct browser_window *bw)
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
nserror browser_window_navigate(struct browser_window *bw,
nsurl *url,
nsurl *referrer,
@@ -2343,7 +2343,7 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
}
}
-/* Exported interface, documented in desktop/browser.h */
+/* Exported interface, documented in netsurf/browser_window.h */
void browser_window_update_box(struct browser_window *bw, struct rect *rect)
{
int pos_x;
@@ -2370,7 +2370,7 @@ void browser_window_update_box(struct browser_window *bw, struct rect *rect)
}
}
-/* Exported interface, documented in desktop/browser.h */
+/* Exported interface, documented in netsurf/browser_window.h */
void browser_window_stop(struct browser_window *bw)
{
int children, index;
@@ -2411,7 +2411,7 @@ void browser_window_stop(struct browser_window *bw)
}
-/* Exported interface, documented in desktop/browser.h */
+/* Exported interface, documented in netsurf/browser_window.h */
void browser_window_reload(struct browser_window *bw, bool all)
{
hlcache_handle *c;
@@ -2457,7 +2457,7 @@ void browser_window_reload(struct browser_window *bw, bool all)
}
-/* Exported interface, documented in desktop/browser.h */
+/* Exported interface, documented in netsurf/browser_window.h */
void browser_window_set_status(struct browser_window *bw, const char *text)
{
int text_len;
@@ -2491,7 +2491,7 @@ void browser_window_set_status(struct browser_window *bw, const char *text)
}
-/* Exported interface, documented in desktop/browser.h */
+/* Exported interface, documented in netsurf/browser_window.h */
void browser_window_set_pointer(struct browser_window *bw,
browser_pointer_shape shape)
{
@@ -2530,7 +2530,7 @@ void browser_window_set_pointer(struct browser_window *bw,
guit->window->set_pointer(root->window, gui_shape);
}
-/* exported function documented in desktop/browser.h */
+/* exported function documented in netsurf/browser_window.h */
nserror browser_window_schedule_reformat(struct browser_window *bw)
{
/* The ugly cast here is so the reformat function can be
@@ -2541,7 +2541,7 @@ nserror browser_window_schedule_reformat(struct browser_window *bw)
}
-/* exported function documented in desktop/browser.h */
+/* exported function documented in netsurf/browser_window.h */
void browser_window_reformat(struct browser_window *bw, bool background,
int width, int height)
{
@@ -2601,7 +2601,7 @@ static void browser_window_set_scale_internal(struct browser_window *bw,
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
void browser_window_set_scale(struct browser_window *bw, float scale, bool all)
{
while (bw->parent && all)
@@ -2616,7 +2616,7 @@ void browser_window_set_scale(struct browser_window *bw, float scale, bool all)
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
float browser_window_get_scale(struct browser_window *bw)
{
if (bw == NULL) {
@@ -2681,7 +2681,7 @@ static void browser_window_find_target_internal(struct browser_window *bw,
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
struct browser_window *browser_window_find_target(struct browser_window *bw,
const char *target, browser_mouse_state mouse)
{
@@ -2875,7 +2875,7 @@ static void browser_window_mouse_drag_end(struct browser_window *bw,
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
void browser_window_mouse_track(struct browser_window *bw,
browser_mouse_state mouse, int x, int y)
{
@@ -3023,7 +3023,7 @@ void browser_window_mouse_track(struct browser_window *bw,
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
void browser_window_mouse_click(struct browser_window *bw,
browser_mouse_state mouse, int x, int y)
{
@@ -3148,7 +3148,7 @@ void browser_window_mouse_click(struct browser_window *bw,
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
int width, int height)
{
@@ -3156,7 +3156,7 @@ void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
void browser_window_page_drag_start(struct browser_window *bw, int x, int y)
{
assert(bw != NULL);
@@ -3181,7 +3181,7 @@ void browser_window_page_drag_start(struct browser_window *bw, int x, int y)
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
bool browser_window_back_available(struct browser_window *bw)
{
return (bw && bw->history &&
@@ -3190,21 +3190,21 @@ bool browser_window_back_available(struct browser_window *bw)
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
bool browser_window_forward_available(struct browser_window *bw)
{
return (bw && bw->history &&
browser_window_history_forward_available(bw));
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
bool browser_window_reload_available(struct browser_window *bw)
{
return (bw && bw->current_content && !bw->loading_content);
}
-/* exported interface documented in desktop/browser.h */
+/* exported interface documented in netsurf/browser_window.h */
bool browser_window_stop_available(struct browser_window *bw)
{
return (bw && (bw->loading_content ||
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index f2b0fb3..5cd98cd 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -29,19 +29,17 @@
#include <time.h>
#include "utils/log.h"
-#include "utils/nsurl.h"
#include "utils/utils.h"
-#include "content/content.h"
+#include "netsurf/layout.h"
+#include "netsurf/plotters.h"
+#include "netsurf/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
-#include "css/css.h"
-#include "image/bitmap.h"
+#include "netsurf/bitmap.h"
-#include "desktop/gui_layout.h"
#include "desktop/gui_internal.h"
#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/plotters.h"
#define WIDTH 100
#define HEIGHT 86
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index efd875f..64c698b 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -26,8 +26,9 @@
#include <libwapcaplet/libwapcaplet.h>
-#include "desktop/browser.h"
-
+#include "netsurf/browser_window.h"
+#include "desktop/frame_types.h"
+#include "desktop/plot_style.h"
struct box;
struct hlcache_handle;
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 6731e8e..6134fa5 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -16,8 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Cookie Manager (implementation).
+/**
+ * \file
+ * Implementation of Cookie Management
+ *
+ * This allows users to view and remove their web cookies.
+ *
+ * \todo the viewing of cookies is pretty basic and it would be good
+ * to apply more processing of the values and perhaps top level domain
+ * suffix highlighting to give a better user information as to how the
+ * cookies interact with the users sessions.
+ *
+ * \todo In addition to removing cookies it might be useful to allow
+ * users to edit them, especially to alter expiry times.
*/
@@ -41,7 +52,6 @@ enum cookie_manager_field {
COOKIE_M_LAST_USED,
COOKIE_M_RESTRICTIONS,
COOKIE_M_VERSION,
- COOKIE_M_PERSISTENT,
COOKIE_M_DOMAIN_FOLDER,
COOKIE_M_N_FIELDS
};
@@ -205,10 +215,10 @@ static void cookie_manager_free_treeview_field_data(
* \param value Text to set in field, ownership yielded
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static inline nserror cookie_manager_field_builder(
- enum cookie_manager_field field,
- struct treeview_field_data *data,
- const char *value)
+static inline nserror
+cookie_manager_field_builder(enum cookie_manager_field field,
+ struct treeview_field_data *data,
+ const char *value)
{
data->field = cm_ctx.fields[field].field;
data->value = value;
@@ -217,6 +227,46 @@ static inline nserror cookie_manager_field_builder(
return NSERROR_OK;
}
+/**
+ * Build a cookie manager treeview field from given time
+ *
+ * The time should be converted to text in the users locacle
+ *
+ * \todo This should probably generate the user text using localtime
+ * and strftime with the c format specifier. Currently ctime will
+ * always generate output in the C locale.
+ *
+ * \param field Cookie manager treeview field to build
+ * \param fdata Cookie manager entry field data to set
+ * \param value Time to show in field
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static inline nserror
+cookie_manager_field_builder_time(enum cookie_manager_field field,
+ struct treeview_field_data *fdata,
+ const time_t *value)
+{
+ const char *date;
+ char *date2;
+
+ fdata->field = cm_ctx.fields[field].field;
+
+ date = ctime(value);
+ date2 = strdup(date);
+ if (date2 == NULL) {
+ fdata->value = NULL;
+ fdata->value_len = 0;
+ } else {
+ assert(date2[24] == '\n');
+ date2[24] = '\0';
+
+ fdata->value = date2;
+ fdata->value_len = strlen(date2);
+ }
+
+ return NSERROR_OK;
+}
+
/**
* Set a cookie manager entry's data from the cookie_data.
@@ -225,13 +275,10 @@ static inline nserror cookie_manager_field_builder(
* \param data Data associated with entry's cookie
* \return NSERROR_OK on success, appropriate error otherwise
*/
-static nserror cookie_manager_set_treeview_field_data(
- struct cookie_manager_entry *e,
- const struct cookie_data *data)
+static nserror
+cookie_manager_set_treeview_field_data(struct cookie_manager_entry *e,
+ const struct cookie_data *data)
{
- const char *date;
- char *date2;
-
assert(e != NULL);
assert(data != NULL);
@@ -246,54 +293,45 @@ static nserror cookie_manager_set_treeview_field_data(
&e->data[COOKIE_M_PATH], strdup(data->path));
/* Set the Expires date field */
- date = ctime(&data->expires);
- date2 = strdup(date);
- if (date2 != NULL) {
- assert(date2[24] == '\n');
- date2[24] = '\0';
+ if (data->expires == -1) {
+ cookie_manager_field_builder(COOKIE_M_EXPIRES,
+ &e->data[COOKIE_M_EXPIRES],
+ strdup(messages_get("CookieManagerSession")));
+ } else {
+ cookie_manager_field_builder_time(COOKIE_M_EXPIRES,
+ &e->data[COOKIE_M_EXPIRES], &data->expires);
}
- cookie_manager_field_builder(COOKIE_M_EXPIRES,
- &e->data[COOKIE_M_EXPIRES], date2);
/* Set the Last used date field */
- date = ctime(&data->last_used);
- date2 = strdup(date);
- if (date2 != NULL) {
- assert(date2[24] == '\n');
- date2[24] = '\0';
- }
- cookie_manager_field_builder(COOKIE_M_LAST_USED,
- &e->data[COOKIE_M_LAST_USED], date2);
+ cookie_manager_field_builder_time(COOKIE_M_LAST_USED,
+ &e->data[COOKIE_M_LAST_USED], &data->last_used);
/* Set the Restrictions text */
- if (data->secure && data->http_only)
+ if (data->secure && data->http_only) {
e->data[COOKIE_M_RESTRICTIONS] = cm_ctx.values[COOKIE_M_HTTPS];
- else if (data->secure)
+ } else if (data->secure) {
e->data[COOKIE_M_RESTRICTIONS] = cm_ctx.values[COOKIE_M_SECURE];
- else if (data->http_only)
+ } else if (data->http_only) {
e->data[COOKIE_M_RESTRICTIONS] = cm_ctx.values[COOKIE_M_HTTP];
- else
+ } else {
e->data[COOKIE_M_RESTRICTIONS] = cm_ctx.values[COOKIE_M_NONE];
+ }
/* Set the Version text */
switch (data->version) {
case COOKIE_NETSCAPE:
e->data[COOKIE_M_VERSION] = cm_ctx.values[COOKIE_M_NETSCAPE];
break;
+
case COOKIE_RFC2109:
e->data[COOKIE_M_VERSION] = cm_ctx.values[COOKIE_M_RFC2109];
break;
+
case COOKIE_RFC2965:
e->data[COOKIE_M_VERSION] = cm_ctx.values[COOKIE_M_RFC2965];
break;
}
- /* Set the Persistent text */
- if (data->no_destroy)
- e->data[COOKIE_M_PERSISTENT] = cm_ctx.values[COOKIE_M_YES];
- else
- e->data[COOKIE_M_PERSISTENT] = cm_ctx.values[COOKIE_M_NO];
-
return NSERROR_OK;
}
@@ -329,10 +367,13 @@ static nserror cookie_manager_create_cookie_node(
return err;
}
- err = treeview_create_node_entry(cm_ctx.tree, &(cookie->entry),
- parent->folder, TREE_REL_FIRST_CHILD,
- cookie->data, cookie,
- cm_ctx.built ? TREE_OPTION_NONE :
+ err = treeview_create_node_entry(cm_ctx.tree,
+ &(cookie->entry),
+ parent->folder,
+ TREE_REL_FIRST_CHILD,
+ cookie->data,
+ cookie,
+ cm_ctx.built ? TREE_OPTION_NONE :
TREE_OPTION_SUPPRESS_RESIZE |
TREE_OPTION_SUPPRESS_REDRAW);
if (err != NSERROR_OK) {
@@ -589,15 +630,6 @@ static nserror cookie_manager_init_entry_fields(void)
goto error;
}
- cm_ctx.fields[COOKIE_M_PERSISTENT].flags = TREE_FLAG_SHOW_NAME;
- label = "TreeviewLabelPersistent";
- label = messages_get(label);
- if (lwc_intern_string(label, strlen(label),
- &cm_ctx.fields[COOKIE_M_PERSISTENT].field) !=
- lwc_error_ok) {
- goto error;
- }
-
cm_ctx.fields[COOKIE_M_DOMAIN_FOLDER].flags = TREE_FLAG_DEFAULT;
label = "TreeviewLabelDomainFolder";
label = messages_get(label);
@@ -661,15 +693,6 @@ static nserror cookie_manager_init_common_values(void)
cookie_manager_field_builder(COOKIE_M_VERSION,
&cm_ctx.values[COOKIE_M_RFC2965], strdup(temp));
- /* Set the Persistent value text */
- temp = messages_get("Yes");
- cookie_manager_field_builder(COOKIE_M_PERSISTENT,
- &cm_ctx.values[COOKIE_M_YES], strdup(temp));
-
- temp = messages_get("No");
- cookie_manager_field_builder(COOKIE_M_PERSISTENT,
- &cm_ctx.values[COOKIE_M_NO], strdup(temp));
-
return NSERROR_OK;
}
@@ -677,7 +700,7 @@ static nserror cookie_manager_init_common_values(void)
/**
* Delete cookie manager entries (and optionally delete from urldb)
*
- * \param e Cookie manager entry to delete.
+ * \param e Cookie manager entry to delete.
*/
static void cookie_manager_delete_entry(struct cookie_manager_entry *e)
{
@@ -724,6 +747,8 @@ static nserror cookie_manager_tree_node_folder_cb(
return NSERROR_OK;
}
+
+
static nserror cookie_manager_tree_node_entry_cb(
struct treeview_node_msg msg, void *data)
{
@@ -744,6 +769,8 @@ static nserror cookie_manager_tree_node_entry_cb(
}
return NSERROR_OK;
}
+
+
struct treeview_callback_table cm_tree_cb_t = {
.folder = cookie_manager_tree_node_folder_cb,
.entry = cookie_manager_tree_node_entry_cb
@@ -756,6 +783,11 @@ nserror cookie_manager_init(struct core_window_callback_table *cw_t,
{
nserror err;
+ err = treeview_init();
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
LOG("Generating cookie manager data");
/* Init. cookie manager treeview entry fields */
@@ -822,6 +854,11 @@ nserror cookie_manager_fini(void)
if (cm_ctx.values[i].value != NULL)
free((void *) cm_ctx.values[i].value);
+ err = treeview_fini();
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
LOG("Finalised cookie manager");
return err;
@@ -844,9 +881,9 @@ void cookie_manager_mouse_action(enum browser_mouse_state mouse, int x, int y)
/* Exported interface, documented in cookie_manager.h */
-void cookie_manager_keypress(uint32_t key)
+bool cookie_manager_keypress(uint32_t key)
{
- treeview_keypress(cm_ctx.tree, key);
+ return treeview_keypress(cm_ctx.tree, key);
}
diff --git a/desktop/cookie_manager.h b/desktop/cookie_manager.h
index b7acfe9..4ae74a2 100644
--- a/desktop/cookie_manager.h
+++ b/desktop/cookie_manager.h
@@ -26,14 +26,13 @@
#include <stdbool.h>
#include <stdint.h>
-#include "desktop/core_window.h"
-#include "desktop/textinput.h"
#include "utils/errors.h"
+#include "netsurf/mouse.h"
struct redraw_context;
struct cookie_data;
-
-enum browser_mouse_state;
+struct core_window_callback_table;
+struct rect;
/**
* Initialise the cookie manager.
@@ -102,7 +101,7 @@ void cookie_manager_mouse_action(enum browser_mouse_state mouse, int x, int y);
* \param key The ucs4 character codepoint
* \return true if the keypress is dealt with, false otherwise.
*/
-void cookie_manager_keypress(uint32_t key);
+bool cookie_manager_keypress(uint32_t key);
/**
* Determine whether there is a selection
diff --git a/desktop/download.c b/desktop/download.c
index 131bc80..76c2949 100644
--- a/desktop/download.c
+++ b/desktop/download.c
@@ -30,7 +30,7 @@
#include "utils/http.h"
#include "utils/utils.h"
#include "desktop/download.h"
-#include "desktop/gui_download.h"
+#include "netsurf/download.h"
#include "desktop/gui_internal.h"
/**
diff --git a/desktop/font_haru.c b/desktop/font_haru.c
index d2d7efd..caa751b 100644
--- a/desktop/font_haru.c
+++ b/desktop/font_haru.c
@@ -36,9 +36,6 @@
#include <hpdf.h>
-#include "css/css.h"
-#include "css/utils.h"
-
#include "utils/nsoption.h"
#include "desktop/save_pdf/font_haru.h"
#include "desktop/font.h"
diff --git a/desktop/frame_types.h b/desktop/frame_types.h
index 7008e98..416c888 100644
--- a/desktop/frame_types.h
+++ b/desktop/frame_types.h
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Browser window creation and manipulation (interface).
+/**
+ * \file
+ * Interface to browser frames.
*/
#ifndef _NETSURF_DESKTOP_FRAME_TYPES_H_
diff --git a/desktop/frames.c b/desktop/frames.c
index 7be75ce..70e51e7 100644
--- a/desktop/frames.c
+++ b/desktop/frames.c
@@ -29,18 +29,17 @@
#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/scrollbar.h"
-#include "desktop/selection.h"
#include "utils/log.h"
-#include "utils/messages.h"
#include "utils/utils.h"
+#include "netsurf/content.h"
+#include "content/hlcache.h"
#include "render/html.h"
#include "render/box.h"
+#include "desktop/browser_private.h"
+#include "desktop/frames.h"
+#include "desktop/scrollbar.h"
+
/** maximum frame resize margin */
#define FRAME_RESIZE 6
@@ -98,7 +97,7 @@ void browser_window_scroll_callback(void *client_data,
/* exported interface, documented in browser.h */
void browser_window_handle_scrollbars(struct browser_window *bw)
{
- hlcache_handle *h = bw->current_content;
+ struct hlcache_handle *h = bw->current_content;
bool scroll_x;
bool scroll_y;
int c_width = 0;
@@ -380,8 +379,8 @@ nserror browser_window_create_frameset(struct browser_window *bw,
/* Use the URL of the first ancestor window containing html content
* as the referer */
for (window = bw; window->parent; window = window->parent) {
- if (window->current_content &&
- content_get_type(window->current_content) ==
+ if (window->current_content &&
+ content_get_type(window->current_content) ==
CONTENT_HTML)
break;
}
diff --git a/desktop/frames.h b/desktop/frames.h
index b39c8a8..063e2c5 100644
--- a/desktop/frames.h
+++ b/desktop/frames.h
@@ -24,6 +24,8 @@
#define _NETSURF_DESKTOP_FRAMES_H_
struct scrollbar_msg_data;
+struct content_html_iframe;
+struct content_html_frames;
/**
* Create and open iframes for a browser window.
diff --git a/desktop/global_history.c b/desktop/global_history.c
index 9fa1d6d..b6f4882 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -19,17 +19,19 @@
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/utf8.h"
#include "utils/libdom.h"
#include "utils/log.h"
+#include "utils/nsurl.h"
#include "content/urldb.h"
#include "desktop/global_history.h"
#include "desktop/treeview.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#define N_DAYS 28
#define N_SEC_PER_DAY (60 * 60 * 24)
@@ -722,6 +724,11 @@ nserror global_history_init(struct core_window_callback_table *cw_t,
{
nserror err;
+ err = treeview_init();
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
LOG("Loading global history");
/* Init. global history treeview time */
@@ -802,6 +809,11 @@ nserror global_history_fini(void)
if (gh_ctx.fields[i].field != NULL)
lwc_string_unref(gh_ctx.fields[i].field);
+ err = treeview_fini();
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
LOG("Finalised global history");
return err;
@@ -945,9 +957,9 @@ void global_history_mouse_action(browser_mouse_state mouse, int x, int y)
/* Exported interface, documented in global_history.h */
-void global_history_keypress(uint32_t key)
+bool global_history_keypress(uint32_t key)
{
- treeview_keypress(gh_ctx.tree, key);
+ return treeview_keypress(gh_ctx.tree, key);
}
diff --git a/desktop/global_history.h b/desktop/global_history.h
index bfbd132..213a014 100644
--- a/desktop/global_history.h
+++ b/desktop/global_history.h
@@ -22,14 +22,13 @@
#include <stdbool.h>
#include <stdint.h>
-#include "desktop/core_window.h"
-#include "desktop/textinput.h"
#include "utils/errors.h"
+#include "netsurf/mouse.h"
+struct core_window_callback_table;
struct redraw_context;
struct nsurl;
-
-enum browser_mouse_state;
+struct rect;
/**
* Initialise the global history.
@@ -67,7 +66,7 @@ nserror global_history_fini(void);
*/
nserror global_history_add(struct nsurl *url);
-/*
+/**
* Save global history to file (html)
*
* \param path The path to save history to
@@ -102,7 +101,7 @@ void global_history_mouse_action(enum browser_mouse_state mouse, int x, int y);
* \param key The ucs4 character codepoint
* \return true if the keypress is dealt with, false otherwise.
*/
-void global_history_keypress(uint32_t key);
+bool global_history_keypress(uint32_t key);
/**
* Determine whether there is a selection
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index 956c508..88bb9ba 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -23,22 +23,22 @@
#include "utils/config.h"
#include "utils/errors.h"
#include "utils/file.h"
-#include "image/bitmap.h"
+#include "netsurf/bitmap.h"
#include "content/hlcache.h"
#include "content/backing_store.h"
#include "desktop/save_pdf.h"
#include "desktop/download.h"
#include "desktop/searchweb.h"
-#include "desktop/gui_download.h"
-#include "desktop/gui_fetch.h"
-#include "desktop/gui_misc.h"
-#include "desktop/gui_window.h"
-#include "desktop/gui_search.h"
-#include "desktop/gui_clipboard.h"
-#include "desktop/gui_utf8.h"
-#include "desktop/gui_layout.h"
-#include "desktop/netsurf.h"
+#include "netsurf/download.h"
+#include "netsurf/fetch.h"
+#include "netsurf/misc.h"
+#include "netsurf/window.h"
+#include "netsurf/search.h"
+#include "netsurf/clipboard.h"
+#include "netsurf/utf8.h"
+#include "netsurf/layout.h"
+#include "netsurf/netsurf.h"
/**
* The global interface table.
@@ -685,13 +685,13 @@ static nserror gui_default_launch_url(struct nsurl *url)
}
-static void gui_default_cert_verify(nsurl *url,
+static nserror gui_default_cert_verify(nsurl *url,
const struct ssl_cert_info *certs,
unsigned long num,
nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
- cb(false, cbpw);
+ return NSERROR_NOT_IMPLEMENTED;
}
static void gui_default_401login_open(nsurl *url, const char *realm,
@@ -743,7 +743,7 @@ static nserror verify_misc_register(struct gui_misc_table *gmt)
}
-/* exported interface documented in desktop/netsurf.h */
+/* exported interface documented in netsurf/netsurf.h */
nserror netsurf_register(struct netsurf_table *gt)
{
nserror err;
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 98d5f9c..78473c7 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -31,13 +31,14 @@
#include "utils/utf8.h"
#include "utils/libdom.h"
#include "utils/log.h"
+#include "utils/nsurl.h"
#include "content/urldb.h"
-#include "desktop/gui_misc.h"
+#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "desktop/hotlist.h"
#include "desktop/treeview.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#define N_DAYS 28
#define N_SEC_PER_DAY (60 * 60 * 24)
@@ -1226,11 +1227,15 @@ static nserror hotlist_populate(const char *path)
/* Exported interface, documented in hotlist.h */
-nserror hotlist_init(struct core_window_callback_table *cw_t,
- void *core_window_handle, const char *path)
+nserror hotlist_init(const char *path)
{
nserror err;
+ err = treeview_init();
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
LOG("Loading hotlist");
hl_ctx.tree = NULL;
@@ -1246,8 +1251,7 @@ nserror hotlist_init(struct core_window_callback_table *cw_t,
/* Create the hotlist treeview */
err = treeview_create(&hl_ctx.tree, &hl_tree_cb_t,
- HL_N_FIELDS, hl_ctx.fields,
- cw_t, core_window_handle,
+ HL_N_FIELDS, hl_ctx.fields, NULL, NULL,
TREEVIEW_NO_FLAGS);
if (err != NSERROR_OK) {
hl_ctx.tree = NULL;
@@ -1265,10 +1269,41 @@ nserror hotlist_init(struct core_window_callback_table *cw_t,
* the treeview is built. */
hl_ctx.built = true;
+ LOG("Loaded hotlist");
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_manager_init(struct core_window_callback_table *cw_t,
+ void *core_window_handle)
+{
+ nserror err;
+
+ /* Create the hotlist treeview */
+ err = treeview_cw_attach(hl_ctx.tree, cw_t, core_window_handle);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
/* Inform client of window height */
treeview_get_height(hl_ctx.tree);
- LOG("Loaded hotlist");
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_manager_fini(void)
+{
+ nserror err;
+
+ /* Create the hotlist treeview */
+ err = treeview_cw_detach(hl_ctx.tree);
+ if (err != NSERROR_OK) {
+ return err;
+ }
return NSERROR_OK;
}
@@ -1297,6 +1332,11 @@ nserror hotlist_fini(const char *path)
if (hl_ctx.fields[i].field != NULL)
lwc_string_unref(hl_ctx.fields[i].field);
+ err = treeview_fini();
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
LOG("Finalised hotlist");
return err;
@@ -1571,9 +1611,9 @@ void hotlist_mouse_action(browser_mouse_state mouse, int x, int y)
/* Exported interface, documented in hotlist.h */
-void hotlist_keypress(uint32_t key)
+bool hotlist_keypress(uint32_t key)
{
- treeview_keypress(hl_ctx.tree, key);
+ return treeview_keypress(hl_ctx.tree, key);
}
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index 2733d58..c77ac92 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -22,30 +22,55 @@
#include <stdbool.h>
#include <stdint.h>
-#include "desktop/core_window.h"
-#include "desktop/textinput.h"
#include "utils/errors.h"
+#include "netsurf/mouse.h"
+struct core_window_callback_table;
struct redraw_context;
struct nsurl;
-
-enum browser_mouse_state;
+struct rect;
/**
* Initialise the hotlist.
*
- * This opens the hotlist file, generating the hotlist data, and creates a
+ * This opens the hotlist file, construct the hostlist, and creates a
* treeview. If there's no hotlist file, it generates a default hotlist.
*
- * This must be called before any other hotlist_* function.
+ * This must be called before any other hotlist_* function. It must
+ * be called before URLs can be added to the hotlist, and before the
+ * hotlist can be queried to ask if URLs are present in the hotlist.
+ *
+ * \param path The path to hotlist file to load
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror hotlist_init(const char *path);
+
+/**
+ * Initialise the hotlist manager.
+ *
+ * This connects the underlying hotlist treeview to a corewindow for display.
+ *
+ * The provided core window handle must be valid until hotlist_fini is called.
*
* \param cw_t Callback table for core_window containing the treeview
* \param core_window_handle The handle in which the treeview is shown
- * \param path The path to hotlist file to load
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror hotlist_init(struct core_window_callback_table *cw_t,
- void *core_window_handle, const char *path);
+nserror hotlist_manager_init(struct core_window_callback_table *cw_t,
+ void *core_window_handle);
+
+
+/**
+ * Finalise the hotlist manager.
+ *
+ * This simply disconnects the underlying treeview from its corewindow,
+ * allowing destruction of a GUI hotlist window, without finalising the
+ * hotlist module.
+ *
+ * \param path The path to save hotlist to
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror hotlist_manager_fini(void);
/**
* Finalise the hotlist.
@@ -190,10 +215,10 @@ void hotlist_mouse_action(enum browser_mouse_state mouse, int x, int y);
/**
* Key press handling.
*
- * \param key The ucs4 character codepoint
+ * \param key The ucs4 character codepoint
* \return true if the keypress is dealt with, false otherwise.
*/
-void hotlist_keypress(uint32_t key);
+bool hotlist_keypress(uint32_t key);
/**
* Determine whether there is a selection
diff --git a/desktop/knockout.c b/desktop/knockout.c
index 54e371c..b930ef6 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -69,12 +69,12 @@
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/errors.h"
-#include "image/bitmap.h"
+#include "netsurf/bitmap.h"
#include "content/content.h"
#include "desktop/gui_internal.h"
#include "desktop/knockout.h"
-#include "desktop/plotters.h"
+#include "netsurf/plotters.h"
/* Define to enable knockout debug */
#undef KNOCKOUT_DEBUG
diff --git a/desktop/knockout.h b/desktop/knockout.h
index a6b61d8..c4f1245 100644
--- a/desktop/knockout.h
+++ b/desktop/knockout.h
@@ -23,7 +23,7 @@
#ifndef _NETSURF_DESKTOP_KNOCKOUT_H_
#define _NETSURF_DESKTOP_KNOCKOUT_H_
-#include "desktop/plotters.h"
+#include "netsurf/plotters.h"
bool knockout_plot_start(const struct redraw_context *ctx,
diff --git a/desktop/mouse.c b/desktop/mouse.c
index ea627ac..6d22fd4 100644
--- a/desktop/mouse.c
+++ b/desktop/mouse.c
@@ -20,7 +20,7 @@
* Browser window creation and manipulation (implementation).
*/
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#include "utils/log.h"
/**
diff --git a/desktop/mouse.h b/desktop/mouse.h
deleted file mode 100644
index 083bd17..0000000
--- a/desktop/mouse.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2003 Phil Mellor <monkeyson(a)users.sourceforge.net>
- * Copyright 2006 James Bursa <bursa(a)users.sourceforge.net>
- * Copyright 2010 Michael Drake <tlsa(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
- * Core mouse state.
- */
-
-#ifndef _NETSURF_DESKTOP_MOUSE_H_
-#define _NETSURF_DESKTOP_MOUSE_H_
-
-/* Mouse state. 1 is primary mouse button (e.g. Select on RISC OS).
- * 2 is secondary mouse button (e.g. Adjust on RISC OS). */
-typedef enum browser_mouse_state {
- BROWSER_MOUSE_HOVER = 0, /* No mouse buttons pressed,
- * May be used to indicate
- * hover or end of drag. */
-
- BROWSER_MOUSE_PRESS_1 = (1 << 0), /* button 1 pressed */
- BROWSER_MOUSE_PRESS_2 = (1 << 1), /* button 2 pressed */
-
- /* note: click meaning is different for
- * different front ends. On RISC OS, it
- * is standard to act on press, so a
- * click is fired at the same time as a
- * mouse button is pressed. With GTK, it
- * is standard to act on release, so a
- * click is fired when the mouse button
- * is released, if the operation wasn't
- * a drag. */
-
- BROWSER_MOUSE_CLICK_1 = (1 << 2), /* button 1 clicked. */
- BROWSER_MOUSE_CLICK_2 = (1 << 3), /* button 2 clicked. */
-
- BROWSER_MOUSE_DOUBLE_CLICK = (1 << 4), /* button double clicked */
- BROWSER_MOUSE_TRIPLE_CLICK = (1 << 5), /* button triple clicked */
-
- /* note: double and triple clicks are
- * fired alongside a
- * BROWSER_MOUSE_CLICK_[1|2]
- * to indicate which button
- * is used.
- */
-
- BROWSER_MOUSE_DRAG_1 = (1 << 6), /* start of button 1 drag */
- BROWSER_MOUSE_DRAG_2 = (1 << 7), /* start of button 2 drag */
-
- BROWSER_MOUSE_DRAG_ON = (1 << 8), /* a drag operation was started
- * and a mouse button is still
- * pressed */
-
- BROWSER_MOUSE_HOLDING_1 = (1 << 9), /* during button 1 drag */
- BROWSER_MOUSE_HOLDING_2 = (1 << 10), /* during button 2 drag */
-
-
- BROWSER_MOUSE_MOD_1 = (1 << 11), /* 1st modifier key pressed
- * (eg. Shift) */
- BROWSER_MOUSE_MOD_2 = (1 << 12), /* 2nd modifier key pressed
- * (eg. Ctrl) */
- BROWSER_MOUSE_MOD_3 = (1 << 13) /* 3rd modifier key pressed
- * (eg. Alt) */
-} browser_mouse_state;
-
-
-typedef enum gui_pointer_shape {
- GUI_POINTER_DEFAULT, GUI_POINTER_POINT, GUI_POINTER_CARET,
- GUI_POINTER_MENU, GUI_POINTER_UP, GUI_POINTER_DOWN,
- GUI_POINTER_LEFT, GUI_POINTER_RIGHT, GUI_POINTER_RU,
- GUI_POINTER_LD, GUI_POINTER_LU, GUI_POINTER_RD,
- GUI_POINTER_CROSS, GUI_POINTER_MOVE, GUI_POINTER_WAIT,
- GUI_POINTER_HELP, GUI_POINTER_NO_DROP, GUI_POINTER_NOT_ALLOWED,
- GUI_POINTER_PROGRESS } gui_pointer_shape;
-
-/** Mouse pointer type */
-typedef enum {
- BROWSER_POINTER_DEFAULT = GUI_POINTER_DEFAULT,
- BROWSER_POINTER_POINT = GUI_POINTER_POINT,
- BROWSER_POINTER_CARET = GUI_POINTER_CARET,
- BROWSER_POINTER_MENU = GUI_POINTER_MENU,
- BROWSER_POINTER_UP = GUI_POINTER_UP,
- BROWSER_POINTER_DOWN = GUI_POINTER_DOWN,
- BROWSER_POINTER_LEFT = GUI_POINTER_LEFT,
- BROWSER_POINTER_RIGHT = GUI_POINTER_RIGHT,
- BROWSER_POINTER_RU = GUI_POINTER_RU,
- BROWSER_POINTER_LD = GUI_POINTER_LD,
- BROWSER_POINTER_LU = GUI_POINTER_LU,
- BROWSER_POINTER_RD = GUI_POINTER_RD,
- BROWSER_POINTER_CROSS = GUI_POINTER_CROSS,
- BROWSER_POINTER_MOVE = GUI_POINTER_MOVE,
- BROWSER_POINTER_WAIT = GUI_POINTER_WAIT,
- BROWSER_POINTER_HELP = GUI_POINTER_HELP,
- BROWSER_POINTER_NO_DROP = GUI_POINTER_NO_DROP,
- BROWSER_POINTER_NOT_ALLOWED = GUI_POINTER_NOT_ALLOWED,
- BROWSER_POINTER_PROGRESS = GUI_POINTER_PROGRESS,
- BROWSER_POINTER_AUTO
-} browser_pointer_shape;
-
-
-void browser_mouse_state_dump(browser_mouse_state mouse);
-
-#endif
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 46d8d67..4a14737 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -44,12 +44,12 @@
#include "render/html.h"
#include "render/textplain.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#include "desktop/system_colour.h"
#include "desktop/searchweb.h"
-#include "desktop/gui_misc.h"
+#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
-#include "desktop/netsurf.h"
+#include "netsurf/netsurf.h"
/** speculative pre-conversion small image size
*
@@ -104,24 +104,28 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw)
static nserror netsurf_llcache_query_handler(const llcache_query *query,
void *pw, llcache_query_response cb, void *cbpw)
{
+ nserror res = NSERROR_OK;
+
switch (query->type) {
case LLCACHE_QUERY_AUTH:
guit->misc->login(query->url, query->data.auth.realm, cb, cbpw);
break;
+
case LLCACHE_QUERY_REDIRECT:
/** \todo Need redirect query dialog */
/* For now, do nothing, as this query type isn't emitted yet */
break;
+
case LLCACHE_QUERY_SSL:
- guit->misc->cert_verify(query->url, query->data.ssl.certs,
+ res = guit->misc->cert_verify(query->url, query->data.ssl.certs,
query->data.ssl.num, cb, cbpw);
break;
}
- return NSERROR_OK;
+ return res;
}
-/* exported interface documented in desktop/netsurf.h */
+/* exported interface documented in netsurf/netsurf.h */
nserror netsurf_init(const char *store_path)
{
nserror ret;
@@ -208,12 +212,11 @@ nserror netsurf_init(const char *store_path)
if (ret != NSERROR_OK)
return ret;
-
ret = mimesniff_init();
if (ret != NSERROR_OK)
return ret;
- setlocale(LC_ALL, "C");
+ setlocale(LC_ALL, "");
/* initialise the fetchers */
ret = fetcher_init();
@@ -276,6 +279,9 @@ void netsurf_exit(void)
LOG("Destroying System colours");
ns_system_colour_finalize();
+ LOG("Destroying Messages");
+ messages_destroy();
+
corestrings_fini();
LOG("Remaining lwc strings:");
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
diff --git a/desktop/options.h b/desktop/options.h
index 2f36887..437d104 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -59,7 +59,10 @@ NSOPTION_STRING(http_proxy_auth_pass, NULL)
/** Proxy omission list */
NSOPTION_STRING(http_proxy_noproxy, "localhost")
-/** Default font size / 0.1pt. */
+/** Default treeview font size (unit: 0.1pt) */
+NSOPTION_INTEGER(treeview_font_size, 110)
+
+/** Default font size (unit: 0.1pt) */
NSOPTION_INTEGER(font_size, 128)
/** Minimum font size. */
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
index 05e42ba..f9ba4bc 100644
--- a/desktop/plot_style.c
+++ b/desktop/plot_style.c
@@ -23,7 +23,7 @@
* These plot styles are globaly available and used in many places.
*/
-#include "desktop/plotters.h"
+#include "netsurf/plotters.h"
static plot_style_t plot_style_fill_white_static = {
.fill_type = PLOT_OP_TYPE_SOLID,
diff --git a/desktop/plot_style.h b/desktop/plot_style.h
index af54e79..347c6e8 100644
--- a/desktop/plot_style.h
+++ b/desktop/plot_style.h
@@ -113,7 +113,7 @@ typedef enum {
/**
* Plot style for stroke/fill plotters
*/
-typedef struct {
+typedef struct plot_style_s {
plot_operation_type_t stroke_type; /**< Stroke plot type */
int stroke_width; /**< Width of stroke, in pixels */
colour stroke_colour; /**< Colour of stroke */
diff --git a/desktop/print.c b/desktop/print.c
index 711e907..e7c8cf2 100644
--- a/desktop/print.c
+++ b/desktop/print.c
@@ -30,12 +30,12 @@
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/talloc.h"
-#include "content/content.h"
+#include "netsurf/content.h"
+#include "netsurf/plotters.h"
#include "content/hlcache.h"
#include "css/utils.h"
#include "render/box.h"
-#include "desktop/plotters.h"
#include "desktop/print.h"
#include "desktop/printer.h"
@@ -44,11 +44,8 @@
#define DEFAULT_PAGE_HEIGHT 840
#define DEFAULT_COPIES 1
-static hlcache_handle *print_init(hlcache_handle *, struct print_settings *);
-static bool print_apply_settings(hlcache_handle *, struct print_settings *);
-
static float page_content_width, page_content_height;
-static hlcache_handle *printed_content;
+static struct hlcache_handle *printed_content;
static float done_height;
bool html_redraw_printing = false;
@@ -71,7 +68,7 @@ bool print_basic_run(hlcache_handle *content,
bool ret = true;
assert(content != NULL && printer != NULL && settings != NULL);
-
+
if (print_set_up(content, printer, settings, NULL))
return false;
@@ -80,10 +77,62 @@ bool print_basic_run(hlcache_handle *content,
}
print_cleanup(content, printer, settings);
-
+
return ret;
}
+
+/**
+ * The content passed to the function is duplicated with its boxes, font
+ * measuring functions are being set.
+ *
+ * \param content The content to be printed
+ * \param settings The settings for printing to use
+ * \return true if successful, false otherwise
+ */
+static struct hlcache_handle *
+print_init(struct hlcache_handle *content, struct print_settings *settings)
+{
+ struct hlcache_handle* printed_content;
+
+ hlcache_handle_clone(content, &printed_content);
+
+ return printed_content;
+}
+
+
+/**
+ * The content is resized to fit page width.
+ *
+ * \param content The content to be printed
+ * \param settings The settings for printing to use
+ * \return true if successful, false otherwise
+ */
+static bool
+print_apply_settings(hlcache_handle *content, struct print_settings *settings)
+{
+ if (settings == NULL)
+ return false;
+
+ /* Apply settings - adjust page size etc */
+
+ page_content_width = (settings->page_width -
+ FIXTOFLT(FSUB(settings->margins[MARGINLEFT],
+ settings->margins[MARGINRIGHT]))) / settings->scale;
+
+ page_content_height = (settings->page_height -
+ FIXTOFLT(FSUB(settings->margins[MARGINTOP],
+ settings->margins[MARGINBOTTOM]))) / settings->scale;
+
+ content_reformat(content, false, page_content_width, 0);
+
+ LOG("New layout applied.New height = %d ; New width = %d ",
+ content_get_height(content), content_get_width(content));
+
+ return true;
+}
+
+
/**
* This function prepares the content to be printed. The current browser content
* is duplicated and resized, printer initialization is called.
@@ -99,20 +148,20 @@ bool print_set_up(hlcache_handle *content,
double *height)
{
printed_content = print_init(content, settings);
-
+
if (printed_content == NULL)
return false;
-
+
print_apply_settings(printed_content, settings);
if (height)
*height = content_get_height(printed_content);
-
+
printer->print_begin(settings);
done_height = 0;
-
- return true;
+
+ return true;
}
/**
@@ -158,59 +207,12 @@ bool print_draw_next_page(const struct printer *printer,
done_height += page_content_height -
(html_redraw_printing_top_cropped != INT_MAX ?
- clip.y1 - html_redraw_printing_top_cropped : 0) /
+ clip.y1 - html_redraw_printing_top_cropped : 0) /
settings->scale;
return true;
}
-/**
- * The content passed to the function is duplicated with its boxes, font
- * measuring functions are being set.
- *
- * \param content The content to be printed
- * \param settings The settings for printing to use
- * \return true if successful, false otherwise
- */
-hlcache_handle *print_init(hlcache_handle *content,
- struct print_settings *settings)
-{
- hlcache_handle* printed_content;
-
- hlcache_handle_clone(content, &printed_content);
-
- return printed_content;
-}
-
-/**
- * The content is resized to fit page width.
- *
- * \param content The content to be printed
- * \param settings The settings for printing to use
- * \return true if successful, false otherwise
- */
-bool print_apply_settings(hlcache_handle *content,
- struct print_settings *settings)
-{
- if (settings == NULL)
- return false;
-
- /* Apply settings - adjust page size etc */
-
- page_content_width = (settings->page_width -
- FIXTOFLT(FSUB(settings->margins[MARGINLEFT],
- settings->margins[MARGINRIGHT]))) / settings->scale;
-
- page_content_height = (settings->page_height -
- FIXTOFLT(FSUB(settings->margins[MARGINTOP],
- settings->margins[MARGINBOTTOM]))) / settings->scale;
-
- content_reformat(content, false, page_content_width, 0);
-
- LOG("New layout applied.New height = %d ; New width = %d ", content_get_height(content), content_get_width(content));
-
- return true;
-}
/**
* Memory allocated during printing is being freed here.
@@ -224,16 +226,16 @@ bool print_cleanup(hlcache_handle *content, const struct printer *printer,
struct print_settings *settings)
{
printer->print_end();
-
+
html_redraw_printing = false;
-
+
if (printed_content) {
hlcache_handle_release(printed_content);
}
-
+
free((void *)settings->output);
free(settings);
-
+
return true;
}
@@ -252,57 +254,57 @@ struct print_settings *print_make_settings(print_configuration configuration,
struct print_settings *settings;
css_fixed length = 0;
css_unit unit = CSS_UNIT_MM;
-
+
switch (configuration){
- case PRINT_DEFAULT:
- settings = (struct print_settings*)
+ case PRINT_DEFAULT:
+ settings = (struct print_settings*)
malloc(sizeof(struct print_settings));
if (settings == NULL)
return NULL;
-
+
settings->page_width = DEFAULT_PAGE_WIDTH;
settings->page_height = DEFAULT_PAGE_HEIGHT;
settings->copies = DEFAULT_COPIES;
settings->scale = DEFAULT_EXPORT_SCALE;
-
+
length = INTTOFIX(DEFAULT_MARGIN_LEFT_MM);
- settings->margins[MARGINLEFT] =
+ settings->margins[MARGINLEFT] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(DEFAULT_MARGIN_RIGHT_MM);
- settings->margins[MARGINRIGHT] =
+ settings->margins[MARGINRIGHT] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(DEFAULT_MARGIN_TOP_MM);
- settings->margins[MARGINTOP] =
+ settings->margins[MARGINTOP] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(DEFAULT_MARGIN_BOTTOM_MM);
- settings->margins[MARGINBOTTOM] =
+ settings->margins[MARGINBOTTOM] =
nscss_len2px(length, unit, NULL);
break;
/* use settings from the Export options tab */
case PRINT_OPTIONS:
- settings = (struct print_settings*)
+ settings = (struct print_settings*)
malloc(sizeof(struct print_settings));
if (settings == NULL)
return NULL;
-
+
settings->page_width = DEFAULT_PAGE_WIDTH;
settings->page_height = DEFAULT_PAGE_HEIGHT;
settings->copies = DEFAULT_COPIES;
-
+
settings->scale = (float)nsoption_int(export_scale) / 100;
-
+
length = INTTOFIX(nsoption_int(margin_left));
- settings->margins[MARGINLEFT] =
+ settings->margins[MARGINLEFT] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(nsoption_int(margin_right));
- settings->margins[MARGINRIGHT] =
+ settings->margins[MARGINRIGHT] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(nsoption_int(margin_top));
- settings->margins[MARGINTOP] =
+ settings->margins[MARGINTOP] =
nscss_len2px(length, unit, NULL);
length = INTTOFIX(nsoption_int(margin_bottom));
- settings->margins[MARGINBOTTOM] =
+ settings->margins[MARGINBOTTOM] =
nscss_len2px(length, unit, NULL);
break;
default:
@@ -319,9 +321,9 @@ struct print_settings *print_make_settings(print_configuration configuration,
free(settings);
return NULL;
}
- } else
+ } else {
settings->output = NULL;
+ }
- return settings;
+ return settings;
}
-
diff --git a/desktop/print.h b/desktop/print.h
index 5c51981..fb1fd63 100644
--- a/desktop/print.h
+++ b/desktop/print.h
@@ -33,8 +33,7 @@
#define NETSURF_DESKTOP_PRINT_H
#include <stdbool.h>
-
-#include "css/css.h"
+#include <libcss/libcss.h>
struct hlcache_handle;
struct printer;
diff --git a/desktop/save_complete.c b/desktop/save_complete.c
index 98b0304..f8f0057 100644
--- a/desktop/save_complete.c
+++ b/desktop/save_complete.c
@@ -17,12 +17,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Save HTML document with dependencies (implementation).
+/**
+ * \file
+ * Save HTML document with dependencies implementation.
*/
#include <assert.h>
-#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
@@ -39,13 +39,14 @@
#include "utils/utils.h"
#include "utils/file.h"
#include "utils/messages.h"
-#include "content/content.h"
+#include "utils/ascii.h"
+#include "netsurf/content.h"
#include "content/hlcache.h"
#include "css/css.h"
#include "render/box.h"
#include "render/html.h"
-#include "desktop/gui_misc.h"
+#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "desktop/save_complete.h"
@@ -53,7 +54,7 @@ regex_t save_complete_import_re;
/** An entry in save_complete_list. */
typedef struct save_complete_entry {
- hlcache_handle *content;
+ struct hlcache_handle *content;
struct save_complete_entry *next; /**< Next entry in list */
} save_complete_entry;
@@ -73,7 +74,7 @@ typedef enum {
} save_complete_event_type;
-static bool save_complete_save_html(save_complete_ctx *ctx, hlcache_handle *c,
+static bool save_complete_save_html(save_complete_ctx *ctx, struct hlcache_handle *c,
bool index);
static bool save_complete_save_imported_sheets(save_complete_ctx *ctx,
struct nscss_import *imports, uint32_t import_count);
@@ -99,7 +100,7 @@ static void save_complete_ctx_finalise(save_complete_ctx *ctx)
}
static bool save_complete_ctx_add_content(save_complete_ctx *ctx,
- hlcache_handle *content)
+ struct hlcache_handle *content)
{
save_complete_entry *entry;
@@ -114,24 +115,32 @@ static bool save_complete_ctx_add_content(save_complete_ctx *ctx,
return true;
}
-
-static hlcache_handle *save_complete_ctx_find_content(save_complete_ctx *ctx,
- const nsurl *url)
+/**
+ * find handle to content for url
+ *
+ * \param ctx The save context
+ * \param url The url to find content handle for
+ * \return The content handle or NULL if not found.
+ */
+static struct hlcache_handle *
+save_complete_ctx_find_content(save_complete_ctx *ctx, const nsurl *url)
{
save_complete_entry *entry;
- for (entry = ctx->list; entry != NULL; entry = entry->next)
+ for (entry = ctx->list; entry != NULL; entry = entry->next) {
if (nsurl_compare(url,
- hlcache_handle_get_url(entry->content),
- NSURL_COMPLETE))
+ hlcache_handle_get_url(entry->content),
+ NSURL_COMPLETE)) {
return entry->content;
+ }
+ }
return NULL;
}
static bool save_complete_ctx_has_content(save_complete_ctx *ctx,
- hlcache_handle *content)
+ struct hlcache_handle *content)
{
save_complete_entry *entry;
@@ -201,13 +210,14 @@ static char *save_complete_rewrite_stylesheet_urls(save_complete_ctx *ctx,
for (offset = 0; SLEN("@import") < size &&
offset <= size - SLEN("@import"); offset++) {
if (source[offset] == '@' &&
- tolower(source[offset + 1]) == 'i' &&
- tolower(source[offset + 2]) == 'm' &&
- tolower(source[offset + 3]) == 'p' &&
- tolower(source[offset + 4]) == 'o' &&
- tolower(source[offset + 5]) == 'r' &&
- tolower(source[offset + 6]) == 't')
+ ascii_to_lower(source[offset + 1]) == 'i' &&
+ ascii_to_lower(source[offset + 2]) == 'm' &&
+ ascii_to_lower(source[offset + 3]) == 'p' &&
+ ascii_to_lower(source[offset + 4]) == 'o' &&
+ ascii_to_lower(source[offset + 5]) == 'r' &&
+ ascii_to_lower(source[offset + 6]) == 't') {
imports++;
+ }
}
rewritten = malloc(size + imports * 20);
diff --git a/desktop/save_pdf.c b/desktop/save_pdf.c
index 8fd6795..d303eca 100644
--- a/desktop/save_pdf.c
+++ b/desktop/save_pdf.c
@@ -44,6 +44,7 @@
*/
#include "utils/config.h"
+#include "utils/errors.h"
#include "desktop/save_pdf.h"
@@ -52,18 +53,18 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-
#include <hpdf.h>
+#include "utils/log.h"
+#include "utils/utils.h"
+#include "utils/useragent.h"
#include "content/hlcache.h"
#include "utils/nsoption.h"
-#include "desktop/plotters.h"
+#include "netsurf/bitmap.h"
+
+#include "netsurf/plotters.h"
#include "desktop/print.h"
#include "desktop/printer.h"
-#include "image/bitmap.h"
-#include "utils/log.h"
-#include "utils/utils.h"
-#include "utils/useragent.h"
#include "font_haru.h"
diff --git a/desktop/save_text.c b/desktop/save_text.c
index 81c3db6..e63c96e 100644
--- a/desktop/save_text.c
+++ b/desktop/save_text.c
@@ -31,12 +31,11 @@
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
-#include "content/content.h"
-#include "content/hlcache.h"
+#include "netsurf/content.h"
#include "render/box.h"
#include "render/html.h"
-#include "desktop/gui_utf8.h"
+#include "netsurf/utf8.h"
#include "desktop/gui_internal.h"
#include "desktop/save_text.h"
@@ -55,7 +54,7 @@ static bool save_text_add_to_buffer(const char *text, size_t length,
* \param path Path to save text file too.
*/
-void save_as_text(hlcache_handle *c, char *path)
+void save_as_text(struct hlcache_handle *c, char *path)
{
FILE *out;
struct save_text_state save = { NULL, 0, 0 };
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 82fcac1..b9e963a 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -30,11 +30,11 @@
#include "utils/utils.h"
#include "utils/nsoption.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#include "desktop/system_colour.h"
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
#include "desktop/scrollbar.h"
-#include "desktop/plotters.h"
+#include "netsurf/plotters.h"
#include "desktop/plot_style.h"
diff --git a/desktop/searchweb.c b/desktop/searchweb.c
index 83a19c3..29a998e 100644
--- a/desktop/searchweb.c
+++ b/desktop/searchweb.c
@@ -27,6 +27,7 @@
#include "utils/log.h"
#include "utils/url.h"
#include "utils/nsoption.h"
+#include "netsurf/content.h"
#include "content/hlcache.h"
#include "desktop/searchweb.h"
@@ -59,7 +60,7 @@ static const char *default_search_icon_url = "resource:icons/search.png";
/**
* Read providers file.
*
- * Allocates stoage of sufficient size for the providers file and
+ * Allocates storage of sufficient size for the providers file and
* reads the entire file in.
*
* \param fname The filename to read.
@@ -131,7 +132,7 @@ read_providers(const char *fname,
* \param providers_size The size of the provider data.
* \param providers_out The resulting provider array.
* \param providers_count The number of providers in the output array.
- * \return NSERROR_OK on success or error code on faliure.
+ * \return NSERROR_OK on success or error code on failure.
*/
static nserror
parse_providers(char *providersd,
@@ -223,7 +224,7 @@ parse_providers(char *providersd,
* \param provider The provider to use.
* \param term The term being searched for.
* \param url_out The resulting url.
- * \return NSERROR_OK on sucess or appropriate error code.
+ * \return NSERROR_OK on success or appropriate error code.
*/
static nserror
make_search_nsurl(struct search_provider *provider,
@@ -239,7 +240,7 @@ make_search_nsurl(struct search_provider *provider,
size_t urlstr_len;
/* escape the search term and join it to the search url */
- ret = url_escape(term, 0, true, NULL, &eterm);
+ ret = url_escape(term, true, NULL, &eterm);
if (ret != NSERROR_OK) {
return ret;
}
@@ -288,7 +289,7 @@ search_web_ico_callback(hlcache_handle *ico,
switch (event->type) {
case CONTENT_MSG_DONE:
- LOG("icon '%s' retrived", nsurl_access(hlcache_handle_get_url(ico)));
+ LOG("icon '%s' retrieved", nsurl_access(hlcache_handle_get_url(ico)));
guit->search_web->provider_update(provider->name,
content_get_bitmap(ico));
break;
@@ -398,7 +399,7 @@ nserror search_web_select_provider(int selection)
guit->search_web->provider_update(provider->name, ico_bitmap);
- /* if the providers icon has not been retrived get it now */
+ /* if the providers icon has not been retrieved get it now */
if (provider->ico_handle == NULL) {
nsurl *icon_nsurl;
nserror ret;
@@ -437,7 +438,7 @@ default_ico_callback(hlcache_handle *ico,
switch (event->type) {
case CONTENT_MSG_DONE:
- LOG("default icon '%s' retrived", nsurl_access(hlcache_handle_get_url(ico)));
+ LOG("default icon '%s' retrieved", nsurl_access(hlcache_handle_get_url(ico)));
/* only set to default icon if providers icon has no handle */
if (ctx->providers[search_web_ctx.current].ico_handle == NULL) {
diff --git a/desktop/selection.c b/desktop/selection.c
index e2bd747..7506af0 100644
--- a/desktop/selection.c
+++ b/desktop/selection.c
@@ -31,19 +31,19 @@
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "netsurf/form.h"
#include "render/box.h"
-#include "render/form.h"
#include "render/html_internal.h"
#include "render/font.h"
#include "render/textplain.h"
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
#include "desktop/browser_private.h"
-#include "desktop/plotters.h"
+#include "netsurf/plotters.h"
#include "desktop/save_text.h"
#include "desktop/selection.h"
-#include "desktop/gui_clipboard.h"
-#include "desktop/gui_window.h"
+#include "netsurf/clipboard.h"
+#include "netsurf/window.h"
#include "desktop/gui_internal.h"
/**
diff --git a/desktop/selection.h b/desktop/selection.h
index 7e620fc..e2bc3b3 100644
--- a/desktop/selection.h
+++ b/desktop/selection.h
@@ -24,7 +24,7 @@
#define _NETSURF_DESKTOP_SELECTION_H_
#include <stdbool.h>
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
struct box;
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index f3eb169..09a281c 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -353,6 +353,11 @@ nserror sslcert_viewer_init(struct core_window_callback_table *cw_t,
assert(ssl_d != NULL);
+ err = treeview_init();
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
LOG("Building certificate viewer");
/* Init. certificate chain treeview entry fields */
@@ -427,6 +432,11 @@ nserror sslcert_viewer_fini(struct sslcert_session_data *ssl_d)
/* Destroy the sslcert_session_data */
sslcert_cleanup_session(ssl_d);
+ err = treeview_fini();
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
LOG("Finalised ssl certificate viewer");
return err;
@@ -516,8 +526,7 @@ void sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
/* Exported interface, documented in sslcert_viewer.h */
-void sslcert_viewer_keypress(struct sslcert_session_data *ssl_d,
- uint32_t key)
+bool sslcert_viewer_keypress(struct sslcert_session_data *ssl_d, uint32_t key)
{
- treeview_keypress(ssl_d->tree, key);
+ return treeview_keypress(ssl_d->tree, key);
}
diff --git a/desktop/sslcert_viewer.h b/desktop/sslcert_viewer.h
index 92f402f..9b21cd1 100644
--- a/desktop/sslcert_viewer.h
+++ b/desktop/sslcert_viewer.h
@@ -22,7 +22,7 @@
#define _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
#include "content/llcache.h"
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
struct sslcert_session_data;
struct redraw_context;
@@ -119,7 +119,6 @@ void sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
* \param key The ucs4 character codepoint
* \return true if the keypress is dealt with, false otherwise.
*/
-void sslcert_viewer_keypress(struct sslcert_session_data *ssl_d,
- uint32_t key);
+bool sslcert_viewer_keypress(struct sslcert_session_data *ssl_d, uint32_t key);
#endif
diff --git a/desktop/system_colour.c b/desktop/system_colour.c
index 178c035..f33b57a 100644
--- a/desktop/system_colour.c
+++ b/desktop/system_colour.c
@@ -26,10 +26,10 @@
#include "utils/config.h"
#include "utils/utils.h"
#include "utils/log.h"
-#include "css/utils.h"
-#include "desktop/system_colour.h"
#include "utils/nsoption.h"
+#include "netsurf/css.h"
+#include "desktop/system_colour.h"
#define colour_list_len ((NSOPTION_SYS_COLOUR_END - NSOPTION_SYS_COLOUR_START) + 1)
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 467965d..203c28e 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -26,19 +26,19 @@
#include <stdint.h>
#include <string.h>
-#include "css/utils.h"
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/plotters.h"
+#include "netsurf/mouse.h"
+#include "netsurf/keypress.h"
+#include "netsurf/clipboard.h"
+#include "netsurf/layout.h"
+#include "css/utils.h"
-#include "desktop/browser.h"
-#include "desktop/mouse.h"
#include "desktop/textarea.h"
-#include "desktop/textinput.h"
-#include "desktop/plotters.h"
#include "desktop/scrollbar.h"
-#include "desktop/gui_clipboard.h"
-#include "desktop/gui_layout.h"
#include "desktop/gui_internal.h"
#define CARET_COLOR 0x0000FF
diff --git a/desktop/textarea.h b/desktop/textarea.h
index 66d5cbc..74652f3 100644
--- a/desktop/textarea.h
+++ b/desktop/textarea.h
@@ -29,7 +29,11 @@
#include "utils/utils.h"
+#include "desktop/plot_style.h"
+#include "netsurf/mouse.h"
+
struct textarea;
+struct redraw_context;
/* Text area flags */
typedef enum {
diff --git a/desktop/textinput.c b/desktop/textinput.c
index bd51d5a..c0e0ba8 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -33,15 +33,16 @@
#include "utils/talloc.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "netsurf/mouse.h"
+#include "netsurf/form.h"
+#include "netsurf/window.h"
+#include "netsurf/keypress.h"
#include "render/box.h"
-#include "render/form.h"
#include "render/html_internal.h"
#include "render/layout.h"
-#include "desktop/mouse.h"
#include "desktop/browser_private.h"
#include "desktop/textinput.h"
-#include "desktop/gui_window.h"
#include "desktop/gui_internal.h"
/* Define to enable textinput debug */
@@ -101,7 +102,7 @@ void browser_window_remove_caret(struct browser_window *bw, bool only_hide)
}
}
-/* exported interface documented in desktop/textinput.h */
+/* exported interface documented in netsurf/keypress.h */
bool browser_window_key_press(struct browser_window *bw, uint32_t key)
{
struct browser_window *focus = bw->focus;
diff --git a/desktop/textinput.h b/desktop/textinput.h
index 0b35931..5859ea8 100644
--- a/desktop/textinput.h
+++ b/desktop/textinput.h
@@ -19,8 +19,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Textual input handling (interface)
+/**
+ * \file
+ * Textual input handling interface
*/
#ifndef _NETSURF_DESKTOP_TEXTINPUT_H_
@@ -28,49 +29,6 @@
struct browser_window;
-enum input_key {
-
- NS_KEY_SELECT_ALL = 1,
- NS_KEY_COPY_SELECTION = 3,
-
- NS_KEY_DELETE_LEFT = 8,
- NS_KEY_TAB = 9,
-
- NS_KEY_NL = 10,
- NS_KEY_SHIFT_TAB = 11,
- NS_KEY_CR = 13,
-
- NS_KEY_DELETE_LINE = 21,
- NS_KEY_PASTE = 22,
- NS_KEY_CUT_SELECTION = 24,
- NS_KEY_CLEAR_SELECTION = 26,
-
- NS_KEY_ESCAPE = 27,
-
- /* cursor movement keys */
- NS_KEY_LEFT = 28,
- NS_KEY_RIGHT,
- NS_KEY_UP,
- NS_KEY_DOWN,
-
- NS_KEY_DELETE_RIGHT = 127,
-
- NS_KEY_LINE_START = 128,
- NS_KEY_LINE_END,
- NS_KEY_TEXT_START,
- NS_KEY_TEXT_END,
- NS_KEY_WORD_LEFT,
- NS_KEY_WORD_RIGHT,
- NS_KEY_PAGE_UP,
- NS_KEY_PAGE_DOWN,
- NS_KEY_DELETE_LINE_END,
- NS_KEY_DELETE_LINE_START,
-
- NS_KEY_UNDO,
- NS_KEY_REDO
-};
-
-
/**
* Position the caret and assign a callback for key presses.
*
@@ -91,13 +49,5 @@ void browser_window_place_caret(struct browser_window *bw, int x, int y,
*/
void browser_window_remove_caret(struct browser_window *bw, bool only_hide);
-/**
- * Handle key presses in a browser window.
- *
- * \param bw The root browser window
- * \param key The UCS4 character codepoint
- * \return true if key handled, false otherwise
- */
-bool browser_window_key_press(struct browser_window *bw, uint32_t key);
#endif
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 97cf30d..1d0ac52 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -23,24 +23,29 @@
*/
#include "utils/log.h"
-#include "css/utils.h"
-#include "image/bitmap.h"
+#include "utils/nsurl.h"
+#include "utils/nsoption.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
+#include "netsurf/plotters.h"
+#include "netsurf/clipboard.h"
+#include "netsurf/layout.h"
+#include "netsurf/keypress.h"
+#include "netsurf/core_window.h"
#include "content/hlcache.h"
+#include "css/utils.h"
#include "desktop/system_colour.h"
#include "desktop/knockout.h"
-#include "desktop/plotters.h"
#include "desktop/textarea.h"
#include "desktop/treeview.h"
-#include "desktop/gui_clipboard.h"
-#include "desktop/gui_layout.h"
#include "desktop/gui_internal.h"
/** @todo get rid of REDRAW_MAX -- need to be able to know window size */
#define REDRAW_MAX 8000
struct treeview_globals {
- bool initialised;
+ unsigned initialised;
int line_height;
int furniture_width;
int step_width;
@@ -214,6 +219,72 @@ static struct treeview_resource treeview_res[TREE_RES_LAST] = {
}; /**< Treeview content resources */
+/**
+ * Corewindow callback wrapper: Request a redraw of the window
+ *
+ * \param[in] cw the core window object
+ * \param[in] r rectangle to redraw
+ */
+static inline void treeview__cw_redraw_request(
+ const struct treeview *tree,
+ const struct rect *r)
+{
+ if (tree->cw_t != NULL) {
+ tree->cw_t->redraw_request(tree->cw_h, r);
+ }
+}
+
+
+/**
+ * Corewindow callback wrapper: Update the limits of the window
+ *
+ * \param[in] cw the core window object
+ * \param[in] width the width in px, or negative if don't care
+ * \param[in] height the height in px, or negative if don't care
+ */
+static inline void treeview__cw_update_size(
+ const struct treeview *tree,
+ int width, int height)
+{
+ if (tree->cw_t != NULL) {
+ tree->cw_t->update_size(tree->cw_h, width, height);
+ }
+}
+
+
+/**
+ * Corewindow callback wrapper: Get window viewport dimensions
+ *
+ * \param[in] cw the core window object
+ * \param[out] width to be set to viewport width in px
+ * \param[out] height to be set to viewport height in px
+ */
+static inline void treeview__cw_get_window_dimensions(
+ const struct treeview *tree,
+ int *width, int *height)
+{
+ if (tree->cw_t != NULL) {
+ tree->cw_t->get_window_dimensions(tree->cw_h, width, height);
+ }
+}
+
+
+/**
+ * Corewindow callback wrapper: Inform corewindow owner of drag status
+ *
+ * \param[in] cw the core window object
+ * \param[in] ds the current drag status
+ */
+static inline void treeview__cw_drag_status(
+ const struct treeview *tree,
+ core_window_drag_status ds)
+{
+ if (tree->cw_t != NULL) {
+ tree->cw_t->drag_status(tree->cw_h, ds);
+ }
+}
+
+
/* Helper function to access the given field of a node
*
* \param tree Treeview that node belongs to
@@ -600,7 +671,7 @@ nserror treeview_create_node_folder(treeview *tree,
if (n->parent->flags & TV_NFLAGS_EXPANDED) {
/* Inform front end of change in dimensions */
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE))
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
/* Redraw */
@@ -610,7 +681,7 @@ nserror treeview_create_node_folder(treeview *tree,
r.y0 = treeview_node_y(tree, n);
r.x1 = REDRAW_MAX;
r.y1 = tree->root->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -660,7 +731,7 @@ nserror treeview_update_node_folder(treeview *tree,
r.y0 = treeview_node_y(tree, folder);
r.x1 = REDRAW_MAX;
r.y1 = r.y0 + tree_g.line_height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -731,7 +802,7 @@ nserror treeview_update_node_entry(treeview *tree,
r.y0 = treeview_node_y(tree, entry);
r.x1 = REDRAW_MAX;
r.y1 = r.y0 + entry->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -806,7 +877,7 @@ nserror treeview_create_node_entry(treeview *tree,
if (n->parent->flags & TV_NFLAGS_EXPANDED) {
/* Inform front end of change in dimensions */
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE))
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
/* Redraw */
@@ -816,7 +887,7 @@ nserror treeview_create_node_entry(treeview *tree,
r.y0 = treeview_node_y(tree, n);
r.x1 = REDRAW_MAX;
r.y1 = tree->root->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -937,7 +1008,7 @@ static void treeview_edit_cancel(treeview *tree, bool redraw)
r.y0 = tree->edit.y;
r.x1 = tree->edit.x + tree->edit.w;
r.y1 = tree->edit.y + tree->edit.h;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -1105,7 +1176,7 @@ static nserror treeview_delete_node_internal(treeview *tree, treeview_node *n,
if (tree->root != NULL && p != NULL && p->flags & TV_NFLAGS_EXPANDED &&
nd.h_reduction > 0 &&
!(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
@@ -1248,7 +1319,7 @@ nserror treeview_delete_node(treeview *tree, treeview_node *n,
if (tree->root->height != h) {
r.y0 = 0;
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
}
@@ -1258,7 +1329,7 @@ nserror treeview_delete_node(treeview *tree, treeview_node *n,
if (visible && !(flags & TREE_OPTION_SUPPRESS_REDRAW)) {
r.x0 = 0;
r.x1 = REDRAW_MAX;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -1275,8 +1346,7 @@ nserror treeview_create(treeview **tree,
nserror error;
int i;
- assert(cw_t != NULL);
- assert(cw != NULL);
+ assert((cw_t == NULL && cw == NULL) || (cw_t != NULL && cw != NULL));
assert(callbacks != NULL);
assert(fields != NULL);
@@ -1352,6 +1422,35 @@ nserror treeview_create(treeview **tree,
/* Exported interface, documented in treeview.h */
+nserror treeview_cw_attach(treeview *tree,
+ const struct core_window_callback_table *cw_t,
+ struct core_window *cw)
+{
+ assert(cw_t != NULL);
+ assert(cw != NULL);
+
+ if (tree->cw_t != NULL || tree->cw_h != NULL) {
+ LOG("Treeview already attached.");
+ return NSERROR_UNKNOWN;
+ }
+ tree->cw_t = cw_t;
+ tree->cw_h = cw;
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
+nserror treeview_cw_detach(treeview *tree)
+{
+ tree->cw_t = NULL;
+ tree->cw_h = NULL;
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
nserror treeview_destroy(treeview *tree)
{
int f;
@@ -1464,7 +1563,7 @@ static nserror treeview_node_expand_internal(treeview *tree,
/* Inform front end of change in dimensions */
if (additional_height != 0)
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return NSERROR_OK;
}
@@ -1486,7 +1585,7 @@ nserror treeview_node_expand(treeview *tree, treeview_node *node)
r.y1 = tree->root->height;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1558,7 +1657,7 @@ static nserror treeview_node_contract_internal(treeview *tree,
node->flags |= TV_NFLAGS_SELECTED;
/* Inform front end of change in dimensions */
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return NSERROR_OK;
}
@@ -1582,7 +1681,7 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
return err;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1625,10 +1724,10 @@ nserror treeview_contract(treeview *tree, bool all)
}
/* Inform front end of change in dimensions */
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1682,7 +1781,7 @@ nserror treeview_expand(treeview *tree, bool only_folders)
r.y1 = tree->root->height;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -2469,7 +2568,7 @@ static nserror treeview_move_selection(treeview *tree, struct rect *rect)
/* Tell window, if height has changed */
if (height != tree->root->height)
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
/* TODO: Deal with redraw area properly */
rect->x0 = 0;
@@ -2777,7 +2876,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
/* Inform front end of change in dimensions */
if (tree->root->height != h) {
r.y0 = 0;
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
}
@@ -2801,7 +2900,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
}
if (redraw) {
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return true;
@@ -2958,7 +3057,7 @@ static void treeview_textarea_callback(void *data, struct textarea_msg *msg)
/* Textarea drag started */
tree->drag.type = TV_DRAG_TEXTAREA;
}
- tree->cw_t->drag_status(tree->cw_h, tree->drag.type);
+ treeview__cw_drag_status(tree, tree->drag.type);
break;
case TEXTAREA_MSG_REDRAW_REQUEST:
@@ -2969,7 +3068,7 @@ static void treeview_textarea_callback(void *data, struct textarea_msg *msg)
r->y1 += tree->edit.y;
/* Redraw the textarea */
- tree->cw_t->redraw_request(tree->cw_h, r);
+ treeview__cw_redraw_request(tree, r);
break;
default:
@@ -3039,7 +3138,7 @@ static bool treeview_edit_node_at_point(treeview *tree, treeview_node *n,
}
/* Get window width/height */
- tree->cw_t->get_window_dimensions(tree->cw_h, &width, &height);
+ treeview__cw_get_window_dimensions(tree, &width, &height);
/* Anow textarea width/height */
field_x = n->inset + tree_g.step_width + tree_g.icon_step - 3;
@@ -3142,7 +3241,7 @@ void treeview_edit_selection(treeview *tree)
rect.y0 = y;
rect.x1 = REDRAW_MAX;
rect.y1 = y + tree_g.line_height;
- tree->cw_t->redraw_request(tree->cw_h, &rect);
+ treeview__cw_redraw_request(tree, &rect);
}
@@ -3261,7 +3360,7 @@ static nserror treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
ma->tree->drag.selected == false &&
ma->tree->drag.part == TV_NODE_PART_NONE) {
ma->tree->drag.type = TV_DRAG_SELECTION;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_SELECTION);
} else if (!(ma->tree->flags & TREEVIEW_NO_MOVES) &&
@@ -3269,13 +3368,13 @@ static nserror treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
(ma->tree->drag.selected == true ||
ma->tree->drag.part == TV_NODE_PART_ON_NODE)) {
ma->tree->drag.type = TV_DRAG_MOVE;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_MOVE);
redraw |= treeview_propagate_selection(ma->tree, &r);
} else if (ma->mouse & BROWSER_MOUSE_DRAG_2) {
ma->tree->drag.type = TV_DRAG_SELECTION;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_SELECTION);
}
@@ -3402,7 +3501,7 @@ static nserror treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
}
if (redraw) {
- ma->tree->cw_t->redraw_request(ma->tree->cw_h, &r);
+ treeview__cw_redraw_request(ma->tree, &r);
}
*end = true; /* Reached line with click; stop walking tree */
@@ -3451,8 +3550,7 @@ void treeview_mouse_action(treeview *tree,
tree->drag.type = TV_DRAG_NONE;
tree->drag.start_node = NULL;
- tree->cw_t->drag_status(tree->cw_h,
- CORE_WINDOW_DRAG_NONE);
+ treeview__cw_drag_status(tree, CORE_WINDOW_DRAG_NONE);
return;
case TV_DRAG_MOVE:
treeview_move_selection(tree, &r);
@@ -3462,9 +3560,8 @@ void treeview_mouse_action(treeview *tree,
tree->move.target = NULL;
tree->move.target_pos = TV_TARGET_NONE;
- tree->cw_t->drag_status(tree->cw_h,
- CORE_WINDOW_DRAG_NONE);
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_drag_status(tree, CORE_WINDOW_DRAG_NONE);
+ treeview__cw_redraw_request(tree, &r);
return;
default:
/* No drag to end */
@@ -3501,11 +3598,11 @@ void treeview_mouse_action(treeview *tree,
tree->drag.selected == false &&
tree->drag.part == TV_NODE_PART_NONE) {
tree->drag.type = TV_DRAG_SELECTION;
- tree->cw_t->drag_status(tree->cw_h,
+ treeview__cw_drag_status(tree,
CORE_WINDOW_DRAG_SELECTION);
} else if (mouse & BROWSER_MOUSE_DRAG_2) {
tree->drag.type = TV_DRAG_SELECTION;
- tree->cw_t->drag_status(tree->cw_h,
+ treeview__cw_drag_status(tree,
CORE_WINDOW_DRAG_SELECTION);
}
@@ -3539,7 +3636,7 @@ void treeview_mouse_action(treeview *tree,
}
if (redraw) {
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
} else {
@@ -3564,7 +3661,7 @@ int treeview_get_height(treeview *tree)
assert(tree != NULL);
assert(tree->root != NULL);
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return tree->root->height;
}
@@ -3584,7 +3681,7 @@ static void treeview_init_plot_styles(int font_pt_size)
/* Text colour */
plot_style_even.text.family = PLOT_FONT_FAMILY_SANS_SERIF;
- plot_style_even.text.size = font_pt_size * FONT_SIZE_SCALE;
+ plot_style_even.text.size = font_pt_size;
plot_style_even.text.weight = 400;
plot_style_even.text.flags = FONTF_NONE;
plot_style_even.text.foreground = ns_system_colour_char("WindowText");
@@ -3634,8 +3731,10 @@ static void treeview_init_plot_styles(int font_pt_size)
/**
* Callback for hlcache.
*/
-static nserror treeview_res_cb(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
+static nserror
+treeview_res_cb(struct hlcache_handle *handle,
+ const hlcache_event *event,
+ void *pw)
{
struct treeview_resource *r = pw;
@@ -3663,6 +3762,8 @@ static void treeview_init_resources(void)
for (i = 0; i < TREE_RES_LAST; i++) {
nsurl *url;
+ treeview_res[i].ready = false;
+ treeview_res[i].height = 0;
if (nsurl_create(treeview_res[i].url, &url) == NSERROR_OK) {
hlcache_handle_retrieve(url, 0, NULL, NULL,
treeview_res_cb,
@@ -3942,23 +4043,29 @@ static nserror treeview_init_furniture(void)
/* Exported interface, documented in treeview.h */
-nserror treeview_init(int font_pt_size)
+nserror treeview_init(void)
{
- int font_px_size;
+ long long font_px_size;
+ long long font_pt_size;
nserror err;
- if (tree_g.initialised == true)
+ if (tree_g.initialised > 0) {
+ tree_g.initialised++;
return NSERROR_OK;
+ }
LOG("Initialising treeview module");
- if (font_pt_size <= 0)
- font_pt_size = 11;
+ font_pt_size = nsoption_int(treeview_font_size);
+ if (font_pt_size <= 0) {
+ font_pt_size = 11 * 10;
+ }
- font_px_size = (font_pt_size * FIXTOINT(nscss_screen_dpi) + 36) / 72;
+ font_px_size = (font_pt_size * FIXTOINT(nscss_screen_dpi) /
+ 10 + 36) / 72;
tree_g.line_height = (font_px_size * 8 + 3) / 6;
- treeview_init_plot_styles(font_pt_size);
+ treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
treeview_init_resources();
err = treeview_init_furniture();
if (err != NSERROR_OK)
@@ -3970,7 +4077,7 @@ nserror treeview_init(int font_pt_size)
tree_g.icon_step = 23;
tree_g.move_offset = 18;
- tree_g.initialised = true;
+ tree_g.initialised++;
LOG("Initialised treeview module");
@@ -3983,6 +4090,15 @@ nserror treeview_fini(void)
{
int i;
+ if (tree_g.initialised > 1) {
+ tree_g.initialised--;
+ return NSERROR_OK;
+
+ } else if (tree_g.initialised == 0) {
+ LOG("Warning: tried to finalise uninitialised treeview module");
+ return NSERROR_OK;
+ }
+
LOG("Finalising treeview module");
for (i = 0; i < TREE_RES_LAST; i++) {
@@ -3998,7 +4114,7 @@ nserror treeview_fini(void)
guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].bmp);
guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].sel);
- tree_g.initialised = false;
+ tree_g.initialised--;
LOG("Finalised treeview module");
diff --git a/desktop/treeview.h b/desktop/treeview.h
index d4d4ce9..518f045 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Treeview handling (interface).
+/**
+ * \file
+ * Treeview handling interface.
*/
#ifndef _NETSURF_DESKTOP_TREEVIEW_H_
@@ -25,12 +26,13 @@
#include <stdbool.h>
#include <stdint.h>
+#include <libwapcaplet/libwapcaplet.h>
-#include "desktop/mouse.h"
-#include "desktop/core_window.h"
-#include "desktop/textinput.h"
+#include "netsurf/mouse.h"
struct redraw_context;
+struct core_window;
+struct core_window_callback_table;
typedef struct treeview treeview;
typedef struct treeview_node treeview_node;
@@ -110,10 +112,9 @@ struct treeview_callback_table {
/**
* Prepare treeview module for treeview usage
*
- * \param font_pt_size Treeview text size in pt. Set to <= 0 for default.
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror treeview_init(int font_pt_size);
+nserror treeview_init(void);
/**
* Finalise the treeview module (all treeviews must have been destroyed first)
@@ -149,6 +150,28 @@ nserror treeview_create(treeview **tree,
struct core_window *cw, treeview_flags flags);
/**
+ * Attach a treeview to a corewindow.
+ *
+ * Treeview must be detached.
+ *
+ * \param tree Treeview object
+ * \param cw_t Callback table for core_window containing the treeview
+ * \param cw The core_window in which the treeview is shown
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_cw_attach(treeview *tree,
+ const struct core_window_callback_table *cw_t,
+ struct core_window *cw);
+
+/**
+ * Detach a treeview from a corewindow
+ *
+ * \param tree Treeview object
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_cw_detach(treeview *tree);
+
+/**
* Destroy a treeview object
*
* \param tree Treeview object to destroy
diff --git a/desktop/version.c b/desktop/version.c
index 6828f82..6126c5b 100644
--- a/desktop/version.c
+++ b/desktop/version.c
@@ -20,11 +20,11 @@
#include "desktop/version.h"
-const char * const netsurf_version = "3.6 (Dev"
+const char * const netsurf_version = "3.7 (Dev"
#if defined(CI_BUILD)
" CI #" CI_BUILD
#endif
")"
;
const int netsurf_version_major = 3;
-const int netsurf_version_minor = 6;
+const int netsurf_version_minor = 7;
diff --git a/frontends/Makefile b/frontends/Makefile
index da6fe20..f0f9145 100644
--- a/frontends/Makefile
+++ b/frontends/Makefile
@@ -7,3 +7,5 @@ FRONTEND_RESOURCES_DIR := frontends/$(TARGET)/res
include frontends/$(TARGET)/Makefile
S_FRONTEND := $(addprefix frontends/$(TARGET)/,$(S_FRONTEND))
+
+INCLUDE_DIRS += frontends
diff --git a/frontends/amiga/Makefile b/frontends/amiga/Makefile
index 2b727ca..f3c178e 100644
--- a/frontends/amiga/Makefile
+++ b/frontends/amiga/Makefile
@@ -7,47 +7,23 @@ CFLAGS += -std=c99 -Dnsamiga
ifneq ($(SUBTARGET),os3)
CFLAGS += -O2 -finline-functions -U__STRICT_ANSI__ -D__USE_INLINE__ -D__USE_BASETYPE__
else
- CFLAGS += -msoft-float -m68020-60 -O2 -DPATH_MAX=1024 -D__m68k__
+ CFLAGS += -O2 -DPATH_MAX=1024 -D__m68k__ -m68020
endif
-NETSURF_FEATURE_ROSPRITE_CFLAGS := -DWITH_NSSPRITE
-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_VIDEO_CFLAGS := -DWITH_VIDEO
-
-ifeq ($(HOST),amiga)
- $(eval $(call feature_enabled,ROSPRITE,-DWITH_NSSPRITE,-lrosprite,Sprite (librosprite)))
- $(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,BMP (libnsbmp)))
- $(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,GIF (libnsgif)))
- $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng) ))
- $(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
- $(eval $(call feature_enabled,VIDEO,-DWITH_VIDEO -I /SDK/local/newlib/include/glib-2.0,-lgstreamer-0.10 -lglib-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lintl -lffi,Video (libgstreamer)))
- $(eval $(call feature_enabled,JS,-DXP_UNIX -DWITH_JS -DJS_VERSION=185,-lstdc++ -lmozjs185,JavaScript))
- $(eval $(call feature_enabled,MOZJS,-DXP_AMIGA -DWITH_MOZJS -DJS_VERSION=170 -DJSVERSION_LATEST=170 -DJSOPTION_JIT=0 -DJSCLASS_GLOBAL_FLAGS=0,-ljs -lfdlibm,JavaScript))
- $(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
- $(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
-
- CFLAGS += -I /SDK/local/common/include/libpng12
- LDFLAGS += -lcurl -lrtmp -lpthread -ltre -lintl -lpbl
- LDFLAGS += -lssl -lcrypto -ldom -lhubbub -lcss -lparserutils -lwapcaplet
-else
- $(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
- $(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
+$(eval $(call feature_enabled,AMIGA_ICON,-DWITH_AMIGA_ICON,,Amiga icon))
+$(eval $(call feature_enabled,AMIGA_DATATYPES,-DWITH_AMIGA_DATATYPES,,DataTypes))
- CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include
- CFLAGS += $(shell $(PKG_CONFIG) --cflags tre)
+CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include
+CFLAGS += $(shell $(PKG_CONFIG) --cflags tre)
- LDFLAGS += $(shell $(PKG_CONFIG) --static --libs libcurl openssl)
- LDFLAGS += $(shell $(PKG_CONFIG) --libs tre)
- LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
+LDFLAGS += $(shell $(PKG_CONFIG) --static --libs libcurl openssl)
+LDFLAGS += $(shell $(PKG_CONFIG) --libs tre)
+LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
- LDFLAGS += -lpbl -liconv
+LDFLAGS += -lpbl -liconv
- ifeq ($(SUBTARGET),os3)
- LDFLAGS += -lamiga -lm
- endif
+ifeq ($(SUBTARGET),os3)
+ LDFLAGS += -lamiga -lm
endif
EXETARGET := NetSurf
@@ -61,7 +37,7 @@ MESSAGES_FILTER=ami
# sources purely for the Amiga build
S_FRONTEND := gui.c tree.c history.c hotlist.c schedule.c file.c \
- misc.c bitmap.c font.c filetype.c utf8.c login.c \
+ misc.c bitmap.c font.c filetype.c utf8.c login.c memory.c \
plotters.c object.c menu.c save_pdf.c arexx.c version.c \
cookies.c ctxmenu.c clipboard.c help.c font_scan.c \
launch.c search.c history_local.c download.c iff_dr2d.c \
@@ -69,7 +45,8 @@ S_FRONTEND := gui.c tree.c history.c hotlist.c schedule.c file.c \
datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \
stringview/stringview.c stringview/urlhistory.c rtg.c \
agclass/amigaguide_class.c os3support.c font_diskfont.c \
- selectmenu.c hash/xxhash.c font_cache.c font_bullet.c
+ selectmenu.c hash/xxhash.c font_cache.c font_bullet.c \
+ nsoption.c desktop-tree.c
# This is the final source build list
# Note this is deliberately *not* expanded here as common and image
@@ -89,7 +66,7 @@ install-amiga:
package-amiga: netsurf.lha
AMIGA_LANGUAGES := de en it ja nl
-AMIGA_PLATFORM_RESOURCES := Pointers Themes default.css default.css.info favicon.png LangNames mimetypes Resource.map SearchEngines splash.png
+AMIGA_PLATFORM_RESOURCES := Pointers Themes default.css default.css.info favicon.png LangNames mimetypes Resource.map splash.png
AMIGA_GENERIC_RESOURCES := $(AMIGA_LANGUAGES) ca-bundle Icons
AMIGA_RESOURCES := $(addprefix $(FRONTEND_SOURCE_DIR)/resources/,$(AMIGA_PLATFORM_RESOURCES)) $(addprefix \!NetSurf/Resources/,$(AMIGA_GENERIC_RESOURCES))
AMIGA_DISTRIBUTION_FILES := $(FRONTEND_SOURCE_DIR)/dist/*
@@ -102,21 +79,22 @@ netsurf.lha: $(EXETARGET)
$(Q)mkdir -p $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
$(Q)cp -p $(EXETARGET) $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
$(Q)mkdir $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources
- $(Q)cp -r $(AMIGA_RESOURCES) $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources
- $(Q)cp -r $(AMIGA_DISTRIBUTION_FILES) $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
- $(Q)cp \!NetSurf/Resources/AdBlock,f79 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/adblock.css
- $(Q)cp \!NetSurf/Resources/CSS,f79 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/nsdefault.css
- $(Q)cp \!NetSurf/Resources/internal.css,f79 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/internal.css
- $(Q)cp \!NetSurf/Resources/Quirks,f79 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/quirks.css
- $(Q)cp \!NetSurf/Resources/netsurf.png,b60 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/netsurf.png
- $(Q)cp $(AMIGA_PKG_DIR)/drawer.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf.info
- $(Q)cp $(AMIGA_PKG_DIR)/AutoInstall $(AMIGA_INSTALL_TARGET_DIR)
+ $(Q)cp -rp $(AMIGA_RESOURCES) $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources
+ $(Q)cp -rp $(AMIGA_DISTRIBUTION_FILES) $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
+ $(Q)cat resources/SearchEngines $(AMIGA_PKG_DIR)/SearchEngines >$(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/SearchEngines
+ $(Q)cp -p \!NetSurf/Resources/AdBlock,f79 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/adblock.css
+ $(Q)cp -p \!NetSurf/Resources/CSS,f79 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/nsdefault.css
+ $(Q)cp -p \!NetSurf/Resources/internal.css,f79 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/internal.css
+ $(Q)cp -p \!NetSurf/Resources/Quirks,f79 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/quirks.css
+ $(Q)cp -p \!NetSurf/Resources/netsurf.png,b60 $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/netsurf.png
+ $(Q)cp -p $(AMIGA_PKG_DIR)/drawer.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf.info
+ $(Q)cp -p $(AMIGA_PKG_DIR)/AutoInstall $(AMIGA_INSTALL_TARGET_DIR)
ifeq ($(SUBTARGET),os3)
- $(Q)cp $(AMIGA_PKG_DIR)/netsurf_os3.readme $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
- $(Q)cp $(AMIGA_PKG_DIR)/netsurf_os3.readme.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
+ $(Q)cp -p $(AMIGA_PKG_DIR)/netsurf_os3.readme $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
+ $(Q)cp -p $(AMIGA_PKG_DIR)/netsurf_os3.readme.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
else
- $(Q)cp $(AMIGA_PKG_DIR)/netsurf.readme $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
- $(Q)cp $(AMIGA_PKG_DIR)/netsurf.readme.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
+ $(Q)cp -p $(AMIGA_PKG_DIR)/netsurf.readme $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
+ $(Q)cp -p $(AMIGA_PKG_DIR)/netsurf.readme.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
endif
$(Q)cd $(AMIGA_INSTALL_TARGET_DIR); \
lha a netsurf.lha NetSurf NetSurf.info AutoInstall
diff --git a/frontends/amiga/Makefile.defaults b/frontends/amiga/Makefile.defaults
index 0674a9d..f19d6e3 100644
--- a/frontends/amiga/Makefile.defaults
+++ b/frontends/amiga/Makefile.defaults
@@ -4,11 +4,7 @@
# Force using glibc internal iconv implementation instead of external libiconv
# Valid options: YES, NO
-ifneq ($(SUBTARGET),os3)
- NETSURF_USE_LIBICONV_PLUG := YES
-else
- NETSURF_USE_LIBICONV_PLUG := NO
-endif
+NETSURF_USE_LIBICONV_PLUG := NO
# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
# Valid options: YES, NO, AUTO
@@ -26,12 +22,6 @@ NETSURF_USE_AMIGA_DATATYPES := YES
# Valid options: YES, NO
NETSURF_USE_NSSVG := YES
-# 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
-
# Enable building the source object cache filesystem based backing store.
# implementation.
# Valid options: YES, NO
diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c
index c5b5ab4..b970228 100644
--- a/frontends/amiga/arexx.c
+++ b/frontends/amiga/arexx.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2010 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2010, 2016 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -29,23 +29,26 @@
#include <gadgets/clicktab.h>
#include <reaction/reaction_macros.h>
-#include "utils/utils.h"
#include "utils/log.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
-#include "content/hlcache.h"
-#include "desktop/browser.h"
-#include "desktop/gui_window.h"
+#include "netsurf/content.h"
+#include "netsurf/browser_window.h"
#include "desktop/version.h"
#include "amiga/arexx.h"
-#include "amiga/download.h"
#include "amiga/gui.h"
+#include "amiga/download.h"
#include "amiga/hotlist.h"
+#include "amiga/tree.h"
#include "amiga/libs.h"
#include "amiga/misc.h"
#include "amiga/theme.h"
+#ifndef __amigaos4__
+#include "amiga/memory.h"
+#endif
+
extern const char * const verarexx;
extern const char * const wt_revid;
@@ -66,31 +69,40 @@ enum
RX_WINDOWS,
RX_ACTIVE,
RX_CLOSE,
- RX_HOTLIST
+ RX_HOTLIST,
+ RX_SLABSTATS
};
+static Object *arexx_obj = NULL;
STATIC char result[100];
-STATIC VOID rx_open(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_quit(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_tofront(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_geturl(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_gettitle(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_version(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_save(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_pubscreen(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_back(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_forward(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_home(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_reload(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_windows(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_active(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_close(struct ARexxCmd *, struct RexxMsg *);
-STATIC VOID rx_hotlist(struct ARexxCmd *, struct RexxMsg *);
+#ifdef __amigaos4__
+#define RXHOOKF(func) static VOID func(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+#else
+#define RXHOOKF(func) static ASM VOID func(REG(a0, struct ARexxCmd* cmd), REG(a1, struct RexxMsg* msg))
+#endif
+
+RXHOOKF(rx_open);
+RXHOOKF(rx_quit);
+RXHOOKF(rx_tofront);
+RXHOOKF(rx_geturl);
+RXHOOKF(rx_gettitle);
+RXHOOKF(rx_version);
+RXHOOKF(rx_save);
+RXHOOKF(rx_pubscreen);
+RXHOOKF(rx_back);
+RXHOOKF(rx_forward);
+RXHOOKF(rx_home);
+RXHOOKF(rx_reload);
+RXHOOKF(rx_windows);
+RXHOOKF(rx_active);
+RXHOOKF(rx_close);
+RXHOOKF(rx_hotlist);
+RXHOOKF(rx_slabstats);
STATIC struct ARexxCmd Commands[] =
{
- {"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N,ACTIVE/S", 0, NULL, 0, 0, NULL },
{"QUIT",RX_QUIT,rx_quit,NULL, 0, NULL, 0, 0, NULL },
{"TOFRONT",RX_TOFRONT,rx_tofront,NULL, 0, NULL, 0, 0, NULL },
{"GETURL",RX_GETURL,rx_geturl, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
@@ -106,10 +118,11 @@ STATIC struct ARexxCmd Commands[] =
{"ACTIVE", RX_ACTIVE, rx_active, "T=TAB/S", 0, NULL, 0, 0, NULL },
{"CLOSE", RX_CLOSE, rx_close, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
{"HOTLIST", RX_HOTLIST, rx_hotlist, "A=ACTION/A", 0, NULL, 0, 0, NULL },
+ {"SLABSTATS", RX_SLABSTATS, rx_slabstats, "FILE", 0, NULL, 0, 0, NULL },
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
};
-BOOL ami_arexx_init(void)
+bool ami_arexx_init(ULONG *rxsig)
{
if((arexx_obj = ARexxObj,
AREXX_HostName,"NETSURF",
@@ -119,7 +132,7 @@ BOOL ami_arexx_init(void)
AREXX_DefExtension,"nsrx",
End))
{
- GetAttr(AREXX_SigMask, arexx_obj, &rxsig);
+ GetAttr(AREXX_SigMask, arexx_obj, rxsig);
return true;
}
else
@@ -133,6 +146,7 @@ BOOL ami_arexx_init(void)
AREXX_ReplyHook,NULL,
AREXX_DefExtension,"nsrx",
End;
+
return false;
}
}
@@ -142,6 +156,17 @@ void ami_arexx_handle(void)
RA_HandleRexx(arexx_obj);
}
+static void ami_arexx_command(const char *cmd, const char *port)
+{
+ if(arexx_obj == NULL) return;
+ IDoMethod(arexx_obj, AM_EXECUTE, cmd, port, NULL, NULL, NULL, NULL);
+}
+
+void ami_arexx_self(const char *cmd)
+{
+ ami_arexx_command(cmd, "NETSURF");
+}
+
void ami_arexx_execute(char *script)
{
char full_script_path[1025];
@@ -150,7 +175,7 @@ void ami_arexx_execute(char *script)
if((lock = Lock(script, ACCESS_READ))) {
DevNameFromLock(lock, full_script_path, 1024, DN_FULLPATH);
LOG("Executing script: %s", full_script_path);
- IDoMethod(arexx_obj, AM_EXECUTE, full_script_path, NULL, NULL, NULL, NULL, NULL);
+ ami_arexx_command(full_script_path, NULL);
UnLock(lock);
}
}
@@ -233,7 +258,7 @@ static struct gui_window *ami_find_tab(int window, int tab)
return NULL;
}
-STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_open)
{
struct dlnode *dln;
struct gui_window *gw = cur_gw;
@@ -253,7 +278,7 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
{
if(!gw) return;
- dln = ami_misc_allocvec_clear(sizeof(struct dlnode), 0);
+ dln = calloc(1, sizeof(struct dlnode));
dln->filename = strdup((char *)cmd->ac_ArgList[3]);
dln->node.ln_Name = strdup((char *)cmd->ac_ArgList[0]);
dln->node.ln_Type = NT_USER;
@@ -268,12 +293,24 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
}
else if(cmd->ac_ArgList[2])
{
- browser_window_create(BW_CREATE_HISTORY |
+ if(gw == NULL) {
+ browser_window_create(BW_CREATE_HISTORY,
+ url,
+ NULL,
+ NULL,
+ NULL);
+ } else {
+ browser_window_create(BW_CREATE_HISTORY |
BW_CREATE_TAB,
url,
NULL,
gw->bw,
NULL);
+
+ if(cmd->ac_ArgList[6]) {
+ ami_gui_switch_to_new_tab(gw->shared);
+ }
+ }
}
else if(cmd->ac_ArgList[1])
{
@@ -307,7 +344,7 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
nsurl_unref(url);
}
-STATIC VOID rx_save(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_save)
{
BPTR fh = 0;
ULONG source_size;
@@ -325,7 +362,7 @@ STATIC VOID rx_save(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
if((fh = FOpen((char *)cmd->ac_ArgList[0], MODE_NEWFILE, 0)))
{
- hlcache_handle *h = browser_window_get_content(gw->bw);
+ struct hlcache_handle *h = browser_window_get_content(gw->bw);
if((source_data = content_get_source_data(h, &source_size)))
FWrite(fh, source_data, 1, source_size);
@@ -336,19 +373,19 @@ STATIC VOID rx_save(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
ami_reset_pointer(gw->shared);
}
-STATIC VOID rx_quit(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_quit)
{
cmd->ac_RC = 0;
ami_quit_netsurf();
}
-STATIC VOID rx_tofront(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_tofront)
{
cmd->ac_RC = 0;
ScreenToFront(scrn);
}
-STATIC VOID rx_geturl(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_geturl)
{
struct gui_window *gw = cur_gw;
@@ -369,7 +406,7 @@ STATIC VOID rx_geturl(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((u
cmd->ac_Result = result;
}
-STATIC VOID rx_gettitle(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_gettitle)
{
struct gui_window *gw = cur_gw;
@@ -393,7 +430,7 @@ STATIC VOID rx_gettitle(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__(
cmd->ac_Result = result;
}
-STATIC VOID rx_version(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_version)
{
cmd->ac_RC = 0;
@@ -459,7 +496,7 @@ STATIC VOID rx_version(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((
cmd->ac_Result = result;
}
-STATIC VOID rx_pubscreen(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_pubscreen)
{
cmd->ac_RC = 0;
@@ -475,7 +512,7 @@ STATIC VOID rx_pubscreen(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__
cmd->ac_Result = result;
}
-STATIC VOID rx_back(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_back)
{
struct gui_window *gw = cur_gw;
@@ -487,7 +524,7 @@ STATIC VOID rx_back(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
if(gw) ami_gui_history(gw->shared, true);
}
-STATIC VOID rx_forward(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_forward)
{
struct gui_window *gw = cur_gw;
@@ -500,7 +537,7 @@ STATIC VOID rx_forward(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((
}
-STATIC VOID rx_home(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_home)
{
struct gui_window *gw = cur_gw;
nsurl *url;
@@ -526,7 +563,7 @@ STATIC VOID rx_home(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
}
}
-STATIC VOID rx_reload(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_reload)
{
struct gui_window *gw = cur_gw;
@@ -548,7 +585,7 @@ STATIC VOID rx_reload(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((u
}
}
-STATIC VOID rx_windows(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_windows)
{
int windows = 0, tabs = 0;
int window = 0;
@@ -563,7 +600,7 @@ STATIC VOID rx_windows(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((
cmd->ac_Result = result;
}
-STATIC VOID rx_active(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_active)
{
int window = 0, tab = 0;
struct gui_window *gw = cur_gw;
@@ -606,7 +643,7 @@ STATIC VOID rx_active(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((u
cmd->ac_Result = result;
}
-STATIC VOID rx_close(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_close)
{
struct gui_window *gw = cur_gw;
@@ -623,7 +660,7 @@ STATIC VOID rx_close(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((un
if(gw) browser_window_destroy(gw->bw);
}
-STATIC VOID rx_hotlist(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+RXHOOKF(rx_hotlist)
{
cmd->ac_RC = 0;
@@ -634,3 +671,17 @@ STATIC VOID rx_hotlist(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((
}
}
+RXHOOKF(rx_slabstats)
+{
+#ifndef __amigaos4__
+ BPTR fh = 0;
+
+ if(cmd->ac_ArgList[0] != NULL) {
+ fh = Open((char *)cmd->ac_ArgList[0], MODE_NEWFILE);
+ }
+ ami_memory_slab_dump(fh);
+
+ if(fh != 0) Close(fh);
+#endif
+}
+
diff --git a/frontends/amiga/arexx.h b/frontends/amiga/arexx.h
index 358d174..b97967a 100755
--- a/frontends/amiga/arexx.h
+++ b/frontends/amiga/arexx.h
@@ -22,11 +22,9 @@
#include <proto/arexx.h>
#include <classes/arexx.h>
-BOOL ami_arexx_init(void);
+bool ami_arexx_init(ULONG *rxsig);
void ami_arexx_handle(void);
void ami_arexx_execute(char *);
+void ami_arexx_self(const char *cmd);
void ami_arexx_cleanup(void);
-
-Object *arexx_obj;
-ULONG rxsig;
#endif
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 5fb8bde..fe84a94 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -19,6 +19,7 @@
#include "amiga/os3support.h"
#include <stdlib.h>
+#include <string.h>
#include <proto/exec.h>
#ifdef __amigaos4__
#include <graphics/blitattr.h>
@@ -48,18 +49,22 @@
#include "utils/nsoption.h"
#include "utils/nsurl.h"
#include "utils/messages.h"
-#include "content/hlcache.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
-#include "image/bitmap.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
#include "amiga/gui.h"
#include "amiga/bitmap.h"
-#include "amiga/download.h"
+#include "amiga/plotters.h"
+#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/rtg.h"
#include "amiga/schedule.h"
+// disable use of "triangle mode" for scaling
+#ifdef AMI_NS_TRIANGLE_SCALING
+#undef AMI_NS_TRIANGLE_SCALING
+#endif
+
struct bitmap {
int width;
int height;
@@ -85,16 +90,31 @@ enum {
AMI_NSBM_PALETTEMAPPED
};
-APTR pool_bitmap = NULL;
+struct vertex {
+ float x, y;
+ float s, t, w;
+};
+
+#define VTX(I,X,Y,S,T) vtx[I].x = X; vtx[I].y = Y; vtx[I].s = S; vtx[I].t = T; vtx[I].w = 1.0f;
+#define VTX_RECT(SX,SY,SW,SH,DX,DY,DW,DH) \
+ VTX(0, DX, DY, SX, SY); \
+ VTX(1, DX + DW, DY, SX + SW, SY); \
+ VTX(2, DX, DY + DH, SX, SY + SH); \
+ VTX(3, DX + DW, DY, SX + SW, SY); \
+ VTX(4, DX, DY + DH, SX, SY + SH); \
+ VTX(5, DX + DW, DY + DH, SX + SW, SY + SH);
+
+static APTR pool_bitmap = NULL;
+static bool guigfx_warned = false;
/* exported function documented in amiga/bitmap.h */
void *amiga_bitmap_create(int width, int height, unsigned int state)
{
struct bitmap *bitmap;
- if(pool_bitmap == NULL) pool_bitmap = ami_misc_itempool_create(sizeof(struct bitmap));
+ if(pool_bitmap == NULL) pool_bitmap = ami_memory_itempool_create(sizeof(struct bitmap));
- bitmap = ami_misc_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
+ bitmap = ami_memory_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
if(bitmap == NULL) return NULL;
bitmap->size = width * height * 4;
@@ -113,7 +133,7 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
} else
#endif
{
- bitmap->pixdata = ami_misc_allocvec_clear(bitmap->size, 0xff);
+ bitmap->pixdata = ami_memory_clear_alloc(bitmap->size, 0xff);
}
bitmap->width = width;
@@ -206,11 +226,10 @@ void amiga_bitmap_destroy(void *bitmap)
} else
#endif
{
- FreeVec(bm->pixdata);
+ if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
+ ami_memory_clear_free(bm->pixdata);
}
- if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
-
if(bm->url) nsurl_unref(bm->url);
if(bm->title) free(bm->title);
@@ -221,7 +240,7 @@ void amiga_bitmap_destroy(void *bitmap)
bm->url = NULL;
bm->title = NULL;
- ami_misc_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
+ ami_memory_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
bm = NULL;
}
}
@@ -257,6 +276,10 @@ void amiga_bitmap_modified(void *bitmap)
{
struct bitmap *bm = bitmap;
+#ifdef __amigaos4__
+ amiga_bitmap_unmap_buffer(bm);
+#endif
+
if(bm->nativebm) ami_rtg_freebitmap(bm->nativebm);
if(bm->drawhandle) ReleaseDrawHandle(bm->drawhandle);
if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
@@ -367,7 +390,7 @@ static void ami_bitmap_rgba_to_argb(struct bitmap *bm)
ULONG *data = (ULONG *)amiga_bitmap_get_buffer(bm);
for(int i = 0; i < (bm->width * bm->height); i++) {
- data[i] = (data[i] >> 8) | (data[i] << 24);
+ data[i] = (data[ i] >> 8) | (data[i] << 24);
}
}
@@ -456,9 +479,10 @@ struct bitmap *ami_bitmap_from_datatype(char *filename)
return bm;
}
-static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, int width, int height, struct BitMap *friendbm, int type)
+static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap,
+ int width, int height, struct BitMap *restrict friendbm, int type)
{
- struct BitMap *tbm = NULL;
+ struct BitMap *restrict tbm = NULL;
if(bitmap->nativebm)
{
@@ -475,16 +499,19 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, int w
if(tbm == NULL) {
if(type == AMI_NSBM_TRUECOLOUR) {
- if((tbm = ami_rtg_allocbitmap(bitmap->width, bitmap->height, 32, 0,
- friendbm, AMI_BITMAP_FORMAT))) {
- ami_rtg_writepixelarray(amiga_bitmap_get_buffer(bitmap),
+ tbm = ami_rtg_allocbitmap(bitmap->width, bitmap->height, 32, 0,
+ friendbm, AMI_BITMAP_FORMAT);
+ if(tbm == NULL) return NULL;
+
+ ami_rtg_writepixelarray(amiga_bitmap_get_buffer(bitmap),
tbm, bitmap->width, bitmap->height,
bitmap->width * 4, AMI_BITMAP_FORMAT);
- }
} else {
- if((tbm = ami_rtg_allocbitmap(bitmap->width, bitmap->height,
- 8, 0, friendbm, AMI_BITMAP_FORMAT))) {
+ tbm = ami_rtg_allocbitmap(width, height,
+ 8, 0, friendbm, AMI_BITMAP_FORMAT);
+ if(tbm == NULL) return NULL;
+ if(GuiGFXBase != NULL) {
struct RastPort rp;
InitRastPort(&rp);
rp.BitMap = tbm;
@@ -504,26 +531,40 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, int w
APTR ddh = CreateDirectDrawHandle(bitmap->drawhandle,
bitmap->width, bitmap->height,
- bitmap->width, bitmap->height, NULL);
+ width, height, NULL);
DirectDrawTrueColor(ddh, (ULONG *)amiga_bitmap_get_buffer(bitmap), 0, 0, TAG_DONE);
DeleteDirectDrawHandle(ddh);
ami_bitmap_argb_to_rgba(bitmap);
+ } else {
+ if(guigfx_warned == false) {
+ amiga_warn_user("BMConvErr", NULL);
+ guigfx_warned = true;
+ }
}
}
- if(nsoption_int(cache_bitmaps) == 2)
- {
+ if(((type == AMI_NSBM_TRUECOLOUR) && (nsoption_int(cache_bitmaps) == 2)) ||
+ ((type == AMI_NSBM_PALETTEMAPPED) && (((bitmap->width == width) &&
+ (bitmap->height == height) && (nsoption_int(cache_bitmaps) == 2)) ||
+ (nsoption_int(cache_bitmaps) >= 1)))) {
bitmap->nativebm = tbm;
- bitmap->nativebmwidth = bitmap->width;
- bitmap->nativebmheight = bitmap->height;
+ if(type == AMI_NSBM_TRUECOLOUR) {
+ bitmap->nativebmwidth = bitmap->width;
+ bitmap->nativebmheight = bitmap->height;
+ } else {
+ bitmap->nativebmwidth = width;
+ bitmap->nativebmheight = height;
+ }
bitmap->native = type;
}
+
+ if(type == AMI_NSBM_PALETTEMAPPED)
+ return tbm;
}
- if((bitmap->width != width) || (bitmap->height != height))
- {
- struct BitMap *scaledbm;
+ if((bitmap->width != width) || (bitmap->height != height)) {
+ struct BitMap *restrict scaledbm;
struct BitScaleArgs bsa;
int depth = 32;
if(type == AMI_NSBM_PALETTEMAPPED) depth = 8;
@@ -535,21 +576,42 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, int w
(type == AMI_NSBM_TRUECOLOUR)), 1)) {
/* AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
* Additionally, when we use friend BitMaps in non 32-bit modes it freezes the OS */
+
uint32 flags = 0;
- if(nsoption_bool(scale_quality)) flags |= COMPFLAG_SrcFilter;
+ uint32 err = COMPERR_Success;
+#ifdef AMI_NS_TRIANGLE_SCALING
+ struct vertex vtx[6];
+ VTX_RECT(0, 0, bitmap->width, bitmap->height, 0, 0, width, height);
+
+ flags = COMPFLAG_HardwareOnly;
+ if(nsoption_bool(scale_quality) == true) flags |= COMPFLAG_SrcFilter;
- CompositeTags(COMPOSITE_Src, tbm, scaledbm,
+ err = CompositeTags(COMPOSITE_Src, tbm, scaledbm,
+ COMPTAG_VertexArray, vtx,
+ COMPTAG_VertexFormat, COMPVF_STW0_Present,
+ COMPTAG_NumTriangles, 2,
+ COMPTAG_Flags, flags,
+ COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
+ TAG_DONE);
+
+ if (err != COMPERR_Success) {
+ LOG("Composite error %ld - falling back", err);
+ /* If it failed, do it again the way which works in software */
+#else
+ {
+#endif
+ flags = 0;
+ if(nsoption_bool(scale_quality) == true) flags |= COMPFLAG_SrcFilter;
+
+ err = CompositeTags(COMPOSITE_Src, tbm, scaledbm,
COMPTAG_ScaleX, COMP_FLOAT_TO_FIX((float)width/bitmap->width),
COMPTAG_ScaleY, COMP_FLOAT_TO_FIX((float)height/bitmap->height),
COMPTAG_Flags, flags,
- COMPTAG_DestX, 0,
- COMPTAG_DestY, 0,
- COMPTAG_DestWidth, width,
- COMPTAG_DestHeight, height,
- COMPTAG_OffsetX, 0,
- COMPTAG_OffsetY, 0,
COMPTAG_FriendBitMap, scrn->RastPort.BitMap,
TAG_DONE);
+ /* If it still fails... it's non-fatal */
+ LOG("Fallback returned error %ld", err);
+ }
} else /* Do it the old-fashioned way. This is pretty slow, even on OS4.1 */
#endif
{
@@ -589,7 +651,8 @@ static inline struct BitMap *ami_bitmap_get_generic(struct bitmap *bitmap, int w
}
-static inline struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int width,int height,struct BitMap *friendbm)
+static inline struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,
+ int width, int height, struct BitMap *friendbm)
{
if((bitmap->native != AMI_NSBM_NONE) && (bitmap->native != AMI_NSBM_TRUECOLOUR)) {
amiga_bitmap_modified(bitmap);
@@ -653,11 +716,11 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
void ami_bitmap_fini(void)
{
- if(pool_bitmap) ami_misc_itempool_delete(pool_bitmap);
+ if(pool_bitmap) ami_memory_itempool_delete(pool_bitmap);
pool_bitmap = NULL;
}
-static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
+static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
{
#ifdef __amigaos4__
LOG("Entering bitmap_render");
@@ -730,14 +793,15 @@ void ami_bitmap_set_title(struct bitmap *bm, const char *title)
bm->title = strdup(title);
}
-ULONG *ami_bitmap_get_icondata(struct bitmap *bm)
+void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
{
- return bm->icondata;
+ bm->icondata = icondata;
}
-void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
+void ami_bitmap_free_icondata(struct bitmap *bm)
{
- bm->icondata = icondata;
+ if(bm->icondata) free(bm->icondata);
+ bm->icondata = NULL;
}
bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm)
diff --git a/frontends/amiga/bitmap.h b/frontends/amiga/bitmap.h
index d7dd70b..a32d740 100755
--- a/frontends/amiga/bitmap.h
+++ b/frontends/amiga/bitmap.h
@@ -28,7 +28,7 @@
#define AMI_BITMAP_FORMAT RGBFB_R8G8B8A8
#define AMI_BITMAP_SCALE_ICON 0xFF
-struct gui_bitmap_table *amiga_bitmap_table;
+extern struct gui_bitmap_table *amiga_bitmap_table;
struct bitmap;
struct nsurl;
@@ -43,8 +43,8 @@ struct bitmap *ami_bitmap_from_datatype(char *filename);
/**
* Set bitmap URL
*
- * \param bm a bitmap, as returned by bitmap_create()
- * \param title a pointer to a title string
+ * \param bm a bitmap, as returned by bitmap_create()
+ * \param url the url for the bitmap
*
* A reference will be kept by the bitmap object.
* The URL can only ever be set once for a bitmap.
@@ -63,24 +63,24 @@ void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url);
void ami_bitmap_set_title(struct bitmap *bm, const char *title);
/**
- * Get an icondata pointer
+ * Set an icondata pointer
*
* \param bm a bitmap, as returned by bitmap_create()
- * \return pointer to the icondata area
+ * \param icondata a pointer to memory
*
* This function probably shouldn't be here!
*/
-ULONG *ami_bitmap_get_icondata(struct bitmap *bm);
+void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata);
/**
- * Set an icondata pointer
+ * Free an icondata pointer
*
* \param bm a bitmap, as returned by bitmap_create()
* \param icondata a pointer to memory
*
* This function probably shouldn't be here!
*/
-void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata);
+void ami_bitmap_free_icondata(struct bitmap *bm);
/**
* Test if a BitMap is owned by a bitmap.
diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c
index 12ceb0f..9489110 100644
--- a/frontends/amiga/clipboard.c
+++ b/frontends/amiga/clipboard.c
@@ -30,12 +30,12 @@
#include "utils/nsoption.h"
#include "utils/utf8.h"
#include "utils/nsurl.h"
-#include "content/hlcache.h"
-#include "desktop/browser.h"
-#include "desktop/plotters.h"
-#include "desktop/textinput.h"
-#include "desktop/gui_window.h"
-#include "desktop/gui_clipboard.h"
+#include "netsurf/content.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/plotters.h"
+#include "netsurf/keypress.h"
+#include "netsurf/window.h"
+#include "netsurf/clipboard.h"
#include "amiga/bitmap.h"
#include "amiga/clipboard.h"
@@ -45,12 +45,11 @@
#include "amiga/iff_cset.h"
#include "amiga/iff_dr2d.h"
#include "amiga/menu.h"
-#include "amiga/misc.h"
#include "amiga/utf8.h"
#define ID_UTF8 MAKE_ID('U','T','F','8')
-struct IFFHandle *iffh = NULL;
+static struct IFFHandle *iffh = NULL;
static struct IFFHandle *ami_clipboard_init_internal(int unit)
{
@@ -114,10 +113,10 @@ static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codese
case 0:
if(ci_new) {
- ci_next->ci_Next = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
+ ci_next->ci_Next = calloc(1, sizeof(struct CollectionItem));
ci_next = ci_next->ci_Next;
} else {
- ci_new = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
+ ci_new = calloc(1, sizeof(struct CollectionItem));
ci_next = ci_new;
}
@@ -128,10 +127,10 @@ static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codese
default:
if(ci_new) {
- ci_next->ci_Next = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
+ ci_next->ci_Next = calloc(1, sizeof(struct CollectionItem));
ci_next = ci_next->ci_Next;
} else {
- ci_new = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
+ ci_new = calloc(1, sizeof(struct CollectionItem));
ci_next = ci_new;
}
@@ -166,7 +165,7 @@ static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codese
if(ci_new) {
free(ci_curr->ci_Data);
- FreeVec(ci_curr);
+ free(ci_curr);
}
} while ((ci_curr = ci_next));
diff --git a/frontends/amiga/cookies.c b/frontends/amiga/cookies.c
index 0ca1741..15f6dce 100755
--- a/frontends/amiga/cookies.c
+++ b/frontends/amiga/cookies.c
@@ -19,12 +19,14 @@
#include <proto/exec.h>
#include "desktop/cookie_manager.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
#include "amiga/cookies.h"
#include "amiga/tree.h"
+struct treeview_window *cookies_window;
+
void ami_cookies_initialise(void)
{
cookies_window = ami_tree_create(TREE_COOKIES, NULL);
diff --git a/frontends/amiga/cookies.h b/frontends/amiga/cookies.h
index d692275..157091d 100755
--- a/frontends/amiga/cookies.h
+++ b/frontends/amiga/cookies.h
@@ -18,11 +18,11 @@
#ifndef AMIGA_COOKIES_H
#define AMIGA_COOKIES_H
-#include "desktop/tree.h"
+#include "amiga/desktop-tree.h"
#include "amiga/tree.h"
void ami_cookies_initialise(void);
void ami_cookies_free(void);
-struct treeview_window *cookies_window;
+extern struct treeview_window *cookies_window;
#endif
diff --git a/frontends/amiga/ctxmenu.c b/frontends/amiga/ctxmenu.c
index cc612da..717096f 100644
--- a/frontends/amiga/ctxmenu.c
+++ b/frontends/amiga/ctxmenu.c
@@ -40,12 +40,12 @@
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
-#include "content/hlcache.h"
-#include "desktop/browser.h"
+#include "netsurf/content.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/keypress.h"
#include "desktop/browser_history.h"
-#include "desktop/mouse.h"
#include "desktop/searchweb.h"
-#include "desktop/textinput.h"
#include "amiga/bitmap.h"
#include "amiga/clipboard.h"
@@ -56,7 +56,7 @@
#include "amiga/plugin_hack.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
-
+#include "amiga/misc.h"
enum {
AMI_CTX_ID_NONE = 0,
diff --git a/desktop/tree.c b/frontends/amiga/desktop-tree.c
similarity index 96%
copy from desktop/tree.c
copy to frontends/amiga/desktop-tree.c
index c5bca61..3fb41ed 100644
--- a/desktop/tree.c
+++ b/frontends/amiga/desktop-tree.c
@@ -30,13 +30,20 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
+#include "utils/nsoption.h"
+#include "netsurf/misc.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/core_window.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "css/utils.h"
-#include "utils/nsoption.h"
+#include "desktop/gui_internal.h"
+#include "desktop/treeview.h"
+#include "desktop/hotlist.h"
+#include "desktop/cookie_manager.h"
+#include "desktop/global_history.h"
+#include "desktop/sslcert_viewer.h"
-#include "desktop/browser.h"
-#include "desktop/tree.h"
+#include "amiga/desktop-tree.h"
struct tree {
unsigned int flags; /* Tree flags */
@@ -45,17 +52,9 @@ struct tree {
void *client_data; /* User assigned data for the callbacks */
};
-#include "desktop/gui_misc.h"
-#include "desktop/gui_internal.h"
-#include "desktop/treeview.h"
-#include "desktop/hotlist.h"
-#include "desktop/cookie_manager.h"
-#include "desktop/global_history.h"
-#include "desktop/sslcert_viewer.h"
struct sslcert_session_data *ssl_current_session = NULL;
const char *tree_hotlist_path = NULL;
-int treeview_inits;
static void treeview_test_redraw_request(struct core_window *cw,
const struct rect *r)
@@ -128,17 +127,8 @@ static bool treeview_test_init(struct tree *tree)
{
nserror err;
- treeview_inits++;
-
- if (treeview_inits == 1)
- treeview_init(0);
-
switch (tree->flags) {
case TREE_COOKIES:
- assert(ssl_current_session == NULL &&
- "Call sslcert_viewer_init directly, "
- "this compat. layer can't cope with simultanious "
- "sslcert viewers");
err = cookie_manager_init(&cw_t, (struct core_window *)tree);
if (err != NSERROR_OK)
guit->misc->warning("Couldn't init new cookie manager.", 0);
@@ -149,12 +139,18 @@ static bool treeview_test_init(struct tree *tree)
guit->misc->warning("Couldn't init new global history.", 0);
break;
case TREE_HOTLIST:
- err = hotlist_init(&cw_t, (struct core_window *)tree,
- tree_hotlist_path);
+ err = hotlist_init(tree_hotlist_path);
if (err != NSERROR_OK)
guit->misc->warning("Couldn't init new hotlist.", 0);
+ err = hotlist_manager_init(&cw_t, (struct core_window *)tree);
+ if (err != NSERROR_OK)
+ guit->misc->warning("Couldn't init hotlist manager.", 0);
break;
case TREE_SSLCERT:
+ assert(ssl_current_session == NULL &&
+ "Call sslcert_viewer_init directly, "
+ "this compat. layer can't cope with simultanious "
+ "sslcert viewers");
err = sslcert_viewer_init(&cw_t, (struct core_window *)tree,
ssl_current_session);
if (err != NSERROR_OK)
@@ -195,10 +191,6 @@ static bool treeview_test_fini(struct tree *tree)
break;
}
- if (treeview_inits == 1)
- treeview_fini();
- treeview_inits--;
-
return true;
}
diff --git a/desktop/tree.h b/frontends/amiga/desktop-tree.h
similarity index 99%
copy from desktop/tree.h
copy to frontends/amiga/desktop-tree.h
index b4e0f66..f8864e1 100644
--- a/desktop/tree.h
+++ b/frontends/amiga/desktop-tree.h
@@ -27,7 +27,7 @@
#include <stdbool.h>
#include <stdint.h>
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
struct sslcert_session_data;
struct tree;
diff --git a/frontends/amiga/dist/Install b/frontends/amiga/dist/Install
index e8d9d0e..b33b36c 100755
--- a/frontends/amiga/dist/Install
+++ b/frontends/amiga/dist/Install
@@ -310,7 +310,7 @@
(help @textfile-help)
(dest "Rexx:NetSurf")
(append "/*\n"
-" * Copyright 2013 Chris Young <chris(a)unsatisfactorysoftware.co.uk>\n"
+" * Copyright 2013, 2016 Chris Young <chris(a)unsatisfactorysoftware.co.uk>\n"
" *\n"
" * This file is part of NetSurf, http://www.netsurf-browser.org/\n"
" *\n"
@@ -336,7 +336,7 @@
"parse arg url\n"
"\n"
"if show('P', 'NETSURF') then do\n"
-" address NETSURF 'OPEN' url 'NEWTAB'\n"
+" address NETSURF 'OPEN' url 'NEWTAB ACTIVE'\n"
" address NETSURF 'TOFRONT'\n"
"end\n"
"else do\n"
diff --git a/frontends/amiga/dist/NetSurf.guide b/frontends/amiga/dist/NetSurf.guide
index 58eb917..8fc6cc3 100755
--- a/frontends/amiga/dist/NetSurf.guide
+++ b/frontends/amiga/dist/NetSurf.guide
@@ -129,8 +129,8 @@ The user directories contain user-specific preferences and cache data. Always l
Current user. Defaults to the value of the USER env-var, or Default.
@endnode
-@node options "Options file"
-The options file is stored in @{"Users/Default/Choices" link Users/Default/Choices/Main} by default. Most of the settings can be changed from within NetSurf by selecting Edit preferences from the Settings menu.
+@node options "Choices file"
+The Choices file is stored in @{"Users/Default/Choices" link Users/Default/Choices/Main} by default. Most of the settings can be changed from within NetSurf by selecting Edit preferences from the Settings menu.
There are a couple of Amiga-specific options which can only be changed directly in the file. These are:
@@ -143,9 +143,9 @@ There are a couple of Amiga-specific options which can only be changed directly
@{b}reformat_delay@{ub} Sets a delay on performing content reformats (eg. if the window has been resized). Set to a higher value to make "resize with contents" more responsive. Defaults to 0 (immediate).
@{b}redraw_tile_size_x@{ub}/@{b}redraw_tile_size_y@{ub} Specify the size of the off-screen bitmap. Higher will speed up redraws at the expense of memory. 0 disables tiling (will use a bitmap at least the size of the screen NetSurf is running on)
@{b}web_search_width@{ub} Defaults to 0. Larger values will increase the size of the web search gadget next to the URL bar.
+@{b}mask_alpha@{ub} Threshold to use when determining which alpha values to convert to full transparency (0 - 255, where 255 will convert even opaque pixels to transparent). Defaults to 0. This is only used in palette-mapped modes where alpha blending is not currently supported.
+@{b}tab_new_session{ub} If NetSurf is already running, this will cause any passed URLs to open in a new tab rather than a new window.
@{b}use_extmem@{ub} Defaults to 0 (disabled). Setting to 1 will make NetSurf use Extended Memory to store uncompressed images. OS4 only; does not work on Pegasus 2.
-@{b}mask_alpha@{ub} Threshold to use when determining which alpha values to convert to full transparency (0 - 255, where 255 will convert even opaque pixels to transparent). Defaults to 50 (0x32). This is only used in palette-mapped modes where alpha blending is not currently supported.
-
@{b}url_file@{ub} Path to URL database file
@{b}hotlist_file@{ub} Path to Hotlist file
@{b}arexx_dir@{ub} Path to ARexx scripts dir
@@ -198,9 +198,10 @@ NetSurf's ARexx port is called NETSURF.
Commands are:
-@{b}OPEN URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N@{ub}
+@{b}OPEN URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N,ACTIVE/S@{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.
+ACTIVE forces a NEWTAB to be switched to even if this wouldn't normally be the case (available in 3.6)
@{b}SAVE FILENAME/A,W=WINDOW/K/N,T=TAB/K/N@{ub} (2.6027)
Saves current page source to FILENAME
diff --git a/frontends/amiga/download.c b/frontends/amiga/download.c
index a0bc5c4..47485e0 100644
--- a/frontends/amiga/download.c
+++ b/frontends/amiga/download.c
@@ -48,13 +48,13 @@
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "utils/string.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
+#include "netsurf/download.h"
+#include "content/handlers/image/ico.h"
#include "desktop/download.h"
#include "desktop/save_complete.h"
-#include "desktop/browser.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
-#include "desktop/gui_download.h"
-#include "image/ico.h"
#include "amiga/gui.h"
#include "amiga/download.h"
@@ -62,7 +62,6 @@
#include "amiga/bitmap.h"
#include "amiga/icon.h"
#include "amiga/file.h"
-#include "amiga/drag.h"
#include "amiga/iff_dr2d.h"
#include "amiga/libs.h"
#include "amiga/misc.h"
@@ -70,7 +69,7 @@
#include "amiga/utf8.h"
struct gui_download_window {
- struct nsObject *node;
+ struct ami_generic_window w;
struct Window *win;
Object *objects[GID_LAST];
BPTR fh;
@@ -90,7 +89,15 @@ enum {
AMINS_DLOAD_ABORT,
};
-int downloads_in_progress = 0;
+static void ami_download_window_abort(void *w);
+static BOOL ami_download_window_event(void *w);
+
+static const struct ami_win_event_table ami_download_table = {
+ ami_download_window_event,
+ ami_download_window_abort,
+};
+
+static int downloads_in_progress = 0;
static struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *gui)
@@ -101,7 +108,7 @@ static struct gui_download_window *gui_download_window_create(download_context *
char *dl_filename = ami_utf8_easy(download_context_get_filename(ctx));
APTR va[3];
- dw = ami_misc_allocvec_clear(sizeof(struct gui_download_window), 0);
+ dw = calloc(1, sizeof(struct gui_download_window));
if(gui && (!IsListEmpty(&gui->dllist)) && (dw->dln = (struct dlnode *)FindName(&gui->dllist,url)))
{
@@ -123,13 +130,13 @@ static struct gui_download_window *gui_download_window_create(download_context *
AddPart((STRPTR)&dw->fname,savereq->fr_File,1024);
if(!ami_download_check_overwrite(dw->fname, gui->shared->win, total_size))
{
- FreeVec(dw);
+ free(dw);
return NULL;
}
}
else
{
- FreeVec(dw);
+ free(dw);
return NULL;
}
}
@@ -146,7 +153,7 @@ static struct gui_download_window *gui_download_window_create(download_context *
if(!(dw->fh = FOpen((STRPTR)&dw->fname,MODE_NEWFILE,0)))
{
- FreeVec(dw);
+ free(dw);
return NULL;
}
@@ -191,8 +198,7 @@ static struct gui_download_window *gui_download_window_create(download_context *
dw->win = (struct Window *)RA_OpenWindow(dw->objects[OID_MAIN]);
dw->ctx = ctx;
- dw->node = AddObject(window_list,AMINS_DLWINDOW);
- dw->node->objstruct = dw;
+ ami_gui_win_list_add(dw, AMINS_DLWINDOW, &ami_download_table);
downloads_in_progress++;
@@ -261,7 +267,7 @@ static void gui_download_window_done(struct gui_download_window *dw)
free(dln->filename);
Remove((struct Node *)dln);
- FreeVec(dln);
+ free(dln);
}
FClose(dw->fh);
@@ -270,7 +276,7 @@ static void gui_download_window_done(struct gui_download_window *dw)
downloads_in_progress--;
DisposeObject(dw->objects[OID_MAIN]);
- DelObject(dw->node);
+ ami_gui_win_list_remove(dw);
if(queuedl) {
nsurl *url;
if (nsurl_create(dln2->node.ln_Name, &url) != NSERROR_OK) {
@@ -297,16 +303,18 @@ static void gui_download_window_error(struct gui_download_window *dw,
gui_download_window_done(dw);
}
-void ami_download_window_abort(struct gui_download_window *dw)
+static void ami_download_window_abort(void *w)
{
+ struct gui_download_window *dw = (struct gui_download_window *)dw;
download_context_abort(dw->ctx);
dw->result = AMINS_DLOAD_ABORT;
gui_download_window_done(dw);
}
-BOOL ami_download_window_event(struct gui_download_window *dw)
+static BOOL ami_download_window_event(void *w)
{
/* return TRUE if window destroyed */
+ struct gui_download_window *dw = (struct gui_download_window *)w;
ULONG result;
uint16 code;
@@ -344,7 +352,7 @@ void ami_free_download_list(struct List *dllist)
free(node->node.ln_Name);
free(node->filename);
Remove((struct Node *)node);
- FreeVec((struct Node *)node);
+ free((struct Node *)node);
}while((node=nnode));
}
diff --git a/frontends/amiga/download.h b/frontends/amiga/download.h
index 51981ed..b60b4f0 100755
--- a/frontends/amiga/download.h
+++ b/frontends/amiga/download.h
@@ -34,8 +34,6 @@ struct dlnode
char *filename;
};
-void ami_download_window_abort(struct gui_download_window *dw);
-BOOL ami_download_window_event(struct gui_download_window *dw);
void ami_free_download_list(struct List *dllist);
BOOL ami_download_check_overwrite(const char *file, struct Window *win, ULONG size);
diff --git a/frontends/amiga/drag.c b/frontends/amiga/drag.c
index 67d1722..92617dd 100644
--- a/frontends/amiga/drag.c
+++ b/frontends/amiga/drag.c
@@ -34,8 +34,8 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
-#include "content/hlcache.h"
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
+#include "netsurf/content.h"
#include "amiga/bitmap.h"
#include "amiga/clipboard.h"
@@ -46,11 +46,14 @@
#include "amiga/gui.h"
#include "amiga/theme.h"
-
-struct Window *drag_icon = NULL;
-ULONG drag_icon_width;
-ULONG drag_icon_height;
-BOOL drag_in_progress = FALSE;
+static void *drag_save_data;
+static int drag_save;
+static struct gui_window *drag_save_gui;
+static struct Window *drag_icon = NULL;
+static ULONG drag_icon_width;
+static ULONG drag_icon_height;
+static BOOL drag_in_progress = FALSE;
+static bool ami_autoscroll = false;
void gui_drag_save_object(struct gui_window *g, struct hlcache_handle *c,
gui_save_type type)
@@ -97,7 +100,7 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection)
{
ami_drag_icon_show(g->shared->win, "ascii");
- ami_autoscroll = TRUE;
+ ami_autoscroll = true;
drag_save_data = g;
drag_save = GUI_SAVE_TEXT_SELECTION;
}
@@ -108,7 +111,7 @@ void ami_drag_save(struct Window *win)
char path[1025], dpath[1025];
ami_drag_icon_close(NULL);
- ami_autoscroll = FALSE;
+ ami_autoscroll = true;
if(nsoption_charp(pubscreen_name) && (strcmp(nsoption_charp(pubscreen_name),"Workbench") == 0))
{
@@ -175,7 +178,7 @@ void ami_drag_save(struct Window *win)
case GUI_SAVE_OBJECT_NATIVE:
{
- hlcache_handle *c = drag_save_data;
+ struct hlcache_handle *c = drag_save_data;
AddPart(path, content_get_title(c), 1024);
ami_file_save(AMINS_SAVE_IFF, path, win, c, NULL, NULL);
@@ -246,13 +249,15 @@ void ami_drag_icon_show(struct Window *win, const char *type)
TAG_DONE);
}
-void ami_drag_icon_move(void)
+bool ami_drag_icon_move(void)
{
- if(drag_icon == NULL) return;
+ if(drag_icon == NULL) return FALSE;
ChangeWindowBox(drag_icon, scrn->MouseX - (drag_icon_width / 2),
scrn->MouseY - (drag_icon_height / 2),
drag_icon_width, drag_icon_height);
+
+ return ami_autoscroll;
}
/**
@@ -274,6 +279,12 @@ BOOL ami_drag_in_progress(void)
return drag_in_progress;
}
+bool ami_drag_has_data(void)
+{
+ if(drag_save_data != NULL) return true;
+ else return false;
+}
+
static void *ami_find_gwin_by_id(struct Window *win, uint32 type)
{
struct nsObject *node, *nnode;
@@ -312,6 +323,7 @@ void *ami_window_at_pointer(int type)
}
#else
+#include "utils/errors.h"
#include "amiga/drag.h"
void gui_drag_save_object(struct gui_window *g, struct hlcache_handle *c,
@@ -335,8 +347,9 @@ void ami_drag_icon_close(struct Window *win)
{
}
-void ami_drag_icon_move(void)
+bool ami_drag_icon_move(void)
{
+ return false;
}
BOOL ami_drag_in_progress(void)
@@ -344,6 +357,11 @@ BOOL ami_drag_in_progress(void)
return FALSE;
}
+bool ami_drag_has_data(void)
+{
+ return false;
+}
+
void *ami_window_at_pointer(int type)
{
return NULL;
diff --git a/frontends/amiga/drag.h b/frontends/amiga/drag.h
index 59a1a84..c0b040f 100644
--- a/frontends/amiga/drag.h
+++ b/frontends/amiga/drag.h
@@ -18,28 +18,25 @@
#ifndef AMIGA_DRAG_H
#define AMIGA_DRAG_H
-#include <exec/types.h>
-#include "desktop/browser.h"
-#include "desktop/gui_window.h"
-#define AMI_DRAG_THRESHOLD 10
+#include <stdbool.h>
+#include <exec/types.h>
+#include "netsurf/window.h"
-struct hlcache_handle;
struct Window;
-int drag_save;
-void *drag_save_data;
-struct gui_window *drag_save_gui;
+#define AMI_DRAG_THRESHOLD 10
void gui_drag_save_selection(struct gui_window *g, const char *selection);
void gui_drag_save_object(struct gui_window *g, struct hlcache_handle *c, gui_save_type type);
-
void ami_drag_save(struct Window *win);
void ami_drag_icon_show(struct Window *win, const char *type);
void ami_drag_icon_close(struct Window *win);
-void ami_drag_icon_move(void);
+bool ami_drag_icon_move(void);
BOOL ami_drag_in_progress(void);
+bool ami_drag_has_data(void);
void *ami_window_at_pointer(int type);
+
#endif
diff --git a/frontends/amiga/dt_anim.c b/frontends/amiga/dt_anim.c
index a3bfb1d..a486334 100644
--- a/frontends/amiga/dt_anim.c
+++ b/frontends/amiga/dt_anim.c
@@ -37,14 +37,15 @@
#include "utils/log.h"
#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
+#include "content/llcache.h"
#include "amiga/bitmap.h"
#include "amiga/filetype.h"
#include "amiga/datatypes.h"
-#include "amiga/misc.h"
#include "amiga/plotters.h"
typedef struct amiga_dt_anim_content {
@@ -59,7 +60,7 @@ typedef struct amiga_dt_anim_content {
int h;
} amiga_dt_anim_content;
-APTR ami_colormap_to_clut(struct ColorMap *cmap);
+static APTR ami_colormap_to_clut(struct ColorMap *cmap);
static nserror amiga_dt_anim_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
@@ -214,7 +215,7 @@ bool amiga_dt_anim_convert(struct content *c)
#else
#warning FIXME: Need to use a different blitter function for OS3!
#endif
- FreeVec(clut);
+ free(clut);
adt_frame.MethodID = ADTM_UNLOADFRAME;
IDoMethodA(plugin->dto, (Msg)&adt_frame);
@@ -339,10 +340,10 @@ content_type amiga_dt_anim_content_type(void)
return CONTENT_IMAGE;
}
-APTR ami_colormap_to_clut(struct ColorMap *cmap)
+static APTR ami_colormap_to_clut(struct ColorMap *cmap)
{
int i;
- UBYTE *clut = ami_misc_allocvec_clear(256 * 4, 0); /* NB: Was not MEMF_PRIVATE */
+ UBYTE *clut = calloc(1, 256 * 4);
ULONG colr[256 * 4];
if(!clut) return NULL;
diff --git a/frontends/amiga/dt_picture.c b/frontends/amiga/dt_picture.c
index aa2418d..e7f1c97 100644
--- a/frontends/amiga/dt_picture.c
+++ b/frontends/amiga/dt_picture.c
@@ -33,10 +33,11 @@
#include "utils/log.h"
#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "content/llcache.h"
#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
-#include "image/image_cache.h"
+#include "content/handlers/image/image_cache.h"
#include "amiga/bitmap.h"
#include "amiga/filetype.h"
diff --git a/frontends/amiga/dt_sound.c b/frontends/amiga/dt_sound.c
index fe1b1fc..55fc60d 100644
--- a/frontends/amiga/dt_sound.c
+++ b/frontends/amiga/dt_sound.c
@@ -23,20 +23,24 @@
#ifdef WITH_AMIGA_DATATYPES
#include "amiga/os3support.h"
-#include "amiga/filetype.h"
-#include "amiga/datatypes.h"
-#include "content/content_protected.h"
-#include "desktop/plotters.h"
-#include "render/box.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-
#include <proto/datatypes.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <datatypes/soundclass.h>
#include <intuition/classusr.h>
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/content.h"
+#include "render/box.h"
+#include "content/llcache.h"
+#include "content/content_protected.h"
+
+#include "amiga/filetype.h"
+#include "amiga/datatypes.h"
+
+
typedef struct amiga_dt_sound_content {
struct content base;
diff --git a/frontends/amiga/file.c b/frontends/amiga/file.c
index 8957ecf..04f8e8a 100644
--- a/frontends/amiga/file.c
+++ b/frontends/amiga/file.c
@@ -26,14 +26,12 @@
#include "utils/nsoption.h"
#include "utils/file.h"
#include "utils/messages.h"
-#include "content/hlcache.h"
-#include "content/content.h"
-#include "content/fetch.h"
-#include "desktop/browser.h"
+#include "utils/nsurl.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/content.h"
#include "desktop/save_complete.h"
#include "desktop/save_pdf.h"
#include "desktop/save_text.h"
-#include "desktop/gui_window.h"
#include "amiga/gui.h"
#include "amiga/bitmap.h"
@@ -91,7 +89,7 @@ void ami_file_open(struct gui_window_2 *gwin)
ASLFR_FilterFunc, &aslhookfunc,
TAG_DONE))
{
- if((temp = AllocVecTagList(1024, NULL)))
+ if((temp = malloc(1024)))
{
strlcpy(temp, filereq->fr_Drawer, 1024);
AddPart(temp, filereq->fr_File, 1024);
@@ -109,7 +107,7 @@ void ami_file_open(struct gui_window_2 *gwin)
nsurl_unref(url);
}
- FreeVec(temp);
+ free(temp);
}
}
}
@@ -214,7 +212,7 @@ void ami_file_save(int type, char *fname, struct Window *win,
void ami_file_save_req(int type, struct gui_window_2 *gwin,
struct hlcache_handle *object)
{
- char *fname = AllocVecTagList(1024, NULL);
+ char *fname = malloc(1024);
char *initial_fname = NULL;
char *fname_with_ext = NULL;
bool strip_ext = true;
@@ -225,7 +223,7 @@ void ami_file_save_req(int type, struct gui_window_2 *gwin,
}
if(initial_fname != NULL) {
- fname_with_ext = AllocVecTagList(strlen(initial_fname) + 5, NULL); /* 5 = .ext\0 */
+ fname_with_ext = malloc(strlen(initial_fname) + 5); /* 5 = .ext\0 */
strcpy(fname_with_ext, initial_fname);
@@ -262,8 +260,8 @@ void ami_file_save_req(int type, struct gui_window_2 *gwin,
ami_file_save(type, fname, gwin->win, object, gwin->gw->favicon, gwin->gw->bw);
}
- if(fname) FreeVec(fname);
- if(fname_with_ext) FreeVec(fname_with_ext);
+ if(fname) free(fname);
+ if(fname_with_ext) free(fname_with_ext);
}
void ami_file_req_init(void)
diff --git a/frontends/amiga/filetype.c b/frontends/amiga/filetype.c
index 39058b4..a0449d8 100644
--- a/frontends/amiga/filetype.c
+++ b/frontends/amiga/filetype.c
@@ -20,24 +20,24 @@
#include <stdlib.h>
#include <string.h>
-#include "amiga/filetype.h"
-#include "amiga/misc.h"
-#include "amiga/object.h"
-#include "content/fetch.h"
-#include "content/content.h"
-#include "utils/log.h"
-#include "utils/utils.h"
#include <proto/icon.h>
#include <proto/dos.h>
#include <proto/datatypes.h>
#include <proto/exec.h>
#include <workbench/icon.h>
+#include "netsurf/content.h"
+#include "utils/log.h"
+#include "utils/utils.h"
+
+#include "amiga/filetype.h"
+#include "amiga/object.h"
+
/**
* filetype -- determine the MIME type of a local file
*/
-struct MinList *ami_mime_list = NULL;
+static struct MinList *ami_mime_list = NULL;
struct ami_mime_entry
{
@@ -216,7 +216,7 @@ nserror ami_mime_init(const char *mimefile)
{
if ((node = AddObject(ami_mime_list, AMINS_MIME))) {
ObjectCallback(node, ami_mime_entry_free);
- mimeentry = ami_misc_allocvec_clear(sizeof(struct ami_mime_entry), 0);
+ mimeentry = calloc(1, sizeof(struct ami_mime_entry));
node->objstruct = mimeentry;
if(rarray[AMI_MIME_MIMETYPE])
@@ -351,7 +351,7 @@ static APTR ami_mime_guess_add_datatype(struct DataType *dt, lwc_string **lwc_mi
{
struct nsObject *node;
char mimetype[100];
- char *dt_name_lwr;
+ char *dt_name_lwr = NULL;
struct ami_mime_entry *mimeentry;
lwc_error lerror;
struct DataTypeHeader *dth = dt->dtn_Header;
@@ -360,7 +360,7 @@ static APTR ami_mime_guess_add_datatype(struct DataType *dt, lwc_string **lwc_mi
node = AddObject(ami_mime_list, AMINS_MIME);
if(node == NULL) return NULL;
- mimeentry = ami_misc_allocvec_clear(sizeof(struct ami_mime_entry), 0);
+ mimeentry = calloc(1, sizeof(struct ami_mime_entry));
if(mimeentry == NULL) return NULL;
node->objstruct = mimeentry;
diff --git a/frontends/amiga/filetype.h b/frontends/amiga/filetype.h
index fc27b1d..52fdf9c 100644
--- a/frontends/amiga/filetype.h
+++ b/frontends/amiga/filetype.h
@@ -18,12 +18,14 @@
#ifndef AMIGA_FILETYPE_H
#define AMIGA_FILETYPE_H
+
#include <stdbool.h>
#include <libwapcaplet/libwapcaplet.h>
-#include "content/content_type.h"
-#include "utils/errors.h"
#include <datatypes/datatypes.h>
+#include "netsurf/content_type.h"
+#include "utils/errors.h"
+
struct hlcache_handle;
struct ami_mime_entry;
diff --git a/frontends/amiga/font.c b/frontends/amiga/font.c
index 1c9702a..22a0f4a 100644
--- a/frontends/amiga/font.c
+++ b/frontends/amiga/font.c
@@ -24,8 +24,8 @@
#include "utils/log.h"
#include "utils/nsoption.h"
-#include "desktop/browser.h"
-#include "desktop/gui_layout.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/layout.h"
#include "amiga/font.h"
#include "amiga/font_bullet.h"
@@ -115,6 +115,8 @@ void ami_font_fini(void)
{
if(nsoption_bool(bitmap_fonts) == false) {
ami_font_bullet_fini();
+ } else {
+ ami_font_diskfont_fini();
}
}
diff --git a/frontends/amiga/font.h b/frontends/amiga/font.h
index cd52605..4f58211 100755
--- a/frontends/amiga/font.h
+++ b/frontends/amiga/font.h
@@ -19,7 +19,7 @@
#ifndef AMIGA_FONT_H
#define AMIGA_FONT_H
-#include "desktop/plotters.h"
+#include "netsurf/plotters.h"
#include "utils/errors.h"
#include <graphics/rastport.h>
#include <graphics/text.h>
@@ -57,7 +57,7 @@ struct ami_font_functions {
const struct ami_font_functions *ami_nsfont;
-struct gui_layout_table *ami_layout_table;
+extern struct gui_layout_table *ami_layout_table;
#endif
diff --git a/frontends/amiga/font_bullet.c b/frontends/amiga/font_bullet.c
index 3032b97..fd41c29 100644
--- a/frontends/amiga/font_bullet.c
+++ b/frontends/amiga/font_bullet.c
@@ -16,6 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Amiga font handling implementation
+ */
+
#include "amiga/os3support.h"
#include <stdlib.h>
@@ -31,15 +36,18 @@
#include <diskfont/diskfonttag.h>
#include <diskfont/oterrors.h>
+#include "utils/log.h"
+#include "utils/nsoption.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
+
+#include "amiga/memory.h"
+#include "amiga/misc.h"
#include "amiga/font.h"
#include "amiga/font_bullet.h"
#include "amiga/font_cache.h"
#include "amiga/font_scan.h"
-#include "utils/log.h"
-#include "utils/nsoption.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
#define NSA_UNICODE_FONT PLOT_FONT_FAMILY_COUNT
@@ -124,14 +132,14 @@ const uint16 sc_table[] = {
#endif
0, 0};
-lwc_string *glypharray[0xffff + 1];
+static lwc_string *glypharray[0xffff + 1];
static struct List ami_diskfontlib_list;
static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
- uint16 *char1, uint16 *char2, uint32 x, uint32 y, uint32 emwidth, bool aa);
+ uint16 *restrict char1, uint16 *restrict char2, uint32 x, uint32 y, uint32 emwidth, bool aa);
static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
- const uint16 *char1, const uint16 *char2, uint32 emwidth);
+ const uint16 *restrict char1, const uint16 *restrict char2, uint32 emwidth);
static struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
const uint16 *codepoint);
static inline ULONG ami_font_unicode_width(const char *string, ULONG length,
@@ -355,7 +363,7 @@ static struct ami_font_cache_node *ami_font_open(const char *font, bool critical
{
LOG("Requested font not found: %s", font);
if(critical == true) amiga_warn_user("CompError", font);
- FreeVec(nodedata);
+ free(nodedata);
return NULL;
}
@@ -523,7 +531,8 @@ static struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle
}
static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
- uint16 *char1, uint16 *char2, uint32 x, uint32 y, uint32 emwidth, bool aa)
+ uint16 *restrict char1, uint16 *restrict char2, uint32 x, uint32 y,
+ uint32 emwidth, bool aa)
{
struct GlyphMap *glyph;
UBYTE *glyphbm;
@@ -592,7 +601,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
TAG_DONE);
#else
/* On OS3 the glyph needs to be in chip RAM */
- void *chip_glyph = AllocVec(glyph->glm_BMModulo * glyph->glm_BMRows, MEMF_CHIP);
+ void *chip_glyph = ami_memory_chip_alloc(glyph->glm_BMModulo * glyph->glm_BMRows);
if(chip_glyph != NULL) {
CopyMem(glyphbm, chip_glyph, glyph->glm_BMModulo * glyph->glm_BMRows);
@@ -603,7 +612,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
y - glyph->glm_Y0 + glyph->glm_BlackTop,
glyph->glm_BlackWidth, glyph->glm_BlackHeight);
- FreeVec(chip_glyph);
+ ami_memory_chip_free(chip_glyph);
}
#endif
}
@@ -630,12 +639,11 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
}
static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
- const uint16 *char1, const uint16 *char2, uint32 emwidth)
+ const uint16 *restrict char1, const uint16 *restrict char2, uint32 emwidth)
{
int32 char_advance = 0;
FIXED kern = 0;
struct MinList *gwlist = NULL;
- FIXED char1w = 0;
struct GlyphWidthEntry *gwnode;
bool skip_c2 = false;
uint32 long_char_1 = 0;
@@ -670,6 +678,7 @@ static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
OT_WidthList, &gwlist,
TAG_END) == 0)
{
+ FIXED char1w = 0;
gwnode = (struct GlyphWidthEntry *)GetHead((struct List *)gwlist);
if(gwnode) char1w = gwnode->gwe_Width;
@@ -719,11 +728,11 @@ static const uint16 *ami_font_translate_smallcaps(uint16 *utf16char)
static ULONG amiga_nsfont_text(struct RastPort *rp, const char *string, ULONG length,
const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa)
{
- uint16 *utf16 = NULL, *outf16 = NULL;
- uint16 *utf16charsc = 0, *utf16nextsc = 0;
- uint16 *utf16next = 0;
+ uint16 *restrict utf16 = NULL, *restrict outf16 = NULL;
+ uint16 *restrict utf16charsc = 0, *restrict utf16nextsc = 0;
+ uint16 *restrict utf16next = 0;
int utf16charlen;
- struct OutlineFont *ofont, *ufont = NULL;
+ struct OutlineFont *restrict ofont, *restrict ufont = NULL;
uint32 x=0;
int32 tempx = 0;
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
@@ -784,11 +793,11 @@ static ULONG amiga_nsfont_text(struct RastPort *rp, const char *string, ULONG le
static inline ULONG ami_font_unicode_width(const char *string, ULONG length,
const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa)
{
- uint16 *utf16 = NULL, *outf16 = NULL;
- uint16 *utf16charsc = 0, *utf16nextsc = 0;
- uint16 *utf16next = 0;
+ uint16 *restrict utf16 = NULL, *restrict outf16 = NULL;
+ uint16 *restrict utf16charsc = 0, *restrict utf16nextsc = 0;
+ uint16 *restrict utf16next = 0;
int utf16charlen;
- struct OutlineFont *ofont, *ufont = NULL;
+ struct OutlineFont *restrict ofont, *restrict ufont = NULL;
uint32 x=0;
int32 tempx = 0;
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
diff --git a/frontends/amiga/font_cache.c b/frontends/amiga/font_cache.c
index ea28573..3d83309 100644
--- a/frontends/amiga/font_cache.c
+++ b/frontends/amiga/font_cache.c
@@ -130,7 +130,7 @@ static void ami_font_cache_del_skiplist(struct SkipList *skiplist)
struct ami_font_cache_node *ami_font_cache_locate(const char *font)
{
- struct ami_font_cache_node *nodedata;
+ struct ami_font_cache_node *nodedata = NULL;
uint32 hash = 0;
#ifdef __amigaos4__
@@ -158,7 +158,7 @@ struct ami_font_cache_node *ami_font_cache_alloc_entry(const char *font)
uint32 hash = XXH32(font, strlen(font), 0);
nodedata = (struct ami_font_cache_node *)InsertSkipNode(ami_font_cache_list, (APTR)hash, sizeof(struct ami_font_cache_node));
#else
- nodedata = AllocVecTagList(sizeof(struct ami_font_cache_node), NULL);
+ nodedata = malloc(sizeof(struct ami_font_cache_node));
#endif
GetSysTime(&nodedata->lastused);
diff --git a/frontends/amiga/font_cache.h b/frontends/amiga/font_cache.h
index 7c95ba5..a52f2f1 100644
--- a/frontends/amiga/font_cache.h
+++ b/frontends/amiga/font_cache.h
@@ -27,9 +27,9 @@ struct ami_font_cache_node
struct SkipNode skip_node;
#endif
struct OutlineFont *font;
- char *bold;
- char *italic;
- char *bolditalic;
+ char *restrict bold;
+ char *restrict italic;
+ char *restrict bolditalic;
struct TimeVal lastused;
};
diff --git a/frontends/amiga/font_diskfont.c b/frontends/amiga/font_diskfont.c
index a64674b..8593f81 100644
--- a/frontends/amiga/font_diskfont.c
+++ b/frontends/amiga/font_diskfont.c
@@ -34,10 +34,14 @@
#include "amiga/font.h"
#include "amiga/font_diskfont.h"
#include "amiga/gui.h"
+#include "amiga/plotters.h"
#include "amiga/utf8.h"
#define MAX_FONT_NAME_SIZE 33
+static plot_font_style_t *prev_fstyle = NULL;
+static struct TextFont *prev_font = NULL;
+
static struct TextFont *ami_font_bm_open(struct RastPort *rp, const plot_font_style_t *fstyle)
{
struct TextFont *bmfont = NULL;
@@ -45,6 +49,15 @@ static struct TextFont *ami_font_bm_open(struct RastPort *rp, const plot_font_st
char *fontname;
char font[MAX_FONT_NAME_SIZE];
+ if((prev_fstyle != NULL) && (prev_font != NULL) &&
+ (fstyle->family == prev_fstyle->family) &&
+ (fstyle->size == prev_fstyle->size) &&
+ (fstyle->flags == prev_fstyle->flags) &&
+ (fstyle->weight == prev_fstyle->weight)) {
+ LOG("(using current font)");
+ return prev_font;
+ }
+
if(rp == NULL) return NULL;
tattr.ta_Flags = 0;
@@ -86,16 +99,19 @@ static struct TextFont *ami_font_bm_open(struct RastPort *rp, const plot_font_st
tattr.ta_Name = font;
tattr.ta_YSize = fstyle->size / FONT_SIZE_SCALE;
LOG("font: %s/%d", tattr.ta_Name, tattr.ta_YSize);
+
+ if(prev_font != NULL) CloseFont(prev_font);
+
if((bmfont = OpenDiskFont(&tattr))) {
SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE);
}
- return bmfont;
-}
+ if(prev_fstyle != NULL) {
+ memcpy(prev_fstyle, fstyle, sizeof(plot_font_style_t));
+ prev_font = bmfont;
+ }
-static void ami_font_bm_close(struct TextFont *bmfont)
-{
- CloseFont(bmfont);
+ return bmfont;
}
static size_t ami_font_bm_convert_local_to_utf8_offset(const char *utf8string, size_t length, UWORD offset)
@@ -124,15 +140,12 @@ static nserror amiga_bm_nsfont_width(const plot_font_style_t *fstyle,
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
*width = TextLength(glob->rp, localtext, (UWORD)strlen(localtext));
free(localtext);
- ami_font_bm_close(bmfont);
-
return NSERROR_OK;
}
@@ -163,7 +176,6 @@ static nserror amiga_bm_nsfont_position_in_string(const plot_font_style_t *fstyl
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
@@ -173,7 +185,6 @@ static nserror amiga_bm_nsfont_position_in_string(const plot_font_style_t *fstyl
*actual_x = extent.te_Extent.MaxX;
free(localtext);
- ami_font_bm_close(bmfont);
return NSERROR_OK;
}
@@ -217,7 +228,6 @@ static nserror amiga_bm_nsfont_split(const plot_font_style_t *fstyle,
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
@@ -251,7 +261,6 @@ static nserror amiga_bm_nsfont_split(const plot_font_style_t *fstyle,
}
free(localtext);
- ami_font_bm_close(bmfont);
return NSERROR_OK;
}
@@ -272,8 +281,6 @@ static ULONG amiga_bm_nsfont_text(struct RastPort *rp, const char *string, ULONG
free(localtext);
}
- ami_font_bm_close(bmfont);
-
return 0;
}
@@ -288,5 +295,14 @@ void ami_font_diskfont_init(void)
{
/* Set up table */
ami_nsfont = &ami_font_diskfont_table;
+
+ /* Alloc space to hold currently open font - doesn't matter if this fails */
+ prev_fstyle = calloc(1, sizeof(plot_font_style_t));
+}
+
+void ami_font_diskfont_fini(void)
+{
+ if(prev_font != NULL) CloseFont(prev_font);
+ if(prev_fstyle != NULL) free(prev_fstyle);
}
diff --git a/frontends/amiga/font_diskfont.h b/frontends/amiga/font_diskfont.h
index de19e94..1c891d2 100644
--- a/frontends/amiga/font_diskfont.h
+++ b/frontends/amiga/font_diskfont.h
@@ -19,5 +19,6 @@
#ifndef AMIGA_FONT_DISKFONT_H
#define AMIGA_FONT_DISKFONT_H
void ami_font_diskfont_init(void);
+void ami_font_diskfont_fini(void);
#endif
diff --git a/frontends/amiga/font_scan.c b/frontends/amiga/font_scan.c
index b65798d..932179e 100644
--- a/frontends/amiga/font_scan.c
+++ b/frontends/amiga/font_scan.c
@@ -48,8 +48,8 @@
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
#include "amiga/font_scan.h"
#include "amiga/gui.h"
@@ -99,7 +99,7 @@ const char *ami_font_scan_lookup(const uint16 *code, lwc_string **glypharray)
static struct ami_font_scan_window *ami_font_scan_gui_open(int32 fonts)
{
struct ami_font_scan_window *fsw =
- AllocVecTagList(sizeof(struct ami_font_scan_window), NULL);
+ malloc(sizeof(struct ami_font_scan_window));
if(fsw == NULL) return NULL;
@@ -201,7 +201,7 @@ static void ami_font_scan_gui_close(struct ami_font_scan_window *fsw)
if(fsw) {
DisposeObject(fsw->objects[FS_OID_MAIN]);
ami_utf8_free(fsw->title);
- FreeVec(fsw);
+ free(fsw);
}
}
@@ -317,10 +317,10 @@ static ULONG ami_font_scan_list(struct MinList *list)
struct nsObject *node;
do {
- if((afh = (struct AvailFontsHeader *)AllocVecTagList(afSize, NULL))) {
+ if((afh = (struct AvailFontsHeader *)malloc(afSize))) {
if(((afShortage = AvailFonts((STRPTR)afh, afSize,
AFF_DISK | AFF_OTAG | AFF_SCALED)))) {
- FreeVec(afh);
+ free(afh);
afSize += afShortage;
}
} else {
@@ -350,7 +350,7 @@ static ULONG ami_font_scan_list(struct MinList *list)
}
}
}
- FreeVec(afh);
+ free(afh);
} else {
return 0;
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index c6c9633..a51d8c2 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -28,6 +28,7 @@
#endif
#include <proto/asl.h>
#include <proto/datatypes.h>
+#include <proto/diskfont.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/graphics.h>
@@ -44,6 +45,7 @@
#include <graphics/gfxbase.h>
#include <graphics/rpattr.h>
#ifdef __amigaos4__
+#include <diskfont/diskfonttag.h>
#include <graphics/blitattr.h>
#include <intuition/gui.h>
#include <libraries/application.h>
@@ -86,6 +88,7 @@
/* newlib includes */
#include <math.h>
#include <string.h>
+#include <stdlib.h>
/* NetSurf core includes */
#include "utils/log.h"
@@ -95,28 +98,27 @@
#include "utils/utils.h"
#include "utils/nsurl.h"
#include "utils/file.h"
-#include "content/hlcache.h"
+#include "netsurf/window.h"
+#include "netsurf/fetch.h"
+#include "netsurf/misc.h"
+#include "netsurf/mouse.h"
+#include "netsurf/netsurf.h"
+#include "netsurf/content.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/cookie_db.h"
+#include "netsurf/url_db.h"
+#include "netsurf/keypress.h"
#include "content/backing_store.h"
-#include "content/fetchers.h"
-#include "content/fetchers/resource.h"
-#include "content/urldb.h"
-#include "image/ico.h"
+#include "content/fetch.h"
#include "desktop/browser_history.h"
-#include "desktop/browser.h"
#include "desktop/hotlist.h"
-#include "desktop/mouse.h"
-#include "desktop/netsurf.h"
#include "desktop/version.h"
#include "desktop/save_complete.h"
#include "desktop/scrollbar.h"
#include "desktop/searchweb.h"
-#include "desktop/textinput.h"
-#include "desktop/tree.h"
-#include "desktop/gui_window.h"
-#include "desktop/gui_fetch.h"
-#include "desktop/gui_misc.h"
/* NetSurf Amiga platform includes */
+#include "amiga/desktop-tree.h"
#include "amiga/gui.h"
#include "amiga/arexx.h"
#include "amiga/bitmap.h"
@@ -138,8 +140,10 @@
#include "amiga/launch.h"
#include "amiga/libs.h"
#include "amiga/login.h"
+#include "amiga/memory.h"
#include "amiga/menu.h"
#include "amiga/misc.h"
+#include "amiga/nsoption.h"
#include "amiga/plotters.h"
#include "amiga/plugin_hack.h"
#include "amiga/print.h"
@@ -161,6 +165,10 @@
#define EXTRADOWN (IECODE_5TH_BUTTON)
#define EXTRAUP (IECODE_5TH_BUTTON | IECODE_UP_PREFIX)
+/* Left OR Right Shift/Alt keys */
+#define NSA_QUAL_SHIFT (IEQUALIFIER_RSHIFT | IEQUALIFIER_LSHIFT)
+#define NSA_QUAL_ALT (IEQUALIFIER_RALT | IEQUALIFIER_LALT)
+
#ifdef __amigaos4__
#define NSA_STATUS_TEXT GA_Text
#else
@@ -173,8 +181,6 @@
#define BOOL_MISMATCH(a,b) (1)
#endif
-static bool ami_quit = false;
-
extern struct gui_utf8_table *amiga_utf8_table;
struct ami_gui_tb_userdata {
@@ -183,6 +189,13 @@ struct ami_gui_tb_userdata {
int items;
};
+struct MinList *window_list = NULL;
+struct Screen *scrn = NULL;
+struct MsgPort *sport = NULL;
+struct gui_window *cur_gw = NULL;
+
+static bool ami_quit = false;
+
static struct MsgPort *schedulermsgport = NULL;
static struct MsgPort *appport;
static Class *urlStringClass;
@@ -191,10 +204,12 @@ static BOOL locked_screen = FALSE;
static int screen_signal = -1;
static bool win_destroyed;
static STRPTR nsscreentitle;
+static struct gui_globals browserglob;
static struct MsgPort *applibport = NULL;
-static ULONG applibsig = 0;
static uint32 ami_appid = 0;
+static ULONG applibsig = 0;
+static ULONG rxsig = 0;
static struct Hook newprefs_hook;
static STRPTR temp_homepage_url = NULL;
@@ -202,7 +217,6 @@ static bool cli_force = false;
#define USERS_DIR "PROGDIR:Users"
static char *users_dir = NULL;
-static char *current_user = NULL;
static char *current_user_dir;
static char *current_user_faviconcache;
@@ -211,7 +225,7 @@ static const __attribute__((used)) char *stack_cookie = "\0$STACK:196608\0";
const char * const versvn;
const char * const verdate;
-void ami_switch_tab(struct gui_window_2 *gwin,bool redraw);
+void ami_switch_tab(struct gui_window_2 *gwin, bool redraw);
void ami_change_tab(struct gui_window_2 *gwin, int direction);
void ami_get_hscroll_pos(struct gui_window_2 *gwin, ULONG *xs);
void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys);
@@ -220,13 +234,13 @@ Object *ami_gui_splash_open(void);
void ami_gui_splash_close(Object *win_obj);
HOOKF(uint32, ami_set_favicon_render_hook, APTR, space, struct gpRender *);
HOOKF(uint32, ami_set_throbber_render_hook, APTR, space, struct gpRender *);
-bool ami_gui_map_filename(char **remapped, const char *path, const char *file,
- const char *map);
+bool ami_gui_map_filename(char **remapped, const char *restrict path, const char *restrict file,
+ const char *restrict map);
static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw);
static void ami_do_redraw(struct gui_window_2 *g);
static void ami_schedule_redraw_remove(struct gui_window_2 *gwin);
-static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy);
+static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy);
static void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
static void gui_window_remove_caret(struct gui_window *g);
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip);
@@ -241,14 +255,16 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
-STRPTR ami_locale_langs(void)
+STRPTR ami_locale_langs(int *codeset)
{
struct Locale *locale;
STRPTR acceptlangs = NULL;
- char *remapped;
+ char *remapped = NULL;
if((locale = OpenLocale(NULL)))
{
+ if(codeset != NULL) *codeset = locale->loc_CodeSet;
+
for(int i = 0; i < 10; i++)
{
if(locale->loc_PrefLanguages[i])
@@ -268,6 +284,7 @@ STRPTR ami_locale_langs(void)
acceptlangs = ASPrintf("%s", remapped);
}
}
+ if(remapped != NULL) free(remapped);
}
else
{
@@ -279,13 +296,14 @@ STRPTR ami_locale_langs(void)
return acceptlangs;
}
-bool ami_gui_map_filename(char **remapped, const char *path, const char *file, const char *map)
+bool ami_gui_map_filename(char **remapped, const char *restrict path,
+ const char *restrict file, const char *restrict map)
{
BPTR fh = 0;
char *mapfile = NULL;
size_t mapfile_size = 0;
char buffer[1024];
- char *realfname;
+ char *restrict realfname;
bool found = false;
netsurf_mkpath(&mapfile, &mapfile_size, 2, path, map);
@@ -336,8 +354,7 @@ static bool ami_gui_check_resource(char *fullpath, const char *file)
netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
lock = Lock(fullpath, ACCESS_READ);
- if(lock)
- {
+ if(lock) {
UnLock(lock);
found = true;
}
@@ -353,7 +370,7 @@ bool ami_locate_resource(char *fullpath, const char *file)
struct Locale *locale;
int i;
bool found = false;
- char *remapped;
+ char *remapped = NULL;
size_t fullpath_len = 1024;
/* Check NetSurf user data area first */
@@ -376,14 +393,15 @@ bool ami_locate_resource(char *fullpath, const char *file)
locale = OpenLocale(NULL);
for(i=0;i<10;i++) {
- strcpy(fullpath,"PROGDIR:Resources/");
+ strcpy(fullpath, "PROGDIR:Resources/");
if(locale->loc_PrefLanguages[i]) {
- ami_gui_map_filename(&remapped, "PROGDIR:Resources",
- locale->loc_PrefLanguages[i], "LangNames");
- netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
-
- found = ami_gui_check_resource(fullpath, file);
+ if(ami_gui_map_filename(&remapped, "PROGDIR:Resources",
+ locale->loc_PrefLanguages[i], "LangNames") == true) {
+ netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped);
+ found = ami_gui_check_resource(fullpath, file);
+ free(remapped);
+ }
} else {
continue;
}
@@ -411,7 +429,17 @@ bool ami_locate_resource(char *fullpath, const char *file)
return found;
}
-static bool ami_open_resources(void)
+static void ami_gui_resources_free(void)
+{
+ ami_schedule_free();
+ ami_object_fini();
+
+ FreeSysObject(ASOT_PORT, appport);
+ FreeSysObject(ASOT_PORT, sport);
+ FreeSysObject(ASOT_PORT, schedulermsgport);
+}
+
+static bool ami_gui_resources_open(void)
{
urlStringClass = MakeStringClass();
@@ -427,6 +455,13 @@ static bool ami_open_resources(void)
ASO_NoTrack, FALSE,
TAG_DONE))) return false;
+ if(ami_schedule_create(schedulermsgport) != NSERROR_OK) {
+ ami_misc_fatal_error("Failed to initialise scheduler");
+ return false;
+ }
+
+ ami_object_init();
+
return true;
}
@@ -556,6 +591,7 @@ static nserror ami_set_options(struct nsoption_s *defaults)
{
STRPTR tempacceptlangs;
char temp[1024];
+ int codeset = 0;
/* The following line disables the popupmenu.class select menu.
** It's not recommended to use it!
@@ -566,20 +602,11 @@ static nserror ami_set_options(struct nsoption_s *defaults)
if(ClickTabBase->lib_Version < 53)
nsoption_set_bool(tab_always_show, true);
- /* Some AmigaOS3 overrides */
-#ifndef __amigaos4__
- nsoption_set_bool(download_notify, false);
- nsoption_set_bool(font_antialiasing, false);
- nsoption_set_bool(truecolour_mouse_pointers, false);
- nsoption_set_bool(use_openurl_lib, true);
- nsoption_set_bool(bitmap_fonts, true);
-#endif
-
if((!nsoption_charp(accept_language)) ||
(nsoption_charp(accept_language)[0] == '\0') ||
(nsoption_bool(accept_lang_locale) == true))
{
- if((tempacceptlangs = ami_locale_langs()))
+ if((tempacceptlangs = ami_locale_langs(&codeset)))
{
nsoption_set_charp(accept_language,
(char *)strdup(tempacceptlangs));
@@ -587,6 +614,20 @@ static nserror ami_set_options(struct nsoption_s *defaults)
}
}
+ /* Some OS-specific overrides */
+#ifdef __amigaos4__
+ if(codeset == 0) codeset = 4; /* ISO-8859-1 */
+ const char *encname = (const char *)ObtainCharsetInfo(DFCS_NUMBER, codeset,
+ DFCS_MIMENAME);
+ nsoption_set_charp(local_charset, strdup(encname));
+#else
+ nsoption_set_bool(download_notify, false);
+ nsoption_set_bool(font_antialiasing, false);
+ nsoption_set_bool(truecolour_mouse_pointers, false);
+ nsoption_set_bool(use_openurl_lib, true);
+ nsoption_set_bool(bitmap_fonts, true);
+#endif
+
sprintf(temp, "%s/Cookies", current_user_dir);
nsoption_setnull_charp(cookie_file,
(char *)strdup(temp));
@@ -759,7 +800,7 @@ static void ami_openscreen(void)
id = screenmodereq->sm_DisplayID;
sprintf(modeid, "0x%lx", id);
nsoption_set_charp(screen_modeid, modeid);
- nsoption_write(current_user_options, NULL, NULL);
+ ami_nsoption_write();
}
FreeAslRequest(screenmodereq);
}
@@ -823,9 +864,9 @@ static void ami_openscreenfirst(void)
ami_theme_throbber_setup();
}
-static struct RDArgs *ami_gui_commandline(int *argc, char **argv, int *nargc, char **nargv)
+static struct RDArgs *ami_gui_commandline(int *restrict argc, char ** argv,
+ int *restrict nargc, char ** nargv)
{
- int new_argc = 1;
struct RDArgs *args;
CONST_STRPTR template = "-v/S,NSOPTS/M,URL/K,USERSDIR/K,FORCE/S";
long rarray[] = {0,0,0,0,0};
@@ -842,12 +883,14 @@ static struct RDArgs *ami_gui_commandline(int *argc, char **argv, int *nargc, ch
if((args = ReadArgs(template, rarray, NULL))) {
if(rarray[A_URL]) {
- LOG("URL %s specified on command line", rarray[A_URL]);
- temp_homepage_url = ami_to_utf8_easy((char *)rarray[A_URL]);
+ LOG("URL %s specified on command line",
+ (char *)rarray[A_URL]);
+ temp_homepage_url = strdup((char *)rarray[A_URL]); /**\todo allow IDNs */
}
if(rarray[A_USERSDIR]) {
- LOG("USERSDIR %s specified on command line", rarray[A_USERSDIR]);
+ LOG("USERSDIR %s specified on command line",
+ (char *)rarray[A_USERSDIR]);
users_dir = ASPrintf("%s", rarray[A_USERSDIR]);
}
@@ -866,39 +909,25 @@ static struct RDArgs *ami_gui_commandline(int *argc, char **argv, int *nargc, ch
* first, nsoption_commandline() can no longer parse (fetch?)
* the arguments. If nsoption_commandline() is called first,
* then ReadArgs cannot fetch the arguments.
+ *\todo this was totally broken so to stop startup crashing
+ * has been temporarily removed (core cli not called when func
+ * returns NULL).
*/
- char **p = (char **)rarray[A_NSOPTS];
-
- do {
- LOG("Arg [%d] assigned to NSOPTS/M by ReadArgs: %s", new_argc, *p);
- new_argc++;
- p++;
- } while(*p != NULL);
-
- const char *new_argv = malloc(sizeof(char *) * new_argc);
- const char **new_argvp = &new_argv;
- p = (char **)rarray[A_NSOPTS];
-
- do {
- *new_argvp = *p;
- new_argvp++;
- p++;
- } while(*p != NULL);
-
- *nargc = new_argc;
- *nargv = new_argv;
}
} else {
LOG("ReadArgs failed to parse command line");
}
- return args;
+
+ FreeArgs(args);
+ return NULL;
}
-static void ami_gui_read_tooltypes(struct WBArg *wbarg)
+static char *ami_gui_read_tooltypes(struct WBArg *wbarg)
{
struct DiskObject *dobj;
STRPTR *toolarray;
char *s;
+ char *current_user = NULL;
if((*wbarg->wa_Name) && (dobj = GetDiskObject(wbarg->wa_Name))) {
toolarray = (STRPTR *)dobj->do_ToolTypes;
@@ -908,27 +937,40 @@ static void ami_gui_read_tooltypes(struct WBArg *wbarg)
FreeDiskObject(dobj);
}
+ return current_user;
}
-static void ami_gui_read_all_tooltypes(int argc, char **argv)
+static STRPTR ami_gui_read_all_tooltypes(int argc, char **argv)
{
struct WBStartup *WBenchMsg;
struct WBArg *wbarg;
- char i;
- LONG olddir = -1;
+ char i = 0;
+ char *current_user = NULL;
+ char *cur_user = NULL;
if(argc == 0) { /* Started from WB */
WBenchMsg = (struct WBStartup *)argv;
for(i = 0, wbarg = WBenchMsg->sm_ArgList; i < WBenchMsg->sm_NumArgs; i++,wbarg++) {
- olddir =-1;
+ LONG olddir =-1;
if((wbarg->wa_Lock) && (*wbarg->wa_Name))
olddir = SetCurrentDir(wbarg->wa_Lock);
- ami_gui_read_tooltypes(wbarg);
+ cur_user = ami_gui_read_tooltypes(wbarg);
+ if(cur_user != NULL) {
+ if(current_user != NULL) FreeVec(current_user);
+ current_user = cur_user;
+ }
if(olddir !=-1) SetCurrentDir(olddir);
}
}
+
+ return current_user;
+}
+
+void ami_gui_set_default_gg(void)
+{
+ glob = &browserglob;
}
static void gui_init2(int argc, char** argv)
@@ -939,10 +981,10 @@ static void gui_init2(int argc, char** argv)
nserror error;
struct browser_window *bw = NULL;
- notalreadyrunning = ami_arexx_init();
+ notalreadyrunning = ami_arexx_init(&rxsig);
/* Treeview init code ends up calling a font function which needs this */
- glob = &browserglob;
+ ami_gui_set_default_gg();
/* ...and this ensures the treeview at least gets the WB colour palette to work with */
if(scrn == NULL) {
@@ -1049,19 +1091,24 @@ static void gui_init2(int argc, char** argv)
if(!notalreadyrunning)
{
STRPTR sendcmd = NULL;
+ char newtab[11] = "\0";
- if(temp_homepage_url)
- {
- sendcmd = ASPrintf("OPEN \"%s\" NEW",temp_homepage_url);
- free(temp_homepage_url);
+ if(nsoption_bool(tab_new_session) == true) {
+ strcpy(newtab, "TAB ACTIVE");
}
- else
- {
- sendcmd = ASPrintf("OPEN \"%s\" NEW",nsoption_charp(homepage_url));
+
+ if(temp_homepage_url) {
+ sendcmd = ASPrintf("OPEN \"%s\" NEW%s", temp_homepage_url, newtab);
+ free(temp_homepage_url);
+ } else {
+ sendcmd = ASPrintf("OPEN \"%s\" NEW%s", nsoption_charp(homepage_url), newtab);
}
- IDoMethod(arexx_obj,AM_EXECUTE,sendcmd,"NETSURF",NULL,NULL,NULL,NULL);
+ ami_arexx_self(sendcmd);
FreeVec(sendcmd);
+ /* Bring the screen to the front. Intuition may have already done this, but it doesn't hurt. */
+ ami_arexx_self("TOFRONT");
+
ami_quit=true;
return;
}
@@ -1214,45 +1261,33 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
switch(keycode)
{
case RAWKEY_CRSRUP:
- if(ie->ie_Qualifier & IEQUALIFIER_RSHIFT)
- {
+ if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
nskey = NS_KEY_PAGE_UP;
- }
- else if(ie->ie_Qualifier & IEQUALIFIER_RALT)
- {
+ } else if(ie->ie_Qualifier & NSA_QUAL_ALT) {
nskey = NS_KEY_TEXT_START;
}
else nskey = NS_KEY_UP;
break;
case RAWKEY_CRSRDOWN:
- if(ie->ie_Qualifier & IEQUALIFIER_RSHIFT)
- {
+ if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
nskey = NS_KEY_PAGE_DOWN;
- }
- else if(ie->ie_Qualifier & IEQUALIFIER_RALT)
- {
+ } else if(ie->ie_Qualifier & NSA_QUAL_ALT) {
nskey = NS_KEY_TEXT_END;
}
else nskey = NS_KEY_DOWN;
break;
case RAWKEY_CRSRLEFT:
- if(ie->ie_Qualifier & IEQUALIFIER_RSHIFT)
- {
+ if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
nskey = NS_KEY_LINE_START;
- }
- else if(ie->ie_Qualifier & IEQUALIFIER_RALT)
- {
+ }else if(ie->ie_Qualifier & NSA_QUAL_ALT) {
nskey = NS_KEY_WORD_LEFT;
}
else nskey = NS_KEY_LEFT;
break;
case RAWKEY_CRSRRIGHT:
- if(ie->ie_Qualifier & IEQUALIFIER_RSHIFT)
- {
+ if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
nskey = NS_KEY_LINE_END;
- }
- else if(ie->ie_Qualifier & IEQUALIFIER_RALT)
- {
+ }else if(ie->ie_Qualifier & NSA_QUAL_ALT) {
nskey = NS_KEY_WORD_RIGHT;
}
else nskey = NS_KEY_RIGHT;
@@ -1273,25 +1308,25 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
nskey = NS_KEY_TEXT_END;
break;
case RAWKEY_BACKSPACE:
- if(ie->ie_Qualifier & IEQUALIFIER_RSHIFT)
- {
+ if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
nskey = NS_KEY_DELETE_LINE_START;
+ } else {
+ nskey = NS_KEY_DELETE_LEFT;
}
- else nskey = NS_KEY_DELETE_LEFT;
break;
case RAWKEY_DEL:
- if(ie->ie_Qualifier & IEQUALIFIER_RSHIFT)
- {
+ if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
nskey = NS_KEY_DELETE_LINE_END;
+ } else {
+ nskey = NS_KEY_DELETE_RIGHT;
}
- else nskey = NS_KEY_DELETE_RIGHT;
break;
case RAWKEY_TAB:
- if(ie->ie_Qualifier & IEQUALIFIER_RSHIFT)
- {
+ if(ie->ie_Qualifier & NSA_QUAL_SHIFT) {
nskey = NS_KEY_SHIFT_TAB;
+ } else {
+ nskey = NS_KEY_TAB;
}
- else nskey = NS_KEY_TAB;
break;
case RAWKEY_F5:
case RAWKEY_F8:
@@ -1303,8 +1338,9 @@ int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie)
break;
default:
if((chars = MapRawKey(ie,buffer,20,NULL)) > 0) {
- utf8_from_local_encoding(buffer, chars, &utf8);
+ if(utf8_from_local_encoding(buffer, chars, &utf8) != NSERROR_OK) return 0;
nskey = utf8_to_ucs4(utf8, utf8_char_byte_length(utf8));
+ free(utf8);
if(ie->ie_Qualifier & IEQUALIFIER_RCOMMAND) {
switch(nskey) {
@@ -1345,18 +1381,15 @@ static void ami_update_quals(struct gui_window_2 *gwin)
#endif
gwin->key_state = 0;
- if((quals & IEQUALIFIER_LSHIFT) || (quals & IEQUALIFIER_RSHIFT))
- {
+ if(quals & NSA_QUAL_SHIFT) {
gwin->key_state |= BROWSER_MOUSE_MOD_1;
}
- if(quals & IEQUALIFIER_CONTROL)
- {
+ if(quals & IEQUALIFIER_CONTROL) {
gwin->key_state |= BROWSER_MOUSE_MOD_2;
}
- if((quals & IEQUALIFIER_LALT) || (quals & IEQUALIFIER_RALT))
- {
+ if(quals & NSA_QUAL_ALT) {
gwin->key_state |= BROWSER_MOUSE_MOD_3;
}
}
@@ -1366,7 +1399,7 @@ nserror ami_gui_get_space_box(Object *obj, struct IBox **bbox)
{
#ifdef __amigaos4__
if(LIB_IS_AT_LEAST((struct Library *)SpaceBase, 53, 6)) {
- *bbox = AllocVecTagList(sizeof(struct IBox), NULL);
+ *bbox = malloc(sizeof(struct IBox));
if(*bbox == NULL) return NSERROR_NOMEM;
GetAttr(SPACE_RenderBox, obj, (ULONG *)*bbox);
} else
@@ -1383,13 +1416,13 @@ void ami_gui_free_space_box(struct IBox *bbox)
{
#ifdef __amigaos4__
if(LIB_IS_AT_LEAST((struct Library *)SpaceBase, 53, 6)) {
- FreeVec(bbox);
+ free(bbox);
}
#endif
}
-static bool ami_spacebox_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
- int space_x, int space_y)
+static bool ami_spacebox_to_ns_coords(struct gui_window_2 *gwin,
+ int *restrict x, int *restrict y, int space_x, int space_y)
{
int ns_x = space_x;
int ns_y = space_y;
@@ -1406,7 +1439,7 @@ static bool ami_spacebox_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
return true;
}
-bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
+bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *restrict x, int *restrict y,
int mouse_x, int mouse_y)
{
int ns_x, ns_y;
@@ -1511,7 +1544,7 @@ static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct
{
struct IBox *bbox, *ibox;
- ibox = AllocVecTagList(sizeof(struct IBox), NULL);
+ ibox = malloc(sizeof(struct IBox));
if(ibox == NULL) return NULL;
if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
@@ -1532,7 +1565,7 @@ static struct IBox *ami_ns_rect_to_ibox(struct gui_window_2 *gwin, const struct
(ibox->Top > (bbox->Top + bbox->Height)) ||
(ibox->Width < 0) || (ibox->Height < 0))
{
- FreeVec(ibox);
+ free(ibox);
ami_gui_free_space_box(bbox);
return NULL;
}
@@ -1583,8 +1616,8 @@ static void ami_gui_menu_update_all(void)
} while((node = nnode));
}
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
- bool scaled)
+static void gui_window_get_dimensions(struct gui_window *g,
+ int *restrict width, int *restrict height, bool scaled)
{
struct IBox *bbox;
if(!g) return;
@@ -1748,7 +1781,7 @@ static void ami_gui_scroller_update(struct gui_window_2 *gwin)
/**
* function to add retrieved favicon to gui
*/
-static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
{
struct BitMap *bm = NULL;
struct IBox *bbox;
@@ -1829,7 +1862,8 @@ static void ami_gui_refresh_favicon(void *p)
* Returns the width of the size gadget as a convenience.
*/
#ifdef __amigaos4__
-static ULONG ami_get_border_gadget_size(struct gui_window_2 *gwin, ULONG *width, ULONG *height)
+static ULONG ami_get_border_gadget_size(struct gui_window_2 *gwin,
+ ULONG *restrict width, ULONG *restrict height)
{
static ULONG sz_gad_width = 0;
static ULONG sz_gad_height = 0;
@@ -1869,684 +1903,642 @@ static void ami_set_border_gadget_size(struct gui_window_2 *gwin)
#endif
}
-static void ami_handle_msg(void)
+static BOOL ami_handle_msg(void)
{
- ULONG result,storage = 0,x,y,xs,ys,width=800,height=600;
- uint16 code;
- struct IBox *bbox;
+ struct ami_generic_window *w = NULL;
struct nsObject *node;
struct nsObject *nnode;
- struct gui_window_2 *gwin = NULL;
- struct InputEvent *ie;
- struct Node *tabnode;
- int nskey;
- struct timeval curtime;
- static int drag_x_move = 0, drag_y_move = 0;
- char *utf8 = NULL;
- nsurl *url;
+ BOOL win_closed = FALSE;
- if(IsMinListEmpty(window_list))
- {
+ if(IsMinListEmpty(window_list)) {
/* no windows in list, so NetSurf should not be running */
ami_try_quit();
- return;
+ return FALSE;
}
node = (struct nsObject *)GetHead((struct List *)window_list);
- do
- {
+ do {
nnode=(struct nsObject *)GetSucc((struct Node *)node);
- gwin = node->objstruct;
+ w = node->objstruct;
+ if(w == NULL) continue;
- if(node->Type == AMINS_TVWINDOW) {
- if(ami_tree_event((struct treeview_window *)gwin)) {
- ami_try_quit();
- break;
- } else {
- node = nnode;
- continue;
- }
- } else if(node->Type == AMINS_FINDWINDOW) {
- if(ami_search_event()) {
- ami_try_quit();
- break;
- } else {
- node = nnode;
- continue;
- }
- } else if(node->Type == AMINS_HISTORYWINDOW) {
- if(ami_history_event((struct history_window *)gwin)) {
- ami_try_quit();
- break;
- } else {
- node = nnode;
- continue;
- }
- } else if(node->Type == AMINS_PRINTWINDOW) {
- if(ami_print_event((struct ami_print_window *)gwin)) {
- ami_try_quit();
- break;
- } else {
- node = nnode;
- continue;
- }
- } 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 {
- node = nnode;
- continue;
- }
- } else if(node->Type == AMINS_DLWINDOW) {
- if(ami_download_window_event((struct gui_download_window *)gwin)) {
- ami_try_quit();
- break;
- } else {
- node = nnode;
- continue;
- }
- } else if(node->Type == AMINS_LOGINWINDOW) {
- if(ami_401login_event((struct gui_login_window *)gwin)) {
- ami_try_quit();
- break;
+ if(w->tbl->event != NULL) {
+ if((win_closed = w->tbl->event(w))) {
+ if((node->Type != AMINS_GUIOPTSWINDOW) ||
+ ((node->Type == AMINS_GUIOPTSWINDOW) && (scrn != NULL))) {
+ ami_try_quit();
+ break;
+ }
} else {
node = nnode;
continue;
}
}
+ } while((node = nnode));
- if((gwin == NULL) || (gwin->objects[OID_MAIN] == NULL)) continue;
+ if(ami_menu_quit_selected() == true) {
+ ami_quit_netsurf();
+ }
+
+ if(ami_menu_get_check_toggled() == true) {
+ ami_gui_menu_update_all();
+ }
- while((result = RA_HandleInput(gwin->objects[OID_MAIN], &code)) != WMHI_LASTMSG) {
- switch(result & WMHI_CLASSMASK) // class
- {
- case WMHI_MOUSEMOVE:
- ami_gui_trap_mouse(gwin); /* re-assert mouse area */
+ return win_closed;
+}
- drag_x_move = 0;
- drag_y_move = 0;
+static BOOL ami_gui_event(void *w)
+{
+ struct gui_window_2 *gwin = (struct gui_window_2 *)w;
+ ULONG result, storage = 0, x, y, xs, ys, width = 800, height = 600;
+ uint16 code;
+ struct IBox *bbox;
+ struct InputEvent *ie;
+ struct Node *tabnode;
+ int nskey;
+ struct timeval curtime;
+ static int drag_x_move = 0, drag_y_move = 0;
+ char *utf8 = NULL;
+ nsurl *url;
+ BOOL win_closed = FALSE;
- if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
- amiga_warn_user("NoMemory", "");
- break;
- }
+ while((result = RA_HandleInput(gwin->objects[OID_MAIN], &code)) != WMHI_LASTMSG) {
+ switch(result & WMHI_CLASSMASK) // class
+ {
+ case WMHI_MOUSEMOVE:
+ ami_gui_trap_mouse(gwin); /* re-assert mouse area */
- x = (ULONG)((gwin->win->MouseX - bbox->Left) / gwin->gw->scale);
- y = (ULONG)((gwin->win->MouseY - bbox->Top) / gwin->gw->scale);
+ drag_x_move = 0;
+ drag_y_move = 0;
- ami_get_hscroll_pos(gwin, (ULONG *)&xs);
- ami_get_vscroll_pos(gwin, (ULONG *)&ys);
+ if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ break;
+ }
- x += xs;
- y += ys;
+ x = (ULONG)((gwin->win->MouseX - bbox->Left) / gwin->gw->scale);
+ y = (ULONG)((gwin->win->MouseY - bbox->Top) / gwin->gw->scale);
- width=bbox->Width;
- height=bbox->Height;
+ ami_get_hscroll_pos(gwin, (ULONG *)&xs);
+ ami_get_vscroll_pos(gwin, (ULONG *)&ys);
- if(gwin->mouse_state & BROWSER_MOUSE_DRAG_ON)
- {
- ami_drag_icon_move();
-
- if(ami_autoscroll == TRUE) {
- if((gwin->win->MouseX < bbox->Left) &&
- ((gwin->win->MouseX - bbox->Left) > -AMI_DRAG_THRESHOLD))
- drag_x_move = gwin->win->MouseX - bbox->Left;
- if((gwin->win->MouseX > (bbox->Left + bbox->Width)) &&
- ((gwin->win->MouseX - (bbox->Left + bbox->Width)) < AMI_DRAG_THRESHOLD))
- drag_x_move = gwin->win->MouseX - (bbox->Left + bbox->Width);
- if((gwin->win->MouseY < bbox->Top) &&
- ((gwin->win->MouseY - bbox->Top) > -AMI_DRAG_THRESHOLD))
- drag_y_move = gwin->win->MouseY - bbox->Top;
- if((gwin->win->MouseY > (bbox->Top + bbox->Height)) &&
- ((gwin->win->MouseY - (bbox->Top + bbox->Height)) < AMI_DRAG_THRESHOLD))
- drag_y_move = gwin->win->MouseY - (bbox->Top + bbox->Height);
- }
+ x += xs;
+ y += ys;
+
+ width=bbox->Width;
+ height=bbox->Height;
+
+ if(gwin->mouse_state & BROWSER_MOUSE_DRAG_ON)
+ {
+ if(ami_drag_icon_move() == TRUE) {
+ if((gwin->win->MouseX < bbox->Left) &&
+ ((gwin->win->MouseX - bbox->Left) > -AMI_DRAG_THRESHOLD))
+ drag_x_move = gwin->win->MouseX - bbox->Left;
+ if((gwin->win->MouseX > (bbox->Left + bbox->Width)) &&
+ ((gwin->win->MouseX - (bbox->Left + bbox->Width)) < AMI_DRAG_THRESHOLD))
+ drag_x_move = gwin->win->MouseX - (bbox->Left + bbox->Width);
+ if((gwin->win->MouseY < bbox->Top) &&
+ ((gwin->win->MouseY - bbox->Top) > -AMI_DRAG_THRESHOLD))
+ drag_y_move = gwin->win->MouseY - bbox->Top;
+ if((gwin->win->MouseY > (bbox->Top + bbox->Height)) &&
+ ((gwin->win->MouseY - (bbox->Top + bbox->Height)) < AMI_DRAG_THRESHOLD))
+ drag_y_move = gwin->win->MouseY - (bbox->Top + bbox->Height);
}
+ }
- ami_gui_free_space_box(bbox);
+ ami_gui_free_space_box(bbox);
- if((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys))
- {
- ami_update_quals(gwin);
+ if((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys))
+ {
+ ami_update_quals(gwin);
- if(gwin->mouse_state & BROWSER_MOUSE_PRESS_1)
- {
- browser_window_mouse_track(gwin->gw->bw,BROWSER_MOUSE_DRAG_1 | gwin->key_state,x,y);
- gwin->mouse_state = BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON;
- }
- else if(gwin->mouse_state & BROWSER_MOUSE_PRESS_2)
- {
- browser_window_mouse_track(gwin->gw->bw,BROWSER_MOUSE_DRAG_2 | gwin->key_state,x,y);
- gwin->mouse_state = BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_ON;
- }
- else
- {
- browser_window_mouse_track(gwin->gw->bw,gwin->mouse_state | gwin->key_state,x,y);
- }
- } else {
- if(!gwin->mouse_state) ami_set_pointer(gwin, GUI_POINTER_DEFAULT, true);
+ if(gwin->mouse_state & BROWSER_MOUSE_PRESS_1)
+ {
+ browser_window_mouse_track(gwin->gw->bw,BROWSER_MOUSE_DRAG_1 | gwin->key_state,x,y);
+ gwin->mouse_state = BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON;
}
- break;
-
- case WMHI_MOUSEBUTTONS:
- if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
- amiga_warn_user("NoMemory", "");
- return;
+ else if(gwin->mouse_state & BROWSER_MOUSE_PRESS_2)
+ {
+ browser_window_mouse_track(gwin->gw->bw,BROWSER_MOUSE_DRAG_2 | gwin->key_state,x,y);
+ gwin->mouse_state = BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_ON;
}
+ else
+ {
+ browser_window_mouse_track(gwin->gw->bw,gwin->mouse_state | gwin->key_state,x,y);
+ }
+ } else {
+ if(!gwin->mouse_state) ami_set_pointer(gwin, GUI_POINTER_DEFAULT, true);
+ }
+ break;
- x = (ULONG)((gwin->win->MouseX - bbox->Left) / gwin->gw->scale);
- y = (ULONG)((gwin->win->MouseY - bbox->Top) / gwin->gw->scale);
+ case WMHI_MOUSEBUTTONS:
+ if(ami_gui_get_space_box((Object *)gwin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ amiga_warn_user("NoMemory", "");
+ return FALSE;
+ }
- ami_get_hscroll_pos(gwin, (ULONG *)&xs);
- ami_get_vscroll_pos(gwin, (ULONG *)&ys);
+ x = (ULONG)((gwin->win->MouseX - bbox->Left) / gwin->gw->scale);
+ y = (ULONG)((gwin->win->MouseY - bbox->Top) / gwin->gw->scale);
- x += xs;
- y += ys;
+ ami_get_hscroll_pos(gwin, (ULONG *)&xs);
+ ami_get_vscroll_pos(gwin, (ULONG *)&ys);
- width=bbox->Width;
- height=bbox->Height;
+ x += xs;
+ y += ys;
- ami_gui_free_space_box(bbox);
+ width=bbox->Width;
+ height=bbox->Height;
- ami_update_quals(gwin);
+ ami_gui_free_space_box(bbox);
+
+ ami_update_quals(gwin);
- if((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys))
+ if((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys))
+ {
+ //code = code>>16;
+ switch(code)
{
- //code = code>>16;
- switch(code)
- {
- case SELECTDOWN:
- browser_window_mouse_click(gwin->gw->bw,BROWSER_MOUSE_PRESS_1 | gwin->key_state,x,y);
- gwin->mouse_state=BROWSER_MOUSE_PRESS_1;
- break;
- case MIDDLEDOWN:
- browser_window_mouse_click(gwin->gw->bw,BROWSER_MOUSE_PRESS_2 | gwin->key_state,x,y);
- gwin->mouse_state=BROWSER_MOUSE_PRESS_2;
- break;
- }
+ case SELECTDOWN:
+ browser_window_mouse_click(gwin->gw->bw,BROWSER_MOUSE_PRESS_1 | gwin->key_state,x,y);
+ gwin->mouse_state=BROWSER_MOUSE_PRESS_1;
+ break;
+ case MIDDLEDOWN:
+ browser_window_mouse_click(gwin->gw->bw,BROWSER_MOUSE_PRESS_2 | gwin->key_state,x,y);
+ gwin->mouse_state=BROWSER_MOUSE_PRESS_2;
+ break;
}
+ }
- if(x<xs) x=xs;
- if(y<ys) y=ys;
- if(x>=width+xs) x=width+xs-1;
- if(y>=height+ys) y=height+ys-1;
+ if(x<xs) x=xs;
+ if(y<ys) y=ys;
+ if(x>=width+xs) x=width+xs-1;
+ if(y>=height+ys) y=height+ys-1;
- switch(code)
- {
- case SELECTUP:
- if(gwin->mouse_state & BROWSER_MOUSE_PRESS_1)
- {
- CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
+ switch(code)
+ {
+ case SELECTUP:
+ if(gwin->mouse_state & BROWSER_MOUSE_PRESS_1)
+ {
+ CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
- gwin->mouse_state = BROWSER_MOUSE_CLICK_1;
+ gwin->mouse_state = BROWSER_MOUSE_CLICK_1;
- if(gwin->lastclick.tv_sec)
- {
- if(DoubleClick(gwin->lastclick.tv_sec,
- gwin->lastclick.tv_usec,
- curtime.tv_sec, curtime.tv_usec)) {
- if(gwin->prev_mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
- gwin->mouse_state |= BROWSER_MOUSE_TRIPLE_CLICK;
- } else {
- gwin->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
- }
+ if(gwin->lastclick.tv_sec)
+ {
+ if(DoubleClick(gwin->lastclick.tv_sec,
+ gwin->lastclick.tv_usec,
+ curtime.tv_sec, curtime.tv_usec)) {
+ if(gwin->prev_mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
+ gwin->mouse_state |= BROWSER_MOUSE_TRIPLE_CLICK;
+ } else {
+ gwin->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
}
}
+ }
- browser_window_mouse_click(gwin->gw->bw,
- gwin->mouse_state | gwin->key_state,x,y);
+ browser_window_mouse_click(gwin->gw->bw,
+ gwin->mouse_state | gwin->key_state,x,y);
- if(gwin->mouse_state & BROWSER_MOUSE_TRIPLE_CLICK)
- {
- gwin->lastclick.tv_sec = 0;
- gwin->lastclick.tv_usec = 0;
- }
- else
- {
- gwin->lastclick.tv_sec = curtime.tv_sec;
- gwin->lastclick.tv_usec = curtime.tv_usec;
- }
+ if(gwin->mouse_state & BROWSER_MOUSE_TRIPLE_CLICK)
+ {
+ gwin->lastclick.tv_sec = 0;
+ gwin->lastclick.tv_usec = 0;
}
else
{
- browser_window_mouse_track(gwin->gw->bw, 0, x, y);
+ gwin->lastclick.tv_sec = curtime.tv_sec;
+ gwin->lastclick.tv_usec = curtime.tv_usec;
}
- gwin->prev_mouse_state = gwin->mouse_state;
- gwin->mouse_state=0;
- break;
+ }
+ else
+ {
+ browser_window_mouse_track(gwin->gw->bw, 0, x, y);
+ }
+ gwin->prev_mouse_state = gwin->mouse_state;
+ gwin->mouse_state=0;
+ break;
- case MIDDLEUP:
- if(gwin->mouse_state & BROWSER_MOUSE_PRESS_2)
- {
- CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
+ case MIDDLEUP:
+ if(gwin->mouse_state & BROWSER_MOUSE_PRESS_2)
+ {
+ CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
- gwin->mouse_state = BROWSER_MOUSE_CLICK_2;
+ gwin->mouse_state = BROWSER_MOUSE_CLICK_2;
- if(gwin->lastclick.tv_sec)
- {
- if(DoubleClick(gwin->lastclick.tv_sec,
- gwin->lastclick.tv_usec,
- curtime.tv_sec, curtime.tv_usec)) {
- if(gwin->prev_mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
- gwin->mouse_state |= BROWSER_MOUSE_TRIPLE_CLICK;
- } else {
- gwin->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
- }
+ if(gwin->lastclick.tv_sec)
+ {
+ if(DoubleClick(gwin->lastclick.tv_sec,
+ gwin->lastclick.tv_usec,
+ curtime.tv_sec, curtime.tv_usec)) {
+ if(gwin->prev_mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
+ gwin->mouse_state |= BROWSER_MOUSE_TRIPLE_CLICK;
+ } else {
+ gwin->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
}
}
+ }
- browser_window_mouse_click(gwin->gw->bw,
- gwin->mouse_state | gwin->key_state,x,y);
+ browser_window_mouse_click(gwin->gw->bw,
+ gwin->mouse_state | gwin->key_state,x,y);
- if(gwin->mouse_state & BROWSER_MOUSE_TRIPLE_CLICK)
- {
- gwin->lastclick.tv_sec = 0;
- gwin->lastclick.tv_usec = 0;
- }
- else
- {
- gwin->lastclick.tv_sec = curtime.tv_sec;
- gwin->lastclick.tv_usec = curtime.tv_usec;
- }
+ if(gwin->mouse_state & BROWSER_MOUSE_TRIPLE_CLICK)
+ {
+ gwin->lastclick.tv_sec = 0;
+ gwin->lastclick.tv_usec = 0;
}
else
{
- browser_window_mouse_track(gwin->gw->bw, 0, x, y);
+ gwin->lastclick.tv_sec = curtime.tv_sec;
+ gwin->lastclick.tv_usec = curtime.tv_usec;
}
- gwin->prev_mouse_state = gwin->mouse_state;
- gwin->mouse_state=0;
- break;
+ }
+ else
+ {
+ browser_window_mouse_track(gwin->gw->bw, 0, x, y);
+ }
+ gwin->prev_mouse_state = gwin->mouse_state;
+ gwin->mouse_state=0;
+ break;
#ifdef __amigaos4__
- case SIDEUP:
- ami_gui_history(gwin, true);
- break;
+ case SIDEUP:
+ ami_gui_history(gwin, true);
+ break;
- case EXTRAUP:
- ami_gui_history(gwin, false);
- break;
+ case EXTRAUP:
+ ami_gui_history(gwin, false);
+ break;
#endif
+ }
+
+ if(ami_drag_has_data() && !gwin->mouse_state)
+ ami_drag_save(gwin->win);
+ break;
+
+ case WMHI_GADGETUP:
+ switch(result & WMHI_GADGETMASK)
+ {
+ case GID_TABS:
+ if(gwin->objects[GID_TABS] == NULL) break;
+ if(ClickTabBase->lib_Version >= 53) {
+ GetAttrs(gwin->objects[GID_TABS],
+ CLICKTAB_NodeClosed, &tabnode, TAG_DONE);
+ } else {
+ tabnode = NULL;
+ }
+
+ if(tabnode) {
+ struct gui_window *closedgw;
+
+ GetClickTabNodeAttrs(tabnode,
+ TNA_UserData, &closedgw,
+ TAG_DONE);
+
+ browser_window_destroy(closedgw->bw);
+ } else {
+ ami_switch_tab(gwin, true);
+ }
+ break;
+
+ case GID_CLOSETAB:
+ browser_window_destroy(gwin->gw->bw);
+ break;
+
+ case GID_ADDTAB:
+ ami_gui_new_blank_tab(gwin);
+ break;
+
+ case GID_URL:
+ {
+ nserror ret;
+ nsurl *url;
+ GetAttr(STRINGA_TextVal,
+ (Object *)gwin->objects[GID_URL],
+ (ULONG *)&storage);
+ utf8 = ami_to_utf8_easy((const char *)storage);
+
+ ret = search_web_omni(utf8, SEARCH_WEB_OMNI_NONE, &url);
+ ami_utf8_free(utf8);
+ if (ret == NSERROR_OK) {
+ browser_window_navigate(gwin->gw->bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (ret != NSERROR_OK) {
+ amiga_warn_user(messages_get_errorcode(ret), 0);
+ }
}
+ break;
- if(drag_save_data && !gwin->mouse_state)
- ami_drag_save(gwin->win);
- break;
+ case GID_TOOLBARLAYOUT:
+ /* Need fixing: never gets here */
+ search_web_select_provider(-1);
+ break;
- case WMHI_GADGETUP:
- switch(result & WMHI_GADGETMASK)
+ case GID_SEARCH_ICON:
+ GetAttr(CHOOSER_Selected, gwin->objects[GID_SEARCH_ICON], (ULONG *)&storage);
+ search_web_select_provider(storage);
+ break;
+
+ case GID_SEARCHSTRING:
{
- case GID_TABS:
- if(gwin->objects[GID_TABS] == NULL) break;
- if(ClickTabBase->lib_Version >= 53) {
- GetAttrs(gwin->objects[GID_TABS],
- CLICKTAB_NodeClosed, &tabnode, TAG_DONE);
- } else {
- tabnode = NULL;
- }
+ nserror ret;
+ nsurl *url;
- if(tabnode) {
- struct gui_window *closedgw;
+ GetAttr(STRINGA_TextVal,
+ (Object *)gwin->objects[GID_SEARCHSTRING],
+ (ULONG *)&storage);
- GetClickTabNodeAttrs(tabnode,
- TNA_UserData, &closedgw,
- TAG_DONE);
+ utf8 = ami_to_utf8_easy((const char *)storage);
+
+ ret = search_web_omni(utf8, SEARCH_WEB_OMNI_SEARCHONLY, &url);
+ ami_utf8_free(utf8);
+ if (ret == NSERROR_OK) {
+ browser_window_navigate(gwin->gw->bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (ret != NSERROR_OK) {
+ amiga_warn_user(messages_get_errorcode(ret), 0);
+ }
- browser_window_destroy(closedgw->bw);
+ }
+ break;
+
+ case GID_HOME:
+ {
+ if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
+ amiga_warn_user("NoMemory", 0);
} else {
- ami_switch_tab(gwin, true);
+ browser_window_navigate(gwin->gw->bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
}
- break;
+ }
+ break;
- case GID_CLOSETAB:
- browser_window_destroy(gwin->gw->bw);
- break;
+ case GID_STOP:
+ if(browser_window_stop_available(gwin->gw->bw))
+ browser_window_stop(gwin->gw->bw);
+ break;
- case GID_ADDTAB:
- ami_gui_new_blank_tab(gwin);
- break;
+ case GID_RELOAD:
+ ami_update_quals(gwin);
- case GID_URL:
+ if(browser_window_reload_available(gwin->gw->bw))
{
- nserror ret;
- nsurl *url;
- GetAttr(STRINGA_TextVal,
- (Object *)gwin->objects[GID_URL],
- (ULONG *)&storage);
- utf8 = ami_to_utf8_easy((const char *)storage);
-
- ret = search_web_omni(utf8, SEARCH_WEB_OMNI_NONE, &url);
- ami_utf8_free(utf8);
- if (ret == NSERROR_OK) {
- browser_window_navigate(gwin->gw->bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
+ if(gwin->key_state & BROWSER_MOUSE_MOD_1)
+ {
+ browser_window_reload(gwin->gw->bw, true);
}
- if (ret != NSERROR_OK) {
- amiga_warn_user(messages_get_errorcode(ret), 0);
+ else
+ {
+ browser_window_reload(gwin->gw->bw, false);
}
}
- break;
+ break;
- case GID_TOOLBARLAYOUT:
- /* Need fixing: never gets here */
- search_web_select_provider(-1);
- break;
+ case GID_BACK:
+ ami_gui_history(gwin, true);
+ break;
- case GID_SEARCH_ICON:
- GetAttr(CHOOSER_Selected, gwin->objects[GID_SEARCH_ICON], (ULONG *)&storage);
- search_web_select_provider(storage);
- break;
+ case GID_FORWARD:
+ ami_gui_history(gwin, false);
+ break;
- case GID_SEARCHSTRING:
- {
- nserror ret;
- nsurl *url;
+ case GID_FAVE:
+ 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);
+ } else {
+ hotlist_add_url(url);
+ }
+ nsurl_unref(url);
+ }
+ ami_gui_update_hotlist_button(gwin);
+ break;
- GetAttr(STRINGA_TextVal,
- (Object *)gwin->objects[GID_SEARCHSTRING],
- (ULONG *)&storage);
+ case GID_HOTLIST:
+ default:
+// printf("GADGET: %ld\n",(result & WMHI_GADGETMASK));
+ break;
+ }
+ break;
- utf8 = ami_to_utf8_easy((const char *)storage);
+ case WMHI_RAWKEY:
+ ami_update_quals(gwin);
+
+ storage = result & WMHI_GADGETMASK;
+ if(storage >= IECODE_UP_PREFIX) break;
- ret = search_web_omni(utf8, SEARCH_WEB_OMNI_SEARCHONLY, &url);
- ami_utf8_free(utf8);
- if (ret == NSERROR_OK) {
- browser_window_navigate(gwin->gw->bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- if (ret != NSERROR_OK) {
- amiga_warn_user(messages_get_errorcode(ret), 0);
- }
+ GetAttr(WINDOW_InputEvent,gwin->objects[OID_MAIN],(ULONG *)&ie);
- }
- break;
+ nskey = ami_key_to_nskey(storage, ie);
- case GID_HOME:
- {
- if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
- amiga_warn_user("NoMemory", 0);
- } else {
- browser_window_navigate(gwin->gw->bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- }
+ if((ie->ie_Qualifier & IEQUALIFIER_RCOMMAND) &&
+ ((31 < nskey) && (nskey < 127))) {
+ /* NB: Some keypresses are converted to generic keypresses above
+ * rather than being "menu-emulated" here. */
+ switch(nskey)
+ {
+ /* The following aren't available from the menu at the moment */
+
+ case 'r': // reload
+ if(browser_window_reload_available(gwin->gw->bw))
+ browser_window_reload(gwin->gw->bw, false);
break;
- case GID_STOP:
- if(browser_window_stop_available(gwin->gw->bw))
- browser_window_stop(gwin->gw->bw);
+ case 'u': // open url
+ if((nsoption_bool(kiosk_mode) == false))
+ ActivateLayoutGadget((struct Gadget *)gwin->objects[GID_MAIN],
+ gwin->win, NULL, (uint32)gwin->objects[GID_URL]);
break;
+ }
+ }
+ else
+ {
+ if(!browser_window_key_press(gwin->gw->bw, nskey))
+ {
+ switch(nskey)
+ {
+ case NS_KEY_UP:
+ ami_gui_scroll_internal(gwin, 0, -NSA_KBD_SCROLL_PX);
+ break;
- case GID_RELOAD:
- ami_update_quals(gwin);
+ case NS_KEY_DOWN:
+ ami_gui_scroll_internal(gwin, 0, +NSA_KBD_SCROLL_PX);
+ break;
- if(browser_window_reload_available(gwin->gw->bw))
- {
- if(gwin->key_state & BROWSER_MOUSE_MOD_1)
- {
- browser_window_reload(gwin->gw->bw, true);
- }
- else
- {
- browser_window_reload(gwin->gw->bw, false);
- }
- }
- break;
+ case NS_KEY_LEFT:
+ ami_gui_scroll_internal(gwin, -NSA_KBD_SCROLL_PX, 0);
+ break;
- case GID_BACK:
- ami_gui_history(gwin, true);
- break;
+ case NS_KEY_RIGHT:
+ ami_gui_scroll_internal(gwin, +NSA_KBD_SCROLL_PX, 0);
+ break;
- case GID_FORWARD:
- ami_gui_history(gwin, false);
- break;
+ case NS_KEY_PAGE_UP:
+ ami_gui_scroll_internal(gwin, 0, SCROLL_PAGE_UP);
+ break;
- case GID_FAVE:
- 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);
- } else {
- hotlist_add_url(url);
- }
- nsurl_unref(url);
- }
- ami_gui_update_hotlist_button(gwin);
- break;
+ case NS_KEY_PAGE_DOWN:
+ case ' ':
+ ami_gui_scroll_internal(gwin, 0, SCROLL_PAGE_DOWN);
+ break;
- case GID_HOTLIST:
- default:
-// printf("GADGET: %ld\n",(result & WMHI_GADGETMASK));
- break;
- }
- break;
+ case NS_KEY_LINE_START: // page left
+ ami_gui_scroll_internal(gwin, SCROLL_PAGE_UP, 0);
+ break;
- case WMHI_RAWKEY:
- ami_update_quals(gwin);
-
- storage = result & WMHI_GADGETMASK;
- if(storage >= IECODE_UP_PREFIX) break;
+ case NS_KEY_LINE_END: // page right
+ ami_gui_scroll_internal(gwin, SCROLL_PAGE_DOWN, 0);
+ break;
- GetAttr(WINDOW_InputEvent,gwin->objects[OID_MAIN],(ULONG *)&ie);
+ case NS_KEY_TEXT_START: // home
+ ami_gui_scroll_internal(gwin, SCROLL_TOP, SCROLL_TOP);
+ break;
- nskey = ami_key_to_nskey(storage, ie);
+ case NS_KEY_TEXT_END: // end
+ ami_gui_scroll_internal(gwin, SCROLL_BOTTOM, SCROLL_BOTTOM);
+ break;
- if((ie->ie_Qualifier & IEQUALIFIER_RCOMMAND) &&
- ((31 < nskey) && (nskey < 127))) {
- /* NB: Some keypresses are converted to generic keypresses above
- * rather than being "menu-emulated" here. */
- switch(nskey)
- {
- /* The following aren't available from the menu at the moment */
+ case NS_KEY_WORD_RIGHT: // alt+right
+ ami_change_tab(gwin, 1);
+ break;
- case 'r': // reload
+ case NS_KEY_WORD_LEFT: // alt+left
+ ami_change_tab(gwin, -1);
+ break;
+
+ case NS_KEY_DELETE_LEFT: // backspace
+ ami_gui_history(gwin, true);
+ break;
+
+ /* RawKeys. NB: These are passthrus in ami_key_to_nskey() */
+ case RAWKEY_F5: // reload
if(browser_window_reload_available(gwin->gw->bw))
- browser_window_reload(gwin->gw->bw, false);
+ browser_window_reload(gwin->gw->bw,false);
break;
- case 'u': // open url
- if((nsoption_bool(kiosk_mode) == false))
- ActivateLayoutGadget((struct Gadget *)gwin->objects[GID_MAIN],
- gwin->win, NULL, (uint32)gwin->objects[GID_URL]);
+ case RAWKEY_F8: // scale 100%
+ ami_gui_set_scale(gwin->gw, 1.0);
+ break;
+
+ case RAWKEY_F9: // decrease scale
+ ami_gui_set_scale(gwin->gw, gwin->gw->scale - 0.1);
+ break;
+
+ case RAWKEY_F10: // increase scale
+ ami_gui_set_scale(gwin->gw, gwin->gw->scale + 0.1);
+ break;
+
+ case RAWKEY_HELP: // help
+ ami_help_open(AMI_HELP_GUI, scrn);
break;
}
+ } else if(nskey == NS_KEY_COPY_SELECTION) {
+ /* if we've copied a selection we need to clear it - style guide rules */
+ browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
}
- else
- {
- if(!browser_window_key_press(gwin->gw->bw, nskey))
- {
- switch(nskey)
- {
- case NS_KEY_UP:
- ami_gui_scroll_internal(gwin, 0, -NSA_KBD_SCROLL_PX);
- break;
-
- case NS_KEY_DOWN:
- ami_gui_scroll_internal(gwin, 0, +NSA_KBD_SCROLL_PX);
- break;
-
- case NS_KEY_LEFT:
- ami_gui_scroll_internal(gwin, -NSA_KBD_SCROLL_PX, 0);
- break;
-
- case NS_KEY_RIGHT:
- ami_gui_scroll_internal(gwin, +NSA_KBD_SCROLL_PX, 0);
- break;
-
- case NS_KEY_PAGE_UP:
- ami_gui_scroll_internal(gwin, 0, SCROLL_PAGE_UP);
- break;
-
- case NS_KEY_PAGE_DOWN:
- case ' ':
- ami_gui_scroll_internal(gwin, 0, SCROLL_PAGE_DOWN);
- break;
-
- case NS_KEY_LINE_START: // page left
- ami_gui_scroll_internal(gwin, SCROLL_PAGE_UP, 0);
- break;
-
- case NS_KEY_LINE_END: // page right
- ami_gui_scroll_internal(gwin, SCROLL_PAGE_DOWN, 0);
- break;
-
- case NS_KEY_TEXT_START: // home
- ami_gui_scroll_internal(gwin, SCROLL_TOP, SCROLL_TOP);
- break;
-
- case NS_KEY_TEXT_END: // end
- ami_gui_scroll_internal(gwin, SCROLL_BOTTOM, SCROLL_BOTTOM);
- break;
-
- case NS_KEY_WORD_RIGHT: // alt+right
- ami_change_tab(gwin, 1);
- break;
-
- case NS_KEY_WORD_LEFT: // alt+left
- ami_change_tab(gwin, -1);
- break;
-
- case NS_KEY_DELETE_LEFT: // backspace
- ami_gui_history(gwin, true);
- break;
-
- /* RawKeys. NB: These are passthrus in ami_key_to_nskey() */
- case RAWKEY_F5: // reload
- if(browser_window_reload_available(gwin->gw->bw))
- browser_window_reload(gwin->gw->bw,false);
- break;
-
- case RAWKEY_F8: // scale 100%
- ami_gui_set_scale(gwin->gw, 1.0);
- break;
-
- case RAWKEY_F9: // decrease scale
- ami_gui_set_scale(gwin->gw, gwin->gw->scale - 0.1);
- break;
-
- case RAWKEY_F10: // increase scale
- ami_gui_set_scale(gwin->gw, gwin->gw->scale + 0.1);
- break;
-
- case RAWKEY_HELP: // help
- ami_help_open(AMI_HELP_GUI, scrn);
- break;
- }
- } else if(nskey == NS_KEY_COPY_SELECTION) {
- /* if we've copied a selection we need to clear it - style guide rules */
- browser_window_key_press(gwin->gw->bw, NS_KEY_CLEAR_SELECTION);
- }
- }
- break;
+ }
+ break;
- case WMHI_NEWSIZE:
- ami_set_border_gadget_size(gwin);
- ami_throbber_redraw_schedule(0, gwin->gw);
- ami_schedule(0, ami_gui_refresh_favicon, gwin);
- browser_window_schedule_reformat(gwin->gw->bw);
- break;
+ case WMHI_NEWSIZE:
+ ami_set_border_gadget_size(gwin);
+ ami_throbber_redraw_schedule(0, gwin->gw);
+ ami_schedule(0, ami_gui_refresh_favicon, gwin);
+ browser_window_schedule_reformat(gwin->gw->bw);
+ break;
- case WMHI_CLOSEWINDOW:
- ami_gui_close_window(gwin);
- break;
+ case WMHI_CLOSEWINDOW:
+ ami_gui_close_window(gwin);
+ win_closed = TRUE;
+ break;
#ifdef __amigaos4__
- case WMHI_ICONIFY:
- {
- struct bitmap *bm;
-
- bm = urldb_get_thumbnail(browser_window_get_url(gwin->gw->bw));
- if(!bm) bm = content_get_bitmap(browser_window_get_content(gwin->gw->bw));
- gwin->dobj = amiga_icon_from_bitmap(bm);
- amiga_icon_superimpose_favicon_internal(gwin->gw->favicon,
- gwin->dobj);
- HideWindow(gwin->win);
- gwin->appicon = AddAppIcon((ULONG)gwin->objects[OID_MAIN],
- (ULONG)gwin, gwin->win->Title, appport,
- 0, gwin->dobj, NULL);
-
- cur_gw = NULL;
- }
- break;
+ case WMHI_ICONIFY:
+ {
+ struct bitmap *bm;
+
+ bm = urldb_get_thumbnail(browser_window_get_url(gwin->gw->bw));
+ if(!bm) bm = content_get_bitmap(browser_window_get_content(gwin->gw->bw));
+ gwin->dobj = amiga_icon_from_bitmap(bm);
+ amiga_icon_superimpose_favicon_internal(gwin->gw->favicon,
+ gwin->dobj);
+ HideWindow(gwin->win);
+ gwin->appicon = AddAppIcon((ULONG)gwin->objects[OID_MAIN],
+ (ULONG)gwin, gwin->win->Title, appport,
+ 0, gwin->dobj, NULL);
+
+ cur_gw = NULL;
+ }
+ break;
#endif
- case WMHI_INACTIVE:
- gwin->gw->c_h_temp = gwin->gw->c_h;
- gui_window_remove_caret(gwin->gw);
- break;
-
- case WMHI_ACTIVE:
- if(gwin->gw->bw) cur_gw = gwin->gw;
- if(gwin->gw->c_h_temp)
- gwin->gw->c_h = gwin->gw->c_h_temp;
- break;
+ case WMHI_INACTIVE:
+ gwin->gw->c_h_temp = gwin->gw->c_h;
+ gui_window_remove_caret(gwin->gw);
+ break;
- case WMHI_INTUITICK:
- break;
+ case WMHI_ACTIVE:
+ if(gwin->gw->bw) cur_gw = gwin->gw;
+ if(gwin->gw->c_h_temp)
+ gwin->gw->c_h = gwin->gw->c_h_temp;
+ break;
- default:
- //printf("class: %ld\n",(result & WMHI_CLASSMASK));
- break;
- }
+ case WMHI_INTUITICK:
+ break;
- if(win_destroyed)
- {
- /* we can't be sure what state our window_list is in, so let's
- jump out of the function and start again */
+ default:
+ //printf("class: %ld\n",(result & WMHI_CLASSMASK));
+ break;
+ }
- win_destroyed = false;
- return;
- }
+ if(win_destroyed)
+ {
+ /* we can't be sure what state our window_list is in, so let's
+ jump out of the function and start again */
- if(drag_x_move || drag_y_move)
- {
- gui_window_get_scroll(gwin->gw,
- &gwin->gw->scrollx, &gwin->gw->scrolly);
+ win_destroyed = false;
+ return TRUE;
+ }
- gui_window_set_scroll(gwin->gw,
- gwin->gw->scrollx + drag_x_move,
- gwin->gw->scrolly + drag_y_move);
- }
+ if(drag_x_move || drag_y_move)
+ {
+ gui_window_get_scroll(gwin->gw,
+ &gwin->gw->scrollx, &gwin->gw->scrolly);
-// ReplyMsg((struct Message *)message);
+ gui_window_set_scroll(gwin->gw,
+ gwin->gw->scrollx + drag_x_move,
+ gwin->gw->scrolly + drag_y_move);
}
- } while((node = nnode));
-
- if(ami_menu_window_close)
- {
- if(ami_menu_window_close == (void *)AMI_MENU_WINDOW_CLOSE_ALL)
- ami_quit_netsurf();
- else
- ami_gui_close_window(ami_menu_window_close);
-
- ami_menu_window_close = NULL;
+// ReplyMsg((struct Message *)message);
}
-
- if(ami_menu_check_toggled) {
- ami_gui_menu_update_all();
- ami_menu_check_toggled = false;
+
+ if(gwin->closed == true) {
+ win_closed = TRUE;
+ ami_gui_close_window(gwin);
}
+
+ return win_closed;
}
static void ami_gui_appicon_remove(struct gui_window_2 *gwin)
@@ -2584,7 +2576,7 @@ static void ami_handle_appmsg(void)
{
if((appwinargs = &appmsg->am_ArgList[i]))
{
- if((filename = AllocVecTagList(1024, NULL)))
+ if((filename = malloc(1024)))
{
if(appwinargs->wa_Lock)
{
@@ -2665,7 +2657,7 @@ static void ami_handle_appmsg(void)
}
}
}
- FreeVec(filename);
+ free(filename);
}
}
}
@@ -2775,7 +2767,7 @@ void ami_get_msg(void)
uint32 signalmask = winsignal | appsig | schedulesig | rxsig |
printsig | applibsig | helpsignal;
- if ((fetcher_fdset(&read_fd_set, &write_fd_set, &except_fd_set, &max_fd) == NSERROR_OK) &&
+ if ((fetch_fdset(&read_fd_set, &write_fd_set, &except_fd_set, &max_fd) == NSERROR_OK) &&
(max_fd != -1)) {
/* max_fd is the highest fd in use, but waitselect() needs to know how many
* are in use, so we add 1. */
@@ -2800,7 +2792,7 @@ void ami_get_msg(void)
}
if(signal & winsignal)
- ami_handle_msg();
+ while(ami_handle_msg());
if(signal & appsig)
ami_handle_appmsg();
@@ -2855,7 +2847,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
struct IBox *bbox;
/* Clear the last new tab list */
- gwin->gw->last_new_tab = NULL;
+ gwin->last_new_tab = NULL;
if(gwin->tabs == 0) return;
@@ -2911,34 +2903,24 @@ void ami_quit_netsurf(void)
{
struct nsObject *node;
struct nsObject *nnode;
- struct gui_window_2 *gwin;
+ struct ami_generic_window *w;
+
+ /* Disable the multiple tabs open warning */
+ nsoption_set_bool(tab_close_warn, false);
if(!IsMinListEmpty(window_list)) {
node = (struct nsObject *)GetHead((struct List *)window_list);
do {
nnode=(struct nsObject *)GetSucc((struct Node *)node);
- gwin = node->objstruct;
-
- 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_gui_close_window(gwin);
- break;
-
- case AMINS_GUIOPTSWINDOW:
- ami_gui_opts_close();
- break;
+ w = node->objstruct;
- case AMINS_DLWINDOW:
- ami_download_window_abort((struct gui_download_window *)gwin);
- break;
+ if(w->tbl->close != NULL) {
+ if(node->Type == AMINS_WINDOW) {
+ struct gui_window_2 *gwin = (struct gui_window_2 *)w;
+ ShowWindow(gwin->win, WINDOW_BACKMOST); // do we need this??
+ }
+ w->tbl->close(w);
}
} while((node = nnode));
@@ -2972,7 +2954,6 @@ void ami_quit_netsurf_delayed(void)
free(utf8gadgets);
#endif
if(res == -1) { /* Requester timed out */
- nsoption_set_bool(tab_close_warn, false);
ami_quit_netsurf();
}
}
@@ -2986,6 +2967,9 @@ static void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen, BOOL d
locked_screen = FALSE;
}
+ /* If this is our own screen, wait for visitor windows to close */
+ if(screen_signal == -1) return;
+
if(CloseScreen(scrn) == TRUE) {
if(screen_signal != -1) {
FreeSignal(screen_signal);
@@ -2996,9 +2980,6 @@ static void ami_gui_close_screen(struct Screen *scrn, BOOL locked_screen, BOOL d
}
if(donotwait == TRUE) return;
- /* If this is our own screen, wait for visitor windows to close */
- if(screen_signal == -1) return;
-
ULONG scrnsig = 1 << screen_signal;
LOG("Waiting for visitor windows to close... (signal)");
Wait(scrnsig);
@@ -3060,17 +3041,24 @@ static void gui_quit(void)
FreeStringClass(urlStringClass);
FreeObjList(window_list);
+
+ ami_clipboard_free();
+ ami_gui_resources_free();
+
+ LOG("Closing screen");
+ ami_gui_close_screen(scrn, locked_screen, FALSE);
+ if(nsscreentitle) FreeVec(nsscreentitle);
}
char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail)
{
STRPTR filename = NULL;
- BPTR lock = 0;
if ((filename = ASPrintf("%s/%x", current_user_faviconcache, nsurl_hash(url)))) {
LOG("favicon cache location: %s", filename);
if (only_if_avail == true) {
+ BPTR lock = 0;
if((lock = Lock(filename, ACCESS_READ))) {
UnLock(lock);
return filename;
@@ -3117,7 +3105,8 @@ void ami_gui_update_hotlist_button(struct gui_window_2 *gwin)
}
}
-static bool ami_gui_hotlist_add(void *userdata, int level, int item, const char *title, nsurl *url, bool is_folder)
+static bool ami_gui_hotlist_add(void *userdata, int level, int item,
+ const char *title, nsurl *url, bool is_folder)
{
struct ami_gui_tb_userdata *tb_userdata = (struct ami_gui_tb_userdata *)userdata;
struct Node *speed_button_node;
@@ -3471,6 +3460,19 @@ void ami_gui_set_scale(struct gui_window *gw, float scale)
browser_window_set_scale(gw->bw, scale, true);
}
+void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin)
+{
+ if(nsoption_bool(new_tab_is_active) == true) return;
+
+ /* Switch to the just-opened tab (if new_tab_is_active, we already did!) */
+ RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_TABS],
+ gwin->win, NULL,
+ CLICKTAB_CurrentNode, gwin->last_new_tab,
+ TAG_DONE);
+
+ ami_switch_tab(gwin, false);
+}
+
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
{
nsurl *url;
@@ -3492,6 +3494,8 @@ nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
return error;
}
+ ami_gui_switch_to_new_tab(gwin);
+
return NSERROR_OK;
}
@@ -3756,6 +3760,37 @@ HOOKF(void, ami_scroller_hook, Object *, object, struct IntuiMessage *)
// ReplyMsg((struct Message *)msg);
}
+/* exported function documented in gui.h */
+nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table)
+{
+ struct nsObject *node = AddObject(window_list, type);
+ if(node == NULL) return NSERROR_NOMEM;
+ node->objstruct = win;
+
+ struct ami_generic_window *w = (struct ami_generic_window *)win;
+ w->tbl = table;
+ w->node = node;
+
+ return NSERROR_OK;
+}
+
+/* exported function documented in gui.h */
+void ami_gui_win_list_remove(void *win)
+{
+ struct ami_generic_window *w = (struct ami_generic_window *)win;
+
+ if(w->node->Type == AMINS_TVWINDOW) {
+ DelObjectNoFree(w->node);
+ } else {
+ DelObject(w->node);
+ }
+}
+
+static const struct ami_win_event_table ami_gui_table = {
+ ami_gui_event,
+ ami_gui_close_window,
+};
+
static struct gui_window *
gui_window_create(struct browser_window *bw,
struct gui_window *existing,
@@ -3802,7 +3837,7 @@ gui_window_create(struct browser_window *bw,
if(curh > (scrn->Height - cury)) curh = scrn->Height - cury;
- g = ami_misc_allocvec_clear(sizeof(struct gui_window), 0);
+ g = calloc(1, sizeof(struct gui_window));
if(!g)
{
@@ -3812,7 +3847,7 @@ gui_window_create(struct browser_window *bw,
NewList(&g->dllist);
g->deferred_rects = NewObjList();
- g->deferred_rects_pool = ami_misc_itempool_create(sizeof(struct rect));
+ g->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
g->bw = bw;
g->scale = browser_window_get_scale(bw);
@@ -3842,12 +3877,13 @@ gui_window_create(struct browser_window *bw,
} else {
struct Node *insert_after = existing->tab_node;
- if(existing->last_new_tab)
- insert_after = existing->last_new_tab;
+ if(g->shared->last_new_tab)
+ insert_after = g->shared->last_new_tab;
Insert(&g->shared->tab_list, g->tab_node, insert_after);
- existing->last_new_tab = g->tab_node;
}
+ g->shared->last_new_tab = g->tab_node;
+
RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS],
g->shared->win, NULL,
CLICKTAB_Labels, &g->shared->tab_list,
@@ -3875,7 +3911,7 @@ gui_window_create(struct browser_window *bw,
return g;
}
- g->shared = ami_misc_allocvec_clear(sizeof(struct gui_window_2), 0);
+ g->shared = calloc(1, sizeof(struct gui_window_2));
if(!g->shared)
{
@@ -3938,7 +3974,7 @@ gui_window_create(struct browser_window *bw,
g->shared->tabs=1;
g->shared->next_tab=1;
- g->shared->svbuffer = ami_misc_allocvec_clear(2000, 0);
+ g->shared->svbuffer = calloc(1, 2000);
g->shared->helphints[GID_BACK] =
translate_escape_chars(messages_get("HelpToolbarBack"));
@@ -4218,8 +4254,8 @@ gui_window_create(struct browser_window *bw,
CHILD_WeightedWidth, nsoption_int(web_search_width),
LAYOUT_AddChild, g->shared->objects[GID_THROBBER] = SpaceObj,
GA_ID,GID_THROBBER,
- SPACE_MinWidth,throbber_width,
- SPACE_MinHeight,throbber_height,
+ SPACE_MinWidth, ami_theme_throbber_get_width(),
+ SPACE_MinHeight, ami_theme_throbber_get_height(),
SPACE_Transparent,TRUE,
// SPACE_RenderHook, &g->shared->throbber_hook,
SpaceEnd,
@@ -4330,8 +4366,8 @@ gui_window_create(struct browser_window *bw,
if(!g->shared->win)
{
amiga_warn_user("NoMemory","");
- FreeVec(g->shared);
- FreeVec(g);
+ free(g->shared);
+ free(g);
return NULL;
}
@@ -4394,10 +4430,9 @@ gui_window_create(struct browser_window *bw,
g->shared->appwin = AddAppWindowA((ULONG)g->shared->objects[OID_MAIN],
(ULONG)g->shared, g->shared->win, appport, NULL);
- g->shared->node = AddObject(window_list,AMINS_WINDOW);
- g->shared->node->objstruct = g->shared;
+ ami_gui_win_list_add(g->shared, AMINS_WINDOW, &ami_gui_table);
- glob = &browserglob;
+ ami_gui_set_default_gg();
if(locked_screen) {
UnlockPubScreen(NULL,scrn);
@@ -4443,8 +4478,9 @@ static void ami_gui_close_tabs(struct gui_window_2 *gwin, bool other_tabs)
}
}
-void ami_gui_close_window(struct gui_window_2 *gwin)
+void ami_gui_close_window(void *w)
{
+ struct gui_window_2 *gwin = (struct gui_window_2 *)w;
ami_gui_close_tabs(gwin, false);
}
@@ -4460,7 +4496,7 @@ static void gui_window_destroy(struct gui_window *g)
if(!g) return;
- if(g->shared->searchwin && (g->shared->searchwin->gwin == g))
+ if (ami_search_get_gwin(g->shared->searchwin) == g)
{
ami_search_close();
win_destroyed = true;
@@ -4474,7 +4510,7 @@ static void gui_window_destroy(struct gui_window *g)
ami_free_download_list(&g->dllist);
FreeObjList(g->deferred_rects);
- ami_misc_itempool_delete(g->deferred_rects_pool);
+ ami_memory_itempool_delete(g->deferred_rects_pool);
gui_window_stop_throbber(g);
cur_gw = NULL;
@@ -4509,14 +4545,13 @@ static void gui_window_destroy(struct gui_window *g)
if((g->shared->tabs == 1) && (nsoption_bool(tab_always_show) == false))
ami_toggletabbar(g->shared, false);
- ami_utf8_free(g->tabtitle);
-
- FreeVec(g);
+ if(g->tabtitle) free(g->tabtitle);
+ free(g);
return;
}
ami_plot_release_pens(g->shared->shared_pens);
- FreeVec(g->shared->shared_pens);
+ free(g->shared->shared_pens);
ami_schedule_redraw_remove(g->shared);
ami_schedule(-1, ami_gui_refresh_favicon, g->shared);
@@ -4546,17 +4581,18 @@ static void gui_window_destroy(struct gui_window *g)
free(g->shared->wintitle);
ami_utf8_free(g->shared->status);
- FreeVec(g->shared->svbuffer);
+ free(g->shared->svbuffer);
for(gid = 0; gid < GID_LAST; gid++)
free(g->shared->helphints[gid]);
- DelObject(g->shared->node);
+ ami_gui_win_list_remove(g->shared);
if(g->tab_node) {
Remove(g->tab_node);
FreeClickTabNode(g->tab_node);
}
- FreeVec(g); // g->shared should be freed by DelObject()
+ if(g->tabtitle) free(g->tabtitle);
+ free(g); // g->shared should be freed by DelObject()
if(IsMinListEmpty(window_list))
{
@@ -4567,18 +4603,17 @@ static void gui_window_destroy(struct gui_window *g)
win_destroyed = true;
}
-static void gui_window_set_title(struct gui_window *g, const char *title)
+static void gui_window_set_title(struct gui_window *g, const char *restrict title)
{
struct Node *node;
- char *utf8title;
+ char *restrict utf8title;
if(!g) return;
if(!title) return;
utf8title = ami_utf8_easy((char *)title);
- if(g->tab_node) // && (g->shared->tabs > 1))
- {
+ if(g->tab_node) {
node = g->tab_node;
if((g->tabtitle == NULL) || (strcmp(utf8title, g->tabtitle)))
@@ -4588,7 +4623,7 @@ static void gui_window_set_title(struct gui_window *g, const char *title)
CLICKTAB_Labels, ~0,
TAG_DONE);
- if(g->tabtitle) ami_utf8_free(g->tabtitle);
+ if(g->tabtitle) free(g->tabtitle);
g->tabtitle = strdup(utf8title);
SetClickTabNodeAttrs(node, TNA_Text, g->tabtitle,
@@ -4687,7 +4722,7 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
rect->x0, rect->y0, rect->x1, rect->y1);
}
nnode=(struct nsObject *)GetSucc((struct Node *)node);
- ami_misc_itempool_free(g->deferred_rects_pool, node->objstruct, sizeof(struct rect));
+ ami_memory_itempool_free(g->deferred_rects_pool, node->objstruct, sizeof(struct rect));
DelObjectNoFree(node);
} while((node = nnode));
@@ -4695,11 +4730,11 @@ static void ami_gui_window_update_box_deferred(struct gui_window *g, bool draw)
}
static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_rects,
- const struct rect *new_rect, APTR mempool)
+ const struct rect *restrict new_rect, APTR mempool)
{
struct nsObject *node;
struct nsObject *nnode;
- struct rect *rect;
+ struct rect *restrict rect;
if(IsMinListEmpty(deferred_rects)) return true;
@@ -4721,7 +4756,7 @@ static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_re
(new_rect->x1 >= rect->x1) &&
(new_rect->y1 >= rect->y1)) {
LOG("Removing queued redraw that is a subset of new box redraw");
- ami_misc_itempool_free(mempool, node->objstruct, sizeof(struct rect));
+ ami_memory_itempool_free(mempool, node->objstruct, sizeof(struct rect));
DelObjectNoFree(node);
/* Don't return - we might find more */
}
@@ -4730,15 +4765,15 @@ static bool ami_gui_window_update_box_deferred_check(struct MinList *deferred_re
return true;
}
-static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *g, const struct rect *restrict rect)
{
struct nsObject *nsobj;
- struct rect *deferred_rect;
+ struct rect *restrict deferred_rect;
if(!g) return;
if(ami_gui_window_update_box_deferred_check(g->deferred_rects, rect,
g->deferred_rects_pool)) {
- deferred_rect = ami_misc_itempool_alloc(g->deferred_rects_pool, sizeof(struct rect));
+ deferred_rect = ami_memory_itempool_alloc(g->deferred_rects_pool, sizeof(struct rect));
CopyMem(rect, deferred_rect, sizeof(struct rect));
nsobj = AddObject(g->deferred_rects, AMINS_RECT);
nsobj->objstruct = deferred_rect;
@@ -4849,7 +4884,7 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
.plot = &amiplot
};
- glob = &browserglob;
+ ami_gui_set_default_gg();
if(nsoption_bool(direct_render) == false)
{
@@ -4914,7 +4949,7 @@ void ami_get_vscroll_pos(struct gui_window_2 *gwin, ULONG *ys)
*ys /= gwin->gw->scale;
}
-static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
+static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy)
{
ami_get_hscroll_pos(g->shared, (ULONG *)sx);
ami_get_vscroll_pos(g->shared, (ULONG *)sy);
@@ -5215,7 +5250,7 @@ static void gui_window_remove_caret(struct gui_window *g)
static void gui_window_new_content(struct gui_window *g)
{
- hlcache_handle *c;
+ struct hlcache_handle *c;
if(g && g->shared && g->bw && browser_window_has_content(g->bw))
c = browser_window_get_content(g->bw);
@@ -5248,7 +5283,7 @@ static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
if(g->shared->ptr_lock)
{
- FreeVec(g->shared->ptr_lock);
+ free(g->shared->ptr_lock);
g->shared->ptr_lock = NULL;
}
}
@@ -5259,7 +5294,7 @@ static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
/* return the text box at posn x,y in window coordinates
x,y are updated to be document co-ordinates */
-bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y)
+bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *restrict x, ULONG *restrict y)
{
struct IBox *bbox;
ULONG xs, ys;
@@ -5304,11 +5339,10 @@ BOOL ami_gadget_hit(Object *obj, int x, int y)
Object *ami_gui_splash_open(void)
{
- Object *win_obj, *bm_obj;
+ Object *restrict win_obj, *restrict bm_obj;
struct Window *win;
struct Screen *wbscreen = LockPubScreen("Workbench");
uint32 top = 0, left = 0;
- STRPTR ver_string;
struct TextAttr tattr;
struct TextFont *tfont;
@@ -5330,9 +5364,24 @@ Object *ami_gui_splash_open(void)
LayoutEnd,
EndWindow;
+ if(win_obj == NULL) {
+ LOG("Splash window object not created");
+ return NULL;
+ }
+
LOG("Attempting to open splash window...");
win = RA_OpenWindow(win_obj);
+ if(win == NULL) {
+ LOG("Splash window did not open");
+ return NULL;
+ }
+
+ if(bm_obj == NULL) {
+ LOG("BitMap object not created");
+ return NULL;
+ }
+
GetAttrs(bm_obj, IA_Top, &top,
IA_Left, &left,
TAG_DONE);
@@ -5377,12 +5426,9 @@ Object *ami_gui_splash_open(void)
if((tfont = ami_font_open_disk_font(&tattr)))
SetFont(win->RPort, tfont);
- ver_string = ASPrintf("%s", netsurf_version);
-
Move(win->RPort, left + 185, top + 220);
- Text(win->RPort, ver_string, strlen(ver_string));
+ Text(win->RPort, netsurf_version, strlen(netsurf_version));
- if(ver_string) FreeVec(ver_string);
if(tfont) ami_font_close_disk_font(tfont);
UnlockPubScreen(NULL, wbscreen);
@@ -5398,7 +5444,7 @@ void ami_gui_splash_close(Object *win_obj)
DisposeObject(win_obj);
}
-static void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
+static void gui_file_gadget_open(struct gui_window *g, struct hlcache_handle *hl,
struct form_control *gadget)
{
LOG("File open dialog request for %p/%p", g, gadget);
@@ -5423,6 +5469,84 @@ uint32 ami_gui_get_app_id(void)
return ami_appid;
}
+/* Get current user directory for user-specific NetSurf data
+ * Returns NULL on error
+ */
+static char *ami_gui_get_user_dir(STRPTR current_user)
+{
+ BPTR lock = 0;
+ char temp[1024];
+ int32 user = 0;
+
+ if(current_user == NULL) {
+ user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
+ current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
+ }
+ LOG("User: %s", current_user);
+
+ if(users_dir == NULL) {
+ users_dir = ASPrintf("%s", USERS_DIR);
+ if(users_dir == NULL) {
+ ami_misc_fatal_error("Failed to allocate memory");
+ FreeVec(current_user);
+ return NULL;
+ }
+ }
+
+ if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
+#ifdef __amigaos4__
+ struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
+ if(infodata == NULL) {
+ ami_misc_fatal_error("Failed to allocate memory");
+ FreeVec(current_user);
+ return NULL;
+ }
+ GetDiskInfoTags(GDI_StringNameInput, users_dir,
+ GDI_InfoData, infodata,
+ TAG_DONE);
+ if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
+ FreeDosObject(DOS_INFODATA, infodata);
+ ami_misc_fatal_error("User directory MUST be on a writeable volume");
+ FreeVec(current_user);
+ return NULL;
+ }
+ FreeDosObject(DOS_INFODATA, infodata);
+#else
+#warning FIXME for OS3 and older OS4
+#endif
+ } else {
+//TODO: check volume write status using old API
+ }
+
+ int len = strlen(current_user);
+ len += strlen(users_dir);
+ len += 2; /* for poss path sep and NULL term */
+
+ current_user_dir = malloc(len);
+ if(current_user_dir == NULL) {
+ ami_misc_fatal_error("Failed to allocate memory");
+ FreeVec(current_user);
+ return NULL;
+ }
+
+ strlcpy(current_user_dir, users_dir, len);
+ AddPart(current_user_dir, current_user, len);
+ FreeVec(users_dir);
+ FreeVec(current_user);
+
+ LOG("User dir: %s", current_user_dir);
+
+ if((lock = CreateDirTree(current_user_dir)))
+ UnLock(lock);
+
+ ami_nsoption_set_location(current_user_dir);
+
+ current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
+ if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
+
+ return current_user_dir;
+}
+
static struct gui_window_table amiga_window_table = {
.create = gui_window_create,
.destroy = gui_window_destroy,
@@ -5486,8 +5610,8 @@ int main(int argc, char** argv)
char script[1024];
char temp[1024];
STRPTR current_user_cache = NULL;
+ STRPTR current_user = NULL;
BPTR lock = 0;
- int32 user = 0;
nserror ret;
int nargc = 0;
char *nargv = NULL;
@@ -5529,99 +5653,29 @@ int main(int argc, char** argv)
/* Open splash window */
Object *splash_window = ami_gui_splash_open();
- ami_object_init();
+#ifndef __amigaos4__
+ /* OS3 low memory handler */
+ struct Interupt *memhandler = ami_memory_init();
+#endif
- if (ami_open_resources() == false) { /* alloc message ports */
+ if (ami_gui_resources_open() == false) { /* alloc msgports, objects and other miscelleny */
ami_misc_fatal_error("Unable to allocate resources");
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
}
- if(ami_schedule_create(schedulermsgport) != NSERROR_OK) {
- ami_misc_fatal_error("Failed to initialise scheduler");
- ami_gui_splash_close(splash_window);
- ami_libs_close();
- return RETURN_FAIL;
- }
-
- ami_gui_read_all_tooltypes(argc, argv);
+ current_user = ami_gui_read_all_tooltypes(argc, argv);
struct RDArgs *args = ami_gui_commandline(&argc, argv, &nargc, &nargv);
- if(current_user == NULL) {
- user = GetVar("user", temp, 1024, GVF_GLOBAL_ONLY);
- current_user = ASPrintf("%s", (user == -1) ? "Default" : temp);
- }
- LOG("User: %s", current_user);
-
- if(users_dir == NULL) {
- users_dir = ASPrintf("%s", USERS_DIR);
- if(users_dir == NULL) {
- ami_misc_fatal_error("Failed to allocate memory");
- ami_schedule_free();
- ami_gui_splash_close(splash_window);
- ami_libs_close();
- return RETURN_FAIL;
- }
- }
-
- if(LIB_IS_AT_LEAST((struct Library *)DOSBase, 51, 96)) {
-#ifdef __amigaos4__
- struct InfoData *infodata = AllocDosObject(DOS_INFODATA, 0);
- if(infodata == NULL) {
- ami_misc_fatal_error("Failed to allocate memory");
- ami_schedule_free();
- ami_gui_splash_close(splash_window);
- ami_libs_close();
- return RETURN_FAIL;
- }
- GetDiskInfoTags(GDI_StringNameInput, users_dir,
- GDI_InfoData, infodata,
- TAG_DONE);
- if(infodata->id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) {
- FreeDosObject(DOS_INFODATA, infodata);
- ami_misc_fatal_error("User directory MUST be on a writeable volume");
- ami_schedule_free();
- ami_gui_splash_close(splash_window);
- ami_libs_close();
- return RETURN_FAIL;
- }
- FreeDosObject(DOS_INFODATA, infodata);
-#else
-#warning FIXME for OS3 and older OS4
-#endif
- } else {
-//TODO: check volume write status using old API
- }
-
- int len = strlen(current_user);
- len += strlen(users_dir);
- len += 2; /* for poss path sep and NULL term */
-
- current_user_dir = AllocVecTagList(len, NULL);
+ current_user_dir = ami_gui_get_user_dir(current_user);
if(current_user_dir == NULL) {
- ami_misc_fatal_error("Failed to allocate memory");
- ami_schedule_free();
+ ami_gui_resources_free();
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
}
- strlcpy(current_user_dir, users_dir, len);
- AddPart(current_user_dir, current_user, len);
- FreeVec(users_dir);
- LOG("User dir: %s", current_user_dir);
-
- if((lock = CreateDirTree(current_user_dir)))
- UnLock(lock);
-
- current_user_options = ASPrintf("%s/Choices", current_user_dir);
- current_user_cache = ASPrintf("%s/Cache", current_user_dir);
- current_user_faviconcache = ASPrintf("%s/IconCache", current_user_dir);
-
- if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
- if((lock = CreateDirTree(current_user_faviconcache))) UnLock(lock);
-
ami_mime_init("PROGDIR:Resources/mimetypes");
sprintf(temp, "%s/mimetypes.user", current_user_dir);
ami_mime_init(temp);
@@ -5639,12 +5693,12 @@ int main(int argc, char** argv)
ret = nsoption_init(ami_set_options, &nsoptions, &nsoptions_default);
if (ret != NSERROR_OK) {
ami_misc_fatal_error("Options failed to initialise");
- ami_schedule_free();
+ ami_gui_resources_free();
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
}
- nsoption_read(current_user_options, NULL);
+ ami_nsoption_read();
if(args != NULL) {
nsoption_commandline(&nargc, &nargv, NULL);
FreeArgs(args);
@@ -5652,7 +5706,9 @@ int main(int argc, char** argv)
if (ami_locate_resource(messages, "Messages") == false) {
ami_misc_fatal_error("Cannot open Messages file");
- ami_schedule_free();
+ ami_nsoption_free();
+ nsoption_finalise(nsoptions, nsoptions_default);
+ ami_gui_resources_free();
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
@@ -5660,16 +5716,23 @@ int main(int argc, char** argv)
ret = messages_add_from_file(messages);
+ current_user_cache = ASPrintf("%s/Cache", current_user_dir);
+ if((lock = CreateDirTree(current_user_cache))) UnLock(lock);
+
ret = netsurf_init(current_user_cache);
+
+ if(current_user_cache != NULL) FreeVec(current_user_cache);
+
if (ret != NSERROR_OK) {
ami_misc_fatal_error("NetSurf failed to initialise");
- ami_schedule_free();
+ ami_nsoption_free();
+ nsoption_finalise(nsoptions, nsoptions_default);
+ ami_gui_resources_free();
ami_gui_splash_close(splash_window);
ami_libs_close();
return RETURN_FAIL;
}
- if(current_user_cache != NULL) FreeVec(current_user_cache);
ret = amiga_icon_init();
search_web_init(nsoption_charp(search_engines_file));
@@ -5714,25 +5777,17 @@ int main(int argc, char** argv)
netsurf_exit();
- FreeVec(current_user_options);
- FreeVec(current_user_dir);
+ nsoption_finalise(nsoptions, nsoptions_default);
+ ami_nsoption_free();
+ free(current_user_dir);
FreeVec(current_user_faviconcache);
- FreeVec(current_user);
-
- ami_clipboard_free();
- ami_schedule_free();
- FreeSysObject(ASOT_PORT, appport);
- FreeSysObject(ASOT_PORT, sport);
- FreeSysObject(ASOT_PORT, schedulermsgport);
+#ifndef __amigaos4__
+ /* OS3 low memory handler */
+ ami_memory_fini(memhandler);
+#endif
- ami_object_fini();
ami_bitmap_fini();
-
- LOG("Closing screen");
- ami_gui_close_screen(scrn, locked_screen, FALSE);
- if(nsscreentitle) FreeVec(nsscreentitle);
-
ami_libs_close();
return RETURN_OK;
diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h
index d301ac5..eb39e9e 100644
--- a/frontends/amiga/gui.h
+++ b/frontends/amiga/gui.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2015 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2016 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -25,13 +25,12 @@
#include <dos/dos.h>
#include <devices/inputevent.h>
-#include "desktop/gui_window.h"
-#include "desktop/mouse.h"
+#include "netsurf/window.h"
+#include "netsurf/mouse.h"
#include "amiga/menu.h"
#include "amiga/object.h"
#include "amiga/os3support.h"
-#include "amiga/plotters.h"
#ifdef __amigaos4__
#define HOOKF(ret,func,type,ptr,msgtype) static ret func(struct Hook *hook, type ptr, msgtype msg)
@@ -92,16 +91,36 @@ struct history_window;
#define AMI_GUI_TOOLBAR_MAX 20
-struct gui_window_2 {
+struct ami_win_event_table {
+ /* callback to handle events when using a shared msgport
+ *
+ * @param pointer to our window structure (must start with ami_generic_window)
+ * @return TRUE if window was destroyed during event processing
+ */
+ BOOL (*event)(void *w);
+
+ /* callback for explicit window closure
+ * some windows are implicitly closed by the browser and should set this to NULL
+ */
+ void (*close)(void *w);
+};
+
+struct ami_generic_window {
struct nsObject *node;
+ const struct ami_win_event_table *tbl;
+};
+
+struct gui_window_2 {
+ struct ami_generic_window w;
struct Window *win;
- Object *objects[GID_LAST];
+ Object *restrict objects[GID_LAST];
struct gui_window *gw; /* currently-displayed gui_window */
bool redraw_required;
int throbber_frame;
struct List tab_list;
ULONG tabs;
ULONG next_tab;
+ struct Node *last_new_tab;
struct Hook scrollerhook;
struct form_control *control;
browser_mouse_state mouse_state;
@@ -113,22 +132,22 @@ struct gui_window_2 {
int temp;
bool redraw_scroll;
bool new_content;
- char *menulab[AMI_MENU_AREXX_MAX + 1];
- Object *menuobj[AMI_MENU_AREXX_MAX + 1];
+ char *restrict menulab[AMI_MENU_AREXX_MAX + 1];
+ Object *restrict menuobj[AMI_MENU_AREXX_MAX + 1];
char menukey[AMI_MENU_AREXX_MAX + 1];
- char *menuicon[AMI_MENU_AREXX_MAX + 1];
+ char *restrict menuicon[AMI_MENU_AREXX_MAX + 1];
struct Hook menu_hook[AMI_MENU_AREXX_MAX + 1];
UBYTE *menutype;
struct NewMenu *menu;
ULONG hotlist_items;
- Object *hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
+ Object *restrict hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
struct List hotlist_toolbar_list;
struct List *web_search_list;
Object *search_bm;
- char *svbuffer;
- char *status;
- char *wintitle;
- char *helphints[GID_LAST];
+ char *restrict svbuffer;
+ char *restrict status;
+ char *restrict wintitle;
+ char *restrict helphints[GID_LAST];
browser_mouse_state prev_mouse_state;
struct timeval lastclick;
struct AppIcon *appicon; /* iconify appicon */
@@ -136,8 +155,8 @@ struct gui_window_2 {
struct Hook favicon_hook;
struct Hook throbber_hook;
struct Hook *ctxmenu_hook;
- Object *history_ctxmenu[2];
- Object *clicktab_ctxmenu;
+ Object *restrict history_ctxmenu[2];
+ Object *restrict clicktab_ctxmenu;
gui_drag_type drag_op;
struct IBox *ptr_lock;
struct AppWindow *appwin;
@@ -145,6 +164,7 @@ struct gui_window_2 {
gui_pointer_shape mouse_pointer;
struct Menu *imenu; /* Intuition menu */
struct VisualInfo *vi; /* For GadTools menu */
+ bool closed; /* Window has been closed (via menu) */
};
struct gui_window
@@ -152,7 +172,6 @@ struct gui_window
struct gui_window_2 *shared;
int tab;
struct Node *tab_node;
- struct Node *last_new_tab;
int c_x; /* Caret X posn */
int c_y; /* Caret Y posn */
int c_w; /* Caret width */
@@ -171,14 +190,23 @@ struct gui_window
float scale;
};
+extern struct MinList *window_list; /**\todo stop arexx.c poking about in here */
+extern struct Screen *scrn;
+extern struct MsgPort *sport;
+extern struct gui_window *cur_gw;
+
+/* The return value for these functions must be deallocated using FreeVec() */
+STRPTR ami_locale_langs(int *codeset);
+char *ami_gui_get_cache_favicon_name(struct nsurl *url, bool only_if_avail);
+
+/* Functions lacking documentation */
void ami_get_msg(void);
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);
int ami_key_to_nskey(ULONG keycode, struct InputEvent *ie);
-bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *x, ULONG *y);
-bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *x, int *y,
+bool ami_text_box_at_point(struct gui_window_2 *gwin, ULONG *restrict x, ULONG *restrict y);
+bool ami_mouse_to_ns_coords(struct gui_window_2 *gwin, int *restrict x, int *restrict y,
int mouse_x, int mouse_y);
BOOL ami_gadget_hit(Object *obj, int x, int y);
void ami_gui_history(struct gui_window_2 *gwin, bool back);
@@ -187,7 +215,6 @@ void ami_gui_tabs_toggle_all(void);
bool ami_locate_resource(char *fullpath, const char *file);
void ami_gui_update_hotlist_button(struct gui_window_2 *gwin);
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin);
-char *ami_gui_get_cache_favicon_name(struct nsurl *url, bool only_if_avail);
int ami_gui_count_windows(int window, int *tabs);
void ami_gui_set_scale(struct gui_window *gw, float scale);
@@ -195,9 +222,9 @@ void ami_gui_set_scale(struct gui_window *gw, float scale);
/**
* Close a window and all tabs attached to it.
*
- * @param gwin gui_window_2 to act upon.
+ * @param w gui_window_2 to act upon.
*/
-void ami_gui_close_window(struct gui_window_2 *gwin);
+void ami_gui_close_window(void *w);
/**
* Close all tabs in a window except the active one.
@@ -236,11 +263,24 @@ uint32 ami_gui_get_app_id(void);
*/
STRPTR ami_gui_get_screen_title(void);
-struct MinList *window_list;
-struct Screen *scrn;
-struct MsgPort *sport;
-struct gui_window *cur_gw;
-struct gui_globals browserglob;
-BOOL ami_autoscroll;
+/**
+ * Set gui_globals back to the default for the browser context
+ */
+void ami_gui_set_default_gg(void);
+
+/**
+ * Switch to the most-recently-opened tab
+ */
+void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin);
+
+/**
+ * Add a window to the NetSurf window list (to enable event processing)
+ */
+nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table);
+
+/**
+ * Remove a window from the NetSurf window list
+ */
+void ami_gui_win_list_remove(void *win);
#endif
diff --git a/frontends/amiga/gui_options.c b/frontends/amiga/gui_options.c
index 221b0da..698735b 100755
--- a/frontends/amiga/gui_options.c
+++ b/frontends/amiga/gui_options.c
@@ -20,6 +20,7 @@
#include <string.h>
#include <stdlib.h>
#include <proto/exec.h>
+#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/utility.h>
#ifdef __amigaos4__
@@ -61,9 +62,9 @@
#include "utils/nsurl.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#include "desktop/searchweb.h"
-#include "desktop/gui_window.h"
+#include "netsurf/window.h"
#include "amiga/file.h"
#include "amiga/font.h"
@@ -72,11 +73,12 @@
#include "amiga/gui_options.h"
#include "amiga/help.h"
#include "amiga/libs.h"
-#include "amiga/misc.h"
+#include "amiga/nsoption.h"
#include "amiga/object.h"
#include "amiga/selectmenu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
+#include "amiga/plotters.h"
enum
{
@@ -218,7 +220,7 @@ enum {
};
struct ami_gui_opts_window {
- struct nsObject *node;
+ struct ami_generic_window w;
struct Window *win;
Object *objects[GID_OPTS_LAST];
#ifndef __amigaos4__
@@ -231,16 +233,24 @@ struct ami_gui_opts_window {
#endif
};
+static BOOL ami_gui_opts_event(void *w);
+static void ami_gui_opts_close(void *w);
+
+static const struct ami_win_event_table ami_guiopts_table = {
+ ami_gui_opts_event,
+ ami_gui_opts_close,
+};
+
static struct ami_gui_opts_window *gow = NULL;
-CONST_STRPTR tabs[OPTS_MAX_TABS];
+static CONST_STRPTR tabs[OPTS_MAX_TABS];
static STRPTR screenopts[OPTS_MAX_SCREEN];
-CONST_STRPTR proxyopts[OPTS_MAX_PROXY];
-CONST_STRPTR nativebmopts[OPTS_MAX_NATIVEBM];
-CONST_STRPTR ditheropts[OPTS_MAX_DITHER];
-CONST_STRPTR fontopts[6];
-CONST_STRPTR gadlab[OPTS_LAST];
-struct List *websearch_list;
+static CONST_STRPTR proxyopts[OPTS_MAX_PROXY];
+static CONST_STRPTR nativebmopts[OPTS_MAX_NATIVEBM];
+static CONST_STRPTR ditheropts[OPTS_MAX_DITHER];
+static CONST_STRPTR fontopts[6];
+static CONST_STRPTR gadlab[OPTS_LAST];
+static struct List *websearch_list;
#ifndef __amigaos4__
static void ami_gui_opts_array_to_list(struct List *list, const char *array[], int type)
@@ -633,7 +643,7 @@ void ami_gui_opts_open(void)
if(!gow)
{
- gow = ami_misc_allocvec_clear(sizeof(struct ami_gui_opts_window), 0);
+ gow = calloc(1, sizeof(struct ami_gui_opts_window));
if(gow == NULL) return;
ami_gui_opts_setup(gow);
@@ -1665,8 +1675,7 @@ void ami_gui_opts_open(void)
EndWindow;
gow->win = (struct Window *)RA_OpenWindow(gow->objects[OID_MAIN]);
- gow->node = AddObject(window_list,AMINS_GUIOPTSWINDOW);
- gow->node->objstruct = gow;
+ ami_gui_win_list_add(gow, AMINS_GUIOPTSWINDOW, &ami_guiopts_table);
}
ami_utf8_free(homepage_url_lc);
}
@@ -2053,24 +2062,23 @@ static void ami_gui_opts_use(bool save)
}
if(save == true) {
- nsoption_write(current_user_options, NULL, NULL);
+ ami_nsoption_write();
ami_font_savescanner(); /* just in case it has changed and been used only */
}
- ami_menu_check_toggled = true;
-
+ ami_menu_set_check_toggled();
ami_update_pointer(gow->win, GUI_POINTER_DEFAULT);
}
-void ami_gui_opts_close(void)
+static void ami_gui_opts_close(void *w)
{
DisposeObject(gow->objects[OID_MAIN]);
ami_gui_opts_free(gow);
- DelObject(gow->node);
+ ami_gui_win_list_remove(gow);
gow = NULL;
}
-BOOL ami_gui_opts_event(void)
+static BOOL ami_gui_opts_event(void *w)
{
/* return TRUE if window destroyed */
ULONG result,data = 0;
@@ -2082,7 +2090,7 @@ BOOL ami_gui_opts_event(void)
switch(result & WMHI_CLASSMASK) // class
{
case WMHI_CLOSEWINDOW:
- ami_gui_opts_close();
+ ami_gui_opts_close(gow);
return TRUE;
break;
@@ -2101,7 +2109,7 @@ BOOL ami_gui_opts_event(void)
{
case GID_OPTS_SAVE:
ami_gui_opts_use(true);
- ami_gui_opts_close();
+ ami_gui_opts_close(gow);
return TRUE;
break;
@@ -2110,7 +2118,7 @@ BOOL ami_gui_opts_event(void)
// fall through
case GID_OPTS_CANCEL:
- ami_gui_opts_close();
+ ami_gui_opts_close(gow);
return TRUE;
break;
@@ -2136,7 +2144,7 @@ BOOL ami_gui_opts_event(void)
RefreshSetGadgetAttrs((struct Gadget *)gow->objects[GID_OPTS_CONTENTLANG],
gow->win, NULL, GA_Disabled, code, TAG_DONE);
- if(code && (text = ami_locale_langs()))
+ if(code && (text = ami_locale_langs(NULL)))
{
RefreshSetGadgetAttrs((struct Gadget *)gow->objects[GID_OPTS_CONTENTLANG],
gow->win, NULL, STRINGA_TextVal, text, TAG_DONE);
@@ -2282,7 +2290,7 @@ struct List *ami_gui_opts_websearch(void)
const char *name;
int iter;
- list = AllocVecTagList(sizeof(struct List), NULL);
+ list = malloc(sizeof(struct List));
NewList(list);
if (nsoption_charp(search_engines_file) == NULL) return list;
@@ -2302,6 +2310,7 @@ void ami_gui_opts_websearch_free(struct List *websearchlist)
struct Node *node;
struct Node *nnode;
+ if(websearchlist == NULL) return;
if(IsListEmpty(websearchlist)) return;
node = GetHead(websearchlist);
@@ -2311,6 +2320,6 @@ void ami_gui_opts_websearch_free(struct List *websearchlist)
FreeChooserNode(node);
} while((node = nnode));
- FreeVec(websearchlist);
+ free(websearchlist);
}
diff --git a/frontends/amiga/gui_options.h b/frontends/amiga/gui_options.h
index 04c1be5..7de35cc 100755
--- a/frontends/amiga/gui_options.h
+++ b/frontends/amiga/gui_options.h
@@ -20,13 +20,9 @@
#define AMIGA_GUI_OPTIONS_H
/* Prefs GUI control */
void ami_gui_opts_open(void);
-BOOL ami_gui_opts_event(void);
-void ami_gui_opts_close(void);
/* Web search list */
struct List *ami_gui_opts_websearch(void);
void ami_gui_opts_websearch_free(struct List *websearchlist);
-
-char *current_user_options;
#endif
diff --git a/frontends/amiga/help.c b/frontends/amiga/help.c
index 64b3384..fe1f124 100755
--- a/frontends/amiga/help.c
+++ b/frontends/amiga/help.c
@@ -23,8 +23,8 @@
/* AmigaGuide class */
#include "amiga/agclass/amigaguide_class.h"
-Class *AmigaGuideClass = NULL;
-Object *AmigaGuideObject = NULL;
+static Class *AmigaGuideClass = NULL;
+static Object *AmigaGuideObject = NULL;
/* This array needs to match the enum in help.h */
CONST_STRPTR context_nodes[] = {
diff --git a/frontends/amiga/history.c b/frontends/amiga/history.c
index 72b69d4..2287c70 100755
--- a/frontends/amiga/history.c
+++ b/frontends/amiga/history.c
@@ -20,13 +20,15 @@
#include <proto/exec.h>
#include "utils/errors.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
#include "amiga/history.h"
#include "amiga/tree.h"
#include "amiga/tree.h"
+struct treeview_window *global_history_window = NULL;
+
void ami_global_history_initialise(void)
{
global_history_window = ami_tree_create(TREE_HISTORY, NULL);
diff --git a/frontends/amiga/history.h b/frontends/amiga/history.h
index 1f06474..47e00ed 100755
--- a/frontends/amiga/history.h
+++ b/frontends/amiga/history.h
@@ -18,12 +18,12 @@
#ifndef AMIGA_HISTORY_H
#define AMIGA_HISTORY_H
-#include "desktop/tree.h"
+#include "amiga/desktop-tree.h"
#define GLOBAL_HISTORY_RECENT_URLS 16
void ami_global_history_initialise(void);
void ami_global_history_free(void);
-struct treeview_window *global_history_window;
+extern struct treeview_window *global_history_window;
#endif
diff --git a/frontends/amiga/history_local.c b/frontends/amiga/history_local.c
index 3016cbf..3d1c6f3 100755
--- a/frontends/amiga/history_local.c
+++ b/frontends/amiga/history_local.c
@@ -45,20 +45,37 @@
#include "utils/utils.h"
#include "utils/messages.h"
#include "desktop/browser_history.h"
-#include "desktop/browser.h"
-#include "desktop/plotters.h"
-#include "desktop/gui_window.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/plotters.h"
+#include "netsurf/window.h"
#include "graphics/rpattr.h"
#include "amiga/libs.h"
#include "amiga/misc.h"
#include "amiga/object.h"
+#include "amiga/plotters.h"
#include "amiga/gui.h"
#include "amiga/history_local.h"
-void ami_history_update_extent(struct history_window *hw);
+struct history_window {
+ struct ami_generic_window w;
+ struct Window *win;
+ Object *objects[GID_LAST];
+ struct gui_window *gw;
+ struct Hook scrollerhook;
+ struct gui_globals *gg;
+};
+
+static void ami_history_update_extent(struct history_window *hw);
HOOKF(void, ami_history_scroller_hook, Object *, object, struct IntuiMessage *);
+static BOOL ami_history_event(void *w);
+
+static const struct ami_win_event_table ami_localhistory_table = {
+ ami_history_event,
+ NULL, /* we don't explicitly close the local history window on quit */
+};
+
/**
* Redraw history window.
*/
@@ -80,7 +97,7 @@ static void ami_history_redraw(struct history_window *hw)
return;
}
- glob = &hw->gg;
+ glob = hw->gg;
SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE);
RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1);
@@ -88,12 +105,12 @@ static void ami_history_redraw(struct history_window *hw)
browser_window_history_redraw_rectangle(hw->gw->bw, xs, ys,
bbox->Width + xs, bbox->Height + ys, 0, 0, &ctx);
- glob = &browserglob;
+ ami_gui_set_default_gg();
- ami_clearclipreg(&hw->gg);
+ ami_clearclipreg(hw->gg);
ami_history_update_extent(hw);
- BltBitMapRastPort(hw->gg.bm, 0, 0, hw->win->RPort,
+ BltBitMapRastPort(hw->gg->bm, 0, 0, hw->win->RPort,
bbox->Left, bbox->Top, bbox->Width, bbox->Height, 0x0C0);
ami_gui_free_space_box(bbox);
@@ -115,9 +132,10 @@ void ami_history_open(struct gui_window *gw)
if(!gw->hw)
{
- gw->hw = ami_misc_allocvec_clear(sizeof(struct history_window), 0);
+ gw->hw = calloc(1, sizeof(struct history_window));
+ gw->hw->gg = calloc(1, sizeof(struct gui_globals));
- ami_init_layers(&gw->hw->gg, scrn->Width, scrn->Height, false);
+ ami_init_layers(gw->hw->gg, scrn->Width, scrn->Height, false);
gw->hw->gw = gw;
browser_window_history_size(gw->bw, &width, &height);
@@ -157,8 +175,7 @@ void ami_history_open(struct gui_window *gw)
EndWindow;
gw->hw->win = (struct Window *)RA_OpenWindow(gw->hw->objects[OID_MAIN]);
- gw->hw->node = AddObject(window_list,AMINS_HISTORYWINDOW);
- gw->hw->node->objstruct = gw->hw;
+ ami_gui_win_list_add(gw->hw, AMINS_HISTORYWINDOW, &ami_localhistory_table);
GetAttr(WINDOW_HorizObject,gw->hw->objects[OID_MAIN],(ULONG *)&gw->hw->objects[OID_HSCROLL]);
GetAttr(WINDOW_VertObject,gw->hw->objects[OID_MAIN],(ULONG *)&gw->hw->objects[OID_VSCROLL]);
@@ -223,15 +240,17 @@ static bool ami_history_click(struct history_window *hw, uint16 code)
void ami_history_close(struct history_window *hw)
{
- ami_free_layers(&hw->gg);
+ ami_free_layers(hw->gg);
+ free(hw->gg);
hw->gw->hw = NULL;
DisposeObject(hw->objects[OID_MAIN]);
- DelObject(hw->node);
+ ami_gui_win_list_remove(hw);
}
-BOOL ami_history_event(struct history_window *hw)
+static BOOL ami_history_event(void *w)
{
/* return TRUE if window destroyed */
+ struct history_window *hw = (struct history_window *)w;
ULONG result = 0;
uint16 code;
const char *url;
@@ -292,7 +311,7 @@ BOOL ami_history_event(struct history_window *hw)
return FALSE;
}
-void ami_history_update_extent(struct history_window *hw)
+static void ami_history_update_extent(struct history_window *hw)
{
struct IBox *bbox;
int width, height;
diff --git a/frontends/amiga/history_local.h b/frontends/amiga/history_local.h
index 452fe15..97aea05 100755
--- a/frontends/amiga/history_local.h
+++ b/frontends/amiga/history_local.h
@@ -21,16 +21,10 @@
#include <exec/types.h>
#include <intuition/classusr.h>
-#include "amiga/gui.h"
-struct history_window {
- struct nsObject *node;
- struct Window *win;
- Object *objects[GID_LAST];
- struct gui_window *gw;
- struct Hook scrollerhook;
- struct gui_globals gg;
-};
+struct gui_window;
+struct gui_globals;
+struct history_window;
/**
* Open history window.
@@ -40,6 +34,5 @@ struct history_window {
void ami_history_open(struct gui_window *gw);
void ami_history_close(struct history_window *hw);
-BOOL ami_history_event(struct history_window *hw);
#endif
diff --git a/frontends/amiga/hotlist.c b/frontends/amiga/hotlist.c
index 79e679f..fc2342d 100755
--- a/frontends/amiga/hotlist.c
+++ b/frontends/amiga/hotlist.c
@@ -21,8 +21,8 @@
#include "utils/nsurl.h"
#include "desktop/hotlist.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
#include "amiga/hotlist.h"
#include "amiga/tree.h"
@@ -37,6 +37,7 @@ struct ami_hotlist_ctx {
bool (*cb)(void *userdata, int level, int item, const char *title, nsurl *url, bool folder);
};
+struct treeview_window *hotlist_window = NULL;
void ami_hotlist_initialise(const char *hotlist_file)
{
diff --git a/frontends/amiga/hotlist.h b/frontends/amiga/hotlist.h
index c50ceec..113a2d1 100755
--- a/frontends/amiga/hotlist.h
+++ b/frontends/amiga/hotlist.h
@@ -19,16 +19,16 @@
#ifndef AMIGA_HOTLIST_H
#define AMIGA_HOTLIST_H
-#include "desktop/tree.h"
-#include "amiga/tree.h"
-
struct nsurl;
+struct treeview_window;
+
+extern struct treeview_window *hotlist_window;
void ami_hotlist_initialise(const char *hotlist_file);
+
void ami_hotlist_free(const char *hotlist_file);
-nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder,
- bool (*cb_add_item)(void *userdata, int level, int item, const char *title, struct nsurl *url, bool folder));
-struct treeview_window *hotlist_window;
+nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder, bool (*cb_add_item)(void *userdata, int level, int item, const char *title, struct nsurl *url, bool folder));
+
#endif
diff --git a/frontends/amiga/icon.c b/frontends/amiga/icon.c
index e75bf82..3f597a1 100644
--- a/frontends/amiga/icon.c
+++ b/frontends/amiga/icon.c
@@ -41,19 +41,19 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/file.h"
-#include "desktop/plotters.h"
-#include "image/bitmap.h"
+#include "netsurf/plotters.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
#include "content/content_protected.h"
#include "amiga/os3support.h"
#include "amiga/bitmap.h"
#include "amiga/icon.h"
-#include "amiga/misc.h"
#define THUMBNAIL_WIDTH 100 /* Icon sizes for thumbnails, usually the same as */
#define THUMBNAIL_HEIGHT 86 /* WIDTH/HEIGHT in desktop/thumbnail.c */
-ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height,
+static ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height,
ULONG trans, ULONG pals1, struct ColorRegister *pal1, int alpha);
#ifdef WITH_AMIGA_ICON
@@ -66,7 +66,7 @@ typedef struct amiga_icon_content {
static nserror amiga_icon_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
+ struct llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c);
static bool amiga_icon_convert(struct content *c);
static void amiga_icon_destroy(struct content *c);
@@ -104,7 +104,7 @@ CONTENT_FACTORY_REGISTER_TYPES(amiga_icon, amiga_icon_types,
nserror amiga_icon_create(const content_handler *handler,
lwc_string *imime_type, const struct http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
+ struct llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
{
amiga_icon_content *ai_content;
@@ -238,7 +238,7 @@ bool amiga_icon_convert(struct content *c)
if(dobj) FreeDiskObject(dobj);
if(format==IDFMT_PALETTEMAPPED)
- FreeVec(imagebufptr);
+ free(imagebufptr);
return true;
}
@@ -314,7 +314,7 @@ content_type amiga_icon_content_type(void)
#endif /* WITH_AMIGA_ICON */
-ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height,
+static ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height,
ULONG trans, ULONG pals1, struct ColorRegister *pal1, int alpha)
{
ULONG *argbicon;
@@ -325,7 +325,7 @@ ULONG *amiga_icon_convertcolouricon32(UBYTE *icondata, ULONG width, ULONG height
if (alpha==0) alpha=0xff;
- argbicon = (ULONG *)AllocVecTagList(width*height*4, NULL);
+ argbicon = (ULONG *)malloc(width * height * 4);
if (!argbicon) return(NULL);
cmap=GetColorMap(pals1);
@@ -484,8 +484,8 @@ void amiga_icon_superimpose_favicon(char *path, struct hlcache_handle *icon, cha
if(format == IDFMT_PALETTEMAPPED)
{
/* Free the 32-bit data we created */
- FreeVec(icondata1);
- FreeVec(icondata2);
+ free(icondata1);
+ free(icondata2);
}
}
@@ -500,17 +500,19 @@ struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm)
{
bitmap = ami_bitmap_get_native(bm, THUMBNAIL_WIDTH,
THUMBNAIL_HEIGHT, NULL);
- icondata = AllocVecTagList(THUMBNAIL_WIDTH * 4 * THUMBNAIL_HEIGHT, NULL);
+ icondata = malloc(THUMBNAIL_WIDTH * 4 * THUMBNAIL_HEIGHT);
ami_bitmap_set_icondata(bm, icondata);
- BltBitMapTags(BLITA_Width, THUMBNAIL_WIDTH,
- BLITA_Height, THUMBNAIL_HEIGHT,
- BLITA_SrcType, BLITT_BITMAP,
- BLITA_Source, bitmap,
- BLITA_DestType, BLITT_ARGB32,
- BLITA_DestBytesPerRow, THUMBNAIL_WIDTH * 4,
- BLITA_Dest, icondata,
+ if(bitmap) {
+ BltBitMapTags(BLITA_Width, THUMBNAIL_WIDTH,
+ BLITA_Height, THUMBNAIL_HEIGHT,
+ BLITA_SrcType, BLITT_BITMAP,
+ BLITA_Source, bitmap,
+ BLITA_DestType, BLITT_ARGB32,
+ BLITA_DestBytesPerRow, THUMBNAIL_WIDTH * 4,
+ BLITA_Dest, icondata,
TAG_DONE);
+ }
}
#endif
dobj = GetIconTags(NULL, ICONGETA_GetDefaultType, WBPROJECT,
@@ -540,6 +542,6 @@ void amiga_icon_free(struct DiskObject *dobj)
struct bitmap *bm = dobj->do_Gadget.UserData;
FreeDiskObject(dobj);
- if(bm) FreeVec(ami_bitmap_get_icondata(bm));
+ if(bm) ami_bitmap_free_icondata(bm);
}
diff --git a/frontends/amiga/iff_dr2d.c b/frontends/amiga/iff_dr2d.c
index a4d1738..91973f4 100644
--- a/frontends/amiga/iff_dr2d.c
+++ b/frontends/amiga/iff_dr2d.c
@@ -19,6 +19,7 @@
#ifdef WITH_NS_SVG
#include <stdio.h>
+#include <stdlib.h>
#include <inttypes.h>
#include <svgtiny.h>
#include <proto/exec.h>
@@ -26,18 +27,17 @@
#include <proto/dos.h>
#ifndef AMIGA_DR2D_STANDALONE
+#include "utils/nsurl.h"
+#include "netsurf/content.h"
#include "amiga/os3support.h"
#include "amiga/iff_dr2d.h"
-#include "amiga/misc.h"
-#include "content/hlcache.h"
#else
#include "os3support.h"
#include "iff_dr2d.h"
-#include "misc.h"
#endif
-struct ColorRegister cm[1000];
-ULONG numcols;
+static struct ColorRegister cm[1000];
+static ULONG numcols;
static ULONG findcolour(ULONG newcol)
{
@@ -77,8 +77,6 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
{
struct svgtiny_diagram *diagram;
svgtiny_code code;
- unsigned int i;
- unsigned int j;
BOOL fons_written = FALSE;
struct fons_struct *fons;
struct stxt_struct *stxt;
@@ -155,7 +153,7 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
if(!(PushChunk(iffh,0,ID_CMAP,IFFSIZE_UNKNOWN)))
{
- for (i = 0; i != diagram->shape_count; i++) {
+ for (unsigned int i = 0; i != diagram->shape_count; i++) {
if(diagram->shape[i].fill != svgtiny_TRANSPARENT)
{
addcolour(diagram->shape[i].fill);
@@ -171,8 +169,8 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
PopChunk(iffh);
}
- for (i = 0; i != diagram->shape_count; i++) {
- attr = ami_misc_allocvec_clear(sizeof(struct attr_struct), 0);
+ for (unsigned int i = 0; i != diagram->shape_count; i++) {
+ attr = calloc(1, sizeof(struct attr_struct));
if (diagram->shape[i].fill == svgtiny_TRANSPARENT)
attr->FillType = FT_NONE;
else
@@ -194,7 +192,7 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
WriteChunkBytes(iffh,attr,14);
PopChunk(iffh);
}
- FreeVec(attr);
+ free(attr);
if (diagram->shape[i].path) {
union {
@@ -211,7 +209,7 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
NumPoints = 0;
type = ID_OPLY;
- for (j = 0;
+ for (unsigned int j = 0;
j != diagram->shape[i].path_length; ) {
switch ((int) diagram->shape[i].path[j]) {
case svgtiny_PATH_MOVE:
@@ -273,30 +271,30 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
PopChunk(iffh);
}
} else if (diagram->shape[i].text) {
- stxt = ami_misc_allocvec_clear(sizeof(struct stxt_struct), 0);
+ stxt = calloc(1, sizeof(struct stxt_struct));
stxt->BaseX = diagram->shape[i].text_x;
stxt->BaseY = diagram->shape[i].text_y;
stxt->NumChars = strlen(diagram->shape[i].text);
if(!fons_written)
{
- fons = ami_misc_allocvec_clear(sizeof(struct fons_struct), 0);
- if(!(PushChunk(iffh,0,ID_FONS,IFFSIZE_UNKNOWN)))
+ fons = calloc(1, sizeof(struct fons_struct));
+ if(!(PushChunk(iffh, 0, ID_FONS, IFFSIZE_UNKNOWN)))
{
WriteChunkBytes(iffh, fons, sizeof(struct fons_struct));
WriteChunkBytes(iffh, "Topaz\0", 6);
PopChunk(iffh);
}
- FreeVec(fons);
+ free(fons);
fons_written = TRUE;
}
- if(!(PushChunk(iffh,0,ID_STXT,IFFSIZE_UNKNOWN)))
+ if(!(PushChunk(iffh, 0, ID_STXT, IFFSIZE_UNKNOWN)))
{
- WriteChunkBytes(iffh,stxt,26);
- WriteChunkBytes(iffh,diagram->shape[i].text,strlen(diagram->shape[i].text));
+ WriteChunkBytes(iffh, stxt, 26);
+ WriteChunkBytes(iffh, diagram->shape[i].text, strlen(diagram->shape[i].text));
PopChunk(iffh);
}
- FreeVec(stxt);
+ free(stxt);
}
}
@@ -381,7 +379,7 @@ int main(int argc, char **argv)
{
size = GetFileSize(fh);
- buffer = AllocVecTagList((uint32_t)size, NULL);
+ buffer = malloc((uint32_t)size);
Read(fh,buffer,(uint32_t)size);
Close(fh);
@@ -405,7 +403,7 @@ int main(int argc, char **argv)
ami_svg_to_dr2d(iffh,buffer,size,(char *)rarray[A_SVG]);
- FreeVec(buffer);
+ free(buffer);
if(iffh) CloseIFF(iffh);
if(iffh->iff_Stream) Close((BPTR)iffh->iff_Stream);
if(iffh) FreeIFF(iffh);
diff --git a/frontends/amiga/launch.c b/frontends/amiga/launch.c
index 1f2b9e1..10c32ae 100755
--- a/frontends/amiga/launch.c
+++ b/frontends/amiga/launch.c
@@ -38,7 +38,7 @@
struct Library *OpenURLBase = NULL;
struct OpenURLIFace *IOpenURL = NULL;
-struct MinList *ami_unsupportedprotocols;
+static struct MinList *ami_unsupportedprotocols;
struct ami_protocol
{
@@ -50,10 +50,10 @@ static struct ami_protocol *ami_openurl_add_protocol(const char *url)
{
nsurl *ns_url;
struct ami_protocol *ami_p =
- (struct ami_protocol *)AllocVecTagList(sizeof(struct ami_protocol), NULL);
+ (struct ami_protocol *)malloc(sizeof(struct ami_protocol));
if (nsurl_create(url, &ns_url) != NSERROR_OK) {
- FreeVec(ami_p);
+ free(ami_p);
return NULL;
}
@@ -61,7 +61,7 @@ static struct ami_protocol *ami_openurl_add_protocol(const char *url)
nsurl_unref(ns_url);
if (ami_p->protocol == NULL)
{
- FreeVec(ami_p);
+ free(ami_p);
return NULL;
}
@@ -74,20 +74,20 @@ static void ami_openurl_free_list(struct MinList *list)
struct ami_protocol *node;
struct ami_protocol *nnode;
- if(IsMinListEmpty(list)) return;
- node = (struct ami_protocol *)GetHead((struct List *)list);
-
- do
- {
- nnode=(struct ami_protocol *)GetSucc((struct Node *)node);
+ if(IsMinListEmpty(list) == NULL) {
+ node = (struct ami_protocol *)GetHead((struct List *)list);
- Remove((struct Node *)node);
- if (node->protocol) lwc_string_unref(node->protocol);
- FreeVec(node);
- node = NULL;
- }while((node=nnode));
+ do
+ {
+ nnode=(struct ami_protocol *)GetSucc((struct Node *)node);
- FreeVec(list);
+ Remove((struct Node *)node);
+ if (node->protocol) lwc_string_unref(node->protocol);
+ free(node);
+ node = NULL;
+ }while((node=nnode));
+ }
+ free(list);
}
static BOOL ami_openurl_check_list(struct MinList *list, nsurl *url)
diff --git a/frontends/amiga/libs.c b/frontends/amiga/libs.c
index 993cd3a..4c242d2 100644
--- a/frontends/amiga/libs.c
+++ b/frontends/amiga/libs.c
@@ -61,6 +61,13 @@
I##PREFIX = (struct PREFIX##IFace *)GetInterface((struct Library *)PREFIX##Base, INTERFACE, INTVER, NULL); \
if(I##PREFIX == NULL) { \
LOG("Failed to get %s interface v%d of %s", INTERFACE, INTVER, LIB); \
+ AMINS_LIB_CLOSE(PREFIX) \
+ if(FAIL == true) { \
+ STRPTR error = ASPrintf("Unable to open interface %s v%d\nof %s v%ld (fatal error - not an OS4 lib?)", INTERFACE, INTVER, LIB, LIBVER); \
+ ami_misc_fatal_error(error); \
+ FreeVec(error); \
+ return false; \
+ } \
} \
} else { \
LOG("Failed to open %s v%d", LIB, LIBVER); \
@@ -74,7 +81,9 @@
#define AMINS_LIB_CLOSE(PREFIX) \
if(I##PREFIX) DropInterface((struct Interface *)I##PREFIX); \
- if(PREFIX##Base) CloseLibrary((struct Library *)PREFIX##Base);
+ if(PREFIX##Base) CloseLibrary((struct Library *)PREFIX##Base); \
+ I##PREFIX = NULL; \
+ PREFIX##Base = NULL;
#define AMINS_LIB_STRUCT(PREFIX) \
struct PREFIX##Base *PREFIX##Base = NULL; \
@@ -227,7 +236,7 @@ bool ami_libs_open(void)
AMINS_LIB_OPEN("Picasso96API.library", 0, P96, "main", 1, false)
/* Non-OS provided libraries */
- AMINS_LIB_OPEN("guigfx.library", 9, GuiGFX, "main", 1, true)
+ AMINS_LIB_OPEN("guigfx.library", 9, GuiGFX, "main", 1, false)
/* NB: timer.device is opened in schedule.c (ultimately by the scheduler process).
* The library base and interface are obtained there, rather than here, due to
diff --git a/frontends/amiga/login.c b/frontends/amiga/login.c
index a4c0d62..85324b0 100755
--- a/frontends/amiga/login.c
+++ b/frontends/amiga/login.c
@@ -39,19 +39,18 @@
#include <reaction/reaction_macros.h>
#include "utils/messages.h"
-#include "utils/errors.h"
-#include "content/urldb.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
+#include "utils/nsurl.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
+#include "netsurf/url_db.h"
#include "amiga/gui.h"
#include "amiga/libs.h"
-#include "amiga/misc.h"
#include "amiga/object.h"
#include "amiga/login.h"
struct gui_login_window {
- struct nsObject *node;
+ struct ami_generic_window w;
struct Window *win;
Object *objects[GID_LAST];
nserror (*cb)(bool proceed, void *pw);
@@ -63,11 +62,19 @@ struct gui_login_window {
char pwd[256];
};
+static BOOL ami_401login_event(void *w);
+
+static const struct ami_win_event_table ami_login_table = {
+ ami_401login_event,
+ NULL, /* we don't explicitly close the login window at all.
+ @todo check if this prevents us from quitting NetSurf */
+};
+
void gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
const char *auth;
- struct gui_login_window *lw = ami_misc_allocvec_clear(sizeof(struct gui_login_window), 0);
+ struct gui_login_window *lw = calloc(1, sizeof(struct gui_login_window));
lwc_string *host = nsurl_get_component(url, NSURL_HOST);
assert(host != NULL);
@@ -169,9 +176,7 @@ void gui_401login_open(nsurl *url, const char *realm,
EndWindow;
lw->win = (struct Window *)RA_OpenWindow(lw->objects[OID_MAIN]);
-
- lw->node = AddObject(window_list,AMINS_LOGINWINDOW);
- lw->node->objstruct = lw;
+ ami_gui_win_list_add(lw, AMINS_LOGINWINDOW, &ami_login_table);
}
static void ami_401login_close(struct gui_login_window *lw)
@@ -183,7 +188,7 @@ static void ami_401login_close(struct gui_login_window *lw)
DisposeObject(lw->objects[OID_MAIN]);
lwc_string_unref(lw->host);
nsurl_unref(lw->url);
- DelObject(lw->node);
+ ami_gui_win_list_remove(lw);
}
static void ami_401login_login(struct gui_login_window *lw)
@@ -207,9 +212,10 @@ static void ami_401login_login(struct gui_login_window *lw)
ami_401login_close(lw);
}
-BOOL ami_401login_event(struct gui_login_window *lw)
+static BOOL ami_401login_event(void *w)
{
/* return TRUE if window destroyed */
+ struct gui_login_window *lw = (struct gui_login_window *)w;
ULONG result;
uint16 code;
diff --git a/frontends/amiga/login.h b/frontends/amiga/login.h
index e3f7790..058fa59 100755
--- a/frontends/amiga/login.h
+++ b/frontends/amiga/login.h
@@ -23,9 +23,7 @@
struct gui_login_window;
-BOOL ami_401login_event(struct gui_login_window *lw);
-
void gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
-
#endif
+
diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c
new file mode 100755
index 0000000..d371d25
--- /dev/null
+++ b/frontends/amiga/memory.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2016 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ *
+ * 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 __amigaos4__
+#include <proto/dos.h>
+#include <proto/exec.h>
+#include <exec/interrupts.h>
+#include <stdlib.h>
+#include "amiga/memory.h"
+#include "amiga/os3support.h"
+#include "amiga/schedule.h"
+#include "content/llcache.h"
+#include "utils/log.h"
+
+ULONG __slab_max_size = 2048; /* Enable clib2's slab allocator */
+
+enum {
+ PURGE_NONE = 0,
+ PURGE_STEP1,
+ PURGE_STEP2,
+ PURGE_DONE_STEP1,
+ PURGE_DONE_STEP2
+};
+static int low_mem_status = PURGE_NONE;
+
+/* Special clear (ie. non-zero) */
+void *ami_memory_clear_alloc(size_t size, UBYTE value)
+{
+ void *mem = malloc(size);
+ if (mem) memset(mem, value, size);
+ return mem;
+}
+
+/* clib2 slab allocator stats */
+static int ami_memory_slab_usage_cb(const struct __slab_usage_information * sui)
+{
+ if(sui->sui_slab_index <= 1) {
+ LOG("clib2 slab usage:");
+ LOG(" The size of all slabs, in bytes: %ld", sui->sui_slab_size);
+ LOG(" Number of allocations which are not managed by slabs: %ld",
+ sui->sui_num_single_allocations);
+ LOG(" Total number of bytes allocated for memory not managed by slabs: %ld",
+ sui->sui_total_single_allocation_size);
+ LOG(" Number of slabs currently in play: %ld", sui->sui_num_slabs);
+ LOG(" Number of currently unused slabs: %ld", sui->sui_num_empty_slabs);
+ LOG(" Number of slabs in use which are completely filled with data: %ld",
+ sui->sui_num_full_slabs);
+ LOG(" Total number of bytes allocated for all slabs: %ld",
+ sui->sui_total_slab_allocation_size);
+ }
+ LOG("Slab %d", sui->sui_slab_index);
+ LOG(" Memory chunk size managed by this slab: %ld", sui->sui_chunk_size);
+ LOG(" Number of memory chunks that fit in this slab: %ld", sui->sui_num_chunks);
+ LOG(" Number of memory chunks used in this slab: %ld", sui->sui_num_chunks_used);
+
+ return 0;
+}
+
+static int ami_memory_slab_alloc_cb(const struct __slab_allocation_information *sai)
+{
+ if(sai->sai_allocation_index <= 1) {
+ LOG("clib2 allocation usage:");
+ LOG(" Number of allocations which are not managed by slabs: %ld",
+ sai->sai_num_single_allocations);
+ LOG(" Total number of bytes allocated for memory not managed by slabs: %ld",
+ sai->sai_total_single_allocation_size);
+ }
+ LOG("Alloc %d", sai->sai_allocation_index);
+ LOG(" Size of this allocation, as requested: %ld", sai->sai_allocation_size);
+ LOG(" Total size of this allocation, including management data: %ld",
+ sai->sai_total_allocation_size);
+
+ return 0;
+}
+
+static int ami_memory_slab_stats_cb(void *user_data, const char *line, size_t line_length)
+{
+ BPTR fh = (BPTR)user_data;
+ long err = FPuts(fh, line);
+
+ if(err != 0) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+void ami_memory_slab_dump(BPTR fh)
+{
+ __get_slab_usage(ami_memory_slab_usage_cb);
+ __get_slab_allocations(ami_memory_slab_alloc_cb);
+ __get_slab_stats(fh, ami_memory_slab_stats_cb);
+}
+
+/* Low memory handler */
+static void ami_memory_low_mem_handler(void *p)
+{
+ if(low_mem_status == PURGE_STEP1) {
+ LOG("Purging llcache");
+ llcache_clean(true);
+ low_mem_status = PURGE_DONE_STEP1;
+ }
+
+ if(low_mem_status == PURGE_STEP2) {
+ LOG("Purging unused slabs");
+ __free_unused_slabs();
+ low_mem_status = PURGE_DONE_STEP2;
+ }
+}
+
+static ASM ULONG ami_memory_handler(REG(a0, struct MemHandlerData *mhd), REG(a1, void *userdata), REG(a6, struct ExecBase *execbase))
+{
+ if(low_mem_status == PURGE_DONE_STEP2) {
+ low_mem_status = PURGE_NONE;
+ return MEM_ALL_DONE;
+ }
+
+ if(low_mem_status == PURGE_DONE_STEP1) {
+ low_mem_status = PURGE_STEP2;
+ }
+
+ if(low_mem_status == PURGE_NONE) {
+ low_mem_status = PURGE_STEP1;
+ }
+
+ ami_schedule(1, ami_memory_low_mem_handler, NULL);
+
+ return MEM_TRY_AGAIN;
+}
+
+struct Interrupt *ami_memory_init(void)
+{
+ struct Interrupt *memhandler = malloc(sizeof(struct Interrupt));
+ if(memhandler == NULL) return NULL; // we're screwed
+
+ memhandler->is_Node.ln_Pri = -127; // low down as will be slow
+ memhandler->is_Node.ln_Name = "NetSurf low memory handler";
+ memhandler->is_Data = NULL;
+ memhandler->is_Code = (APTR)&ami_memory_handler;
+ AddMemHandler(memhandler);
+
+ return memhandler;
+}
+
+void ami_memory_fini(struct Interrupt *memhandler)
+{
+ if(memhandler != NULL) {
+ RemMemHandler(memhandler);
+ free(memhandler);
+ }
+}
+
+#endif
+
diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h
new file mode 100644
index 0000000..a9a882e
--- /dev/null
+++ b/frontends/amiga/memory.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2016 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ *
+ * 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 AMIGA_MEMORY_H
+#define AMIGA_MEMORY_H
+
+#include <exec/types.h>
+
+/* Alloc/free chip memory */
+#ifdef __amigaos4__
+#define ami_memory_chip_alloc(s) malloc(s)
+#define ami_memory_chip_free(p) free(p)
+#else
+#define ami_memory_chip_alloc(s) AllocVec(s, MEMF_CHIP)
+#define ami_memory_chip_free(p) FreeVec(p)
+#endif
+
+/* Alloc/free a block cleared to non-zero */
+#ifdef __amigaos4__
+#define ami_memory_clear_alloc(s,v) AllocVecTags(s, AVT_ClearWithValue, v, TAG_DONE)
+#define ami_memory_clear_free(p) FreeVec(p)
+#else
+void *ami_memory_clear_alloc(size_t size, UBYTE value);
+#define ami_memory_clear_free(p) free(p)
+#endif
+
+/* Itempool cross-compatibility */
+#ifdef __amigaos4__
+#define ami_memory_itempool_create(s) AllocSysObjectTags(ASOT_ITEMPOOL, \
+ ASOITEM_MFlags, MEMF_PRIVATE, \
+ ASOITEM_ItemSize, s, \
+ ASOITEM_GCPolicy, ITEMGC_AFTERCOUNT, \
+ ASOITEM_GCParameter, 100, \
+ TAG_DONE)
+#define ami_memory_itempool_delete(p) FreeSysObject(ASOT_ITEMPOOL, p)
+#define ami_memory_itempool_alloc(p,s) ItemPoolAlloc(p)
+#define ami_memory_itempool_free(p,i,s) ItemPoolFree(p,i)
+#else
+#define ami_memory_itempool_create(s) ((APTR)1)
+#define ami_memory_itempool_delete(p) ((void)0)
+#define ami_memory_itempool_alloc(p,s) malloc(s)
+#define ami_memory_itempool_free(p,i,s) free(i)
+#endif
+
+/* clib2 slab allocator */
+#ifndef __amigaos4__
+void ami_memory_slab_dump(BPTR fh);
+struct Interrupt *ami_memory_init(void);
+void ami_memory_fini(struct Interrupt *memhandler);
+#endif
+
+#endif //AMIGA_MEMORY_H
+
diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c
index 4a30c48..dc5514b 100644
--- a/frontends/amiga/menu.c
+++ b/frontends/amiga/menu.c
@@ -47,12 +47,12 @@
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/nsurl.h"
-#include "content/hlcache.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
+#include "netsurf/content.h"
+#include "netsurf/keypress.h"
#include "desktop/hotlist.h"
-#include "desktop/browser.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
-#include "desktop/textinput.h"
#include "desktop/version.h"
#include "amiga/arexx.h"
@@ -69,6 +69,7 @@
#include "amiga/libs.h"
#include "amiga/menu.h"
#include "amiga/misc.h"
+#include "amiga/nsoption.h"
#include "amiga/print.h"
#include "amiga/search.h"
#include "amiga/theme.h"
@@ -87,16 +88,35 @@ enum {
NSA_GLYPH_MAX
};
-BOOL menualreadyinit;
+static bool menu_quit = false;
+static bool ami_menu_check_toggled = false;
+static Object *restrict menu_glyph[NSA_GLYPH_MAX];
+static int menu_glyph_width[NSA_GLYPH_MAX];
+static bool menu_glyphs_loaded = false;
+
const char * const netsurf_version;
const char * const verdate;
-Object *menu_glyph[NSA_GLYPH_MAX];
-int menu_glyph_width[NSA_GLYPH_MAX];
-bool menu_glyphs_loaded = false;
static nserror ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
void ami_menu_arexx_scan(struct gui_window_2 *gwin);
+void ami_menu_set_check_toggled(void)
+{
+ ami_menu_check_toggled = true;
+}
+
+bool ami_menu_get_check_toggled(void)
+{
+ bool check_toggled = ami_menu_check_toggled;
+ ami_menu_check_toggled = false;
+ return check_toggled;
+}
+
+bool ami_menu_quit_selected(void)
+{
+ return menu_quit;
+}
+
/*
* The below functions are called automatically by window.class when menu items are selected.
*/
@@ -159,7 +179,7 @@ HOOKF(void, ami_menu_item_project_closewin, APTR, window, struct IntuiMessage *)
struct gui_window_2 *gwin;
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
- ami_menu_window_close = gwin;
+ gwin->closed = true;
}
HOOKF(void, ami_menu_item_project_print, APTR, window, struct IntuiMessage *)
@@ -237,7 +257,7 @@ HOOKF(void, ami_menu_item_project_about, APTR, window, struct IntuiMessage *)
HOOKF(void, ami_menu_item_project_quit, APTR, window, struct IntuiMessage *)
{
- ami_menu_window_close = AMI_MENU_WINDOW_CLOSE_ALL;
+ menu_quit = true;
}
HOOKF(void, ami_menu_item_edit_cut, APTR, window, struct IntuiMessage *)
@@ -350,7 +370,7 @@ HOOKF(void, ami_menu_item_browser_foreimg, APTR, window, struct IntuiMessage *)
if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
nsoption_set_bool(foreground_images, checked);
- ami_menu_check_toggled = true;
+ ami_menu_set_check_toggled();
}
HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
@@ -362,7 +382,7 @@ HOOKF(void, ami_menu_item_browser_backimg, APTR, window, struct IntuiMessage *)
if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
nsoption_set_bool(background_images, checked);
- ami_menu_check_toggled = true;
+ ami_menu_set_check_toggled();
}
HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
@@ -374,7 +394,7 @@ HOOKF(void, ami_menu_item_browser_enablejs, APTR, window, struct IntuiMessage *)
if(ItemAddress(menustrip, msg->Code)->Flags & CHECKED) checked = true;
nsoption_set_bool(enable_javascript, checked);
- ami_menu_check_toggled = true;
+ ami_menu_set_check_toggled();
}
HOOKF(void, ami_menu_item_browser_scale_decrease, APTR, window, struct IntuiMessage *)
@@ -465,7 +485,7 @@ HOOKF(void, ami_menu_item_settings_snapshot, APTR, window, struct IntuiMessage *
HOOKF(void, ami_menu_item_settings_save, APTR, window, struct IntuiMessage *)
{
- nsoption_write(current_user_options, NULL, NULL);
+ ami_nsoption_write();
}
HOOKF(void, ami_menu_item_arexx_execute, APTR, window, struct IntuiMessage *)
@@ -483,11 +503,11 @@ HOOKF(void, ami_menu_item_arexx_execute, APTR, window, struct IntuiMessage *)
ASLFR_InitialDrawer, nsoption_charp(arexx_dir),
ASLFR_InitialPattern, "#?.nsrx",
TAG_DONE)) {
- if((temp = AllocVecTagList(1024, NULL))) {
+ if((temp = malloc(1024))) {
strlcpy(temp, filereq->fr_Drawer, 1024);
AddPart(temp, filereq->fr_File, 1024);
ami_arexx_execute(temp);
- FreeVec(temp);
+ free(temp);
}
}
}
@@ -500,13 +520,13 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
if(script) {
- if((temp = AllocVecTagList(1024, NULL))) {
+ if((temp = malloc(1024))) {
BPTR lock;
if((lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))) {
DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
AddPart(temp, script, 1024);
ami_arexx_execute(temp);
- FreeVec(temp);
+ free(temp);
UnLock(lock);
}
}
@@ -539,12 +559,13 @@ void ami_free_menulabs(struct gui_window_2 *gwin)
gwin->menukey[i] = 0;
}
- FreeVec(gwin->menutype);
+ free(gwin->menutype);
gwin->menutype = NULL;
}
static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type,
- const char *label, char key, const char *icon, void *func, void *hookdata)
+ const char *restrict label, char key, const char *restrict icon,
+ void *restrict func, void *restrict hookdata)
{
char menu_icon[1024];
@@ -556,7 +577,7 @@ static void ami_menu_alloc_item(struct gui_window_2 *gwin, int num, UBYTE type,
if((num >= AMI_MENU_HOTLIST) && (num <= AMI_MENU_HOTLIST_MAX)) {
utf8_from_local_encoding(label,
(strlen(label) < NSA_MAX_HOTLIST_MENU_LEN) ? strlen(label) : NSA_MAX_HOTLIST_MENU_LEN,
- &gwin->menulab[num]);
+ (char **)&gwin->menulab[num]);
} else if((num >= AMI_MENU_AREXX) && (num < AMI_MENU_AREXX_MAX)) {
gwin->menulab[num] = strdup(label);
} else {
@@ -587,7 +608,7 @@ static void ami_init_menulabs(struct gui_window_2 *gwin)
{
int i;
- gwin->menutype = ami_misc_allocvec_clear(sizeof(UBYTE) * (AMI_MENU_AREXX_MAX + 1), 0);
+ gwin->menutype = calloc(1, sizeof(UBYTE) * (AMI_MENU_AREXX_MAX + 1));
for(i=0;i <= AMI_MENU_AREXX_MAX;i++)
{
@@ -835,8 +856,8 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
using label.image if there's a bitmap associated with the item. */
if((gwin->menuicon[i] != NULL) && (gwin->menulab[i] != NM_BARLABEL)) {
int icon_width = 0;
- Object *submenuarrow = NULL;
- Object *icon = BitMapObj,
+ Object *restrict submenuarrow = NULL;
+ Object *restrict icon = BitMapObj,
IA_Scalable, TRUE,
BITMAP_Screen, scrn,
BITMAP_SourceFile, gwin->menuicon[i],
@@ -914,7 +935,7 @@ void ami_menu_free(struct gui_window_2 *gwin)
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
{
- gwin->menu = ami_misc_allocvec_clear(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1), 0);
+ gwin->menu = calloc(1, sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1));
ami_init_menulabs(gwin);
ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin);
ami_menu_arexx_scan(gwin);
@@ -937,7 +958,7 @@ struct Menu *ami_menu_create(struct gui_window_2 *gwin)
gwin->imenu = CreateMenus(gwin->menu, TAG_DONE);
LayoutMenus(gwin->imenu, gwin->vi,
GTMN_NewLookMenus, TRUE, TAG_DONE);
- FreeVec(gwin->menu); /**\todo this should be local to this function */
+ free(gwin->menu); /**\todo this should be local to this function */
gwin->menu = NULL;
return gwin->imenu;
@@ -956,7 +977,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
char *menu_lab;
if((lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK))) {
- if((buffer = AllocVecTagList(1024, NULL))) {
+ if((buffer = malloc(1024))) {
if((ctrl = AllocDosObject(DOS_EXALLCONTROL,NULL))) {
ctrl->eac_LastKey = 0;
@@ -987,7 +1008,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
} while(cont);
FreeDosObject(DOS_EXALLCONTROL,ctrl);
}
- FreeVec(buffer);
+ free(buffer);
}
UnLock(lock);
}
@@ -1072,7 +1093,7 @@ void ami_menu_update_checked(struct gui_window_2 *gwin)
ResetMenuStrip(gwin->win, menustrip);
}
-void ami_menu_update_disabled(struct gui_window *g, hlcache_handle *c)
+void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c)
{
struct Window *win = g->shared->win;
diff --git a/frontends/amiga/menu.h b/frontends/amiga/menu.h
index 3bec113..ac74f38 100755
--- a/frontends/amiga/menu.h
+++ b/frontends/amiga/menu.h
@@ -129,15 +129,9 @@ enum {
#define AMI_MENU_BACKIMG FULLMENUNUM(2,8,1)
#define AMI_MENU_JS FULLMENUNUM(2,9,0)
-/** A special value for ami_menu_window_close */
-#define AMI_MENU_WINDOW_CLOSE_ALL (void *)1
-
struct gui_window;
struct gui_window_2;
-struct gui_window_2 *ami_menu_window_close;
-bool ami_menu_check_toggled;
-
void ami_free_menulabs(struct gui_window_2 *gwin);
struct Menu *ami_menu_create(struct gui_window_2 *gwin);
void ami_menu_refresh(struct gui_window_2 *gwin);
@@ -146,5 +140,25 @@ void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
void ami_menu_free_glyphs(void);
void ami_menu_free(struct gui_window_2 *gwin);
+/**
+ * Sets that an item linked to a toggle menu item has been changed.
+ */
+void ami_menu_set_check_toggled(void);
+
+/**
+ * Gets if the menu needs updating because an item linked
+ * to a toggle menu item has been changed.
+ * NB: This also *clears* the state
+ *
+ * \return true if the menus need refreshing
+ */
+bool ami_menu_get_check_toggled(void);
+
+/**
+ * Gets if NetSurf has been quit from the menu
+ *
+ * \return true if NetSurf has been quit
+ */
+bool ami_menu_quit_selected(void);
#endif
diff --git a/frontends/amiga/misc.c b/frontends/amiga/misc.c
index 2c23358..5ca4f90 100755
--- a/frontends/amiga/misc.c
+++ b/frontends/amiga/misc.c
@@ -36,64 +36,12 @@
#include "utils/nsurl.h"
#include "utils/url.h"
-#include "desktop/gui_window.h"
+#include "netsurf/window.h"
#include "amiga/gui.h"
#include "amiga/misc.h"
#include "amiga/utf8.h"
-void *ami_misc_allocvec_clear(int size, UBYTE value)
-{
-#ifdef __amigaos4__
- return AllocVecTags(size, AVT_ClearWithValue, value, TAG_DONE);
-#else
- void *mem = AllocVec(size, MEMF_ANY);
- if (mem) memset(mem, value, size);
- return mem;
-#endif
-}
-
-APTR ami_misc_itempool_create(int size)
-{
-#ifdef __amigaos4__
- return AllocSysObjectTags(ASOT_ITEMPOOL,
- ASOITEM_MFlags, MEMF_PRIVATE,
- ASOITEM_ItemSize, size,
- ASOITEM_GCPolicy, ITEMGC_AFTERCOUNT,
- ASOITEM_GCParameter, 100,
- TAG_DONE);
-#else
- return CreatePool(MEMF_ANY, 20 * size, size);
-#endif
-}
-
-void ami_misc_itempool_delete(APTR pool)
-{
-#ifdef __amigaos4__
- FreeSysObject(ASOT_ITEMPOOL, pool);
-#else
- DeletePool(pool);
-#endif
-}
-
-APTR ami_misc_itempool_alloc(APTR pool, int size)
-{
-#ifdef __amigaos4__
- return ItemPoolAlloc(pool);
-#else
- return AllocPooled(pool, size);
-#endif
-}
-
-void ami_misc_itempool_free(APTR pool, APTR item, int size)
-{
-#ifdef __amigaos4__
- ItemPoolFree(pool, item);
-#else
- FreePooled(pool, item, size);
-#endif
-}
-
static LONG ami_misc_req(const char *message, uint32 type)
{
LONG ret = 0;
@@ -189,6 +137,7 @@ int32 amiga_warn_user_multi(const char *body, const char *opt1, const char *opt2
static nserror amiga_nsurl_to_path(struct nsurl *url, char **path_out)
{
lwc_string *urlpath;
+ size_t path_len;
char *path;
bool match;
lwc_string *scheme;
@@ -217,25 +166,27 @@ static nserror amiga_nsurl_to_path(struct nsurl *url, char **path_out)
return NSERROR_BAD_PARAMETER;
}
- res = url_unescape(lwc_string_data(urlpath) + 1, &path);
+ res = url_unescape(lwc_string_data(urlpath) + 1, 0, &path_len, &path);
lwc_string_unref(urlpath);
if (res != NSERROR_OK) {
return res;
}
colon = strchr(path, ':');
- if(colon == NULL)
- {
+ if(colon == NULL) {
slash = strchr(path, '/');
- if(slash)
- {
+ if(slash) {
*slash = ':';
- }
- else
- {
- int len = strlen(path);
- path[len] = ':';
- path[len + 1] = '\0';
+ } else {
+ char *tmp_path = malloc(path_len + 2);
+ if(tmp_path == NULL) return NSERROR_NOMEM;
+
+ strncpy(tmp_path, path, path_len);
+ free(path);
+
+ path = tmp_path;
+ path[path_len] = ':';
+ path[path_len + 1] = '\0';
}
}
diff --git a/frontends/amiga/misc.h b/frontends/amiga/misc.h
index c7ae5af..a749794 100644
--- a/frontends/amiga/misc.h
+++ b/frontends/amiga/misc.h
@@ -35,15 +35,6 @@ struct Window;
* faliure displaying the message to the user.
*/
nserror amiga_warn_user(const char *warning, const char *detail);
-
-void *ami_misc_allocvec_clear(int size, UBYTE value);
-
-/* Itempool cross-compatibility */
-APTR ami_misc_itempool_create(int size);
-void ami_misc_itempool_delete(APTR pool);
-APTR ami_misc_itempool_alloc(APTR pool, int size);
-void ami_misc_itempool_free(APTR pool, APTR item, int size);
-
char *translate_escape_chars(const char *s);
void ami_misc_fatal_error(const char *message);
int32 amiga_warn_user_multi(const char *body,
diff --git a/frontends/amiga/nsoption.c b/frontends/amiga/nsoption.c
new file mode 100644
index 0000000..69b59bc
--- /dev/null
+++ b/frontends/amiga/nsoption.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ *
+ * 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/>.
+ */
+
+#include "amiga/os3support.h"
+
+#include <proto/exec.h>
+#include <proto/utility.h>
+
+#include "utils/nsoption.h"
+#include "amiga/nsoption.h"
+
+static char *current_user_options = NULL;
+
+nserror ami_nsoption_read(void)
+{
+ return nsoption_read(current_user_options, NULL);
+}
+
+nserror ami_nsoption_write(void)
+{
+ return nsoption_write(current_user_options, NULL, NULL);
+}
+
+nserror ami_nsoption_set_location(const char *current_user_dir)
+{
+ nserror err = NSERROR_OK;
+
+ ami_nsoption_free();
+
+ current_user_options = ASPrintf("%s/Choices", current_user_dir);
+ if(current_user_options == NULL)
+ err = NSERROR_NOMEM;
+
+ return err;
+}
+
+void ami_nsoption_free(void)
+{
+ if(current_user_options != NULL)
+ FreeVec(current_user_options);
+
+ current_user_options = NULL;
+}
+
diff --git a/frontends/amiga/font_diskfont.h b/frontends/amiga/nsoption.h
similarity index 75%
copy from frontends/amiga/font_diskfont.h
copy to frontends/amiga/nsoption.h
index de19e94..c3a3b56 100644
--- a/frontends/amiga/font_diskfont.h
+++ b/frontends/amiga/nsoption.h
@@ -16,8 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef AMIGA_FONT_DISKFONT_H
-#define AMIGA_FONT_DISKFONT_H
-void ami_font_diskfont_init(void);
+#ifndef AMIGA_NSOPTION_H
+#define AMIGA_NSOPTION_H 1
+#include "utils/errors.h"
+
+nserror ami_nsoption_read(void);
+nserror ami_nsoption_write(void);
+nserror ami_nsoption_set_location(const char *current_user_dir);
+void ami_nsoption_free(void);
#endif
diff --git a/frontends/amiga/object.c b/frontends/amiga/object.c
index 8da1639..37fc724 100755
--- a/frontends/amiga/object.c
+++ b/frontends/amiga/object.c
@@ -26,7 +26,7 @@
#include <exec/lists.h>
#include <exec/nodes.h>
-#include "amiga/misc.h"
+#include "amiga/memory.h"
#include "amiga/object.h"
#ifdef __amigaos4__
@@ -37,11 +37,11 @@
#define NewnsList NewList
#endif
-APTR pool_nsobj = NULL;
+static APTR pool_nsobj = NULL;
bool ami_object_init(void)
{
- pool_nsobj = ami_misc_itempool_create(sizeof(struct nsObject));
+ pool_nsobj = ami_memory_itempool_create(sizeof(struct nsObject));
if(pool_nsobj == NULL) return false;
else return true;
@@ -49,7 +49,7 @@ bool ami_object_init(void)
void ami_object_fini(void)
{
- ami_misc_itempool_delete(pool_nsobj);
+ ami_memory_itempool_delete(pool_nsobj);
}
/* Slightly abstract MinList initialisation */
@@ -62,7 +62,7 @@ static void ami_NewMinList(struct MinList *list)
/* Allocate and initialise a new MinList */
struct MinList *ami_AllocMinList(void)
{
- struct MinList *objlist = (struct MinList *)AllocVecTagList(sizeof(struct nsList), NULL);
+ struct MinList *objlist = (struct MinList *)malloc(sizeof(struct nsList));
if(objlist == NULL) return NULL;
ami_NewMinList(objlist);
return objlist;
@@ -78,7 +78,7 @@ struct nsObject *AddObject(struct MinList *objlist, ULONG otype)
{
struct nsObject *dtzo;
- dtzo = (struct nsObject *)ami_misc_itempool_alloc(pool_nsobj, sizeof(struct nsObject));
+ dtzo = (struct nsObject *)ami_memory_itempool_alloc(pool_nsobj, sizeof(struct nsObject));
if(dtzo == NULL) return NULL;
memset(dtzo, 0, sizeof(struct nsObject));
@@ -98,9 +98,9 @@ static void DelObjectInternal(struct nsObject *dtzo, BOOL free_obj)
{
Remove((struct Node *)dtzo);
if(dtzo->callback != NULL) dtzo->callback(dtzo->objstruct);
- if(dtzo->objstruct && free_obj) FreeVec(dtzo->objstruct);
+ if(dtzo->objstruct && free_obj) free(dtzo->objstruct);
if(dtzo->dtz_Node.ln_Name) free(dtzo->dtz_Node.ln_Name);
- ami_misc_itempool_free(pool_nsobj, dtzo, sizeof(struct nsObject));
+ ami_memory_itempool_free(pool_nsobj, dtzo, sizeof(struct nsObject));
dtzo = NULL;
}
@@ -119,18 +119,18 @@ void FreeObjList(struct MinList *objlist)
struct nsObject *node;
struct nsObject *nnode;
- if(IsMinListEmpty((struct MinList *)objlist)) return;
- node = (struct nsObject *)GetHead((struct List *)objlist);
-
- do {
- nnode=(struct nsObject *)GetSucc((struct Node *)node);
- if(node->Type == AMINS_RECT) {
- DelObjectNoFree(node);
- } else {
- DelObject(node);
- }
- } while((node=nnode));
-
- FreeVec(objlist);
+ if(IsMinListEmpty((struct MinList *)objlist) == FALSE) {
+ node = (struct nsObject *)GetHead((struct List *)objlist);
+
+ do {
+ nnode = (struct nsObject *)GetSucc((struct Node *)node);
+ if(node->Type == AMINS_RECT) {
+ DelObjectNoFree(node);
+ } else {
+ DelObject(node);
+ }
+ } while((node = nnode));
+ }
+ free(objlist);
}
diff --git a/frontends/amiga/options.h b/frontends/amiga/options.h
index 84e3f78..b5b2b3b 100644
--- a/frontends/amiga/options.h
+++ b/frontends/amiga/options.h
@@ -41,6 +41,7 @@ NSOPTION_BOOL(new_tab_is_active, false)
NSOPTION_BOOL(new_tab_last, false)
NSOPTION_BOOL(tab_close_warn, true)
NSOPTION_BOOL(tab_always_show, false)
+NSOPTION_BOOL(tab_new_session, false) /* When NetSurf is already running, open new tab */
NSOPTION_BOOL(kiosk_mode, false)
NSOPTION_STRING(search_engines_file, "PROGDIR:Resources/SearchEngines")
NSOPTION_STRING(arexx_dir, "PROGDIR:Rexx")
@@ -51,7 +52,7 @@ NSOPTION_BOOL(download_notify, true)
NSOPTION_BOOL(faster_scroll, true)
NSOPTION_BOOL(scale_quality, false)
NSOPTION_INTEGER(dither_quality, 0)
-NSOPTION_INTEGER(mask_alpha, 50)
+NSOPTION_INTEGER(mask_alpha, 0)
NSOPTION_BOOL(ask_overwrite, true)
NSOPTION_INTEGER(printer_unit, 0)
NSOPTION_INTEGER(print_scale, 100)
@@ -87,12 +88,12 @@ NSOPTION_INTEGER(redraw_tile_size_y, 0)
NSOPTION_INTEGER(monitor_aspect_x, 0)
NSOPTION_INTEGER(monitor_aspect_y, 0)
NSOPTION_BOOL(accept_lang_locale, true)
+NSOPTION_STRING(local_charset, "ISO-8859-1")
#ifdef __amigaos4__
/* Options relevant for OS4 only */
NSOPTION_BOOL(use_extmem, true)
#else
/* Options relevant for OS3 only */
NSOPTION_BOOL(friend_bitmap, false)
-NSOPTION_STRING(local_charset, "ISO-8859-1")
#endif
diff --git a/frontends/amiga/os3support.c b/frontends/amiga/os3support.c
index b251448..c082602 100644
--- a/frontends/amiga/os3support.c
+++ b/frontends/amiga/os3support.c
@@ -17,7 +17,7 @@
*/
/** \file
- * Minimal compatibility header for AmigaOS 3
+ * Compatibility functions for AmigaOS 3
*/
#ifndef __amigaos4__
@@ -26,6 +26,9 @@
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <dirent.h>
#include <proto/bullet.h>
#include <proto/exec.h>
@@ -43,6 +46,155 @@
#define FAILURE (FALSE)
#define NO !
+/* Utility */
+struct FormatContext
+{
+ STRPTR Index;
+ LONG Size;
+ BOOL Overflow;
+};
+
+STATIC VOID ASM
+StuffChar(
+ REG(a3, struct FormatContext * Context),
+ REG(d0, UBYTE Char))
+{
+ /* Is there still room? */
+ if(Context->Size > 0)
+ {
+ (*Context->Index) = Char;
+
+ Context->Index++;
+ Context->Size--;
+
+ /* Is there only a single character left? */
+ if(Context->Size == 1)
+ {
+ /* Provide null-termination. */
+ (*Context->Index) = '\0';
+
+ /* Don't store any further characters. */
+ Context->Size = 0;
+ }
+ }
+ else
+ {
+ Context->Overflow = TRUE;
+ }
+}
+
+BOOL
+VSPrintfN(
+ LONG MaxLen,
+ STRPTR Buffer,
+ const STRPTR FormatString,
+ const va_list VarArgs)
+{
+ BOOL result = FAILURE;
+
+ /* format a text, but place only up to MaxLen
+ * characters in the output buffer (including
+ * the terminating NUL)
+ */
+
+ if (Buffer == NULL || FormatString == NULL) return(result);
+
+ if(MaxLen > 1)
+ {
+ struct FormatContext Context;
+
+ Context.Index = Buffer;
+ Context.Size = MaxLen;
+ Context.Overflow = FALSE;
+
+ RawDoFmt(FormatString,(APTR)VarArgs,(VOID (*)())StuffChar,(APTR)&Context);
+
+ if(NO Context.Overflow)
+ result = SUCCESS;
+ }
+
+ return(result);
+}
+
+BOOL
+SPrintfN(
+ LONG MaxLen,
+ STRPTR Buffer,
+ const STRPTR FormatString,
+ ...)
+{
+ va_list VarArgs;
+ BOOL result = FAILURE;
+
+ /* format a text, varargs version */
+
+ if (Buffer == NULL && FormatString == NULL) return result;
+
+ va_start(VarArgs,FormatString);
+ result = VSPrintfN(MaxLen,Buffer,FormatString,VarArgs);
+ va_end(VarArgs);
+
+ return(result);
+}
+
+char *ASPrintf(const char *fmt, ...)
+{
+ int r;
+ va_list ap;
+ static char buffer[2048];
+ char *rbuf;
+
+ va_start(ap, fmt);
+ r = VSPrintfN(2048, buffer, (const STRPTR)fmt, ap);
+ va_end(ap);
+
+ r = strlen(buffer);
+ rbuf = AllocVec(r+1, MEMF_CLEAR);
+ if (rbuf != NULL)
+ {
+ strncpy(rbuf, buffer, r);
+ }
+ return rbuf;
+}
+
+/* C */
+char *strlwr(char *str)
+{
+ size_t i;
+ size_t len = strlen(str);
+
+ for(i=0; i<len; i++)
+ str[i] = tolower((unsigned char)str[i]);
+
+ return str;
+}
+
+char *strsep(char **s1, const char *s2)
+{
+ char *const p1 = *s1;
+
+ if (p1 != NULL) {
+ *s1 = strpbrk(p1, s2);
+ if (*s1 != NULL) {
+ *(*s1)++ = '\0';
+ }
+ }
+ return p1;
+}
+
+int scandir(const char *dir, struct dirent ***namelist,
+ int (*filter)(const struct dirent *),
+ int (*compar)(const struct dirent **, const struct dirent **))
+{
+ /*\todo stub function, needs writing, preferably into clib2 */
+ return 0;
+}
+
+long long int strtoll(const char *nptr, char **endptr, int base)
+{
+ return (long long int)strtol(nptr, endptr, base);
+}
+
/* Diskfont */
struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG flags)
{
@@ -57,7 +209,7 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl
char *p = 0;
struct FontContentsHeader fch;
- if(p = strrchr(fileName, '.'))
+ if((p = strrchr(fileName, '.')))
*p = '\0';
fontpath = (STRPTR)ASPrintf("FONTS:%s.font", fileName);
@@ -96,7 +248,7 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl
}
size = GetFileSize(fh);
- buffer = (struct TagItem *)AllocVec(size, MEMF_ANY);
+ buffer = (UBYTE *)malloc(size);
if(buffer == NULL) {
LOG("Unable to allocate memory");
Close(fh);
@@ -111,15 +263,15 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl
struct TagItem *tag = (struct TagItem *)buffer;
if((tag->ti_Tag != OT_FileIdent) || (tag->ti_Data != (ULONG)size)) {
LOG("Invalid OTAG file");
- FreeVec(buffer);
+ free(buffer);
FreeVec(otagpath);
return NULL;
}
/* Relocate all the OT_Indirect tags */
- while (ti = NextTagItem(&tag)) {
+ while((ti = NextTagItem(&tag))) {
if(ti->ti_Tag & OT_Indirect) {
- ti->ti_Data += buffer;
+ ti->ti_Data += (ULONG)buffer;
}
}
@@ -129,16 +281,16 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl
fname = ASPrintf("%s.library", ti->ti_Data);
} else {
LOG("Cannot find OT_Engine tag");
- FreeVec(buffer);
+ free(buffer);
FreeVec(otagpath);
return NULL;
}
- BulletBase = OpenLibrary(fname, 0L);
+ BulletBase = (struct BulletBase *)OpenLibrary(fname, 0L);
if(BulletBase == NULL) {
LOG("Unable to open font engine %s", fname);
- FreeVec(buffer);
+ free(buffer);
FreeVec(fname);
FreeVec(otagpath);
}
@@ -148,11 +300,11 @@ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG fl
gengine = OpenEngine();
SetInfo(gengine,
- OT_OTagPath, otagpath,
- OT_OTagList, buffer,
+ OT_OTagPath, (ULONG)otagpath,
+ OT_OTagList, (ULONG)buffer,
TAG_DONE);
- of = AllocVec(sizeof(struct OutlineFont), MEMF_CLEAR);
+ of = calloc(1, sizeof(struct OutlineFont));
if(of == NULL) return NULL;
of->BulletBase = BulletBase;
@@ -168,11 +320,11 @@ void CloseOutlineFont(struct OutlineFont *of, struct List *list)
struct BulletBase *BulletBase = of->BulletBase;
CloseEngine(of->GEngine);
- CloseLibrary(BulletBase);
+ CloseLibrary((struct Library *)BulletBase);
FreeVec(of->OTagPath);
- FreeVec(of->olf_OTagList);
- FreeVec(of);
+ free(of->olf_OTagList);
+ free(of);
}
@@ -180,13 +332,13 @@ void CloseOutlineFont(struct OutlineFont *of, struct List *list)
int64 GetFileSize(BPTR fh)
{
int32 size = 0;
- struct FileInfoBlock *fib = AllocVec(sizeof(struct FileInfoBlock), MEMF_ANY);
+ struct FileInfoBlock *fib = malloc(sizeof(struct FileInfoBlock));
if(fib == NULL) return 0;
ExamineFH(fh, fib);
size = fib->fib_Size;
- FreeVec(fib);
+ free(fib);
return (int64)size;
}
@@ -277,155 +429,5 @@ APTR NewObject(struct IClass * classPtr, CONST_STRPTR classID, ULONG tagList, ..
{
return NewObjectA(classPtr, classID, (const struct TagItem *) &tagList);
}
-
-/* Utility */
-struct FormatContext
-{
- STRPTR Index;
- LONG Size;
- BOOL Overflow;
-};
-
-STATIC VOID ASM
-StuffChar(
- REG(a3, struct FormatContext * Context),
- REG(d0, UBYTE Char))
-{
- /* Is there still room? */
- if(Context->Size > 0)
- {
- (*Context->Index) = Char;
-
- Context->Index++;
- Context->Size--;
-
- /* Is there only a single character left? */
- if(Context->Size == 1)
- {
- /* Provide null-termination. */
- (*Context->Index) = '\0';
-
- /* Don't store any further characters. */
- Context->Size = 0;
- }
- }
- else
- {
- Context->Overflow = TRUE;
- }
-}
-
-BOOL
-VSPrintfN(
- LONG MaxLen,
- STRPTR Buffer,
- const STRPTR FormatString,
- const va_list VarArgs)
-{
- BOOL result = FAILURE;
-
- /* format a text, but place only up to MaxLen
- * characters in the output buffer (including
- * the terminating NUL)
- */
-
- if (Buffer == NULL || FormatString == NULL) return(result);
-
- if(MaxLen > 1)
- {
- struct FormatContext Context;
-
- Context.Index = Buffer;
- Context.Size = MaxLen;
- Context.Overflow = FALSE;
-
- RawDoFmt(FormatString,(APTR)VarArgs,(VOID (*)())StuffChar,(APTR)&Context);
-
- if(NO Context.Overflow)
- result = SUCCESS;
- }
-
- return(result);
-}
-
-BOOL
-SPrintfN(
- LONG MaxLen,
- STRPTR Buffer,
- const STRPTR FormatString,
- ...)
-{
- va_list VarArgs;
- BOOL result = FAILURE;
-
- /* format a text, varargs version */
-
- if (Buffer == NULL && FormatString == NULL) return result;
-
- va_start(VarArgs,FormatString);
- result = VSPrintfN(MaxLen,Buffer,FormatString,VarArgs);
- va_end(VarArgs);
-
- return(result);
-}
-
-char *ASPrintf(const char *fmt, ...)
-{
- int r;
- va_list ap;
- static char buffer[2048];
- char *rbuf;
-
- va_start(ap, fmt);
- r = VSPrintfN(2048, buffer, (const STRPTR)fmt, ap);
- va_end(ap);
-
- r = strlen(buffer);
- rbuf = AllocVec(r+1, MEMF_CLEAR);
- if (rbuf != NULL)
- {
- strncpy(rbuf, buffer, r);
- }
- return rbuf;
-}
-
-/* C */
-char *strlwr(char *str)
-{
- size_t i;
- size_t len = strlen(str);
-
- for(i=0; i<len; i++)
- str[i] = tolower((unsigned char)str[i]);
-
- return str;
-}
-
-char *strsep(char **s1, const char *s2)
-{
- char *const p1 = *s1;
-
- if (p1 != NULL) {
- *s1 = strpbrk(p1, s2);
- if (*s1 != NULL) {
- *(*s1)++ = '\0';
- }
- }
- return p1;
-}
-
-int scandir(const char *dir, struct dirent ***namelist,
- int (*filter)(const struct dirent *),
- int (*compar)(const struct dirent **, const struct dirent **))
-{
- /*\todo stub function, needs writing, preferably into clib2 */
- return 0;
-}
-
-long long int strtoll(const char *nptr, char **endptr, int base)
-{
- return (long long int)strtol(nptr, endptr, base);
-}
-
#endif
diff --git a/frontends/amiga/os3support.h b/frontends/amiga/os3support.h
index 94d1d58..856439b 100644
--- a/frontends/amiga/os3support.h
+++ b/frontends/amiga/os3support.h
@@ -152,7 +152,6 @@
#define DevNameFromLock(A,B,C,D) NameFromLock(A,B,C)
/* Exec */
-#define AllocVecTagList(SZ,TAG) AllocVec(SZ,MEMF_ANY) /* AllocVecTagList with no tags */
#define FindIName FindName
/* Intuition */
diff --git a/frontends/amiga/pkg/SearchEngines b/frontends/amiga/pkg/SearchEngines
new file mode 100644
index 0000000..3f4bdd9
--- /dev/null
+++ b/frontends/amiga/pkg/SearchEngines
@@ -0,0 +1,2 @@
+Aminet|www.aminet.net|http://aminet.net/search?query=%s|http://aminet.net/favicon.ico|
+OS4Depot|www.os4depot.net|http://www.os4depot.net/index.php?function=search&tool=simple&f_fields=%s|http://www.os4depot.net/favicon.ico|
diff --git a/frontends/amiga/pkg/netsurf.readme b/frontends/amiga/pkg/netsurf.readme
index 3e929b0..817e074 100755
--- a/frontends/amiga/pkg/netsurf.readme
+++ b/frontends/amiga/pkg/netsurf.readme
@@ -2,11 +2,11 @@ Short: Fast CSS capable web browser
Uploader: chris(a)unsatisfactorysoftware.co.uk (Chris Young)
Author: NetSurf contributors (OS4 port by Chris Young)
Type: comm/www
-Version: 3.6
+Version: 3.8
Requires: dev/misc/guigfxlib.lha
Architecture: ppc-amigaos >= 4.0.0
-This is NetSurf 3.6 for AmigaOS 4 (native frontend).
+This is NetSurf 3.8 for AmigaOS 4 (native frontend).
For the latest version, visit http://www.netsurf-browser.org
*******************************************
diff --git a/frontends/amiga/pkg/netsurf_os3.readme b/frontends/amiga/pkg/netsurf_os3.readme
index d9c0eb5..087e586 100644
--- a/frontends/amiga/pkg/netsurf_os3.readme
+++ b/frontends/amiga/pkg/netsurf_os3.readme
@@ -2,11 +2,11 @@ Short: Fast CSS capable web browser
Uploader: chris(a)unsatisfactorysoftware.co.uk (Chris Young)
Author: NetSurf contributors (OS4 port by Chris Young)
Type: comm/www
-Version: 3.6 BETA
+Version: 3.8 BETA
Requires: dev/misc/guigfxlib.lha
Architecture: m68k-amigaos >= 3.5.0
-This is NetSurf 3.6 BETA for AmigaOS 3.
+This is NetSurf 3.8 BETA for AmigaOS 3.
It is built off of the OS4 (Reaction) frontend.
Requirements are AmigaOS 3.5 or 3.9, 32MB RAM.
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index 23a73f8..6bae634 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -33,18 +33,20 @@
#include <math.h>
#include <assert.h>
+#include <stdlib.h>
#include "utils/nsoption.h"
#include "utils/utils.h"
#include "utils/log.h"
-#include "css/utils.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
+#include "netsurf/css.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
#include "amiga/plotters.h"
#include "amiga/bitmap.h"
#include "amiga/font.h"
#include "amiga/gui.h"
+#include "amiga/memory.h"
#include "amiga/misc.h"
#include "amiga/rtg.h"
#include "amiga/utf8.h"
@@ -72,6 +74,8 @@ struct bez_point {
float y;
};
+struct gui_globals *glob;
+
static int init_layers_count = 0;
static APTR pool_pens = NULL;
@@ -103,13 +107,32 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for
if(force32bit == false) depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
LOG("Screen depth = %d", depth);
+#ifdef __amigaos4__
if(depth < 16) {
gg->palette_mapped = true;
} else {
gg->palette_mapped = false;
}
+#else
+ /* Friend BitMaps are weird.
+ * For OS4, we shouldn't use a friend BitMap here (see below).
+ * For OS3 AGA, we get no display blitted if we use a friend BitMap,
+ * however on RTG it seems to be a benefit.
+ */
+ if(nsoption_bool(friend_bitmap) == true) {
+ friend = scrn->RastPort.BitMap;
+ } else {
+ /* Force friend BitMaps on for obvious RTG screens under OS3.
+ * If we get a bit smarter about this we can lose the user option. */
+ if((depth > 8) && (force32bit == false)) friend = scrn->RastPort.BitMap;
+ }
-#ifndef __amigaos4__
+ /* OS3 is locked to using palette-mapped display even on RTG.
+ * To change this, comment out the below and build with the similar OS4 lines above.
+ * Various bits of RTG code are OS4-only and OS3 versions will need to be written,
+ * however a brief test reveals a negative performance benefit, so this lock to a
+ * palette-mapped display is most likely permanent.
+ */
#warning OS3 locked to palette-mapped modes
gg->palette_mapped = true;
if(depth > 8) depth = 8;
@@ -124,29 +147,10 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for
gg->height = height;
gg->layerinfo = NewLayerInfo();
- gg->areabuf = AllocVecTagList(AREA_SIZE, NULL);
+ gg->areabuf = malloc(AREA_SIZE);
-#ifdef __amigaos4__
- gg->tmprasbuf = AllocVecTagList(width * height, NULL);
-#else
/* OS3/AGA requires this to be in chip mem. RTG would probably rather it wasn't. */
- gg->tmprasbuf = AllocVec(width * height, MEMF_CHIP);
-#endif
-
- /* Friend BitMaps are weird.
- * For OS4, we shouldn't use a friend BitMap here (see below).
- * For OS3 AGA, we get no display blitted if we use a friend BitMap,
- * however on RTG it seems to be a benefit.
- */
-#ifndef __amigaos4__
- if(nsoption_bool(friend_bitmap) == true) {
- friend = scrn->RastPort.BitMap;
- } else {
- /* Force friend BitMaps on for obvious RTG screens under OS3.
- * If we get a bit smarter about this we can lose the user option. */
- if((depth >= 16) && (force32bit == false)) friend = scrn->RastPort.BitMap;
- }
-#endif
+ gg->tmprasbuf = ami_memory_chip_alloc(width * height);
if(gg->palette_mapped == true) {
gg->bm = AllocBitMap(width, height, depth, 0, friend);
@@ -165,7 +169,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for
if(!gg->bm) amiga_warn_user("NoMemory","");
- gg->rp = AllocVecTagList(sizeof(struct RastPort), NULL);
+ gg->rp = malloc(sizeof(struct RastPort));
if(!gg->rp) amiga_warn_user("NoMemory","");
InitRastPort(gg->rp);
@@ -178,18 +182,18 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for
InstallLayerHook(gg->rp->Layer,LAYERS_NOBACKFILL);
- gg->rp->AreaInfo = AllocVecTagList(sizeof(struct AreaInfo), NULL);
+ gg->rp->AreaInfo = malloc(sizeof(struct AreaInfo));
if((!gg->areabuf) || (!gg->rp->AreaInfo)) amiga_warn_user("NoMemory","");
- InitArea(gg->rp->AreaInfo,gg->areabuf, AREA_SIZE/5);
+ InitArea(gg->rp->AreaInfo, gg->areabuf, AREA_SIZE/5);
- gg->rp->TmpRas = AllocVecTagList(sizeof(struct TmpRas), NULL);
+ gg->rp->TmpRas = malloc(sizeof(struct TmpRas));
if((!gg->tmprasbuf) || (!gg->rp->TmpRas)) amiga_warn_user("NoMemory","");
InitTmpRas(gg->rp->TmpRas, gg->tmprasbuf, width*height);
if((gg->palette_mapped == true) && (pool_pens == NULL)) {
- pool_pens = ami_misc_itempool_create(sizeof(struct ami_plot_pen));
+ pool_pens = ami_memory_itempool_create(sizeof(struct ami_plot_pen));
}
gg->apen = 0x00000000;
@@ -206,19 +210,19 @@ void ami_free_layers(struct gui_globals *gg)
init_layers_count--;
if((init_layers_count == 0) && (pool_pens != NULL)) {
- ami_misc_itempool_delete(pool_pens);
+ ami_memory_itempool_delete(pool_pens);
pool_pens = NULL;
}
if(gg->rp) {
DeleteLayer(0,gg->rp->Layer);
- FreeVec(gg->rp->TmpRas);
- FreeVec(gg->rp->AreaInfo);
- FreeVec(gg->rp);
+ free(gg->rp->TmpRas);
+ free(gg->rp->AreaInfo);
+ free(gg->rp);
}
- FreeVec(gg->tmprasbuf);
- FreeVec(gg->areabuf);
+ ami_memory_chip_free(gg->tmprasbuf);
+ free(gg->areabuf);
DisposeLayerInfo(gg->layerinfo);
if(gg->palette_mapped == false) {
if(gg->bm) ami_rtg_freebitmap(gg->bm);
@@ -252,7 +256,7 @@ static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colr)
if(pen == -1) LOG("WARNING: Cannot allocate pen for ABGR:%lx", colr);
if((shared_pens != NULL) && (pool_pens != NULL)) {
- if((node = (struct ami_plot_pen *)ami_misc_itempool_alloc(pool_pens, sizeof(struct ami_plot_pen)))) {
+ if((node = (struct ami_plot_pen *)ami_memory_itempool_alloc(pool_pens, sizeof(struct ami_plot_pen)))) {
node->pen = pen;
AddTail((struct List *)shared_pens, (struct Node *)node);
}
@@ -276,7 +280,7 @@ void ami_plot_release_pens(struct MinList *shared_pens)
nnode = (struct ami_plot_pen *)GetSucc((struct Node *)node);
ReleasePen(scrn->ViewPort.ColorMap, node->pen);
Remove((struct Node *)node);
- ami_misc_itempool_free(pool_pens, node, sizeof(struct ami_plot_pen));
+ ami_memory_itempool_free(pool_pens, node, sizeof(struct ami_plot_pen));
} while((node = nnode));
glob->apen = 0x00000000;
@@ -706,7 +710,7 @@ static bool ami_bitmap_tile(int x, int y, int width, int height,
bfbm.offsetx = ox;
bfbm.offsety = oy;
bfbm.mask = ami_bitmap_get_mask(bitmap, width, height, tbm);
- bfh = ami_misc_allocvec_clear(sizeof(struct Hook), 0); /* NB: Was not MEMF_PRIVATE */
+ bfh = calloc(1, sizeof(struct Hook));
bfh->h_Entry = (HOOKFUNC)ami_bitmap_tile_hook;
bfh->h_SubEntry = 0;
bfh->h_Data = &bfbm;
@@ -720,7 +724,7 @@ static bool ami_bitmap_tile(int x, int y, int width, int height,
if(amiga_bitmap_get_opaque(bitmap)) DeleteBackFillHook(bfh);
else
#endif
- FreeVec(bfh);
+ free(bfh);
if((ami_bitmap_is_nativebm(bitmap, tbm) == false)) {
/**\todo is this logic logical? */
@@ -794,8 +798,9 @@ HOOKF(void, ami_bitmap_tile_hook, struct RastPort *, rp, struct BackFillMessage
}
}
-static void ami_bezier(struct bez_point *a, struct bez_point *b, struct bez_point *c,
- struct bez_point *d, double t, struct bez_point *p) {
+static void ami_bezier(struct bez_point *restrict a, struct bez_point *restrict b,
+ struct bez_point *restrict c, struct bez_point *restrict d,
+ double t, struct bez_point *restrict p) {
p->x = pow((1 - t), 3) * a->x + 3 * t * pow((1 -t), 2) * b->x + 3 * (1-t) * pow(t, 2)* c->x + pow (t, 3)* d->x;
p->y = pow((1 - t), 3) * a->y + 3 * t * pow((1 -t), 2) * b->y + 3 * (1-t) * pow(t, 2)* c->y + pow (t, 3)* d->y;
}
diff --git a/frontends/amiga/plotters.h b/frontends/amiga/plotters.h
index 7baa21f..7cb994f 100644
--- a/frontends/amiga/plotters.h
+++ b/frontends/amiga/plotters.h
@@ -18,7 +18,8 @@
#ifndef AMIGA_PLOTTERS_H
#define AMIGA_PLOTTERS_H
-#include "desktop/plotters.h"
+
+#include "netsurf/plotters.h"
#include <proto/layers.h>
#include <proto/graphics.h>
@@ -44,6 +45,8 @@ struct gui_globals
extern const struct plotter_table amiplot;
+extern struct gui_globals *glob;
+
void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool force32bit);
void ami_free_layers(struct gui_globals *gg);
void ami_clearclipreg(struct gui_globals *gg);
@@ -51,5 +54,4 @@ void ami_plot_clear_bbox(struct RastPort *rp, struct IBox *bbox);
void ami_plot_release_pens(struct MinList *shared_pens);
bool ami_plot_screen_is_palettemapped(void);
-struct gui_globals *glob;
#endif
diff --git a/frontends/amiga/plugin_hack.c b/frontends/amiga/plugin_hack.c
index 21f4da1..7fe78b9 100644
--- a/frontends/amiga/plugin_hack.c
+++ b/frontends/amiga/plugin_hack.c
@@ -23,19 +23,20 @@
#include "amiga/os3support.h"
#include <stdlib.h>
+#include <proto/dos.h>
+#include <proto/exec.h>
+#include <proto/intuition.h>
+#include <proto/utility.h>
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "netsurf/plotters.h"
+#include "netsurf/content.h"
#include "amiga/filetype.h"
#include "amiga/plugin_hack.h"
#include "content/content_protected.h"
-#include "content/hlcache.h"
-#include "desktop/plotters.h"
-#include "utils/log.h"
-#include "utils/messages.h"
+#include "content/llcache.h"
-#include <proto/dos.h>
-#include <proto/exec.h>
-#include <proto/intuition.h>
-#include <proto/utility.h>
typedef struct amiga_plugin_hack_content {
struct content base;
diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c
index fcccc91..5fab0f9 100644
--- a/frontends/amiga/print.c
+++ b/frontends/amiga/print.c
@@ -49,13 +49,14 @@
#include "utils/nsoption.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "desktop/plotters.h"
+#include "utils/nsurl.h"
+#include "netsurf/plotters.h"
+#include "netsurf/layout.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
+#include "netsurf/content.h"
#include "desktop/printer.h"
#include "desktop/print.h"
-#include "desktop/gui_layout.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
-#include "content/hlcache.h"
#include "amiga/plotters.h"
#include "amiga/font.h"
@@ -95,6 +96,14 @@ struct ami_printer_info
struct Window *win;
};
+struct ami_print_window {
+ struct ami_generic_window w;
+ struct Window *win;
+ Object *objects[OID_LAST];
+ Object *gadgets[GID_LAST];
+ struct hlcache_handle *c;
+};
+
enum
{
PGID_MAIN=0,
@@ -118,6 +127,13 @@ static struct ami_printer_info ami_print_info;
static CONST_STRPTR gadlab[PGID_LAST];
static STRPTR printers[11];
+static BOOL ami_print_event(void *w);
+
+static const struct ami_win_event_table ami_print_table = {
+ ami_print_event,
+ NULL, /* we don't explicitly close the print window on quit (or at all???) */
+};
+
static void ami_print_ui_setup(void)
{
gadlab[PGID_PRINTER] = (char *)ami_utf8_easy((char *)messages_get("Printer"));
@@ -132,11 +148,11 @@ static void ami_print_ui_free(void)
int i;
for(i = 0; i < PGID_LAST; i++) {
- if(gadlab[i]) FreeVec((APTR)gadlab[i]);
+ if(gadlab[i]) free((APTR)gadlab[i]);
}
for(i = 0; i < 10; i++) {
- if(printers[i]) FreeVec(printers[i]);
+ if(printers[i]) free(printers[i]);
}
}
@@ -226,21 +242,21 @@ void ami_print_ui(struct hlcache_handle *c)
char filename[30];
int i;
- struct ami_print_window *pw = ami_misc_allocvec_clear(sizeof(struct ami_print_window), 0);
+ struct ami_print_window *pw = calloc(1, sizeof(struct ami_print_window));
pw->c = c;
- printers[0] = ami_misc_allocvec_clear(50, 0);
+ printers[0] = calloc(1, 50);
ami_print_readunit("ENV:Sys/printer.prefs", printers[0], 50, 0);
strcpy(filename,"ENV:Sys/printerN.prefs");
for (i = 1; i < 10; i++)
{
filename[15] = '0' + i;
- printers[i] = AllocVecTagList(50, NULL);
+ printers[i] = malloc(50);
if(!ami_print_readunit(filename, printers[i], 50, i))
{
- FreeVec(printers[i]);
+ free(printers[i]);
printers[i] = NULL;
break;
}
@@ -324,22 +340,21 @@ void ami_print_ui(struct hlcache_handle *c)
EndWindow;
pw->win = (struct Window *)RA_OpenWindow(pw->objects[OID_MAIN]);
-
- pw->node = AddObject(window_list, AMINS_PRINTWINDOW);
- pw->node->objstruct = pw;
+ ami_gui_win_list_add(pw, AMINS_PRINTWINDOW, &ami_print_table);
}
static void ami_print_close(struct ami_print_window *pw)
{
DisposeObject(pw->objects[OID_MAIN]);
- DelObject(pw->node);
+ ami_gui_win_list_remove(pw);
ami_print_ui_free();
}
-BOOL ami_print_event(struct ami_print_window *pw)
+static BOOL ami_print_event(void *w)
{
/* return TRUE if window destroyed */
+ struct ami_print_window *pw = (struct ami_print_window *)w;
ULONG result;
uint16 code;
struct hlcache_handle *c;
@@ -447,7 +462,7 @@ bool ami_print_cont(void)
glob = ami_print_info.gg;
print_draw_next_page(&amiprinter, ami_print_info.ps);
ami_print_dump();
- glob = &browserglob;
+ ami_gui_set_default_gg();
ret = true;
}
else
@@ -481,7 +496,7 @@ struct MsgPort *ami_print_get_msgport(void)
bool ami_print_begin(struct print_settings *ps)
{
- ami_print_info.gg = ami_misc_allocvec_clear(sizeof(struct gui_globals), 0);
+ ami_print_info.gg = calloc(1, sizeof(struct gui_globals));
if(!ami_print_info.gg) return false;
ami_init_layers(ami_print_info.gg,
@@ -508,9 +523,9 @@ bool ami_print_next_page(void)
void ami_print_end(void)
{
ami_free_layers(ami_print_info.gg);
- FreeVec(ami_print_info.gg);
+ free(ami_print_info.gg);
DisposeObject(ami_print_info.objects[OID_MAIN]);
- glob = &browserglob;
+ ami_gui_set_default_gg();
ami_print_close_device();
ami_print_free();
diff --git a/frontends/amiga/print.h b/frontends/amiga/print.h
index bdd409b..0d6b4f5 100755
--- a/frontends/amiga/print.h
+++ b/frontends/amiga/print.h
@@ -21,18 +21,10 @@
#include <proto/exec.h>
struct content;
-
-struct ami_print_window {
- struct nsObject *node;
- struct Window *win;
- Object *objects[OID_LAST];
- Object *gadgets[GID_LAST];
- struct hlcache_handle *c;
-};
+struct ami_print_window;
void ami_print(struct hlcache_handle *c, int copies);
void ami_print_ui(struct hlcache_handle *c);
-BOOL ami_print_event(struct ami_print_window *pw);
bool ami_print_cont(void);
struct MsgPort *ami_print_init(void);
void ami_print_free(void);
diff --git a/frontends/amiga/resources/SearchEngines b/frontends/amiga/resources/SearchEngines
deleted file mode 100644
index f1b705a..0000000
--- a/frontends/amiga/resources/SearchEngines
+++ /dev/null
@@ -1,22 +0,0 @@
-Google|www.google.com|http://www.google.com/search?q=%s|http://www.google.com/favicon.ico|
-Yahoo|search.yahoo.com|http://search.yahoo.com/search?p=%s|http://www.yahoo.com/favicon.ico|
-Bing|www.bing.com|http://www.bing.com/search?q=%s|http://www.bing.com/favicon.ico|
-Business.com|www.business.com|http://www.business.com/search/rslt_default.asp?query=%s|http://www.business.com/favicon.ico|
-Omgili|www.omgili.com|http://www.omgili.com/AAAAA/%s.html|http://www.omgili.com/favicon.ico|
-BBC News|search.bbc.co.uk|http://search.bbc.co.uk/search?q=%s&tab=ns|http://news.bbc.co.uk/favicon.ico|
-Creative Commons|creativecommons.org|http://creativecommons.org/?s=%s|http://creat...
-Ask.com|www.ask.com|http://www.ask.com/web?q=%s|http://www.ask.com/favicon.ico|
-Answers.com|www.answers.com|http://www.answers.com/%s|http://www.answers.com/favicon.ico|
-Dictionary.com|dictionary.reference.com|http://dictionary.reference.com/browse/%s?jss=0|http://dictionary.reference.com/favicon.ico|
-Youtube|www.youtube.com|http://www.youtube.com/results?search_query=%s|http://www.youtube.com/favicon.ico|
-AeroMp3|www.aeromp3.com|http://www.aeromp3.com/search?q=%s|http://www.aeromp3.com/favicon.ico|
-AOL|search.aol.com|http://search.aol.com/aol/search?query=%s|http://www.aol.com/favicon.ico|
-Baidu|www.baidu.com|http://www.baidu.com/s?wd=%s|http://www.baidu.com/favicon.ico|
-Amazon|www.amazon.com|http://www.amazon.com/s/ref=nb_ss_gw?field-keywords=%s|http://www.amazon.com/favicon.ico|
-Ebay|shop.ebay.com|http://shop.ebay.com/items/%s|http://www.ebay.com/favicon.ico|
-IMDB|www.imdb.com|http://www.imdb.com/find?q=%s|http://www.imdb.com/favicon.ico|
-ESPN|search.espn.go.com|http://search.espn.go.com/%s/|http://www.espn.go.com/favicon.ico|
-Wikipedia|en.wikipedia.org|http://en.wikipedia.org/w/index.php?title=Special%%3ASearch&search=%s|http://en.wikipedia.org/favicon.ico|
-Aminet|www.aminet.net|http://aminet.net/search?query=%s|http://aminet.net/favicon.ico|
-OS4Depot|www.os4depot.net|http://www.os4depot.net/index.php?function=search&tool=simple&f_fields=%s|http://www.os4depot.net/favicon.ico|
-DuckDuckGo|www.duckduckgo.com|http://www.duckduckgo.com/?q=%s|http://www.duckduckgo.com/favicon.ico|
diff --git a/frontends/amiga/schedule.c b/frontends/amiga/schedule.c
old mode 100755
new mode 100644
index e34c000..bfafe9c
--- a/frontends/amiga/schedule.c
+++ b/frontends/amiga/schedule.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 - 2014 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008 - 2016 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -21,6 +21,7 @@
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/timer.h>
+#include <proto/utility.h> /* For Amiga2Date */
#include <stdio.h>
#include <stdbool.h>
@@ -29,26 +30,25 @@
#include "utils/errors.h"
#include "utils/log.h"
-#include "amiga/misc.h"
+#include "amiga/memory.h"
#include "amiga/schedule.h"
-static struct TimeRequest *tioreq;
+struct nscallback
+{
+ struct TimeRequest timereq;
+ struct TimeVal tv; /* time we expect the event to occur */
+ void *restrict callback;
+ void *restrict p;
+};
+
+static struct nscallback *tioreq;
struct Device *TimerBase;
#ifdef __amigaos4__
struct TimerIFace *ITimer;
+#else
+static struct MsgPort *schedule_msgport = NULL;
#endif
-static APTR pool_nscb = NULL;
-static APTR pool_timereq = NULL;
-
-struct nscallback
-{
- struct TimeVal tv;
- void *callback;
- void *p;
- struct TimeRequest *treq;
-};
-
static PblHeap *schedule_list;
/**
@@ -63,14 +63,10 @@ static void ami_schedule_remove_timer_event(struct nscallback *nscb)
{
if(!nscb) return;
- if(nscb->treq)
- {
- if(CheckIO((struct IORequest *)nscb->treq)==NULL)
- AbortIO((struct IORequest *)nscb->treq);
+ if(CheckIO((struct IORequest *)nscb)==NULL)
+ AbortIO((struct IORequest *)nscb);
- WaitIO((struct IORequest *)nscb->treq);
- ami_misc_itempool_free(pool_timereq, nscb->treq, sizeof(struct TimeRequest));
- }
+ WaitIO((struct IORequest *)nscb);
}
/**
@@ -87,21 +83,16 @@ static nserror ami_schedule_add_timer_event(struct nscallback *nscb, int t)
struct TimeVal tv;
ULONG time_us = t * 1000; /* t converted to �s */
- nscb->tv.Seconds = time_us / 1000000;
- nscb->tv.Microseconds = time_us % 1000000;
+ tv.Seconds = time_us / 1000000;
+ tv.Microseconds = time_us % 1000000;
- GetSysTime(&tv);
- AddTime(&nscb->tv,&tv); // now contains time when event occurs
-
- if((nscb->treq = ami_misc_itempool_alloc(pool_timereq, sizeof(struct TimeRequest)))) {
- *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);
- } else {
- return NSERROR_NOMEM;
- }
+ GetSysTime(&nscb->tv);
+ AddTime(&nscb->tv, &tv); // now contains time when event occurs (for debug and heap sorting)
+
+ nscb->timereq.Request.io_Command = TR_ADDREQUEST;
+ nscb->timereq.Time.Seconds = tv.Seconds; // secs
+ nscb->timereq.Time.Microseconds = tv.Microseconds; // micro
+ SendIO((struct IORequest *)nscb);
return NSERROR_OK;
}
@@ -166,19 +157,20 @@ static nserror ami_schedule_reschedule(struct nscallback *nscb, int t)
*
* \param callback callback function
* \param p user parameter, passed to callback function
+ * \param abort abort pending timer
*
* All scheduled callbacks matching both callback and p are removed.
*/
-static nserror schedule_remove(void (*callback)(void *p), void *p)
+static nserror schedule_remove(void (*callback)(void *p), void *p, bool abort)
{
struct nscallback *nscb;
nscb = ami_schedule_locate(callback, p, true);
if(nscb != NULL) {
- ami_schedule_remove_timer_event(nscb);
- ami_misc_itempool_free(pool_nscb, nscb, sizeof(struct nscallback));
+ if(abort == true) ami_schedule_remove_timer_event(nscb);
+ FreeSysObject(ASOT_IOREQUEST, nscb);
pblHeapConstruct(schedule_list);
}
@@ -198,7 +190,7 @@ static void schedule_remove_all(void)
{
ami_schedule_remove_timer_event(nscb);
pblIteratorRemove(iterator);
- ami_misc_itempool_free(pool_nscb, nscb, sizeof(struct nscallback));
+ FreeSysObject(ASOT_IOREQUEST, nscb);
};
pblIteratorFree(iterator);
@@ -209,62 +201,79 @@ static int ami_schedule_compare(const void *prev, const void *next)
struct nscallback *nscb1 = *(struct nscallback **)prev;
struct nscallback *nscb2 = *(struct nscallback **)next;
+ /**\todo a heap probably isn't the best idea now */
return CmpTime(&nscb1->tv, &nscb2->tv);
}
+/* Outputs all scheduled events to the log */
+static void ami_schedule_dump(void)
+{
+ PblIterator *iterator;
+ struct nscallback *nscb;
+ struct ClockData clockdata;
+
+ if(pblHeapIsEmpty(schedule_list)) return;
+
+ struct TimeVal tv;
+ GetSysTime(&tv);
+ Amiga2Date(tv.Seconds, &clockdata);
+
+ LOG("Current time = %d-%d-%d %d:%d:%d.%d", clockdata.mday, clockdata.month, clockdata.year,
+ clockdata.hour, clockdata.min, clockdata.sec, tv.Microseconds);
+ LOG("Events remaining in queue:");
+
+ iterator = pblHeapIterator(schedule_list);
+
+ while ((nscb = pblIteratorNext(iterator)) != -1)
+ {
+ Amiga2Date(nscb->tv.Seconds, &clockdata);
+ LOG("nscb: %p, at %d-%d-%d %d:%d:%d.%d, callback: %p, %p",
+ nscb, clockdata.mday, clockdata.month, clockdata.year, clockdata.hour, clockdata.min, clockdata.sec,
+ nscb->tv.Microseconds, nscb->callback, nscb->p);
+ if(CheckIO((struct IORequest *)nscb) == NULL) {
+ LOG("-> ACTIVE");
+ } else {
+ LOG("-> COMPLETE");
+ }
+ };
+
+ pblIteratorFree(iterator);
+}
/**
- * Process events up to current time.
+ * Process signalled event
*
- * 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.
+ * This implementation only processes the callback that arrives in the message from timer.device.
*/
-static void ami_scheduler_run(void)
+static bool ami_scheduler_run(struct nscallback *nscb)
{
- struct nscallback *nscb;
- struct TimeVal tv;
void (*callback)(void *p);
void *p;
- nscb = pblHeapGetFirst(schedule_list);
- if(nscb == -1) return;
-
- /* Ensure the scheduled event time has passed (CmpTime<=0)
- * in case something been deleted between the timer
- * signalling us and us responding to it.
- */
- GetSysTime(&tv);
- if(CmpTime(&tv, &nscb->tv) > 0) return;
-
callback = nscb->callback;
p = nscb->p;
- ami_schedule_remove_timer_event(nscb);
- pblHeapRemoveFirst(schedule_list);
- ami_misc_itempool_free(pool_nscb, nscb, sizeof(struct nscallback));
+ schedule_remove(callback, p, false); /* this does a lookup as we don't know if we're the first item on the heap */
- LOG("Running scheduled callback %p with arg %p", callback, p);
callback(p);
-
- return;
+ return true;
}
static void ami_schedule_open_timer(struct MsgPort *msgport)
{
#ifdef __amigaos4__
- tioreq = (struct TimeRequest *)AllocSysObjectTags(ASOT_IOREQUEST,
- ASOIOR_Size,sizeof(struct TimeRequest),
- ASOIOR_ReplyPort,msgport,
- ASO_NoTrack,FALSE,
+ tioreq = (struct nscallback *)AllocSysObjectTags(ASOT_IOREQUEST,
+ ASOIOR_Size, sizeof(struct nscallback),
+ ASOIOR_ReplyPort, msgport,
+ ASO_NoTrack, FALSE,
TAG_DONE);
#else
- tioreq = (struct TimeRequest *)CreateIORequest(msgport, sizeof(struct TimeRequest));
+ tioreq = (struct nscallback *)CreateIORequest(msgport, sizeof(struct nscallback));
#endif
- OpenDevice("timer.device", UNIT_WAITUNTIL, (struct IORequest *)tioreq, 0);
+ OpenDevice("timer.device", UNIT_VBLANK, (struct IORequest *)tioreq, 0);
- TimerBase = (struct Device *)tioreq->Request.io_Device;
+ TimerBase = (struct Device *)tioreq->timereq.Request.io_Device;
#ifdef __amigaos4__
ITimer = (struct TimerIFace *)GetInterface((struct Library *)TimerBase, "main", 1, NULL);
#endif
@@ -282,10 +291,10 @@ static void ami_schedule_close_timer(void)
/* exported interface documented in amiga/schedule.h */
nserror ami_schedule_create(struct MsgPort *msgport)
{
- pool_nscb = ami_misc_itempool_create(sizeof(struct nscallback));
- pool_timereq = ami_misc_itempool_create(sizeof(struct TimeRequest));
-
ami_schedule_open_timer(msgport);
+#ifndef __amigaos4__
+ schedule_msgport = msgport;
+#endif
schedule_list = pblHeapNew();
if(schedule_list == PBL_ERROR_OUT_OF_MEMORY) return NSERROR_NOMEM;
@@ -297,14 +306,12 @@ nserror ami_schedule_create(struct MsgPort *msgport)
/* exported interface documented in amiga/schedule.h */
void ami_schedule_free(void)
{
+ ami_schedule_dump();
schedule_remove_all();
pblHeapFree(schedule_list); // this should be empty at this point
schedule_list = NULL;
ami_schedule_close_timer();
-
- ami_misc_itempool_delete(pool_timereq);
- ami_misc_itempool_delete(pool_nscb);
}
/* exported function documented in amiga/schedule.h */
@@ -312,14 +319,23 @@ nserror ami_schedule(int t, void (*callback)(void *p), void *p)
{
struct nscallback *nscb;
+ if(t == 0) t = 1;
+
if(schedule_list == NULL) return NSERROR_INIT_FAILED;
- if(t < 0) return schedule_remove(callback, p);
+ if(t < 0) return schedule_remove(callback, p, true);
if ((nscb = ami_schedule_locate(callback, p, false))) {
return ami_schedule_reschedule(nscb, t);
}
- nscb = ami_misc_itempool_alloc(pool_nscb, sizeof(struct nscallback));
+#ifdef __amigaos4__
+ nscb = AllocSysObjectTags(ASOT_IOREQUEST,
+ ASOIOR_Duplicate, tioreq,
+ TAG_DONE);
+#else
+ nscb = (struct nscallback *)CreateIORequest(schedule_msgport, sizeof(struct nscallback));
+ *nscb = *tioreq;
+#endif
if(!nscb) return NSERROR_NOMEM;
if (ami_schedule_add_timer_event(nscb, t) != NSERROR_OK)
@@ -337,17 +353,13 @@ nserror ami_schedule(int t, void (*callback)(void *p), void *p)
/* exported interface documented in amiga/schedule.h */
void ami_schedule_handle(struct MsgPort *nsmsgport)
{
- /* nsmsgport is the NetSurf message port that the scheduler task
- * (or timer.device in no-async mode) is sending messages to. */
+ /* nsmsgport is the NetSurf message port that
+ * timer.device is sending messages to. */
- struct TimerRequest *timermsg;
+ struct nscallback *timermsg;
- while((timermsg = (struct TimerRequest *)GetMsg(nsmsgport))) {
- /* reply first, as we don't need the message contents and
- * it crashes if we reply after schedule_run has executed.
- */
- ReplyMsg((struct Message *)timermsg);
- ami_scheduler_run();
- }
+ while((timermsg = (struct nscallback *)GetMsg(nsmsgport))) {
+ ami_scheduler_run(timermsg);
+ };
}
diff --git a/frontends/amiga/schedule.h b/frontends/amiga/schedule.h
index fb648ea..199e6db 100755
--- a/frontends/amiga/schedule.h
+++ b/frontends/amiga/schedule.h
@@ -19,6 +19,7 @@
#ifndef AMIGA_SCHEDULE_H
#define AMIGA_SCHEDULE_H
#include "amiga/os3support.h"
+#include "utils/errors.h"
/**
* Schedule a callback.
diff --git a/frontends/amiga/search.c b/frontends/amiga/search.c
index 5ca9792..99ee5b4 100755
--- a/frontends/amiga/search.c
+++ b/frontends/amiga/search.c
@@ -27,6 +27,7 @@
#include "utils/config.h"
#include <ctype.h>
#include <string.h>
+#include <stdlib.h>
#include <proto/intuition.h>
#include <proto/exec.h>
@@ -48,14 +49,15 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "content/content.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#include "desktop/search.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
-#include "desktop/gui_search.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
+#include "netsurf/search.h"
#include "amiga/libs.h"
-#include "amiga/misc.h"
+#include "amiga/gui.h"
+#include "amiga/memory.h"
#include "amiga/search.h"
#include "amiga/object.h"
#include "amiga/theme.h"
@@ -66,6 +68,13 @@
static bool search_insert;
+struct find_window {
+ struct ami_generic_window w;
+ struct Window *win;
+ Object *objects[GID_LAST];
+ struct gui_window *gwin;
+};
+
static struct find_window *fwin = NULL;
search_flags_t ami_search_flags(void);
@@ -75,6 +84,7 @@ static void ami_search_set_hourglass(bool active, void *p);
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 BOOL ami_search_event(void *w);
static struct gui_search_table search_table = {
ami_search_set_status,
@@ -84,8 +94,21 @@ static struct gui_search_table search_table = {
ami_search_set_back_state,
};
+static const struct ami_win_event_table ami_search_table = {
+ ami_search_event,
+ NULL, /* we don't explicitly close the search window on quit */
+};
+
struct gui_search_table *amiga_search_table = &search_table;
+struct gui_window *ami_search_get_gwin(struct find_window *fw)
+{
+ if (fw != NULL) {
+ return fw->gwin;
+ }
+ return NULL;
+}
+
/**
* Change the displayed search status.
*
@@ -106,7 +129,7 @@ void ami_search_open(struct gui_window *gwin)
return;
}
- fwin = ami_misc_allocvec_clear(sizeof(struct find_window), 0);
+ fwin = calloc(1, sizeof(struct find_window));
fwin->objects[OID_MAIN] = WindowObj,
WA_ScreenTitle, ami_gui_get_screen_title(),
@@ -167,8 +190,7 @@ void ami_search_open(struct gui_window *gwin)
fwin->win = (struct Window *)RA_OpenWindow(fwin->objects[OID_MAIN]);
fwin->gwin = gwin;
- fwin->node = AddObject(window_list,AMINS_FINDWINDOW);
- fwin->node->objstruct = fwin;
+ ami_gui_win_list_add(fwin, AMINS_FINDWINDOW, &ami_search_table);
gwin->shared->searchwin = fwin;
ActivateLayoutGadget((struct Gadget *)fwin->objects[GID_MAIN], fwin->win,
@@ -180,11 +202,11 @@ void ami_search_close(void)
browser_window_search_clear(fwin->gwin->bw);
fwin->gwin->shared->searchwin = NULL;
DisposeObject(fwin->objects[OID_MAIN]);
- DelObject(fwin->node);
- fwin=NULL;
+ ami_gui_win_list_remove(fwin);
+ fwin = NULL;
}
-BOOL ami_search_event(void)
+static BOOL ami_search_event(void *w)
{
/* return TRUE if window destroyed */
ULONG result;
diff --git a/frontends/amiga/search.h b/frontends/amiga/search.h
index c4f30eb..f30352c 100755
--- a/frontends/amiga/search.h
+++ b/frontends/amiga/search.h
@@ -19,19 +19,26 @@
#ifndef AMIGA_SEARCH_H
#define AMIGA_SEARCH_H
-#include "amiga/gui.h"
-
-struct find_window {
- struct nsObject *node;
- struct Window *win;
- Object *objects[GID_LAST];
- struct gui_window *gwin;
-};
+struct gui_search_table;
+struct gui_window;
struct gui_search_table *amiga_search_table;
+/**
+ * Change the displayed search status.
+ *
+ * \param gwin gui window to open search for.
+ */
void ami_search_open(struct gui_window *gwin);
-BOOL ami_search_event(void);
+
+/**
+ * Close search
+ */
void ami_search_close(void);
+/**
+ * Obtain gui window associated with find window.
+ */
+struct gui_window *ami_search_get_gwin(struct find_window *fw);
+
#endif
diff --git a/frontends/amiga/selectmenu.c b/frontends/amiga/selectmenu.c
index 2593178..f3a11b6 100644
--- a/frontends/amiga/selectmenu.c
+++ b/frontends/amiga/selectmenu.c
@@ -28,8 +28,8 @@
#include "utils/errors.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "render/form.h"
-#include "desktop/mouse.h"
+#include "netsurf/form.h"
+#include "netsurf/mouse.h"
#include "amiga/gui.h"
#include "amiga/selectmenu.h"
diff --git a/frontends/amiga/selectmenu.h b/frontends/amiga/selectmenu.h
index f55b6ca..920b7e7 100755
--- a/frontends/amiga/selectmenu.h
+++ b/frontends/amiga/selectmenu.h
@@ -24,8 +24,6 @@
struct gui_window;
struct form_control;
-BOOL popupmenu_lib_ok;
-
void gui_create_form_select_menu(struct gui_window *g, struct form_control *control);
/**
diff --git a/frontends/amiga/sslcert.c b/frontends/amiga/sslcert.c
index 699ce71..83798f2 100644
--- a/frontends/amiga/sslcert.c
+++ b/frontends/amiga/sslcert.c
@@ -20,14 +20,14 @@
#include "utils/nsurl.h"
#include "content/llcache.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
#include "desktop/sslcert_viewer.h"
#include "amiga/tree.h"
#include "amiga/sslcert.h"
-void gui_cert_verify(nsurl *url,
+nserror gui_cert_verify(nsurl *url,
const struct ssl_cert_info *certs, unsigned long num,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
@@ -39,9 +39,13 @@ void gui_cert_verify(nsurl *url,
ssl_current_session = data;
ssl_window = ami_tree_create(TREE_SSLCERT, data);
- if(!ssl_window) return;
+ if (!ssl_window) {
+ return NSERROR_INIT_FAILED;
+ }
ami_tree_open(ssl_window, AMI_TREE_SSLCERT);
+
+ return NSERROR_OK;
}
void ami_ssl_free(struct treeview_window *twin)
diff --git a/frontends/amiga/sslcert.h b/frontends/amiga/sslcert.h
index 953142e..86ce9c4 100644
--- a/frontends/amiga/sslcert.h
+++ b/frontends/amiga/sslcert.h
@@ -19,7 +19,7 @@
#ifndef AMIGA_SSLCERT_H
#define AMIGA_SSLCERT_H
-void gui_cert_verify(nsurl *url,
+nserror gui_cert_verify(nsurl *url,
const struct ssl_cert_info *certs, unsigned long num,
nserror (*cb)(bool proceed, void *pw), void *cbpw);
diff --git a/frontends/amiga/stringview/urlhistory.c b/frontends/amiga/stringview/urlhistory.c
index c58a377..7405fbb 100644
--- a/frontends/amiga/stringview/urlhistory.c
+++ b/frontends/amiga/stringview/urlhistory.c
@@ -26,10 +26,11 @@
#include "amiga/os3support.h"
-#include "urlhistory.h"
-
-#include "content/urldb.h"
#include "utils/nsoption.h"
+#include "utils/nsurl.h"
+#include "netsurf/url_db.h"
+
+#include "urlhistory.h"
static struct List PageList;
diff --git a/frontends/amiga/theme.c b/frontends/amiga/theme.c
index ab32b23..496fc54 100644
--- a/frontends/amiga/theme.c
+++ b/frontends/amiga/theme.c
@@ -41,8 +41,8 @@
#include "utils/nsoption.h"
#include "utils/utils.h"
#include "desktop/searchweb.h"
-#include "desktop/mouse.h"
-#include "desktop/gui_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/window.h"
#include "amiga/gui.h"
#include "amiga/drag.h"
@@ -51,9 +51,9 @@
#include "amiga/theme.h"
#include "amiga/misc.h"
-struct BitMap *throbber = NULL;
-struct bitmap *throbber_nsbm = NULL;
-int throbber_frames, throbber_update_interval;
+static struct BitMap *throbber = NULL;
+static struct bitmap *throbber_nsbm = NULL;
+static int throbber_frames, throbber_update_interval;
static Object *mouseptrobj[AMI_LASTPOINTER+1];
static struct BitMap *mouseptrbm[AMI_LASTPOINTER+1];
@@ -158,6 +158,16 @@ void ami_theme_init(void)
}
}
+int ami_theme_throbber_get_width(void)
+{
+ return bitmap_get_width(throbber_nsbm) / throbber_frames;
+}
+
+int ami_theme_throbber_get_height(void)
+{
+ return bitmap_get_height(throbber_nsbm);
+}
+
void ami_theme_throbber_setup(void)
{
char throbberfile[1024];
@@ -171,8 +181,6 @@ void ami_theme_throbber_setup(void)
bm = ami_bitmap_from_datatype(throbberfile);
throbber = ami_bitmap_get_native(bm, bitmap_get_width(bm), bitmap_get_height(bm), NULL);
- throbber_width = bitmap_get_width(bm) / throbber_frames;
- throbber_height = bitmap_get_height(bm);
throbber_nsbm = bm;
}
@@ -221,7 +229,7 @@ void ami_reset_pointer(struct gui_window_2 *gwin)
void ami_update_pointer(struct Window *win, gui_pointer_shape shape)
{
- if(drag_save_data) return;
+ if(ami_drag_has_data()) return; /**\todo check this shouldn't be drag_in_progress */
if(LIB_IS_AT_LEAST((struct Library *)IntuitionBase, 53, 42)) {
#ifdef __amigaos4__
@@ -355,13 +363,13 @@ void ami_init_mouse_pointers(void)
if((ptrfile = Open(ptrfname,MODE_OLDFILE)))
{
int mx,my;
- UBYTE *pprefsbuf = AllocVecTagList(1061, NULL);
- Read(ptrfile,pprefsbuf,1061);
+ UBYTE *pprefsbuf = malloc(1061);
+ Read(ptrfile, pprefsbuf, 1061);
- mouseptrbm[i]=AllocVecTagList(sizeof(struct BitMap), NULL);
- InitBitMap(mouseptrbm[i],2,32,32);
- mouseptrbm[i]->Planes[0] = AllocRaster(32,32);
- mouseptrbm[i]->Planes[1] = AllocRaster(32,32);
+ mouseptrbm[i] = malloc(sizeof(struct BitMap));
+ InitBitMap(mouseptrbm[i], 2, 32, 32);
+ mouseptrbm[i]->Planes[0] = AllocRaster(32, 32);
+ mouseptrbm[i]->Planes[1] = AllocRaster(32, 32);
mouseptr.BitMap = mouseptrbm[i];
for(my=0;my<32;my++)
@@ -385,7 +393,7 @@ void ami_init_mouse_pointers(void)
POINTERA_YResolution,POINTERYRESN_SCREENRESASPECT,
TAG_DONE);
- FreeVec(pprefsbuf);
+ free(pprefsbuf);
Close(ptrfile);
}
@@ -406,7 +414,7 @@ void ami_mouse_pointers_free(void)
{
FreeRaster(mouseptrbm[i]->Planes[0],32,32);
FreeRaster(mouseptrbm[i]->Planes[1],32,32);
- FreeVec(mouseptrbm[i]);
+ free(mouseptrbm[i]);
}
}
}
@@ -452,9 +460,12 @@ void gui_window_stop_throbber(struct gui_window *g)
return;
}
- BltBitMapRastPort(throbber, 0, 0, g->shared->win->RPort, bbox->Left,
- bbox->Top, throbber_width, throbber_height, 0x0C0);
-
+ if(throbber != NULL) {
+ BltBitMapRastPort(throbber, 0, 0, g->shared->win->RPort,
+ bbox->Left, bbox->Top,
+ ami_theme_throbber_get_width(), ami_theme_throbber_get_height(),
+ 0x0C0);
+ }
ami_gui_free_space_box(bbox);
}
@@ -483,23 +494,29 @@ static void ami_throbber_update(void *p)
amiga_warn_user("NoMemory", "");
return;
}
+
+ if(throbber != NULL) {
#ifdef __amigaos4__
- BltBitMapTags(BLITA_SrcX, throbber_width * frame,
- BLITA_SrcY, 0,
- BLITA_DestX, bbox->Left,
- BLITA_DestY, bbox->Top,
- BLITA_Width, throbber_width,
- BLITA_Height, throbber_height,
- BLITA_Source, throbber,
- BLITA_Dest, g->shared->win->RPort,
- BLITA_SrcType, BLITT_BITMAP,
- BLITA_DestType, BLITT_RASTPORT,
- // BLITA_UseSrcAlpha, TRUE,
+ BltBitMapTags(BLITA_SrcX, ami_theme_throbber_get_width() * frame,
+ BLITA_SrcY, 0,
+ BLITA_DestX, bbox->Left,
+ BLITA_DestY, bbox->Top,
+ BLITA_Width, ami_theme_throbber_get_width(),
+ BLITA_Height, ami_theme_throbber_get_height(),
+ BLITA_Source, throbber,
+ BLITA_Dest, g->shared->win->RPort,
+ BLITA_SrcType, BLITT_BITMAP,
+ BLITA_DestType, BLITT_RASTPORT,
+ // BLITA_UseSrcAlpha, TRUE,
TAG_DONE);
#else
- BltBitMapRastPort(throbber, throbber_width * frame, 0, g->shared->win->RPort,
- bbox->Left, bbox->Top, throbber_width, throbber_height, 0xC0);
+ BltBitMapRastPort(throbber, ami_theme_throbber_get_width() * frame,
+ 0, g->shared->win->RPort,
+ bbox->Left, bbox->Top,
+ ami_theme_throbber_get_width(), ami_theme_throbber_get_height(),
+ 0xC0);
#endif
+ }
ami_gui_free_space_box(bbox);
}
diff --git a/frontends/amiga/theme.h b/frontends/amiga/theme.h
index f295efe..6de7bc1 100644
--- a/frontends/amiga/theme.h
+++ b/frontends/amiga/theme.h
@@ -19,15 +19,21 @@
#ifndef AMIGA_THEME_H
#define AMIGA_THEME_H
+#include "netsurf/mouse.h"
+
+struct gui_window_2;
+struct gui_window;
+
#define AMI_GUI_POINTER_BLANK GUI_POINTER_PROGRESS+1
#define AMI_GUI_POINTER_DRAG GUI_POINTER_PROGRESS+2
#define AMI_LASTPOINTER AMI_GUI_POINTER_DRAG
-ULONG throbber_width, throbber_height;
-
void ami_theme_init(void);
void ami_get_theme_filename(char *filename, const char *themestring, bool protocol);
+int ami_theme_throbber_get_width(void);
+int ami_theme_throbber_get_height(void);
+
void ami_theme_throbber_setup(void);
void ami_theme_throbber_free(void);
void ami_update_throbber(struct gui_window_2 *g,bool redraw);
diff --git a/frontends/amiga/tree.c b/frontends/amiga/tree.c
index f147b5e..f1c5327 100644
--- a/frontends/amiga/tree.c
+++ b/frontends/amiga/tree.c
@@ -53,13 +53,13 @@
#include "utils/nsoption.h"
#include "utils/utils.h"
#include "utils/messages.h"
-#include "content/urldb.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/window.h"
+#include "netsurf/keypress.h"
#include "content/llcache.h"
-#include "desktop/browser.h"
#include "desktop/cookie_manager.h"
#include "desktop/global_history.h"
#include "desktop/hotlist.h"
-#include "desktop/gui_window.h"
#include "desktop/sslcert_viewer.h"
#include "amiga/gui.h"
@@ -73,6 +73,7 @@
#include "amiga/theme.h" /* pointers */
#include "amiga/filetype.h"
#include "amiga/schedule.h"
+#include "amiga/plotters.h"
#define AMI_TREE_MENU_ITEMS 26
#define AMI_TREE_MENU_NEWDIR FULLMENUNUM(1,0,0)
@@ -88,7 +89,7 @@ enum {
struct treeview_window {
- struct nsObject *node;
+ struct ami_generic_window w;
struct Window *win;
Object *objects[GID_TREE_LAST];
int type;
@@ -120,6 +121,13 @@ struct ami_tree_redraw_req {
struct treeview_window *twin;
};
+static BOOL ami_tree_event(void *w);
+
+static const struct ami_win_event_table ami_tree_table = {
+ ami_tree_event,
+ ami_tree_close,
+};
+
#if 0
void ami_tree_draw(struct treeview_window *twin);
static void ami_tree_resized(struct tree *tree, int width,
@@ -131,8 +139,8 @@ static void ami_tree_get_window_dimensions(int *width, int *height, void *data);
void ami_tree_destroy(struct treeview_window *twin)
{
tree_delete(twin->tree);
- FreeVec(twin->shared_pens);
- FreeVec(twin);
+ free(twin->shared_pens);
+ free(twin);
}
struct tree *ami_tree_get_tree(struct treeview_window *twin)
@@ -233,6 +241,7 @@ static void ami_tree_redraw_req_dr(void *p)
if(ami_gui_get_space_box(twin->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
amiga_warn_user("NoMemory", "");
+ free(atrr_data);
return;
}
@@ -256,12 +265,12 @@ static void ami_tree_redraw_req_dr(void *p)
atrr_data->x, atrr_data->y,
atrr_data->width, atrr_data->height, &ctx);
- FreeVec(atrr_data);
+ free(atrr_data);
ami_gui_free_space_box(bbox);
ami_update_pointer(twin->win, GUI_POINTER_DEFAULT);
ami_clearclipreg(glob);
glob->rp = temprp;
- glob = &browserglob;
+ ami_gui_set_default_gg();
}
static void ami_tree_redraw_req(void *p)
@@ -281,6 +290,8 @@ static void ami_tree_redraw_req(void *p)
.plot = &amiplot
};
+ free(atrr_data);
+
if(!twin->win) return;
ami_update_pointer(twin->win, GUI_POINTER_WAIT);
@@ -340,16 +351,15 @@ static void ami_tree_redraw_req(void *p)
}
}
- FreeVec(atrr_data);
ami_gui_free_space_box(bbox);
ami_update_pointer(twin->win, GUI_POINTER_DEFAULT);
ami_clearclipreg(glob);
- glob = &browserglob;
+ ami_gui_set_default_gg();
}
static void ami_tree_redraw_request(int x, int y, int width, int height, void *data)
{
- struct ami_tree_redraw_req *atrr_data = AllocVecTagList(sizeof(struct ami_tree_redraw_req), NULL);
+ struct ami_tree_redraw_req *atrr_data = malloc(sizeof(struct ami_tree_redraw_req));
atrr_data->x = x;
atrr_data->y = y;
@@ -561,7 +571,7 @@ static void ami_tree_menu(struct treeview_window *twin)
{
if(twin->menu) return;
- if((twin->menu = ami_misc_allocvec_clear(sizeof(struct NewMenu) * AMI_TREE_MENU_ITEMS, 0))) {
+ if((twin->menu = calloc(1, sizeof(struct NewMenu) * AMI_TREE_MENU_ITEMS))) {
twin->menu[0].nm_Type = NM_TITLE;
twin->menu_name[0] = ami_utf8_easy((char *)messages_get("Tree"));
twin->menu[0].nm_Label = twin->menu_name[0];
@@ -874,21 +884,21 @@ void ami_tree_open(struct treeview_window *twin,int type)
ICA_TARGET,ICTARGET_IDCMP,
TAG_DONE);
- twin->node = AddObject(window_list,AMINS_TVWINDOW);
- twin->node->objstruct = twin;
+ ami_gui_win_list_add(twin, AMINS_TVWINDOW, &ami_tree_table);
ami_tree_update_buttons(twin);
ami_tree_resized(twin->tree, twin->max_width, twin->max_height, twin);
ami_tree_draw(twin);
}
-void ami_tree_close(struct treeview_window *twin)
+void ami_tree_close(void *w)
{
+ struct treeview_window *twin = (struct treeview_window *)w;
int i;
twin->win = NULL;
DisposeObject(twin->objects[OID_MAIN]);
- DelObjectNoFree(twin->node);
+ ami_gui_win_list_remove(twin);
ami_plot_release_pens(twin->shared_pens);
ami_free_layers(&twin->globals);
@@ -898,7 +908,7 @@ void ami_tree_close(struct treeview_window *twin)
twin->menu_name[i] = NULL;
}
- FreeVec(twin->menu);
+ free(twin->menu);
twin->menu = NULL;
ami_utf8_free(twin->wintitle);
twin->wintitle = NULL;
@@ -939,9 +949,10 @@ static void ami_tree_update_quals(struct treeview_window *twin)
}
}
-BOOL ami_tree_event(struct treeview_window *twin)
+static BOOL ami_tree_event(void *w)
{
/* return TRUE if window destroyed */
+ struct treeview_window *twin = (struct treeview_window *)w;
ULONG result,storage = 0;
uint16 code;
struct MenuItem *item;
@@ -1454,7 +1465,7 @@ struct treeview_window *ami_tree_create(int flags,
{
struct treeview_window *twin;
- twin = ami_misc_allocvec_clear(sizeof(struct treeview_window), 0);
+ twin = calloc(1, sizeof(struct treeview_window));
if(!twin)
{
diff --git a/frontends/amiga/tree.h b/frontends/amiga/tree.h
index 39a71d7..a8cada5 100755
--- a/frontends/amiga/tree.h
+++ b/frontends/amiga/tree.h
@@ -22,7 +22,7 @@
#include <exec/types.h>
#include <intuition/classusr.h>
#include "amiga/os3support.h"
-#include "desktop/tree.h"
+#include "amiga/desktop-tree.h"
struct treeview_window;
@@ -40,8 +40,7 @@ void ami_tree_destroy(struct treeview_window *twin);
struct tree *ami_tree_get_tree(struct treeview_window *twin);
void ami_tree_open(struct treeview_window *twin,int type);
-void ami_tree_close(struct treeview_window *twin);
-BOOL ami_tree_event(struct treeview_window *twin);
+void ami_tree_close(void *w); /* for Arexx interface only */
extern const struct treeview_table ami_tree_callbacks;
diff --git a/frontends/amiga/utf8.c b/frontends/amiga/utf8.c
index 91d7c90..5d05e95 100755
--- a/frontends/amiga/utf8.c
+++ b/frontends/amiga/utf8.c
@@ -16,49 +16,35 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "amiga/os3support.h"
+
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+
#include <proto/exec.h>
-#include <proto/diskfont.h>
-#include <diskfont/diskfonttag.h>
+#include <proto/utility.h>
#include "utils/nsoption.h"
#include "utils/utf8.h"
-#include "desktop/gui_utf8.h"
+#include "netsurf/utf8.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);
-#else
- encname = nsoption_charp(local_charset);
-#endif
-
- return utf8_from_enc(string,encname,len,result,NULL);
+ return utf8_from_enc(string, nsoption_charp(local_charset), 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);
-#else
- encname = nsoption_charp(local_charset);
-#endif
-
- return utf8_to_enc(string,encname,len,result);
+ nserror err = NSERROR_NOMEM;
+ char *local_charset = ASPrintf("%s//IGNORE", nsoption_charp(local_charset));
+ if(local_charset) {
+ err = utf8_to_enc(string, local_charset, len, result);
+ FreeVec(local_charset);
+ }
+ return err;
}
void ami_utf8_free(char *ptr)
@@ -69,13 +55,9 @@ void ami_utf8_free(char *ptr)
char *ami_utf8_easy(const char *string)
{
char *localtext;
-
- if(utf8_to_local_encoding(string,strlen(string),&localtext) == NSERROR_OK)
- {
+ if(utf8_to_local_encoding(string, strlen(string), &localtext) == NSERROR_OK) {
return localtext;
- }
- else
- {
+ } else {
return strdup(string);
}
}
@@ -84,12 +66,9 @@ char *ami_to_utf8_easy(const char *string)
{
char *localtext;
- if(utf8_from_local_encoding(string,strlen(string),&localtext) == NSERROR_OK)
- {
+ if(utf8_from_local_encoding(string, strlen(string), &localtext) == NSERROR_OK) {
return localtext;
- }
- else
- {
+ } else {
return strdup(string);
}
}
diff --git a/frontends/amiga/version.c b/frontends/amiga/version.c
index bc31d0c..c3cd9e2 100644
--- a/frontends/amiga/version.c
+++ b/frontends/amiga/version.c
@@ -18,14 +18,14 @@
#include "testament.h"
-/* NB: AmigaOS revision numbers start at 1 (not 0) and are monotonically
- * incremental (v1.20 is higher than v1.3 and not the same as v1.2).
- * Consequently, this version pair may not match the user-facing one in
- * desktop/version.c. Release revisions are prepended with 6000 to ensure
- * they are higher than CI builds, and make this (slightly) less confusing.
+/* Release revisions are prepended with 6000 so the version numbers below
+ * are same as NetSurf numbering.
+ * CI builds use themselves as the revision.
+ * This means releases have a higher revision than CI builds, and stops
+ * problems created by "0" not being a valid AmigaOS revision number.
*/
#define NETSURF_VERSION_MAJOR "3"
-#define NETSURF_VERSION_MINOR_EXTERNAL "6"
+#define NETSURF_VERSION_MINOR_EXTERNAL "7"
#if defined(CI_BUILD)
#define NETSURF_VERSION_MINOR CI_BUILD
#else
diff --git a/frontends/atari/Makefile.defaults b/frontends/atari/Makefile.defaults
index b738b48..dd04054 100644
--- a/frontends/atari/Makefile.defaults
+++ b/frontends/atari/Makefile.defaults
@@ -18,10 +18,6 @@ NETSURF_USE_RSVG := AUTO
# Valid options: YES, NO, AUTO
NETSURF_USE_NSSVG := AUTO
-# Enable Spidermonkey JavaScript engine
-# Valid options: YES, NO
-NETSURF_USE_MOZJS := NO
-
# Enable building the source object cache filesystem based backing store.
# implementation.
# Valid options: YES, NO
diff --git a/frontends/atari/about.c b/frontends/atari/about.c
index 105037a..c541b0f 100644
--- a/frontends/atari/about.c
+++ b/frontends/atari/about.c
@@ -28,7 +28,7 @@
#include "utils/nsurl.h"
#include "utils/messages.h"
#include "desktop/version.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#include "curl/curlver.h"
diff --git a/frontends/atari/bitmap.c b/frontends/atari/bitmap.c
index a159a66..d0de378 100644
--- a/frontends/atari/bitmap.c
+++ b/frontends/atari/bitmap.c
@@ -24,8 +24,8 @@
#include "utils/nsoption.h"
#include "utils/log.h"
-#include "image/bitmap.h"
-#include "desktop/mouse.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/mouse.h"
#include "atari/bitmap.h"
#include "atari/plot/plot.h"
diff --git a/frontends/atari/certview.c b/frontends/atari/certview.c
index 7f0a295..6950d31 100644
--- a/frontends/atari/certview.c
+++ b/frontends/atari/certview.c
@@ -27,10 +27,7 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "content/urldb.h"
-#include "content/hlcache.h"
#include "desktop/sslcert_viewer.h"
-#include "desktop/core_window.h"
#include "atari/gui.h"
#include "atari/misc.h"
diff --git a/frontends/atari/cookies.c b/frontends/atari/cookies.c
index 6019b47..b7f7309 100644
--- a/frontends/atari/cookies.c
+++ b/frontends/atari/cookies.c
@@ -20,10 +20,9 @@
#include "utils/log.h"
#include "utils/messages.h"
-#include "desktop/mouse.h"
-#include "desktop/plotters.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
#include "desktop/cookie_manager.h"
-#include "desktop/core_window.h"
#include "atari/treeview.h"
#include "atari/cookies.h"
diff --git a/frontends/atari/ctxmenu.c b/frontends/atari/ctxmenu.c
index 0343b20..e25d8e5 100644
--- a/frontends/atari/ctxmenu.c
+++ b/frontends/atari/ctxmenu.c
@@ -19,9 +19,10 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
-#include "desktop/browser.h"
-#include "desktop/textinput.h"
-#include "content/hlcache.h"
+#include "utils/nsurl.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/content.h"
+#include "netsurf/keypress.h"
#include "atari/gui.h"
#include "atari/misc.h"
@@ -50,7 +51,7 @@ struct s_context_info ctxinfo;
static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my )
{
- hlcache_handle *h;
+ struct hlcache_handle *h;
GRECT area;
struct browser_window * bw = gw->browser->bw;
int sx, sy;
diff --git a/frontends/atari/deskmenu.c b/frontends/atari/deskmenu.c
index 7238358..77df4e5 100644
--- a/frontends/atari/deskmenu.c
+++ b/frontends/atari/deskmenu.c
@@ -23,9 +23,9 @@
#include "utils/nsurl.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/keypress.h"
#include "desktop/save_complete.h"
-#include "desktop/textinput.h"
#include "atari/res/netsurf.rsh"
#include "atari/gemtk/gemtk.h"
diff --git a/frontends/atari/download.c b/frontends/atari/download.c
index 9ebe787..3e7a685 100644
--- a/frontends/atari/download.c
+++ b/frontends/atari/download.c
@@ -24,19 +24,17 @@
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
+#include <time.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "utils/string.h"
-#include "content/urldb.h"
-#include "content/fetch.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/download.h"
#include "desktop/save_complete.h"
-#include "desktop/textinput.h"
#include "desktop/download.h"
-#include "desktop/browser.h"
-#include "desktop/gui_download.h"
#include "atari/gui.h"
#include "atari/misc.h"
diff --git a/frontends/atari/encoding.c b/frontends/atari/encoding.c
index 9a16cbd..5997cb0 100644
--- a/frontends/atari/encoding.c
+++ b/frontends/atari/encoding.c
@@ -19,7 +19,7 @@
#include <stdlib.h>
#include "utils/errors.h"
-#include "desktop/gui_utf8.h"
+#include "netsurf/utf8.h"
#include "atari/encoding.h"
diff --git a/frontends/atari/file.c b/frontends/atari/file.c
index 499edd6..235d824 100644
--- a/frontends/atari/file.c
+++ b/frontends/atari/file.c
@@ -112,6 +112,7 @@ static nserror atari_basename(const char *path, char **str, size_t *size)
static nserror atari_nsurl_to_path(struct nsurl *url, char **path_out)
{
lwc_string *urlpath;
+ size_t path_len;
char *path;
bool match;
lwc_string *scheme;
@@ -138,7 +139,10 @@ static nserror atari_nsurl_to_path(struct nsurl *url, char **path_out)
return NSERROR_BAD_PARAMETER;
}
- res = url_unescape(lwc_string_data(urlpath), &path);
+ res = url_unescape(lwc_string_data(urlpath),
+ lwc_string_length(urlpath),
+ &path_len,
+ &path);
lwc_string_unref(urlpath);
if (res != NSERROR_OK) {
return res;
@@ -151,7 +155,7 @@ static nserror atari_nsurl_to_path(struct nsurl *url, char **path_out)
* strlen is *not* copying too much data as we are
* moving the null too!
*/
- memmove(path, path + 1, strlen(path));
+ memmove(path, path + 1, path_len);
}
/* if the path does not have a drive letter we return the
* complete path.
@@ -189,7 +193,7 @@ static nserror atari_path_to_nsurl(const char *path, struct nsurl **url_out)
}
/* escape the path so it can be placed in a url */
- ret = url_escape(path, 0, false, "/", &escpath);
+ ret = url_escape(path, false, "/", &escpath);
if (ret != NSERROR_OK) {
return ret;
}
diff --git a/frontends/atari/filetype.c b/frontends/atari/filetype.c
index 1cce6fc..d27076e 100644
--- a/frontends/atari/filetype.c
+++ b/frontends/atari/filetype.c
@@ -24,7 +24,6 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/log.h"
-#include "content/fetch.h"
#include "atari/filetype.h"
diff --git a/frontends/atari/font.c b/frontends/atari/font.c
index cb0c574..5402e78 100644
--- a/frontends/atari/font.c
+++ b/frontends/atari/font.c
@@ -24,9 +24,9 @@
#include "utils/utf8.h"
#include "utils/log.h"
#include "utils/nsoption.h"
-#include "desktop/gui_layout.h"
-#include "desktop/mouse.h"
-#include "desktop/plotters.h"
+#include "netsurf/layout.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
#include "atari/gui.h"
#include "atari/plot/fontplot.h"
@@ -122,7 +122,7 @@ atari_font_split(const plot_font_style_t *fstyle,
* Measure the width of a string.
*
* \param[in] fstyle plot style for this text
- * \param[in] string UTF-8 string to measure
+ * \param[in] str UTF-8 string to measure
* \param[in] length length of string, in bytes
* \param[out] width updated to width of string[0..length)
* \return NSERROR_OK and width updated or appropriate error code on faliure
@@ -131,7 +131,7 @@ static nserror
atari_font_width(const plot_font_style_t *fstyle,
const char *str,
size_t length,
- int * width)
+ int *width)
{
float scale = plot_get_scale();
diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c
index 810c764..1cf51d3 100644
--- a/frontends/atari/gui.c
+++ b/frontends/atari/gui.c
@@ -29,18 +29,17 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/corestrings.h"
-#include "content/urldb.h"
-#include "content/content.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/layout.h"
+#include "netsurf/window.h"
+#include "netsurf/clipboard.h"
+#include "netsurf/fetch.h"
+#include "netsurf/misc.h"
+#include "netsurf/netsurf.h"
+#include "netsurf/content.h"
+#include "netsurf/cookie_db.h"
+#include "netsurf/url_db.h"
#include "content/backing_store.h"
-#include "content/hlcache.h"
-#include "desktop/treeview.h"
-#include "desktop/browser.h"
-#include "desktop/gui_layout.h"
-#include "desktop/gui_window.h"
-#include "desktop/gui_clipboard.h"
-#include "desktop/gui_fetch.h"
-#include "desktop/gui_misc.h"
-#include "desktop/netsurf.h"
#include "atari/gemtk/gemtk.h"
#include "atari/gui.h"
@@ -663,7 +662,7 @@ gui_window_remove_caret(struct gui_window *w)
* \param icon handle to object to use as icon.
*/
static void
-gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
+gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
{
struct bitmap *bmp_icon;
@@ -771,7 +770,7 @@ static void gui_401login_open(nsurl *url, const char *realm,
}
-static void
+static nserror
gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
@@ -795,7 +794,7 @@ gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
&data);
atari_sslcert_viewer_open(data);
}
-
+ return NSERROR_OK;
}
void gui_set_input_gui_window(struct gui_window *gw)
@@ -828,9 +827,6 @@ static void gui_quit(void)
atari_hotlist_destroy();
atari_cookie_manager_destroy();
- /* shutdown netsurf treeview framework: */
- treeview_fini();
-
/* shutdown the toolbar framework: */
toolbar_exit();
@@ -1037,9 +1033,6 @@ static void gui_init(int argc, char** argv)
}
gemtk_wm_init();
- /* Initialize the netsurf treeview framework with default font size: */
- treeview_init(0);
-
/* Initialize the specific treeview windows: */
atari_global_history_init();
atari_hotlist_init();
diff --git a/frontends/atari/gui.h b/frontends/atari/gui.h
index 50184d0..9c9aaaa 100644
--- a/frontends/atari/gui.h
+++ b/frontends/atari/gui.h
@@ -22,7 +22,7 @@
#include <stdbool.h>
#include <mt_gem.h>
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
#include "atari/redrawslots.h"
#include "atari/gemtk/gemtk.h"
diff --git a/frontends/atari/history.c b/frontends/atari/history.c
index ba72c7f..56aafd0 100644
--- a/frontends/atari/history.c
+++ b/frontends/atari/history.c
@@ -21,9 +21,8 @@
#include "utils/log.h"
#include "utils/messages.h"
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
#include "desktop/global_history.h"
-#include "desktop/core_window.h"
#include "atari/treeview.h"
#include "atari/history.h"
diff --git a/frontends/atari/hotlist.c b/frontends/atari/hotlist.c
index 1130e62..ee9385d 100644
--- a/frontends/atari/hotlist.c
+++ b/frontends/atari/hotlist.c
@@ -26,13 +26,11 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
#include "utils/nsoption.h"
+#include "utils/nsurl.h"
+#include "netsurf/keypress.h"
+#include "content/content.h"
#include "desktop/hotlist.h"
-#include "desktop/tree.h"
-#include "desktop/core_window.h"
#include "atari/gui.h"
#include "atari/misc.h"
@@ -44,6 +42,8 @@
extern GRECT desk_area;
+const char *tree_hotlist_path;
+
struct atari_hotlist hl;
/* Setup Atari Treeview Callbacks: */
@@ -73,7 +73,7 @@ static nserror atari_hotlist_init_phase2(struct core_window *cw,
struct core_window_callback_table *cb_t)
{
LOG("cw:%p", cw);
- return(hotlist_init(cb_t, cw, hl.path));
+ return hotlist_manager_init(cb_t, cw);
}
static void atari_hotlist_finish(struct core_window *cw)
@@ -199,6 +199,7 @@ void atari_hotlist_init(void)
}
LOG("Hotlist: %s", (char *)&hl.path);
+ hotlist_init(hl.path);
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
diff --git a/frontends/atari/hotlist.h b/frontends/atari/hotlist.h
index 1598782..f35fa15 100644
--- a/frontends/atari/hotlist.h
+++ b/frontends/atari/hotlist.h
@@ -21,7 +21,6 @@
#include <stdbool.h>
-#include "desktop/tree.h"
#include "atari/gemtk/gemtk.h"
#include "atari/treeview.h"
diff --git a/frontends/atari/login.c b/frontends/atari/login.c
index c44b077..1b21c5d 100644
--- a/frontends/atari/login.c
+++ b/frontends/atari/login.c
@@ -27,10 +27,6 @@
#include "utils/utils.h"
#include "utils/messages.h"
#include "utils/log.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "content/fetch.h"
#include "atari/gui.h"
#include "atari/misc.h"
diff --git a/frontends/atari/misc.c b/frontends/atari/misc.c
index 8688b93..4866f05 100644
--- a/frontends/atari/misc.c
+++ b/frontends/atari/misc.c
@@ -25,18 +25,17 @@
#include <sys/types.h>
#include <mint/osbind.h>
-#include "utils/dirent.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "desktop/cookie_manager.h"
-#include "desktop/mouse.h"
-#include "desktop/tree.h"
#include "utils/nsoption.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/file.h"
-#include "content/fetch.h"
+#include "utils/dirent.h"
+#include "netsurf/mouse.h"
+#include "netsurf/keypress.h"
+#include "content/content.h"
+#include "content/hlcache.h"
+#include "desktop/cookie_manager.h"
#include "atari/gui.h"
#include "atari/toolbar.h"
diff --git a/frontends/atari/plot/font_freetype.c b/frontends/atari/plot/font_freetype.c
index a77aff8..6028207 100644
--- a/frontends/atari/plot/font_freetype.c
+++ b/frontends/atari/plot/font_freetype.c
@@ -24,7 +24,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
#include "desktop/plot_style.h"
#include "atari/gui.h"
diff --git a/frontends/atari/plot/font_internal.c b/frontends/atari/plot/font_internal.c
index 89a56d0..b96f4c7 100644
--- a/frontends/atari/plot/font_internal.c
+++ b/frontends/atari/plot/font_internal.c
@@ -24,7 +24,7 @@
#include "utils/utf8.h"
#include "utils/log.h"
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
#include "desktop/plot_style.h"
#include "atari/gui.h"
diff --git a/frontends/atari/plot/fontplot.c b/frontends/atari/plot/fontplot.c
index 9f0edd9..d0a1fe1 100644
--- a/frontends/atari/plot/fontplot.c
+++ b/frontends/atari/plot/fontplot.c
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <mt_gem.h>
-#include "desktop/mouse.h"
+#include "netsurf/mouse.h"
#include "desktop/plot_style.h"
#include "atari/bitmap.h"
diff --git a/frontends/atari/plot/plot.c b/frontends/atari/plot/plot.c
index 45e4cea..0a0d7a4 100644
--- a/frontends/atari/plot/plot.c
+++ b/frontends/atari/plot/plot.c
@@ -29,9 +29,9 @@
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
-#include "image/bitmap.h"
-#include "desktop/plotters.h"
-#include "desktop/mouse.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/plotters.h"
+#include "netsurf/mouse.h"
#include "atari/gui.h"
#include "atari/osspec.h"
@@ -45,30 +45,30 @@
void vq_scrninfo(VdiHdl handle, short *work_out);
struct s_view {
- short x; /* drawing (screen) offset x */
- short y; /* drawing (screen) offset y */
- short w; /* width of buffer, not in sync with vis_w */
- short h; /* height of buffer, not in sync with vis_w */
- short vis_x; /* visible rectangle of the screen buffer */
- short vis_y; /* coords are relative to plot location */
- short vis_w; /* clipped to screen dimensions */
- short vis_h; /* visible width */
- struct rect abs_clipping; /* The toplevel clipping rectangle */
- struct rect clipping; /* actual clipping rectangle */
+ short x; /* drawing (screen) offset x */
+ short y; /* drawing (screen) offset y */
+ short w; /* width of buffer, not in sync with vis_w */
+ short h; /* height of buffer, not in sync with vis_w */
+ short vis_x; /* visible rectangle of the screen buffer */
+ short vis_y; /* coords are relative to plot location */
+ short vis_w; /* clipped to screen dimensions */
+ short vis_h; /* visible width */
+ struct rect abs_clipping; /* The toplevel clipping rectangle */
+ struct rect clipping; /* actual clipping rectangle */
float scale;
};
/*
-* Capture the screen at x,y location
-* param self instance
-* param x absolute screen coords
-* param y absolute screen coords
-* param w width
-* param h height
-*
-* This creates an snapshot in RGBA format (NetSurf's native format)
-*
-*/
+ * Capture the screen at x,y location
+ * param self instance
+ * param x absolute screen coords
+ * param y absolute screen coords
+ * param w width
+ * param h height
+ *
+ * This creates an snapshot in RGBA format (NetSurf's native format)
+ *
+ */
static struct bitmap * snapshot_create(int x, int y, int w, int h);
/* Garbage collection of the snapshot routine */
@@ -181,7 +181,7 @@ unsigned long atari_plot_flags;
unsigned long atari_font_flags;
typedef bool (*bitmap_convert_fnc)( struct bitmap * img, int x, int y,
- GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out );
+ GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out );
static bitmap_convert_fnc bitmap_convert;
const char* plot_err_str(int i)
@@ -197,22 +197,22 @@ const char* plot_err_str(int i)
*/
inline static void vsl_rgbcolor(short vdih, colour cin)
{
- #ifdef WITH_8BPP_SUPPORT
- if( vdi_sysinfo.scr_bpp > 8 ) {
- #endif
- RGB1000 c; /* a struct with three (RGB) shorts */
- rgb_to_vdi1000( (unsigned char*)&cin, &c);
- vs_color(vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
- vsl_color(vdih, OFFSET_CUSTOM_COLOR);
- #ifdef WITH_8BPP_SUPPORT
- } else {
- if( vdi_sysinfo.scr_bpp >= 4 ){
- vsl_color(vdih, RGB_TO_VDI(cin));
- }
- else
- vsl_color(vdih, BLACK);
- }
- #endif
+#ifdef WITH_8BPP_SUPPORT
+ if( vdi_sysinfo.scr_bpp > 8 ) {
+#endif
+ RGB1000 c; /* a struct with three (RGB) shorts */
+ rgb_to_vdi1000( (unsigned char*)&cin, &c);
+ vs_color(vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
+ vsl_color(vdih, OFFSET_CUSTOM_COLOR);
+#ifdef WITH_8BPP_SUPPORT
+ } else {
+ if( vdi_sysinfo.scr_bpp >= 4 ){
+ vsl_color(vdih, RGB_TO_VDI(cin));
+ }
+ else
+ vsl_color(vdih, BLACK);
+ }
+#endif
}
/**
@@ -223,22 +223,22 @@ inline static void vsl_rgbcolor(short vdih, colour cin)
*/
inline static void vsf_rgbcolor(short vdih, colour cin)
{
- #ifdef WITH_8BPP_SUPPORT
- if( vdi_sysinfo.scr_bpp > 8 ) {
- #endif
- RGB1000 c; /* a struct with three (RGB) shorts */
- rgb_to_vdi1000( (unsigned char*)&cin, &c);
- vs_color( vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
- vsf_color( vdih, OFFSET_CUSTOM_COLOR );
- #ifdef WITH_8BPP_SUPPORT
- } else {
- if( vdi_sysinfo.scr_bpp >= 4 ){
- vsf_color( vdih, RGB_TO_VDI(cin) );
- }
- else
- vsf_color( vdih, WHITE );
- }
- #endif
+#ifdef WITH_8BPP_SUPPORT
+ if( vdi_sysinfo.scr_bpp > 8 ) {
+#endif
+ RGB1000 c; /* a struct with three (RGB) shorts */
+ rgb_to_vdi1000( (unsigned char*)&cin, &c);
+ vs_color( vdih, OFFSET_CUSTOM_COLOR, (short *)&c);
+ vsf_color( vdih, OFFSET_CUSTOM_COLOR );
+#ifdef WITH_8BPP_SUPPORT
+ } else {
+ if( vdi_sysinfo.scr_bpp >= 4 ){
+ vsf_color( vdih, RGB_TO_VDI(cin) );
+ }
+ else
+ vsf_color( vdih, WHITE );
+ }
+#endif
}
@@ -248,146 +248,146 @@ inline static void vsf_rgbcolor(short vdih, colour cin)
*/
inline static void plot_get_visible_grect(GRECT * out)
{
- out->g_x = view.vis_x;
- out->g_y = view.vis_y;
- out->g_w = view.vis_w;
- out->g_h = view.vis_h;
+ out->g_x = view.vis_x;
+ out->g_y = view.vis_y;
+ out->g_w = view.vis_w;
+ out->g_h = view.vis_h;
}
-/* calculate visible area of framebuffer in coords relative to framebuffer */
-/* position */
-/* result: */
-/* this function should calculates an rectangle relative to the plot origin*/
-/* and size. */
-/* If the ploter coords do not fall within the screen region, */
-/* all values of the region are set to zero. */
+/* calculate visible area of framebuffer in coords relative to framebuffer */
+/* position */
+/* result: */
+/* this function should calculates an rectangle relative to the plot origin*/
+/* and size. */
+/* If the ploter coords do not fall within the screen region, */
+/* all values of the region are set to zero. */
inline static void update_visible_rect(void)
{
- GRECT screen; // dimensions of the screen
- GRECT frame; // dimensions of the drawing area
- GRECT common; // dimensions of intersection of both
+ GRECT screen; // dimensions of the screen
+ GRECT frame; // dimensions of the drawing area
+ GRECT common; // dimensions of intersection of both
- screen.g_x = 0;
- screen.g_y = 0;
- screen.g_w = vdi_sysinfo.scr_w;
- screen.g_h = vdi_sysinfo.scr_h;
+ screen.g_x = 0;
+ screen.g_y = 0;
+ screen.g_w = vdi_sysinfo.scr_w;
+ screen.g_h = vdi_sysinfo.scr_h;
common.g_x = frame.g_x = view.x;
- common.g_y = frame.g_y = view.y;
- common.g_w = frame.g_w = view.w;
- common.g_h = frame.g_h = view.h;
-
- if (rc_intersect(&screen, &common)) {
- view.vis_w = common.g_w;
- view.vis_h = common.g_h;
- if (view.x < screen.g_x)
- view.vis_x = frame.g_w - common.g_w;
- else
- view.vis_x = 0;
- if (view.y <screen.g_y)
- view.vis_y = frame.g_h - common.g_h;
- else
- view.vis_y = 0;
- } else {
- view.vis_w = view.vis_h = 0;
- view.vis_x = view.vis_y = 0;
- }
+ common.g_y = frame.g_y = view.y;
+ common.g_w = frame.g_w = view.w;
+ common.g_h = frame.g_h = view.h;
+
+ if (rc_intersect(&screen, &common)) {
+ view.vis_w = common.g_w;
+ view.vis_h = common.g_h;
+ if (view.x < screen.g_x)
+ view.vis_x = frame.g_w - common.g_w;
+ else
+ view.vis_x = 0;
+ if (view.y <screen.g_y)
+ view.vis_y = frame.g_h - common.g_h;
+ else
+ view.vis_y = 0;
+ } else {
+ view.vis_w = view.vis_h = 0;
+ view.vis_x = view.vis_y = 0;
+ }
}
/* Returns the visible parts of the box (relative coords within framebuffer),*/
-/* relative to screen coords (normally starting at 0,0 ) */
+/* relative to screen coords (normally starting at 0,0 ) */
inline static bool fbrect_to_screen(GRECT box, GRECT * ret)
{
- GRECT out, vis, screen;
+ GRECT out, vis, screen;
- screen.g_x = 0;
- screen.g_y = 0;
- screen.g_w = vdi_sysinfo.scr_w;
- screen.g_h = vdi_sysinfo.scr_h;
+ screen.g_x = 0;
+ screen.g_y = 0;
+ screen.g_w = vdi_sysinfo.scr_w;
+ screen.g_h = vdi_sysinfo.scr_h;
- /* get visible region: */
+ /* get visible region: */
vis.g_x = view.x;
- vis.g_y = view.y;
- vis.g_w = view.w;
- vis.g_h = view.h;
-
- if ( !rc_intersect( &screen, &vis ) ) {
- return( false );
- }
- vis.g_x = view.w - vis.g_w;
- vis.g_y = view.h - vis.g_h;
-
- /* clip box to visible region: */
- if( !rc_intersect(&vis, &box) ) {
- return( false );
- }
- out.g_x = box.g_x + view.x;
- out.g_y = box.g_y + view.y;
- out.g_w = box.g_w;
- out.g_h = box.g_h;
- *ret = out;
- return ( true );
+ vis.g_y = view.y;
+ vis.g_w = view.w;
+ vis.g_h = view.h;
+
+ if ( !rc_intersect( &screen, &vis ) ) {
+ return( false );
+ }
+ vis.g_x = view.w - vis.g_w;
+ vis.g_y = view.h - vis.g_h;
+
+ /* clip box to visible region: */
+ if( !rc_intersect(&vis, &box) ) {
+ return( false );
+ }
+ out.g_x = box.g_x + view.x;
+ out.g_y = box.g_y + view.y;
+ out.g_w = box.g_w;
+ out.g_h = box.g_h;
+ *ret = out;
+ return ( true );
}
/* copy an rectangle from the plot buffer to screen */
/* because this is an on-screen plotter, this is an screen to screen copy. */
bool plot_copy_rect(GRECT src, GRECT dst)
{
- MFDB devmf;
- MFDB scrmf;
- short pxy[8];
- GRECT vis;
-
- /* clip to visible rect, only needed for onscreen renderer: */
- plot_get_visible_grect(&vis );
-
- if( !rc_intersect(&vis, &src) )
- return(true);
- if( !rc_intersect(&vis, &dst) )
- return(true);
-
- src.g_x = view.x + src.g_x;
- src.g_y = view.y + src.g_y;
- dst.g_x = view.x + dst.g_x;
- dst.g_y = view.y + dst.g_y;
-
- devmf.fd_addr = NULL;
- devmf.fd_w = src.g_w;
- devmf.fd_h = src.g_h;
- devmf.fd_wdwidth = 0;
- devmf.fd_stand = 0;
- devmf.fd_nplanes = 0;
- devmf.fd_r1 = devmf.fd_r2 = devmf.fd_r3 = 0;
-
- scrmf.fd_addr = NULL;
- scrmf.fd_w = dst.g_w;
- scrmf.fd_h = dst.g_h;
- scrmf.fd_wdwidth = 0 ;
- scrmf.fd_stand = 0;
- scrmf.fd_nplanes = 0;
- scrmf.fd_r1 = scrmf.fd_r2 = scrmf.fd_r3 = 0;
-
- pxy[0] = src.g_x;
- pxy[1] = src.g_y;
- pxy[2] = pxy[0] + src.g_w-1;
- pxy[3] = pxy[1] + src.g_h-1;
- pxy[4] = dst.g_x;
- pxy[5] = dst.g_y;
- pxy[6] = pxy[4] + dst.g_w-1;
- pxy[7] = pxy[5] + dst.g_h-1;
- plot_lock();
- vro_cpyfm( atari_plot_vdi_handle, S_ONLY, (short*)&pxy, &devmf, &scrmf);
- plot_unlock();
-
- return(true);
+ MFDB devmf;
+ MFDB scrmf;
+ short pxy[8];
+ GRECT vis;
+
+ /* clip to visible rect, only needed for onscreen renderer: */
+ plot_get_visible_grect(&vis );
+
+ if( !rc_intersect(&vis, &src) )
+ return(true);
+ if( !rc_intersect(&vis, &dst) )
+ return(true);
+
+ src.g_x = view.x + src.g_x;
+ src.g_y = view.y + src.g_y;
+ dst.g_x = view.x + dst.g_x;
+ dst.g_y = view.y + dst.g_y;
+
+ devmf.fd_addr = NULL;
+ devmf.fd_w = src.g_w;
+ devmf.fd_h = src.g_h;
+ devmf.fd_wdwidth = 0;
+ devmf.fd_stand = 0;
+ devmf.fd_nplanes = 0;
+ devmf.fd_r1 = devmf.fd_r2 = devmf.fd_r3 = 0;
+
+ scrmf.fd_addr = NULL;
+ scrmf.fd_w = dst.g_w;
+ scrmf.fd_h = dst.g_h;
+ scrmf.fd_wdwidth = 0 ;
+ scrmf.fd_stand = 0;
+ scrmf.fd_nplanes = 0;
+ scrmf.fd_r1 = scrmf.fd_r2 = scrmf.fd_r3 = 0;
+
+ pxy[0] = src.g_x;
+ pxy[1] = src.g_y;
+ pxy[2] = pxy[0] + src.g_w-1;
+ pxy[3] = pxy[1] + src.g_h-1;
+ pxy[4] = dst.g_x;
+ pxy[5] = dst.g_y;
+ pxy[6] = pxy[4] + dst.g_w-1;
+ pxy[7] = pxy[5] + dst.g_h-1;
+ plot_lock();
+ vro_cpyfm( atari_plot_vdi_handle, S_ONLY, (short*)&pxy, &devmf, &scrmf);
+ plot_unlock();
+
+ return(true);
}
/**
* Fill the screen info structure.
*
- * \param vdhi The handle
+ * \param vdih The handle
* \param[out] info The infor structure to fill.
*/
static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
@@ -468,7 +468,7 @@ static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
case VDI_CLUT_HARDWARE: {
}
- break;
+ break;
case VDI_CLUT_SOFTWARE: {
int component; /* red, green, blue, alpha, overlay */
@@ -505,11 +505,11 @@ static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
}
}
- /* Remove lower green bits for Intel endian screen */
- if ((info->mask_g == ((7<<13)|3)) || (info->mask_g == ((7<<13)|7))) {
- info->mask_g &= ~(7<<13);
- }
- break;
+ /* Remove lower green bits for Intel endian screen */
+ if ((info->mask_g == ((7<<13)|3)) || (info->mask_g == ((7<<13)|7))) {
+ info->mask_g &= ~(7<<13);
+ }
+ break;
case VDI_CLUT_NONE:
break;
@@ -519,13 +519,13 @@ static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info) {
/*
- Convert an RGB color to an VDI Color
+ Convert an RGB color to an VDI Color
*/
inline void rgb_to_vdi1000(unsigned char * in, RGB1000 *out)
{
double r = ((double)in[3]/255); /* prozentsatz red */
- double g = ((double)in[2]/255); /* prozentsatz green */
- double b = ((double)in[1]/255); /* prozentsatz blue */
+ double g = ((double)in[2]/255); /* prozentsatz green */
+ double b = ((double)in[1]/255); /* prozentsatz blue */
out->red = 1000 * r + 0.5;
out->green = 1000 * g + 0.5;
out->blue = 1000 * b + 0.5;
@@ -550,34 +550,34 @@ inline void vdi1000_to_rgb(unsigned short * in, unsigned char * out)
*/
inline static void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned char val )
{
- short * buf;
- short whichbit = (1<<(15-(x%16)));
+ short * buf;
+ short whichbit = (1<<(15-(x%16)));
- buf = dst->fd_addr;
- buf += ((dst->fd_wdwidth*(y))+(x>>4));
+ buf = dst->fd_addr;
+ buf += ((dst->fd_wdwidth*(y))+(x>>4));
- *buf = (val&1) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ *buf = (val&1) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
- buf += wdplanesz;
- *buf = (val&(1<<1)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ buf += wdplanesz;
+ *buf = (val&(1<<1)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
- buf += wdplanesz;
- *buf = (val&(1<<2)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ buf += wdplanesz;
+ *buf = (val&(1<<2)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
- buf += wdplanesz;
- *buf = (val&(1<<3)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ buf += wdplanesz;
+ *buf = (val&(1<<3)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
- buf += wdplanesz;
- *buf = (val&(1<<4)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ buf += wdplanesz;
+ *buf = (val&(1<<4)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
- buf += wdplanesz;
- *buf = (val&(1<<5)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ buf += wdplanesz;
+ *buf = (val&(1<<5)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
- buf += wdplanesz;
- *buf = (val&(1<<6)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ buf += wdplanesz;
+ *buf = (val&(1<<6)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
- buf += wdplanesz;
- *buf = (val&(1<<7)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ buf += wdplanesz;
+ *buf = (val&(1<<7)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
}
/**
@@ -585,49 +585,49 @@ inline static void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned
*/
inline static unsigned char get_stdpx(MFDB * dst, int wdplanesz, int x, int y)
{
- unsigned char ret=0;
- short * buf;
- short whichbit = (1<<(15-(x%16)));
+ unsigned char ret=0;
+ short * buf;
+ short whichbit = (1<<(15-(x%16)));
- buf = dst->fd_addr;
- buf += ((dst->fd_wdwidth*(y))+(x>>4));
+ buf = dst->fd_addr;
+ buf += ((dst->fd_wdwidth*(y))+(x>>4));
- if( *buf & whichbit )
- ret |= 1;
+ if( *buf & whichbit )
+ ret |= 1;
- buf += wdplanesz;
- if( *buf & whichbit )
- ret |= 2;
+ buf += wdplanesz;
+ if( *buf & whichbit )
+ ret |= 2;
- buf += wdplanesz;
- if( *buf & whichbit )
- ret |= 4;
+ buf += wdplanesz;
+ if( *buf & whichbit )
+ ret |= 4;
- buf += wdplanesz;
- if( *buf & whichbit )
- ret |= 8;
+ buf += wdplanesz;
+ if( *buf & whichbit )
+ ret |= 8;
- buf += wdplanesz;
- if( *buf & whichbit )
- ret |= 16;
+ buf += wdplanesz;
+ if( *buf & whichbit )
+ ret |= 16;
- buf += wdplanesz;
- if( *buf & whichbit )
- ret |= 32;
+ buf += wdplanesz;
+ if( *buf & whichbit )
+ ret |= 32;
- buf += wdplanesz;
- if( *buf & whichbit )
- ret |= 64;
+ buf += wdplanesz;
+ if( *buf & whichbit )
+ ret |= 64;
- buf += wdplanesz;
- if( *buf & whichbit )
- ret |= 128;
+ buf += wdplanesz;
+ if( *buf & whichbit )
+ ret |= 128;
- return( ret );
+ return( ret );
}
/*
- Convert an RGB color into an index into the 216 colors web pallette
+ Convert an RGB color into an index into the 216 colors web pallette
*/
inline short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b)
{
@@ -669,26 +669,26 @@ static void dump_vdi_info(short vdih)
struct s_vdi_sysinfo temp;
read_vdi_sysinfo( vdih, &temp );
printf("struct s_vdi_sysinfo {\n");
- printf(" short vdi_handle: %d\n", temp.vdi_handle);
- printf(" short scr_w: %d \n", temp.scr_w);
- printf(" short scr_h: %d\n", temp.scr_h);
- printf(" short scr_bpp: %d\n", temp.scr_bpp);
- printf(" int colors: %d\n", temp.colors);
- printf(" ulong hicolors: %lu\n", temp.hicolors);
- printf(" short pixelsize: %d\n", temp.pixelsize);
- printf(" unsigned short pitch: %d\n", temp.pitch);
- printf(" unsigned short vdiformat: %d\n", temp.vdiformat);
- printf(" unsigned short clut: %d\n", temp.clut);
- printf(" void * screen: 0x0%p\n", temp.screen);
- printf(" unsigned long screensize: %lu\n", temp.screensize);
- printf(" unsigned long mask_r: 0x0%08lx\n", temp.mask_r);
- printf(" unsigned long mask_g: 0x0%08lx\n", temp.mask_g);
- printf(" unsigned long mask_b: 0x0%08lx\n", temp.mask_b);
- printf(" unsigned long mask_a: 0x0%08lx\n", temp.mask_a);
- printf(" short maxintin: %d\n", temp.maxintin);
- printf(" short maxpolycoords: %d\n", temp.maxpolycoords);
- printf(" unsigned long EdDiVersion: 0x0%03lx\n", temp.EdDiVersion);
- printf(" unsigned short rasterscale: 0x%2x\n", temp.rasterscale);
+ printf(" short vdi_handle: %d\n", temp.vdi_handle);
+ printf(" short scr_w: %d \n", temp.scr_w);
+ printf(" short scr_h: %d\n", temp.scr_h);
+ printf(" short scr_bpp: %d\n", temp.scr_bpp);
+ printf(" int colors: %d\n", temp.colors);
+ printf(" ulong hicolors: %lu\n", temp.hicolors);
+ printf(" short pixelsize: %d\n", temp.pixelsize);
+ printf(" unsigned short pitch: %d\n", temp.pitch);
+ printf(" unsigned short vdiformat: %d\n", temp.vdiformat);
+ printf(" unsigned short clut: %d\n", temp.clut);
+ printf(" void * screen: 0x0%p\n", temp.screen);
+ printf(" unsigned long screensize: %lu\n", temp.screensize);
+ printf(" unsigned long mask_r: 0x0%08lx\n", temp.mask_r);
+ printf(" unsigned long mask_g: 0x0%08lx\n", temp.mask_g);
+ printf(" unsigned long mask_b: 0x0%08lx\n", temp.mask_b);
+ printf(" unsigned long mask_a: 0x0%08lx\n", temp.mask_a);
+ printf(" short maxintin: %d\n", temp.maxintin);
+ printf(" short maxpolycoords: %d\n", temp.maxpolycoords);
+ printf(" unsigned long EdDiVersion: 0x0%03lx\n", temp.EdDiVersion);
+ printf(" unsigned short rasterscale: 0x%2x\n", temp.rasterscale);
printf("};\n");
}
@@ -697,162 +697,124 @@ static void dump_vdi_info(short vdih)
*/
static MFDB * snapshot_create_native_mfdb(int x, int y, int w, int h)
{
- MFDB scr;
- short pxy[8];
-
- /* allocate memory for the snapshot */
- {
- int scr_stride = MFDB_STRIDE( w );
- int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp );
- if(size_buf_scr == 0 ){
- /* init screen mfdb */
- buf_scr.fd_addr = malloc( scr_size );
- size_buf_scr = scr_size;
- } else {
- if( scr_size >size_buf_scr ) {
- buf_scr.fd_addr = realloc(
- buf_scr.fd_addr, scr_size
- );
- size_buf_scr = scr_size;
- }
- }
- if(buf_scr.fd_addr == NULL ) {
- size_buf_scr = 0;
- return( NULL );
- }
- buf_scr.fd_nplanes = vdi_sysinfo.scr_bpp;
- buf_scr.fd_w = scr_stride;
- buf_scr.fd_h = h;
- buf_scr.fd_wdwidth = scr_stride >> 4;
- assert(buf_scr.fd_addr != NULL );
- }
- init_mfdb( 0, w, h, 0, &scr );
- pxy[0] = x;
- pxy[1] = y;
- pxy[2] = pxy[0] + w-1;
- pxy[3] = pxy[1] + h-1;
- pxy[4] = 0;
- pxy[5] = 0;
- pxy[6] = w-1;
- pxy[7] = h-1;
- vro_cpyfm(
- atari_plot_vdi_handle, S_ONLY, (short*)&pxy,
- &scr, &buf_scr
- );
-
- return( &buf_scr );
+ MFDB scr;
+ short pxy[8];
+
+ /* allocate memory for the snapshot */
+ {
+ int scr_stride = MFDB_STRIDE( w );
+ int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp );
+ if(size_buf_scr == 0 ){
+ /* init screen mfdb */
+ buf_scr.fd_addr = malloc( scr_size );
+ size_buf_scr = scr_size;
+ } else {
+ if( scr_size >size_buf_scr ) {
+ buf_scr.fd_addr = realloc(
+ buf_scr.fd_addr, scr_size
+ );
+ size_buf_scr = scr_size;
+ }
+ }
+ if(buf_scr.fd_addr == NULL ) {
+ size_buf_scr = 0;
+ return( NULL );
+ }
+ buf_scr.fd_nplanes = vdi_sysinfo.scr_bpp;
+ buf_scr.fd_w = scr_stride;
+ buf_scr.fd_h = h;
+ buf_scr.fd_wdwidth = scr_stride >> 4;
+ assert(buf_scr.fd_addr != NULL );
+ }
+ init_mfdb( 0, w, h, 0, &scr );
+ pxy[0] = x;
+ pxy[1] = y;
+ pxy[2] = pxy[0] + w-1;
+ pxy[3] = pxy[1] + h-1;
+ pxy[4] = 0;
+ pxy[5] = 0;
+ pxy[6] = w-1;
+ pxy[7] = h-1;
+ vro_cpyfm(
+ atari_plot_vdi_handle, S_ONLY, (short*)&pxy,
+ &scr, &buf_scr
+ );
+
+ return( &buf_scr );
}
-/**
- * Create an snapshot of the screen image in VDI standard format (8 bit).
- */
-static MFDB * snapshot_create_std_mfdb(int x, int y, int w, int h)
-{
- /* allocate memory for the snapshot */
- {
- int scr_stride = MFDB_STRIDE( w );
- int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp );
- if(size_buf_std == 0 ){
- /* init screen mfdb */
- buf_std.fd_addr = malloc( scr_size );
- size_buf_std = scr_size;
- } else {
- if( scr_size >size_buf_std ) {
- buf_std.fd_addr = realloc(
- buf_std.fd_addr, scr_size
- );
- size_buf_std = scr_size;
- }
- }
- if(buf_std.fd_addr == NULL ) {
- size_buf_std = 0;
- return( NULL );
- }
- buf_std.fd_nplanes = 8;
- buf_std.fd_w = scr_stride;
- buf_std.fd_h = h;
- buf_std.fd_stand = 1;
- buf_std.fd_wdwidth = scr_stride >> 4;
- assert(buf_std.fd_addr != NULL );
- }
- MFDB * native = snapshot_create_native_mfdb(x,y,w,h );
- assert( native );
-
- vr_trnfm(atari_plot_vdi_handle, native, &buf_std);
- return( &buf_std );
-}
/*
* Create an snapshot of the screen in netsurf ABGR format
*/
static struct bitmap * snapshot_create(int x, int y, int w, int h)
{
- int err;
- MFDB * native;
- // uint32_t start = clock();
-
- // FIXME: This can be optimized a lot.
- // 1. do not copy the snapshot to the bitmap buffer
- // when the format of screen and bitmap equals.
- // just point the bitmap to the native mfdb.
- // 2. if we have eddi 1.1, we could optimize that further
- // make snapshot_create_native_mfdb just returning a pointer
- // to the screen.
-
- native = snapshot_create_native_mfdb(x, y, w, h );
-
- if(vfmt.bits == 32 )
- goto no_copy;
-
- /* allocate buffer for result bitmap: */
- if(buf_scr_compat == NULL ) {
- buf_scr_compat = atari_bitmap_create(w, h, 0);
- } else {
- buf_scr_compat = atari_bitmap_realloc( w, h,
- buf_scr_compat->bpp,
- w *buf_scr_compat->bpp,
- BITMAP_GROW,
- buf_scr_compat );
- }
-
- /* convert screen buffer to ns format: */
- err = Hermes_ConverterRequest( hermes_cnv_h,
- &vfmt,
- &nsfmt
- );
- assert( err != 0 );
- err = Hermes_ConverterCopy( hermes_cnv_h,
- native->fd_addr,
- 0, /* x src coord of top left in pixel coords */
- 0, /* y src coord of top left in pixel coords */
- w, h,
- native->fd_w * vdi_sysinfo.pixelsize, /* stride as bytes */
- buf_scr_compat->pixdata,
- 0, /* x dst coord of top left in pixel coords */
- 0, /* y dst coord of top left in pixel coords */
- w, h,
- atari_bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */
- );
- assert( err != 0 );
- return( (struct bitmap * )buf_scr_compat );
+ int err;
+ MFDB * native;
+ // uint32_t start = clock();
+
+ // FIXME: This can be optimized a lot.
+ // 1. do not copy the snapshot to the bitmap buffer
+ // when the format of screen and bitmap equals.
+ // just point the bitmap to the native mfdb.
+ // 2. if we have eddi 1.1, we could optimize that further
+ // make snapshot_create_native_mfdb just returning a pointer
+ // to the screen.
+
+ native = snapshot_create_native_mfdb(x, y, w, h );
+
+ if(vfmt.bits == 32 )
+ goto no_copy;
+
+ /* allocate buffer for result bitmap: */
+ if(buf_scr_compat == NULL ) {
+ buf_scr_compat = atari_bitmap_create(w, h, 0);
+ } else {
+ buf_scr_compat = atari_bitmap_realloc( w, h,
+ buf_scr_compat->bpp,
+ w *buf_scr_compat->bpp,
+ BITMAP_GROW,
+ buf_scr_compat );
+ }
+
+ /* convert screen buffer to ns format: */
+ err = Hermes_ConverterRequest( hermes_cnv_h,
+ &vfmt,
+ &nsfmt
+ );
+ assert( err != 0 );
+ err = Hermes_ConverterCopy( hermes_cnv_h,
+ native->fd_addr,
+ 0, /* x src coord of top left in pixel coords */
+ 0, /* y src coord of top left in pixel coords */
+ w, h,
+ native->fd_w * vdi_sysinfo.pixelsize, /* stride as bytes */
+ buf_scr_compat->pixdata,
+ 0, /* x dst coord of top left in pixel coords */
+ 0, /* y dst coord of top left in pixel coords */
+ w, h,
+ atari_bitmap_get_rowstride(buf_scr_compat) /* stride as bytes */
+ );
+ assert( err != 0 );
+ return( (struct bitmap * )buf_scr_compat );
no_copy:
- snapshot.width = w;
- snapshot.height = h;
- snapshot.pixdata = native->fd_addr;
- snapshot.native = *native;
- snapshot.rowstride = MFDB_STRIDE( w )*4;
-
- uint32_t row, col;
- for (row = 0; row<(uint32_t)h; row++) {
- // fd_w matches stride!
- uint32_t *rowptr = ((uint32_t*)native->fd_addr + ((row*native->fd_w)));
- for (col=0; col<(uint32_t)w; col++) {
- *(rowptr+col) = (*(rowptr+col)<<8);
- }
- }
- return( &snapshot );
+ snapshot.width = w;
+ snapshot.height = h;
+ snapshot.pixdata = native->fd_addr;
+ snapshot.native = *native;
+ snapshot.rowstride = MFDB_STRIDE( w )*4;
+
+ uint32_t row, col;
+ for (row = 0; row<(uint32_t)h; row++) {
+ // fd_w matches stride!
+ uint32_t *rowptr = ((uint32_t*)native->fd_addr + ((row*native->fd_w)));
+ for (col=0; col<(uint32_t)w; col++) {
+ *(rowptr+col) = (*(rowptr+col)<<8);
+ }
+ }
+ return( &snapshot );
}
/**
@@ -860,43 +822,43 @@ no_copy:
*/
static void snapshot_suspend(void)
{
- if(size_buf_scr > CONV_KEEP_LIMIT ) {
- buf_scr.fd_addr = realloc(
- buf_scr.fd_addr, CONV_KEEP_LIMIT
- );
- if(buf_scr.fd_addr != NULL ) {
- size_buf_scr = CONV_KEEP_LIMIT;
- } else {
- size_buf_scr = 0;
- }
- }
+ if(size_buf_scr > CONV_KEEP_LIMIT ) {
+ buf_scr.fd_addr = realloc(
+ buf_scr.fd_addr, CONV_KEEP_LIMIT
+ );
+ if(buf_scr.fd_addr != NULL ) {
+ size_buf_scr = CONV_KEEP_LIMIT;
+ } else {
+ size_buf_scr = 0;
+ }
+ }
#ifdef WITH_8BPP_SUPPORT
- if(size_buf_std > CONV_KEEP_LIMIT ) {
- buf_std.fd_addr = realloc(
- buf_std.fd_addr, CONV_KEEP_LIMIT
- );
- if(buf_std.fd_addr != NULL ) {
- size_buf_std = CONV_KEEP_LIMIT;
- } else {
- size_buf_std = 0;
- }
- }
+ if(size_buf_std > CONV_KEEP_LIMIT ) {
+ buf_std.fd_addr = realloc(
+ buf_std.fd_addr, CONV_KEEP_LIMIT
+ );
+ if(buf_std.fd_addr != NULL ) {
+ size_buf_std = CONV_KEEP_LIMIT;
+ } else {
+ size_buf_std = 0;
+ }
+ }
#endif
- if(buf_scr_compat != NULL ) {
- size_t bs = atari_bitmap_buffer_size(buf_scr_compat );
- if( bs > CONV_KEEP_LIMIT ) {
- int w = 0;
- int h = 1;
- w = (CONV_KEEP_LIMIT /buf_scr_compat->bpp);
- assert( CONV_KEEP_LIMIT == w*buf_scr_compat->bpp );
- buf_scr_compat = atari_bitmap_realloc( w, h,
- buf_scr_compat->bpp,
- CONV_KEEP_LIMIT, BITMAP_SHRINK,buf_scr_compat
- );
- }
- }
+ if(buf_scr_compat != NULL ) {
+ size_t bs = atari_bitmap_buffer_size(buf_scr_compat );
+ if( bs > CONV_KEEP_LIMIT ) {
+ int w = 0;
+ int h = 1;
+ w = (CONV_KEEP_LIMIT /buf_scr_compat->bpp);
+ assert( CONV_KEEP_LIMIT == w*buf_scr_compat->bpp );
+ buf_scr_compat = atari_bitmap_realloc( w, h,
+ buf_scr_compat->bpp,
+ CONV_KEEP_LIMIT, BITMAP_SHRINK,buf_scr_compat
+ );
+ }
+ }
}
/**
@@ -905,17 +867,17 @@ static void snapshot_suspend(void)
static void snapshot_destroy(void)
{
- free(buf_scr.fd_addr);
- if( buf_scr_compat != NULL) {
- atari_bitmap_destroy(buf_scr_compat);
- }
+ free(buf_scr.fd_addr);
+ if( buf_scr_compat != NULL) {
+ atari_bitmap_destroy(buf_scr_compat);
+ }
- buf_scr.fd_addr = NULL;
- buf_scr_compat = NULL;
+ buf_scr.fd_addr = NULL;
+ buf_scr_compat = NULL;
#ifdef WITH_8BPP_SUPPORT
- free(buf_std.fd_addr);
- buf_std.fd_addr = NULL;
+ free(buf_std.fd_addr);
+ buf_std.fd_addr = NULL;
#endif
}
@@ -925,83 +887,123 @@ inline static uint32_t ablend(uint32_t pixel, uint32_t scrpixel)
int opacity = pixel & 0xFF;
int transp = 0x100 - opacity;
uint32_t rb, g;
- pixel >>= 8;
- scrpixel >>= 8;
- rb = ((pixel & 0xFF00FF) * opacity +
- (scrpixel & 0xFF00FF) * transp) >> 8;
+ pixel >>= 8;
+ scrpixel >>= 8;
+ rb = ((pixel & 0xFF00FF) * opacity +
+ (scrpixel & 0xFF00FF) * transp) >> 8;
g = ((pixel & 0x00FF00) * opacity +
- (scrpixel & 0x00FF00) * transp) >> 8;
+ (scrpixel & 0x00FF00) * transp) >> 8;
return ((rb & 0xFF00FF) | (g & 0xFF00)) << 8;
}
/*
- Alpha blends an image, using one pixel as the background.
- The bitmap receives the result.
+ Alpha blends an image, using one pixel as the background.
+ The bitmap receives the result.
*/
inline static bool ablend_pixel(struct bitmap * img, uint32_t bg, GRECT * clip)
{
- uint32_t * imgrow;
- int img_x, img_y, img_stride;
-
- img_stride= atari_bitmap_get_rowstride(img);
-
- for( img_y = 0; img_y < clip->g_h; img_y++) {
- imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
- for( img_x = 0; img_x < clip->g_w; img_x++ ) {
- imgrow[img_x] = ablend( imgrow[img_x], bg );
- }
- }
- return(true);
+ uint32_t * imgrow;
+ int img_x, img_y, img_stride;
+
+ img_stride= atari_bitmap_get_rowstride(img);
+
+ for( img_y = 0; img_y < clip->g_h; img_y++) {
+ imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
+ for( img_x = 0; img_x < clip->g_w; img_x++ ) {
+ imgrow[img_x] = ablend( imgrow[img_x], bg );
+ }
+ }
+ return(true);
}
/*
- Aplha blends the foreground image (img) onto the
- background images (bg). The background receives the blended
- image pixels.
+ Aplha blends the foreground image (img) onto the
+ background images (bg). The background receives the blended
+ image pixels.
*/
inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg,
- GRECT * img_clip, GRECT * bg_clip )
+ GRECT * img_clip, GRECT * bg_clip )
{
- uint32_t * imgrow;
- uint32_t * screenrow;
- int img_x, img_y, bg_x, bg_y, img_stride, bg_stride;
-
- bg_clip = bg_clip;
- img_stride = atari_bitmap_get_rowstride(img);
- bg_stride = atari_bitmap_get_rowstride(bg);
-
- for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) {
- imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
- screenrow = (uint32_t *)(bg->pixdata + (bg_stride * bg_y));
- for( img_x = img_clip->g_x, bg_x = 0; bg_x < img_clip->g_w; bg_x++, img_x++ ) {
-
- // when the pixel isn't fully transparent,...:
- if( (imgrow[img_x] & 0x0FF) != 0 ){
- screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
- }
-
- // FIXME, maybe this loop would be faster??:
- // ---
- //if( (imgrow[img_x] & 0x0FF) != 0xFF ){
- // imgrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
- //}
-
- // or maybe even this???
- // ---
- //if( (imgrow[img_x] & 0x0FF) == 0xFF ){
- // screenrow[bg_x] = imgrow[img_x];
- //} else if( (imgrow[img_x] & 0x0FF) != 0x00 ) {
- // screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
- //}
- }
- }
- return(false);
+ uint32_t * imgrow;
+ uint32_t * screenrow;
+ int img_x, img_y, bg_x, bg_y, img_stride, bg_stride;
+
+ bg_clip = bg_clip;
+ img_stride = atari_bitmap_get_rowstride(img);
+ bg_stride = atari_bitmap_get_rowstride(bg);
+
+ for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) {
+ imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
+ screenrow = (uint32_t *)(bg->pixdata + (bg_stride * bg_y));
+ for( img_x = img_clip->g_x, bg_x = 0; bg_x < img_clip->g_w; bg_x++, img_x++ ) {
+
+ // when the pixel isn't fully transparent,...:
+ if( (imgrow[img_x] & 0x0FF) != 0 ){
+ screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
+ }
+
+ // FIXME, maybe this loop would be faster??:
+ // ---
+ //if( (imgrow[img_x] & 0x0FF) != 0xFF ){
+ // imgrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
+ //}
+
+ // or maybe even this???
+ // ---
+ //if( (imgrow[img_x] & 0x0FF) == 0xFF ){
+ // screenrow[bg_x] = imgrow[img_x];
+ //} else if( (imgrow[img_x] & 0x0FF) != 0x00 ) {
+ // screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
+ //}
+ }
+ }
+ return(false);
}
#ifdef WITH_8BPP_SUPPORT
+
+/**
+ * Create an snapshot of the screen image in VDI standard format (8 bit).
+ */
+static MFDB * snapshot_create_std_mfdb(int x, int y, int w, int h)
+{
+ /* allocate memory for the snapshot */
+ {
+ int scr_stride = MFDB_STRIDE( w );
+ int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp );
+ if(size_buf_std == 0 ){
+ /* init screen mfdb */
+ buf_std.fd_addr = malloc( scr_size );
+ size_buf_std = scr_size;
+ } else {
+ if( scr_size >size_buf_std ) {
+ buf_std.fd_addr = realloc(
+ buf_std.fd_addr, scr_size
+ );
+ size_buf_std = scr_size;
+ }
+ }
+ if(buf_std.fd_addr == NULL ) {
+ size_buf_std = 0;
+ return( NULL );
+ }
+ buf_std.fd_nplanes = 8;
+ buf_std.fd_w = scr_stride;
+ buf_std.fd_h = h;
+ buf_std.fd_stand = 1;
+ buf_std.fd_wdwidth = scr_stride >> 4;
+ assert(buf_std.fd_addr != NULL );
+ }
+ MFDB * native = snapshot_create_native_mfdb(x,y,w,h );
+ assert( native );
+
+ vr_trnfm(atari_plot_vdi_handle, native, &buf_std);
+ return( &buf_std );
+}
+
/**
* Convert an bitmap to an 8 bit device dependant MFDB
* \param img the bitmap (only tested with 32bit bitmaps)
@@ -1014,514 +1016,528 @@ inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg,
*
*/
static bool bitmap_convert_8(struct bitmap * img, int x,
- int y, GRECT * clip, uint32_t bg, uint32_t flags,
- MFDB *out )
+ int y, GRECT * clip, uint32_t bg, uint32_t flags,
+ MFDB *out )
{
- MFDB native;
- MFDB stdform;
- int dststride; /* stride of dest. image */
- int dstsize; /* size of dest. in byte */
- int bw, bh;
- struct bitmap * scrbuf = NULL;
- bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
- bool opaque = atari_bitmap_get_opaque( img );
-
- if( opaque == false ){
- if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
- &&
- ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){
- opaque = true;
- }
- }
-
- assert( clip->g_h > 0 );
- assert( clip->g_w > 0 );
-
- bw = atari_bitmap_get_width( img );
- bh = atari_bitmap_get_height( img );
-
- // The converted bitmap can be saved for subsequent blits, when
- // the bitmap is fully opaque
-
- if( (opaque == true) || (flags & BITMAPF_BUFFER_NATIVE ) ){
- if( img->converted == true ){
- *out = img->native;
- return( 0 );
- }
- if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){
- cache = true;
- }
- }
- if( ( flags & BITMAPF_MONOGLYPH ) != 0 ){
- assert(cache == false);
- }
-
- /* (re)allocate buffer for out image: */
- /* altough the buffer is named "buf_packed" on 8bit systems */
- /* it's not... */
- if( cache == false ){
- // the size of the output will match the size of the clipping:
- dststride = MFDB_STRIDE( clip->g_w );
- dstsize = ( ((dststride >> 3) * clip->g_h) * atari_plot_bpp_virt);
- if( dstsize > size_buf_packed) {
- int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
- if( buf_packed == NULL )
- buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE);
- else
- buf_packed =(void*)realloc(buf_packed,blocks * CONV_BLOCK_SIZE);
- assert( buf_packed );
- if( buf_packed == NULL ) {
- return( 0-ERR_NO_MEM );
- }
- size_buf_packed = blocks * CONV_BLOCK_SIZE;
- }
- native.fd_addr = buf_packed;
- }
- else {
- // the output image will be completly saved, so size of the output
- // image will match the input image size.
- dststride = MFDB_STRIDE( bw );
- dstsize = ( ((dststride >> 3) * bh) * atari_plot_bpp_virt);
- assert( out->fd_addr == NULL );
- native.fd_addr = (void*)malloc( dstsize );
- if (native.fd_addr == NULL){
- if (scrbuf != NULL)
- atari_bitmap_destroy(scrbuf);
- return( 0-ERR_NO_MEM );
- }
- }
-
-
- /*
- on 8 bit systems we must convert the TC (ABGR) image
- to vdi standard format. ( only tested for 256 colors )
- and then convert it to native format with v_trnfm()
- */
- // realloc mem for stdform
- if( opaque == false ){
- // point image to snapshot buffer, otherwise allocate mem
- MFDB * bg = snapshot_create_std_mfdb(x, y, clip->g_w, clip->g_h);
- stdform.fd_addr = bg->fd_addr;
- bh = clip->g_h;
- } else {
- if( dstsize > size_buf_planar) {
- int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
- if( buf_planar == NULL )
- buf_planar =(void*)malloc( blocks * CONV_BLOCK_SIZE );
- else
- buf_planar =(void*)realloc(buf_planar, blocks * CONV_BLOCK_SIZE);
- assert(buf_planar);
- if( buf_planar == NULL ) {
- return( 0-ERR_NO_MEM );
- }
- size_buf_planar = blocks * CONV_BLOCK_SIZE;
- }
- stdform.fd_addr = buf_planar;
- }
- stdform.fd_w = dststride;
- stdform.fd_h = bh;
- stdform.fd_wdwidth = dststride >> 4;
- stdform.fd_stand = 1;
- stdform.fd_nplanes = (short)atari_plot_bpp_virt;
- stdform.fd_r1 = stdform.fd_r2 = stdform.fd_r3 = 0;
-
- int img_stride = atari_bitmap_get_rowstride(img);
- uint32_t prev_pixel = 0x12345678; //TODO: check for collision in first pixel
- unsigned long col = 0;
- unsigned char val = 0;
- uint32_t * row;
- uint32_t pixel;
- int wdplanesize = stdform.fd_wdwidth*stdform.fd_h;
-
- if( opaque == false ){
- // apply transparency and convert to vdi std format
- unsigned long bgcol = 0;
- unsigned char prev_col = 0;
- for( y=0; y<clip->g_h; y++ ){
- row = (uint32_t *)(img->pixdata + (img_stride * (y+clip->g_y)));
- for( x=0; x<clip->g_w; x++ ){
- pixel = row[x+clip->g_x];
- if( (pixel&0xFF) == 0 ){
- continue;
- }
- if( (pixel&0xFF) < 0xF0 ){
- col = get_stdpx( &stdform, wdplanesize,x,y );
- if( (col != prev_col) || (y == 0) )
- bgcol = (((rgb_lookup[col][2] << 16) | (rgb_lookup[col][1] << 8) | (rgb_lookup[col][0]))<<8);
- if( prev_col != col || prev_pixel != pixel ){
- prev_col = col;
- pixel = ablend( pixel, bgcol );
- prev_pixel = pixel;
- pixel = pixel >> 8;
- /* convert pixel value to vdi color index: */
- col = ( ((pixel&0xFF)<<16)
- | (pixel&0xFF00)
- | ((pixel&0xFF0000)>>16) );
- val = RGB_TO_VDI( col );
- }
- set_stdpx( &stdform, wdplanesize, x, y, val );
- } else {
- if( pixel != prev_pixel ){
- /* convert pixel value to vdi color index: */
- pixel = pixel >> 8;
- col = ( ((pixel&0xFF)<<16)
- | (pixel&0xFF00)
- | ((pixel&0xFF0000)>>16) );
- val = RGB_TO_VDI( col );
- prev_pixel = pixel;
- }
- set_stdpx( &stdform, wdplanesize, x, y, val );
- }
- }
- }
- // adjust output position:
- clip->g_x = 0;
- clip->g_y = 0;
- } else {
- // convert the whole image data to vdi std format.
- for( y=0; y < bh; y++ ){
- row = (uint32_t *)(img->pixdata + (img_stride * y));
- for( x=0; x < bw; x++ ){
- pixel = row[x];
- if( pixel != prev_pixel ){
- /* convert pixel value to vdi color index: */
- pixel = pixel >> 8;
- col = ( ((pixel&0xFF)<<16)
- | (pixel&0xFF00)
- | ((pixel&0xFF0000)>>16) );
- val = RGB_TO_VDI( col );
- prev_pixel = pixel;
- }
- set_stdpx( &stdform, wdplanesize, x, y, val );
- }
- }
- }
-
- // convert into native format:
- native.fd_w = stdform.fd_w;
- native.fd_h = stdform.fd_h;
- native.fd_wdwidth = stdform.fd_wdwidth;
- native.fd_stand = 0;
- native.fd_nplanes = (short)atari_plot_bpp_virt;
- native.fd_r1 = native.fd_r2 = native.fd_r3 = 0;
- vr_trnfm(atari_plot_vdi_handle, &stdform, &native );
- *out = native;
- if( cache == true ){
- img->native = native;
- img->converted = true;
- }
-
- return(0);
+ MFDB native;
+ MFDB stdform;
+ int dststride; /* stride of dest. image */
+ int dstsize; /* size of dest. in byte */
+ int bw, bh;
+ struct bitmap * scrbuf = NULL;
+ bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
+ bool opaque = atari_bitmap_get_opaque( img );
+
+ if( opaque == false ){
+ if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
+ &&
+ ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){
+ opaque = true;
+ }
+ }
+
+ assert( clip->g_h > 0 );
+ assert( clip->g_w > 0 );
+
+ bw = atari_bitmap_get_width( img );
+ bh = atari_bitmap_get_height( img );
+
+ // The converted bitmap can be saved for subsequent blits, when
+ // the bitmap is fully opaque
+
+ if( (opaque == true) || (flags & BITMAPF_BUFFER_NATIVE ) ){
+ if( img->converted == true ){
+ *out = img->native;
+ return( 0 );
+ }
+ if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){
+ cache = true;
+ }
+ }
+ if( ( flags & BITMAPF_MONOGLYPH ) != 0 ){
+ assert(cache == false);
+ }
+
+ /* (re)allocate buffer for out image: */
+ /* altough the buffer is named "buf_packed" on 8bit systems */
+ /* it's not... */
+ if( cache == false ){
+ // the size of the output will match the size of the clipping:
+ dststride = MFDB_STRIDE( clip->g_w );
+ dstsize = ( ((dststride >> 3) * clip->g_h) * atari_plot_bpp_virt);
+ if (dstsize > size_buf_packed) {
+ int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
+ void *buf;
+ if (buf_packed == NULL) {
+ buf = malloc( blocks * CONV_BLOCK_SIZE);
+ } else {
+ buf = realloc(buf_packed, blocks * CONV_BLOCK_SIZE);
+ }
+ if (buf == NULL) {
+ return( 0-ERR_NO_MEM );
+ }
+ buf_packed = buf;
+ size_buf_packed = blocks * CONV_BLOCK_SIZE;
+ }
+ native.fd_addr = buf_packed;
+ }
+ else {
+ // the output image will be completly saved, so size of the output
+ // image will match the input image size.
+ dststride = MFDB_STRIDE( bw );
+ dstsize = ( ((dststride >> 3) * bh) * atari_plot_bpp_virt);
+ assert( out->fd_addr == NULL );
+ native.fd_addr = malloc( dstsize );
+ if (native.fd_addr == NULL){
+ if (scrbuf != NULL)
+ atari_bitmap_destroy(scrbuf);
+ return( 0-ERR_NO_MEM );
+ }
+ }
+
+
+ /*
+ on 8 bit systems we must convert the TC (ABGR) image
+ to vdi standard format. ( only tested for 256 colors )
+ and then convert it to native format with v_trnfm()
+ */
+ // realloc mem for stdform
+ if( opaque == false ){
+ // point image to snapshot buffer, otherwise allocate mem
+ MFDB * bg = snapshot_create_std_mfdb(x, y, clip->g_w, clip->g_h);
+ stdform.fd_addr = bg->fd_addr;
+ bh = clip->g_h;
+ } else {
+ if (dstsize > size_buf_planar) {
+ int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
+ void *buf;
+ if (buf_planar == NULL) {
+ buf = malloc(blocks * CONV_BLOCK_SIZE);
+ } else {
+ buf = realloc(buf_planar, blocks * CONV_BLOCK_SIZE);
+ }
+ if (buf == NULL ) {
+ if (cache) {
+ free(native.fd_addr);
+ }
+ return( 0-ERR_NO_MEM );
+ }
+ buf_planar = buf;
+ size_buf_planar = blocks * CONV_BLOCK_SIZE;
+ }
+ stdform.fd_addr = buf_planar;
+ }
+ stdform.fd_w = dststride;
+ stdform.fd_h = bh;
+ stdform.fd_wdwidth = dststride >> 4;
+ stdform.fd_stand = 1;
+ stdform.fd_nplanes = (short)atari_plot_bpp_virt;
+ stdform.fd_r1 = stdform.fd_r2 = stdform.fd_r3 = 0;
+
+ int img_stride = atari_bitmap_get_rowstride(img);
+ uint32_t prev_pixel = 0x12345678; //TODO: check for collision in first pixel
+ unsigned long col = 0;
+ unsigned char val = 0;
+ uint32_t * row;
+ uint32_t pixel;
+ int wdplanesize = stdform.fd_wdwidth*stdform.fd_h;
+
+ if( opaque == false ){
+ // apply transparency and convert to vdi std format
+ unsigned long bgcol = 0;
+ unsigned char prev_col = 0;
+ for( y=0; y<clip->g_h; y++ ){
+ row = (uint32_t *)(img->pixdata + (img_stride * (y+clip->g_y)));
+ for( x=0; x<clip->g_w; x++ ){
+ pixel = row[x+clip->g_x];
+ if( (pixel&0xFF) == 0 ){
+ continue;
+ }
+ if( (pixel&0xFF) < 0xF0 ){
+ col = get_stdpx( &stdform, wdplanesize,x,y );
+ if( (col != prev_col) || (y == 0) )
+ bgcol = (((rgb_lookup[col][2] << 16) | (rgb_lookup[col][1] << 8) | (rgb_lookup[col][0]))<<8);
+ if( prev_col != col || prev_pixel != pixel ){
+ prev_col = col;
+ pixel = ablend( pixel, bgcol );
+ prev_pixel = pixel;
+ pixel = pixel >> 8;
+ /* convert pixel value to vdi color index: */
+ col = ( ((pixel&0xFF)<<16)
+ | (pixel&0xFF00)
+ | ((pixel&0xFF0000)>>16) );
+ val = RGB_TO_VDI( col );
+ }
+ set_stdpx( &stdform, wdplanesize, x, y, val );
+ } else {
+ if( pixel != prev_pixel ){
+ /* convert pixel value to vdi color index: */
+ pixel = pixel >> 8;
+ col = ( ((pixel&0xFF)<<16)
+ | (pixel&0xFF00)
+ | ((pixel&0xFF0000)>>16) );
+ val = RGB_TO_VDI( col );
+ prev_pixel = pixel;
+ }
+ set_stdpx( &stdform, wdplanesize, x, y, val );
+ }
+ }
+ }
+ // adjust output position:
+ clip->g_x = 0;
+ clip->g_y = 0;
+ } else {
+ // convert the whole image data to vdi std format.
+ for( y=0; y < bh; y++ ){
+ row = (uint32_t *)(img->pixdata + (img_stride * y));
+ for( x=0; x < bw; x++ ){
+ pixel = row[x];
+ if( pixel != prev_pixel ){
+ /* convert pixel value to vdi color index: */
+ pixel = pixel >> 8;
+ col = ( ((pixel&0xFF)<<16)
+ | (pixel&0xFF00)
+ | ((pixel&0xFF0000)>>16) );
+ val = RGB_TO_VDI( col );
+ prev_pixel = pixel;
+ }
+ set_stdpx( &stdform, wdplanesize, x, y, val );
+ }
+ }
+ }
+
+ // convert into native format:
+ native.fd_w = stdform.fd_w;
+ native.fd_h = stdform.fd_h;
+ native.fd_wdwidth = stdform.fd_wdwidth;
+ native.fd_stand = 0;
+ native.fd_nplanes = (short)atari_plot_bpp_virt;
+ native.fd_r1 = native.fd_r2 = native.fd_r3 = 0;
+ vr_trnfm(atari_plot_vdi_handle, &stdform, &native );
+ *out = native;
+ if( cache == true ){
+ img->native = native;
+ img->converted = true;
+ }
+
+ return(0);
}
#endif
/*
-*
-* Convert bitmap to the native screen format
-* img: the bitmap
-* x: coordinate where the bitmap REGION (described in clip)
-* shall be drawn (screen coords)
-* y: coordinate where the bitmap REGION (described in clip)
-* shall be drawn (screen coords)
-* clip: which area of the bitmap shall be drawn
-* bg: background color
-* flags: blit flags
-* out: the result MFDB
-*/
+ *
+ * Convert bitmap to the native screen format
+ * img: the bitmap
+ * x: coordinate where the bitmap REGION (described in clip)
+ * shall be drawn (screen coords)
+ * y: coordinate where the bitmap REGION (described in clip)
+ * shall be drawn (screen coords)
+ * clip: which area of the bitmap shall be drawn
+ * bg: background color
+ * flags: blit flags
+ * out: the result MFDB
+ */
static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
- GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out )
+ GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out )
{
- int dststride; /* stride of dest. image */
- int dstsize; /* size of dest. in byte */
- int err;
- int bw, bh;
- struct bitmap * scrbuf = NULL;
- struct bitmap * source = NULL;
- bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
- bool opaque = atari_bitmap_get_opaque( img );
-
- if( opaque == false ){
- if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
- &&
- ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){
- opaque = true;
- }
- }
-
-
- assert( clip->g_h > 0 );
- assert( clip->g_w > 0 );
-
- bw = atari_bitmap_get_width( img );
- bh = atari_bitmap_get_height( img );
-
- // The converted bitmap can be saved for subsequent blits, WHEN:
- // A.) the bitmap is fully opaque OR
- // B.) the bitmap is completly inside the window
- // the latter one is important for alpha blits,
- // because we must get the window background to apply transparency
- // If the image is not completly within the window,
- // we can't get the whole background for the image.
- // this only works if the image isn't used at several different places.
- // In fact in case of alpha bitmap caching it is only used for the
- // toolbar buttons right now.
-
- if( (opaque == true) || (flags & BITMAPF_BUFFER_NATIVE ) ){
- if( img->converted == true ){
- *out = img->native;
- return( 0 );
- }
- if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){
- cache = true;
- }
- }
-
- /* rem. if eddi xy is installed, we could directly access the screen! */
- /* apply transparency to the image: */
- if (( opaque == false )) {
- /* copy the screen to an temp buffer: */
- if ((flags & BITMAPF_BUFFER_NATIVE) == 0) {
- scrbuf = snapshot_create(x, y, clip->g_w, clip->g_h);
- if( scrbuf != NULL ) {
-
- assert( clip->g_w <= bw );
- assert( clip->g_h <= bh );
-
- // copy blended pixels to the screen buffer:
- ablend_bitmap( img, scrbuf, clip, NULL );
- /* adjust size which gets converted: */
- bw = clip->g_w;
- bh = clip->g_h;
- /* adjust output position: */
- clip->g_x = 0;
- clip->g_y = 0;
- /* set the source of conversion: */
- source = scrbuf;
- }
- } else {
- /*
- The whole bitmap can be transformed to an mfdb
- (and get's cached)
- */
- GRECT region = { 0, 0, bw, bh };
- ablend_pixel( img, bg, ®ion );
- source = img;
- }
- } else {
- source = img;
- }
- /* (re)allocate buffer for converted image: */
- dststride = MFDB_STRIDE(bw);
- dstsize = ( ((dststride >> 3) * bh) * atari_plot_bpp_virt );
- if (cache == false) {
- if (dstsize > size_buf_packed) {
- int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
- if( buf_packed == NULL )
- buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
- else
- buf_packed =(void*)realloc(buf_packed,
- blocks * CONV_BLOCK_SIZE);
- assert( buf_packed );
- if( buf_packed == NULL ) {
- if( scrbuf != NULL )
- atari_bitmap_destroy( scrbuf );
- return( 0-ERR_NO_MEM );
- }
- size_buf_packed = blocks * CONV_BLOCK_SIZE;
- }
- out->fd_addr = buf_packed;
- } else {
- assert( out->fd_addr == NULL );
- out->fd_addr = (void*)malloc( dstsize );
- if( out->fd_addr == NULL ){
- if( scrbuf != NULL )
- atari_bitmap_destroy( scrbuf );
- return( 0-ERR_NO_MEM );
- }
- }
-
- out->fd_w = dststride;
- out->fd_h = bh;
- out->fd_wdwidth = dststride >> 4;
- out->fd_stand = 0;
- out->fd_nplanes = (short)atari_plot_bpp_virt;
- out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
-
- err = Hermes_ConverterRequest(
- hermes_cnv_h,
- &nsfmt,
- &vfmt
- );
- assert( err != 0 );
-
- // FIXME: here we can use the same optimization which is used for
- // the snapshot creation.
-
- /* convert image to virtual format: */
- err = Hermes_ConverterCopy( hermes_cnv_h,
- source->pixdata,
- 0, /* x src coord of top left in pixel coords */
- 0, /* y src coord of top left in pixel coords */
- bw, bh,
- source->rowstride, /* stride as bytes */
- out->fd_addr,
- 0, /* x dst coord of top left in pixel coords */
- 0, /* y dst coord of top left in pixel coords */
- bw, bh,
- (dststride >> 3) * atari_plot_bpp_virt /* stride as bytes */
- );
- assert( err != 0 );
-
- if( cache == true ){
- img->native = *out;
- img->converted = true;
- }
- return( 0 );
+ int dststride; /* stride of dest. image */
+ int dstsize; /* size of dest. in byte */
+ int err;
+ int bw, bh;
+ struct bitmap * scrbuf = NULL;
+ struct bitmap * source = NULL;
+ bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
+ bool opaque = atari_bitmap_get_opaque( img );
+
+ if( opaque == false ){
+ if( ( (atari_plot_flags & PLOT_FLAG_TRANS) == 0)
+ &&
+ ((flags & (BITMAPF_MONOGLYPH|BITMAPF_BUFFER_NATIVE))==0) ){
+ opaque = true;
+ }
+ }
+
+
+ assert( clip->g_h > 0 );
+ assert( clip->g_w > 0 );
+
+ bw = atari_bitmap_get_width( img );
+ bh = atari_bitmap_get_height( img );
+
+ // The converted bitmap can be saved for subsequent blits, WHEN:
+ // A.) the bitmap is fully opaque OR
+ // B.) the bitmap is completly inside the window
+ // the latter one is important for alpha blits,
+ // because we must get the window background to apply transparency
+ // If the image is not completly within the window,
+ // we can't get the whole background for the image.
+ // this only works if the image isn't used at several different places.
+ // In fact in case of alpha bitmap caching it is only used for the
+ // toolbar buttons right now.
+
+ if( (opaque == true) || (flags & BITMAPF_BUFFER_NATIVE ) ){
+ if( img->converted == true ){
+ *out = img->native;
+ return( 0 );
+ }
+ if( ( flags & BITMAPF_MONOGLYPH ) == 0 ){
+ cache = true;
+ }
+ }
+
+ /* rem. if eddi xy is installed, we could directly access the screen! */
+ /* apply transparency to the image: */
+ if (( opaque == false )) {
+ /* copy the screen to an temp buffer: */
+ if ((flags & BITMAPF_BUFFER_NATIVE) == 0) {
+ scrbuf = snapshot_create(x, y, clip->g_w, clip->g_h);
+ if( scrbuf != NULL ) {
+
+ assert( clip->g_w <= bw );
+ assert( clip->g_h <= bh );
+
+ // copy blended pixels to the screen buffer:
+ ablend_bitmap( img, scrbuf, clip, NULL );
+ /* adjust size which gets converted: */
+ bw = clip->g_w;
+ bh = clip->g_h;
+ /* adjust output position: */
+ clip->g_x = 0;
+ clip->g_y = 0;
+ /* set the source of conversion: */
+ source = scrbuf;
+ }
+ } else {
+ /*
+ The whole bitmap can be transformed to an mfdb
+ (and get's cached)
+ */
+ GRECT region = { 0, 0, bw, bh };
+ ablend_pixel( img, bg, ®ion );
+ source = img;
+ }
+ } else {
+ source = img;
+ }
+ /* (re)allocate buffer for converted image: */
+ dststride = MFDB_STRIDE(bw);
+ dstsize = ( ((dststride >> 3) * bh) * atari_plot_bpp_virt );
+ if (cache == false) {
+ /* ensure cache buffer is large enough */
+ if (dstsize > size_buf_packed) {
+ int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
+ void *buf;
+ if (buf_packed == NULL) {
+ buf = malloc(blocks * CONV_BLOCK_SIZE);
+ } else {
+ buf = realloc(buf_packed, blocks * CONV_BLOCK_SIZE);
+ }
+ if (buf == NULL ) {
+ if (scrbuf != NULL) {
+ atari_bitmap_destroy(scrbuf);
+ }
+ return( 0-ERR_NO_MEM );
+ }
+ buf_packed = buf;
+ size_buf_packed = blocks * CONV_BLOCK_SIZE;
+ }
+ out->fd_addr = buf_packed;
+ } else {
+ assert( out->fd_addr == NULL );
+ out->fd_addr = (void*)malloc( dstsize );
+ if( out->fd_addr == NULL ){
+ if( scrbuf != NULL )
+ atari_bitmap_destroy( scrbuf );
+ return( 0-ERR_NO_MEM );
+ }
+ }
+
+ out->fd_w = dststride;
+ out->fd_h = bh;
+ out->fd_wdwidth = dststride >> 4;
+ out->fd_stand = 0;
+ out->fd_nplanes = (short)atari_plot_bpp_virt;
+ out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
+
+ err = Hermes_ConverterRequest(
+ hermes_cnv_h,
+ &nsfmt,
+ &vfmt
+ );
+ assert( err != 0 );
+
+ // FIXME: here we can use the same optimization which is used for
+ // the snapshot creation.
+
+ /* convert image to virtual format: */
+ err = Hermes_ConverterCopy( hermes_cnv_h,
+ source->pixdata,
+ 0, /* x src coord of top left in pixel coords */
+ 0, /* y src coord of top left in pixel coords */
+ bw, bh,
+ source->rowstride, /* stride as bytes */
+ out->fd_addr,
+ 0, /* x dst coord of top left in pixel coords */
+ 0, /* y dst coord of top left in pixel coords */
+ bw, bh,
+ (dststride >> 3) * atari_plot_bpp_virt /* stride as bytes */
+ );
+ assert( err != 0 );
+
+ if( cache == true ){
+ img->native = *out;
+ img->converted = true;
+ }
+ return( 0 );
}
- inline static void convert_bitmap_done(void)
+inline static void convert_bitmap_done(void)
{
- if (size_buf_packed > CONV_KEEP_LIMIT) {
- /* free the mem if it was an large allocation ... */
- buf_packed = realloc(buf_packed, CONV_KEEP_LIMIT);
- size_buf_packed = CONV_KEEP_LIMIT;
- }
+ if (size_buf_packed > CONV_KEEP_LIMIT) {
+ void *buf;
+ /* free the mem if it was an large allocation ... */
+ buf = realloc(buf_packed, CONV_KEEP_LIMIT);
+ if (buf != NULL) {
+ buf_packed = buf;
+ size_buf_packed = CONV_KEEP_LIMIT;
+ }
+ }
}
bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
- unsigned long bg, unsigned long flags )
+ unsigned long bg, unsigned long flags )
{
- MFDB src_mf;
- MFDB scrmf;
- short pxy[8];
- GRECT off, clip, vis;
- int screen_x, screen_y;
-
- src_mf.fd_addr = NULL;
- scrmf.fd_addr = NULL;
-
- off.g_x = x;
- off.g_y = y;
- off.g_h = bmp->height;
- off.g_w = bmp->width;
-
- // clip plotter clip rectangle:
- clip.g_x = view.clipping.x0;
- clip.g_y = view.clipping.y0;
- clip.g_w = view.clipping.x1 - view.clipping.x0;
- clip.g_h = view.clipping.y1 - view.clipping.y0;
-
- if( !rc_intersect( &clip, &off) ) {
- return(true);
- }
-
- // clip the visible rectangle of the plot area
- // this is the area of the plotter which falls into
- // screen region:
- plot_get_visible_grect(&vis);
- if( !rc_intersect( &vis, &off) ) {
- return(true);
- }
-
- screen_x = view.x + off.g_x;
- screen_y = view.y + off.g_y;
-
- // convert the clipping relative to bitmap:
- off.g_x = off.g_x - x;
- off.g_y = off.g_y - y;
- assert( (off.g_x >= 0) && (off.g_y >= 0) );
-
- /* Convert the Bitmap to native screen format - ready for output. */
- /* This includes blending transparent pixels: */
- if (bitmap_convert(bmp, screen_x, screen_y, &off, bg, flags, &src_mf)
- != 0 ) {
- return(true);
- }
-
- // setup the src region:
- pxy[0] = off.g_x;
- pxy[1] = off.g_y;
- pxy[2] = off.g_x + off.g_w-1;
- pxy[3] = off.g_y + off.g_h-1;
-
- // setup the target region:
- pxy[4] = screen_x;
- pxy[5] = screen_y;
- pxy[6] = screen_x + off.g_w-1;
- pxy[7] = screen_y + off.g_h-1;
-
- vro_cpyfm(atari_plot_vdi_handle, S_ONLY, (short*)&pxy, &src_mf, &scrmf);
- convert_bitmap_done();
- snapshot_suspend();
- return(true);
+ MFDB src_mf;
+ MFDB scrmf;
+ short pxy[8];
+ GRECT off, clip, vis;
+ int screen_x, screen_y;
+
+ src_mf.fd_addr = NULL;
+ scrmf.fd_addr = NULL;
+
+ off.g_x = x;
+ off.g_y = y;
+ off.g_h = bmp->height;
+ off.g_w = bmp->width;
+
+ // clip plotter clip rectangle:
+ clip.g_x = view.clipping.x0;
+ clip.g_y = view.clipping.y0;
+ clip.g_w = view.clipping.x1 - view.clipping.x0;
+ clip.g_h = view.clipping.y1 - view.clipping.y0;
+
+ if( !rc_intersect( &clip, &off) ) {
+ return(true);
+ }
+
+ // clip the visible rectangle of the plot area
+ // this is the area of the plotter which falls into
+ // screen region:
+ plot_get_visible_grect(&vis);
+ if( !rc_intersect( &vis, &off) ) {
+ return(true);
+ }
+
+ screen_x = view.x + off.g_x;
+ screen_y = view.y + off.g_y;
+
+ // convert the clipping relative to bitmap:
+ off.g_x = off.g_x - x;
+ off.g_y = off.g_y - y;
+ assert( (off.g_x >= 0) && (off.g_y >= 0) );
+
+ /* Convert the Bitmap to native screen format - ready for output. */
+ /* This includes blending transparent pixels: */
+ if (bitmap_convert(bmp, screen_x, screen_y, &off, bg, flags, &src_mf)
+ != 0 ) {
+ return(true);
+ }
+
+ // setup the src region:
+ pxy[0] = off.g_x;
+ pxy[1] = off.g_y;
+ pxy[2] = off.g_x + off.g_w-1;
+ pxy[3] = off.g_y + off.g_h-1;
+
+ // setup the target region:
+ pxy[4] = screen_x;
+ pxy[5] = screen_y;
+ pxy[6] = screen_x + off.g_w-1;
+ pxy[7] = screen_y + off.g_h-1;
+
+ vro_cpyfm(atari_plot_vdi_handle, S_ONLY, (short*)&pxy, &src_mf, &scrmf);
+ convert_bitmap_done();
+ snapshot_suspend();
+ return(true);
}
bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor,
- uint32_t flags)
+ uint32_t flags)
{
- MFDB screen;
-// MFDB tran;
- MFDB * src;
- short pxy[8];
- short c[2] = {fgcolor, 0};
- GRECT off;
-
- plot_get_clip_grect(&off);
- if( rc_intersect(loc, &off) == 0 ){
- return( 1 );
- }
-
- init_mfdb( 0, loc->g_w, loc->g_h, 0, &screen );
+ MFDB screen;
+// MFDB tran;
+ MFDB * src;
+ short pxy[8];
+ short c[2] = {fgcolor, 0};
+ GRECT off;
+
+ plot_get_clip_grect(&off);
+ if( rc_intersect(loc, &off) == 0 ){
+ return( 1 );
+ }
+
+ init_mfdb( 0, loc->g_w, loc->g_h, 0, &screen );
//
-// if( insrc->fd_stand){
-// printf("st\n");
-// int size = init_mfdb( insrc->fd_nplanes, loc->g_w, loc->g_h,
-// MFDB_FLAG_NOALLOC,
-// &tran
-// );
-// if( size_buf_scr == 0 ){
-// buf_scr.fd_addr = malloc( size );
-// size_buf_scr = size;
-// } else {
-// if( size > size_buf_scr ) {
-// buf_scr.fd_addr = realloc(
-// buf_scr.fd_addr, size
-// );
-// size_buf_scr = size;
-// }
-// }
-// tran.fd_addr = buf_scr.fd_addr;
-// vr_trnfm(atari_plot_vdi_handle, insrc, &tran );
-// src = &tran;
-// } else {
- src = insrc;
-// }
-
- pxy[0] = off.g_x - loc->g_x;
- pxy[1] = off.g_y - loc->g_y;
- pxy[2] = pxy[0] + off.g_w - 1;
- pxy[3] = pxy[1] + off.g_h - 1;
- pxy[4] = view.x + off.g_x;
- pxy[5] = view.y + off.g_y;
- pxy[6] = pxy[4] + off.g_w-1;
- pxy[7] = pxy[5] + off.g_h-1;
-
-
- if( flags & PLOT_FLAG_TRANS && src->fd_nplanes == 1){
- vrt_cpyfm(atari_plot_vdi_handle, MD_REPLACE/*MD_TRANS*/, (short*)pxy, src, &screen, (short*)&c);
- } else {
- /* this method only plots transparent bitmaps, right now... */
- }
- return( 1 );
+// if( insrc->fd_stand){
+// printf("st\n");
+// int size = init_mfdb( insrc->fd_nplanes, loc->g_w, loc->g_h,
+// MFDB_FLAG_NOALLOC,
+// &tran
+// );
+// if( size_buf_scr == 0 ){
+// buf_scr.fd_addr = malloc( size );
+// size_buf_scr = size;
+// } else {
+// if( size > size_buf_scr ) {
+// buf_scr.fd_addr = realloc(
+// buf_scr.fd_addr, size
+// );
+// size_buf_scr = size;
+// }
+// }
+// tran.fd_addr = buf_scr.fd_addr;
+// vr_trnfm(atari_plot_vdi_handle, insrc, &tran );
+// src = &tran;
+// } else {
+ src = insrc;
+// }
+
+ pxy[0] = off.g_x - loc->g_x;
+ pxy[1] = off.g_y - loc->g_y;
+ pxy[2] = pxy[0] + off.g_w - 1;
+ pxy[3] = pxy[1] + off.g_h - 1;
+ pxy[4] = view.x + off.g_x;
+ pxy[5] = view.y + off.g_y;
+ pxy[6] = pxy[4] + off.g_w-1;
+ pxy[7] = pxy[5] + off.g_h-1;
+
+
+ if( flags & PLOT_FLAG_TRANS && src->fd_nplanes == 1){
+ vrt_cpyfm(atari_plot_vdi_handle, MD_REPLACE/*MD_TRANS*/, (short*)pxy, src, &screen, (short*)&c);
+ } else {
+ /* this method only plots transparent bitmaps, right now... */
+ }
+ return( 1 );
}
/*
-Init screen and font driver objects.
-Returns non-zero value > -1 when the objects could be succesfully created.
-Returns value < 0 to indicate an error
+ Init screen and font driver objects.
+ Returns non-zero value > -1 when the objects could be succesfully created.
+ Returns value < 0 to indicate an error
*/
int plot_init(char * fdrvrname)
@@ -1537,16 +1553,16 @@ int plot_init(char * fdrvrname)
if( nsoption_int(atari_font_monochrom) == 1 )
atari_font_flags |= FONTPLOT_FLAG_MONOGLYPH;
- if(atari_plot_vdi_handle == -1) {
+ if(atari_plot_vdi_handle == -1) {
- short dummy;
- short work_in[12] = {Getrez()+2,1,1,1,1,1,1,1,1,1,2,1};
+ short dummy;
+ short work_in[12] = {Getrez()+2,1,1,1,1,1,1,1,1,1,2,1};
short work_out[57];
atari_plot_vdi_handle=graf_handle(&dummy, &dummy, &dummy, &dummy);
v_opnvwk(work_in, &atari_plot_vdi_handle, work_out);
LOG("Plot VDI handle: %d", atari_plot_vdi_handle);
}
- read_vdi_sysinfo(atari_plot_vdi_handle, &vdi_sysinfo);
+ read_vdi_sysinfo(atari_plot_vdi_handle, &vdi_sysinfo);
if(verbose_log) {
dump_vdi_info(atari_plot_vdi_handle) ;
dump_font_drivers();
@@ -1556,104 +1572,105 @@ int plot_init(char * fdrvrname)
atari_font_flags, &err);
if(err) {
const char * desc = plot_err_str(err);
- die(("Unable to load font plotter %s -> %s", fdrvrname, desc ));
+ LOG("Unable to load font plotter %s -> %s", fdrvrname, desc );
+ die("font plotter");
}
memset(&view, 0, sizeof(struct s_view));
atari_plot_bpp_virt = vdi_sysinfo.scr_bpp;
- view.x = loc_pos.g_x;
- view.y = loc_pos.g_y;
- view.w = loc_pos.g_w;
- view.h = loc_pos.g_h;
- size_buf_packed = 0;
- size_buf_planar = 0;
- buf_packed = NULL;
- buf_planar = NULL;
- if( vdi_sysinfo.vdiformat == VDI_FORMAT_PACK ) {
- atari_plot_bpp_virt = vdi_sysinfo.scr_bpp;
- } else {
- atari_plot_bpp_virt = 8;
- }
+ view.x = loc_pos.g_x;
+ view.y = loc_pos.g_y;
+ view.w = loc_pos.g_w;
+ view.h = loc_pos.g_h;
+ size_buf_packed = 0;
+ size_buf_planar = 0;
+ buf_packed = NULL;
+ buf_planar = NULL;
+ if( vdi_sysinfo.vdiformat == VDI_FORMAT_PACK ) {
+ atari_plot_bpp_virt = vdi_sysinfo.scr_bpp;
+ } else {
+ atari_plot_bpp_virt = 8;
+ }
plot_set_scale(1.0);
- update_visible_rect();
+ update_visible_rect();
- struct rect clip;
- clip.x0 = 0;
- clip.y0 = 0;
- clip.x1 = view.w;
- clip.y1 = view.h;
- plot_clip(&clip);
+ struct rect clip;
+ clip.x0 = 0;
+ clip.y0 = 0;
+ clip.x1 = view.w;
+ clip.y1 = view.h;
+ plot_clip(&clip);
- assert(Hermes_Init());
+ assert(Hermes_Init());
#ifdef WITH_8BPP_SUPPORT
- bitmap_convert = (vdi_sysinfo.scr_bpp > 8) ? bitmap_convert_tc : bitmap_convert_8;
-
- /* Setup color lookup tables and palette */
- unsigned char rgbcol[4];
- if( vdi_sysinfo.scr_bpp <= 8 ){
- unsigned char graytone=0;
- int i;
- for( i=0; i<=255; i++ ) {
-
- // get the current color and save it for restore:
- vq_color(atari_plot_vdi_handle, i, 1, (unsigned short*)&sys_pal[i][0] );
- if( i<OFFSET_WEB_PAL ) {
- pal[i][0] = sys_pal[i][0];
- pal[i][1] = sys_pal[i][1];
- pal[i][2] = sys_pal[i][2];
- } else if( vdi_sysinfo.scr_bpp >= 8 ) {
- if ( i < OFFSET_CUST_PAL ){
- pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0];
- pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1];
- pal[i][2] = vdi_web_pal[i-OFFSET_WEB_PAL][2];
- //set the new palette color to websafe value:
- vs_color(atari_plot_vdi_handle, i, &pal[i][0]);
- }
- if( i >= OFFSET_CUST_PAL && i<OFFSET_CUST_PAL+16 ) {
- /* here we define 20 additional gray colors... */
- rgbcol[1] = rgbcol[2] = rgbcol[3] = ((graytone&0x0F) << 4);
- rgb_to_vdi1000( &rgbcol[0], &pal[i][0] );
- vs_color(atari_plot_vdi_handle, i, &pal[i][0]);
- graytone++;
- }
-
- }
- vdi1000_to_rgb( &pal[i][0], &rgb_lookup[i][0] );
- }
-
- } else {
- /* no need to change the palette - its application specific */
- }
+ bitmap_convert = (vdi_sysinfo.scr_bpp > 8) ? bitmap_convert_tc : bitmap_convert_8;
+
+ /* Setup color lookup tables and palette */
+ unsigned char rgbcol[4];
+ if( vdi_sysinfo.scr_bpp <= 8 ){
+ unsigned char graytone=0;
+ int i;
+ for( i=0; i<=255; i++ ) {
+
+ // get the current color and save it for restore:
+ vq_color(atari_plot_vdi_handle, i, 1, (unsigned short*)&sys_pal[i][0] );
+ if( i<OFFSET_WEB_PAL ) {
+ pal[i][0] = sys_pal[i][0];
+ pal[i][1] = sys_pal[i][1];
+ pal[i][2] = sys_pal[i][2];
+ } else if( vdi_sysinfo.scr_bpp >= 8 ) {
+ if ( i < OFFSET_CUST_PAL ){
+ pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0];
+ pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1];
+ pal[i][2] = vdi_web_pal[i-OFFSET_WEB_PAL][2];
+ //set the new palette color to websafe value:
+ vs_color(atari_plot_vdi_handle, i, &pal[i][0]);
+ }
+ if( i >= OFFSET_CUST_PAL && i<OFFSET_CUST_PAL+16 ) {
+ /* here we define 20 additional gray colors... */
+ rgbcol[1] = rgbcol[2] = rgbcol[3] = ((graytone&0x0F) << 4);
+ rgb_to_vdi1000( &rgbcol[0], &pal[i][0] );
+ vs_color(atari_plot_vdi_handle, i, &pal[i][0]);
+ graytone++;
+ }
+
+ }
+ vdi1000_to_rgb( &pal[i][0], &rgb_lookup[i][0] );
+ }
+
+ } else {
+ /* no need to change the palette - its application specific */
+ }
#else
- bitmap_convert = bitmap_convert_tc;
+ bitmap_convert = bitmap_convert_tc;
#endif
- /* Setup Hermes conversion handles */
- unsigned long hermesflags = (atari_plot_flags & PLOT_FLAG_DITHER) ? HERMES_CONVERT_DITHER : 0;
- hermes_cnv_h = Hermes_ConverterInstance(hermesflags);
- assert( hermes_cnv_h );
- hermes_res_h = Hermes_ConverterInstance(hermesflags);
- assert( hermes_res_h );
-
- /* set up the src & dst format: */
- /* netsurf uses RGBA ... */
- nsfmt.a = 0xFFUL;
- nsfmt.b = 0x0FF00UL;
- nsfmt.g = 0x0FF0000UL;
- nsfmt.r = 0x0FF000000UL;
- nsfmt.bits = 32;
- nsfmt.indexed = false;
- nsfmt.has_colorkey = false;
-
- vfmt.r = vdi_sysinfo.mask_r;
- vfmt.g = vdi_sysinfo.mask_g;
- vfmt.b = vdi_sysinfo.mask_b;
- vfmt.a = vdi_sysinfo.mask_a;
- vfmt.bits = atari_plot_bpp_virt;
- vfmt.indexed = (atari_plot_bpp_virt <= 8) ? 1 : 0;
- vfmt.has_colorkey = 0;
+ /* Setup Hermes conversion handles */
+ unsigned long hermesflags = (atari_plot_flags & PLOT_FLAG_DITHER) ? HERMES_CONVERT_DITHER : 0;
+ hermes_cnv_h = Hermes_ConverterInstance(hermesflags);
+ assert( hermes_cnv_h );
+ hermes_res_h = Hermes_ConverterInstance(hermesflags);
+ assert( hermes_res_h );
+
+ /* set up the src & dst format: */
+ /* netsurf uses RGBA ... */
+ nsfmt.a = 0xFFUL;
+ nsfmt.b = 0x0FF00UL;
+ nsfmt.g = 0x0FF0000UL;
+ nsfmt.r = 0x0FF000000UL;
+ nsfmt.bits = 32;
+ nsfmt.indexed = false;
+ nsfmt.has_colorkey = false;
+
+ vfmt.r = vdi_sysinfo.mask_r;
+ vfmt.g = vdi_sysinfo.mask_g;
+ vfmt.b = vdi_sysinfo.mask_b;
+ vfmt.a = vdi_sysinfo.mask_a;
+ vfmt.bits = atari_plot_bpp_virt;
+ vfmt.indexed = (atari_plot_bpp_virt <= 8) ? 1 : 0;
+ vfmt.has_colorkey = 0;
return( err );
}
@@ -1664,220 +1681,220 @@ int plot_finalise( void )
delete_font_plotter(fplotter);
#ifdef WITH_8BPP_SUPPORT
- if (vfmt.indexed) {
- int i;
- for (i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++) {
- vs_color(atari_plot_vdi_handle, i, &sys_pal[i][0]);
- }
- }
+ if (vfmt.indexed) {
+ int i;
+ for (i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++) {
+ vs_color(atari_plot_vdi_handle, i, &sys_pal[i][0]);
+ }
+ }
#endif
- /* close Hermes stuff: */
- Hermes_ConverterReturn(hermes_cnv_h);
- Hermes_Done();
+ /* close Hermes stuff: */
+ Hermes_ConverterReturn(hermes_cnv_h);
+ Hermes_Done();
- /* free up temporary buffers */
- free(buf_packed );
- free(buf_planar);
- snapshot_destroy();
+ /* free up temporary buffers */
+ free(buf_packed );
+ free(buf_planar);
+ snapshot_destroy();
- return 0;
+ return 0;
}
bool plot_lock(void)
{
- if ((atari_plot_flags & PLOT_FLAG_LOCKED) != 0)
- return(true);
- if( !wind_update(BEG_UPDATE|0x100) )
- return(false);
- if( !wind_update(BEG_MCTRL|0x100) ){
- wind_update(END_UPDATE);
- return(false);
- }
- atari_plot_flags |= PLOT_FLAG_LOCKED;
- graf_mouse(M_OFF, NULL);
- return(true);
+ if ((atari_plot_flags & PLOT_FLAG_LOCKED) != 0)
+ return(true);
+ if( !wind_update(BEG_UPDATE|0x100) )
+ return(false);
+ if( !wind_update(BEG_MCTRL|0x100) ){
+ wind_update(END_UPDATE);
+ return(false);
+ }
+ atari_plot_flags |= PLOT_FLAG_LOCKED;
+ graf_mouse(M_OFF, NULL);
+ return(true);
}
bool plot_unlock(void)
{
- if( (atari_plot_flags & PLOT_FLAG_LOCKED) == 0 )
- return(true);
- wind_update(END_MCTRL);
- wind_update(END_UPDATE);
- graf_mouse(M_ON, NULL);
- vs_clip_off(atari_plot_vdi_handle);
- atari_plot_flags &= ~PLOT_FLAG_LOCKED;
- return(false);
+ if( (atari_plot_flags & PLOT_FLAG_LOCKED) == 0 )
+ return(true);
+ wind_update(END_MCTRL);
+ wind_update(END_UPDATE);
+ graf_mouse(M_ON, NULL);
+ vs_clip_off(atari_plot_vdi_handle);
+ atari_plot_flags &= ~PLOT_FLAG_LOCKED;
+ return(false);
}
bool plot_rectangle(int x0, int y0, int x1, int y1,
- const plot_style_t *pstyle )
+ const plot_style_t *pstyle )
{
- short pxy[4];
- GRECT r, rclip, sclip;
- int sw = pstyle->stroke_width;
- uint32_t lt;
-
- /* current canvas clip: */
- rclip.g_x = view.clipping.x0;
- rclip.g_y = view.clipping.y0;
- rclip.g_w = view.clipping.x1 - view.clipping.x0;
- rclip.g_h = view.clipping.y1 - view.clipping.y0;
-
- /* physical clipping: */
- sclip.g_x = rclip.g_x;
- sclip.g_y = rclip.g_y;
- sclip.g_w = view.vis_w;
- sclip.g_h = view.vis_h;
-
- rc_intersect(&sclip, &rclip);
- r.g_x = x0;
- r.g_y = y0;
- r.g_w = x1 - x0;
- r.g_h = y1 - y0;
-
- if (!rc_intersect( &rclip, &r )) {
- return(true);
- }
- if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
- /*
- manually draw the line, because we do not need vdi clipping
- for vertical / horizontal line draws.
- */
- if( sw == 0)
- sw = 1;
-
- NSLT2VDI(lt, pstyle);
- vsl_type(atari_plot_vdi_handle, (lt&0x0F));
- /*
- if the line style is not available within VDI system,
- define own style:
- */
- if( (lt&0x0F) == 7 ){
- vsl_udsty(atari_plot_vdi_handle, ((lt&0xFFFF00) >> 8));
- }
- vsl_width(atari_plot_vdi_handle, (short)sw );
- vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
- /* top border: */
- if( r.g_y == y0){
- pxy[0] = view.x + r.g_x;
- pxy[1] = view.y + r.g_y ;
- pxy[2] = view.x + r.g_x + r.g_w;
- pxy[3] = view.y + r.g_y;
- v_pline(atari_plot_vdi_handle, 2, (short *)&pxy);
- }
-
- /* right border: */
- if( r.g_x + r.g_w == x1 ){
- pxy[0] = view.x + r.g_x + r.g_w;
- pxy[1] = view.y + r.g_y;
- pxy[2] = view.x + r.g_x + r.g_w;
- pxy[3] = view.y + r.g_y + r.g_h;
- v_pline(atari_plot_vdi_handle, 2, (short *)&pxy);
- }
-
- /* bottom border: */
- if( r.g_y+r.g_h == y1 ){
- pxy[0] = view.x + r.g_x;
- pxy[1] = view.y + r.g_y+r.g_h;
- pxy[2] = view.x + r.g_x+r.g_w;
- pxy[3] = view.y + r.g_y+r.g_h;
- v_pline(atari_plot_vdi_handle, 2, (short *)&pxy);
- }
-
- /* left border: */
- if( r.g_x == x0 ){
- pxy[0] = view.x + r.g_x;
- pxy[1] = view.y + r.g_y;
- pxy[2] = view.x + r.g_x;
- pxy[3] = view.y + r.g_y + r.g_h;
- v_pline(atari_plot_vdi_handle, 2, (short *)&pxy);
- }
- }
-
- if( pstyle->fill_type != PLOT_OP_TYPE_NONE ){
- short stroke_width = (short)(pstyle->stroke_type != PLOT_OP_TYPE_NONE) ?
- pstyle->stroke_width : 0;
-
- vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
- vsf_perimeter(atari_plot_vdi_handle, 0);
- vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
-
-
- pxy[0] = view.x + r.g_x + stroke_width;
- pxy[1] = view.y + r.g_y + stroke_width;
- pxy[2] = view.x + r.g_x + r.g_w -1 - stroke_width;
- pxy[3] = view.y + r.g_y + r.g_h -1 - stroke_width;
-
- vsf_style(atari_plot_vdi_handle, 1);
- v_bar(atari_plot_vdi_handle, (short*)&pxy);
- }
+ short pxy[4];
+ GRECT r, rclip, sclip;
+ int sw = pstyle->stroke_width;
+ uint32_t lt;
+
+ /* current canvas clip: */
+ rclip.g_x = view.clipping.x0;
+ rclip.g_y = view.clipping.y0;
+ rclip.g_w = view.clipping.x1 - view.clipping.x0;
+ rclip.g_h = view.clipping.y1 - view.clipping.y0;
+
+ /* physical clipping: */
+ sclip.g_x = rclip.g_x;
+ sclip.g_y = rclip.g_y;
+ sclip.g_w = view.vis_w;
+ sclip.g_h = view.vis_h;
+
+ rc_intersect(&sclip, &rclip);
+ r.g_x = x0;
+ r.g_y = y0;
+ r.g_w = x1 - x0;
+ r.g_h = y1 - y0;
+
+ if (!rc_intersect( &rclip, &r )) {
+ return(true);
+ }
+ if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
+ /*
+ manually draw the line, because we do not need vdi clipping
+ for vertical / horizontal line draws.
+ */
+ if( sw == 0)
+ sw = 1;
+
+ NSLT2VDI(lt, pstyle);
+ vsl_type(atari_plot_vdi_handle, (lt&0x0F));
+ /*
+ if the line style is not available within VDI system,
+ define own style:
+ */
+ if( (lt&0x0F) == 7 ){
+ vsl_udsty(atari_plot_vdi_handle, ((lt&0xFFFF00) >> 8));
+ }
+ vsl_width(atari_plot_vdi_handle, (short)sw );
+ vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
+ /* top border: */
+ if( r.g_y == y0){
+ pxy[0] = view.x + r.g_x;
+ pxy[1] = view.y + r.g_y ;
+ pxy[2] = view.x + r.g_x + r.g_w;
+ pxy[3] = view.y + r.g_y;
+ v_pline(atari_plot_vdi_handle, 2, (short *)&pxy);
+ }
+
+ /* right border: */
+ if( r.g_x + r.g_w == x1 ){
+ pxy[0] = view.x + r.g_x + r.g_w;
+ pxy[1] = view.y + r.g_y;
+ pxy[2] = view.x + r.g_x + r.g_w;
+ pxy[3] = view.y + r.g_y + r.g_h;
+ v_pline(atari_plot_vdi_handle, 2, (short *)&pxy);
+ }
+
+ /* bottom border: */
+ if( r.g_y+r.g_h == y1 ){
+ pxy[0] = view.x + r.g_x;
+ pxy[1] = view.y + r.g_y+r.g_h;
+ pxy[2] = view.x + r.g_x+r.g_w;
+ pxy[3] = view.y + r.g_y+r.g_h;
+ v_pline(atari_plot_vdi_handle, 2, (short *)&pxy);
+ }
+
+ /* left border: */
+ if( r.g_x == x0 ){
+ pxy[0] = view.x + r.g_x;
+ pxy[1] = view.y + r.g_y;
+ pxy[2] = view.x + r.g_x;
+ pxy[3] = view.y + r.g_y + r.g_h;
+ v_pline(atari_plot_vdi_handle, 2, (short *)&pxy);
+ }
+ }
+
+ if( pstyle->fill_type != PLOT_OP_TYPE_NONE ){
+ short stroke_width = (short)(pstyle->stroke_type != PLOT_OP_TYPE_NONE) ?
+ pstyle->stroke_width : 0;
+
+ vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
+ vsf_perimeter(atari_plot_vdi_handle, 0);
+ vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
+
+
+ pxy[0] = view.x + r.g_x + stroke_width;
+ pxy[1] = view.y + r.g_y + stroke_width;
+ pxy[2] = view.x + r.g_x + r.g_w -1 - stroke_width;
+ pxy[3] = view.y + r.g_y + r.g_h -1 - stroke_width;
+
+ vsf_style(atari_plot_vdi_handle, 1);
+ v_bar(atari_plot_vdi_handle, (short*)&pxy);
+ }
return (true);
}
bool plot_line(int x0, int y0, int x1, int y1,
- const plot_style_t *pstyle )
+ const plot_style_t *pstyle )
{
- short pxy[4];
- uint32_t lt;
- int sw = pstyle->stroke_width;
-
- if((x0 < 0 && x1 < 0) || (y0 < 0 && y1 < 0)){
- return(true);
- }
-
- pxy[0] = view.x + MAX(0,x0);
- pxy[1] = view.y + MAX(0,y0);
- pxy[2] = view.x + MAX(0,x1);
- pxy[3] = view.y + MAX(0,y1);
-
- if((y0 > view.h-1) && (y1 > view.h-1))
- return(true);
-
- //printf("view: %d,%d,%d,%d\n", view.x, view.y, view.w, view.h);
- //printf("line: %d,%d,%d,%d\n", x0, y0, x1, y1);
-
-
- //plot_vdi_clip(true);
- if( sw == 0)
- sw = 1;
- NSLT2VDI(lt, pstyle)
- vsl_type(atari_plot_vdi_handle, (lt&0x0F));
- /* if the line style is not available within VDI system,define own style: */
- if( (lt&0x0F) == 7 ){
- vsl_udsty(atari_plot_vdi_handle, ((lt&0xFFFF00) >> 8));
- }
- vsl_width(atari_plot_vdi_handle, (short)sw);
- vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
- v_pline(atari_plot_vdi_handle, 2, (short *)&pxy );
- //plot_vdi_clip(false);
+ short pxy[4];
+ uint32_t lt;
+ int sw = pstyle->stroke_width;
+
+ if((x0 < 0 && x1 < 0) || (y0 < 0 && y1 < 0)){
+ return(true);
+ }
+
+ pxy[0] = view.x + MAX(0,x0);
+ pxy[1] = view.y + MAX(0,y0);
+ pxy[2] = view.x + MAX(0,x1);
+ pxy[3] = view.y + MAX(0,y1);
+
+ if((y0 > view.h-1) && (y1 > view.h-1))
+ return(true);
+
+ //printf("view: %d,%d,%d,%d\n", view.x, view.y, view.w, view.h);
+ //printf("line: %d,%d,%d,%d\n", x0, y0, x1, y1);
+
+
+ //plot_vdi_clip(true);
+ if( sw == 0)
+ sw = 1;
+ NSLT2VDI(lt, pstyle)
+ vsl_type(atari_plot_vdi_handle, (lt&0x0F));
+ /* if the line style is not available within VDI system,define own style: */
+ if( (lt&0x0F) == 7 ){
+ vsl_udsty(atari_plot_vdi_handle, ((lt&0xFFFF00) >> 8));
+ }
+ vsl_width(atari_plot_vdi_handle, (short)sw);
+ vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
+ v_pline(atari_plot_vdi_handle, 2, (short *)&pxy );
+ //plot_vdi_clip(false);
return (true);
}
static bool plot_polygon(const int *p, unsigned int n,
const plot_style_t *pstyle)
{
- short pxy[n*2];
- unsigned int i=0;
- if (vdi_sysinfo.maxpolycoords > 0)
- assert( (signed int)n < vdi_sysinfo.maxpolycoords);
-
- vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
- vsf_style(atari_plot_vdi_handle, 1);
- for (i = 0; i<n*2; i=i+2) {
- pxy[i] = (short)view.x+p[i];
- pxy[i+1] = (short)view.y+p[i+1];
- }
- if (pstyle->fill_type == PLOT_OP_TYPE_SOLID) {
- vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
- v_fillarea(atari_plot_vdi_handle, n, (short*)&pxy);
- } else {
- pxy[n*2]=pxy[0];
- pxy[n*2+1]=pxy[1];
- vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
- v_pline(atari_plot_vdi_handle, n+1, (short *)&pxy);
- }
+ short pxy[n*2];
+ unsigned int i=0;
+ if (vdi_sysinfo.maxpolycoords > 0)
+ assert( (signed int)n < vdi_sysinfo.maxpolycoords);
+
+ vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
+ vsf_style(atari_plot_vdi_handle, 1);
+ for (i = 0; i<n*2; i=i+2) {
+ pxy[i] = (short)view.x+p[i];
+ pxy[i+1] = (short)view.y+p[i+1];
+ }
+ if (pstyle->fill_type == PLOT_OP_TYPE_SOLID) {
+ vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
+ v_fillarea(atari_plot_vdi_handle, n, (short*)&pxy);
+ } else {
+ pxy[n*2]=pxy[0];
+ pxy[n*2+1]=pxy[1];
+ vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
+ v_pline(atari_plot_vdi_handle, n+1, (short *)&pxy);
+ }
return ( true );
}
@@ -1891,27 +1908,27 @@ static bool plot_polygon(const int *p, unsigned int n,
*/
bool plot_set_dimensions(int x, int y, int w, int h)
{
- bool doupdate = false;
- struct rect newclip = {0, 0, w, h};
- GRECT absclip = {x, y, w, h};
-
- if (!(w == view.w && h == view.h)) {
- view.w = (short)w;
- view.h = (short)h;
- doupdate = true;
- }
- if (!(x == view.x && y == view.y)) {
- view.x = (short)x;
- view.y = (short)y;
- doupdate = true;
- }
- if (doupdate==true)
- update_visible_rect();
-
- //dbg_rect("plot_set_dimensions", &newclip);
+ bool doupdate = false;
+ struct rect newclip = {0, 0, w, h};
+ GRECT absclip = {x, y, w, h};
+
+ if (!(w == view.w && h == view.h)) {
+ view.w = (short)w;
+ view.h = (short)h;
+ doupdate = true;
+ }
+ if (!(x == view.x && y == view.y)) {
+ view.x = (short)x;
+ view.y = (short)y;
+ doupdate = true;
+ }
+ if (doupdate==true)
+ update_visible_rect();
+
+ //dbg_rect("plot_set_dimensions", &newclip);
plot_set_abs_clipping(&absclip);
- plot_clip(&newclip);
+ plot_clip(&newclip);
return(true);
}
@@ -1922,11 +1939,11 @@ bool plot_set_dimensions(int x, int y, int w, int h)
*/
bool plot_get_dimensions(GRECT *dst)
{
- dst->g_x = view.x;
- dst->g_y = view.y;
- dst->g_w = view.w;
- dst->g_h = view.h;
- return(true);
+ dst->g_x = view.x;
+ dst->g_y = view.y;
+ dst->g_w = view.w;
+ dst->g_h = view.h;
+ return(true);
}
/**
@@ -1955,7 +1972,7 @@ float plot_get_scale(void)
* Subsequent calls to plot_clip will be clipped by the absolute clip.
* \param area the maximum clipping rectangle (absolute screen coords)
*
-*/
+ */
void plot_set_abs_clipping(const GRECT *area)
{
GRECT canvas;
@@ -2001,72 +2018,72 @@ void plot_get_abs_clipping_grect(GRECT *dst)
bool plot_clip(const struct rect *clip)
{
- GRECT canvas, screen, gclip, maxclip;
- short pxy[4];
+ GRECT canvas, screen, gclip, maxclip;
+ short pxy[4];
- screen.g_x = 0;
- screen.g_y = 0;
- screen.g_w = vdi_sysinfo.scr_w;
- screen.g_h = vdi_sysinfo.scr_h;
+ screen.g_x = 0;
+ screen.g_y = 0;
+ screen.g_w = vdi_sysinfo.scr_w;
+ screen.g_h = vdi_sysinfo.scr_h;
- plot_get_dimensions(&canvas);
+ plot_get_dimensions(&canvas);
- view.clipping.y0 = clip->y0;
- view.clipping.y1 = clip->y1;
- view.clipping.x0 = clip->x0;
- view.clipping.x1 = clip->x1;
+ view.clipping.y0 = clip->y0;
+ view.clipping.y1 = clip->y1;
+ view.clipping.x0 = clip->x0;
+ view.clipping.x1 = clip->x1;
- plot_get_clip_grect(&gclip);
+ plot_get_clip_grect(&gclip);
- gclip.g_x += canvas.g_x;
- gclip.g_y += canvas.g_y;
+ gclip.g_x += canvas.g_x;
+ gclip.g_y += canvas.g_y;
- rc_intersect(&canvas, &gclip);
+ rc_intersect(&canvas, &gclip);
- if(gclip.g_h < 0){
- gclip.g_h = 0;
- }
+ if(gclip.g_h < 0){
+ gclip.g_h = 0;
+ }
- if (!rc_intersect(&screen, &gclip)) {
- //dbg_rect("cliprect: ", &view.clipping);
- //dbg_grect("screen: ", &canvas);
- //dbg_grect("canvas clipped: ", &gclip);
- //assert(1 == 0);
- }
+ if (!rc_intersect(&screen, &gclip)) {
+ //dbg_rect("cliprect: ", &view.clipping);
+ //dbg_grect("screen: ", &canvas);
+ //dbg_grect("canvas clipped: ", &gclip);
+ //assert(1 == 0);
+ }
// When setting VDI clipping, obey to maximum cliping rectangle:
- plot_get_abs_clipping_grect(&maxclip);
- rc_intersect(&maxclip, &gclip);
+ plot_get_abs_clipping_grect(&maxclip);
+ rc_intersect(&maxclip, &gclip);
- //dbg_grect("canvas clipped to screen", &gclip);
+ //dbg_grect("canvas clipped to screen", &gclip);
- pxy[0] = gclip.g_x;
- pxy[1] = gclip.g_y;
- pxy[2] = pxy[0] + gclip.g_w;
- pxy[3] = pxy[1] + gclip.g_h;
+ pxy[0] = gclip.g_x;
+ pxy[1] = gclip.g_y;
+ pxy[2] = pxy[0] + gclip.g_w;
+ pxy[3] = pxy[1] + gclip.g_h;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy);
+ vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy);
return ( true );
}
VdiHdl plot_get_vdi_handle(void)
{
- return(atari_plot_vdi_handle);
+ return(atari_plot_vdi_handle);
}
long plot_get_flags(void)
{
- return(atari_plot_flags);
+ return(atari_plot_flags);
}
bool plot_get_clip(struct rect * out)
{
- out->x0 = view.clipping.x0;
- out->y0 = view.clipping.y0;
- out->x1 = view.clipping.x1;
- out->y1 = view.clipping.y1;
+ out->x0 = view.clipping.x0;
+ out->y0 = view.clipping.y0;
+ out->x1 = view.clipping.x1;
+ out->y1 = view.clipping.y1;
return( true );
}
@@ -2084,12 +2101,12 @@ void plot_get_clip_grect(GRECT * out)
FONT_PLOTTER plot_get_text_plotter()
{
- return(fplotter);
+ return(fplotter);
}
void plot_set_text_plotter(FONT_PLOTTER font_plotter)
{
- fplotter = font_plotter;
+ fplotter = font_plotter;
}
static bool plot_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle )
@@ -2107,17 +2124,17 @@ static bool plot_text(int x, int y, const char *text, size_t length, const plot_
static bool plot_disc(int x, int y, int radius, const plot_style_t *pstyle)
{
- if (pstyle->fill_type != PLOT_OP_TYPE_SOLID) {
- vsf_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
- vsf_perimeter(atari_plot_vdi_handle, 1);
- vsf_interior(atari_plot_vdi_handle, 0);
- v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius);
- } else {
- vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
- vsf_perimeter(atari_plot_vdi_handle, 0);
- vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
- v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius);
- }
+ if (pstyle->fill_type != PLOT_OP_TYPE_SOLID) {
+ vsf_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
+ vsf_perimeter(atari_plot_vdi_handle, 1);
+ vsf_interior(atari_plot_vdi_handle, 0);
+ v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius);
+ } else {
+ vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
+ vsf_perimeter(atari_plot_vdi_handle, 0);
+ vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
+ v_circle(atari_plot_vdi_handle, view.x + x, view.y + y, radius);
+ }
return(true);
}
@@ -2126,20 +2143,20 @@ static bool plot_arc(int x, int y, int radius, int angle1, int angle2,
const plot_style_t *pstyle)
{
- vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
- if (pstyle->fill_type == PLOT_OP_TYPE_NONE)
- return(true);
- if ( pstyle->fill_type != PLOT_OP_TYPE_SOLID) {
- vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
- vsf_perimeter(atari_plot_vdi_handle, 1);
- vsf_interior(atari_plot_vdi_handle, 1 );
- v_arc(atari_plot_vdi_handle, view.x + x, view.y + y, radius, angle1*10, angle2*10);
- } else {
- vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
- vsl_width(atari_plot_vdi_handle, 1 );
- vsf_perimeter(atari_plot_vdi_handle, 1);
- v_arc(atari_plot_vdi_handle, view.x + x, view.y + y, radius, angle1*10, angle2*10);
- }
+ vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
+ if (pstyle->fill_type == PLOT_OP_TYPE_NONE)
+ return(true);
+ if ( pstyle->fill_type != PLOT_OP_TYPE_SOLID) {
+ vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
+ vsf_perimeter(atari_plot_vdi_handle, 1);
+ vsf_interior(atari_plot_vdi_handle, 1 );
+ v_arc(atari_plot_vdi_handle, view.x + x, view.y + y, radius, angle1*10, angle2*10);
+ } else {
+ vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
+ vsl_width(atari_plot_vdi_handle, 1 );
+ vsf_perimeter(atari_plot_vdi_handle, 1);
+ v_arc(atari_plot_vdi_handle, view.x + x, view.y + y, radius, angle1*10, angle2*10);
+ }
return (true);
}
@@ -2203,10 +2220,10 @@ static bool plot_bitmap(int x, int y, int width, int height,
xoff = (clip.x0 - width) + ((xoff - clip.x0) % width);
/* for now, repeating just works in the rigth / down direction */
/*
- if( repeat_x == true )
- xoff = clip.x0;
- if(repeat_y == true )
- yoff = clip.y0;
+ if( repeat_x == true )
+ xoff = clip.x0;
+ if(repeat_y == true )
+ yoff = clip.y0;
*/
for( xf = xoff; xf < clip.x1; xf += width ) {
diff --git a/frontends/atari/plot/plot.h b/frontends/atari/plot/plot.h
index 22f8781..fd73a8c 100644
--- a/frontends/atari/plot/plot.h
+++ b/frontends/atari/plot/plot.h
@@ -54,6 +54,8 @@
#define ERR_NO_MEM 2 /* Not enough memory for requested operation */
#define ERR_PLOTTER_NOT_AVAILABLE 3 /* invalid plotter driver name passed */
+struct plot_style_s;
+
struct s_vdi_sysinfo {
short vdi_handle; /**< vdi handle */
short scr_w; /**< resolution horz. */
@@ -104,8 +106,8 @@ void plot_get_clip_grect(GRECT * out);
bool plot_clip(const struct rect *clip);
VdiHdl plot_get_vdi_handle(void);
long plot_get_flags(void);
-bool plot_rectangle( int x0, int y0, int x1, int y1,const plot_style_t *style );
-bool plot_line( int x0, int y0, int x1, int y1, const plot_style_t *style );
+bool plot_rectangle( int x0, int y0, int x1, int y1,const struct plot_style_s *style );
+bool plot_line( int x0, int y0, int x1, int y1, const struct plot_style_s *style );
bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
unsigned long bg, unsigned long flags);
bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor, uint32_t flags);
diff --git a/frontends/atari/rootwin.c b/frontends/atari/rootwin.c
index 605ce45..dd41e17 100644
--- a/frontends/atari/rootwin.c
+++ b/frontends/atari/rootwin.c
@@ -14,10 +14,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Module Description:
- *
- * This File implements the NetSurf Browser window, or passed functionality to
+ */
+
+/**
+ * \file
+ * Implements the NetSurf Browser window, or passed functionality to
* the appropriate widget's.
*
*/
@@ -37,13 +38,11 @@
#include <mt_gem.h>
#include "utils/log.h"
-#include "desktop/browser.h"
-#include "desktop/mouse.h"
-#include "desktop/plotters.h"
-#include "desktop/textinput.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
+#include "utils/nsurl.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
+#include "netsurf/keypress.h"
#include "atari/res/netsurf.rsh"
#include "atari/gemtk/gemtk.h"
diff --git a/frontends/atari/search.c b/frontends/atari/search.c
index d72d3ca..4da7f16 100644
--- a/frontends/atari/search.c
+++ b/frontends/atari/search.c
@@ -27,9 +27,9 @@
#include "utils/log.h"
#include "utils/messages.h"
-#include "desktop/browser.h"
+#include "netsurf/browser_window.h"
#include "desktop/search.h"
-#include "desktop/gui_search.h"
+#include "netsurf/search.h"
#include "atari/gui.h"
#include "atari/rootwin.h"
diff --git a/frontends/atari/statusbar.c b/frontends/atari/statusbar.c
index c9d0f78..3a216f9 100644
--- a/frontends/atari/statusbar.c
+++ b/frontends/atari/statusbar.c
@@ -28,8 +28,8 @@
#include <math.h>
#include "utils/log.h"
-#include "desktop/mouse.h"
-#include "desktop/plotters.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
#include "atari/gui.h"
#include "atari/statusbar.h"
diff --git a/frontends/atari/toolbar.c b/frontends/atari/toolbar.c
index f630332..66bd44b 100644
--- a/frontends/atari/toolbar.c
+++ b/frontends/atari/toolbar.c
@@ -31,16 +31,14 @@
#include "utils/nsoption.h"
#include "utils/nsurl.h"
#include "utils/utf8.h"
-#include "desktop/browser_history.h"
-#include "desktop/browser.h"
-#include "desktop/mouse.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
+#include "netsurf/keypress.h"
#include "desktop/plot_style.h"
-#include "desktop/plotters.h"
-#include "desktop/tree.h"
+#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
#include "desktop/textarea.h"
-#include "desktop/textinput.h"
-#include "content/hlcache.h"
#include "atari/clipboard.h"
#include "atari/gui.h"
@@ -72,7 +70,7 @@ struct s_toolbar;
struct s_tb_button {
short rsc_id;
void (*cb_click)(struct s_toolbar *tb);
- hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
+ struct hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
struct s_toolbar *owner;
enum e_toolbar_button_states state;
short index;
diff --git a/frontends/atari/treeview.c b/frontends/atari/treeview.c
index 513e2df..731c032 100644
--- a/frontends/atari/treeview.c
+++ b/frontends/atari/treeview.c
@@ -27,9 +27,9 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "content/urldb.h"
-#include "desktop/plotters.h"
-#include "desktop/mouse.h"
+#include "netsurf/plotters.h"
+#include "netsurf/mouse.h"
+#include "netsurf/core_window.h"
#include "desktop/treeview.h"
#include "atari/gui.h"
diff --git a/frontends/atari/treeview.h b/frontends/atari/treeview.h
index a6b4a62..d10129e 100644
--- a/frontends/atari/treeview.h
+++ b/frontends/atari/treeview.h
@@ -19,10 +19,11 @@
#ifndef NSATARI_TREEVIEW_H
#define NSATARI_TREEVIEW_H
-#include "desktop/core_window.h"
#include "atari/gui.h"
#include "atari/gemtk/gemtk.h"
+struct core_window_callback_table;
+
/**
* Default AES Window widgets for a treeview window, can be passed to
* atari_treeview_create as the flags parameter to have an standardized treeview
diff --git a/frontends/atari/verify_ssl.c b/frontends/atari/verify_ssl.c
index cbd9d0b..055fd30 100644
--- a/frontends/atari/verify_ssl.c
+++ b/frontends/atari/verify_ssl.c
@@ -27,8 +27,7 @@
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "content/urldb.h"
-#include "content/fetch.h"
+
#include "atari/res/netsurf.rsh"
#include "atari/verify_ssl.h"
diff --git a/frontends/beos/Makefile b/frontends/beos/Makefile
index 19ab43f..f40cce4 100644
--- a/frontends/beos/Makefile
+++ b/frontends/beos/Makefile
@@ -29,7 +29,7 @@ CFLAGS += -I$(PREFIX)/include
CXXFLAGS += -Dnsbeos -D_BSD_SOURCE -D_POSIX_C_SOURCE -Drestrict="" -g
CXXFLAGS += -I$(PREFIX)/include
-VERSION_FULL := $(shell sed -n '/_version.*=.*"/{s/.*"\(.*\)".*/\1/;p;}' desktop/version.c)
+VERSION_FULL := $(shell sed -n '/_version.*=.*"/{s/.*"\(.*\)".*/\1/;p;}' desktop/version.c))
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)
diff --git a/frontends/beos/about.cpp b/frontends/beos/about.cpp
index 89eb818..70268ce 100644
--- a/frontends/beos/about.cpp
+++ b/frontends/beos/about.cpp
@@ -26,7 +26,7 @@ extern "C" {
#include "testament.h"
#include "utils/useragent.h"
#include "curl/curlver.h"
-#include "desktop/gui_clipboard.h"
+#include "netsurf/clipboard.h"
}
#include "beos/about.h"
#include "beos/scaffolding.h"
diff --git a/frontends/beos/bitmap.cpp b/frontends/beos/bitmap.cpp
index 26b7a39..68d8442 100644
--- a/frontends/beos/bitmap.cpp
+++ b/frontends/beos/bitmap.cpp
@@ -38,11 +38,11 @@
extern "C" {
#include "utils/log.h"
-#include "content/content.h"
-#include "content/urldb.h"
-#include "desktop/plotters.h"
-#include "desktop/browser.h"
-#include "image/bitmap.h"
+#include "netsurf/plotters.h"
+#include "netsurf/content_type.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/bitmap.h"
+#include "netsurf/content.h"
}
#include "beos/bitmap.h"
diff --git a/frontends/beos/cookies.cpp b/frontends/beos/cookies.cpp
index d1357ff..91a9beb 100644
--- a/frontends/beos/cookies.cpp
+++ b/frontends/beos/cookies.cpp
@@ -21,13 +21,12 @@
#include <stdlib.h>
#include <string.h>
extern "C" {
-#include "desktop/mouse.h"
#include "utils/log.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
+#include "netsurf/cookie_db.h"
+#include "netsurf/keypress.h"
#include "desktop/cookie_manager.h"
-#include "desktop/plotters.h"
-#include "desktop/tree.h"
-#include "desktop/textinput.h"
-#include "content/urldb.h"
}
#include "beos/cookies.h"
diff --git a/frontends/beos/download.cpp b/frontends/beos/download.cpp
index ea0271e..b64591c 100644
--- a/frontends/beos/download.cpp
+++ b/frontends/beos/download.cpp
@@ -23,7 +23,7 @@
extern "C" {
#include "desktop/download.h"
-#include "desktop/gui_download.h"
+#include "netsurf/download.h"
#include "utils/utils.h"
#include "utils/string.h"
}
diff --git a/frontends/beos/fetch_rsrc.cpp b/frontends/beos/fetch_rsrc.cpp
index b771f7b..e77f4c9 100644
--- a/frontends/beos/fetch_rsrc.cpp
+++ b/frontends/beos/fetch_rsrc.cpp
@@ -30,26 +30,26 @@
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/utsname.h>
-#include <curl/curl.h> /* for URL unescaping functions */
+#include <image.h>
+#include <Resources.h>
+#include <String.h>
+#include <libwapcaplet/libwapcaplet.h>
+
extern "C" {
#include "utils/config.h"
-#include "content/fetch.h"
-#include "content/fetchers.h"
-#include "content/urldb.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/ring.h"
-#include "utils/base64.h"
+#include "content/fetch.h"
+#include "content/fetchers.h"
}
+
#include "beos/fetch_rsrc.h"
#include "beos/filetype.h"
#include "beos/gui.h"
-#include <image.h>
-#include <Resources.h>
-#include <String.h>
struct fetch_rsrc_context {
struct fetch *parent_fetch;
@@ -151,10 +151,10 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
{
fetch_msg msg;
char *params;
- char *at = NULL;
+ //char *at = NULL;
char *slash;
- char *comma = NULL;
- char *unescaped;
+ //char *comma = NULL;
+ //char *unescaped;
uint32 type = 'data'; // default for embeded files
int32 id = 0;
@@ -368,6 +368,7 @@ void fetch_rsrc_register(void)
fetch_rsrc_abort,
fetch_rsrc_free,
fetch_rsrc_poll,
+ NULL,
fetch_rsrc_finalise
};
diff --git a/frontends/beos/filetype.cpp b/frontends/beos/filetype.cpp
index 75a3324..7a2ca97 100644
--- a/frontends/beos/filetype.cpp
+++ b/frontends/beos/filetype.cpp
@@ -31,7 +31,6 @@
#include <String.h>
extern "C" {
-#include "content/fetch.h"
#include "utils/log.h"
#include "utils/hashtable.h"
#include "utils/utils.h"
@@ -91,7 +90,7 @@ void beos_fetch_filetype_fin(void)
const char *fetch_filetype(const char *unix_path)
{
- struct stat statbuf;
+ // struct stat statbuf;
status_t err;
int i;
// NOT THREADSAFE
diff --git a/frontends/beos/font.cpp b/frontends/beos/font.cpp
index 003af52..407918f 100644
--- a/frontends/beos/font.cpp
+++ b/frontends/beos/font.cpp
@@ -36,7 +36,7 @@ extern "C" {
#include "utils/log.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
-#include "desktop/gui_layout.h"
+#include "netsurf/layout.h"
}
#include "beos/gui.h"
diff --git a/frontends/beos/gui.cpp b/frontends/beos/gui.cpp
index 2e0aa4c..d3321b5 100644
--- a/frontends/beos/gui.cpp
+++ b/frontends/beos/gui.cpp
@@ -30,7 +30,6 @@
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <curl/curl.h>
#include <Alert.h>
#include <Application.h>
@@ -54,20 +53,17 @@ extern "C" {
#include "utils/corestrings.h"
#include "utils/utf8.h"
#include "utils/utils.h"
-
-#include "content/content.h"
-#include "content/content_protected.h"
+#include "utils/nsurl.h"
+#include "netsurf/misc.h"
+#include "netsurf/clipboard.h"
+#include "netsurf/search.h"
+#include "netsurf/fetch.h"
+#include "netsurf/netsurf.h"
+#include "netsurf/content.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/cookie_db.h"
+#include "netsurf/url_db.h"
#include "content/fetch.h"
-#include "content/fetchers.h"
-#include "content/fetchers/resource.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "desktop/gui_misc.h"
-#include "desktop/gui_clipboard.h"
-#include "desktop/gui_search.h"
-#include "desktop/gui_fetch.h"
-#include "desktop/netsurf.h"
}
@@ -742,7 +738,7 @@ void nsbeos_gui_poll(void)
bigtime_t next_schedule = 0;
/* get any active fetcher fd */
- fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
+ fetch_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
/* run the scheduler */
schedule_run();
@@ -798,12 +794,14 @@ static void gui_quit(void)
static char *url_to_path(const char *url)
{
- char *url_path = curl_unescape(url, 0);
- char *path;
+ char *url_path;
+ char *path = NULL;
- /* return the absolute path including leading / */
- path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1));
- curl_free(url_path);
+ if (url_unescape(url, 0, NULL, &url_path) == NSERROR_OK) {
+ /* return the absolute path including leading / */
+ path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1));
+ free(url_path);
+ }
return path;
}
@@ -842,13 +840,28 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
* allow it to be re-used next time NetSurf is started. The
* memory overhead from doing this is under 1 byte per
* filename. */
- const char *filename = filename_request();
- if (!filename) {
+ BString filename(filename_request());
+ if (filename.IsEmpty()) {
beos_warn_user("NoMemory", 0);
return;
}
+
+ lwc_string *mime = content_get_mime_type(content);
+
+ /* provide an extension, as Pe still doesn't sniff the MIME */
+ if (mime) {
+ BMimeType type(lwc_string_data(mime));
+ BMessage extensions;
+ if (type.GetFileExtensions(&extensions) == B_OK) {
+ BString ext;
+ if (extensions.FindString("extensions", &ext) == B_OK)
+ filename << "." << ext;
+ }
+ /* we unref(mime) later on, we just leak on error */
+ }
+
path.SetTo(TEMP_FILENAME_PREFIX);
- path.Append(filename);
+ path.Append(filename.String());
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
err = file.InitCheck();
if (err < B_OK) {
@@ -860,7 +873,7 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
beos_warn_user("IOError", strerror(err));
return;
}
- lwc_string *mime = content_get_mime_type(content);
+
if (mime) {
file.WriteAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0LL,
lwc_string_data(mime), lwc_string_length(mime) + 1);
@@ -879,6 +892,7 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
// apps to try
const char *editorSigs[] = {
+ "text/x-source-code",
"application/x-vnd.beunited.pe",
"application/x-vnd.XEmacs",
"application/x-vnd.Haiku-StyledEdit",
@@ -893,10 +907,11 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
BMessenger msgr(editorSigs[i], team);
if (msgr.SendMessage(&m) >= B_OK)
break;
+
}
err = be_roster->Launch(editorSigs[i], (BMessage *)&m, &team);
- if (err >= B_OK)
+ if (err >= B_OK || err == B_ALREADY_RUNNING)
break;
}
}
@@ -1023,7 +1038,7 @@ int main(int argc, char** argv)
char path[12];
sprintf(path,"%.2s/Messages", getenv("LC_MESSAGES"));
- fprintf(stderr, "Loading messages from resource %s\n", path);
+ LOG("Loading messages from resource %s\n", path);
const uint8_t* res = (const uint8_t*)resources.LoadResource('data', path, &size);
if (size > 0 && res != NULL) {
diff --git a/frontends/beos/gui.h b/frontends/beos/gui.h
index 774820b..debb5f3 100644
--- a/frontends/beos/gui.h
+++ b/frontends/beos/gui.h
@@ -35,8 +35,7 @@ extern bool nsbeos_done;
extern bool replicated;
int gui_init_replicant(int argc, char** argv);
-extern "C" void gui_401login_open(nsurl *url, const char *realm,
- nserror (*cb)(bool proceed, void *pw), void *cbpw);
+extern "C" void gui_401login_open(struct nsurl *url, const char *realm, nserror (*cb)(bool proceed, void *pw), void *cbpw);
extern "C" void nsbeos_gui_poll(void);
@@ -44,15 +43,15 @@ extern char *options_file_location;
class NSBrowserApplication : public BApplication {
public:
- NSBrowserApplication();
-virtual ~NSBrowserApplication();
+ NSBrowserApplication();
+ virtual ~NSBrowserApplication();
-virtual void MessageReceived(BMessage *message);
-virtual void RefsReceived(BMessage *message);
-virtual void ArgvReceived(int32 argc, char **argv);
+ virtual void MessageReceived(BMessage *message);
+ virtual void RefsReceived(BMessage *message);
+ virtual void ArgvReceived(int32 argc, char **argv);
-virtual void AboutRequested();
-virtual bool QuitRequested();
+ virtual void AboutRequested();
+ virtual bool QuitRequested();
};
extern BWindow *wndAbout;
diff --git a/frontends/beos/login.cpp b/frontends/beos/login.cpp
index 7689c9d..8506298 100644
--- a/frontends/beos/login.cpp
+++ b/frontends/beos/login.cpp
@@ -26,40 +26,42 @@
#include <TextControl.h>
#include <View.h>
#include <Window.h>
+
extern "C" {
#include "utils/log.h"
-#include "content/content.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
#include "utils/messages.h"
#include "utils/url.h"
#include "utils/utils.h"
-#include "desktop/gui_clipboard.h"
+#include "utils/nsurl.h"
+#include "netsurf/content_type.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/clipboard.h"
}
+
#include "beos/gui.h"
#include "beos/scaffolding.h"
#include "beos/window.h"
class LoginAlert : public BAlert {
public:
- LoginAlert(nserror (*callback)(bool proceed, void *pw),
- void *callbaclpw,
- nsurl *url,
- const char *host,
- const char *realm,
- const char *text);
- virtual ~LoginAlert();
- void MessageReceived(BMessage *message);
+ LoginAlert(nserror (*callback)(bool proceed, void *pw),
+ void *callbaclpw,
+ nsurl *url,
+ const char *host,
+ const char *realm,
+ const char *text);
+ virtual ~LoginAlert();
+ void MessageReceived(BMessage *message);
private:
- nsurl* fUrl; /**< URL being fetched */
- BString fHost; /**< Host for user display */
- BString fRealm; /**< Authentication realm */
- nserror (*fCallback)(bool proceed, void *pw);
- void *fCallbackPw;
-
- BTextControl *fUserControl;
- BTextControl *fPassControl;
+ nsurl* fUrl; /**< URL being fetched */
+ BString fHost; /**< Host for user display */
+ BString fRealm; /**< Authentication realm */
+ nserror (*fCallback)(bool proceed, void *pw);
+ void *fCallbackPw;
+
+ BTextControl *fUserControl;
+ BTextControl *fPassControl;
};
static void create_login_window(nsurl *host,
diff --git a/frontends/beos/plotters.cpp b/frontends/beos/plotters.cpp
index 3fd786e..5ba3fbb 100644
--- a/frontends/beos/plotters.cpp
+++ b/frontends/beos/plotters.cpp
@@ -31,7 +31,7 @@
#include <View.h>
#include <Shape.h>
extern "C" {
-#include "desktop/plotters.h"
+#include "netsurf/plotters.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
diff --git a/frontends/beos/scaffolding.cpp b/frontends/beos/scaffolding.cpp
index 630e059..5e386bd 100644
--- a/frontends/beos/scaffolding.cpp
+++ b/frontends/beos/scaffolding.cpp
@@ -51,24 +51,27 @@
#endif
#include <fs_attr.h>
+
extern "C" {
-#include "content/content.h"
-#include "desktop/browser_history.h"
-#include "desktop/browser.h"
-#include "desktop/netsurf.h"
-#include "desktop/version.h"
-#include "desktop/searchweb.h"
-#include "desktop/search.h"
-#include "desktop/plotters.h"
-#include "utils/nsoption.h"
-#include "desktop/textinput.h"
-#include "render/form.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/nsurl.h"
-#include "desktop/gui_clipboard.h"
+#include "utils/nsoption.h"
+#include "netsurf/netsurf.h"
+#include "netsurf/plotters.h"
+#include "netsurf/clipboard.h"
+#include "netsurf/content.h"
+#include "netsurf/content_type.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/form.h"
+#include "netsurf/keypress.h"
+#include "desktop/browser_history.h"
+#include "desktop/version.h"
+#include "desktop/searchweb.h"
+#include "desktop/search.h"
}
+
#include "beos/about.h"
#include "beos/bitmap.h"
#include "beos/gui.h"
@@ -130,6 +133,9 @@ struct beos_scaffolding {
int being_destroyed;
bool fullscreen;
+
+ /** Object under menu, or 0 if no object. */
+ struct hlcache_handle *current_menu_object;
};
struct beos_history_window {
@@ -726,6 +732,15 @@ NSBrowserWindow::MessageReceived(BMessage *message)
case B_ARGV_RECEIVED:
case B_REFS_RECEIVED:
case B_UI_SETTINGS_CHANGED:
+ // NetPositive messages
+ case B_NETPOSITIVE_OPEN_URL:
+ case B_NETPOSITIVE_BACK:
+ case B_NETPOSITIVE_FORWARD:
+ case B_NETPOSITIVE_HOME:
+ case B_NETPOSITIVE_RELOAD:
+ case B_NETPOSITIVE_STOP:
+ case B_NETPOSITIVE_DOWN:
+ case B_NETPOSITIVE_UP:
DetachCurrentMessage();
nsbeos_pipe_message_top(message, this, fScaffolding);
break;
@@ -1242,6 +1257,11 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
case BROWSER_OBJECT_INFO:
break;
case BROWSER_OBJECT_RELOAD:
+ if (scaffold->current_menu_object != NULL) {
+ content_invalidate_reuse_data(scaffold->current_menu_object);
+ browser_window_reload(bw, false);
+ scaffold->current_menu_object = NULL;
+ }
break;
case BROWSER_OBJECT_SAVE:
break;
@@ -1502,6 +1522,8 @@ void nsbeos_attach_toplevel_view(nsbeos_scaffolding *g, BView *view)
nsbeos_scaffolding_update_colors(g);
+ recursively_set_menu_items_target(g->popup_menu, view);
+
if (g->window) {
recursively_set_menu_items_target(g->menu_bar, view);
@@ -1554,36 +1576,34 @@ static BMenuItem *make_menu_item(const char *name, BMessage *message, bool enabl
{
BMenuItem *item;
BString label(messages_get(name));
- BString accel;
+ BString accelKey(name);
+ accelKey += "Accel";
+ BString accel(messages_get(accelKey));
+ if (accel == accelKey)
+ accel = "";
uint32 mods = 0;
char key = 0;
// try to understand accelerators
- int32 start = label.IFindLast(" ");
- if (start > 0 && (label.Length() - start > 1)
- && (label.Length() - start < 7)
- && (label[start + 1] == 'F'
- || !strcmp(label.String() + start + 1, "PRINT")
- || label[start + 1] == '\xe2'
- || label[start + 1] == '^')) {
-
- label.MoveInto(accel, start + 1, label.Length());
- // strip the trailing spaces
- while (label[label.Length() - 1] == ' ')
- label.Truncate(label.Length() - 1);
-
+ if (!accel.IsEmpty()) {
if (accel.FindFirst("\xe2\x87\x91") > -1) {
accel.RemoveFirst("\xe2\x87\x91");
mods |= B_SHIFT_KEY;
}
if (accel.FindFirst("^") > -1) {
accel.RemoveFirst("^");
- mods |= B_CONTROL_KEY; // ALT!!!
+ mods |= B_CONTROL_KEY;
}
if (accel.FindFirst("PRINT") > -1) {
accel.RemoveFirst("PRINT");
//mods |= ; // ALT!!!
key = B_PRINT_KEY;
}
+
+ /* replace UTF-8 glyphs (arrows...) with API codes */
+ accel.ReplaceAll("\xE2\x86\x90", (BString()+=B_LEFT_ARROW).String());
+ accel.ReplaceAll("\xE2\x86\x92", (BString()+=B_RIGHT_ARROW).String());
+ accel.ReplaceAll("\xE2\x86\x91", (BString()+=B_UP_ARROW).String());
+
if (accel.Length() > 1 && accel[0] == 'F') { // Function key
int num;
if (sscanf(accel.String(), "F%d", &num) > 0) {
@@ -1710,6 +1730,7 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
BMessage *message;
BRect rect;
+ BMenuItem *item;
g->window = NULL;
g->menu_bar = NULL;
@@ -1757,7 +1778,6 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
g->window->AddChild(g->menu_bar);
BMenu *menu;
- BMenuItem *item;
// App menu
//XXX: use icon item ?
@@ -2061,7 +2081,22 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
g->top_view->SetScaffolding(g);
// build popup menu
- g->popup_menu = new BPopUpMenu("");
+ g->popup_menu = new BPopUpMenu("popup", false, false);
+
+#if 0
+ message = new BMessage(BROWSER_OBJECT_INFO);
+ item = make_menu_item("ObjInfo", message);
+ g->popup_menu->AddItem(item);
+
+ message = new BMessage(BROWSER_OBJECT_SAVE);
+ item = make_menu_item("ObjSave", message);
+ g->popup_menu->AddItem(item);
+ // XXX: submenu: Sprite ?
+#endif
+
+ message = new BMessage(BROWSER_OBJECT_RELOAD);
+ item = make_menu_item("ObjReload", message, true);
+ g->popup_menu->AddItem(item);
#ifdef ENABLE_DRAGGER
@@ -2325,8 +2360,19 @@ void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon)
}
-void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where)
+void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *scaffold, struct browser_window *bw, BPoint where, BPoint screenWhere)
{
- g->popup_menu->Go(where);
+ struct browser_window_features cont;
+
+ browser_window_get_features(bw, (int)where.x, (int)where.y, &cont);
+
+ scaffold->current_menu_object = cont.object;
+ bool enabled = !!scaffold->current_menu_object;
+
+ for (int i = 0; scaffold->popup_menu->ItemAt(i); i++) {
+ scaffold->popup_menu->ItemAt(i)->SetEnabled(enabled);
+ }
+
+ scaffold->popup_menu->Go(screenWhere, true, false, true);
}
diff --git a/frontends/beos/scaffolding.h b/frontends/beos/scaffolding.h
index 3fdca57..04cc3fa 100644
--- a/frontends/beos/scaffolding.h
+++ b/frontends/beos/scaffolding.h
@@ -198,7 +198,7 @@ void nsbeos_scaffolding_destroy(nsbeos_scaffolding *scaffold);
//void nsbeos_window_destroy_event(NSBrowserWindow *window, nsbeos_scaffolding *g, BMessage *event);
-void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where);
+void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *scaffold, struct browser_window *bw, BPoint where, BPoint screenWhere);
void gui_window_set_title(struct gui_window *_g, const char *title);
nserror gui_window_set_url(struct gui_window *_g, struct nsurl *url);
diff --git a/frontends/beos/schedule.cpp b/frontends/beos/schedule.cpp
index a9da535..e96e56d 100644
--- a/frontends/beos/schedule.cpp
+++ b/frontends/beos/schedule.cpp
@@ -25,8 +25,8 @@
extern "C" {
#include "utils/errors.h"
#include "beos/schedule.h"
-#include "content/content.h"
-#include "desktop/browser.h"
+#include "netsurf/content_type.h"
+#include "netsurf/browser_window.h"
#ifdef DEBUG_BEOS_SCHEDULE
#include "utils/log.h"
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index 62624f0..fbf7b16 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -21,20 +21,33 @@
#define __STDBOOL_H__ 1
#include <stdlib.h>
#include <assert.h>
+#include <AppDefs.h>
+#include <BeBuild.h>
+#include <Clipboard.h>
+#include <Cursor.h>
+#include <InterfaceDefs.h>
+#include <Message.h>
+#include <ScrollBar.h>
+#include <String.h>
+#include <String.h>
+#include <TextView.h>
+#include <View.h>
+#include <Window.h>
extern "C" {
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
-#include "content/content.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "desktop/plotters.h"
-#include "desktop/gui_window.h"
-#include "desktop/gui_clipboard.h"
+#include "utils/nsurl.h"
+#include "netsurf/content_type.h"
+#include "netsurf/browser_window.h"
+#include "netsurf/mouse.h"
+#include "netsurf/plotters.h"
+#include "netsurf/window.h"
+#include "netsurf/clipboard.h"
+#include "netsurf/url_db.h"
+#include "netsurf/keypress.h"
}
#include "beos/about.h"
@@ -44,18 +57,6 @@ extern "C" {
#include "beos/scaffolding.h"
#include "beos/plotters.h"
-#include <AppDefs.h>
-#include <BeBuild.h>
-#include <Clipboard.h>
-#include <Cursor.h>
-#include <InterfaceDefs.h>
-#include <Message.h>
-#include <ScrollBar.h>
-#include <String.h>
-#include <String.h>
-#include <TextView.h>
-#include <View.h>
-#include <Window.h>
class NSBrowserFrameView;
@@ -544,8 +545,7 @@ void nsbeos_dispatch_event(BMessage *message)
if (buttons & B_SECONDARY_MOUSE_BUTTON) {
/* 2 == right button on BeOS */
-
- nsbeos_scaffolding_popup_menu(gui->scaffold, screenWhere);
+ nsbeos_scaffolding_popup_menu(gui->scaffold, gui->bw, where, screenWhere);
break;
}
@@ -680,7 +680,7 @@ void nsbeos_dispatch_event(BMessage *message)
void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
{
BRect updateRect;
- float scale = g->scale;
+ //float scale = g->scale;
struct rect clip;
struct redraw_context ctx = { true, true, &nsbeos_plotters };
diff --git a/frontends/cocoa/BookmarksController.m b/frontends/cocoa/BookmarksController.m
index 0bd51b2..d7918d9 100644
--- a/frontends/cocoa/BookmarksController.m
+++ b/frontends/cocoa/BookmarksController.m
@@ -18,11 +18,12 @@
#import "utils/messages.h"
#import "utils/utils.h"
-#import "desktop/browser.h"
+#import "utils/nsurl.h"
+#import "netsurf/browser_window.h"
+#import "netsurf/keypress.h"
#import "desktop/hotlist.h"
-#import "desktop/tree.h"
-#import "content/hlcache.h"
+#import "cocoa/desktop-tree.h"
#import "cocoa/BookmarksController.h"
#import "cocoa/Tree.h"
#import "cocoa/TreeView.h"
diff --git a/frontends/cocoa/BrowserView.m b/frontends/cocoa/BrowserView.m
index fc50dbc..f1259d8 100644
--- a/frontends/cocoa/BrowserView.m
+++ b/frontends/cocoa/BrowserView.m
@@ -18,15 +18,18 @@
#import "utils/nsoption.h"
#import "utils/messages.h"
-#import "desktop/browser.h"
-#import "desktop/plotters.h"
-#import "desktop/textinput.h"
-#import "content/hlcache.h"
+#import "utils/nsurl.h"
+#import "utils/utils.h"
+#import "netsurf/browser_window.h"
+#import "netsurf/plotters.h"
+#import "netsurf/content.h"
+#import "netsurf/keypress.h"
#import "cocoa/gui.h"
#import "cocoa/BrowserView.h"
#import "cocoa/HistoryView.h"
#import "cocoa/font.h"
+#import "cocoa/coordinates.h"
#import "cocoa/plotter.h"
#import "cocoa/LocalHistoryController.h"
#import "cocoa/BrowserWindowController.h"
diff --git a/frontends/cocoa/BrowserViewController.m b/frontends/cocoa/BrowserViewController.m
index 5fa8b64..4cac57e 100644
--- a/frontends/cocoa/BrowserViewController.m
+++ b/frontends/cocoa/BrowserViewController.m
@@ -21,11 +21,10 @@
#import "utils/filename.h"
#import "utils/file.h"
#import "utils/messages.h"
-#import "utils/url.h"
+#import "utils/nsurl.h"
+#import "netsurf/content.h"
+#import "netsurf/browser_window.h"
#import "desktop/browser_history.h"
-#import