Merge lp:~uriboni/oxide/find-in-page into lp:~oxide-developers/oxide/oxide.trunk
- find-in-page
- Merge into oxide.trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Approve | ||
Review via email:
|
Commit message
Description of the change
Adds a new API to allow searching text within a page.
- 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
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Olivier Tilloy (osomon) wrote : | # |
- 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
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Chris Coulson (chrisccoulson) wrote : | # |
Thanks for working on this. I have some general comments:
- I think I'd prefer WebView.
- The implementation doesn't need to live in qt/quick/api - it should go in qt/core/api as OxideQFindContr
- 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.
- 1072. By Ugo Riboni
-
Refactor all the logic into an OxideQFindContr
oller 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
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ugo Riboni (uriboni) wrote : | # |
I think all your comments should be addressed at this point, except some to which I replied inline.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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 OxideQFindContr
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://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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 OxideQFindContr
> 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://
> /~oxide-
Thanks Chris.
Just to be clear, is there any further action needed from me on this branch ?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
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
1 | === added file 'qt/core/api/oxideqfindcontroller.cc' | |||
2 | --- qt/core/api/oxideqfindcontroller.cc 1970-01-01 00:00:00 +0000 | |||
3 | +++ qt/core/api/oxideqfindcontroller.cc 2015-05-20 22:10:39 +0000 | |||
4 | @@ -0,0 +1,97 @@ | |||
5 | 1 | // vim:expandtab:shiftwidth=2:tabstop=2: | ||
6 | 2 | // Copyright (C) 2015 Canonical Ltd. | ||
7 | 3 | |||
8 | 4 | // This library is free software; you can redistribute it and/or | ||
9 | 5 | // modify it under the terms of the GNU Lesser General Public | ||
10 | 6 | // License as published by the Free Software Foundation; either | ||
11 | 7 | // version 2.1 of the License, or (at your option) any later version. | ||
12 | 8 | |||
13 | 9 | // This library is distributed in the hope that it will be useful, | ||
14 | 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | 12 | // Lesser General Public License for more details. | ||
17 | 13 | |||
18 | 14 | // You should have received a copy of the GNU Lesser General Public | ||
19 | 15 | // License along with this library; if not, write to the Free Software | ||
20 | 16 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | 17 | |||
22 | 18 | #include "oxideqfindcontroller.h" | ||
23 | 19 | #include "oxideqfindcontroller_p.h" | ||
24 | 20 | |||
25 | 21 | #include "content/browser/web_contents/web_contents_impl.h" | ||
26 | 22 | #include "qt/core/browser/oxide_qt_web_view.h" | ||
27 | 23 | #include "shared/browser/oxide_web_view.h" | ||
28 | 24 | |||
29 | 25 | OxideQFindControllerPrivate::OxideQFindControllerPrivate(oxide::WebView* webview) : | ||
30 | 26 | case_sensitive_(false), | ||
31 | 27 | count_(0), | ||
32 | 28 | current_(0), | ||
33 | 29 | request_id_(0), | ||
34 | 30 | webview_(webview) {} | ||
35 | 31 | |||
36 | 32 | OxideQFindControllerPrivate::~OxideQFindControllerPrivate() {} | ||
37 | 33 | |||
38 | 34 | OxideQFindController::OxideQFindController(oxide::WebView* webview) : | ||
39 | 35 | QObject(nullptr), | ||
40 | 36 | d_ptr(new OxideQFindControllerPrivate(webview)) { | ||
41 | 37 | } | ||
42 | 38 | |||
43 | 39 | OxideQFindController::~OxideQFindController() {} | ||
44 | 40 | |||
45 | 41 | QString OxideQFindController::text() const { | ||
46 | 42 | Q_D(const OxideQFindController); | ||
47 | 43 | |||
48 | 44 | return QString::fromStdString(d->webview_->GetFindInPageText()); | ||
49 | 45 | } | ||
50 | 46 | |||
51 | 47 | void OxideQFindController::setText(const QString& newText) { | ||
52 | 48 | Q_D(OxideQFindController); | ||
53 | 49 | |||
54 | 50 | if (newText == text()) { | ||
55 | 51 | return; | ||
56 | 52 | } | ||
57 | 53 | |||
58 | 54 | d->webview_->SetFindInPageText(newText.toStdString()); | ||
59 | 55 | emit textChanged(); | ||
60 | 56 | } | ||
61 | 57 | |||
62 | 58 | bool OxideQFindController::caseSensitive() const { | ||
63 | 59 | Q_D(const OxideQFindController); | ||
64 | 60 | |||
65 | 61 | return d->webview_->GetFindInPageCaseSensitive(); | ||
66 | 62 | } | ||
67 | 63 | |||
68 | 64 | void OxideQFindController::setCaseSensitive(bool newCaseSensitive) { | ||
69 | 65 | Q_D(OxideQFindController); | ||
70 | 66 | |||
71 | 67 | if (newCaseSensitive == caseSensitive()) { | ||
72 | 68 | return; | ||
73 | 69 | } | ||
74 | 70 | |||
75 | 71 | d->webview_->SetFindInPageCaseSensitive(newCaseSensitive); | ||
76 | 72 | emit caseSensitiveChanged(); | ||
77 | 73 | } | ||
78 | 74 | |||
79 | 75 | int OxideQFindController::count() const { | ||
80 | 76 | Q_D(const OxideQFindController); | ||
81 | 77 | |||
82 | 78 | return d->webview_->GetFindInPageCount(); | ||
83 | 79 | } | ||
84 | 80 | |||
85 | 81 | int OxideQFindController::current() const { | ||
86 | 82 | Q_D(const OxideQFindController); | ||
87 | 83 | |||
88 | 84 | return d->webview_->GetFindInPageCurrent(); | ||
89 | 85 | } | ||
90 | 86 | |||
91 | 87 | void OxideQFindController::next() { | ||
92 | 88 | Q_D(OxideQFindController); | ||
93 | 89 | |||
94 | 90 | d->webview_->FindInPageNext(); | ||
95 | 91 | } | ||
96 | 92 | |||
97 | 93 | void OxideQFindController::previous() { | ||
98 | 94 | Q_D(OxideQFindController); | ||
99 | 95 | |||
100 | 96 | d->webview_->FindInPagePrevious(); | ||
101 | 97 | } | ||
102 | 0 | 98 | ||
103 | === added file 'qt/core/api/oxideqfindcontroller.h' | |||
104 | --- qt/core/api/oxideqfindcontroller.h 1970-01-01 00:00:00 +0000 | |||
105 | +++ qt/core/api/oxideqfindcontroller.h 2015-05-20 22:10:39 +0000 | |||
106 | @@ -0,0 +1,71 @@ | |||
107 | 1 | // vim:expandtab:shiftwidth=2:tabstop=2: | ||
108 | 2 | // Copyright (C) 2015 Canonical Ltd. | ||
109 | 3 | |||
110 | 4 | // This library is free software; you can redistribute it and/or | ||
111 | 5 | // modify it under the terms of the GNU Lesser General Public | ||
112 | 6 | // License as published by the Free Software Foundation; either | ||
113 | 7 | // version 2.1 of the License, or (at your option) any later version. | ||
114 | 8 | |||
115 | 9 | // This library is distributed in the hope that it will be useful, | ||
116 | 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
117 | 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
118 | 12 | // Lesser General Public License for more details. | ||
119 | 13 | |||
120 | 14 | // You should have received a copy of the GNU Lesser General Public | ||
121 | 15 | // License along with this library; if not, write to the Free Software | ||
122 | 16 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
123 | 17 | |||
124 | 18 | #ifndef OXIDE_Q_FIND_CONTROLLER | ||
125 | 19 | #define OXIDE_Q_FIND_CONTROLLER | ||
126 | 20 | |||
127 | 21 | #include <QObject> | ||
128 | 22 | #include <QScopedPointer> | ||
129 | 23 | #include <QString> | ||
130 | 24 | #include <QtGlobal> | ||
131 | 25 | |||
132 | 26 | class OxideQFindControllerPrivate; | ||
133 | 27 | |||
134 | 28 | namespace oxide { | ||
135 | 29 | class WebView; | ||
136 | 30 | namespace qt { | ||
137 | 31 | class WebView; | ||
138 | 32 | } | ||
139 | 33 | } | ||
140 | 34 | |||
141 | 35 | class Q_DECL_EXPORT OxideQFindController : public QObject { | ||
142 | 36 | Q_OBJECT | ||
143 | 37 | Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) | ||
144 | 38 | Q_PROPERTY(bool caseSensitive READ caseSensitive WRITE setCaseSensitive NOTIFY caseSensitiveChanged) | ||
145 | 39 | Q_PROPERTY(int count READ count NOTIFY countChanged) | ||
146 | 40 | Q_PROPERTY(int current READ current NOTIFY currentChanged) | ||
147 | 41 | |||
148 | 42 | Q_DECLARE_PRIVATE(OxideQFindController) | ||
149 | 43 | Q_DISABLE_COPY(OxideQFindController) | ||
150 | 44 | |||
151 | 45 | public: | ||
152 | 46 | OxideQFindController(oxide::WebView* webview); | ||
153 | 47 | ~OxideQFindController(); | ||
154 | 48 | |||
155 | 49 | QString text() const; | ||
156 | 50 | void setText(const QString& text); | ||
157 | 51 | bool caseSensitive() const; | ||
158 | 52 | void setCaseSensitive(bool caseSensitive); | ||
159 | 53 | int count() const; | ||
160 | 54 | int current() const; | ||
161 | 55 | |||
162 | 56 | Q_INVOKABLE void next(); | ||
163 | 57 | Q_INVOKABLE void previous(); | ||
164 | 58 | |||
165 | 59 | Q_SIGNALS: | ||
166 | 60 | void textChanged() const; | ||
167 | 61 | void caseSensitiveChanged() const; | ||
168 | 62 | void countChanged() const; | ||
169 | 63 | void currentChanged() const; | ||
170 | 64 | |||
171 | 65 | private: | ||
172 | 66 | QScopedPointer<OxideQFindControllerPrivate> d_ptr; | ||
173 | 67 | |||
174 | 68 | friend class oxide::qt::WebView; | ||
175 | 69 | }; | ||
176 | 70 | |||
177 | 71 | #endif // OXIDE_Q_FIND_CONTROLLER | ||
178 | 0 | 72 | ||
179 | === added file 'qt/core/api/oxideqfindcontroller_p.h' | |||
180 | --- qt/core/api/oxideqfindcontroller_p.h 1970-01-01 00:00:00 +0000 | |||
181 | +++ qt/core/api/oxideqfindcontroller_p.h 2015-05-20 22:10:39 +0000 | |||
182 | @@ -0,0 +1,46 @@ | |||
183 | 1 | // vim:expandtab:shiftwidth=2:tabstop=2: | ||
184 | 2 | // Copyright (C) 2015 Canonical Ltd. | ||
185 | 3 | |||
186 | 4 | // This library is free software; you can redistribute it and/or | ||
187 | 5 | // modify it under the terms of the GNU Lesser General Public | ||
188 | 6 | // License as published by the Free Software Foundation; either | ||
189 | 7 | // version 2.1 of the License, or (at your option) any later version. | ||
190 | 8 | |||
191 | 9 | // This library is distributed in the hope that it will be useful, | ||
192 | 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
193 | 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
194 | 12 | // Lesser General Public License for more details. | ||
195 | 13 | |||
196 | 14 | // You should have received a copy of the GNU Lesser General Public | ||
197 | 15 | // License along with this library; if not, write to the Free Software | ||
198 | 16 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
199 | 17 | |||
200 | 18 | #ifndef _OXIDE_QT_CORE_API_FIND_CONTROLLER_P_H_ | ||
201 | 19 | #define _OXIDE_QT_CORE_API_FIND_CONTROLLER_P_H_ | ||
202 | 20 | |||
203 | 21 | #include <QtGlobal> | ||
204 | 22 | #include <QString> | ||
205 | 23 | |||
206 | 24 | namespace oxide { | ||
207 | 25 | class WebView; | ||
208 | 26 | } | ||
209 | 27 | |||
210 | 28 | class OxideQFindControllerPrivate { | ||
211 | 29 | public: | ||
212 | 30 | virtual ~OxideQFindControllerPrivate(); | ||
213 | 31 | |||
214 | 32 | private: | ||
215 | 33 | OxideQFindControllerPrivate(oxide::WebView* webview); | ||
216 | 34 | |||
217 | 35 | QString text_; | ||
218 | 36 | bool case_sensitive_; | ||
219 | 37 | int count_; | ||
220 | 38 | int current_; | ||
221 | 39 | int request_id_; | ||
222 | 40 | oxide::WebView* webview_; | ||
223 | 41 | |||
224 | 42 | friend class OxideQFindController; | ||
225 | 43 | }; | ||
226 | 44 | |||
227 | 45 | #endif // _OXIDE_QT_CORE_API_FIND_CONTROLLER_P_H_ | ||
228 | 46 | |||
229 | 0 | 47 | ||
230 | === modified file 'qt/core/browser/oxide_qt_web_view.cc' | |||
231 | --- qt/core/browser/oxide_qt_web_view.cc 2015-05-11 21:23:12 +0000 | |||
232 | +++ qt/core/browser/oxide_qt_web_view.cc 2015-05-20 22:10:39 +0000 | |||
233 | @@ -67,6 +67,8 @@ | |||
234 | 67 | #include "qt/core/api/oxideqcertificateerror_p.h" | 67 | #include "qt/core/api/oxideqcertificateerror_p.h" |
235 | 68 | #include "qt/core/api/oxideqsecuritystatus.h" | 68 | #include "qt/core/api/oxideqsecuritystatus.h" |
236 | 69 | #include "qt/core/api/oxideqsecuritystatus_p.h" | 69 | #include "qt/core/api/oxideqsecuritystatus_p.h" |
237 | 70 | #include "qt/core/api/oxideqfindcontroller.h" | ||
238 | 71 | #include "qt/core/api/oxideqfindcontroller_p.h" | ||
239 | 70 | #include "qt/core/api/oxideqwebpreferences.h" | 72 | #include "qt/core/api/oxideqwebpreferences.h" |
240 | 71 | #include "qt/core/api/oxideqwebpreferences_p.h" | 73 | #include "qt/core/api/oxideqwebpreferences_p.h" |
241 | 72 | #include "qt/core/common/oxide_qt_screen_utils.h" | 74 | #include "qt/core/common/oxide_qt_screen_utils.h" |
242 | @@ -1280,6 +1282,18 @@ | |||
243 | 1280 | Reload(); | 1282 | Reload(); |
244 | 1281 | } | 1283 | } |
245 | 1282 | 1284 | ||
246 | 1285 | OxideQFindController* WebView::findInPage() { | ||
247 | 1286 | return find_in_page_controller_.get(); | ||
248 | 1287 | } | ||
249 | 1288 | |||
250 | 1289 | void WebView::OnFindInPageCountChanged() { | ||
251 | 1290 | Q_EMIT find_in_page_controller_->countChanged(); | ||
252 | 1291 | } | ||
253 | 1292 | |||
254 | 1293 | void WebView::OnFindInPageCurrentChanged() { | ||
255 | 1294 | Q_EMIT find_in_page_controller_->currentChanged(); | ||
256 | 1295 | } | ||
257 | 1296 | |||
258 | 1283 | void WebView::loadHtml(const QString& html, const QUrl& base_url) { | 1297 | void WebView::loadHtml(const QString& html, const QUrl& base_url) { |
259 | 1284 | QByteArray encoded_data = html.toUtf8().toPercentEncoding(); | 1298 | QByteArray encoded_data = html.toUtf8().toPercentEncoding(); |
260 | 1285 | LoadData(std::string(encoded_data.constData(), encoded_data.length()), | 1299 | LoadData(std::string(encoded_data.constData(), encoded_data.length()), |
261 | @@ -1511,7 +1525,8 @@ | |||
262 | 1511 | client_(client), | 1525 | client_(client), |
263 | 1512 | has_input_method_state_(false), | 1526 | has_input_method_state_(false), |
264 | 1513 | qsecurity_status_( | 1527 | qsecurity_status_( |
266 | 1514 | OxideQSecurityStatusPrivate::Create(this)) { | 1528 | OxideQSecurityStatusPrivate::Create(this)), |
267 | 1529 | find_in_page_controller_(new OxideQFindController(this)) { | ||
268 | 1515 | QInputMethod* im = QGuiApplication::inputMethod(); | 1530 | QInputMethod* im = QGuiApplication::inputMethod(); |
269 | 1516 | if (im) { | 1531 | if (im) { |
270 | 1517 | connect(im, SIGNAL(visibleChanged()), | 1532 | connect(im, SIGNAL(visibleChanged()), |
271 | 1518 | 1533 | ||
272 | === modified file 'qt/core/browser/oxide_qt_web_view.h' | |||
273 | --- qt/core/browser/oxide_qt_web_view.h 2015-05-11 21:23:12 +0000 | |||
274 | +++ qt/core/browser/oxide_qt_web_view.h 2015-05-20 22:10:39 +0000 | |||
275 | @@ -41,6 +41,7 @@ | |||
276 | 41 | class QWheelEvent; | 41 | class QWheelEvent; |
277 | 42 | QT_END_NAMESPACE | 42 | QT_END_NAMESPACE |
278 | 43 | 43 | ||
279 | 44 | class OxideQFindController; | ||
280 | 44 | class OxideQSecurityStatus; | 45 | class OxideQSecurityStatus; |
281 | 45 | 46 | ||
282 | 46 | namespace oxide { | 47 | namespace oxide { |
283 | @@ -156,6 +157,9 @@ | |||
284 | 156 | const std::string& cookies, | 157 | const std::string& cookies, |
285 | 157 | const std::string& referrer) override; | 158 | const std::string& referrer) override; |
286 | 158 | 159 | ||
287 | 160 | void OnFindInPageCountChanged() override; | ||
288 | 161 | void OnFindInPageCurrentChanged() override; | ||
289 | 162 | |||
290 | 159 | bool ShouldHandleNavigation(const GURL& url, | 163 | bool ShouldHandleNavigation(const GURL& url, |
291 | 160 | WindowOpenDisposition disposition, | 164 | WindowOpenDisposition disposition, |
292 | 161 | bool user_gesture) override; | 165 | bool user_gesture) override; |
293 | @@ -231,6 +235,8 @@ | |||
294 | 231 | void stop() override; | 235 | void stop() override; |
295 | 232 | void reload() override; | 236 | void reload() override; |
296 | 233 | 237 | ||
297 | 238 | OxideQFindController* findInPage() override; | ||
298 | 239 | |||
299 | 234 | void loadHtml(const QString& html, const QUrl& base_url) override; | 240 | void loadHtml(const QString& html, const QUrl& base_url) override; |
300 | 235 | 241 | ||
301 | 236 | QList<ScriptMessageHandlerProxyHandle*>& messageHandlers() override; | 242 | QList<ScriptMessageHandlerProxyHandle*>& messageHandlers() override; |
302 | @@ -291,6 +297,7 @@ | |||
303 | 291 | UITouchEventFactory touch_event_factory_; | 297 | UITouchEventFactory touch_event_factory_; |
304 | 292 | 298 | ||
305 | 293 | QSharedPointer<CompositorFrameHandle> compositor_frame_; | 299 | QSharedPointer<CompositorFrameHandle> compositor_frame_; |
306 | 300 | scoped_ptr<OxideQFindController> find_in_page_controller_; | ||
307 | 294 | 301 | ||
308 | 295 | DISALLOW_IMPLICIT_CONSTRUCTORS(WebView); | 302 | DISALLOW_IMPLICIT_CONSTRUCTORS(WebView); |
309 | 296 | }; | 303 | }; |
310 | 297 | 304 | ||
311 | === modified file 'qt/core/core.gyp' | |||
312 | --- qt/core/core.gyp 2015-05-06 21:13:13 +0000 | |||
313 | +++ qt/core/core.gyp 2015-05-20 22:10:39 +0000 | |||
314 | @@ -201,6 +201,7 @@ | |||
315 | 201 | '<(INTERMEDIATE_DIR)/moc_oxideqnavigationrequest.cc', | 201 | '<(INTERMEDIATE_DIR)/moc_oxideqnavigationrequest.cc', |
316 | 202 | '<(INTERMEDIATE_DIR)/moc_oxideqnewviewrequest.cc', | 202 | '<(INTERMEDIATE_DIR)/moc_oxideqnewviewrequest.cc', |
317 | 203 | '<(INTERMEDIATE_DIR)/moc_oxideqpermissionrequest.cc', | 203 | '<(INTERMEDIATE_DIR)/moc_oxideqpermissionrequest.cc', |
318 | 204 | '<(INTERMEDIATE_DIR)/moc_oxideqfindcontroller.cc', | ||
319 | 204 | '<(INTERMEDIATE_DIR)/moc_oxideqsecuritystatus.cc', | 205 | '<(INTERMEDIATE_DIR)/moc_oxideqsecuritystatus.cc', |
320 | 205 | '<(INTERMEDIATE_DIR)/moc_oxideqsslcertificate.cc', | 206 | '<(INTERMEDIATE_DIR)/moc_oxideqsslcertificate.cc', |
321 | 206 | '<(INTERMEDIATE_DIR)/moc_oxideqstoragepermissionrequest.cc', | 207 | '<(INTERMEDIATE_DIR)/moc_oxideqstoragepermissionrequest.cc', |
322 | @@ -229,6 +230,9 @@ | |||
323 | 229 | 'api/oxideqpermissionrequest.cc', | 230 | 'api/oxideqpermissionrequest.cc', |
324 | 230 | 'api/oxideqpermissionrequest.h', | 231 | 'api/oxideqpermissionrequest.h', |
325 | 231 | 'api/oxideqpermissionrequest_p.h', | 232 | 'api/oxideqpermissionrequest_p.h', |
326 | 233 | 'api/oxideqfindcontroller.cc', | ||
327 | 234 | 'api/oxideqfindcontroller.h', | ||
328 | 235 | 'api/oxideqfindcontroller_p.h', | ||
329 | 232 | 'api/oxideqsecuritystatus.cc', | 236 | 'api/oxideqsecuritystatus.cc', |
330 | 233 | 'api/oxideqsecuritystatus.h', | 237 | 'api/oxideqsecuritystatus.h', |
331 | 234 | 'api/oxideqsecuritystatus_p.h', | 238 | 'api/oxideqsecuritystatus_p.h', |
332 | @@ -279,6 +283,11 @@ | |||
333 | 279 | 'includes': [ 'moc.gypi' ], | 283 | 'includes': [ 'moc.gypi' ], |
334 | 280 | }, | 284 | }, |
335 | 281 | { | 285 | { |
336 | 286 | 'action_name': 'moc_oxideqfindcontroller.cc', | ||
337 | 287 | 'moc_input': 'api/oxideqfindcontroller.h', | ||
338 | 288 | 'includes': [ 'moc.gypi' ], | ||
339 | 289 | }, | ||
340 | 290 | { | ||
341 | 282 | 'action_name': 'moc_oxideqsecuritystatus.cc', | 291 | 'action_name': 'moc_oxideqsecuritystatus.cc', |
342 | 283 | 'moc_input': 'api/oxideqsecuritystatus.h', | 292 | 'moc_input': 'api/oxideqsecuritystatus.h', |
343 | 284 | 'includes': [ 'moc.gypi' ], | 293 | 'includes': [ 'moc.gypi' ], |
344 | 285 | 294 | ||
345 | === modified file 'qt/core/glue/oxide_qt_web_view_proxy.h' | |||
346 | --- qt/core/glue/oxide_qt_web_view_proxy.h 2015-05-06 15:05:53 +0000 | |||
347 | +++ qt/core/glue/oxide_qt_web_view_proxy.h 2015-05-20 22:10:39 +0000 | |||
348 | @@ -45,6 +45,7 @@ | |||
349 | 45 | class QWheelEvent; | 45 | class QWheelEvent; |
350 | 46 | QT_END_NAMESPACE | 46 | QT_END_NAMESPACE |
351 | 47 | 47 | ||
352 | 48 | class OxideQFindController; | ||
353 | 48 | class OxideQNewViewRequest; | 49 | class OxideQNewViewRequest; |
354 | 49 | class OxideQSecurityStatus; | 50 | class OxideQSecurityStatus; |
355 | 50 | class OxideQWebPreferences; | 51 | class OxideQWebPreferences; |
356 | @@ -101,6 +102,14 @@ | |||
357 | 101 | virtual EGLImageKHR GetImageFrame() = 0; | 102 | virtual EGLImageKHR GetImageFrame() = 0; |
358 | 102 | }; | 103 | }; |
359 | 103 | 104 | ||
360 | 105 | struct FindInPageState { | ||
361 | 106 | int request_id; | ||
362 | 107 | QString text; | ||
363 | 108 | bool case_sensitive; | ||
364 | 109 | int current; | ||
365 | 110 | int count; | ||
366 | 111 | }; | ||
367 | 112 | |||
368 | 104 | OXIDE_Q_DECL_PROXY_HANDLE(ScriptMessageHandlerProxy); | 113 | OXIDE_Q_DECL_PROXY_HANDLE(ScriptMessageHandlerProxy); |
369 | 105 | OXIDE_Q_DECL_PROXY_HANDLE(WebContextProxy); | 114 | OXIDE_Q_DECL_PROXY_HANDLE(WebContextProxy); |
370 | 106 | OXIDE_Q_DECL_PROXY_HANDLE(WebFrameProxy); | 115 | OXIDE_Q_DECL_PROXY_HANDLE(WebFrameProxy); |
371 | @@ -155,6 +164,8 @@ | |||
372 | 155 | virtual void stop() = 0; | 164 | virtual void stop() = 0; |
373 | 156 | virtual void reload() = 0; | 165 | virtual void reload() = 0; |
374 | 157 | 166 | ||
375 | 167 | virtual OxideQFindController* findInPage() = 0; | ||
376 | 168 | |||
377 | 158 | virtual void loadHtml(const QString& html, const QUrl& base_url) = 0; | 169 | virtual void loadHtml(const QString& html, const QUrl& base_url) = 0; |
378 | 159 | 170 | ||
379 | 160 | virtual QList<ScriptMessageHandlerProxyHandle*>& messageHandlers() = 0; | 171 | virtual QList<ScriptMessageHandlerProxyHandle*>& messageHandlers() = 0; |
380 | 161 | 172 | ||
381 | === modified file 'qt/qmlplugin/oxide_qml_plugin.cc' | |||
382 | --- qt/qmlplugin/oxide_qml_plugin.cc 2015-05-11 21:23:12 +0000 | |||
383 | +++ qt/qmlplugin/oxide_qml_plugin.cc 2015-05-20 22:10:39 +0000 | |||
384 | @@ -24,6 +24,7 @@ | |||
385 | 24 | 24 | ||
386 | 25 | #include "qt/core/api/oxideqcertificateerror.h" | 25 | #include "qt/core/api/oxideqcertificateerror.h" |
387 | 26 | #include "qt/core/api/oxideqdownloadrequest.h" | 26 | #include "qt/core/api/oxideqdownloadrequest.h" |
388 | 27 | #include "qt/core/api/oxideqfindcontroller.h" | ||
389 | 27 | #include "qt/core/api/oxideqloadevent.h" | 28 | #include "qt/core/api/oxideqloadevent.h" |
390 | 28 | #include "qt/core/api/oxideqnavigationrequest.h" | 29 | #include "qt/core/api/oxideqnavigationrequest.h" |
391 | 29 | #include "qt/core/api/oxideqnewviewrequest.h" | 30 | #include "qt/core/api/oxideqnewviewrequest.h" |
392 | @@ -128,8 +129,12 @@ | |||
393 | 128 | qmlRegisterUncreatableType<OxideQQuickLocationBarController, 1>(uri, 1, 7, "LocationBarController", | 129 | qmlRegisterUncreatableType<OxideQQuickLocationBarController, 1>(uri, 1, 7, "LocationBarController", |
394 | 129 | "LocationBarController is accessed via WebView.locationBarController"); | 130 | "LocationBarController is accessed via WebView.locationBarController"); |
395 | 130 | 131 | ||
396 | 132 | qmlRegisterUncreatableType<OxideQFindController>(uri, 1, 8, "FindController", | ||
397 | 133 | "FindInPage is accessed via WebView.findController"); | ||
398 | 134 | |||
399 | 131 | qmlRegisterUncreatableType<OxideQLoadEvent, 2>(uri, 1, 8, "LoadEvent", | 135 | qmlRegisterUncreatableType<OxideQLoadEvent, 2>(uri, 1, 8, "LoadEvent", |
400 | 132 | "LoadEvent is delivered by WebView.loadEvent"); | 136 | "LoadEvent is delivered by WebView.loadEvent"); |
401 | 137 | |||
402 | 133 | qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView"); | 138 | qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView"); |
403 | 134 | } | 139 | } |
404 | 135 | }; | 140 | }; |
405 | 136 | 141 | ||
406 | === modified file 'qt/quick/api/oxideqquickwebview.cc' | |||
407 | --- qt/quick/api/oxideqquickwebview.cc 2015-05-11 15:32:11 +0000 | |||
408 | +++ qt/quick/api/oxideqquickwebview.cc 2015-05-20 22:10:39 +0000 | |||
409 | @@ -41,6 +41,7 @@ | |||
410 | 41 | #include <Qt> | 41 | #include <Qt> |
411 | 42 | 42 | ||
412 | 43 | #include "qt/core/api/oxideqcertificateerror.h" | 43 | #include "qt/core/api/oxideqcertificateerror.h" |
413 | 44 | #include "qt/core/api/oxideqfindcontroller.h" | ||
414 | 44 | #include "qt/core/api/oxideqglobal.h" | 45 | #include "qt/core/api/oxideqglobal.h" |
415 | 45 | #include "qt/core/api/oxideqloadevent.h" | 46 | #include "qt/core/api/oxideqloadevent.h" |
416 | 46 | #include "qt/core/api/oxideqnewviewrequest.h" | 47 | #include "qt/core/api/oxideqnewviewrequest.h" |
417 | @@ -1744,4 +1745,10 @@ | |||
418 | 1744 | d->proxy()->prepareToClose(); | 1745 | d->proxy()->prepareToClose(); |
419 | 1745 | } | 1746 | } |
420 | 1746 | 1747 | ||
421 | 1748 | OxideQFindController* OxideQQuickWebView::findController() const { | ||
422 | 1749 | Q_D(const OxideQQuickWebView); | ||
423 | 1750 | |||
424 | 1751 | return d->proxy()->findInPage(); | ||
425 | 1752 | } | ||
426 | 1753 | |||
427 | 1747 | #include "moc_oxideqquickwebview_p.cpp" | 1754 | #include "moc_oxideqquickwebview_p.cpp" |
428 | 1748 | 1755 | ||
429 | === modified file 'qt/quick/api/oxideqquickwebview_p.h' | |||
430 | --- qt/quick/api/oxideqquickwebview_p.h 2015-05-11 15:32:11 +0000 | |||
431 | +++ qt/quick/api/oxideqquickwebview_p.h 2015-05-20 22:10:39 +0000 | |||
432 | @@ -32,6 +32,7 @@ | |||
433 | 32 | 32 | ||
434 | 33 | QT_USE_NAMESPACE | 33 | QT_USE_NAMESPACE |
435 | 34 | 34 | ||
436 | 35 | class OxideQFindController; | ||
437 | 35 | class OxideQLoadEvent; | 36 | class OxideQLoadEvent; |
438 | 36 | class OxideQNavigationRequest; | 37 | class OxideQNavigationRequest; |
439 | 37 | class OxideQNewViewRequest; | 38 | class OxideQNewViewRequest; |
440 | @@ -45,6 +46,11 @@ | |||
441 | 45 | class OxideQQuickWebViewPrivate; | 46 | class OxideQQuickWebViewPrivate; |
442 | 46 | class OxideQDownloadRequest; | 47 | class OxideQDownloadRequest; |
443 | 47 | class OxideQSecurityStatus; | 48 | class OxideQSecurityStatus; |
444 | 49 | namespace oxide { | ||
445 | 50 | namespace qt { | ||
446 | 51 | class WebViewProxy; | ||
447 | 52 | } | ||
448 | 53 | } | ||
449 | 48 | 54 | ||
450 | 49 | class OxideQQuickWebViewAttached : public QObject { | 55 | class OxideQQuickWebViewAttached : public QObject { |
451 | 50 | Q_OBJECT | 56 | Q_OBJECT |
452 | @@ -107,6 +113,8 @@ | |||
453 | 107 | 113 | ||
454 | 108 | Q_PROPERTY(OxideQNewViewRequest* request READ request WRITE setRequest) | 114 | Q_PROPERTY(OxideQNewViewRequest* request READ request WRITE setRequest) |
455 | 109 | 115 | ||
456 | 116 | Q_PROPERTY(OxideQFindController* findController READ findController CONSTANT REVISION 4) | ||
457 | 117 | |||
458 | 110 | // Set at construction time only | 118 | // Set at construction time only |
459 | 111 | Q_PROPERTY(QString restoreState READ restoreState WRITE setRestoreState REVISION 2) | 119 | Q_PROPERTY(QString restoreState READ restoreState WRITE setRestoreState REVISION 2) |
460 | 112 | Q_PROPERTY(RestoreType restoreType READ restoreType WRITE setRestoreType REVISION 2) | 120 | Q_PROPERTY(RestoreType restoreType READ restoreType WRITE setRestoreType REVISION 2) |
461 | @@ -234,6 +242,8 @@ | |||
462 | 234 | 242 | ||
463 | 235 | static OxideQQuickWebViewAttached* qmlAttachedProperties(QObject* object); | 243 | static OxideQQuickWebViewAttached* qmlAttachedProperties(QObject* object); |
464 | 236 | 244 | ||
465 | 245 | OxideQFindController* findController() const; | ||
466 | 246 | |||
467 | 237 | public Q_SLOTS: | 247 | public Q_SLOTS: |
468 | 238 | void goBack(); | 248 | void goBack(); |
469 | 239 | void goForward(); | 249 | void goForward(); |
470 | 240 | 250 | ||
471 | === added file 'qt/tests/qmltests/api/tst_WebView_findController.html' | |||
472 | --- qt/tests/qmltests/api/tst_WebView_findController.html 1970-01-01 00:00:00 +0000 | |||
473 | +++ qt/tests/qmltests/api/tst_WebView_findController.html 2015-05-20 22:10:39 +0000 | |||
474 | @@ -0,0 +1,13 @@ | |||
475 | 1 | <html> | ||
476 | 2 | <head> | ||
477 | 3 | <meta charset="UTF-8"> | ||
478 | 4 | </head> | ||
479 | 5 | <body> | ||
480 | 6 | Lorem ipsum dolor sit Amet, consectetur adipiscing elit. | ||
481 | 7 | Nam eu venenatis velit. | ||
482 | 8 | Suspendisse vitae libero rutrum Amet, congue velit quis, fringilla eros. | ||
483 | 9 | Nulla at semper purus, id scelerisque est. | ||
484 | 10 | Fusce rhoncus placerat erat ñec ultricies amet. | ||
485 | 11 | Curabitur mauris. Dolor, facilisis eu tellus vitae, semper iaculis tortor. | ||
486 | 12 | </body> | ||
487 | 13 | </html> | ||
488 | 0 | 14 | ||
489 | === added file 'qt/tests/qmltests/api/tst_WebView_findController.qml' | |||
490 | --- qt/tests/qmltests/api/tst_WebView_findController.qml 1970-01-01 00:00:00 +0000 | |||
491 | +++ qt/tests/qmltests/api/tst_WebView_findController.qml 2015-05-20 22:10:39 +0000 | |||
492 | @@ -0,0 +1,152 @@ | |||
493 | 1 | import QtQuick 2.0 | ||
494 | 2 | import QtTest 1.0 | ||
495 | 3 | import com.canonical.Oxide 1.8 | ||
496 | 4 | import com.canonical.Oxide.Testing 1.0 | ||
497 | 5 | |||
498 | 6 | TestWebView { | ||
499 | 7 | id: webView | ||
500 | 8 | focus: true | ||
501 | 9 | width: 200 | ||
502 | 10 | height: 200 | ||
503 | 11 | |||
504 | 12 | TestCase { | ||
505 | 13 | name: "findController" | ||
506 | 14 | when: windowShown | ||
507 | 15 | |||
508 | 16 | function init() { | ||
509 | 17 | webView.findController.text = ""; | ||
510 | 18 | webView.findController.caseSensitive = false; | ||
511 | 19 | |||
512 | 20 | // load the page that will be used by most tests | ||
513 | 21 | webView.url = "http://testsuite/tst_WebView_findController.html"; | ||
514 | 22 | verify(webView.waitForLoadSucceeded(), | ||
515 | 23 | "Timed out waiting for successful load"); | ||
516 | 24 | } | ||
517 | 25 | |||
518 | 26 | function test_case_insensitive() { | ||
519 | 27 | webView.findController.text = "suspendisse"; | ||
520 | 28 | tryCompare(webView.findController, "count", 1); | ||
521 | 29 | |||
522 | 30 | webView.findController.text = "aMet"; | ||
523 | 31 | tryCompare(webView.findController, "count", 3); | ||
524 | 32 | } | ||
525 | 33 | |||
526 | 34 | function test_case_sensitive() { | ||
527 | 35 | webView.findController.caseSensitive = true; | ||
528 | 36 | |||
529 | 37 | webView.findController.text = "Suspendisse"; | ||
530 | 38 | tryCompare(webView.findController, "count", 1); | ||
531 | 39 | |||
532 | 40 | webView.findController.text = "suspendisse"; | ||
533 | 41 | tryCompare(webView.findController, "count", 0); | ||
534 | 42 | } | ||
535 | 43 | |||
536 | 44 | function test_change_case_sensitivity() { | ||
537 | 45 | webView.findController.caseSensitive = true; | ||
538 | 46 | |||
539 | 47 | webView.findController.text = "Dolor"; | ||
540 | 48 | tryCompare(webView.findController, "count", 1); | ||
541 | 49 | |||
542 | 50 | webView.findController.caseSensitive = false; | ||
543 | 51 | tryCompare(webView.findController, "count", 2); | ||
544 | 52 | } | ||
545 | 53 | |||
546 | 54 | function test_movement() { | ||
547 | 55 | webView.findController.text = "dolor"; | ||
548 | 56 | tryCompare(webView.findController, "count", 2); | ||
549 | 57 | tryCompare(webView.findController, "current", 1); | ||
550 | 58 | |||
551 | 59 | webView.findController.next(); | ||
552 | 60 | tryCompare(webView.findController, "count", 2); | ||
553 | 61 | tryCompare(webView.findController, "current", 2); | ||
554 | 62 | |||
555 | 63 | webView.findController.previous(); | ||
556 | 64 | tryCompare(webView.findController, "count", 2); | ||
557 | 65 | tryCompare(webView.findController, "current", 1); | ||
558 | 66 | } | ||
559 | 67 | |||
560 | 68 | function test_movement_wraps() { | ||
561 | 69 | webView.findController.text = "dolor"; | ||
562 | 70 | tryCompare(webView.findController, "count", 2); | ||
563 | 71 | tryCompare(webView.findController, "current", 1); | ||
564 | 72 | |||
565 | 73 | webView.findController.next(); | ||
566 | 74 | webView.findController.next(); | ||
567 | 75 | tryCompare(webView.findController, "current", 1); | ||
568 | 76 | |||
569 | 77 | webView.findController.previous(); | ||
570 | 78 | webView.findController.previous(); | ||
571 | 79 | tryCompare(webView.findController, "current", 1); | ||
572 | 80 | } | ||
573 | 81 | |||
574 | 82 | function test_clear() { | ||
575 | 83 | webView.findController.text = "dolor"; | ||
576 | 84 | tryCompare(webView.findController, "count", 2); | ||
577 | 85 | |||
578 | 86 | webView.findController.text = ""; | ||
579 | 87 | tryCompare(webView.findController, "count", 0); | ||
580 | 88 | tryCompare(webView.findController, "current", 0); | ||
581 | 89 | } | ||
582 | 90 | |||
583 | 91 | function test_new_text_resets_count() { | ||
584 | 92 | webView.findController.text = "dolor"; | ||
585 | 93 | tryCompare(webView.findController, "count", 2); | ||
586 | 94 | webView.findController.next(); | ||
587 | 95 | tryCompare(webView.findController, "current", 2); | ||
588 | 96 | |||
589 | 97 | webView.findController.text = "suspendisse"; | ||
590 | 98 | tryCompare(webView.findController, "count", 1); | ||
591 | 99 | tryCompare(webView.findController, "current", 1); | ||
592 | 100 | } | ||
593 | 101 | |||
594 | 102 | function test_not_found_resets_count() { | ||
595 | 103 | webView.findController.text = "dolor"; | ||
596 | 104 | tryCompare(webView.findController, "count", 2); | ||
597 | 105 | |||
598 | 106 | webView.findController.text = "i_am_not_there"; | ||
599 | 107 | tryCompare(webView.findController, "count", 0); | ||
600 | 108 | tryCompare(webView.findController, "current", 0); | ||
601 | 109 | } | ||
602 | 110 | |||
603 | 111 | function test_find_non_latin() { | ||
604 | 112 | webView.findController.text = "ñec"; | ||
605 | 113 | tryCompare(webView.findController, "count", 1); | ||
606 | 114 | } | ||
607 | 115 | |||
608 | 116 | function test_find_on_invalid_page() { | ||
609 | 117 | webView.url = "http://testsuite/tst_invalid_page.html"; | ||
610 | 118 | // verify successful load because the server returns a 404 page apparently | ||
611 | 119 | // and that does not count as a failure | ||
612 | 120 | verify(webView.waitForLoadSucceeded(), | ||
613 | 121 | "Timed out waiting for successful load"); | ||
614 | 122 | |||
615 | 123 | webView.findController.text = "hello"; | ||
616 | 124 | tryCompare(webView.findController, "count", 0); | ||
617 | 125 | tryCompare(webView.findController, "current", 0); | ||
618 | 126 | } | ||
619 | 127 | |||
620 | 128 | function test_navigation_does_not_reset() { | ||
621 | 129 | webView.findController.text = "dolor"; | ||
622 | 130 | tryCompare(webView.findController, "count", 2); | ||
623 | 131 | webView.findController.next(); | ||
624 | 132 | tryCompare(webView.findController, "current", 2); | ||
625 | 133 | |||
626 | 134 | // Verify that when navigating to another page the search does not | ||
627 | 135 | // reset, it is the user responsibility to cancel it and restart it | ||
628 | 136 | webView.url = "http://testsuite/tst_WebView_findControllerManyResults.html"; | ||
629 | 137 | verify(webView.waitForLoadSucceeded(), | ||
630 | 138 | "Timed out waiting for successful load"); | ||
631 | 139 | compare(webView.findController.text, "dolor"); | ||
632 | 140 | tryCompare(webView.findController, "count", 2); | ||
633 | 141 | tryCompare(webView.findController, "current", 2); | ||
634 | 142 | |||
635 | 143 | webView.findController.text = ""; | ||
636 | 144 | tryCompare(webView.findController, "count", 0); | ||
637 | 145 | tryCompare(webView.findController, "current", 0); | ||
638 | 146 | |||
639 | 147 | webView.findController.text = "dolor"; | ||
640 | 148 | tryCompare(webView.findController, "count", 20); | ||
641 | 149 | tryCompare(webView.findController, "current", 1); | ||
642 | 150 | } | ||
643 | 151 | } | ||
644 | 152 | } | ||
645 | 0 | 153 | ||
646 | === added file 'qt/tests/qmltests/api/tst_WebView_findControllerManyResults.html' | |||
647 | --- qt/tests/qmltests/api/tst_WebView_findControllerManyResults.html 1970-01-01 00:00:00 +0000 | |||
648 | +++ qt/tests/qmltests/api/tst_WebView_findControllerManyResults.html 2015-05-20 22:10:39 +0000 | |||
649 | @@ -0,0 +1,9 @@ | |||
650 | 1 | <html> | ||
651 | 2 | <head> | ||
652 | 3 | <meta charset="UTF-8"> | ||
653 | 4 | </head> | ||
654 | 5 | <body> | ||
655 | 6 | Lorem ipsum dolor dolor dolor dolor dolor dolor dolor dolor dolor dolor | ||
656 | 7 | dolor dolor dolor dolor dolor dolor dolor dolor dolor dolor sit amet. | ||
657 | 8 | </body> | ||
658 | 9 | </html> | ||
659 | 0 | 10 | ||
660 | === modified file 'shared/browser/oxide_web_view.cc' | |||
661 | --- shared/browser/oxide_web_view.cc 2015-05-15 14:49:32 +0000 | |||
662 | +++ shared/browser/oxide_web_view.cc 2015-05-20 22:10:39 +0000 | |||
663 | @@ -76,6 +76,8 @@ | |||
664 | 76 | #include "shared/common/oxide_event_utils.h" | 76 | #include "shared/common/oxide_event_utils.h" |
665 | 77 | #include "shared/common/oxide_messages.h" | 77 | #include "shared/common/oxide_messages.h" |
666 | 78 | 78 | ||
667 | 79 | #include "third_party/WebKit/public/web/WebFindOptions.h" | ||
668 | 80 | |||
669 | 79 | #include "oxide_browser_context.h" | 81 | #include "oxide_browser_context.h" |
670 | 80 | #include "oxide_browser_process_main.h" | 82 | #include "oxide_browser_process_main.h" |
671 | 81 | #include "oxide_content_browser_client.h" | 83 | #include "oxide_content_browser_client.h" |
672 | @@ -753,6 +755,25 @@ | |||
673 | 753 | return IsFullscreen(); | 755 | return IsFullscreen(); |
674 | 754 | } | 756 | } |
675 | 755 | 757 | ||
676 | 758 | void WebView::FindReply(content::WebContents* web_contents, | ||
677 | 759 | int request_id, | ||
678 | 760 | int number_of_matches, | ||
679 | 761 | const gfx::Rect& selection_rect, | ||
680 | 762 | int active_match_ordinal, | ||
681 | 763 | bool final_update) { | ||
682 | 764 | if (active_match_ordinal != -1 && | ||
683 | 765 | find_in_page_.current != active_match_ordinal) { | ||
684 | 766 | find_in_page_.current = active_match_ordinal; | ||
685 | 767 | OnFindInPageCurrentChanged(); | ||
686 | 768 | } | ||
687 | 769 | |||
688 | 770 | if (number_of_matches != -1 && | ||
689 | 771 | find_in_page_.count != number_of_matches) { | ||
690 | 772 | find_in_page_.count = number_of_matches; | ||
691 | 773 | OnFindInPageCountChanged(); | ||
692 | 774 | } | ||
693 | 775 | } | ||
694 | 776 | |||
695 | 756 | void WebView::RequestMediaAccessPermission( | 777 | void WebView::RequestMediaAccessPermission( |
696 | 757 | content::WebContents* source, | 778 | content::WebContents* source, |
697 | 758 | const content::MediaStreamRequest& request, | 779 | const content::MediaStreamRequest& request, |
698 | @@ -1222,6 +1243,9 @@ | |||
699 | 1222 | void WebView::OnPrepareToCloseResponse(bool proceed) {} | 1243 | void WebView::OnPrepareToCloseResponse(bool proceed) {} |
700 | 1223 | void WebView::OnCloseRequested() {} | 1244 | void WebView::OnCloseRequested() {} |
701 | 1224 | 1245 | ||
702 | 1246 | void WebView::OnFindInPageCountChanged() {} | ||
703 | 1247 | void WebView::OnFindInPageCurrentChanged() {} | ||
704 | 1248 | |||
705 | 1225 | WebView::WebView() | 1249 | WebView::WebView() |
706 | 1226 | : text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 1250 | : text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
707 | 1227 | show_ime_if_needed_(false), | 1251 | show_ime_if_needed_(false), |
708 | @@ -1636,6 +1660,84 @@ | |||
709 | 1636 | rvh->OnWebkitPreferencesChanged(); | 1660 | rvh->OnWebkitPreferencesChanged(); |
710 | 1637 | } | 1661 | } |
711 | 1638 | 1662 | ||
712 | 1663 | int WebView::GetFindInPageCount() const { | ||
713 | 1664 | return find_in_page_.count; | ||
714 | 1665 | } | ||
715 | 1666 | |||
716 | 1667 | int WebView::GetFindInPageCurrent() const { | ||
717 | 1668 | return find_in_page_.current; | ||
718 | 1669 | } | ||
719 | 1670 | |||
720 | 1671 | std::string WebView::GetFindInPageText() const { | ||
721 | 1672 | return find_in_page_.text; | ||
722 | 1673 | } | ||
723 | 1674 | |||
724 | 1675 | bool WebView::GetFindInPageCaseSensitive() const { | ||
725 | 1676 | return find_in_page_.case_sensitive; | ||
726 | 1677 | } | ||
727 | 1678 | |||
728 | 1679 | void WebView::SetFindInPageText(const std::string& text) { | ||
729 | 1680 | find_in_page_.text = text; | ||
730 | 1681 | RestartFindInPage(); | ||
731 | 1682 | } | ||
732 | 1683 | |||
733 | 1684 | void WebView::SetFindInPageCaseSensitive(bool case_sensitive) { | ||
734 | 1685 | find_in_page_.case_sensitive = case_sensitive; | ||
735 | 1686 | RestartFindInPage(); | ||
736 | 1687 | } | ||
737 | 1688 | |||
738 | 1689 | void WebView::RestartFindInPage() { | ||
739 | 1690 | if (!web_contents_) { | ||
740 | 1691 | return; | ||
741 | 1692 | } | ||
742 | 1693 | |||
743 | 1694 | web_contents_->StopFinding(content::STOP_FIND_ACTION_CLEAR_SELECTION); | ||
744 | 1695 | |||
745 | 1696 | find_in_page_.current = 0; | ||
746 | 1697 | OnFindInPageCurrentChanged(); | ||
747 | 1698 | find_in_page_.count = 0; | ||
748 | 1699 | OnFindInPageCountChanged(); | ||
749 | 1700 | |||
750 | 1701 | if (!find_in_page_.text.empty()) { | ||
751 | 1702 | find_in_page_.request_id++; | ||
752 | 1703 | |||
753 | 1704 | blink::WebFindOptions options; | ||
754 | 1705 | options.forward = true; | ||
755 | 1706 | options.findNext = false; | ||
756 | 1707 | options.matchCase = find_in_page_.case_sensitive; | ||
757 | 1708 | |||
758 | 1709 | web_contents_->Find(find_in_page_.request_id, | ||
759 | 1710 | base::UTF8ToUTF16(find_in_page_.text), | ||
760 | 1711 | options); | ||
761 | 1712 | } | ||
762 | 1713 | } | ||
763 | 1714 | |||
764 | 1715 | void WebView::FindInPageNext() { | ||
765 | 1716 | if (!web_contents_) { | ||
766 | 1717 | return; | ||
767 | 1718 | } | ||
768 | 1719 | |||
769 | 1720 | blink::WebFindOptions options; | ||
770 | 1721 | options.forward = true; | ||
771 | 1722 | options.findNext = true; | ||
772 | 1723 | |||
773 | 1724 | web_contents_->Find(find_in_page_.request_id, | ||
774 | 1725 | base::UTF8ToUTF16(find_in_page_.text), options); | ||
775 | 1726 | } | ||
776 | 1727 | |||
777 | 1728 | void WebView::FindInPagePrevious() { | ||
778 | 1729 | if (!web_contents_) { | ||
779 | 1730 | return; | ||
780 | 1731 | } | ||
781 | 1732 | |||
782 | 1733 | blink::WebFindOptions options; | ||
783 | 1734 | options.forward = false; | ||
784 | 1735 | options.findNext = true; | ||
785 | 1736 | |||
786 | 1737 | web_contents_->Find(find_in_page_.request_id, | ||
787 | 1738 | base::UTF8ToUTF16(find_in_page_.text), options); | ||
788 | 1739 | } | ||
789 | 1740 | |||
790 | 1639 | BrowserContext* WebView::GetBrowserContext() const { | 1741 | BrowserContext* WebView::GetBrowserContext() const { |
791 | 1640 | return BrowserContext::FromContent(web_contents_->GetBrowserContext()); | 1742 | return BrowserContext::FromContent(web_contents_->GetBrowserContext()); |
792 | 1641 | } | 1743 | } |
793 | 1642 | 1744 | ||
794 | === modified file 'shared/browser/oxide_web_view.h' | |||
795 | --- shared/browser/oxide_web_view.h 2015-05-15 14:49:32 +0000 | |||
796 | +++ shared/browser/oxide_web_view.h 2015-05-20 22:10:39 +0000 | |||
797 | @@ -201,6 +201,15 @@ | |||
798 | 201 | void InputPanelVisibilityChanged(); | 201 | void InputPanelVisibilityChanged(); |
799 | 202 | void UpdateWebPreferences(); | 202 | void UpdateWebPreferences(); |
800 | 203 | 203 | ||
801 | 204 | int GetFindInPageCount() const; | ||
802 | 205 | int GetFindInPageCurrent() const; | ||
803 | 206 | std::string GetFindInPageText() const; | ||
804 | 207 | void SetFindInPageText(const std::string& text); | ||
805 | 208 | bool GetFindInPageCaseSensitive() const; | ||
806 | 209 | void SetFindInPageCaseSensitive(bool case_sensitive); | ||
807 | 210 | void FindInPageNext(); | ||
808 | 211 | void FindInPagePrevious(); | ||
809 | 212 | |||
810 | 204 | BrowserContext* GetBrowserContext() const; | 213 | BrowserContext* GetBrowserContext() const; |
811 | 205 | content::WebContents* GetWebContents() const; | 214 | content::WebContents* GetWebContents() const; |
812 | 206 | 215 | ||
813 | @@ -355,6 +364,8 @@ | |||
814 | 355 | void InitializeTopControlsForHost(content::RenderViewHost* rvh, | 364 | void InitializeTopControlsForHost(content::RenderViewHost* rvh, |
815 | 356 | bool initial_host); | 365 | bool initial_host); |
816 | 357 | 366 | ||
817 | 367 | void RestartFindInPage(); | ||
818 | 368 | |||
819 | 358 | // ScriptMessageTarget implementation | 369 | // ScriptMessageTarget implementation |
820 | 359 | virtual size_t GetScriptMessageHandlerCount() const override; | 370 | virtual size_t GetScriptMessageHandlerCount() const override; |
821 | 360 | virtual const ScriptMessageHandler* GetScriptMessageHandlerAt( | 371 | virtual const ScriptMessageHandler* GetScriptMessageHandlerAt( |
822 | @@ -440,6 +451,13 @@ | |||
823 | 440 | const content::MediaStreamRequest& request, | 451 | const content::MediaStreamRequest& request, |
824 | 441 | const content::MediaResponseCallback& callback) final; | 452 | const content::MediaResponseCallback& callback) final; |
825 | 442 | 453 | ||
826 | 454 | void FindReply(content::WebContents* web_contents, | ||
827 | 455 | int request_id, | ||
828 | 456 | int number_of_matches, | ||
829 | 457 | const gfx::Rect& selection_rect, | ||
830 | 458 | int active_match_ordinal, | ||
831 | 459 | bool final_update) final; | ||
832 | 460 | |||
833 | 443 | // content::WebContentsObserver implementation | 461 | // content::WebContentsObserver implementation |
834 | 444 | void RenderFrameCreated(content::RenderFrameHost* render_frame_host) final; | 462 | void RenderFrameCreated(content::RenderFrameHost* render_frame_host) final; |
835 | 445 | void RenderViewReady() final; | 463 | void RenderViewReady() final; |
836 | @@ -577,6 +595,9 @@ | |||
837 | 577 | virtual void OnPrepareToCloseResponse(bool proceed); | 595 | virtual void OnPrepareToCloseResponse(bool proceed); |
838 | 578 | virtual void OnCloseRequested(); | 596 | virtual void OnCloseRequested(); |
839 | 579 | 597 | ||
840 | 598 | virtual void OnFindInPageCurrentChanged(); | ||
841 | 599 | virtual void OnFindInPageCountChanged(); | ||
842 | 600 | |||
843 | 580 | struct WebContentsDeleter { | 601 | struct WebContentsDeleter { |
844 | 581 | void operator()(content::WebContents* contents); | 602 | void operator()(content::WebContents* contents); |
845 | 582 | }; | 603 | }; |
846 | @@ -623,6 +644,17 @@ | |||
847 | 623 | 644 | ||
848 | 624 | SecurityStatus security_status_; | 645 | SecurityStatus security_status_; |
849 | 625 | 646 | ||
850 | 647 | struct FindInPageState { | ||
851 | 648 | int request_id; | ||
852 | 649 | int current; | ||
853 | 650 | int count; | ||
854 | 651 | bool case_sensitive; | ||
855 | 652 | std::string text; | ||
856 | 653 | FindInPageState() : request_id(0), current(0), count(0), | ||
857 | 654 | case_sensitive(false) {} | ||
858 | 655 | }; | ||
859 | 656 | FindInPageState find_in_page_; | ||
860 | 657 | |||
861 | 626 | int location_bar_height_pix_; | 658 | int location_bar_height_pix_; |
862 | 627 | blink::WebTopControlsState location_bar_constraints_; | 659 | blink::WebTopControlsState location_bar_constraints_; |
863 | 628 | bool location_bar_animated_; | 660 | bool location_bar_animated_; |
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. waitForLoadFail ed() ?
- In test_navigation _does_not_ reset() , the comparison of text to "dolor" doesn’t need a tryCompare(), it should be a simple compare().
- In OxideQQuickWebV iewFindInPage’ 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.