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

Proposed by Olivier Tilloy on 2015-11-16
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 2015-11-16 Approve on 2015-11-23
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 on 2015-11-18
1274. By Olivier Tilloy on 2015-11-16

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

1275. By Olivier Tilloy on 2015-11-18

Add a unit test for the hoveredLink property.

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 on 2015-11-23
1276. By Olivier Tilloy on 2015-11-23

Store the target URL in oxide::WebView.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qt/core/browser/oxide_qt_web_view.cc'
2--- qt/core/browser/oxide_qt_web_view.cc 2015-10-27 11:36:49 +0000
3+++ qt/core/browser/oxide_qt_web_view.cc 2015-11-23 18:04:16 +0000
4@@ -873,6 +873,10 @@
5 client_->CloseRequested();
6 }
7
8+void WebView::TargetURLChanged() {
9+ client_->TargetURLChanged();
10+}
11+
12 size_t WebView::GetScriptMessageHandlerCount() const {
13 return message_handlers_.size();
14 }
15@@ -1358,6 +1362,10 @@
16 }
17 }
18
19+QUrl WebView::targetUrl() const {
20+ return QUrl(QString::fromStdString(view_->target_url().spec()));
21+}
22+
23 void WebView::teardownFrameTree() {
24 DCHECK(!frame_tree_torn_down_);
25
26
27=== modified file 'qt/core/browser/oxide_qt_web_view.h'
28--- qt/core/browser/oxide_qt_web_view.h 2015-10-21 19:06:54 +0000
29+++ qt/core/browser/oxide_qt_web_view.h 2015-11-23 18:04:16 +0000
30@@ -171,6 +171,7 @@
31 void ContentBlocked() override;
32 void PrepareToCloseResponseReceived(bool proceed) override;
33 void CloseRequested() override;
34+ void TargetURLChanged() override;
35
36 // oxide::ScriptMessageTarget implementation
37 size_t GetScriptMessageHandlerCount() const override;
38@@ -285,6 +286,8 @@
39
40 void executeEditingCommand(EditingCommands command) const override;
41
42+ QUrl targetUrl() const override;
43+
44 void teardownFrameTree() override;
45
46 // This must outlive |view_|
47
48=== modified file 'qt/core/glue/oxide_qt_web_view_proxy.h'
49--- qt/core/glue/oxide_qt_web_view_proxy.h 2015-10-16 21:36:30 +0000
50+++ qt/core/glue/oxide_qt_web_view_proxy.h 2015-11-23 18:04:16 +0000
51@@ -237,6 +237,8 @@
52
53 virtual void executeEditingCommand(EditingCommands command) const = 0;
54
55+ virtual QUrl targetUrl() const = 0;
56+
57 virtual void teardownFrameTree() = 0;
58 };
59
60
61=== modified file 'qt/core/glue/oxide_qt_web_view_proxy_client.h'
62--- qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-10-08 15:56:22 +0000
63+++ qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-11-23 18:04:16 +0000
64@@ -19,7 +19,6 @@
65 #define _OXIDE_QT_CORE_GLUE_WEB_VIEW_PROXY_CLIENT_H_
66
67 #include <QRect>
68-#include <QUrl>
69 #include <QtGlobal>
70
71 #include "qt/core/glue/oxide_qt_javascript_dialog_proxy_client.h"
72@@ -150,6 +149,8 @@
73
74 virtual void PrepareToCloseResponse(bool proceed) = 0;
75 virtual void CloseRequested() = 0;
76+
77+ virtual void TargetURLChanged() = 0;
78 };
79
80 } // namespace qt
81
82=== modified file 'qt/qmlplugin/oxide.qmltypes'
83--- qt/qmlplugin/oxide.qmltypes 2015-10-19 17:27:42 +0000
84+++ qt/qmlplugin/oxide.qmltypes 2015-11-23 18:04:16 +0000
85@@ -4,7 +4,7 @@
86 // It is used for QML tooling purposes only.
87 //
88 // This file was auto-generated by:
89-// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.11 com/canonical/Oxide'
90+// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.12 com/canonical/Oxide'
91
92 Module {
93 Component {
94@@ -460,13 +460,14 @@
95 exports: [
96 "WebView 1.0",
97 "WebView 1.11",
98+ "WebView 1.12",
99 "WebView 1.3",
100 "WebView 1.4",
101 "WebView 1.5",
102 "WebView 1.8",
103 "WebView 1.9"
104 ]
105- exportMetaObjectRevisions: [0, 6, 1, 2, 3, 4, 5]
106+ exportMetaObjectRevisions: [0, 6, 7, 1, 2, 3, 4, 5]
107 attachedType: "OxideQQuickWebViewAttached"
108 Enum {
109 name: "LogMessageSeverityLevel"
110@@ -618,6 +619,7 @@
111 isPointer: true
112 }
113 Property { name: "webProcessStatus"; revision: 4; type: "WebProcessStatus"; isReadonly: true }
114+ Property { name: "hoveredUrl"; type: "QUrl"; isReadonly: true }
115 Signal { name: "loadingStateChanged"; revision: 1 }
116 Signal {
117 name: "loadEvent"
118@@ -686,6 +688,7 @@
119 revision: 5
120 Parameter { name: "request"; type: "QJSValue" }
121 }
122+ Signal { name: "hoveredUrlChanged"; revision: 7 }
123 Signal {
124 name: "loadingChanged"
125 Parameter { name: "loadEvent"; type: "OxideQLoadEvent" }
126
127=== modified file 'qt/qmlplugin/oxide_qml_plugin.cc'
128--- qt/qmlplugin/oxide_qml_plugin.cc 2015-09-25 22:35:33 +0000
129+++ qt/qmlplugin/oxide_qml_plugin.cc 2015-11-23 18:04:16 +0000
130@@ -162,6 +162,8 @@
131 qmlRegisterType<OxideQQuickWebView, 5>(uri, 1, 9, "WebView");
132
133 qmlRegisterType<OxideQQuickWebView, 6>(uri, 1, 11, "WebView");
134+
135+ qmlRegisterType<OxideQQuickWebView, 7>(uri, 1, 12, "WebView");
136 }
137 };
138
139
140=== modified file 'qt/quick/api/oxideqquickwebview.cc'
141--- qt/quick/api/oxideqquickwebview.cc 2015-11-20 15:49:58 +0000
142+++ qt/quick/api/oxideqquickwebview.cc 2015-11-23 18:04:16 +0000
143@@ -636,6 +636,12 @@
144 emit q->closeRequested();
145 }
146
147+void OxideQQuickWebViewPrivate::TargetURLChanged() {
148+ Q_Q(OxideQQuickWebView);
149+
150+ emit q->hoveredUrlChanged();
151+}
152+
153 void OxideQQuickWebViewPrivate::completeConstruction() {
154 Q_Q(OxideQQuickWebView);
155
156@@ -2068,6 +2074,16 @@
157 return static_cast<WebProcessStatus>(d->proxy()->webProcessStatus());
158 }
159
160+QUrl OxideQQuickWebView::hoveredUrl() const {
161+ Q_D(const OxideQQuickWebView);
162+
163+ if (!d->proxy()) {
164+ return QUrl();
165+ }
166+
167+ return d->proxy()->targetUrl();
168+}
169+
170 // static
171 OxideQQuickWebViewAttached* OxideQQuickWebView::qmlAttachedProperties(
172 QObject* object) {
173
174=== modified file 'qt/quick/api/oxideqquickwebview_p.h'
175--- qt/quick/api/oxideqquickwebview_p.h 2015-09-25 22:30:19 +0000
176+++ qt/quick/api/oxideqquickwebview_p.h 2015-11-23 18:04:16 +0000
177@@ -131,6 +131,8 @@
178
179 Q_PROPERTY(WebProcessStatus webProcessStatus READ webProcessStatus NOTIFY webProcessStatusChanged REVISION 4)
180
181+ Q_PROPERTY(QUrl hoveredUrl READ hoveredUrl NOTIFY hoveredUrlChanged)
182+
183 Q_DECLARE_PRIVATE(OxideQQuickWebView)
184
185 public:
186@@ -293,6 +295,8 @@
187
188 WebProcessStatus webProcessStatus() const;
189
190+ QUrl hoveredUrl() const;
191+
192 static OxideQQuickWebViewAttached* qmlAttachedProperties(QObject* object);
193
194 OxideQFindController* findController() const;
195@@ -357,6 +361,7 @@
196 Q_REVISION(2) void closeRequested();
197 Q_REVISION(4) void webProcessStatusChanged();
198 Q_REVISION(5) void httpAuthenticationRequested(const QJSValue& request);
199+ Q_REVISION(7) void hoveredUrlChanged();
200
201 // Deprecated since 1.3
202 void loadingChanged(const OxideQLoadEvent& loadEvent);
203
204=== modified file 'qt/quick/api/oxideqquickwebview_p_p.h'
205--- qt/quick/api/oxideqquickwebview_p_p.h 2015-10-08 15:56:22 +0000
206+++ qt/quick/api/oxideqquickwebview_p_p.h 2015-11-23 18:04:16 +0000
207@@ -142,6 +142,7 @@
208 void ContentBlocked() override;
209 void PrepareToCloseResponse(bool proceed) override;
210 void CloseRequested() override;
211+ void TargetURLChanged() override;
212
213 oxide::qt::WebViewProxy* proxy() const {
214 return oxide::qt::WebViewProxyHandle::proxy();
215
216=== added file 'qt/tests/qmltests/api/tst_WebView_hoveredUrl.html'
217--- qt/tests/qmltests/api/tst_WebView_hoveredUrl.html 1970-01-01 00:00:00 +0000
218+++ qt/tests/qmltests/api/tst_WebView_hoveredUrl.html 2015-11-23 18:04:16 +0000
219@@ -0,0 +1,7 @@
220+<html>
221+<body>
222+ <p><a id="link1" href="http://example.org/">example.org</a></p>
223+ <p><button id="button">button</button></p>
224+ <p><a id="link2" href="https://launchpad.net/">launchpad.net</a></p>
225+</body>
226+</html>
227
228=== added file 'qt/tests/qmltests/api/tst_WebView_hoveredUrl.qml'
229--- qt/tests/qmltests/api/tst_WebView_hoveredUrl.qml 1970-01-01 00:00:00 +0000
230+++ qt/tests/qmltests/api/tst_WebView_hoveredUrl.qml 2015-11-23 18:04:16 +0000
231@@ -0,0 +1,51 @@
232+import QtQuick 2.0
233+import QtTest 1.0
234+import com.canonical.Oxide 1.12
235+import com.canonical.Oxide.Testing 1.0
236+
237+TestWebView {
238+ id: webView
239+ focus: true
240+ width: 200
241+ height: 200
242+
243+ SignalSpy {
244+ id: spy
245+ target: webView
246+ signalName: "hoveredUrlChanged"
247+ }
248+
249+ TestCase {
250+ name: "WebView_hoveredUrl"
251+ when: windowShown
252+
253+ function test_hoveredUrl() {
254+ webView.url = "http://foo.testsuite/tst_WebView_hoveredUrl.html"
255+ verify(webView.waitForLoadSucceeded());
256+ spy.clear();
257+
258+ var r = webView.getTestApi().getBoundingClientRectForSelector("#link1");
259+ mouseMove(webView, r.x + r.width / 2, r.y + r.height / 2);
260+ spy.wait();
261+ compare(webView.hoveredUrl, "http://example.org/");
262+ compare(spy.count, 1);
263+
264+ r = webView.getTestApi().getBoundingClientRectForSelector("#button");
265+ mouseMove(webView, r.x + r.width / 2, r.y + r.height / 2);
266+ spy.wait();
267+ compare(webView.hoveredUrl, "");
268+ compare(spy.count, 2);
269+
270+ r = webView.getTestApi().getBoundingClientRectForSelector("#link2");
271+ mouseMove(webView, r.x + r.width / 2, r.y + r.height / 2);
272+ spy.wait();
273+ compare(webView.hoveredUrl, "https://launchpad.net/");
274+ compare(spy.count, 3);
275+
276+ mouseMove(webView, r.x + r.width / 2, r.y + r.height * 2);
277+ spy.wait();
278+ compare(webView.hoveredUrl, "");
279+ compare(spy.count, 4);
280+ }
281+ }
282+}
283
284=== modified file 'shared/browser/oxide_web_view.cc'
285--- shared/browser/oxide_web_view.cc 2015-11-16 20:03:58 +0000
286+++ shared/browser/oxide_web_view.cc 2015-11-23 18:04:16 +0000
287@@ -785,6 +785,15 @@
288 client_->CloseRequested();
289 }
290
291+void WebView::UpdateTargetURL(content::WebContents* source, const GURL& url) {
292+ DCHECK_VALID_SOURCE_CONTENTS
293+
294+ if (url != target_url_) {
295+ target_url_ = url;
296+ client_->TargetURLChanged();
297+ }
298+}
299+
300 bool WebView::AddMessageToConsole(content::WebContents* source,
301 int32 level,
302 const base::string16& message,
303
304=== modified file 'shared/browser/oxide_web_view.h'
305--- shared/browser/oxide_web_view.h 2015-11-11 21:20:30 +0000
306+++ shared/browser/oxide_web_view.h 2015-11-23 18:04:16 +0000
307@@ -288,6 +288,8 @@
308
309 bool CanCreateWindows() const;
310
311+ const GURL& target_url() const { return target_url_; }
312+
313 private:
314 WebView(WebViewClient* client);
315
316@@ -390,6 +392,7 @@
317 bool* was_blocked) final;
318 void LoadProgressChanged(content::WebContents* source, double progress) final;
319 void CloseContents(content::WebContents* source) final;
320+ void UpdateTargetURL(content::WebContents* source, const GURL& url) final;
321 bool AddMessageToConsole(content::WebContents* source,
322 int32 level,
323 const base::string16& message,
324@@ -511,6 +514,8 @@
325
326 RenderWidgetHostID interstitial_rwh_id_;
327
328+ GURL target_url_;
329+
330 base::WeakPtrFactory<WebView> weak_factory_;
331
332 DISALLOW_COPY_AND_ASSIGN(WebView);
333
334=== modified file 'shared/browser/oxide_web_view_client.cc'
335--- shared/browser/oxide_web_view_client.cc 2015-10-21 19:06:54 +0000
336+++ shared/browser/oxide_web_view_client.cc 2015-11-23 18:04:16 +0000
337@@ -147,6 +147,8 @@
338
339 void WebViewClient::CloseRequested() {}
340
341+void WebViewClient::TargetURLChanged() {}
342+
343 void WebViewClient::HttpAuthenticationRequested(
344 ResourceDispatcherHostLoginDelegate* login_delegate) {}
345
346
347=== modified file 'shared/browser/oxide_web_view_client.h'
348--- shared/browser/oxide_web_view_client.h 2015-10-21 19:06:54 +0000
349+++ shared/browser/oxide_web_view_client.h 2015-11-23 18:04:16 +0000
350@@ -183,6 +183,8 @@
351
352 virtual void CloseRequested();
353
354+ virtual void TargetURLChanged();
355+
356 virtual void HttpAuthenticationRequested(
357 ResourceDispatcherHostLoginDelegate* login_delegate);
358 };

Subscribers

People subscribed via source and target branches