mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
WebHitTestResult: Use baseURI for resolving link url
Fixes resolving link urls when there is set base href. Closes #2010
This commit is contained in:
parent
29b51048fe
commit
d168efae9e
@ -47,6 +47,7 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
|
||||
" return window.getSelection().containsNode(e, true);"
|
||||
"}"
|
||||
"var res = {"
|
||||
" baseUrl: document.baseURI,"
|
||||
" alternateText: e.getAttribute('alt'),"
|
||||
" boundingRect: '',"
|
||||
" imageUrl: '',"
|
||||
@ -83,7 +84,12 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
|
||||
WebPage *p = const_cast<WebPage*>(page);
|
||||
m_viewportPos = p->mapToViewport(m_pos);
|
||||
const QString &js = source.arg(m_viewportPos.x()).arg(m_viewportPos.y());
|
||||
init(page->url(), p->execJavaScript(js).toMap());
|
||||
init(p->url(), p->execJavaScript(js).toMap());
|
||||
}
|
||||
|
||||
QUrl WebHitTestResult::baseUrl() const
|
||||
{
|
||||
return m_baseUrl;
|
||||
}
|
||||
|
||||
QString WebHitTestResult::alternateText() const
|
||||
@ -161,6 +167,7 @@ void WebHitTestResult::init(const QUrl &url, const QVariantMap &map)
|
||||
if (map.isEmpty())
|
||||
return;
|
||||
|
||||
m_baseUrl = map.value(QSL("baseUrl")).toUrl();
|
||||
m_alternateText = map.value(QSL("alternateText")).toString();
|
||||
m_imageUrl = map.value(QSL("imageUrl")).toUrl();
|
||||
m_isContentEditable = map.value(QSL("contentEditable")).toBool();
|
||||
@ -179,8 +186,7 @@ void WebHitTestResult::init(const QUrl &url, const QVariantMap &map)
|
||||
if (!m_imageUrl.isEmpty())
|
||||
m_imageUrl = url.resolved(m_imageUrl);
|
||||
if (!m_linkUrl.isEmpty())
|
||||
m_linkUrl = url.resolved(m_linkUrl);
|
||||
m_linkUrl = m_baseUrl.resolved(m_linkUrl);
|
||||
if (!m_mediaUrl.isEmpty())
|
||||
m_mediaUrl = url.resolved(m_mediaUrl);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ class QUPZILLA_EXPORT WebHitTestResult
|
||||
public:
|
||||
explicit WebHitTestResult(const WebPage *page, const QPoint &pos);
|
||||
|
||||
QUrl baseUrl() const;
|
||||
QString alternateText() const;
|
||||
QRect boundingRect() const;
|
||||
QUrl imageUrl() const;
|
||||
@ -51,6 +52,7 @@ private:
|
||||
void init(const QUrl &url, const QVariantMap &map);
|
||||
|
||||
bool m_isNull;
|
||||
QUrl m_baseUrl;
|
||||
QString m_alternateText;
|
||||
QRect m_boundingRect;
|
||||
QUrl m_imageUrl;
|
||||
|
Loading…
Reference in New Issue
Block a user