Merge lp:~osomon/webbrowser-app/locationBarController into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 878
Merged at revision: 949
Proposed branch: lp:~osomon/webbrowser-app/locationBarController
Merge into: lp:webbrowser-app
Diff against target: 545 lines (+128/-226)
9 files modified
debian/control (+2/-2)
src/Ubuntu/Web/UbuntuWebView02.qml (+1/-1)
src/app/BrowserWindow.qml (+2/-1)
src/app/ChromeBase.qml (+2/-15)
src/app/ChromeController.qml (+65/-0)
src/app/ChromeStateTracker.qml (+0/-82)
src/app/ScrollTracker.qml (+0/-66)
src/app/webbrowser/Browser.qml (+29/-33)
src/app/webcontainer/WebApp.qml (+27/-26)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/locationBarController
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Alexandre Abreu (community) Approve
Review via email: mp+254068@code.launchpad.net

Commit message

Use the new locationBarController API available in oxide 1.5 to control the position of the chrome.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
872. By Olivier Tilloy

Merge the latest changes from trunk and resolve a bunch of conflicts.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
873. By Olivier Tilloy

Do not force the chrome to be always visible when a page is loading.
Instead, temporarily show it when loading starts.

874. By Olivier Tilloy

Do not reveal the chrome when hitting the bottom of the page.
This doesn’t (and cannot) work well, as this modifies the current scroll offset, thus triggering situations where the chrome briefly shows and hides again.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

Added some inline comments

875. By Olivier Tilloy

Fixed documentation: the mode is forced to ModeShown for 500ms, not 1000ms.

876. By Olivier Tilloy

Never show the chrome while in fullscreen.

877. By Olivier Tilloy

Give precedence to fullscreen over forceShow.

878. By Olivier Tilloy

Remove a redundant property.

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

Thanks for the thorough review! I addressed the issues you pointed out, and answered your comments inline.

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

LGTM

review: Approve
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

Tested on Mako/Vivid & works fine,

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
879. By Olivier Tilloy

Do not set the chrome’s state directly (this doesn’t have any effect).

880. By Olivier Tilloy

Fix the visibility of the bottom edge hint.

881. By Olivier Tilloy

Fix the anchoring of the new tab view.

882. By Olivier Tilloy

Fix the anchoring of the error page.

883. By Olivier Tilloy

Fix the anchoring of the certificate error view.

884. By Olivier Tilloy

Fix the anchoring of the error sheet in the webapp container.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-03-23 07:49:08 +0000
3+++ debian/control 2015-03-31 14:57:27 +0000
4@@ -57,7 +57,7 @@
5 Depends: ${misc:Depends},
6 ${shlibs:Depends},
7 fonts-liberation,
8- liboxideqt-qmlplugin (>= 1.3),
9+ liboxideqt-qmlplugin (>= 1.5),
10 libqt5sql5-sqlite,
11 qml-module-qtquick2 | qtdeclarative5-qtquick2-plugin,
12 qml-module-qtquick-window2 | qtdeclarative5-window-plugin,
13@@ -97,7 +97,7 @@
14 Pre-Depends: ${misc:Pre-Depends}
15 Depends: ${misc:Depends},
16 ${shlibs:Depends},
17- liboxideqt-qmlplugin (>= 1.4),
18+ liboxideqt-qmlplugin (>= 1.5),
19 qml-module-qtquick2 | qtdeclarative5-qtquick2-plugin,
20 qml-module-qtquick-window2 | qtdeclarative5-window-plugin,
21 qtdeclarative5-ubuntu-ui-toolkit-plugin,
22
23=== modified file 'src/Ubuntu/Web/UbuntuWebView02.qml'
24--- src/Ubuntu/Web/UbuntuWebView02.qml 2015-03-23 07:49:08 +0000
25+++ src/Ubuntu/Web/UbuntuWebView02.qml 2015-03-31 14:57:27 +0000
26@@ -18,7 +18,7 @@
27
28 import QtQuick 2.0
29 import QtQuick.Window 2.0
30-import com.canonical.Oxide 1.4 as Oxide
31+import com.canonical.Oxide 1.5 as Oxide
32 import Ubuntu.Components 1.1
33 import Ubuntu.Components.Popups 1.0
34 import "." // QTBUG-34418
35
36=== modified file 'src/app/BrowserWindow.qml'
37--- src/app/BrowserWindow.qml 2014-11-03 17:01:29 +0000
38+++ src/app/BrowserWindow.qml 2015-03-31 14:57:27 +0000
39@@ -1,5 +1,5 @@
40 /*
41- * Copyright 2014 Canonical Ltd.
42+ * Copyright 2014-2015 Canonical Ltd.
43 *
44 * This file is part of webbrowser-app.
45 *
46@@ -39,6 +39,7 @@
47
48 Connections {
49 target: window.currentWebview
50+ ignoreUnknownSignals: true
51 onFullscreenChanged: {
52 if (!window.forceFullscreen) {
53 if (window.currentWebview.fullscreen) {
54
55=== modified file 'src/app/ChromeBase.qml'
56--- src/app/ChromeBase.qml 2014-08-26 08:53:28 +0000
57+++ src/app/ChromeBase.qml 2015-03-31 14:57:27 +0000
58@@ -1,5 +1,5 @@
59 /*
60- * Copyright 2014 Canonical Ltd.
61+ * Copyright 2014-2015 Canonical Ltd.
62 *
63 * This file is part of webbrowser-app.
64 *
65@@ -23,27 +23,14 @@
66 StyledItem {
67 id: chrome
68
69- readonly property real visibleHeight: y + height
70 property var webview
71
72- readonly property bool moving: (y < 0) && (y > -height)
73-
74 states: [
75 State {
76 name: "shown"
77- },
78- State {
79- name: "hidden"
80+ when: chrome.y == 0
81 }
82 ]
83- state: "shown"
84-
85- y: (state == "shown") ? 0 : -height
86- Behavior on y {
87- SmoothedAnimation {
88- duration: UbuntuAnimation.BriskDuration
89- }
90- }
91
92 Rectangle {
93 anchors.fill: parent
94
95=== added file 'src/app/ChromeController.qml'
96--- src/app/ChromeController.qml 1970-01-01 00:00:00 +0000
97+++ src/app/ChromeController.qml 2015-03-31 14:57:27 +0000
98@@ -0,0 +1,65 @@
99+/*
100+ * Copyright 2015 Canonical Ltd.
101+ *
102+ * This file is part of webbrowser-app.
103+ *
104+ * webbrowser-app is free software; you can redistribute it and/or modify
105+ * it under the terms of the GNU General Public License as published by
106+ * the Free Software Foundation; version 3.
107+ *
108+ * webbrowser-app is distributed in the hope that it will be useful,
109+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
110+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
111+ * GNU General Public License for more details.
112+ *
113+ * You should have received a copy of the GNU General Public License
114+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
115+ */
116+
117+import QtQuick 2.0
118+import com.canonical.Oxide 1.5 as Oxide
119+
120+Item {
121+ visible: false
122+
123+ property var webview
124+ property bool forceHide: false
125+
126+ readonly property int mode: {
127+ if (forceHide || webview.fullscreen) {
128+ return Oxide.LocationBarController.ModeHidden
129+ } else if (internal.forceShow) {
130+ return Oxide.LocationBarController.ModeShown
131+ } else {
132+ return Oxide.LocationBarController.ModeAuto
133+ }
134+ }
135+
136+ // Work around the lack of a show() method on the location bar controller
137+ // (https://launchpad.net/bugs/1422920) by forcing its mode to ModeShown
138+ // for long enough (500ms) to allow the animation to be committed.
139+ QtObject {
140+ id: internal
141+ property bool forceShow: false
142+ }
143+ Timer {
144+ id: delayedResetMode
145+ interval: 500
146+ onTriggered: internal.forceShow = false
147+ }
148+ Connections {
149+ target: webview
150+ onFullscreenChanged: {
151+ if (!webview.fullscreen) {
152+ internal.forceShow = true
153+ delayedResetMode.restart()
154+ }
155+ }
156+ onLoadingChanged: {
157+ if (webview.loading && !webview.fullscreen) {
158+ internal.forceShow = true
159+ delayedResetMode.restart()
160+ }
161+ }
162+ }
163+}
164
165=== removed file 'src/app/ChromeStateTracker.qml'
166--- src/app/ChromeStateTracker.qml 2014-08-13 15:43:02 +0000
167+++ src/app/ChromeStateTracker.qml 1970-01-01 00:00:00 +0000
168@@ -1,82 +0,0 @@
169-/*
170- * Copyright 2014 Canonical Ltd.
171- *
172- * This file is part of webbrowser-app.
173- *
174- * webbrowser-app is free software; you can redistribute it and/or modify
175- * it under the terms of the GNU General Public License as published by
176- * the Free Software Foundation; version 3.
177- *
178- * webbrowser-app is distributed in the hope that it will be useful,
179- * but WITHOUT ANY WARRANTY; without even the implied warranty of
180- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181- * GNU General Public License for more details.
182- *
183- * You should have received a copy of the GNU General Public License
184- * along with this program. If not, see <http://www.gnu.org/licenses/>.
185- */
186-
187-import QtQuick 2.0
188-
189-// A specialized ScrollTracker that handles automatically showing/hiding
190-// the chrome for a given webview, based on scroll events and proximity to
191-// the top/bottom of the page, as well as whether the webview is currently
192-// fullscreen.
193-ScrollTracker {
194- id: chromeStateTracker
195-
196- active: webview && !webview.fullscreen
197-
198- onScrolledUp: {
199- if (!header.moving && chromeStateChangeTimer.settled) {
200- delayedAutoHideTimer.up = true
201- delayedAutoHideTimer.restart()
202- }
203- }
204- onScrolledDown: {
205- if (!header.moving && chromeStateChangeTimer.settled) {
206- delayedAutoHideTimer.up = false
207- delayedAutoHideTimer.restart()
208- }
209- }
210-
211- // Delay the auto-hide/auto-show behaviour of the header, in order
212- // to prevent the view from jumping up and down on touch-enabled
213- // devices when the touch event sequence is not finished.
214- // See https://bugs.launchpad.net/webbrowser-app/+bug/1354700.
215- Timer {
216- id: delayedAutoHideTimer
217- interval: 250
218- property bool up
219- onTriggered: {
220- if (up) {
221- chromeStateTracker.header.state = "shown"
222- } else {
223- if (chromeStateTracker.nearBottom) {
224- chromeStateTracker.header.state = "shown"
225- } else if (!chromeStateTracker.nearTop) {
226- chromeStateTracker.header.state = "hidden"
227- }
228- }
229- }
230- }
231-
232- // After the chrome has stopped moving (either fully shown or fully
233- // hidden), give it some time to "settle". Until it is settled,
234- // scroll events won’t trigger a new change in the chrome’s
235- // visibility, to prevent the chrome from jumping back into view if
236- // it has just been hidden.
237- // See https://bugs.launchpad.net/webbrowser-app/+bug/1354700.
238- Timer {
239- id: chromeStateChangeTimer
240- interval: 50
241- running: !chromeStateTracker.header.moving
242- onTriggered: settled = true
243- property bool settled: true
244- }
245-
246- Connections {
247- target: chromeStateTracker.header
248- onMovingChanged: chromeStateChangeTimer.settled = false
249- }
250-}
251
252=== removed file 'src/app/ScrollTracker.qml'
253--- src/app/ScrollTracker.qml 2014-07-29 22:38:58 +0000
254+++ src/app/ScrollTracker.qml 1970-01-01 00:00:00 +0000
255@@ -1,66 +0,0 @@
256-/*
257- * Copyright 2014 Canonical Ltd.
258- *
259- * This file is part of webbrowser-app.
260- *
261- * webbrowser-app is free software; you can redistribute it and/or modify
262- * it under the terms of the GNU General Public License as published by
263- * the Free Software Foundation; version 3.
264- *
265- * webbrowser-app is distributed in the hope that it will be useful,
266- * but WITHOUT ANY WARRANTY; without even the implied warranty of
267- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
268- * GNU General Public License for more details.
269- *
270- * You should have received a copy of the GNU General Public License
271- * along with this program. If not, see <http://www.gnu.org/licenses/>.
272- */
273-
274-import QtQuick 2.0
275-
276-Item {
277- id: scrollTracker
278-
279- property var webview
280- property var header
281-
282- readonly property bool nearTop: webview ? webview.contentY < (internal.headerHeight / internal.contentRatio) : false
283- readonly property bool nearBottom: webview ? (webview.contentY + internal.viewportHeight + internal.headerHeight / internal.contentRatio) > internal.contentHeight : false
284-
285- property bool active: true
286-
287- signal scrolledUp()
288- signal scrolledDown()
289-
290- enabled: false
291- visible: false
292-
293- QtObject {
294- id: internal
295-
296- readonly property real headerHeight: scrollTracker.header ? scrollTracker.header.height : 0
297- readonly property real headerVisibleHeight: scrollTracker.header ? scrollTracker.header.visibleHeight : 0
298-
299- readonly property real contentHeight: scrollTracker.webview ? scrollTracker.webview.contentHeight + headerVisibleHeight : 0.0
300- readonly property real viewportHeight: scrollTracker.webview ? scrollTracker.webview.viewportHeight + headerVisibleHeight : 0.0
301- readonly property real maxContentY: scrollTracker.webview ? scrollTracker.webview.contentHeight - scrollTracker.webview.viewportHeight : 0.0
302-
303- readonly property real contentRatio: scrollTracker.webview ? scrollTracker.webview.viewportHeight / scrollTracker.webview.contentHeight : 1.0
304-
305- readonly property real currentScrollFraction: (maxContentY == 0.0) ? 0.0 : (scrollTracker.webview.contentY / maxContentY)
306- property real previousScrollFraction: 0.0
307- }
308-
309- Connections {
310- target: scrollTracker.active ? scrollTracker.webview : null
311- onContentYChanged: {
312- var old = internal.previousScrollFraction
313- internal.previousScrollFraction = internal.currentScrollFraction
314- if (internal.currentScrollFraction < old) {
315- scrollTracker.scrolledUp()
316- } else if (internal.currentScrollFraction > old) {
317- scrollTracker.scrolledDown()
318- }
319- }
320- }
321-}
322
323=== modified file 'src/app/webbrowser/Browser.qml'
324--- src/app/webbrowser/Browser.qml 2015-03-23 07:49:13 +0000
325+++ src/app/webbrowser/Browser.qml 2015-03-31 14:57:27 +0000
326@@ -103,13 +103,16 @@
327 anchors {
328 left: parent.left
329 right: parent.right
330- top: recentView.visible ? invisibleTabChrome.bottom : chrome.bottom
331+ top: recentView.visible ? invisibleTabChrome.bottom : parent.top
332 }
333- height: parent.height - osk.height - (recentView.visible ? invisibleTabChrome.height : chrome.visibleHeight)
334+ height: parent.height - osk.height - (recentView.visible ? invisibleTabChrome.height : 0)
335 }
336
337 Loader {
338- anchors.fill: tabContainer
339+ anchors {
340+ fill: tabContainer
341+ topMargin: (chrome.state == "shown") ? chrome.height : 0
342+ }
343 sourceComponent: ErrorSheet {
344 visible: currentWebview ? currentWebview.lastLoadFailed : false
345 url: currentWebview ? currentWebview.url : ""
346@@ -119,7 +122,10 @@
347 }
348
349 Loader {
350- anchors.fill: tabContainer
351+ anchors {
352+ fill: tabContainer
353+ topMargin: (chrome.state == "shown") ? chrome.height : 0
354+ }
355 sourceComponent: InvalidCertificateErrorSheet {
356 visible: currentWebview && currentWebview.certificateError != null
357 certificateError: currentWebview ? currentWebview.certificateError : null
358@@ -149,6 +155,8 @@
359 webview: browser.currentWebview
360 searchUrl: searchEngine.urlTemplate
361
362+ y: webview ? webview.locationBarController.offset : 0
363+
364 function isCurrentUrlBookmarked() {
365 return ((webview && browser.bookmarksModel) ? browser.bookmarksModel.contains(webview.url) : false)
366 }
367@@ -217,29 +225,6 @@
368 onTriggered: browser.openUrlInNewTab("", true)
369 }
370 ]
371-
372- Connections {
373- target: browser.currentWebview
374- onLoadingStateChanged: {
375- if (browser.currentWebview.loading) {
376- chrome.state = "shown"
377- } else if (browser.currentWebview.fullscreen) {
378- chrome.state = "hidden"
379- }
380- }
381- onFullscreenChanged: {
382- if (browser.currentWebview.fullscreen) {
383- chrome.state = "hidden"
384- } else {
385- chrome.state = "shown"
386- }
387- }
388- }
389- }
390-
391- ChromeStateTracker {
392- webview: browser.currentWebview
393- header: chrome
394 }
395
396 Suggestions {
397@@ -367,7 +352,6 @@
398 }
399
400 function reset() {
401- chrome.state = "shown"
402 state = ""
403 recentToolbar.state = "hidden"
404 tabslist.reset()
405@@ -390,9 +374,7 @@
406
407 onDraggingChanged: {
408 if (!dragging) {
409- if (stage == 0) {
410- chrome.state = "shown"
411- } else if (stage == 1) {
412+ if (stage == 1) {
413 if (tabsModel.count > 1) {
414 tabslist.selectAndAnimateTab(1)
415 } else {
416@@ -416,7 +398,7 @@
417 anchors {
418 horizontalCenter: parent.horizontalCenter
419 bottom: parent.bottom
420- bottomMargin: (chrome.state == "hidden") ? -height : 0
421+ bottomMargin: (chrome.state == "shown") ? 0 : -height
422 Behavior on bottomMargin {
423 UbuntuNumberAnimation {}
424 }
425@@ -517,6 +499,17 @@
426
427 enabled: visible && !bottomEdgeHandle.dragging && !recentView.visible
428
429+ ChromeController {
430+ id: chromeController
431+ webview: webviewimpl
432+ forceHide: recentView.visible
433+ }
434+
435+ locationBarController {
436+ height: webviewimpl.visible ? chrome.height : 0
437+ mode: chromeController.mode
438+ }
439+
440 //experimental.preferences.developerExtrasEnabled: developerExtrasEnabled
441 preferences.localStorageEnabled: true
442 preferences.appCacheEnabled: true
443@@ -624,7 +617,10 @@
444 id: newTabViewComponent
445
446 NewTabView {
447- anchors.fill: parent
448+ anchors {
449+ fill: parent
450+ topMargin: (chrome.state == "shown") ? chrome.height : 0
451+ }
452
453 historyModel: browser.historyModel
454 bookmarksModel: browser.bookmarksModel
455
456=== modified file 'src/app/webcontainer/WebApp.qml'
457--- src/app/webcontainer/WebApp.qml 2015-02-19 11:50:21 +0000
458+++ src/app/webcontainer/WebApp.qml 2015-03-31 14:57:27 +0000
459@@ -73,14 +73,17 @@
460 left: parent.left
461 right: parent.right
462 top: parent.top
463- topMargin: webapp.chromeless ? 0 : chromeLoader.item.visibleHeight
464+ topMargin: (webapp.oxide || webapp.chromeless) ? 0 : chromeLoader.item.height
465 }
466- height: parent.height - osk.height - (webapp.chromeless ? 0 : chromeLoader.item.visibleHeight)
467+ height: parent.height - osk.height
468 developerExtrasEnabled: webapp.developerExtrasEnabled
469 }
470
471 Loader {
472- anchors.fill: webview
473+ anchors {
474+ fill: webview
475+ topMargin: (webapp.oxide && !webapp.chromeless && chromeLoader.item.state == "shown") ? chromeLoader.item.height : 0
476+ }
477 sourceComponent: ErrorSheet {
478 visible: webview.currentWebview && webview.currentWebview.lastLoadFailed
479 url: webview.currentWebview ? webview.currentWebview.url : ""
480@@ -115,25 +118,7 @@
481 right: parent.right
482 }
483 height: units.gu(6)
484-
485- Connections {
486- target: webapp.currentWebview
487- ignoreUnknownSignals: true
488- onLoadingStateChanged: {
489- if (webapp.currentWebview.loading) {
490- chromeLoader.item.state = "shown"
491- } else if (webapp.currentWebview.fullscreen) {
492- chromeLoader.item.state = "hidden"
493- }
494- }
495- onFullscreenChanged: {
496- if (webapp.currentWebview.fullscreen) {
497- chromeLoader.item.state = "hidden"
498- } else {
499- chromeLoader.item.state = "shown"
500- }
501- }
502- }
503+ y: (webapp.oxide && webapp.currentWebview) ? webview.currentWebview.locationBarController.offset : 0
504 }
505 }
506
507@@ -152,18 +137,34 @@
508 }
509 }
510
511+ Binding {
512+ when: webapp.oxide && webapp.currentWebview && !webapp.chromeless
513+ target: (webapp.oxide && webapp.currentWebview) ? webapp.currentWebview.locationBarController : null
514+ property: 'height'
515+ value: webapp.currentWebview.visible ? chromeLoader.item.height : 0
516+ }
517+
518 Loader {
519- sourceComponent: (webapp.oxide && !webapp.chromeless) ? chromeStateTrackerComponent : undefined
520+ id: oxideChromeController
521+
522+ sourceComponent: webapp.oxide ? oxideChromeControllerComponent : undefined
523
524 Component {
525- id: chromeStateTrackerComponent
526+ id: oxideChromeControllerComponent
527
528- ChromeStateTracker {
529+ ChromeController {
530 webview: webapp.currentWebview
531- header: chromeLoader.item
532+ forceHide: webapp.chromeless
533 }
534 }
535 }
536+
537+ Binding {
538+ when: webapp.oxide && webapp.currentWebview
539+ target: (webapp.oxide && webapp.currentWebview) ? webapp.currentWebview.locationBarController : null
540+ property: 'mode'
541+ value: webapp.oxide ? oxideChromeController.item.mode : 0
542+ }
543 }
544
545 UnityWebApps.UnityWebApps {

Subscribers

People subscribed via source and target branches

to status/vote changes: