libnslayout: branch master created. c721328b2ce5775a6dbee4b8f37a8c949394c8d8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libnslayout.git/shortlog/c721328b2ce5775a6...
...commit http://git.netsurf-browser.org/libnslayout.git/commit/c721328b2ce5775a6db...
...tree http://git.netsurf-browser.org/libnslayout.git/tree/c721328b2ce5775a6dbee...
The branch, master has been created
at c721328b2ce5775a6dbee4b8f37a8c949394c8d8 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libnslayout.git/commit/?id=c721328b2ce5775...
commit c721328b2ce5775a6dbee4b8f37a8c949394c8d8
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Initial interface plan.
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..e7d1026
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,13 @@
+Copyright (c) 2015, Michael Drake
+
+Permission to use, copy, modify, and/or distribute this software for any purpose
+with or without fee is hereby granted, provided that the above copyright notice
+and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
diff --git a/include/nslayout.c b/include/nslayout.c
new file mode 100644
index 0000000..1144e4b
--- /dev/null
+++ b/include/nslayout.c
@@ -0,0 +1,191 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License, http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa(a)netsurf-browser.org>
+ * Copyright 2015 John-Mark Bell <jmb(a)netsurf-browser.org>
+ */
+
+/** An opaque client-owned replaced element */
+typedef void nslayout_replaced;
+
+/** A rectangle */
+typedef struct nslayout_rect {
+ int x;
+ int y;
+ int w;
+ int h;
+} nslayout_rect;
+
+/**
+ * A LibNSLayout request
+ *
+ * Passed to the client via nslayout_callback
+ */
+typedef struct nslayout_request {
+ /** Request type */
+ enum type {
+ NSLAYOUT_GET_RESOURCE,
+ NSLAYOUT_CREATE_REPLACED,
+ NSLAYOUT_RENDER,
+ NSLAYOUT_SET_EXTENTS,
+ NSLAYOUT_GET_INTRINSIC_SIZE
+ } type;
+ /** Request's type-specific parameters */
+ union {
+ struct {
+ const char *url; /**< Absolute URL */
+ } get_resource;
+ struct {
+ dom_element *element; /**< DOM element */
+ } create_replaced;
+ struct {
+ nslayout_render_list *list; /**< Render list */
+ } render;
+ struct {
+ width; /**< Document width in px */
+ height; /**< Document height in px */
+ } set_extents;
+ struct {
+ nslayout_replaced *replaced; /** A replacement object */
+ } get_intrinsic_size;
+ } request;
+ /** Request's type-specific return values */
+ union {
+ struct {
+ nslayout_replaced **replaced; /** Replacement object */
+ } get_resource;
+ struct {
+ nslayout_replaced **replaced; /** Replacement object */
+ } create_replaced;
+ struct {
+ unsigned int *width; /** Replacement object's width */
+ unsigned int *height; /** Replacement object's height */
+ } get_intrinsic_size;
+ } response;
+} nslayout_request;
+
+/**
+ * Initialise LibNSLayout
+ *
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_init(void);
+
+/**
+ * Finalise LibNSLayout
+ *
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_fini(void);
+
+/**
+ * LibNSLayout client callback function
+ *
+ * \param req The request details.
+ * \param layout The layout we're making a request for.
+ * \param pw The client's private data for this layout.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+typedef nslayout_error (*nslayout_callback)(
+ nslayout_request *req,
+ nslayout_layout *layout,
+ void *pw);
+
+/**
+ * Create a Layout object for a given DOM
+ *
+ * \param doc The LibDOM document to build a layout for.
+ * \param css_ctx The LibCSS selection context for the document.
+ * \param media The LibCSS media to use when selecting for this layout.
+ * \param cb The client's private data for this layout.
+ * \param pw The client's private data for this layout.
+ * \param layout Returns a pointer to the created layout object.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_layout_create(
+ dom_document *doc,
+ css_select_ctx *css_ctx,
+ css_media_type *media,
+ nslayout_callback *cb;
+ void *pw,
+ nslayout_layout **layout);
+
+/**
+ * Destroy a Layout object
+ *
+ * \param layout Returns a pointer to the created layout object.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_layout_destroy(
+ nslayout_layout *layout);
+
+/**
+ * Update the viewport for a layout
+ *
+ * Note: Before this is called, the layout engine will create internal
+ * data structures for the document, but will not start to position
+ * things and will not emit render lists.
+ *
+ * \param layout Layout to set viewport for.
+ * \param viewport Viewport dimensions and offset.
+ * \param scale Rendering scale.
+ * \param dpi DPI of render target with viewport.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_update_viewport(
+ nslayout_layout *layout,
+ nslayout_rect *viewport,
+ css_fixed scale
+ int dpi);
+
+/**
+ * Find the top-most element at a given point, in terms of z-order.
+ *
+ * \param layout Layout to locate an element in.
+ * \param element Updated to area with position relative to viewport.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_element_get_location(
+ nslayout_layout *layout,
+ nslayout_rect *area);
+
+/**
+ * Find the top-most element at a given point, in terms of z-order.
+ *
+ * \param layout Layout to find an element in.
+ * \param x Mouse x-coordinate (viewport relative).
+ * \param y Mouse y-coordinate (viewport relative).
+ * \param element Updated to point at the element we found.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_element_at_point(
+ nslayout_layout *layout,
+ unsigned int x,
+ unsigned int y,
+ dom_event_target **element);
+
+/**
+ * Mark an element (or part of it) as needing redraw.
+ *
+ * \param layout Layout to indicate redraw is required for.
+ * \param element Element to mark as needing redraw.
+ * \param rel_area Area of element to redraw relative to object's top-left.
+ * May be NULL, to redraw whole element.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_layout_dirty_element(
+ nslayout_layout *layout,
+ dom_element *element,
+ nslayout_rect *rel_area);
+
+/**
+ * Mark an area as needing redraw.
+ *
+ * \param layout Layout to indicate redraw is required for.
+ * \param area Area to redraw relative to viewport's top-left.
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nslayout_layout_dirty_area(
+ nslayout_layout *layout,
+ nslayout_rect *area);
+
-----------------------------------------------------------------------
--
NetSurf Layout Engine
8 years, 2 months
netsurf: branch master updated. release/3.3-227-gabc7a71
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/abc7a71117e4ae03f9b71...
...commit http://git.netsurf-browser.org/netsurf.git/commit/abc7a71117e4ae03f9b7146...
...tree http://git.netsurf-browser.org/netsurf.git/tree/abc7a71117e4ae03f9b7146ce...
The branch, master has been updated
via abc7a71117e4ae03f9b7146ce3f299a4b931b1ef (commit)
from 3b9df4f79655f80acbb508f85181f795319801a9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=abc7a71117e4ae03f9b...
commit abc7a71117e4ae03f9b7146ce3f299a4b931b1ef
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Pass the URL bar contents back as UTF-8.
diff --git a/riscos/gui/url_bar.c b/riscos/gui/url_bar.c
index 5eccd60..a25ea87 100644
--- a/riscos/gui/url_bar.c
+++ b/riscos/gui/url_bar.c
@@ -83,6 +83,7 @@ struct url_bar {
wimp_i text_icon;
char *text_buffer;
size_t text_size;
+ char *text_buffer_utf8;
wimp_i suggest_icon;
int suggest_x, suggest_y;
@@ -508,6 +509,9 @@ void ro_gui_url_bar_destroy(struct url_bar *url_bar)
if (url_bar == NULL)
return;
+ if (url_bar->text_buffer_utf8 != NULL)
+ free(url_bar->text_buffer_utf8);
+
free(url_bar);
}
@@ -1073,6 +1077,15 @@ const char *ro_gui_url_bar_get_url(struct url_bar *url_bar)
if (url_bar == NULL)
return NULL;
+ if (url_bar->text_buffer_utf8 != NULL) {
+ free(url_bar->text_buffer_utf8);
+ url_bar->text_buffer_utf8 = NULL;
+ }
+
+ if (utf8_from_local_encoding(url_bar->text_buffer, 0, &url_bar->text_buffer_utf8) == NSERROR_OK) {
+ return (const char *) url_bar->text_buffer_utf8;
+ }
+
return (const char *) url_bar->text_buffer;
}
-----------------------------------------------------------------------
Summary of changes:
riscos/gui/url_bar.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/riscos/gui/url_bar.c b/riscos/gui/url_bar.c
index 5eccd60..a25ea87 100644
--- a/riscos/gui/url_bar.c
+++ b/riscos/gui/url_bar.c
@@ -83,6 +83,7 @@ struct url_bar {
wimp_i text_icon;
char *text_buffer;
size_t text_size;
+ char *text_buffer_utf8;
wimp_i suggest_icon;
int suggest_x, suggest_y;
@@ -508,6 +509,9 @@ void ro_gui_url_bar_destroy(struct url_bar *url_bar)
if (url_bar == NULL)
return;
+ if (url_bar->text_buffer_utf8 != NULL)
+ free(url_bar->text_buffer_utf8);
+
free(url_bar);
}
@@ -1073,6 +1077,15 @@ const char *ro_gui_url_bar_get_url(struct url_bar *url_bar)
if (url_bar == NULL)
return NULL;
+ if (url_bar->text_buffer_utf8 != NULL) {
+ free(url_bar->text_buffer_utf8);
+ url_bar->text_buffer_utf8 = NULL;
+ }
+
+ if (utf8_from_local_encoding(url_bar->text_buffer, 0, &url_bar->text_buffer_utf8) == NSERROR_OK) {
+ return (const char *) url_bar->text_buffer_utf8;
+ }
+
return (const char *) url_bar->text_buffer;
}
--
NetSurf Browser
8 years, 2 months
netsurf: branch chris/display-idna updated. release/3.3-232-g5bec5bf
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5bec5bf72a5087df679a6...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5bec5bf72a5087df679a6fc...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5bec5bf72a5087df679a6fc89...
The branch, chris/display-idna has been updated
via 5bec5bf72a5087df679a6fc89ea72a84c0ba9a07 (commit)
from dac91d6d661a88352c02495e41219e4e33cfd580 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5bec5bf72a5087df679...
commit 5bec5bf72a5087df679a6fc89ea72a84c0ba9a07
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Enable RISC OS to display decoded IDNs in the URL bar (subject to local charset restrictions)
diff --git a/riscos/window.c b/riscos/window.c
index 097ab9e..dbed46d 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1038,8 +1038,16 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
/* exported function documented in riscos/window.h */
nserror ro_gui_window_set_url(struct gui_window *g, nsurl *url)
{
+ char *idn_url = NULL;
+
if (g->toolbar) {
- ro_toolbar_set_url(g->toolbar, nsurl_access(url), true, false);
+ if (nsoption_bool(display_decoded_idn) == false) {
+ ro_toolbar_set_url(g->toolbar, nsurl_access(url), true, false);
+ } else {
+ idn_url = nsurl_access_utf8(url);
+ ro_toolbar_set_url(g->toolbar, idn_url, true, false);
+ free(idn_url);
+ }
ro_gui_url_complete_start(g->toolbar);
}
-----------------------------------------------------------------------
Summary of changes:
riscos/window.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/riscos/window.c b/riscos/window.c
index 097ab9e..dbed46d 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -1038,8 +1038,16 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
/* exported function documented in riscos/window.h */
nserror ro_gui_window_set_url(struct gui_window *g, nsurl *url)
{
+ char *idn_url = NULL;
+
if (g->toolbar) {
- ro_toolbar_set_url(g->toolbar, nsurl_access(url), true, false);
+ if (nsoption_bool(display_decoded_idn) == false) {
+ ro_toolbar_set_url(g->toolbar, nsurl_access(url), true, false);
+ } else {
+ idn_url = nsurl_access_utf8(url);
+ ro_toolbar_set_url(g->toolbar, idn_url, true, false);
+ free(idn_url);
+ }
ro_gui_url_complete_start(g->toolbar);
}
--
NetSurf Browser
8 years, 2 months
netsurf: branch chris/display-idna updated. release/3.3-231-gdac91d6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/dac91d6d661a88352c024...
...commit http://git.netsurf-browser.org/netsurf.git/commit/dac91d6d661a88352c02495...
...tree http://git.netsurf-browser.org/netsurf.git/tree/dac91d6d661a88352c02495e4...
The branch, chris/display-idna has been updated
via dac91d6d661a88352c02495e41219e4e33cfd580 (commit)
from d208f02fa5b825c3833fded0a0325853933e4ccb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=dac91d6d661a88352c0...
commit dac91d6d661a88352c02495e41219e4e33cfd580
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Modify the status bar link text so it shows either the ASCII encoded or IDN host, depending on the set option.
Default is to display the encoded version as this provides some security making phishing domains more obvious, and a lot of our frontends are unable to display the full range of UTF-8 characters on the status bar.
Displaying the decoded address in the URL bar requires frontends to be updated (GTK and Amiga done already), and the same caveats apply.
diff --git a/render/html_interaction.c b/render/html_interaction.c
index 6e2a2df..af84174 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -300,6 +300,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
enum { ACTION_NONE, ACTION_SUBMIT, ACTION_GO } action = ACTION_NONE;
const char *title = 0;
nsurl *url = 0;
+ char *idn_url = NULL;
const char *target = 0;
char status_buffer[200];
const char *status = 0;
@@ -814,12 +815,22 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
y - html_object_pos_y);
}
} else if (url) {
+ if (nsoption_bool(display_decoded_idn) == true) {
+ idn_url = nsurl_access_utf8(url);
+ }
+
if (title) {
snprintf(status_buffer, sizeof status_buffer, "%s: %s",
- nsurl_access(url), title);
- status = status_buffer;
- } else
- status = nsurl_access(url);
+ idn_url ? idn_url : nsurl_access(url), title);
+ } else {
+ snprintf(status_buffer, sizeof status_buffer, "%s",
+ idn_url ? idn_url : nsurl_access(url));
+ }
+
+ status = status_buffer;
+
+ if (idn_url != NULL)
+ free(idn_url);
pointer = get_pointer_shape(url_box, imagemap);
-----------------------------------------------------------------------
Summary of changes:
render/html_interaction.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/render/html_interaction.c b/render/html_interaction.c
index 6e2a2df..af84174 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -300,6 +300,7 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
enum { ACTION_NONE, ACTION_SUBMIT, ACTION_GO } action = ACTION_NONE;
const char *title = 0;
nsurl *url = 0;
+ char *idn_url = NULL;
const char *target = 0;
char status_buffer[200];
const char *status = 0;
@@ -814,12 +815,22 @@ void html_mouse_action(struct content *c, struct browser_window *bw,
y - html_object_pos_y);
}
} else if (url) {
+ if (nsoption_bool(display_decoded_idn) == true) {
+ idn_url = nsurl_access_utf8(url);
+ }
+
if (title) {
snprintf(status_buffer, sizeof status_buffer, "%s: %s",
- nsurl_access(url), title);
- status = status_buffer;
- } else
- status = nsurl_access(url);
+ idn_url ? idn_url : nsurl_access(url), title);
+ } else {
+ snprintf(status_buffer, sizeof status_buffer, "%s",
+ idn_url ? idn_url : nsurl_access(url));
+ }
+
+ status = status_buffer;
+
+ if (idn_url != NULL)
+ free(idn_url);
pointer = get_pointer_shape(url_box, imagemap);
--
NetSurf Browser
8 years, 2 months
libdom: branch master updated. release/0.1.2-5-gff1caf3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/ff1caf307c8ea8a8f407c4...
...commit http://git.netsurf-browser.org/libdom.git/commit/ff1caf307c8ea8a8f407c44d...
...tree http://git.netsurf-browser.org/libdom.git/tree/ff1caf307c8ea8a8f407c44da4...
The branch, master has been updated
via ff1caf307c8ea8a8f407c44da48fa6c55cb5e30a (commit)
from 8a14c8d2cd406dfccd7397fb87bedaa8c994f071 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=ff1caf307c8ea8a8f407...
commit ff1caf307c8ea8a8f407c44da48fa6c55cb5e30a
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
Testutils: undef assert before use
diff --git a/test/testutils/domtsasserts.h b/test/testutils/domtsasserts.h
index e18509c..1a292f7 100644
--- a/test/testutils/domtsasserts.h
+++ b/test/testutils/domtsasserts.h
@@ -21,6 +21,7 @@
void __assert2(const char *expr, const char *function,
const char *file, int line);
+#undef assert
#define assert(expr) \
((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0)))
-----------------------------------------------------------------------
Summary of changes:
test/testutils/domtsasserts.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/testutils/domtsasserts.h b/test/testutils/domtsasserts.h
index e18509c..1a292f7 100644
--- a/test/testutils/domtsasserts.h
+++ b/test/testutils/domtsasserts.h
@@ -21,6 +21,7 @@
void __assert2(const char *expr, const char *function,
const char *file, int line);
+#undef assert
#define assert(expr) \
((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0)))
--
Document Object Model library
8 years, 2 months
libcss: branch master updated. release/0.5.0-7-g2ab63a7
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/2ab63a787e65742bd2ddd6...
...commit http://git.netsurf-browser.org/libcss.git/commit/2ab63a787e65742bd2ddd656...
...tree http://git.netsurf-browser.org/libcss.git/tree/2ab63a787e65742bd2ddd65633...
The branch, master has been updated
via 2ab63a787e65742bd2ddd65633cefed51a2607a7 (commit)
from 884502f39d98b556bce0c3af66ac82f33b2cff82 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=2ab63a787e65742bd2dd...
commit 2ab63a787e65742bd2ddd65633cefed51a2607a7
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
Testutils: undef assert before use
diff --git a/test/testutils.h b/test/testutils.h
index 1a13e5b..70d803d 100644
--- a/test/testutils.h
+++ b/test/testutils.h
@@ -28,6 +28,7 @@ void __assert2(const char *expr, const char *function,
exit(EXIT_FAILURE);
}
+#undef assert
#define assert(expr) \
((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0)))
-----------------------------------------------------------------------
Summary of changes:
test/testutils.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/testutils.h b/test/testutils.h
index 1a13e5b..70d803d 100644
--- a/test/testutils.h
+++ b/test/testutils.h
@@ -28,6 +28,7 @@ void __assert2(const char *expr, const char *function,
exit(EXIT_FAILURE);
}
+#undef assert
#define assert(expr) \
((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0)))
--
Cascading Style Sheets library
8 years, 2 months
libwapcaplet: branch master updated. release/0.2.2-8-gb20c9fb
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libwapcaplet.git/shortlog/b20c9fb6a6a20059...
...commit http://git.netsurf-browser.org/libwapcaplet.git/commit/b20c9fb6a6a2005978...
...tree http://git.netsurf-browser.org/libwapcaplet.git/tree/b20c9fb6a6a20059786f...
The branch, master has been updated
via b20c9fb6a6a20059786fc52acd60cda9c6833291 (commit)
from 2c99255d4e567c5acefdf4f1c06d9f1a6378b680 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libwapcaplet.git/commit/?id=b20c9fb6a6a200...
commit b20c9fb6a6a20059786fc52acd60cda9c6833291
Author: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
Update to include asserts in interface macros, and test successfully
diff --git a/include/libwapcaplet/libwapcaplet.h b/include/libwapcaplet/libwapcaplet.h
index 47d93a6..e46ffa8 100644
--- a/include/libwapcaplet/libwapcaplet.h
+++ b/include/libwapcaplet/libwapcaplet.h
@@ -17,6 +17,7 @@ extern "C"
#include <sys/types.h>
#include <stdbool.h>
#include <stdint.h>
+#include <assert.h>
/**
* The type of a reference counter used in libwapcaplet.
@@ -121,7 +122,7 @@ extern lwc_error lwc_intern_substring(lwc_string *str,
* @note Use this if copying the string and intending both sides to retain
* ownership.
*/
-#define lwc_string_ref(str) ({lwc_string *__lwc_s = (str); __lwc_s->refcnt++; __lwc_s;})
+#define lwc_string_ref(str) ({lwc_string *__lwc_s = (str); assert(__lwc_s != NULL); __lwc_s->refcnt++; __lwc_s;})
/**
* Release a reference on an lwc_string.
@@ -135,7 +136,8 @@ extern lwc_error lwc_intern_substring(lwc_string *str,
* will also result in the string being freed.)
*/
#define lwc_string_unref(str) { \
- lwc_string *__lwc_s = (str); \
+ lwc_string *__lwc_s = (str); \
+ assert(__lwc_s != NULL); \
__lwc_s->refcnt--; \
if ((__lwc_s->refcnt == 0) || \
((__lwc_s->refcnt == 1) && (__lwc_s->insensitive == __lwc_s))) \
@@ -215,7 +217,7 @@ lwc__intern_caseless_string(lwc_string *str);
* in future. Any code relying on it currently should be
* modified to use ::lwc_string_length if possible.
*/
-#define lwc_string_data(str) ((const char *)((str)+1))
+#define lwc_string_data(str) ({assert(str != NULL); (const char *)((str)+1);})
/**
* Retrieve the data length for an interned string.
@@ -223,7 +225,7 @@ lwc__intern_caseless_string(lwc_string *str);
* @param str The string to retrieve the length of.
* @return The length of \a str.
*/
-#define lwc_string_length(str) ((str)->len)
+#define lwc_string_length(str) ({assert(str != NULL); (str)->len;})
/**
* Retrieve (or compute if unavailable) a hash value for the content of the string.
@@ -237,7 +239,7 @@ lwc__intern_caseless_string(lwc_string *str);
* to be stable between invocations of the program. Never use the hash
* value as a way to directly identify the value of the string.
*/
-#define lwc_string_hash_value(str) ((str)->hash)
+#define lwc_string_hash_value(str) ({assert(str != NULL); (str)->hash;})
/**
* Iterate the context and return every string in it.
diff --git a/test/testmain.c b/test/testmain.c
index 95fd6d2..421d06f 100644
--- a/test/testmain.c
+++ b/test/testmain.c
@@ -16,8 +16,16 @@
#endif
/* This means that assertion failures are silent in tests */
-extern void __assert_fail(void);
-void __assert_fail(void) { abort(); }
+#ifndef NDEBUG
+void __assert_fail(const char *__assertion, const char *__file,
+ unsigned int __line, const char *__function) {
+ (void)__assertion;
+ (void)__file;
+ (void)__line;
+ (void)__function;
+ abort();
+}
+#endif
int
main(int argc, char **argv)
-----------------------------------------------------------------------
Summary of changes:
include/libwapcaplet/libwapcaplet.h | 12 +++++++-----
test/testmain.c | 12 ++++++++++--
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/include/libwapcaplet/libwapcaplet.h b/include/libwapcaplet/libwapcaplet.h
index 47d93a6..e46ffa8 100644
--- a/include/libwapcaplet/libwapcaplet.h
+++ b/include/libwapcaplet/libwapcaplet.h
@@ -17,6 +17,7 @@ extern "C"
#include <sys/types.h>
#include <stdbool.h>
#include <stdint.h>
+#include <assert.h>
/**
* The type of a reference counter used in libwapcaplet.
@@ -121,7 +122,7 @@ extern lwc_error lwc_intern_substring(lwc_string *str,
* @note Use this if copying the string and intending both sides to retain
* ownership.
*/
-#define lwc_string_ref(str) ({lwc_string *__lwc_s = (str); __lwc_s->refcnt++; __lwc_s;})
+#define lwc_string_ref(str) ({lwc_string *__lwc_s = (str); assert(__lwc_s != NULL); __lwc_s->refcnt++; __lwc_s;})
/**
* Release a reference on an lwc_string.
@@ -135,7 +136,8 @@ extern lwc_error lwc_intern_substring(lwc_string *str,
* will also result in the string being freed.)
*/
#define lwc_string_unref(str) { \
- lwc_string *__lwc_s = (str); \
+ lwc_string *__lwc_s = (str); \
+ assert(__lwc_s != NULL); \
__lwc_s->refcnt--; \
if ((__lwc_s->refcnt == 0) || \
((__lwc_s->refcnt == 1) && (__lwc_s->insensitive == __lwc_s))) \
@@ -215,7 +217,7 @@ lwc__intern_caseless_string(lwc_string *str);
* in future. Any code relying on it currently should be
* modified to use ::lwc_string_length if possible.
*/
-#define lwc_string_data(str) ((const char *)((str)+1))
+#define lwc_string_data(str) ({assert(str != NULL); (const char *)((str)+1);})
/**
* Retrieve the data length for an interned string.
@@ -223,7 +225,7 @@ lwc__intern_caseless_string(lwc_string *str);
* @param str The string to retrieve the length of.
* @return The length of \a str.
*/
-#define lwc_string_length(str) ((str)->len)
+#define lwc_string_length(str) ({assert(str != NULL); (str)->len;})
/**
* Retrieve (or compute if unavailable) a hash value for the content of the string.
@@ -237,7 +239,7 @@ lwc__intern_caseless_string(lwc_string *str);
* to be stable between invocations of the program. Never use the hash
* value as a way to directly identify the value of the string.
*/
-#define lwc_string_hash_value(str) ((str)->hash)
+#define lwc_string_hash_value(str) ({assert(str != NULL); (str)->hash;})
/**
* Iterate the context and return every string in it.
diff --git a/test/testmain.c b/test/testmain.c
index 95fd6d2..421d06f 100644
--- a/test/testmain.c
+++ b/test/testmain.c
@@ -16,8 +16,16 @@
#endif
/* This means that assertion failures are silent in tests */
-extern void __assert_fail(void);
-void __assert_fail(void) { abort(); }
+#ifndef NDEBUG
+void __assert_fail(const char *__assertion, const char *__file,
+ unsigned int __line, const char *__function) {
+ (void)__assertion;
+ (void)__file;
+ (void)__line;
+ (void)__function;
+ abort();
+}
+#endif
int
main(int argc, char **argv)
--
String internment library
8 years, 2 months
netsurf: branch chris/display-idna updated. release/3.3-230-gd208f02
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/d208f02fa5b825c3833fd...
...commit http://git.netsurf-browser.org/netsurf.git/commit/d208f02fa5b825c3833fded...
...tree http://git.netsurf-browser.org/netsurf.git/tree/d208f02fa5b825c3833fded0a...
The branch, chris/display-idna has been updated
via d208f02fa5b825c3833fded0a0325853933e4ccb (commit)
from 88a030af147a98d018050e9e434caed30afeb80a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d208f02fa5b825c3833...
commit d208f02fa5b825c3833fded0a0325853933e4ccb
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Enable Amiga frontend to show decoded IDNs subject to local charset restrictions.
TODO: Statusbar link text
diff --git a/amiga/gui.c b/amiga/gui.c
index b7f3285..dc49a69 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -4996,9 +4996,21 @@ static nserror gui_window_set_url(struct gui_window *g, nsurl *url)
if(!g) return NSERROR_OK;
if (g == g->shared->gw) {
- RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_URL],
- g->shared->win, NULL, STRINGA_TextVal,
- nsurl_access(url), TAG_DONE);
+ if(nsoption_bool(display_decoded_idn) == false) {
+ RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_URL],
+ g->shared->win, NULL,
+ STRINGA_TextVal, nsurl_access(url),
+ TAG_DONE);
+ } else {
+ char *idn_url = nsurl_access_utf8(url);
+ char *idn_url_lc = ami_utf8_easy(idn_url);
+ RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_URL],
+ g->shared->win, NULL,
+ STRINGA_TextVal, idn_url_lc,
+ TAG_DONE);
+ free(idn_url);
+ ami_utf8_free(idn_url_lc);
+ }
}
ami_update_buttons(g->shared);
-----------------------------------------------------------------------
Summary of changes:
amiga/gui.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/amiga/gui.c b/amiga/gui.c
index b7f3285..dc49a69 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -4996,9 +4996,21 @@ static nserror gui_window_set_url(struct gui_window *g, nsurl *url)
if(!g) return NSERROR_OK;
if (g == g->shared->gw) {
- RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_URL],
- g->shared->win, NULL, STRINGA_TextVal,
- nsurl_access(url), TAG_DONE);
+ if(nsoption_bool(display_decoded_idn) == false) {
+ RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_URL],
+ g->shared->win, NULL,
+ STRINGA_TextVal, nsurl_access(url),
+ TAG_DONE);
+ } else {
+ char *idn_url = nsurl_access_utf8(url);
+ char *idn_url_lc = ami_utf8_easy(idn_url);
+ RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_URL],
+ g->shared->win, NULL,
+ STRINGA_TextVal, idn_url_lc,
+ TAG_DONE);
+ free(idn_url);
+ ami_utf8_free(idn_url_lc);
+ }
}
ami_update_buttons(g->shared);
--
NetSurf Browser
8 years, 2 months
netsurf: branch chris/display-idna updated. release/3.3-229-g88a030a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/88a030af147a98d018050...
...commit http://git.netsurf-browser.org/netsurf.git/commit/88a030af147a98d018050e9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/88a030af147a98d018050e9e4...
The branch, chris/display-idna has been updated
via 88a030af147a98d018050e9e434caed30afeb80a (commit)
from 868b765e36a20f2d76f7bf1e1223f7bc95a7b4e2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=88a030af147a98d0180...
commit 88a030af147a98d018050e9e434caed30afeb80a
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Check we've obtained the host string
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 6a92960..6675ee1 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1713,6 +1713,11 @@ char *nsurl_access_utf8(const nsurl *url)
assert(url != NULL);
host = nsurl_get_component(url, NSURL_HOST);
+
+ if(host == NULL) {
+ return strdup(url->string);
+ }
+
if (idna_decode(lwc_string_data(host), lwc_string_length(host),
&idna_host, &idna_host_len) != NSERROR_OK) {
lwc_string_unref(host);
-----------------------------------------------------------------------
Summary of changes:
utils/nsurl.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 6a92960..6675ee1 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1713,6 +1713,11 @@ char *nsurl_access_utf8(const nsurl *url)
assert(url != NULL);
host = nsurl_get_component(url, NSURL_HOST);
+
+ if(host == NULL) {
+ return strdup(url->string);
+ }
+
if (idna_decode(lwc_string_data(host), lwc_string_length(host),
&idna_host, &idna_host_len) != NSERROR_OK) {
lwc_string_unref(host);
--
NetSurf Browser
8 years, 2 months
netsurf: branch chris/display-idna created. release/3.3-228-g868b765
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/868b765e36a20f2d76f7b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/868b765e36a20f2d76f7bf1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/868b765e36a20f2d76f7bf1e1...
The branch, chris/display-idna has been created
at 868b765e36a20f2d76f7bf1e1223f7bc95a7b4e2 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=868b765e36a20f2d76f...
commit 868b765e36a20f2d76f7bf1e1223f7bc95a7b4e2
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Show the IDN decoded form in the URL bar on GTK if the option is set.
diff --git a/desktop/options.h b/desktop/options.h
index 33ecb75..f01261e 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -185,6 +185,9 @@ NSOPTION_UINT(min_reflow_period, DEFAULT_REFLOW_PERIOD)
/* use core selection menu */
NSOPTION_BOOL(core_select_menu, false)
+/* display decoded international domain names */
+NSOPTION_BOOL(display_decoded_idn, false)
+
/******** Fetcher options ********/
/** Maximum simultaneous active fetchers */
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 4506ac2..dc03d94 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -2346,7 +2346,13 @@ nserror gui_window_set_url(struct gui_window *gw, nsurl *url)
g = nsgtk_get_scaffold(gw);
if (g->top_level == gw) {
- gtk_entry_set_text(GTK_ENTRY(g->url_bar), nsurl_access(url));
+ if (nsoption_bool(display_decoded_idn) == false) {
+ gtk_entry_set_text(GTK_ENTRY(g->url_bar), nsurl_access(url));
+ } else {
+ char *idn_url = nsurl_access_utf8(url);
+ gtk_entry_set_text(GTK_ENTRY(g->url_bar), idn_url);
+ free(idn_url);
+ }
gtk_editable_set_position(GTK_EDITABLE(g->url_bar), -1);
}
return NSERROR_OK;
diff --git a/utils/nsurl.c b/utils/nsurl.c
index bb3054d..6a92960 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1698,7 +1698,7 @@ const char *nsurl_access(const nsurl *url)
return url->string;
}
-const char *nsurl_access_utf8(const nsurl *url)
+char *nsurl_access_utf8(const nsurl *url)
{
lwc_string *host;
char *idna_host;
diff --git a/utils/nsurl.h b/utils/nsurl.h
index 4fbc17b..07d73f1 100644
--- a/utils/nsurl.h
+++ b/utils/nsurl.h
@@ -191,7 +191,7 @@ const char *nsurl_access(const nsurl *url);
*
* The returned string has a trailing '\0'.
*/
-const char *nsurl_access_utf8(const nsurl *url);
+char *nsurl_access_utf8(const nsurl *url);
/**
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=eff7d84200de855f115...
commit eff7d84200de855f1152d32b96f2e44ac87589b4
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Add a function to retrieve the decoded version of IDNA URLs
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 8d53be8..bb3054d 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1698,6 +1698,51 @@ const char *nsurl_access(const nsurl *url)
return url->string;
}
+const char *nsurl_access_utf8(const nsurl *url)
+{
+ lwc_string *host;
+ char *idna_host;
+ size_t idna_host_len;
+ char *scheme;
+ size_t scheme_len;
+ char *path;
+ size_t path_len;
+ char *idna_url;
+ size_t idna_url_len;
+
+ assert(url != NULL);
+
+ host = nsurl_get_component(url, NSURL_HOST);
+ if (idna_decode(lwc_string_data(host), lwc_string_length(host),
+ &idna_host, &idna_host_len) != NSERROR_OK) {
+ lwc_string_unref(host);
+ return strdup(url->string);
+ }
+
+ lwc_string_unref(host);
+
+ if (nsurl_get(url, NSURL_SCHEME | NSURL_CREDENTIALS,
+ &scheme, &scheme_len) != NSERROR_OK) {
+ return strdup(url->string);
+ }
+
+ if (nsurl_get(url, NSURL_PORT | NSURL_PATH | NSURL_QUERY,
+ &path, &path_len) != NSERROR_OK) {
+ return strdup(url->string);
+ }
+
+ idna_url_len = scheme_len + idna_host_len + path_len + 1; /* +1 for \0 */
+ idna_url = malloc(idna_url_len);
+
+ if (idna_url == NULL) {
+ return strdup(url->string);
+ }
+
+ snprintf(idna_url, idna_url_len, "%s%s%s", scheme, idna_host, path);
+
+ return(idna_url);
+}
+
/* exported interface, documented in nsurl.h */
const char *nsurl_access_leaf(const nsurl *url)
diff --git a/utils/nsurl.h b/utils/nsurl.h
index b84f55e..4fbc17b 100644
--- a/utils/nsurl.h
+++ b/utils/nsurl.h
@@ -181,6 +181,20 @@ const char *nsurl_access(const nsurl *url);
/**
+ * Access a NetSurf URL object as a UTF-8 string (for human readable IDNA)
+ *
+ * \param url NetSurf URL to retrieve a string pointer for.
+ * \return the required string
+ *
+ * It is up to the client to free the returned string when they have
+ * finished with it.
+ *
+ * The returned string has a trailing '\0'.
+ */
+const char *nsurl_access_utf8(const nsurl *url);
+
+
+/**
* Access a URL's path leaf as a string
*
* \param url NetSurf URL to retrieve a string pointer for.
-----------------------------------------------------------------------
--
NetSurf Browser
8 years, 2 months