summaryrefslogtreecommitdiff
path: root/Tools/MiniBrowser
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-06-20 13:01:08 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-06-20 13:01:08 +0200
commit49233e234e5c787396cadb2cea33b31ae0cd65c1 (patch)
tree5410cb9a8fd53168bb60d62c54b654d86f03c38d /Tools/MiniBrowser
parentb211c645d8ab690f713515dfdc84d80b11c27d2c (diff)
downloadqtwebkit-49233e234e5c787396cadb2cea33b31ae0cd65c1.tar.gz
Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813)
New snapshot with Windows build fixes
Diffstat (limited to 'Tools/MiniBrowser')
-rw-r--r--Tools/MiniBrowser/efl/CMakeLists.txt66
-rw-r--r--Tools/MiniBrowser/efl/main.c164
-rw-r--r--Tools/MiniBrowser/gtk/BrowserWindow.c34
-rw-r--r--Tools/MiniBrowser/mac/BrowserWindowController.m2
-rw-r--r--Tools/MiniBrowser/qt/MiniBrowser.qrc1
-rw-r--r--Tools/MiniBrowser/qt/MiniBrowserApplication.cpp88
-rw-r--r--Tools/MiniBrowser/qt/MiniBrowserApplication.h5
-rw-r--r--Tools/MiniBrowser/qt/icons/contents_width.pngbin0 -> 2097 bytes
-rw-r--r--Tools/MiniBrowser/qt/qml/BrowserWindow.qml23
-rw-r--r--Tools/MiniBrowser/qt/qml/ViewportInfoItem.qml184
10 files changed, 465 insertions, 102 deletions
diff --git a/Tools/MiniBrowser/efl/CMakeLists.txt b/Tools/MiniBrowser/efl/CMakeLists.txt
new file mode 100644
index 000000000..a6fd2d57e
--- /dev/null
+++ b/Tools/MiniBrowser/efl/CMakeLists.txt
@@ -0,0 +1,66 @@
+SET(MiniBrowser_DIR "${TOOLS_DIR}/MiniBrowser/efl")
+
+SET(MiniBrowser_SOURCES
+ ${MiniBrowser_DIR}/main.c
+)
+
+SET(MiniBrowser_INCLUDE_DIRECTORIES
+ ${CAIRO_INCLUDE_DIRS}
+ ${ECORE_X_INCLUDE_DIRS}
+ ${EDJE_INCLUDE_DIRS}
+ ${EFLDEPS_INCLUDE_DIRS}
+ ${EVAS_INCLUDE_DIRS}
+ ${WEBKIT2_DIR}/UIProcess/API/efl
+ ${WEBKIT2_DIR}
+ ${DERIVED_SOURCES_WEBKIT2_DIR}/include
+ ${CMAKE_SOURCE_DIR}/Source
+)
+
+SET(MiniBrowser_LIBRARIES
+ ${JavaScriptCore_LIBRARY_NAME}
+ ${WebCore_LIBRARY_NAME}
+ ${WebKit2_LIBRARY_NAME}
+ ${CAIRO_LIBRARIES}
+ ${ECORE_X_LIBRARIES}
+ ${EDJE_LIBRARIES}
+ ${EFLDEPS_LIBRARIES}
+ ${EVAS_LIBRARIES}
+ ${FONTCONFIG_LIBRARIES}
+ ${LIBSOUP24_LIBRARIES}
+ ${LIBXML2_LIBRARIES}
+ ${LIBXSLT_LIBRARIES}
+ ${SQLITE_LIBRARIES}
+)
+
+SET(MiniBrowser_LINK_FLAGS
+ ${ECORE_X_LDFLAGS}
+ ${EDJE_LDFLAGS}
+ ${EFLDEPS_LDFLAGS}
+ ${EVAS_LDFLAGS}
+ ${LIBSOUP24_LDFLAGS}
+)
+
+IF (ENABLE_GLIB_SUPPORT)
+ LIST(APPEND MiniBrowser_LIBRARIES
+ ${Glib_LIBRARIES}
+ ${Gthread_LIBRARIES}
+ )
+ENDIF ()
+
+ADD_CUSTOM_TARGET(forwarding-headerMiniBrowserEfl
+ COMMAND ${PERL_EXECUTABLE} ${WEBKIT2_DIR}/Scripts/generate-forwarding-headers.pl ${MiniBrowser_DIR} ${DERIVED_SOURCES_WEBKIT2_DIR}/include efl
+)
+
+ADD_CUSTOM_TARGET(forwarding-headerMiniBrowserSoup
+ COMMAND ${PERL_EXECUTABLE} ${WEBKIT2_DIR}/Scripts/generate-forwarding-headers.pl ${MiniBrowser_DIR} ${DERIVED_SOURCES_WEBKIT2_DIR}/include soup
+)
+
+INCLUDE_DIRECTORIES(${MiniBrowser_INCLUDE_DIRECTORIES})
+
+ADD_EXECUTABLE(MiniBrowser ${MiniBrowser_SOURCES})
+TARGET_LINK_LIBRARIES(MiniBrowser ${MiniBrowser_LIBRARIES})
+ADD_TARGET_PROPERTIES(MiniBrowser LINK_FLAGS "${MiniBrowser_LINK_FLAGS}")
+SET_TARGET_PROPERTIES(MiniBrowser PROPERTIES FOLDER "Tools")
+
+ADD_DEPENDENCIES(MiniBrowser forwarding-headerMiniBrowserEfl)
+ADD_DEPENDENCIES(MiniBrowser forwarding-headerMiniBrowserSoup)
diff --git a/Tools/MiniBrowser/efl/main.c b/Tools/MiniBrowser/efl/main.c
new file mode 100644
index 000000000..73c253bea
--- /dev/null
+++ b/Tools/MiniBrowser/efl/main.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "EWebKit2.h"
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Eina.h>
+#include <Evas.h>
+
+static const int DEFAULT_WIDTH = 800;
+static const int DEFAULT_HEIGHT = 600;
+static const char DEFAULT_URL[] = "http://www.google.com/";
+
+#define info(format, args...) \
+ do { \
+ if (verbose) \
+ printf(format, ##args); \
+ } while (0)
+
+static int verbose = 0;
+
+typedef struct _MiniBrowser {
+ Ecore_Evas *ee;
+ Evas *evas;
+ Evas_Object *bg;
+ Evas_Object *browser;
+} MiniBrowser;
+
+static Eina_Bool main_signal_exit(void *data, int ev_type, void *ev)
+{
+ ecore_main_loop_quit();
+ return EINA_TRUE;
+}
+
+static void on_ecore_evas_resize(Ecore_Evas *ee)
+{
+ Evas_Object *webview;
+ Evas_Object *bg;
+ int w, h;
+
+ ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
+
+ bg = evas_object_name_find(ecore_evas_get(ee), "bg");
+ evas_object_move(bg, 0, 0);
+ evas_object_resize(bg, w, h);
+
+ webview = evas_object_name_find(ecore_evas_get(ee), "browser");
+ evas_object_move(webview, 0, 0);
+ evas_object_resize(webview, w, h);
+}
+
+static void
+on_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Key_Down *ev = (Evas_Event_Key_Down*) event_info;
+ if (!strcmp(ev->key, "F1")) {
+ info("Back (F1) was pressed\n");
+ if (!ewk_view_back(obj))
+ info("Back ignored: No back history\n");
+ } else if (!strcmp(ev->key, "F2")) {
+ info("Forward (F2) was pressed\n");
+ if (!ewk_view_forward(obj))
+ info("Forward ignored: No forward history\n");
+ } else if (!strcmp(ev->key, "F5")) {
+ info("Reload (F5) was pressed, reloading.\n");
+ ewk_view_reload(obj);
+ } else if (!strcmp(ev->key, "F6")) {
+ info("Stop (F6) was pressed, stop loading.\n");
+ ewk_view_stop(obj);
+ }
+}
+
+static void
+on_title_changed(void *user_data, Evas_Object *webview, void *event_info)
+{
+ MiniBrowser *app = (MiniBrowser *)user_data;
+ const char *title = (const char *)event_info;
+
+ ecore_evas_title_set(app->ee, title);
+}
+
+static MiniBrowser *browserCreate(const char *url)
+{
+ MiniBrowser *app = malloc(sizeof(MiniBrowser));
+
+ app->ee = ecore_evas_new(0, 0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, 0);
+
+ ecore_evas_title_set(app->ee, "EFL MiniBrowser");
+ ecore_evas_callback_resize_set(app->ee, on_ecore_evas_resize);
+ ecore_evas_borderless_set(app->ee, 0);
+ ecore_evas_show(app->ee);
+
+ app->evas = ecore_evas_get(app->ee);
+
+ app->bg = evas_object_rectangle_add(app->evas);
+ evas_object_name_set(app->bg, "bg");
+ evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ evas_object_move(app->bg, 0, 0);
+ evas_object_resize(app->bg, DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ evas_object_color_set(app->bg, 255, 150, 150, 255);
+ evas_object_show(app->bg);
+
+ /* Create webview */
+ app->browser = ewk_view_add(app->evas);
+ evas_object_name_set(app->browser, "browser");
+
+ evas_object_smart_callback_add(app->browser, "title,changed", on_title_changed, app);
+
+ evas_object_event_callback_add(app->browser, EVAS_CALLBACK_KEY_DOWN, on_key_down, app);
+
+ evas_object_size_hint_weight_set(app->browser, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_resize(app->browser, DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ evas_object_show(app->browser);
+ evas_object_focus_set(app->browser, EINA_TRUE);
+
+ ewk_view_uri_set(app->browser, url);
+
+ return app;
+}
+
+int main(int argc, char *argv[])
+{
+ const char *url;
+ int args = 1;
+
+ if (!ecore_evas_init())
+ return EXIT_FAILURE;
+
+ if (args < argc)
+ url = argv[args];
+ else
+ url = DEFAULT_URL;
+
+ MiniBrowser *browser = browserCreate(url);
+
+ Ecore_Event_Handler *handle = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, 0);
+
+ ecore_main_loop_begin();
+
+ ecore_event_handler_del(handle);
+ ecore_evas_free(browser->ee);
+ free(browser);
+
+ ecore_evas_shutdown();
+
+ return 0;
+}
diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.c b/Tools/MiniBrowser/gtk/BrowserWindow.c
index 68101667d..cef9e7d46 100644
--- a/Tools/MiniBrowser/gtk/BrowserWindow.c
+++ b/Tools/MiniBrowser/gtk/BrowserWindow.c
@@ -213,6 +213,21 @@ static void backForwadlistChanged(WebKitBackForwardList *backForwadlist, WebKitB
browserWindowUpdateNavigationActions(window, backForwadlist);
}
+static void geolocationRequestDialogCallback(GtkDialog *dialog, gint response, WebKitPermissionRequest *request)
+{
+ switch (response) {
+ case GTK_RESPONSE_YES:
+ webkit_permission_request_allow(request);
+ break;
+ default:
+ webkit_permission_request_deny(request);
+ break;
+ }
+
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ g_object_unref(request);
+}
+
static void webViewClose(WebKitWebView *webView, BrowserWindow *window)
{
gtk_widget_destroy(GTK_WIDGET(window));
@@ -277,6 +292,24 @@ static gboolean webViewDecidePolicy(WebKitWebView *webView, WebKitPolicyDecision
return TRUE;
}
+static gboolean webViewDecidePermissionRequest(WebKitWebView *webView, WebKitPermissionRequest *request, BrowserWindow *window)
+{
+ if (!WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(request))
+ return FALSE;
+
+ GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ "Geolocation request");
+
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "Allow geolocation request?");
+ g_signal_connect(dialog, "response", G_CALLBACK(geolocationRequestDialogCallback), g_object_ref(request));
+ gtk_widget_show(dialog);
+
+ return TRUE;
+}
+
static void webViewMouseTargetChanged(WebKitWebView *webView, WebKitHitTestResult *hitTestResult, guint mouseModifiers, BrowserWindow *window)
{
if (!webkit_hit_test_result_context_is_link(hitTestResult)) {
@@ -434,6 +467,7 @@ static void browserWindowConstructed(GObject *gObject)
g_signal_connect(window->webView, "create", G_CALLBACK(webViewCreate), window);
g_signal_connect(window->webView, "load-failed", G_CALLBACK(webViewLoadFailed), window);
g_signal_connect(window->webView, "decide-policy", G_CALLBACK(webViewDecidePolicy), window);
+ g_signal_connect(window->webView, "permission-request", G_CALLBACK(webViewDecidePermissionRequest), window);
g_signal_connect(window->webView, "mouse-target-changed", G_CALLBACK(webViewMouseTargetChanged), window);
g_signal_connect(window->webView, "notify::zoom-level", G_CALLBACK(webViewZoomLevelChanged), window);
diff --git a/Tools/MiniBrowser/mac/BrowserWindowController.m b/Tools/MiniBrowser/mac/BrowserWindowController.m
index 131bfa4dd..5d465f6cf 100644
--- a/Tools/MiniBrowser/mac/BrowserWindowController.m
+++ b/Tools/MiniBrowser/mac/BrowserWindowController.m
@@ -612,6 +612,8 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters
0, // willGoToBackForwardListItem
0, // interactionOccurredWhileProcessUnresponsive
0, // pluginDidFail
+ 0, // didReceiveIntentForFrame
+ 0, // registerIntentServiceForFrame
};
WKPageSetPageLoaderClient(_webView.pageRef, &loadClient);
diff --git a/Tools/MiniBrowser/qt/MiniBrowser.qrc b/Tools/MiniBrowser/qt/MiniBrowser.qrc
index b5490bec1..37fb9a37c 100644
--- a/Tools/MiniBrowser/qt/MiniBrowser.qrc
+++ b/Tools/MiniBrowser/qt/MiniBrowser.qrc
@@ -2,6 +2,7 @@
<qresource prefix="/">
<file>icons/checkbox_checked.png</file>
<file>icons/checkbox_unchecked.png</file>
+ <file>icons/contents_width.png</file>
<file>icons/favicon.png</file>
<file>icons/folder.png</file>
<file>icons/info.png</file>
diff --git a/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp b/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp
index e42c558d2..b85b234e1 100644
--- a/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp
+++ b/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp
@@ -133,18 +133,6 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event)
m_holdingControl = mouseEvent->modifiers().testFlag(Qt::ControlModifier);
QTouchEvent::TouchPoint touchPoint;
-
- touchPoint.setRect(touchRectForPosition(mouseEvent->localPos()));
- touchPoint.setLastPos(m_lastPos);
- m_lastPos = mouseEvent->localPos();
-
- // Gesture recognition uses the screen position for the initial threshold
- // but since the canvas translates touch events we actually need to pass
- // the screen position as the scene position to deliver the appropriate
- // coordinates to the target.
- touchPoint.setSceneRect(touchRectForPosition(mouseEvent->screenPos()));
- touchPoint.setLastScenePos(m_lastScreenPos);
- m_lastScreenPos = mouseEvent->screenPos();
touchPoint.setPressure(1);
QEvent::Type touchType = QEvent::None;
@@ -158,12 +146,15 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event)
touchType = QEvent::TouchUpdate;
} else {
touchPoint.setState(Qt::TouchPointPressed);
- touchType = QEvent::TouchBegin;
- m_startScreenPos = mouseEvent->screenPos();
+ // Check if more buttons are held down than just the event triggering one.
+ if (mouseEvent->buttons() > mouseEvent->button())
+ touchType = QEvent::TouchUpdate;
+ else
+ touchType = QEvent::TouchBegin;
}
break;
case QEvent::MouseMove:
- if (!mouseEvent->buttons() || !m_touchPoints.contains(mouseEvent->buttons())) {
+ if (!mouseEvent->buttons()) {
// We have to swallow the event instead of propagating it,
// since we avoid sending the mouse release events and if the
// Flickable is the mouse grabber it would receive the event
@@ -176,32 +167,37 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event)
touchPoint.setState(Qt::TouchPointMoved);
break;
case QEvent::MouseButtonRelease:
- touchType = QEvent::TouchEnd;
- touchPoint.setState(Qt::TouchPointReleased);
+ // Check if any buttons are still held down after this event.
+ if (mouseEvent->buttons())
+ touchType = QEvent::TouchUpdate;
+ else
+ touchType = QEvent::TouchEnd;
touchPoint.setId(mouseEvent->button());
- if (m_holdingControl) {
- m_heldTouchPoints.insert(touchPoint.id());
-
- // We avoid sending the release event because the Flickable is
- // listening to mouse events and would start a bounce-back
- // animation if it received a mouse release.
- event->accept();
- return true;
- }
+ touchPoint.setState(Qt::TouchPointReleased);
break;
default:
Q_ASSERT_X(false, "multi-touch mocking", "unhandled event type");
}
- // Set the screen pos as the scene pos as canvas translates the touch events.
- touchPoint.setStartScenePos(m_startScreenPos);
-
- // Update current touch-point
- m_touchPoints.insert(touchPoint.id(), touchPoint);
+ // A move can have resulted in multiple buttons, so we need check them individually.
+ if (touchPoint.id() & Qt::LeftButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::LeftButton);
+ if (touchPoint.id() & Qt::MidButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::MidButton);
+ if (touchPoint.id() & Qt::RightButton)
+ updateTouchPoint(mouseEvent, touchPoint, Qt::RightButton);
+
+ if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) {
+ // We avoid sending the release event because the Flickable is
+ // listening to mouse events and would start a bounce-back
+ // animation if it received a mouse release.
+ event->accept();
+ return true;
+ }
// Update states for all other touch-points
for (QHash<int, QTouchEvent::TouchPoint>::iterator it = m_touchPoints.begin(), end = m_touchPoints.end(); it != end; ++it) {
- if (it.value().id() != touchPoint.id())
+ if (!(it.value().id() & touchPoint.id()))
it.value().setState(Qt::TouchPointStationary);
}
@@ -217,6 +213,34 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event)
return QGuiApplication::notify(target, event);
}
+void MiniBrowserApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QTouchEvent::TouchPoint touchPoint, Qt::MouseButton mouseButton)
+{
+ if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) {
+ m_heldTouchPoints.insert(mouseButton);
+ return;
+ }
+ // Gesture recognition uses the screen position for the initial threshold
+ // but since the canvas translates touch events we actually need to pass
+ // the screen position as the scene position to deliver the appropriate
+ // coordinates to the target.
+ touchPoint.setRect(touchRectForPosition(mouseEvent->localPos()));
+ touchPoint.setSceneRect(touchRectForPosition(mouseEvent->screenPos()));
+
+ if (touchPoint.state() == Qt::TouchPointPressed)
+ touchPoint.setStartScenePos(mouseEvent->screenPos());
+ else {
+ const QTouchEvent::TouchPoint& oldTouchPoint = m_touchPoints[mouseButton];
+ touchPoint.setStartScenePos(oldTouchPoint.startScenePos());
+ touchPoint.setLastPos(oldTouchPoint.pos());
+ touchPoint.setLastScenePos(oldTouchPoint.scenePos());
+ }
+
+ // Update current touch-point.
+ touchPoint.setId(mouseButton);
+ m_touchPoints.insert(mouseButton, touchPoint);
+}
+
+
bool MiniBrowserApplication::sendTouchEvent(BrowserWindow* browserWindow, QEvent::Type type, ulong timestamp)
{
static QTouchDevice* device = 0;
diff --git a/Tools/MiniBrowser/qt/MiniBrowserApplication.h b/Tools/MiniBrowser/qt/MiniBrowserApplication.h
index e58c9a196..7d3c7a4ae 100644
--- a/Tools/MiniBrowser/qt/MiniBrowserApplication.h
+++ b/Tools/MiniBrowser/qt/MiniBrowserApplication.h
@@ -101,6 +101,7 @@ public:
virtual bool notify(QObject*, QEvent*);
private:
+ void updateTouchPoint(const QMouseEvent*, QTouchEvent::TouchPoint, Qt::MouseButton);
bool sendTouchEvent(BrowserWindow*, QEvent::Type, ulong timestamp);
void handleUserOptions();
@@ -112,10 +113,6 @@ private:
int m_robotExtraTimeSeconds;
QStringList m_urls;
- QPointF m_lastPos;
- QPointF m_lastScreenPos;
- QPointF m_startScreenPos;
-
QHash<int, QTouchEvent::TouchPoint> m_touchPoints;
QSet<int> m_heldTouchPoints;
diff --git a/Tools/MiniBrowser/qt/icons/contents_width.png b/Tools/MiniBrowser/qt/icons/contents_width.png
new file mode 100644
index 000000000..f2a79ebbc
--- /dev/null
+++ b/Tools/MiniBrowser/qt/icons/contents_width.png
Binary files differ
diff --git a/Tools/MiniBrowser/qt/qml/BrowserWindow.qml b/Tools/MiniBrowser/qt/qml/BrowserWindow.qml
index 0ebf02860..77b6c369f 100644
--- a/Tools/MiniBrowser/qt/qml/BrowserWindow.qml
+++ b/Tools/MiniBrowser/qt/qml/BrowserWindow.qml
@@ -192,6 +192,27 @@ Rectangle {
}
Rectangle {
+ id: preferredMininumContentsWidthButton
+ height: parent.height
+ width: height
+ color: "#efefef"
+ opacity: { webView.experimental.preferredMinimumContentsWidth === 0 ? 0.1 : 0.6 }
+ radius: 6
+
+ Image {
+ anchors.centerIn: parent
+ source: "../icons/contents_width.png"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ webView.experimental.preferredMinimumContentsWidth = webView.experimental.preferredMinimumContentsWidth === 0 ? 980 : 0
+ }
+ }
+ }
+
+ Rectangle {
id: touchEventsButton
height: parent.height
width: height
@@ -335,6 +356,7 @@ Rectangle {
experimental.devicePixelRatio: 1.5
experimental.preferences.fullScreenEnabled: true
+ experimental.preferences.webGLEnabled: true
experimental.preferredMinimumContentsWidth: 980
experimental.itemSelector: ItemSelector { }
experimental.alertDialog: AlertDialog { }
@@ -379,5 +401,6 @@ Rectangle {
}
visible: false
test : webView.experimental.test
+ preferredMinimumContentsWidth: webView.experimental.preferredMinimumContentsWidth
}
}
diff --git a/Tools/MiniBrowser/qt/qml/ViewportInfoItem.qml b/Tools/MiniBrowser/qt/qml/ViewportInfoItem.qml
index 88ac01275..15fd97f79 100644
--- a/Tools/MiniBrowser/qt/qml/ViewportInfoItem.qml
+++ b/Tools/MiniBrowser/qt/qml/ViewportInfoItem.qml
@@ -1,84 +1,136 @@
import QtQuick 2.0
import QtWebKit 3.0
-Rectangle {
+Item {
property var test
+ property var preferredMinimumContentsWidth
- color: "black"
- opacity: 0.8
+ function formatScale(value) {
+ return "<b>" + parseFloat(value.toFixed(4)) + "</b>x";
+ }
- Item {
- anchors.fill: parent
- anchors.margins: 20
+ function formatSize(value) {
+ return "<b>" + value.width.toFixed() + "x" + value.height.toFixed() + "</b>px"
+ }
- property string fontFamily: "Nokia Pure, Helvetica"
- property color fontColor: "white"
+ function formatBool(value) {
+ return "<b>" + (value ? "yes" : "no") + "</b>"
+ }
+
+ Rectangle {
+ id: title;
+
+ anchors {
+ top: parent.top
+ left: parent.left
+ margins: 10
+ }
+
+ height: 50
+ width: 250
+
+ color: "blue"
Text {
id: viewportInfoLabel
+
+ anchors {
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ leftMargin: 10
+ }
+
text: "Viewport Info"
color: "white"
- font.family: "Nokia Pure, Helvetica"
+ font.family: "Nokia Pure"
font.pointSize: 24
}
- Text {
- id: currentScaleLabel
- anchors.top: viewportInfoLabel.bottom
- anchors.topMargin: 30
- text: "Current scale: " + parseFloat(test.contentsScale.toFixed(4))
- font.family: parent.fontFamily
- color: parent.fontColor
- }
- Text {
- id: initialScaleLabel
- anchors.top: currentScaleLabel.bottom
- text: "Initial scale: " + parseFloat(test.initialScale.toFixed(4))
- font.family: parent.fontFamily
- color: parent.fontColor
- }
- Text {
- id: minimumScaleLabel
- anchors.top: initialScaleLabel.bottom
- text: "Minimum scale: " + parseFloat(test.minimumScale.toFixed(4))
- font.family: parent.fontFamily
- color: parent.fontColor
- }
- Text {
- id: maximumScaleLabel
- anchors.top: minimumScaleLabel.bottom
- text: "Maximum scale: " + parseFloat(test.maximumScale.toFixed(4))
- font.family: parent.fontFamily
- color: parent.fontColor
- }
- Text {
- id: devicePixelRatioLabel
- anchors.top: maximumScaleLabel.bottom
- anchors.topMargin: 30
- text: "Device pixel ratio: " + parseFloat(test.devicePixelRatio.toFixed(4))
- font.family: parent.fontFamily
- color: parent.fontColor
- }
- Text {
- id: contentsSizeLabel
- anchors.top: devicePixelRatioLabel.bottom
- text: "Contents size: " + test.contentsSize.width + "x" + test.contentsSize.height
- font.family: parent.fontFamily
- color: parent.fontColor
- }
- Text {
- id: layoutSizeLabel
- anchors.top: contentsSizeLabel.bottom
- text: "Viewport layout size: " + test.layoutSize.width + "x" + test.layoutSize.height
- font.family: parent.fontFamily
- color: parent.fontColor
+ }
+
+ Rectangle {
+ color: "gray"
+ opacity: 0.9
+
+ anchors {
+ top: title.bottom
+ left: title.left
+ topMargin: 10
}
- Text {
- id: scalableLabel
- anchors.top: layoutSizeLabel.bottom
- anchors.topMargin: 30
- text: "View " + (test.isScalable ? "is " : "is not " ) + "scalable."
- font.family: parent.fontFamily
- color: parent.fontColor
+
+ width: 340
+ height: 270
+
+ Item {
+ id: textBox
+
+ anchors {
+ fill: parent
+ margins: 10
+ }
+
+ property string fontFamily: "Nokia Pure"
+ property color fontColor: "black"
+
+ Column {
+ anchors.fill: parent
+ spacing: 20
+ Column {
+ Text {
+ text: "Current scale: " + formatScale(test.contentsScale)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ }
+
+ Column {
+ Text {
+ text: "Initial scale: " + formatScale(test.initialScale)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ Text {
+ text: "Minimum scale: " + formatScale(test.minimumScale)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ Text {
+ text: "Maximum scale: " + formatScale(test.maximumScale)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ }
+
+ Column {
+ Text {
+ text: "Device pixel ratio: " + formatScale(test.devicePixelRatio)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ Text {
+ text: "Contents size: " + formatSize(test.contentsSize)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ Text {
+ text: "Viewport layout size: " + formatSize(test.layoutSize)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ }
+
+ Column {
+ Text {
+ text: "Adapt for small screens: " + formatBool(preferredMinimumContentsWidth)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ Text {
+ text: "Allows scaling: " + formatBool(test.isScalable)
+ font.family: textBox.fontFamily
+ color: textBox.fontColor
+ }
+ }
+ }
}
}
}