diff options
author | Jake Petroules <jake.petroules@qt.io> | 2016-06-13 09:01:49 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2016-06-22 01:11:23 +0000 |
commit | 130487f3aad80037b60f6fbf4be08d5db5edca8a (patch) | |
tree | c0e2492504e190fa1aa27fbd29750ae898de3bc9 | |
parent | a41750ee14febc8fbc11bcb806f631a2657b6249 (diff) |
Add a WKWebView backend.
This replaces the WebView and UIWebView backends for macOS 10.10 and
iOS 8.0 and above.
Task-number: QTBUG-48996
Change-Id: Ief1e369365b3324f747973da1d72c862aa204626
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r-- | examples/webview/minibrowser/macos/Info.plist | 32 | ||||
-rw-r--r-- | examples/webview/minibrowser/minibrowser.pro | 1 | ||||
-rw-r--r-- | src/webview/qwebview_darwin.mm | 431 | ||||
-rw-r--r-- | src/webview/qwebview_darwin_p.h | 121 | ||||
-rw-r--r-- | src/webview/qwebview_ios.mm | 55 | ||||
-rw-r--r-- | src/webview/qwebview_osx.mm | 5 | ||||
-rw-r--r-- | src/webview/webview-lib.pri | 28 |
7 files changed, 601 insertions, 72 deletions
diff --git a/examples/webview/minibrowser/macos/Info.plist b/examples/webview/minibrowser/macos/Info.plist new file mode 100644 index 0000000..332cd25 --- /dev/null +++ b/examples/webview/minibrowser/macos/Info.plist @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleExecutable</key> + <string>minibrowser</string> + <key>CFBundleIdentifier</key> + <string>sd.${PRODUCT_NAME:rfc1034identifier}</string> + <key>CFBundleDisplayName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSAppTransportSecurity</key> + <!-- NOTE! For more information, see: https://developer.apple.com/library/prerelease/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33--> + <dict> + <key>NSAllowsArbitraryLoads</key> + <true/> + </dict> +</dict> +</plist> diff --git a/examples/webview/minibrowser/minibrowser.pro b/examples/webview/minibrowser/minibrowser.pro index 4460e6a..04fe228 100644 --- a/examples/webview/minibrowser/minibrowser.pro +++ b/examples/webview/minibrowser/minibrowser.pro @@ -9,6 +9,7 @@ RESOURCES += qml.qrc EXAMPLE_FILES += doc +osx:QMAKE_INFO_PLIST = macos/Info.plist ios:QMAKE_INFO_PLIST = ios/Info.plist target.path = $$[QT_INSTALL_EXAMPLES]/webview/minibrowser diff --git a/src/webview/qwebview_darwin.mm b/src/webview/qwebview_darwin.mm new file mode 100644 index 0000000..a950c68 --- /dev/null +++ b/src/webview/qwebview_darwin.mm @@ -0,0 +1,431 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebView module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebview_darwin_p.h" +#include "qwebview_p.h" +#include "qwebviewloadrequest_p.h" + +#include <QtCore/qdatetime.h> +#include <QtCore/qmap.h> +#include <QtCore/qvariant.h> + +#include <CoreFoundation/CoreFoundation.h> +#include <WebKit/WebKit.h> + +#ifdef Q_OS_IOS +#include "qwebview_ios_p.h" + +#include <UIKit/UIKit.h> + +#import <UIKit/UIView.h> +#import <UIKit/UIWindow.h> +#import <UIKit/UIViewController.h> +#import <UIKit/UITapGestureRecognizer.h> +#import <UIKit/UIGestureRecognizerSubclass.h> +#endif + +#ifdef Q_OS_OSX +#include "qwebview_osx_p.h" + +#include <AppKit/AppKit.h> + +typedef NSView UIView; +#endif + +QT_BEGIN_NAMESPACE + +inline QSysInfo::MacVersion qt_OS_limit(QSysInfo::MacVersion osxVersion, + QSysInfo::MacVersion iosVersion) +{ +#ifdef Q_OS_OSX + Q_UNUSED(iosVersion) + return osxVersion; +#else + Q_UNUSED(osxVersion) + return iosVersion; +#endif +} + +QWebViewPrivate *QWebViewPrivate::create(QWebView *q) +{ +#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) + if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_10, QSysInfo::MV_IOS_8_0)) + return new QDarwinWebViewPrivate(q); +#endif + +#if defined(Q_OS_IOS) + return new QIosWebViewPrivate(q); +#elif defined(Q_OS_OSX) && defined(QT_WEBVIEW_EXPERIMENTAL) + return new QOsxWebViewPrivate(q); +#else + return nullptr; +#endif +} + +static inline CGRect toCGRect(const QRectF &rect) +{ + return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()); +} + +// ------------------------------------------------------------------------- + +#ifdef Q_OS_IOS +@implementation QIOSNativeViewSelectedRecognizer + +- (id)initWithQWindowControllerItem:(QNativeViewController *)item +{ + self = [super initWithTarget:self action:@selector(nativeViewSelected:)]; + if (self) { + self.cancelsTouchesInView = NO; + self.delaysTouchesEnded = NO; + m_item = item; + } + return self; +} + +- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)other +{ + Q_UNUSED(other); + return NO; +} + +- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)other +{ + Q_UNUSED(other); + return NO; +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + Q_UNUSED(touches); + Q_UNUSED(event); + self.state = UIGestureRecognizerStateRecognized; +} + +- (void)nativeViewSelected:(UIGestureRecognizer *)gestureRecognizer +{ + Q_UNUSED(gestureRecognizer); + m_item->setFocus(true); +} + +@end +#endif + +// ------------------------------------------------------------------------- + +#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) + +class QWebViewInterface; + +@interface QtWKWebViewDelegate : NSObject<WKNavigationDelegate> { + QDarwinWebViewPrivate *qDarwinWebViewPrivate; +} +- (QtWKWebViewDelegate *)initWithQAbstractWebView:(QDarwinWebViewPrivate *)webViewPrivate; +- (void)pageDone; + +// protocol: +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation; +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation; +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation + withError:(NSError *)error; +@end + +@implementation QtWKWebViewDelegate +- (QtWKWebViewDelegate *)initWithQAbstractWebView:(QDarwinWebViewPrivate *)webViewPrivate +{ + if ((self = [super init])) { + Q_ASSERT(webViewPrivate); + qDarwinWebViewPrivate = webViewPrivate; + } + return self; +} + +- (void)pageDone +{ + Q_EMIT qDarwinWebViewPrivate->loadProgressChanged(qDarwinWebViewPrivate->loadProgress()); + Q_EMIT qDarwinWebViewPrivate->titleChanged(qDarwinWebViewPrivate->title()); +} + +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation +{ + Q_UNUSED(webView); + Q_UNUSED(navigation); + // WKNavigationDelegate gives us per-frame notifications while the QWebView API + // should provide per-page notifications. Keep track of started frame loads + // and emit notifications when the final frame completes. + if (++qDarwinWebViewPrivate->requestFrameCount == 1) { + Q_EMIT qDarwinWebViewPrivate->loadingChanged( + QWebViewLoadRequestPrivate(qDarwinWebViewPrivate->url(), + QWebView::LoadStartedStatus, + QString())); + } + + Q_EMIT qDarwinWebViewPrivate->loadProgressChanged(qDarwinWebViewPrivate->loadProgress()); +} + +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation +{ + Q_UNUSED(webView); + Q_UNUSED(navigation); + if (--qDarwinWebViewPrivate->requestFrameCount == 0) { + [self pageDone]; + Q_EMIT qDarwinWebViewPrivate->loadingChanged( + QWebViewLoadRequestPrivate(qDarwinWebViewPrivate->url(), + QWebView::LoadSucceededStatus, + QString())); + } +} + +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation + withError:(NSError *)error +{ + Q_UNUSED(webView); + Q_UNUSED(navigation); + if (--qDarwinWebViewPrivate->requestFrameCount == 0) { + [self pageDone]; + NSString *errorString = [error localizedDescription]; + Q_EMIT qDarwinWebViewPrivate->loadingChanged( + QWebViewLoadRequestPrivate(qDarwinWebViewPrivate->url(), + QWebView::LoadFailedStatus, + QString::fromNSString(errorString))); + } +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change + context:(void *)context { + Q_UNUSED(object); + Q_UNUSED(change); + Q_UNUSED(context); + if ([keyPath isEqualToString:@"estimatedProgress"]) { + Q_EMIT qDarwinWebViewPrivate->loadProgressChanged(qDarwinWebViewPrivate->loadProgress()); + } +} + +@end + +QDarwinWebViewPrivate::QDarwinWebViewPrivate(QObject *p) + : QWebViewPrivate(p) + , wkWebView(nil) +#ifdef Q_OS_IOS + , m_recognizer(0) +#endif +{ + CGRect frame = CGRectMake(0.0, 0.0, 400, 400); + wkWebView = [[WKWebView alloc] initWithFrame:frame]; + wkWebView.navigationDelegate = [[QtWKWebViewDelegate alloc] initWithQAbstractWebView:this]; + [wkWebView addObserver:wkWebView.navigationDelegate forKeyPath:@"estimatedProgress" + options:NSKeyValueObservingOptions(NSKeyValueObservingOptionNew) + context:nil]; + +#ifdef Q_OS_IOS + m_recognizer = [[QIOSNativeViewSelectedRecognizer alloc] initWithQWindowControllerItem:this]; + [wkWebView addGestureRecognizer:m_recognizer]; +#endif +} + +QDarwinWebViewPrivate::~QDarwinWebViewPrivate() +{ + [wkWebView stopLoading]; + [wkWebView removeObserver:wkWebView.navigationDelegate forKeyPath:@"estimatedProgress" + context:nil]; + [wkWebView.navigationDelegate release]; + wkWebView.navigationDelegate = nil; + [wkWebView release]; +#ifdef Q_OS_IOS + [m_recognizer release]; +#endif +} + +QUrl QDarwinWebViewPrivate::url() const +{ + return QUrl::fromNSURL(wkWebView.URL); +} + +void QDarwinWebViewPrivate::setUrl(const QUrl &url) +{ + if (url.isValid()) { + requestFrameCount = 0; + [wkWebView loadRequest:[NSURLRequest requestWithURL:url.toNSURL()]]; + } +} + +void QDarwinWebViewPrivate::loadHtml(const QString &html, const QUrl &baseUrl) +{ + [wkWebView loadHTMLString:html.toNSString() baseURL:baseUrl.toNSURL()]; +} + +bool QDarwinWebViewPrivate::canGoBack() const +{ + return wkWebView.canGoBack; +} + +bool QDarwinWebViewPrivate::canGoForward() const +{ + return wkWebView.canGoForward; +} + +QString QDarwinWebViewPrivate::title() const +{ + return QString::fromNSString(wkWebView.title); +} + +int QDarwinWebViewPrivate::loadProgress() const +{ + return int(wkWebView.estimatedProgress * 100); +} + +bool QDarwinWebViewPrivate::isLoading() const +{ + return wkWebView.loading; +} + +void QDarwinWebViewPrivate::setParentView(QObject *view) +{ + m_parentView = view; + + if (!wkWebView) + return; + + QWindow *w = qobject_cast<QWindow *>(view); + if (w) { + UIView *parentView = reinterpret_cast<UIView *>(w->winId()); + [parentView addSubview:wkWebView]; + } else { + [wkWebView removeFromSuperview]; + } +} + +QObject *QDarwinWebViewPrivate::parentView() const +{ + return m_parentView; +} + +void QDarwinWebViewPrivate::setGeometry(const QRect &geometry) +{ + if (!wkWebView) + return; + + [wkWebView setFrame:toCGRect(geometry)]; +} + +void QDarwinWebViewPrivate::setVisibility(QWindow::Visibility visibility) +{ + Q_UNUSED(visibility); +} + +void QDarwinWebViewPrivate::setVisible(bool visible) +{ + [wkWebView setHidden:!visible]; +} + +void QDarwinWebViewPrivate::setFocus(bool focus) +{ + Q_EMIT requestFocus(focus); +} + +void QDarwinWebViewPrivate::goBack() +{ + [wkWebView goBack]; +} + +void QDarwinWebViewPrivate::goForward() +{ + [wkWebView goForward]; +} + +void QDarwinWebViewPrivate::stop() +{ + [wkWebView stopLoading]; +} + +void QDarwinWebViewPrivate::reload() +{ + [wkWebView reload]; +} + +QVariant fromNSNumber(const NSNumber *number) +{ + if (!number) + return QVariant(); + if (strcmp([number objCType], @encode(BOOL)) == 0) { + return QVariant::fromValue(!![number boolValue]); + } else if (strcmp([number objCType], @encode(signed char)) == 0) { + return QVariant::fromValue([number charValue]); + } else if (strcmp([number objCType], @encode(unsigned char)) == 0) { + return QVariant::fromValue([number unsignedCharValue]); + } else if (strcmp([number objCType], @encode(signed short)) == 0) { + return QVariant::fromValue([number shortValue]); + } else if (strcmp([number objCType], @encode(unsigned short)) == 0) { + return QVariant::fromValue([number unsignedShortValue]); + } else if (strcmp([number objCType], @encode(signed int)) == 0) { + return QVariant::fromValue([number intValue]); + } else if (strcmp([number objCType], @encode(unsigned int)) == 0) { + return QVariant::fromValue([number unsignedIntValue]); + } else if (strcmp([number objCType], @encode(signed long long)) == 0) { + return QVariant::fromValue([number longLongValue]); + } else if (strcmp([number objCType], @encode(unsigned long long)) == 0) { + return QVariant::fromValue([number unsignedLongLongValue]); + } else if (strcmp([number objCType], @encode(float)) == 0) { + return QVariant::fromValue([number floatValue]); + } else if (strcmp([number objCType], @encode(double)) == 0) { + return QVariant::fromValue([number doubleValue]); + } + return QVariant(); +} + +QVariant fromJSValue(id result) +{ + if ([result isKindOfClass:[NSString class]]) + return QString::fromNSString(static_cast<NSString *>(result)); + if ([result isKindOfClass:[NSNumber class]]) + return fromNSNumber(static_cast<NSNumber *>(result)); + if ([result isKindOfClass:[NSDate class]]) + return QDateTime::fromNSDate(static_cast<NSDate *>(result)); + + // JSValue also supports arrays and dictionaries, but we don't handle that yet + return QVariant(); +} + +void QDarwinWebViewPrivate::runJavaScriptPrivate(const QString &script, int callbackId) +{ + [wkWebView evaluateJavaScript:script.toNSString() completionHandler:^(id result, NSError *) { + if (callbackId != -1) + Q_EMIT javaScriptResult(callbackId, fromJSValue(result)); + }]; +} +#endif + +QT_END_NAMESPACE diff --git a/src/webview/qwebview_darwin_p.h b/src/webview/qwebview_darwin_p.h new file mode 100644 index 0000000..4bbe6ab --- /dev/null +++ b/src/webview/qwebview_darwin_p.h @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebView module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBVIEW_DARWIN_P_H +#define QWEBVIEW_DARWIN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QtGui/qwindow.h> + +#include "qwebview_p_p.h" + +#if defined(Q_OS_IOS) && defined(__OBJC__) +#include <UIKit/UIGestureRecognizer.h> + +@interface QIOSNativeViewSelectedRecognizer : UIGestureRecognizer <UIGestureRecognizerDelegate> +{ +@public + QNativeViewController *m_item; +} +- (id)initWithQWindowControllerItem:(QNativeViewController *)item; +@end +#endif + +QT_BEGIN_NAMESPACE + +Q_FORWARD_DECLARE_OBJC_CLASS(WKWebView); + +#ifdef Q_OS_IOS +Q_FORWARD_DECLARE_OBJC_CLASS(UIGestureRecognizer); +#endif + +class QDarwinWebViewPrivate : public QWebViewPrivate +{ + Q_OBJECT +public: + explicit QDarwinWebViewPrivate(QObject *p = 0); + ~QDarwinWebViewPrivate() Q_DECL_OVERRIDE; + + QUrl url() const Q_DECL_OVERRIDE; + void setUrl(const QUrl &url) Q_DECL_OVERRIDE; + bool canGoBack() const Q_DECL_OVERRIDE; + bool canGoForward() const Q_DECL_OVERRIDE; + QString title() const Q_DECL_OVERRIDE; + int loadProgress() const Q_DECL_OVERRIDE; + bool isLoading() const Q_DECL_OVERRIDE; + + void setParentView(QObject *view) Q_DECL_OVERRIDE; + QObject *parentView() const Q_DECL_OVERRIDE; + void setGeometry(const QRect &geometry) Q_DECL_OVERRIDE; + void setVisibility(QWindow::Visibility visibility) Q_DECL_OVERRIDE; + void setVisible(bool visible) Q_DECL_OVERRIDE; + void setFocus(bool focus) Q_DECL_OVERRIDE; + +public Q_SLOTS: + void goBack() Q_DECL_OVERRIDE; + void goForward() Q_DECL_OVERRIDE; + void reload() Q_DECL_OVERRIDE; + void stop() Q_DECL_OVERRIDE; + void loadHtml(const QString &html, const QUrl &baseUrl = QUrl()) Q_DECL_OVERRIDE; + +protected: + void runJavaScriptPrivate(const QString& script, + int callbackId) Q_DECL_OVERRIDE; + +public: + WKWebView *wkWebView; +#ifdef Q_OS_IOS + UIGestureRecognizer *m_recognizer; +#endif + int requestFrameCount; + QPointer<QObject> m_parentView; +}; + +QT_END_NAMESPACE + +#endif // QWEBVIEW_DARWIN_P_H diff --git a/src/webview/qwebview_ios.mm b/src/webview/qwebview_ios.mm index 3936eb4..fe0f17f 100644 --- a/src/webview/qwebview_ios.mm +++ b/src/webview/qwebview_ios.mm @@ -35,6 +35,7 @@ ****************************************************************************/ #include "qwebview_ios_p.h" +#include "qwebview_darwin_p.h" #include "qwebview_p.h" #include "qwebviewloadrequest_p.h" @@ -52,11 +53,6 @@ QT_BEGIN_NAMESPACE -QWebViewPrivate *QWebViewPrivate::create(QWebView *q) -{ - return new QIosWebViewPrivate(q); -} - static inline CGRect toCGRect(const QRectF &rect) { return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()); @@ -64,55 +60,6 @@ static inline CGRect toCGRect(const QRectF &rect) // ------------------------------------------------------------------------- -@interface QIOSNativeViewSelectedRecognizer : UIGestureRecognizer <UIGestureRecognizerDelegate> -{ -@public - QNativeViewController *m_item; -} -@end - -@implementation QIOSNativeViewSelectedRecognizer - -- (id)initWithQWindowControllerItem:(QNativeViewController *)item -{ - self = [super initWithTarget:self action:@selector(nativeViewSelected:)]; - if (self) { - self.cancelsTouchesInView = NO; - self.delaysTouchesEnded = NO; - m_item = item; - } - return self; -} - -- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)other -{ - Q_UNUSED(other); - return NO; -} - -- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)other -{ - Q_UNUSED(other); - return NO; -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - Q_UNUSED(touches); - Q_UNUSED(event); - self.state = UIGestureRecognizerStateRecognized; -} - -- (void)nativeViewSelected:(UIGestureRecognizer *)gestureRecognizer -{ - Q_UNUSED(gestureRecognizer); - m_item->setFocus(true); -} - -@end - -// ------------------------------------------------------------------------- - class QWebViewInterface; @interface QtWebViewDelegate : NSObject<UIWebViewDelegate> { diff --git a/src/webview/qwebview_osx.mm b/src/webview/qwebview_osx.mm index f50bb32..09ca4fb 100644 --- a/src/webview/qwebview_osx.mm +++ b/src/webview/qwebview_osx.mm @@ -125,11 +125,6 @@ class QOsxWebViewPrivate; @end -QWebViewPrivate *QWebViewPrivate::create(QWebView *q) -{ - return new QOsxWebViewPrivate(q); -} - QOsxWebViewPrivate::QOsxWebViewPrivate(QWebView *q) : QWebViewPrivate(q) { diff --git a/src/webview/webview-lib.pri b/src/webview/webview-lib.pri index 40e97a7..9b26626 100644 --- a/src/webview/webview-lib.pri +++ b/src/webview/webview-lib.pri @@ -41,26 +41,28 @@ android { $$COMMON_HEADERS \ qwebview_android_p.h -} else:ios { +} else:if(ios|osx_webview_experimental) { SOURCES += \ $$COMMON_SOURCES OBJECTIVE_SOURCES += \ - qwebview_ios.mm + qwebview_darwin.mm PRIVATE_HEADERS += \ $$COMMON_HEADERS \ - qwebview_ios_p.h + qwebview_darwin_p.h + LIBS_PRIVATE += -framework WebKit -} else:osx_webview_experimental { - DEFINES += QT_WEBVIEW_EXPERIMENTAL - LIBS_PRIVATE += -framework Cocoa -framework WebKit - SOURCES += \ - $$COMMON_SOURCES - OBJECTIVE_SOURCES += \ - qwebview_osx.mm - PRIVATE_HEADERS += \ - $$COMMON_HEADERS \ - qwebview_osx_p.h + ios { + LIBS_PRIVATE += -framework UIKit + PRIVATE_HEADERS += qwebview_ios_p.h + OBJECTIVE_SOURCES += qwebview_ios.mm + } + osx { + LIBS_PRIVATE += -framework AppKit + PRIVATE_HEADERS += qwebview_osx_p.h + OBJECTIVE_SOURCES += qwebview_osx.mm + osx_webview_experimental: DEFINES += QT_WEBVIEW_EXPERIMENTAL + } } else: winrt { NO_PCH_SOURCES += qwebview_winrt.cpp SOURCES += $$COMMON_SOURCES |