[Commits] [SCM] claws branch, master, updated. 3.17.3-101-g655a159

ticho at claws-mail.org ticho at claws-mail.org
Mon Feb 18 00:47:30 CET 2019


The branch, master has been updated
       via  655a159a37d09813988879af691c76748d5886fc (commit)
      from  1efad926768a8f609ad15f9ee3926ba38d4b601c (commit)

Summary of changes:
 src/plugins/litehtml_viewer/lh_widget.cpp |   20 ++++++++++++++++----
 src/plugins/litehtml_viewer/lh_widget.h   |    2 ++
 2 files changed, 18 insertions(+), 4 deletions(-)


- Log -----------------------------------------------------------------
commit 655a159a37d09813988879af691c76748d5886fc
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Feb 18 00:46:24 2019 +0100

    Use prepend document base url to #fragment links in Litehtml plugin

diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
index 17ae04e..e75ec4a 100644
--- a/src/plugins/litehtml_viewer/lh_widget.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -135,15 +135,17 @@ void lh_widget::set_caption(const litehtml::tchar_t* caption)
 
 void lh_widget::set_base_url(const litehtml::tchar_t* base_url)
 {
-	debug_print("lh_widget set_base_url\n");
+	debug_print("lh_widget set_base_url '%s'\n",
+			(base_url ? base_url : "(null)"));
+	m_base_url = base_url;
 	return;
 }
 
 void lh_widget::on_anchor_click(const litehtml::tchar_t* url, const litehtml::element::ptr& el)
 {
 	debug_print("lh_widget on_anchor_click. url -> %s\n", url);
-	m_clicked_url = url;
-	
+
+	m_clicked_url = fullurl(url);
 	return;
 }
 
@@ -333,6 +335,8 @@ void lh_widget::clear()
 	m_html = nullptr;
 	paint_white();
 	m_rendered_width = 0;
+	m_base_url.clear();
+	m_clicked_url.clear();
 }
 
 void lh_widget::set_cursor(const litehtml::tchar_t* cursor)
@@ -369,7 +373,7 @@ void lh_widget::update_cursor()
 	/* If it's an anchor, show its "href" attribute in statusbar,
 	 * otherwise clear statusbar. */
 	if ((href = get_href_at(x, y)) != NULL) {
-		lh_widget_statusbar_push(href);
+		lh_widget_statusbar_push(fullurl(href).c_str());
 	} else {
 		lh_widget_statusbar_pop();
 	}
@@ -444,6 +448,14 @@ void lh_widget::update_font()
 	debug_print("Font set to '%s', size %d\n", m_font_name, m_font_size);
 }
 
+const litehtml::tstring lh_widget::fullurl(const litehtml::tchar_t *url) const
+{
+	if (*url == '#' && !m_base_url.empty())
+		return m_base_url + url;
+
+	return _t(url);
+}
+
 ////////////////////////////////////////////////
 static gboolean expose_event_cb(GtkWidget *widget, GdkEvent *event,
 		gpointer user_data)
diff --git a/src/plugins/litehtml_viewer/lh_widget.h b/src/plugins/litehtml_viewer/lh_widget.h
index a792197..da2dc7f 100644
--- a/src/plugins/litehtml_viewer/lh_widget.h
+++ b/src/plugins/litehtml_viewer/lh_widget.h
@@ -33,9 +33,11 @@ class lh_widget : public container_linux
 
 		const litehtml::tchar_t *get_href_at(const gint x, const gint y) const;
 		void popup_context_menu(const litehtml::tchar_t *url, GdkEventButton *event);
+		const litehtml::tstring fullurl(const litehtml::tchar_t *url) const;
 
 		litehtml::document::ptr m_html;
 		litehtml::tstring m_clicked_url;
+		litehtml::tstring m_base_url;
 
 	private:
 		void paint_white();

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list