commit 655a159a37d09813988879af691c76748d5886fc
parent 1efad926768a8f609ad15f9ee3926ba38d4b601c
Author: Andrej Kacian <ticho@claws-mail.org>
Date: Mon, 18 Feb 2019 00:46:24 +0100
Use prepend document base url to #fragment links in Litehtml plugin
Diffstat:
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git 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
@@ -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();