Merge lp:~osomon/oxide/linkHovered into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 1281
Proposed branch: lp:~osomon/oxide/linkHovered
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 358 lines (+120/-3)
15 files modified
qt/core/browser/oxide_qt_web_view.cc (+8/-0)
qt/core/browser/oxide_qt_web_view.h (+3/-0)
qt/core/glue/oxide_qt_web_view_proxy.h (+2/-0)
qt/core/glue/oxide_qt_web_view_proxy_client.h (+2/-1)
qt/qmlplugin/oxide.qmltypes (+5/-2)
qt/qmlplugin/oxide_qml_plugin.cc (+2/-0)
qt/quick/api/oxideqquickwebview.cc (+16/-0)
qt/quick/api/oxideqquickwebview_p.h (+5/-0)
qt/quick/api/oxideqquickwebview_p_p.h (+1/-0)
qt/tests/qmltests/api/tst_WebView_hoveredUrl.html (+7/-0)
qt/tests/qmltests/api/tst_WebView_hoveredUrl.qml (+51/-0)
shared/browser/oxide_web_view.cc (+9/-0)
shared/browser/oxide_web_view.h (+5/-0)
shared/browser/oxide_web_view_client.cc (+2/-0)
shared/browser/oxide_web_view_client.h (+2/-0)
To merge this branch: bzr merge lp:~osomon/oxide/linkHovered
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+277562@code.launchpad.net

Commit message

Add a hoveredUrl property to the QML WebView API.

Description of the change

Add a hoveredUrl property to the QML WebView API.

This differs from QtWebEngine’s API which exposes only a linkHovered(hoveredUrl) signal.

To post a comment you must log in.
lp:~osomon/oxide/linkHovered updated
1274. By Olivier Tilloy

Replace the linkHovered signal with a hoveredUrl property (with the corresponding change notifier).

1275. By Olivier Tilloy

Add a unit test for the hoveredLink property.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

This looks mostly ok. One thing I'd prefer is for the actual target URL to be stored in oxide::WebView. As the target URL can be updated with keyboard focus, it's possible that a newly created WebContents (created with window.open) might get an update for this before we create a webview. In this case, we'll miss it but in the future I plan to completely decouple the WebContentsDelegate implementation from WebView

review: Approve
lp:~osomon/oxide/linkHovered updated
1276. By Olivier Tilloy

Store the target URL in oxide::WebView.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qt/core/browser/oxide_qt_web_view.cc'
--- qt/core/browser/oxide_qt_web_view.cc 2015-10-27 11:36:49 +0000
+++ qt/core/browser/oxide_qt_web_view.cc 2015-11-23 18:04:16 +0000
@@ -873,6 +873,10 @@
873 client_->CloseRequested();873 client_->CloseRequested();
874}874}
875875
876void WebView::TargetURLChanged() {
877 client_->TargetURLChanged();
878}
879
876size_t WebView::GetScriptMessageHandlerCount() const {880size_t WebView::GetScriptMessageHandlerCount() const {
877 return message_handlers_.size();881 return message_handlers_.size();
878}882}
@@ -1358,6 +1362,10 @@
1358 }1362 }
1359}1363}
13601364
1365QUrl WebView::targetUrl() const {
1366 return QUrl(QString::fromStdString(view_->target_url().spec()));
1367}
1368
1361void WebView::teardownFrameTree() {1369void WebView::teardownFrameTree() {
1362 DCHECK(!frame_tree_torn_down_);1370 DCHECK(!frame_tree_torn_down_);
13631371
13641372
=== modified file 'qt/core/browser/oxide_qt_web_view.h'
--- qt/core/browser/oxide_qt_web_view.h 2015-10-21 19:06:54 +0000
+++ qt/core/browser/oxide_qt_web_view.h 2015-11-23 18:04:16 +0000
@@ -171,6 +171,7 @@
171 void ContentBlocked() override;171 void ContentBlocked() override;
172 void PrepareToCloseResponseReceived(bool proceed) override;172 void PrepareToCloseResponseReceived(bool proceed) override;
173 void CloseRequested() override;173 void CloseRequested() override;
174 void TargetURLChanged() override;
174175
175 // oxide::ScriptMessageTarget implementation176 // oxide::ScriptMessageTarget implementation
176 size_t GetScriptMessageHandlerCount() const override;177 size_t GetScriptMessageHandlerCount() const override;
@@ -285,6 +286,8 @@
285286
286 void executeEditingCommand(EditingCommands command) const override;287 void executeEditingCommand(EditingCommands command) const override;
287288
289 QUrl targetUrl() const override;
290
288 void teardownFrameTree() override;291 void teardownFrameTree() override;
289292
290 // This must outlive |view_|293 // This must outlive |view_|
291294
=== modified file 'qt/core/glue/oxide_qt_web_view_proxy.h'
--- qt/core/glue/oxide_qt_web_view_proxy.h 2015-10-16 21:36:30 +0000
+++ qt/core/glue/oxide_qt_web_view_proxy.h 2015-11-23 18:04:16 +0000
@@ -237,6 +237,8 @@
237237
238 virtual void executeEditingCommand(EditingCommands command) const = 0;238 virtual void executeEditingCommand(EditingCommands command) const = 0;
239239
240 virtual QUrl targetUrl() const = 0;
241
240 virtual void teardownFrameTree() = 0;242 virtual void teardownFrameTree() = 0;
241};243};
242244
243245
=== modified file 'qt/core/glue/oxide_qt_web_view_proxy_client.h'
--- qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-10-08 15:56:22 +0000
+++ qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-11-23 18:04:16 +0000
@@ -19,7 +19,6 @@
19#define _OXIDE_QT_CORE_GLUE_WEB_VIEW_PROXY_CLIENT_H_19#define _OXIDE_QT_CORE_GLUE_WEB_VIEW_PROXY_CLIENT_H_
2020
21#include <QRect>21#include <QRect>
22#include <QUrl>
23#include <QtGlobal>22#include <QtGlobal>
2423
25#include "qt/core/glue/oxide_qt_javascript_dialog_proxy_client.h"24#include "qt/core/glue/oxide_qt_javascript_dialog_proxy_client.h"
@@ -150,6 +149,8 @@
150149
151 virtual void PrepareToCloseResponse(bool proceed) = 0;150 virtual void PrepareToCloseResponse(bool proceed) = 0;
152 virtual void CloseRequested() = 0;151 virtual void CloseRequested() = 0;
152
153 virtual void TargetURLChanged() = 0;
153};154};
154155
155} // namespace qt156} // namespace qt
156157
=== modified file 'qt/qmlplugin/oxide.qmltypes'
--- qt/qmlplugin/oxide.qmltypes 2015-10-19 17:27:42 +0000
+++ qt/qmlplugin/oxide.qmltypes 2015-11-23 18:04:16 +0000
@@ -4,7 +4,7 @@
4// It is used for QML tooling purposes only.4// It is used for QML tooling purposes only.
5//5//
6// This file was auto-generated by:6// This file was auto-generated by:
7// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.11 com/canonical/Oxide'7// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.12 com/canonical/Oxide'
88
9Module {9Module {
10 Component {10 Component {
@@ -460,13 +460,14 @@
460 exports: [460 exports: [
461 "WebView 1.0",461 "WebView 1.0",
462 "WebView 1.11",462 "WebView 1.11",
463 "WebView 1.12",
463 "WebView 1.3",464 "WebView 1.3",
464 "WebView 1.4",465 "WebView 1.4",
465 "WebView 1.5",466 "WebView 1.5",
466 "WebView 1.8",467 "WebView 1.8",
467 "WebView 1.9"468 "WebView 1.9"
468 ]469 ]
469 exportMetaObjectRevisions: [0, 6, 1, 2, 3, 4, 5]470 exportMetaObjectRevisions: [0, 6, 7, 1, 2, 3, 4, 5]
470 attachedType: "OxideQQuickWebViewAttached"471 attachedType: "OxideQQuickWebViewAttached"
471 Enum {472 Enum {
472 name: "LogMessageSeverityLevel"473 name: "LogMessageSeverityLevel"
@@ -618,6 +619,7 @@
618 isPointer: true619 isPointer: true
619 }620 }
620 Property { name: "webProcessStatus"; revision: 4; type: "WebProcessStatus"; isReadonly: true }621 Property { name: "webProcessStatus"; revision: 4; type: "WebProcessStatus"; isReadonly: true }
622 Property { name: "hoveredUrl"; type: "QUrl"; isReadonly: true }
621 Signal { name: "loadingStateChanged"; revision: 1 }623 Signal { name: "loadingStateChanged"; revision: 1 }
622 Signal {624 Signal {
623 name: "loadEvent"625 name: "loadEvent"
@@ -686,6 +688,7 @@
686 revision: 5688 revision: 5
687 Parameter { name: "request"; type: "QJSValue" }689 Parameter { name: "request"; type: "QJSValue" }
688 }690 }
691 Signal { name: "hoveredUrlChanged"; revision: 7 }
689 Signal {692 Signal {
690 name: "loadingChanged"693 name: "loadingChanged"
691 Parameter { name: "loadEvent"; type: "OxideQLoadEvent" }694 Parameter { name: "loadEvent"; type: "OxideQLoadEvent" }
692695
=== modified file 'qt/qmlplugin/oxide_qml_plugin.cc'
--- qt/qmlplugin/oxide_qml_plugin.cc 2015-09-25 22:35:33 +0000
+++ qt/qmlplugin/oxide_qml_plugin.cc 2015-11-23 18:04:16 +0000
@@ -162,6 +162,8 @@
162 qmlRegisterType<OxideQQuickWebView, 5>(uri, 1, 9, "WebView");162 qmlRegisterType<OxideQQuickWebView, 5>(uri, 1, 9, "WebView");
163163
164 qmlRegisterType<OxideQQuickWebView, 6>(uri, 1, 11, "WebView");164 qmlRegisterType<OxideQQuickWebView, 6>(uri, 1, 11, "WebView");
165
166 qmlRegisterType<OxideQQuickWebView, 7>(uri, 1, 12, "WebView");
165 }167 }
166};168};
167169
168170
=== modified file 'qt/quick/api/oxideqquickwebview.cc'
--- qt/quick/api/oxideqquickwebview.cc 2015-11-20 15:49:58 +0000
+++ qt/quick/api/oxideqquickwebview.cc 2015-11-23 18:04:16 +0000
@@ -636,6 +636,12 @@
636 emit q->closeRequested();636 emit q->closeRequested();
637}637}
638638
639void OxideQQuickWebViewPrivate::TargetURLChanged() {
640 Q_Q(OxideQQuickWebView);
641
642 emit q->hoveredUrlChanged();
643}
644
639void OxideQQuickWebViewPrivate::completeConstruction() {645void OxideQQuickWebViewPrivate::completeConstruction() {
640 Q_Q(OxideQQuickWebView);646 Q_Q(OxideQQuickWebView);
641647
@@ -2068,6 +2074,16 @@
2068 return static_cast<WebProcessStatus>(d->proxy()->webProcessStatus());2074 return static_cast<WebProcessStatus>(d->proxy()->webProcessStatus());
2069}2075}
20702076
2077QUrl OxideQQuickWebView::hoveredUrl() const {
2078 Q_D(const OxideQQuickWebView);
2079
2080 if (!d->proxy()) {
2081 return QUrl();
2082 }
2083
2084 return d->proxy()->targetUrl();
2085}
2086
2071// static2087// static
2072OxideQQuickWebViewAttached* OxideQQuickWebView::qmlAttachedProperties(2088OxideQQuickWebViewAttached* OxideQQuickWebView::qmlAttachedProperties(
2073 QObject* object) {2089 QObject* object) {
20742090
=== modified file 'qt/quick/api/oxideqquickwebview_p.h'
--- qt/quick/api/oxideqquickwebview_p.h 2015-09-25 22:30:19 +0000
+++ qt/quick/api/oxideqquickwebview_p.h 2015-11-23 18:04:16 +0000
@@ -131,6 +131,8 @@
131131
132 Q_PROPERTY(WebProcessStatus webProcessStatus READ webProcessStatus NOTIFY webProcessStatusChanged REVISION 4)132 Q_PROPERTY(WebProcessStatus webProcessStatus READ webProcessStatus NOTIFY webProcessStatusChanged REVISION 4)
133133
134 Q_PROPERTY(QUrl hoveredUrl READ hoveredUrl NOTIFY hoveredUrlChanged)
135
134 Q_DECLARE_PRIVATE(OxideQQuickWebView)136 Q_DECLARE_PRIVATE(OxideQQuickWebView)
135137
136 public:138 public:
@@ -293,6 +295,8 @@
293295
294 WebProcessStatus webProcessStatus() const;296 WebProcessStatus webProcessStatus() const;
295297
298 QUrl hoveredUrl() const;
299
296 static OxideQQuickWebViewAttached* qmlAttachedProperties(QObject* object);300 static OxideQQuickWebViewAttached* qmlAttachedProperties(QObject* object);
297301
298 OxideQFindController* findController() const;302 OxideQFindController* findController() const;
@@ -357,6 +361,7 @@
357 Q_REVISION(2) void closeRequested();361 Q_REVISION(2) void closeRequested();
358 Q_REVISION(4) void webProcessStatusChanged();362 Q_REVISION(4) void webProcessStatusChanged();
359 Q_REVISION(5) void httpAuthenticationRequested(const QJSValue& request);363 Q_REVISION(5) void httpAuthenticationRequested(const QJSValue& request);
364 Q_REVISION(7) void hoveredUrlChanged();
360365
361 // Deprecated since 1.3366 // Deprecated since 1.3
362 void loadingChanged(const OxideQLoadEvent& loadEvent);367 void loadingChanged(const OxideQLoadEvent& loadEvent);
363368
=== modified file 'qt/quick/api/oxideqquickwebview_p_p.h'
--- qt/quick/api/oxideqquickwebview_p_p.h 2015-10-08 15:56:22 +0000
+++ qt/quick/api/oxideqquickwebview_p_p.h 2015-11-23 18:04:16 +0000
@@ -142,6 +142,7 @@
142 void ContentBlocked() override;142 void ContentBlocked() override;
143 void PrepareToCloseResponse(bool proceed) override;143 void PrepareToCloseResponse(bool proceed) override;
144 void CloseRequested() override;144 void CloseRequested() override;
145 void TargetURLChanged() override;
145146
146 oxide::qt::WebViewProxy* proxy() const {147 oxide::qt::WebViewProxy* proxy() const {
147 return oxide::qt::WebViewProxyHandle::proxy();148 return oxide::qt::WebViewProxyHandle::proxy();
148149
=== added file 'qt/tests/qmltests/api/tst_WebView_hoveredUrl.html'
--- qt/tests/qmltests/api/tst_WebView_hoveredUrl.html 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_hoveredUrl.html 2015-11-23 18:04:16 +0000
@@ -0,0 +1,7 @@
1<html>
2<body>
3 <p><a id="link1" href="http://example.org/">example.org</a></p>
4 <p><button id="button">button</button></p>
5 <p><a id="link2" href="https://launchpad.net/">launchpad.net</a></p>
6</body>
7</html>
08
=== added file 'qt/tests/qmltests/api/tst_WebView_hoveredUrl.qml'
--- qt/tests/qmltests/api/tst_WebView_hoveredUrl.qml 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_hoveredUrl.qml 2015-11-23 18:04:16 +0000
@@ -0,0 +1,51 @@
1import QtQuick 2.0
2import QtTest 1.0
3import com.canonical.Oxide 1.12
4import com.canonical.Oxide.Testing 1.0
5
6TestWebView {
7 id: webView
8 focus: true
9 width: 200
10 height: 200
11
12 SignalSpy {
13 id: spy
14 target: webView
15 signalName: "hoveredUrlChanged"
16 }
17
18 TestCase {
19 name: "WebView_hoveredUrl"
20 when: windowShown
21
22 function test_hoveredUrl() {
23 webView.url = "http://foo.testsuite/tst_WebView_hoveredUrl.html"
24 verify(webView.waitForLoadSucceeded());
25 spy.clear();
26
27 var r = webView.getTestApi().getBoundingClientRectForSelector("#link1");
28 mouseMove(webView, r.x + r.width / 2, r.y + r.height / 2);
29 spy.wait();
30 compare(webView.hoveredUrl, "http://example.org/");
31 compare(spy.count, 1);
32
33 r = webView.getTestApi().getBoundingClientRectForSelector("#button");
34 mouseMove(webView, r.x + r.width / 2, r.y + r.height / 2);
35 spy.wait();
36 compare(webView.hoveredUrl, "");
37 compare(spy.count, 2);
38
39 r = webView.getTestApi().getBoundingClientRectForSelector("#link2");
40 mouseMove(webView, r.x + r.width / 2, r.y + r.height / 2);
41 spy.wait();
42 compare(webView.hoveredUrl, "https://launchpad.net/");
43 compare(spy.count, 3);
44
45 mouseMove(webView, r.x + r.width / 2, r.y + r.height * 2);
46 spy.wait();
47 compare(webView.hoveredUrl, "");
48 compare(spy.count, 4);
49 }
50 }
51}
052
=== modified file 'shared/browser/oxide_web_view.cc'
--- shared/browser/oxide_web_view.cc 2015-11-16 20:03:58 +0000
+++ shared/browser/oxide_web_view.cc 2015-11-23 18:04:16 +0000
@@ -785,6 +785,15 @@
785 client_->CloseRequested();785 client_->CloseRequested();
786}786}
787787
788void WebView::UpdateTargetURL(content::WebContents* source, const GURL& url) {
789 DCHECK_VALID_SOURCE_CONTENTS
790
791 if (url != target_url_) {
792 target_url_ = url;
793 client_->TargetURLChanged();
794 }
795}
796
788bool WebView::AddMessageToConsole(content::WebContents* source,797bool WebView::AddMessageToConsole(content::WebContents* source,
789 int32 level,798 int32 level,
790 const base::string16& message,799 const base::string16& message,
791800
=== modified file 'shared/browser/oxide_web_view.h'
--- shared/browser/oxide_web_view.h 2015-11-11 21:20:30 +0000
+++ shared/browser/oxide_web_view.h 2015-11-23 18:04:16 +0000
@@ -288,6 +288,8 @@
288288
289 bool CanCreateWindows() const;289 bool CanCreateWindows() const;
290290
291 const GURL& target_url() const { return target_url_; }
292
291 private:293 private:
292 WebView(WebViewClient* client);294 WebView(WebViewClient* client);
293295
@@ -390,6 +392,7 @@
390 bool* was_blocked) final;392 bool* was_blocked) final;
391 void LoadProgressChanged(content::WebContents* source, double progress) final;393 void LoadProgressChanged(content::WebContents* source, double progress) final;
392 void CloseContents(content::WebContents* source) final;394 void CloseContents(content::WebContents* source) final;
395 void UpdateTargetURL(content::WebContents* source, const GURL& url) final;
393 bool AddMessageToConsole(content::WebContents* source,396 bool AddMessageToConsole(content::WebContents* source,
394 int32 level,397 int32 level,
395 const base::string16& message,398 const base::string16& message,
@@ -511,6 +514,8 @@
511514
512 RenderWidgetHostID interstitial_rwh_id_;515 RenderWidgetHostID interstitial_rwh_id_;
513516
517 GURL target_url_;
518
514 base::WeakPtrFactory<WebView> weak_factory_;519 base::WeakPtrFactory<WebView> weak_factory_;
515520
516 DISALLOW_COPY_AND_ASSIGN(WebView);521 DISALLOW_COPY_AND_ASSIGN(WebView);
517522
=== modified file 'shared/browser/oxide_web_view_client.cc'
--- shared/browser/oxide_web_view_client.cc 2015-10-21 19:06:54 +0000
+++ shared/browser/oxide_web_view_client.cc 2015-11-23 18:04:16 +0000
@@ -147,6 +147,8 @@
147147
148void WebViewClient::CloseRequested() {}148void WebViewClient::CloseRequested() {}
149149
150void WebViewClient::TargetURLChanged() {}
151
150void WebViewClient::HttpAuthenticationRequested(152void WebViewClient::HttpAuthenticationRequested(
151 ResourceDispatcherHostLoginDelegate* login_delegate) {}153 ResourceDispatcherHostLoginDelegate* login_delegate) {}
152154
153155
=== modified file 'shared/browser/oxide_web_view_client.h'
--- shared/browser/oxide_web_view_client.h 2015-10-21 19:06:54 +0000
+++ shared/browser/oxide_web_view_client.h 2015-11-23 18:04:16 +0000
@@ -183,6 +183,8 @@
183183
184 virtual void CloseRequested();184 virtual void CloseRequested();
185185
186 virtual void TargetURLChanged();
187
186 virtual void HttpAuthenticationRequested(188 virtual void HttpAuthenticationRequested(
187 ResourceDispatcherHostLoginDelegate* login_delegate);189 ResourceDispatcherHostLoginDelegate* login_delegate);
188};190};

Subscribers

People subscribed via source and target branches