mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 11:02:19 +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);"
|
" return window.getSelection().containsNode(e, true);"
|
||||||
"}"
|
"}"
|
||||||
"var res = {"
|
"var res = {"
|
||||||
|
" baseUrl: document.baseURI,"
|
||||||
" alternateText: e.getAttribute('alt'),"
|
" alternateText: e.getAttribute('alt'),"
|
||||||
" boundingRect: '',"
|
" boundingRect: '',"
|
||||||
" imageUrl: '',"
|
" imageUrl: '',"
|
||||||
|
@ -83,7 +84,12 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
|
||||||
WebPage *p = const_cast<WebPage*>(page);
|
WebPage *p = const_cast<WebPage*>(page);
|
||||||
m_viewportPos = p->mapToViewport(m_pos);
|
m_viewportPos = p->mapToViewport(m_pos);
|
||||||
const QString &js = source.arg(m_viewportPos.x()).arg(m_viewportPos.y());
|
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
|
QString WebHitTestResult::alternateText() const
|
||||||
|
@ -161,6 +167,7 @@ void WebHitTestResult::init(const QUrl &url, const QVariantMap &map)
|
||||||
if (map.isEmpty())
|
if (map.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_baseUrl = map.value(QSL("baseUrl")).toUrl();
|
||||||
m_alternateText = map.value(QSL("alternateText")).toString();
|
m_alternateText = map.value(QSL("alternateText")).toString();
|
||||||
m_imageUrl = map.value(QSL("imageUrl")).toUrl();
|
m_imageUrl = map.value(QSL("imageUrl")).toUrl();
|
||||||
m_isContentEditable = map.value(QSL("contentEditable")).toBool();
|
m_isContentEditable = map.value(QSL("contentEditable")).toBool();
|
||||||
|
@ -179,8 +186,7 @@ void WebHitTestResult::init(const QUrl &url, const QVariantMap &map)
|
||||||
if (!m_imageUrl.isEmpty())
|
if (!m_imageUrl.isEmpty())
|
||||||
m_imageUrl = url.resolved(m_imageUrl);
|
m_imageUrl = url.resolved(m_imageUrl);
|
||||||
if (!m_linkUrl.isEmpty())
|
if (!m_linkUrl.isEmpty())
|
||||||
m_linkUrl = url.resolved(m_linkUrl);
|
m_linkUrl = m_baseUrl.resolved(m_linkUrl);
|
||||||
if (!m_mediaUrl.isEmpty())
|
if (!m_mediaUrl.isEmpty())
|
||||||
m_mediaUrl = url.resolved(m_mediaUrl);
|
m_mediaUrl = url.resolved(m_mediaUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ class QUPZILLA_EXPORT WebHitTestResult
|
||||||
public:
|
public:
|
||||||
explicit WebHitTestResult(const WebPage *page, const QPoint &pos);
|
explicit WebHitTestResult(const WebPage *page, const QPoint &pos);
|
||||||
|
|
||||||
|
QUrl baseUrl() const;
|
||||||
QString alternateText() const;
|
QString alternateText() const;
|
||||||
QRect boundingRect() const;
|
QRect boundingRect() const;
|
||||||
QUrl imageUrl() const;
|
QUrl imageUrl() const;
|
||||||
|
@ -51,6 +52,7 @@ private:
|
||||||
void init(const QUrl &url, const QVariantMap &map);
|
void init(const QUrl &url, const QVariantMap &map);
|
||||||
|
|
||||||
bool m_isNull;
|
bool m_isNull;
|
||||||
|
QUrl m_baseUrl;
|
||||||
QString m_alternateText;
|
QString m_alternateText;
|
||||||
QRect m_boundingRect;
|
QRect m_boundingRect;
|
||||||
QUrl m_imageUrl;
|
QUrl m_imageUrl;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user