Title: [110447] trunk
Revision
110447
Author
[email protected]
Date
2012-03-12 11:02:58 -0700 (Mon, 12 Mar 2012)

Log Message

[Qt][WK2] Add support for rudimentary scroll indicators in MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=80832

Reviewed by Tor Arne Vestbø.

Source/WebKit2:

Since the ScrollDecorator QML component requires a Flickable in its API
we need to expose the Flickable in QML for now and we also need to add
a notifier because we instantiate the internal Flickable only when the
WebView component completes construction.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewFlickablePrivate::onComponentComplete):
(QQuickWebViewExperimental::flickable):
* UIProcess/API/qt/qquickwebview_p.h:

Tools:

Add a basic scroll indicator component to MiniBrowser so that it
behaves similar to the ScrollDecorator QML component.

* MiniBrowser/qt/MiniBrowser.qrc:
* MiniBrowser/qt/qml/BrowserWindow.qml:
* MiniBrowser/qt/qml/ScrollIndicator.qml: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (110446 => 110447)


--- trunk/Source/WebKit2/ChangeLog	2012-03-12 17:50:50 UTC (rev 110446)
+++ trunk/Source/WebKit2/ChangeLog	2012-03-12 18:02:58 UTC (rev 110447)
@@ -1,3 +1,20 @@
+2012-03-12  Andras Becsi  <[email protected]>
+
+        [Qt][WK2] Add support for rudimentary scroll indicators in MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=80832
+
+        Reviewed by Tor Arne Vestbø.
+
+        Since the ScrollDecorator QML component requires a Flickable in its API
+        we need to expose the Flickable in QML for now and we also need to add
+        a notifier because we instantiate the internal Flickable only when the
+        WebView component completes construction.
+
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewFlickablePrivate::onComponentComplete):
+        (QQuickWebViewExperimental::flickable):
+        * UIProcess/API/qt/qquickwebview_p.h:
+
 2012-03-11  Timothy Hatcher  <[email protected]>
 
         Update how the Web Inspector resources are loaded.

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (110446 => 110447)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2012-03-12 17:50:50 UTC (rev 110446)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2012-03-12 18:02:58 UTC (rev 110447)
@@ -44,6 +44,7 @@
 #include "qwebpreferences_p_p.h"
 #include "qwebviewportinfo_p.h"
 
+#include <private/qquickflickable_p.h>
 #include <_javascript_Core/InitializeThreading.h>
 #include <QDeclarativeEngine>
 #include <QFileDialog>
@@ -561,7 +562,7 @@
     flickProvider = new QtFlickProvider(q, pageView.data());
 
     // Propagate flickable signals.
-    const QQuickWebViewExperimental* experimental = q->experimental();
+    QQuickWebViewExperimental* experimental = q->experimental();
     QObject::connect(flickProvider, SIGNAL(contentWidthChanged()), experimental, SIGNAL(contentWidthChanged()));
     QObject::connect(flickProvider, SIGNAL(contentHeightChanged()), experimental, SIGNAL(contentHeightChanged()));
     QObject::connect(flickProvider, SIGNAL(contentXChanged()), experimental, SIGNAL(contentXChanged()));
@@ -586,6 +587,8 @@
     _q_onVisibleChanged();
 
     QQuickWebViewPrivate::onComponentComplete();
+
+    emit experimental->flickableChanged();
 }
 
 void QQuickWebViewFlickablePrivate::loadDidSucceed()
@@ -1059,6 +1062,19 @@
     return d->flickProvider->flickableData();
 }
 
+QQuickFlickable* QQuickWebViewExperimental::flickable()
+{
+    Q_D(QQuickWebView);
+    if (!d->flickProvider)
+        return 0;
+
+    QQuickFlickable* flickableItem = qobject_cast<QQuickFlickable*>(contentItem()->parentItem());
+
+    ASSERT(flickableItem);
+
+    return flickableItem;
+}
+
 QQuickItem* QQuickWebViewExperimental::contentItem()
 {
     Q_D(QQuickWebView);

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h (110446 => 110447)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h	2012-03-12 17:50:50 UTC (rev 110446)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h	2012-03-12 18:02:58 UTC (rev 110447)
@@ -59,6 +59,7 @@
 QT_BEGIN_NAMESPACE
 class QPainter;
 class QUrl;
+class QQuickFlickable;
 QT_END_NAMESPACE
 
 
@@ -236,6 +237,7 @@
     Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
     Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
     Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
+    Q_PROPERTY(QQuickFlickable* flickable READ flickable NOTIFY flickableChanged)
     Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT)
     Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
     Q_PROPERTY(bool transparentBackground WRITE setTransparentBackground READ transparentBackground)
@@ -291,6 +293,7 @@
     void invokeApplicationSchemeHandler(WTF::PassRefPtr<WebKit::QtRefCountedNetworkRequestData>);
     void sendApplicationSchemeReply(QQuickNetworkReply*);
 
+    QQuickFlickable* flickable();
     QQuickItem* contentItem();
     qreal contentWidth() const;
     void setContentWidth(qreal);
@@ -315,6 +318,7 @@
     void postMessage(const QString&);
 
 Q_SIGNALS:
+    void flickableChanged();
     void contentWidthChanged();
     void contentHeightChanged();
     void contentXChanged();

Modified: trunk/Tools/ChangeLog (110446 => 110447)


--- trunk/Tools/ChangeLog	2012-03-12 17:50:50 UTC (rev 110446)
+++ trunk/Tools/ChangeLog	2012-03-12 18:02:58 UTC (rev 110447)
@@ -1,3 +1,17 @@
+2012-03-12  Andras Becsi  <[email protected]>
+
+        [Qt][WK2] Add support for rudimentary scroll indicators in MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=80832
+
+        Reviewed by Tor Arne Vestbø.
+
+        Add a basic scroll indicator component to MiniBrowser so that it
+        behaves similar to the ScrollDecorator QML component.
+
+        * MiniBrowser/qt/MiniBrowser.qrc:
+        * MiniBrowser/qt/qml/BrowserWindow.qml:
+        * MiniBrowser/qt/qml/ScrollIndicator.qml: Added.
+
 2012-03-12  C Anthony Risinger  <[email protected]>
 
         [GTK] r110296 included an extra $ in @$(AM_V_GEN)

Modified: trunk/Tools/MiniBrowser/qt/MiniBrowser.qrc (110446 => 110447)


--- trunk/Tools/MiniBrowser/qt/MiniBrowser.qrc	2012-03-12 17:50:50 UTC (rev 110446)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowser.qrc	2012-03-12 18:02:58 UTC (rev 110447)
@@ -19,6 +19,7 @@
         <file>qml/MockTouchPoint.qml</file>
         <file>qml/PromptDialog.qml</file>
         <file>qml/ProxyAuthenticationDialog.qml</file>
+        <file>qml/ScrollIndicator.qml</file>
         <file>qml/ViewportInfoItem.qml</file>
         <file>useragentlist.txt</file>
         <file>icons/favicon.png</file>

Modified: trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml (110446 => 110447)


--- trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml	2012-03-12 17:50:50 UTC (rev 110446)
+++ trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml	2012-03-12 18:02:58 UTC (rev 110447)
@@ -312,6 +312,10 @@
         experimental.promptDialog: PromptDialog { }
         experimental.authenticationDialog: AuthenticationDialog { }
         experimental.proxyAuthenticationDialog: ProxyAuthenticationDialog { }
+
+        ScrollIndicator {
+            flickableItem: webView.experimental.flickable
+        }
     }
 
     ViewportInfoItem {

Added: trunk/Tools/MiniBrowser/qt/qml/ScrollIndicator.qml (0 => 110447)


--- trunk/Tools/MiniBrowser/qt/qml/ScrollIndicator.qml	                        (rev 0)
+++ trunk/Tools/MiniBrowser/qt/qml/ScrollIndicator.qml	2012-03-12 18:02:58 UTC (rev 110447)
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import QtQuick 2.0
+
+Item {
+    id: root
+    z: 1
+
+    anchors.fill: parent
+
+    property Flickable flickableItem
+
+    property bool __movingHorizontally: flickableItem ? flickableItem.movingHorizontally : false
+    property bool __movingVertically: flickableItem ? flickableItem.movingVertically : false
+
+    property real __viewWidth:  flickableItem ? flickableItem.width: 0
+    property real __viewHeight:  flickableItem ? flickableItem.height: 0
+
+    property int __hideTimeout: 800
+    property real __indicatorSize: 5
+    property real __indicatorBorder: 1
+
+    Item {
+        id: horizontalIndicator
+        opacity: 0
+
+        width: __viewWidth - __indicatorSize
+        height: __indicatorSize
+
+        anchors.bottom: root.bottom
+
+        Rectangle {
+            radius: 10
+            color: "black"
+            border.color: "gray"
+            border.width: 2
+            opacity: 0.5
+            smooth: true
+
+            x: flickableItem ? flickableItem.visibleArea.xPosition * horizontalIndicator.width : 0;
+            y: 0
+
+            width: flickableItem ? flickableItem.visibleArea.widthRatio * horizontalIndicator.width: 0;
+            height: __indicatorSize
+        }
+
+        states: [
+            State {
+                name: "show"
+                when: __movingHorizontally
+                PropertyChanges {
+                    target: horizontalIndicator
+                    opacity: 1
+                }
+            }
+        ]
+
+        transitions: [
+            Transition {
+                NumberAnimation {
+                    target: horizontalIndicator
+                    properties: "opacity"
+                    duration: __hideTimeout
+                }
+            }
+        ]
+    }
+
+    Item {
+        id: verticalIndicator
+        opacity: 0
+
+        width: __indicatorSize
+        height: __viewHeight - __indicatorSize
+
+        anchors.right: root.right
+
+        Rectangle {
+            radius: 10
+            color: "black"
+            border.color: "gray"
+            border.width: 2
+            opacity: 0.5
+            smooth: true;
+
+            x: 0
+            y: flickableItem ? flickableItem.visibleArea.yPosition * verticalIndicator.height : 0;
+
+            width: __indicatorSize
+            height: flickableItem ? flickableItem.visibleArea.heightRatio * verticalIndicator.height : 0;
+        }
+
+        states: [
+            State {
+                name: "show"
+                when: __movingVertically
+                PropertyChanges {
+                    target: verticalIndicator
+                    opacity: 1
+                }
+            }
+        ]
+
+        transitions: [
+            Transition {
+                NumberAnimation {
+                    target: verticalIndicator
+                    properties: "opacity"
+                    duration: __hideTimeout
+                }
+            }
+        ]
+    }
+}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to