Merge lp:~uriboni/oxide/find-in-page into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Ugo Riboni
Status: Merged
Merged at revision: 1088
Proposed branch: lp:~uriboni/oxide/find-in-page
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 863 lines (+587/-1)
15 files modified
qt/core/api/oxideqfindcontroller.cc (+97/-0)
qt/core/api/oxideqfindcontroller.h (+71/-0)
qt/core/api/oxideqfindcontroller_p.h (+46/-0)
qt/core/browser/oxide_qt_web_view.cc (+16/-1)
qt/core/browser/oxide_qt_web_view.h (+7/-0)
qt/core/core.gyp (+9/-0)
qt/core/glue/oxide_qt_web_view_proxy.h (+11/-0)
qt/qmlplugin/oxide_qml_plugin.cc (+5/-0)
qt/quick/api/oxideqquickwebview.cc (+7/-0)
qt/quick/api/oxideqquickwebview_p.h (+10/-0)
qt/tests/qmltests/api/tst_WebView_findController.html (+13/-0)
qt/tests/qmltests/api/tst_WebView_findController.qml (+152/-0)
qt/tests/qmltests/api/tst_WebView_findControllerManyResults.html (+9/-0)
shared/browser/oxide_web_view.cc (+102/-0)
shared/browser/oxide_web_view.h (+32/-0)
To merge this branch: bzr merge lp:~uriboni/oxide/find-in-page
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+258184@code.launchpad.net

Description of the change

Adds a new API to allow searching text within a page.

To post a comment you must log in.
lp:~uriboni/oxide/find-in-page updated
1063. By Ugo Riboni

Remove unrelated changes to cmake file

1064. By Ugo Riboni

Minor code style fixes

1065. By Ugo Riboni

Make findInPage group property constant to prevent non-notifyable property warnings

1066. By Ugo Riboni

Merge changes from trunk

Revision history for this message
Olivier Tilloy (osomon) wrote :

The API looks good to me (I’ll let Chris comment on the actual implementation). Here are a few comments, most of them on the unit tests:

 - In test_case_insensitive(), the second test should be on a different string, otherwise the count might not have been updated yet.

 - In test_new_text_resets_count() and in test_navigation_does_not_reset(), next() should be called after verifying that the count is 2.

 - In test_find_on_invalid_page(), waiting for a successful load doesn’t look right. Shouldn’t you use webView.waitForLoadFailed() ?

 - In test_navigation_does_not_reset(), the comparison of text to "dolor" doesn’t need a tryCompare(), it should be a simple compare().

 - In OxideQQuickWebViewFindInPage’s constructor, the explicit initialization of text_ is useless.

 - In the implementation of WebView::findInPage() and other methods, please avoid the use of a return statement on the same line as the condition, and always use curly braces, even for one-liner if blocks.

lp:~uriboni/oxide/find-in-page updated
1067. By Ugo Riboni

Fix code style (braces, indentation)

1068. By Ugo Riboni

Improve some tests

1069. By Ugo Riboni

Remove useless initialization

1070. By Ugo Riboni

Add explanatory comment and fix indentation

1071. By Ugo Riboni

Merge changes from trunk

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

Thanks for working on this. I have some general comments:

- I think I'd prefer WebView.findController and FindController for the corresponding class name in QML

- The implementation doesn't need to live in qt/quick/api - it should go in qt/core/api as OxideQFindController, as it doesn't really have any dependencies outside of the core library or QtCore and the implementation could be shared with a QWidget port - if someone ever decides it would be a good idea to write one :)

- As we want to open up the C++ API in the future, the data members on the public class should be in a private class.

I've also left some comments inline.

review: Needs Fixing
lp:~uriboni/oxide/find-in-page updated
1072. By Ugo Riboni

Refactor all the logic into an OxideQFindController class owned by oxide::qt::WebView. The QML API merely exposes it through the renamed findController property. Address other minor issues from code review.

1073. By Ugo Riboni

Merge changes from trunk

1074. By Ugo Riboni

Move all non-QT code to oxide::WebView

Revision history for this message
Ugo Riboni (uriboni) wrote :

I think all your comments should be addressed at this point, except some to which I replied inline.

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

Thanks. There's a few stylistic nits (eg, 4-space indents in some places) and some other things (eg, the constructor for OxideQFindController shouldn't be exported). The API looks like it's fine now.

I'm going to approve this though, as I'm currently working on re-architecting oxide::WebView which is probably going to be quite disruptive to this branch - I've already created some merge conflicts with http://bazaar.launchpad.net/~oxide-developers/oxide/oxide.trunk/revision/1087, which I'll fix up

review: Approve
Revision history for this message
Ugo Riboni (uriboni) wrote :

> Thanks. There's a few stylistic nits (eg, 4-space indents in some places) and
> some other things (eg, the constructor for OxideQFindController shouldn't be
> exported). The API looks like it's fine now.
>
> I'm going to approve this though, as I'm currently working on re-architecting
> oxide::WebView which is probably going to be quite disruptive to this branch -
> I've already created some merge conflicts with http://bazaar.launchpad.net
> /~oxide-developers/oxide/oxide.trunk/revision/1087, which I'll fix up

Thanks Chris.
Just to be clear, is there any further action needed from me on this branch ?

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

There isn't - I'm going to clean up the merge conflicts I've created and then merge it in for you.

Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'qt/core/api/oxideqfindcontroller.cc'
--- qt/core/api/oxideqfindcontroller.cc 1970-01-01 00:00:00 +0000
+++ qt/core/api/oxideqfindcontroller.cc 2015-05-20 22:10:39 +0000
@@ -0,0 +1,97 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2015 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#include "oxideqfindcontroller.h"
19#include "oxideqfindcontroller_p.h"
20
21#include "content/browser/web_contents/web_contents_impl.h"
22#include "qt/core/browser/oxide_qt_web_view.h"
23#include "shared/browser/oxide_web_view.h"
24
25OxideQFindControllerPrivate::OxideQFindControllerPrivate(oxide::WebView* webview) :
26 case_sensitive_(false),
27 count_(0),
28 current_(0),
29 request_id_(0),
30 webview_(webview) {}
31
32OxideQFindControllerPrivate::~OxideQFindControllerPrivate() {}
33
34OxideQFindController::OxideQFindController(oxide::WebView* webview) :
35 QObject(nullptr),
36 d_ptr(new OxideQFindControllerPrivate(webview)) {
37}
38
39OxideQFindController::~OxideQFindController() {}
40
41QString OxideQFindController::text() const {
42 Q_D(const OxideQFindController);
43
44 return QString::fromStdString(d->webview_->GetFindInPageText());
45}
46
47void OxideQFindController::setText(const QString& newText) {
48 Q_D(OxideQFindController);
49
50 if (newText == text()) {
51 return;
52 }
53
54 d->webview_->SetFindInPageText(newText.toStdString());
55 emit textChanged();
56}
57
58bool OxideQFindController::caseSensitive() const {
59 Q_D(const OxideQFindController);
60
61 return d->webview_->GetFindInPageCaseSensitive();
62}
63
64void OxideQFindController::setCaseSensitive(bool newCaseSensitive) {
65 Q_D(OxideQFindController);
66
67 if (newCaseSensitive == caseSensitive()) {
68 return;
69 }
70
71 d->webview_->SetFindInPageCaseSensitive(newCaseSensitive);
72 emit caseSensitiveChanged();
73}
74
75int OxideQFindController::count() const {
76 Q_D(const OxideQFindController);
77
78 return d->webview_->GetFindInPageCount();
79}
80
81int OxideQFindController::current() const {
82 Q_D(const OxideQFindController);
83
84 return d->webview_->GetFindInPageCurrent();
85}
86
87void OxideQFindController::next() {
88 Q_D(OxideQFindController);
89
90 d->webview_->FindInPageNext();
91}
92
93void OxideQFindController::previous() {
94 Q_D(OxideQFindController);
95
96 d->webview_->FindInPagePrevious();
97}
098
=== added file 'qt/core/api/oxideqfindcontroller.h'
--- qt/core/api/oxideqfindcontroller.h 1970-01-01 00:00:00 +0000
+++ qt/core/api/oxideqfindcontroller.h 2015-05-20 22:10:39 +0000
@@ -0,0 +1,71 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2015 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#ifndef OXIDE_Q_FIND_CONTROLLER
19#define OXIDE_Q_FIND_CONTROLLER
20
21#include <QObject>
22#include <QScopedPointer>
23#include <QString>
24#include <QtGlobal>
25
26class OxideQFindControllerPrivate;
27
28namespace oxide {
29 class WebView;
30 namespace qt {
31 class WebView;
32 }
33}
34
35class Q_DECL_EXPORT OxideQFindController : public QObject {
36 Q_OBJECT
37 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
38 Q_PROPERTY(bool caseSensitive READ caseSensitive WRITE setCaseSensitive NOTIFY caseSensitiveChanged)
39 Q_PROPERTY(int count READ count NOTIFY countChanged)
40 Q_PROPERTY(int current READ current NOTIFY currentChanged)
41
42 Q_DECLARE_PRIVATE(OxideQFindController)
43 Q_DISABLE_COPY(OxideQFindController)
44
45 public:
46 OxideQFindController(oxide::WebView* webview);
47 ~OxideQFindController();
48
49 QString text() const;
50 void setText(const QString& text);
51 bool caseSensitive() const;
52 void setCaseSensitive(bool caseSensitive);
53 int count() const;
54 int current() const;
55
56 Q_INVOKABLE void next();
57 Q_INVOKABLE void previous();
58
59 Q_SIGNALS:
60 void textChanged() const;
61 void caseSensitiveChanged() const;
62 void countChanged() const;
63 void currentChanged() const;
64
65 private:
66 QScopedPointer<OxideQFindControllerPrivate> d_ptr;
67
68 friend class oxide::qt::WebView;
69};
70
71#endif // OXIDE_Q_FIND_CONTROLLER
072
=== added file 'qt/core/api/oxideqfindcontroller_p.h'
--- qt/core/api/oxideqfindcontroller_p.h 1970-01-01 00:00:00 +0000
+++ qt/core/api/oxideqfindcontroller_p.h 2015-05-20 22:10:39 +0000
@@ -0,0 +1,46 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2015 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#ifndef _OXIDE_QT_CORE_API_FIND_CONTROLLER_P_H_
19#define _OXIDE_QT_CORE_API_FIND_CONTROLLER_P_H_
20
21#include <QtGlobal>
22#include <QString>
23
24namespace oxide {
25 class WebView;
26}
27
28class OxideQFindControllerPrivate {
29 public:
30 virtual ~OxideQFindControllerPrivate();
31
32 private:
33 OxideQFindControllerPrivate(oxide::WebView* webview);
34
35 QString text_;
36 bool case_sensitive_;
37 int count_;
38 int current_;
39 int request_id_;
40 oxide::WebView* webview_;
41
42 friend class OxideQFindController;
43};
44
45#endif // _OXIDE_QT_CORE_API_FIND_CONTROLLER_P_H_
46
047
=== modified file 'qt/core/browser/oxide_qt_web_view.cc'
--- qt/core/browser/oxide_qt_web_view.cc 2015-05-11 21:23:12 +0000
+++ qt/core/browser/oxide_qt_web_view.cc 2015-05-20 22:10:39 +0000
@@ -67,6 +67,8 @@
67#include "qt/core/api/oxideqcertificateerror_p.h"67#include "qt/core/api/oxideqcertificateerror_p.h"
68#include "qt/core/api/oxideqsecuritystatus.h"68#include "qt/core/api/oxideqsecuritystatus.h"
69#include "qt/core/api/oxideqsecuritystatus_p.h"69#include "qt/core/api/oxideqsecuritystatus_p.h"
70#include "qt/core/api/oxideqfindcontroller.h"
71#include "qt/core/api/oxideqfindcontroller_p.h"
70#include "qt/core/api/oxideqwebpreferences.h"72#include "qt/core/api/oxideqwebpreferences.h"
71#include "qt/core/api/oxideqwebpreferences_p.h"73#include "qt/core/api/oxideqwebpreferences_p.h"
72#include "qt/core/common/oxide_qt_screen_utils.h"74#include "qt/core/common/oxide_qt_screen_utils.h"
@@ -1280,6 +1282,18 @@
1280 Reload();1282 Reload();
1281}1283}
12821284
1285OxideQFindController* WebView::findInPage() {
1286 return find_in_page_controller_.get();
1287}
1288
1289void WebView::OnFindInPageCountChanged() {
1290 Q_EMIT find_in_page_controller_->countChanged();
1291}
1292
1293void WebView::OnFindInPageCurrentChanged() {
1294 Q_EMIT find_in_page_controller_->currentChanged();
1295}
1296
1283void WebView::loadHtml(const QString& html, const QUrl& base_url) {1297void WebView::loadHtml(const QString& html, const QUrl& base_url) {
1284 QByteArray encoded_data = html.toUtf8().toPercentEncoding();1298 QByteArray encoded_data = html.toUtf8().toPercentEncoding();
1285 LoadData(std::string(encoded_data.constData(), encoded_data.length()),1299 LoadData(std::string(encoded_data.constData(), encoded_data.length()),
@@ -1511,7 +1525,8 @@
1511 client_(client),1525 client_(client),
1512 has_input_method_state_(false),1526 has_input_method_state_(false),
1513 qsecurity_status_(1527 qsecurity_status_(
1514 OxideQSecurityStatusPrivate::Create(this)) {1528 OxideQSecurityStatusPrivate::Create(this)),
1529 find_in_page_controller_(new OxideQFindController(this)) {
1515 QInputMethod* im = QGuiApplication::inputMethod();1530 QInputMethod* im = QGuiApplication::inputMethod();
1516 if (im) {1531 if (im) {
1517 connect(im, SIGNAL(visibleChanged()),1532 connect(im, SIGNAL(visibleChanged()),
15181533
=== modified file 'qt/core/browser/oxide_qt_web_view.h'
--- qt/core/browser/oxide_qt_web_view.h 2015-05-11 21:23:12 +0000
+++ qt/core/browser/oxide_qt_web_view.h 2015-05-20 22:10:39 +0000
@@ -41,6 +41,7 @@
41class QWheelEvent;41class QWheelEvent;
42QT_END_NAMESPACE42QT_END_NAMESPACE
4343
44class OxideQFindController;
44class OxideQSecurityStatus;45class OxideQSecurityStatus;
4546
46namespace oxide {47namespace oxide {
@@ -156,6 +157,9 @@
156 const std::string& cookies,157 const std::string& cookies,
157 const std::string& referrer) override;158 const std::string& referrer) override;
158159
160 void OnFindInPageCountChanged() override;
161 void OnFindInPageCurrentChanged() override;
162
159 bool ShouldHandleNavigation(const GURL& url,163 bool ShouldHandleNavigation(const GURL& url,
160 WindowOpenDisposition disposition,164 WindowOpenDisposition disposition,
161 bool user_gesture) override;165 bool user_gesture) override;
@@ -231,6 +235,8 @@
231 void stop() override;235 void stop() override;
232 void reload() override;236 void reload() override;
233237
238 OxideQFindController* findInPage() override;
239
234 void loadHtml(const QString& html, const QUrl& base_url) override;240 void loadHtml(const QString& html, const QUrl& base_url) override;
235241
236 QList<ScriptMessageHandlerProxyHandle*>& messageHandlers() override;242 QList<ScriptMessageHandlerProxyHandle*>& messageHandlers() override;
@@ -291,6 +297,7 @@
291 UITouchEventFactory touch_event_factory_;297 UITouchEventFactory touch_event_factory_;
292298
293 QSharedPointer<CompositorFrameHandle> compositor_frame_;299 QSharedPointer<CompositorFrameHandle> compositor_frame_;
300 scoped_ptr<OxideQFindController> find_in_page_controller_;
294301
295 DISALLOW_IMPLICIT_CONSTRUCTORS(WebView);302 DISALLOW_IMPLICIT_CONSTRUCTORS(WebView);
296};303};
297304
=== modified file 'qt/core/core.gyp'
--- qt/core/core.gyp 2015-05-06 21:13:13 +0000
+++ qt/core/core.gyp 2015-05-20 22:10:39 +0000
@@ -201,6 +201,7 @@
201 '<(INTERMEDIATE_DIR)/moc_oxideqnavigationrequest.cc',201 '<(INTERMEDIATE_DIR)/moc_oxideqnavigationrequest.cc',
202 '<(INTERMEDIATE_DIR)/moc_oxideqnewviewrequest.cc',202 '<(INTERMEDIATE_DIR)/moc_oxideqnewviewrequest.cc',
203 '<(INTERMEDIATE_DIR)/moc_oxideqpermissionrequest.cc',203 '<(INTERMEDIATE_DIR)/moc_oxideqpermissionrequest.cc',
204 '<(INTERMEDIATE_DIR)/moc_oxideqfindcontroller.cc',
204 '<(INTERMEDIATE_DIR)/moc_oxideqsecuritystatus.cc',205 '<(INTERMEDIATE_DIR)/moc_oxideqsecuritystatus.cc',
205 '<(INTERMEDIATE_DIR)/moc_oxideqsslcertificate.cc',206 '<(INTERMEDIATE_DIR)/moc_oxideqsslcertificate.cc',
206 '<(INTERMEDIATE_DIR)/moc_oxideqstoragepermissionrequest.cc',207 '<(INTERMEDIATE_DIR)/moc_oxideqstoragepermissionrequest.cc',
@@ -229,6 +230,9 @@
229 'api/oxideqpermissionrequest.cc',230 'api/oxideqpermissionrequest.cc',
230 'api/oxideqpermissionrequest.h',231 'api/oxideqpermissionrequest.h',
231 'api/oxideqpermissionrequest_p.h',232 'api/oxideqpermissionrequest_p.h',
233 'api/oxideqfindcontroller.cc',
234 'api/oxideqfindcontroller.h',
235 'api/oxideqfindcontroller_p.h',
232 'api/oxideqsecuritystatus.cc',236 'api/oxideqsecuritystatus.cc',
233 'api/oxideqsecuritystatus.h',237 'api/oxideqsecuritystatus.h',
234 'api/oxideqsecuritystatus_p.h',238 'api/oxideqsecuritystatus_p.h',
@@ -279,6 +283,11 @@
279 'includes': [ 'moc.gypi' ],283 'includes': [ 'moc.gypi' ],
280 },284 },
281 {285 {
286 'action_name': 'moc_oxideqfindcontroller.cc',
287 'moc_input': 'api/oxideqfindcontroller.h',
288 'includes': [ 'moc.gypi' ],
289 },
290 {
282 'action_name': 'moc_oxideqsecuritystatus.cc',291 'action_name': 'moc_oxideqsecuritystatus.cc',
283 'moc_input': 'api/oxideqsecuritystatus.h',292 'moc_input': 'api/oxideqsecuritystatus.h',
284 'includes': [ 'moc.gypi' ],293 'includes': [ 'moc.gypi' ],
285294
=== modified file 'qt/core/glue/oxide_qt_web_view_proxy.h'
--- qt/core/glue/oxide_qt_web_view_proxy.h 2015-05-06 15:05:53 +0000
+++ qt/core/glue/oxide_qt_web_view_proxy.h 2015-05-20 22:10:39 +0000
@@ -45,6 +45,7 @@
45class QWheelEvent;45class QWheelEvent;
46QT_END_NAMESPACE46QT_END_NAMESPACE
4747
48class OxideQFindController;
48class OxideQNewViewRequest;49class OxideQNewViewRequest;
49class OxideQSecurityStatus;50class OxideQSecurityStatus;
50class OxideQWebPreferences;51class OxideQWebPreferences;
@@ -101,6 +102,14 @@
101 virtual EGLImageKHR GetImageFrame() = 0;102 virtual EGLImageKHR GetImageFrame() = 0;
102};103};
103104
105struct FindInPageState {
106 int request_id;
107 QString text;
108 bool case_sensitive;
109 int current;
110 int count;
111};
112
104OXIDE_Q_DECL_PROXY_HANDLE(ScriptMessageHandlerProxy);113OXIDE_Q_DECL_PROXY_HANDLE(ScriptMessageHandlerProxy);
105OXIDE_Q_DECL_PROXY_HANDLE(WebContextProxy);114OXIDE_Q_DECL_PROXY_HANDLE(WebContextProxy);
106OXIDE_Q_DECL_PROXY_HANDLE(WebFrameProxy);115OXIDE_Q_DECL_PROXY_HANDLE(WebFrameProxy);
@@ -155,6 +164,8 @@
155 virtual void stop() = 0;164 virtual void stop() = 0;
156 virtual void reload() = 0;165 virtual void reload() = 0;
157166
167 virtual OxideQFindController* findInPage() = 0;
168
158 virtual void loadHtml(const QString& html, const QUrl& base_url) = 0;169 virtual void loadHtml(const QString& html, const QUrl& base_url) = 0;
159170
160 virtual QList<ScriptMessageHandlerProxyHandle*>& messageHandlers() = 0;171 virtual QList<ScriptMessageHandlerProxyHandle*>& messageHandlers() = 0;
161172
=== modified file 'qt/qmlplugin/oxide_qml_plugin.cc'
--- qt/qmlplugin/oxide_qml_plugin.cc 2015-05-11 21:23:12 +0000
+++ qt/qmlplugin/oxide_qml_plugin.cc 2015-05-20 22:10:39 +0000
@@ -24,6 +24,7 @@
2424
25#include "qt/core/api/oxideqcertificateerror.h"25#include "qt/core/api/oxideqcertificateerror.h"
26#include "qt/core/api/oxideqdownloadrequest.h"26#include "qt/core/api/oxideqdownloadrequest.h"
27#include "qt/core/api/oxideqfindcontroller.h"
27#include "qt/core/api/oxideqloadevent.h"28#include "qt/core/api/oxideqloadevent.h"
28#include "qt/core/api/oxideqnavigationrequest.h"29#include "qt/core/api/oxideqnavigationrequest.h"
29#include "qt/core/api/oxideqnewviewrequest.h"30#include "qt/core/api/oxideqnewviewrequest.h"
@@ -128,8 +129,12 @@
128 qmlRegisterUncreatableType<OxideQQuickLocationBarController, 1>(uri, 1, 7, "LocationBarController",129 qmlRegisterUncreatableType<OxideQQuickLocationBarController, 1>(uri, 1, 7, "LocationBarController",
129 "LocationBarController is accessed via WebView.locationBarController");130 "LocationBarController is accessed via WebView.locationBarController");
130131
132 qmlRegisterUncreatableType<OxideQFindController>(uri, 1, 8, "FindController",
133 "FindInPage is accessed via WebView.findController");
134
131 qmlRegisterUncreatableType<OxideQLoadEvent, 2>(uri, 1, 8, "LoadEvent",135 qmlRegisterUncreatableType<OxideQLoadEvent, 2>(uri, 1, 8, "LoadEvent",
132 "LoadEvent is delivered by WebView.loadEvent");136 "LoadEvent is delivered by WebView.loadEvent");
137
133 qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView");138 qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView");
134 }139 }
135};140};
136141
=== modified file 'qt/quick/api/oxideqquickwebview.cc'
--- qt/quick/api/oxideqquickwebview.cc 2015-05-11 15:32:11 +0000
+++ qt/quick/api/oxideqquickwebview.cc 2015-05-20 22:10:39 +0000
@@ -41,6 +41,7 @@
41#include <Qt>41#include <Qt>
4242
43#include "qt/core/api/oxideqcertificateerror.h"43#include "qt/core/api/oxideqcertificateerror.h"
44#include "qt/core/api/oxideqfindcontroller.h"
44#include "qt/core/api/oxideqglobal.h"45#include "qt/core/api/oxideqglobal.h"
45#include "qt/core/api/oxideqloadevent.h"46#include "qt/core/api/oxideqloadevent.h"
46#include "qt/core/api/oxideqnewviewrequest.h"47#include "qt/core/api/oxideqnewviewrequest.h"
@@ -1744,4 +1745,10 @@
1744 d->proxy()->prepareToClose();1745 d->proxy()->prepareToClose();
1745}1746}
17461747
1748OxideQFindController* OxideQQuickWebView::findController() const {
1749 Q_D(const OxideQQuickWebView);
1750
1751 return d->proxy()->findInPage();
1752}
1753
1747#include "moc_oxideqquickwebview_p.cpp"1754#include "moc_oxideqquickwebview_p.cpp"
17481755
=== modified file 'qt/quick/api/oxideqquickwebview_p.h'
--- qt/quick/api/oxideqquickwebview_p.h 2015-05-11 15:32:11 +0000
+++ qt/quick/api/oxideqquickwebview_p.h 2015-05-20 22:10:39 +0000
@@ -32,6 +32,7 @@
3232
33QT_USE_NAMESPACE33QT_USE_NAMESPACE
3434
35class OxideQFindController;
35class OxideQLoadEvent;36class OxideQLoadEvent;
36class OxideQNavigationRequest;37class OxideQNavigationRequest;
37class OxideQNewViewRequest;38class OxideQNewViewRequest;
@@ -45,6 +46,11 @@
45class OxideQQuickWebViewPrivate;46class OxideQQuickWebViewPrivate;
46class OxideQDownloadRequest;47class OxideQDownloadRequest;
47class OxideQSecurityStatus;48class OxideQSecurityStatus;
49namespace oxide {
50 namespace qt {
51 class WebViewProxy;
52 }
53}
4854
49class OxideQQuickWebViewAttached : public QObject {55class OxideQQuickWebViewAttached : public QObject {
50 Q_OBJECT56 Q_OBJECT
@@ -107,6 +113,8 @@
107113
108 Q_PROPERTY(OxideQNewViewRequest* request READ request WRITE setRequest)114 Q_PROPERTY(OxideQNewViewRequest* request READ request WRITE setRequest)
109115
116 Q_PROPERTY(OxideQFindController* findController READ findController CONSTANT REVISION 4)
117
110 // Set at construction time only118 // Set at construction time only
111 Q_PROPERTY(QString restoreState READ restoreState WRITE setRestoreState REVISION 2)119 Q_PROPERTY(QString restoreState READ restoreState WRITE setRestoreState REVISION 2)
112 Q_PROPERTY(RestoreType restoreType READ restoreType WRITE setRestoreType REVISION 2)120 Q_PROPERTY(RestoreType restoreType READ restoreType WRITE setRestoreType REVISION 2)
@@ -234,6 +242,8 @@
234242
235 static OxideQQuickWebViewAttached* qmlAttachedProperties(QObject* object);243 static OxideQQuickWebViewAttached* qmlAttachedProperties(QObject* object);
236244
245 OxideQFindController* findController() const;
246
237 public Q_SLOTS:247 public Q_SLOTS:
238 void goBack();248 void goBack();
239 void goForward();249 void goForward();
240250
=== added file 'qt/tests/qmltests/api/tst_WebView_findController.html'
--- qt/tests/qmltests/api/tst_WebView_findController.html 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_findController.html 2015-05-20 22:10:39 +0000
@@ -0,0 +1,13 @@
1<html>
2 <head>
3 <meta charset="UTF-8">
4 </head>
5 <body>
6 Lorem ipsum dolor sit Amet, consectetur adipiscing elit.
7 Nam eu venenatis velit.
8 Suspendisse vitae libero rutrum Amet, congue velit quis, fringilla eros.
9 Nulla at semper purus, id scelerisque est.
10 Fusce rhoncus placerat erat ñec ultricies amet.
11 Curabitur mauris. Dolor, facilisis eu tellus vitae, semper iaculis tortor.
12 </body>
13</html>
014
=== added file 'qt/tests/qmltests/api/tst_WebView_findController.qml'
--- qt/tests/qmltests/api/tst_WebView_findController.qml 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_findController.qml 2015-05-20 22:10:39 +0000
@@ -0,0 +1,152 @@
1import QtQuick 2.0
2import QtTest 1.0
3import com.canonical.Oxide 1.8
4import com.canonical.Oxide.Testing 1.0
5
6TestWebView {
7 id: webView
8 focus: true
9 width: 200
10 height: 200
11
12 TestCase {
13 name: "findController"
14 when: windowShown
15
16 function init() {
17 webView.findController.text = "";
18 webView.findController.caseSensitive = false;
19
20 // load the page that will be used by most tests
21 webView.url = "http://testsuite/tst_WebView_findController.html";
22 verify(webView.waitForLoadSucceeded(),
23 "Timed out waiting for successful load");
24 }
25
26 function test_case_insensitive() {
27 webView.findController.text = "suspendisse";
28 tryCompare(webView.findController, "count", 1);
29
30 webView.findController.text = "aMet";
31 tryCompare(webView.findController, "count", 3);
32 }
33
34 function test_case_sensitive() {
35 webView.findController.caseSensitive = true;
36
37 webView.findController.text = "Suspendisse";
38 tryCompare(webView.findController, "count", 1);
39
40 webView.findController.text = "suspendisse";
41 tryCompare(webView.findController, "count", 0);
42 }
43
44 function test_change_case_sensitivity() {
45 webView.findController.caseSensitive = true;
46
47 webView.findController.text = "Dolor";
48 tryCompare(webView.findController, "count", 1);
49
50 webView.findController.caseSensitive = false;
51 tryCompare(webView.findController, "count", 2);
52 }
53
54 function test_movement() {
55 webView.findController.text = "dolor";
56 tryCompare(webView.findController, "count", 2);
57 tryCompare(webView.findController, "current", 1);
58
59 webView.findController.next();
60 tryCompare(webView.findController, "count", 2);
61 tryCompare(webView.findController, "current", 2);
62
63 webView.findController.previous();
64 tryCompare(webView.findController, "count", 2);
65 tryCompare(webView.findController, "current", 1);
66 }
67
68 function test_movement_wraps() {
69 webView.findController.text = "dolor";
70 tryCompare(webView.findController, "count", 2);
71 tryCompare(webView.findController, "current", 1);
72
73 webView.findController.next();
74 webView.findController.next();
75 tryCompare(webView.findController, "current", 1);
76
77 webView.findController.previous();
78 webView.findController.previous();
79 tryCompare(webView.findController, "current", 1);
80 }
81
82 function test_clear() {
83 webView.findController.text = "dolor";
84 tryCompare(webView.findController, "count", 2);
85
86 webView.findController.text = "";
87 tryCompare(webView.findController, "count", 0);
88 tryCompare(webView.findController, "current", 0);
89 }
90
91 function test_new_text_resets_count() {
92 webView.findController.text = "dolor";
93 tryCompare(webView.findController, "count", 2);
94 webView.findController.next();
95 tryCompare(webView.findController, "current", 2);
96
97 webView.findController.text = "suspendisse";
98 tryCompare(webView.findController, "count", 1);
99 tryCompare(webView.findController, "current", 1);
100 }
101
102 function test_not_found_resets_count() {
103 webView.findController.text = "dolor";
104 tryCompare(webView.findController, "count", 2);
105
106 webView.findController.text = "i_am_not_there";
107 tryCompare(webView.findController, "count", 0);
108 tryCompare(webView.findController, "current", 0);
109 }
110
111 function test_find_non_latin() {
112 webView.findController.text = "ñec";
113 tryCompare(webView.findController, "count", 1);
114 }
115
116 function test_find_on_invalid_page() {
117 webView.url = "http://testsuite/tst_invalid_page.html";
118 // verify successful load because the server returns a 404 page apparently
119 // and that does not count as a failure
120 verify(webView.waitForLoadSucceeded(),
121 "Timed out waiting for successful load");
122
123 webView.findController.text = "hello";
124 tryCompare(webView.findController, "count", 0);
125 tryCompare(webView.findController, "current", 0);
126 }
127
128 function test_navigation_does_not_reset() {
129 webView.findController.text = "dolor";
130 tryCompare(webView.findController, "count", 2);
131 webView.findController.next();
132 tryCompare(webView.findController, "current", 2);
133
134 // Verify that when navigating to another page the search does not
135 // reset, it is the user responsibility to cancel it and restart it
136 webView.url = "http://testsuite/tst_WebView_findControllerManyResults.html";
137 verify(webView.waitForLoadSucceeded(),
138 "Timed out waiting for successful load");
139 compare(webView.findController.text, "dolor");
140 tryCompare(webView.findController, "count", 2);
141 tryCompare(webView.findController, "current", 2);
142
143 webView.findController.text = "";
144 tryCompare(webView.findController, "count", 0);
145 tryCompare(webView.findController, "current", 0);
146
147 webView.findController.text = "dolor";
148 tryCompare(webView.findController, "count", 20);
149 tryCompare(webView.findController, "current", 1);
150 }
151 }
152}
0153
=== added file 'qt/tests/qmltests/api/tst_WebView_findControllerManyResults.html'
--- qt/tests/qmltests/api/tst_WebView_findControllerManyResults.html 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_findControllerManyResults.html 2015-05-20 22:10:39 +0000
@@ -0,0 +1,9 @@
1<html>
2 <head>
3 <meta charset="UTF-8">
4 </head>
5 <body>
6 Lorem ipsum dolor dolor dolor dolor dolor dolor dolor dolor dolor dolor
7 dolor dolor dolor dolor dolor dolor dolor dolor dolor dolor sit amet.
8 </body>
9</html>
010
=== modified file 'shared/browser/oxide_web_view.cc'
--- shared/browser/oxide_web_view.cc 2015-05-15 14:49:32 +0000
+++ shared/browser/oxide_web_view.cc 2015-05-20 22:10:39 +0000
@@ -76,6 +76,8 @@
76#include "shared/common/oxide_event_utils.h"76#include "shared/common/oxide_event_utils.h"
77#include "shared/common/oxide_messages.h"77#include "shared/common/oxide_messages.h"
7878
79#include "third_party/WebKit/public/web/WebFindOptions.h"
80
79#include "oxide_browser_context.h"81#include "oxide_browser_context.h"
80#include "oxide_browser_process_main.h"82#include "oxide_browser_process_main.h"
81#include "oxide_content_browser_client.h"83#include "oxide_content_browser_client.h"
@@ -753,6 +755,25 @@
753 return IsFullscreen();755 return IsFullscreen();
754}756}
755757
758void WebView::FindReply(content::WebContents* web_contents,
759 int request_id,
760 int number_of_matches,
761 const gfx::Rect& selection_rect,
762 int active_match_ordinal,
763 bool final_update) {
764 if (active_match_ordinal != -1 &&
765 find_in_page_.current != active_match_ordinal) {
766 find_in_page_.current = active_match_ordinal;
767 OnFindInPageCurrentChanged();
768 }
769
770 if (number_of_matches != -1 &&
771 find_in_page_.count != number_of_matches) {
772 find_in_page_.count = number_of_matches;
773 OnFindInPageCountChanged();
774 }
775}
776
756void WebView::RequestMediaAccessPermission(777void WebView::RequestMediaAccessPermission(
757 content::WebContents* source,778 content::WebContents* source,
758 const content::MediaStreamRequest& request,779 const content::MediaStreamRequest& request,
@@ -1222,6 +1243,9 @@
1222void WebView::OnPrepareToCloseResponse(bool proceed) {}1243void WebView::OnPrepareToCloseResponse(bool proceed) {}
1223void WebView::OnCloseRequested() {}1244void WebView::OnCloseRequested() {}
12241245
1246void WebView::OnFindInPageCountChanged() {}
1247void WebView::OnFindInPageCurrentChanged() {}
1248
1225WebView::WebView()1249WebView::WebView()
1226 : text_input_type_(ui::TEXT_INPUT_TYPE_NONE),1250 : text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
1227 show_ime_if_needed_(false),1251 show_ime_if_needed_(false),
@@ -1636,6 +1660,84 @@
1636 rvh->OnWebkitPreferencesChanged();1660 rvh->OnWebkitPreferencesChanged();
1637}1661}
16381662
1663int WebView::GetFindInPageCount() const {
1664 return find_in_page_.count;
1665}
1666
1667int WebView::GetFindInPageCurrent() const {
1668 return find_in_page_.current;
1669}
1670
1671std::string WebView::GetFindInPageText() const {
1672 return find_in_page_.text;
1673}
1674
1675bool WebView::GetFindInPageCaseSensitive() const {
1676 return find_in_page_.case_sensitive;
1677}
1678
1679void WebView::SetFindInPageText(const std::string& text) {
1680 find_in_page_.text = text;
1681 RestartFindInPage();
1682}
1683
1684void WebView::SetFindInPageCaseSensitive(bool case_sensitive) {
1685 find_in_page_.case_sensitive = case_sensitive;
1686 RestartFindInPage();
1687}
1688
1689void WebView::RestartFindInPage() {
1690 if (!web_contents_) {
1691 return;
1692 }
1693
1694 web_contents_->StopFinding(content::STOP_FIND_ACTION_CLEAR_SELECTION);
1695
1696 find_in_page_.current = 0;
1697 OnFindInPageCurrentChanged();
1698 find_in_page_.count = 0;
1699 OnFindInPageCountChanged();
1700
1701 if (!find_in_page_.text.empty()) {
1702 find_in_page_.request_id++;
1703
1704 blink::WebFindOptions options;
1705 options.forward = true;
1706 options.findNext = false;
1707 options.matchCase = find_in_page_.case_sensitive;
1708
1709 web_contents_->Find(find_in_page_.request_id,
1710 base::UTF8ToUTF16(find_in_page_.text),
1711 options);
1712 }
1713}
1714
1715void WebView::FindInPageNext() {
1716 if (!web_contents_) {
1717 return;
1718 }
1719
1720 blink::WebFindOptions options;
1721 options.forward = true;
1722 options.findNext = true;
1723
1724 web_contents_->Find(find_in_page_.request_id,
1725 base::UTF8ToUTF16(find_in_page_.text), options);
1726}
1727
1728void WebView::FindInPagePrevious() {
1729 if (!web_contents_) {
1730 return;
1731 }
1732
1733 blink::WebFindOptions options;
1734 options.forward = false;
1735 options.findNext = true;
1736
1737 web_contents_->Find(find_in_page_.request_id,
1738 base::UTF8ToUTF16(find_in_page_.text), options);
1739}
1740
1639BrowserContext* WebView::GetBrowserContext() const {1741BrowserContext* WebView::GetBrowserContext() const {
1640 return BrowserContext::FromContent(web_contents_->GetBrowserContext());1742 return BrowserContext::FromContent(web_contents_->GetBrowserContext());
1641}1743}
16421744
=== modified file 'shared/browser/oxide_web_view.h'
--- shared/browser/oxide_web_view.h 2015-05-15 14:49:32 +0000
+++ shared/browser/oxide_web_view.h 2015-05-20 22:10:39 +0000
@@ -201,6 +201,15 @@
201 void InputPanelVisibilityChanged();201 void InputPanelVisibilityChanged();
202 void UpdateWebPreferences();202 void UpdateWebPreferences();
203203
204 int GetFindInPageCount() const;
205 int GetFindInPageCurrent() const;
206 std::string GetFindInPageText() const;
207 void SetFindInPageText(const std::string& text);
208 bool GetFindInPageCaseSensitive() const;
209 void SetFindInPageCaseSensitive(bool case_sensitive);
210 void FindInPageNext();
211 void FindInPagePrevious();
212
204 BrowserContext* GetBrowserContext() const;213 BrowserContext* GetBrowserContext() const;
205 content::WebContents* GetWebContents() const;214 content::WebContents* GetWebContents() const;
206215
@@ -355,6 +364,8 @@
355 void InitializeTopControlsForHost(content::RenderViewHost* rvh,364 void InitializeTopControlsForHost(content::RenderViewHost* rvh,
356 bool initial_host);365 bool initial_host);
357366
367 void RestartFindInPage();
368
358 // ScriptMessageTarget implementation369 // ScriptMessageTarget implementation
359 virtual size_t GetScriptMessageHandlerCount() const override;370 virtual size_t GetScriptMessageHandlerCount() const override;
360 virtual const ScriptMessageHandler* GetScriptMessageHandlerAt(371 virtual const ScriptMessageHandler* GetScriptMessageHandlerAt(
@@ -440,6 +451,13 @@
440 const content::MediaStreamRequest& request,451 const content::MediaStreamRequest& request,
441 const content::MediaResponseCallback& callback) final;452 const content::MediaResponseCallback& callback) final;
442453
454 void FindReply(content::WebContents* web_contents,
455 int request_id,
456 int number_of_matches,
457 const gfx::Rect& selection_rect,
458 int active_match_ordinal,
459 bool final_update) final;
460
443 // content::WebContentsObserver implementation461 // content::WebContentsObserver implementation
444 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) final;462 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) final;
445 void RenderViewReady() final;463 void RenderViewReady() final;
@@ -577,6 +595,9 @@
577 virtual void OnPrepareToCloseResponse(bool proceed);595 virtual void OnPrepareToCloseResponse(bool proceed);
578 virtual void OnCloseRequested();596 virtual void OnCloseRequested();
579597
598 virtual void OnFindInPageCurrentChanged();
599 virtual void OnFindInPageCountChanged();
600
580 struct WebContentsDeleter {601 struct WebContentsDeleter {
581 void operator()(content::WebContents* contents);602 void operator()(content::WebContents* contents);
582 };603 };
@@ -623,6 +644,17 @@
623644
624 SecurityStatus security_status_;645 SecurityStatus security_status_;
625646
647 struct FindInPageState {
648 int request_id;
649 int current;
650 int count;
651 bool case_sensitive;
652 std::string text;
653 FindInPageState() : request_id(0), current(0), count(0),
654 case_sensitive(false) {}
655 };
656 FindInPageState find_in_page_;
657
626 int location_bar_height_pix_;658 int location_bar_height_pix_;
627 blink::WebTopControlsState location_bar_constraints_;659 blink::WebTopControlsState location_bar_constraints_;
628 bool location_bar_animated_;660 bool location_bar_animated_;

Subscribers

People subscribed via source and target branches

to all changes: