diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/qt')
14 files changed, 227 insertions, 69 deletions
diff --git a/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp b/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp index 60736b1df..8969bbbe3 100644 --- a/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp @@ -27,6 +27,7 @@ #include "MessageID.h" #include "ShareableBitmap.h" #include "TextureMapperGL.h" +#include "TextureMapperQt.h" #include "UpdateInfo.h" #include "WebCoreArgumentCoders.h" #include "WebLayerTreeInfo.h" @@ -57,6 +58,8 @@ public: virtual Type type() const = 0; }; +using namespace WebCore; + template<class MessageData, LayerTreeMessageToRenderer::Type messageType> class LayerTreeMessageToRendererWithData : public LayerTreeMessageToRenderer { public: @@ -94,7 +97,7 @@ struct UpdateTileMessageData { int remoteTileID; IntRect sourceRect; IntRect targetRect; - QImage image; + RefPtr<ShareableBitmap> bitmap; }; struct RemoveTileMessageData { @@ -104,7 +107,7 @@ struct RemoveTileMessageData { struct CreateImageMessageData { int64_t imageID; - QImage image; + RefPtr<ShareableBitmap> bitmap; }; struct DestroyImageMessageData { @@ -165,10 +168,11 @@ LayerTreeHostProxy::~LayerTreeHostProxy() } // This function needs to be reentrant. -void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity) +void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect) { if (!m_textureMapper) m_textureMapper = TextureMapperGL::create(); + ASSERT(dynamic_cast<TextureMapperGL*>(m_textureMapper.get())); syncRemoteContent(); GraphicsLayer* currentRootLayer = rootLayer(); @@ -182,11 +186,11 @@ void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& mat GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); - IntRect viewportRect(viewport[0], viewport[1], viewport[2], viewport[3]); m_textureMapper->setViewportSize(IntSize(viewport[2], viewport[3])); node->setTextureMapper(m_textureMapper.get()); m_textureMapper->beginPainting(); m_textureMapper->bindSurface(0); + m_textureMapper->beginClip(TransformationMatrix(), clipRect); if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) { currentRootLayer->setOpacity(opacity); @@ -194,20 +198,8 @@ void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& mat currentRootLayer->syncCompositingStateForThisLayerOnly(); } - TextureMapperNode::NodeRectMap nodeVisualContentsRectMap; - if (node->collectVisibleContentsRects(nodeVisualContentsRectMap, viewportRect)) { - TextureMapperNode::NodeRectMap::iterator endIterator = nodeVisualContentsRectMap.end(); - for (TextureMapperNode::NodeRectMap::iterator it = nodeVisualContentsRectMap.begin(); it != endIterator; ++it) { - WebLayerID layerID = it->first->id(); - // avoid updating non-synced root layer - if (!layerID) - continue; - IntRect visibleRect = IntRect(it->second); - setVisibleContentsRectForLayer(layerID, visibleRect); - } - } node->paint(); - + m_textureMapper->endClip(); m_textureMapper->endPainting(); if (node->descendantsOrSelfHaveRunningAnimations()) { @@ -216,6 +208,28 @@ void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& mat } } +void LayerTreeHostProxy::paintToGraphicsContext(QPainter* painter) +{ + if (!m_textureMapper) + m_textureMapper = TextureMapperQt::create(); + ASSERT(dynamic_cast<TextureMapperQt*>(m_textureMapper.get())); + + syncRemoteContent(); + TextureMapperNode* node = toTextureMapperNode(rootLayer()); + + if (!node) + return; + + GraphicsContext graphicsContext(painter); + m_textureMapper->setGraphicsContext(&graphicsContext); + m_textureMapper->beginPainting(); + m_textureMapper->bindSurface(0); + node->paint(); + m_textureMapper->endPainting(); + m_textureMapper->setGraphicsContext(0); +} + + void LayerTreeHostProxy::didFireViewportUpdateTimer(Timer<LayerTreeHostProxy>*) { updateViewport(); @@ -226,11 +240,6 @@ void LayerTreeHostProxy::updateViewport() m_drawingAreaProxy->updateViewport(); } -void LayerTreeHostProxy::setVisibleContentsRectForLayer(WebLayerID layerID, const IntRect& rect) -{ - m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectForLayer(layerID, rect), m_drawingAreaProxy->page()->pageID()); -} - int LayerTreeHostProxy::remoteTileIDToNodeTileID(int tileID) const { HashMap<int, int>::const_iterator it = m_tileToNodeTile.find(tileID); @@ -245,6 +254,7 @@ void LayerTreeHostProxy::syncLayerParameters(const WebLayerInfo& layerInfo) ensureLayer(id); LayerMap::iterator it = m_layers.find(id); GraphicsLayer* layer = it->second; + bool needsToUpdateImageTiles = layerInfo.imageIsUpdated || layerInfo.contentsRect != layer->contentsRect(); layer->setName(layerInfo.name); @@ -261,7 +271,7 @@ void LayerTreeHostProxy::syncLayerParameters(const WebLayerInfo& layerInfo) layer->setContentsRect(layerInfo.contentsRect); layer->setDrawsContent(layerInfo.drawsContent); - if (layerInfo.imageIsUpdated) + if (needsToUpdateImageTiles) assignImageToLayer(layer, layerInfo.imageBackingStoreID); // Never make the root layer clip. @@ -366,7 +376,7 @@ void LayerTreeHostProxy::removeTile(WebLayerID layerID, int tileID) m_tileToNodeTile.remove(tileID); } -void LayerTreeHostProxy::updateTile(WebLayerID layerID, int tileID, const IntRect& sourceRect, const IntRect& targetRect, const QImage& image) +void LayerTreeHostProxy::updateTile(WebLayerID layerID, int tileID, const IntRect& sourceRect, const IntRect& targetRect, ShareableBitmap* bitmap) { ensureLayer(layerID); TextureMapperNode* node = toTextureMapperNode(layerByID(layerID)); @@ -377,15 +387,16 @@ void LayerTreeHostProxy::updateTile(WebLayerID layerID, int tileID, const IntRec if (!nodeTileID) return; - QImage imageRef(image); node->setTextureMapper(m_textureMapper.get()); - node->setContentsTileBackBuffer(nodeTileID, sourceRect, targetRect, imageRef.bits(), BitmapTexture::BGRAFormat); + QImage image = bitmap->createQImage(); + node->setContentsTileBackBuffer(nodeTileID, sourceRect, targetRect, image.constBits()); } -void LayerTreeHostProxy::createImage(int64_t imageID, const QImage& image) +void LayerTreeHostProxy::createImage(int64_t imageID, ShareableBitmap* bitmap) { TiledImage tiledImage; static const int TileDimension = 1024; + QImage image = bitmap->createQImage(); bool imageHasAlpha = image.hasAlphaChannel(); IntRect imageRect(0, 0, image.width(), image.height()); for (int y = 0; y < image.height(); y += TileDimension) { @@ -399,13 +410,12 @@ void LayerTreeHostProxy::createImage(int64_t imageID, const QImage& image) subImage = image.copy(rect); RefPtr<BitmapTexture> texture = m_textureMapper->createTexture(); texture->reset(rect.size(), !imageHasAlpha); - texture->updateContents(imageHasAlpha ? BitmapTexture::BGRAFormat : BitmapTexture::BGRFormat, IntRect(IntPoint::zero(), rect.size()), subImage.bits()); + texture->updateRawContents(IntRect(IntPoint::zero(), rect.size()), subImage.constBits()); tiledImage.add(rect.location(), texture); } } - m_directlyCompositedImages.remove(imageID); - m_directlyCompositedImages.add(imageID, tiledImage); + m_directlyCompositedImages.set(imageID, tiledImage); } void LayerTreeHostProxy::destroyImage(int64_t imageID) @@ -447,6 +457,8 @@ void LayerTreeHostProxy::assignImageToLayer(GraphicsLayer* layer, int64_t imageI void LayerTreeHostProxy::flushLayerChanges() { m_rootLayer->syncCompositingState(FloatRect()); + // The pending tiles state is on its way for the screen, tell the web process to render the next one. + m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID()); } void LayerTreeHostProxy::ensureRootLayer() @@ -504,18 +516,18 @@ void LayerTreeHostProxy::syncRemoteContent() case LayerTreeMessageToRenderer::UpdateTile: { const UpdateTileMessageData& data = static_cast<UpdateTileMessage*>(nextMessage.get())->data(); - updateTile(data.layerID, data.remoteTileID, data.sourceRect, data.targetRect, data.image); + updateTile(data.layerID, data.remoteTileID, data.sourceRect, data.targetRect, data.bitmap.get()); break; } case LayerTreeMessageToRenderer::CreateImage: { const CreateImageMessageData& data = static_cast<CreateImageMessage*>(nextMessage.get())->data(); - createImage(data.imageID, data.image); + createImage(data.imageID, data.bitmap.get()); break; } case LayerTreeMessageToRenderer::DestroyImage: { - const CreateImageMessageData& data = static_cast<CreateImageMessage*>(nextMessage.get())->data(); + const DestroyImageMessageData& data = static_cast<DestroyImageMessage*>(nextMessage.get())->data(); destroyImage(data.imageID); break; } @@ -548,8 +560,7 @@ void LayerTreeHostProxy::updateTileForLayer(int layerID, int tileID, const WebKi UpdateTileMessageData data; data.layerID = layerID; data.remoteTileID = tileID; - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle); - data.image = bitmap->createQImage().copy(); + data.bitmap = ShareableBitmap::create(updateInfo.bitmapHandle); data.sourceRect = IntRect(IntPoint::zero(), updateInfo.updateRectBounds.size()); data.targetRect = updateInfo.updateRectBounds; pushUpdateToQueue(UpdateTileMessage::create(data)); @@ -587,7 +598,6 @@ void LayerTreeHostProxy::syncCompositingLayerState(const WebLayerInfo& info) void LayerTreeHostProxy::didRenderFrame() { - m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID()); pushUpdateToQueue(FlushLayerChangesMessage::create()); updateViewport(); } @@ -595,9 +605,8 @@ void LayerTreeHostProxy::didRenderFrame() void LayerTreeHostProxy::createDirectlyCompositedImage(int64_t key, const WebKit::ShareableBitmap::Handle& handle) { CreateImageMessageData data; - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle); data.imageID = key; - data.image = bitmap->createQImage().copy(); + data.bitmap = ShareableBitmap::create(handle); pushUpdateToQueue(CreateImageMessage::create(data)); } diff --git a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp index 32de21af7..f7e2b8514 100644 --- a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp +++ b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp @@ -69,6 +69,64 @@ private: QString m_defaultValue; }; +class AuthenticationDialogContextObject : public QObject { + Q_OBJECT + Q_PROPERTY(QString hostname READ hostname CONSTANT) + Q_PROPERTY(QString realm READ realm CONSTANT) + Q_PROPERTY(QString prefilledUsername READ prefilledUsername CONSTANT) + +public: + AuthenticationDialogContextObject(const QString& hostname, const QString& realm, const QString& prefilledUsername) + : QObject() + , m_hostname(hostname) + , m_realm(realm) + , m_prefilledUsername(prefilledUsername) + { + } + + QString hostname() const { return m_hostname; } + QString realm() const { return m_realm; } + QString prefilledUsername() const { return m_prefilledUsername; } + +public slots: + void accept(const QString& username, const QString& password) { emit accepted(username, password); } + void reject() { emit rejected(); } + +signals: + void accepted(const QString& username, const QString& password); + void rejected(); + +private: + QString m_hostname; + QString m_realm; + QString m_prefilledUsername; +}; + +class CertificateVerificationDialogContextObject : public QObject { + Q_OBJECT + Q_PROPERTY(QString hostname READ hostname CONSTANT) + +public: + CertificateVerificationDialogContextObject(const QString& hostname) + : QObject() + , m_hostname(hostname) + { + } + + QString hostname() const { return m_hostname; } + +public slots: + void accept() { emit accepted(); } + void reject() { emit rejected(); } + +signals: + void accepted(); + void rejected(); + +private: + QString m_hostname; +}; + bool QtDialogRunner::initForAlert(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& message) { DialogContextObject* contextObject = new DialogContextObject(message); @@ -103,6 +161,32 @@ bool QtDialogRunner::initForPrompt(QDeclarativeComponent* component, QQuickItem* return true; } +bool QtDialogRunner::initForAuthentication(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& hostname, const QString& realm, const QString& prefilledUsername) +{ + AuthenticationDialogContextObject* contextObject = new AuthenticationDialogContextObject(hostname, realm, prefilledUsername); + if (!createDialog(component, dialogParent, contextObject)) + return false; + + connect(contextObject, SIGNAL(accepted(QString, QString)), SLOT(onAuthenticationAccepted(QString, QString))); + connect(contextObject, SIGNAL(accepted(QString, QString)), SLOT(quit())); + connect(contextObject, SIGNAL(rejected()), SLOT(quit())); + + return true; +} + +bool QtDialogRunner::initForCertificateVerification(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& hostname) +{ + CertificateVerificationDialogContextObject* contextObject = new CertificateVerificationDialogContextObject(hostname); + if (!createDialog(component, dialogParent, contextObject)) + return false; + + connect(contextObject, SIGNAL(accepted()), SLOT(onAccepted())); + connect(contextObject, SIGNAL(accepted()), SLOT(quit())); + connect(contextObject, SIGNAL(rejected()), SLOT(quit())); + + return true; +} + bool QtDialogRunner::createDialog(QDeclarativeComponent* component, QQuickItem* dialogParent, QObject* contextObject) { QDeclarativeContext* baseContext = component->creationContext(); diff --git a/Source/WebKit2/UIProcess/qt/QtDialogRunner.h b/Source/WebKit2/UIProcess/qt/QtDialogRunner.h index bfa530264..96dcea27f 100644 --- a/Source/WebKit2/UIProcess/qt/QtDialogRunner.h +++ b/Source/WebKit2/UIProcess/qt/QtDialogRunner.h @@ -38,12 +38,17 @@ public: bool initForAlert(QDeclarativeComponent*, QQuickItem* dialogParent, const QString& message); bool initForConfirm(QDeclarativeComponent*, QQuickItem* dialogParent, const QString& message); bool initForPrompt(QDeclarativeComponent*, QQuickItem* dialogParent, const QString& message, const QString& defaultValue); + bool initForAuthentication(QDeclarativeComponent*, QQuickItem* dialogParent, const QString& hostname, const QString& realm, const QString& prefilledUsername); + bool initForCertificateVerification(QDeclarativeComponent*, QQuickItem*, const QString& hostname); QQuickItem* dialog() const { return m_dialog.get(); } bool wasAccepted() const { return m_wasAccepted; } QString result() const { return m_result; } + QString username() const { return m_username; } + QString password() const { return m_password; } + public slots: void onAccepted(const QString& result = QString()) { @@ -51,6 +56,12 @@ public slots: m_result = result; } + void onAuthenticationAccepted(const QString& username, const QString& password) + { + m_username = username; + m_password = password; + } + private: bool createDialog(QDeclarativeComponent*, QQuickItem* dialogParent, QObject* contextObject); @@ -58,6 +69,9 @@ private: OwnPtr<QQuickItem> m_dialog; QString m_result; bool m_wasAccepted; + + QString m_username; + QString m_password; }; #endif // QtDialogRunner_h diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp index cc96876be..cdc863b61 100644 --- a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp @@ -62,7 +62,7 @@ PassOwnPtr<DrawingAreaProxy> QtPageClient::createDrawingAreaProxy() void QtPageClient::setViewNeedsDisplay(const WebCore::IntRect& rect) { - m_webView->page()->update(); + QQuickWebViewPrivate::get(m_webView)->setNeedsDisplay(); } void QtPageClient::pageDidRequestScroll(const IntPoint& pos) @@ -100,11 +100,27 @@ void QtPageClient::handleDownloadRequest(DownloadProxy* download) QQuickWebViewPrivate::get(m_webView)->handleDownloadRequest(download); } -void QtPageClient::handleApplicationSchemeRequest(PassRefPtr<QtNetworkRequestData> requestData) +void QtPageClient::handleApplicationSchemeRequest(PassRefPtr<QtRefCountedNetworkRequestData> requestData) { if (!m_webView || !m_webView->experimental()) return; - m_webView->experimental()->invokeApplicationSchemeHandler(requestData.get()); + m_webView->experimental()->invokeApplicationSchemeHandler(requestData); +} + +void QtPageClient::handleAuthenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password) +{ + QString qUsername; + QString qPassword; + + QQuickWebViewPrivate::get(m_webView)->handleAuthenticationRequiredRequest(hostname, realm, prefilledUsername, qUsername, qPassword); + + username = qUsername; + password = qPassword; +} + +void QtPageClient::handleCertificateVerificationRequest(const String& hostname, bool& ignoreErrors) +{ + ignoreErrors = QQuickWebViewPrivate::get(m_webView)->handleCertificateVerificationRequest(hostname); } void QtPageClient::setCursor(const WebCore::Cursor& cursor) @@ -184,12 +200,6 @@ void QtPageClient::didFindZoomableArea(const IntPoint& target, const IntRect& ar m_eventHandler->didFindZoomableArea(target, area); } -void QtPageClient::focusEditableArea(const IntRect& caret, const IntRect& area) -{ - ASSERT(m_eventHandler); - m_eventHandler->focusEditableArea(caret, area); -} - void QtPageClient::didReceiveMessageFromNavigatorQtObject(const String& message) { QQuickWebViewPrivate::get(m_webView)->didReceiveMessageFromNavigatorQtObject(message); diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.h b/Source/WebKit2/UIProcess/qt/QtPageClient.h index 7715026f8..43050f502 100644 --- a/Source/WebKit2/UIProcess/qt/QtPageClient.h +++ b/Source/WebKit2/UIProcess/qt/QtPageClient.h @@ -53,7 +53,9 @@ public: virtual void didRelaunchProcess(); virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); virtual void handleDownloadRequest(DownloadProxy*); - virtual void handleApplicationSchemeRequest(PassRefPtr<QtNetworkRequestData>); + virtual void handleApplicationSchemeRequest(PassRefPtr<QtRefCountedNetworkRequestData>); + virtual void handleAuthenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password); + virtual void handleCertificateVerificationRequest(const String& hostname, bool& ignoreErrors); virtual void displayView(); virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); @@ -92,7 +94,6 @@ public: virtual void findStringInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { } virtual void countStringMatchesInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { } virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&); - virtual void focusEditableArea(const WebCore::IntRect&, const WebCore::IntRect&); virtual void updateTextInputState(); virtual void doneWithGestureEvent(const WebGestureEvent&, bool wasEventHandled); virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled); diff --git a/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp index 2ed773c11..7032220d5 100644 --- a/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp +++ b/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp @@ -35,7 +35,6 @@ QtTapGestureRecognizer::QtTapGestureRecognizer(QtWebPageEventHandler* eventHandl : QtGestureRecognizer(eventHandler) , m_tapState(NoTap) { - reset(); } bool QtTapGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTimestampMillis) @@ -68,6 +67,11 @@ bool QtTapGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTim } else m_tapState = SingleTapStarted; m_touchBeginEventForTap = adoptPtr(new QTouchEvent(*event)); + + if (m_tapState == SingleTapStarted) { + const QTouchEvent::TouchPoint& touchPoint = event->touchPoints().first(); + m_eventHandler->handlePotentialSingleTapEvent(touchPoint); + } break; case QEvent::TouchUpdate: // If the touch point moves further than the threshold, we cancel the tap gesture. @@ -82,6 +86,7 @@ bool QtTapGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTim break; case QEvent::TouchEnd: m_tapAndHoldTimer.stop(); + m_eventHandler->handlePotentialSingleTapEvent(QTouchEvent::TouchPoint()); switch (m_tapState) { case DoubleTapCandidate: @@ -111,6 +116,7 @@ bool QtTapGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTim default: break; } + return false; } @@ -140,6 +146,8 @@ void QtTapGestureRecognizer::tapAndHoldTimeout() void QtTapGestureRecognizer::reset() { + m_eventHandler->handlePotentialSingleTapEvent(QTouchEvent::TouchPoint()); + m_tapState = NoTap; m_touchBeginEventForTap.clear(); m_tapAndHoldTimer.stop(); diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp index d12eb0bbd..d2eb1566d 100644 --- a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp +++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp @@ -173,6 +173,9 @@ qreal QtViewportInteractionEngine::outerBoundedCSSScale(qreal cssScale) void QtViewportInteractionEngine::setItemRectVisible(const QRectF& itemRect) { + if (itemRect.isEmpty()) + return; + ViewportUpdateDeferrer guard(this); qreal itemScale = m_viewport->width() / itemRect.width(); @@ -302,6 +305,8 @@ void QtViewportInteractionEngine::wheelEvent(QWheelEvent* ev) QRectF endPosRange = computePosRangeForItemAtScale(m_content->contentScale()); m_content->setPos(-boundPosition(endPosRange.topLeft(), newPos, endPosRange.bottomRight())); + + emit visibleContentRectAndScaleChanged(); } void QtViewportInteractionEngine::pagePositionRequest(const QPoint& pagePosition) diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h index 1790c72ed..a4b699030 100644 --- a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h +++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h @@ -106,6 +106,7 @@ Q_SIGNALS: void contentResumeRequested(); void viewportTrajectoryVectorChanged(const QPointF&); + void visibleContentRectAndScaleChanged(); private Q_SLOTS: // Respond to changes of content that are not driven by us, like the page resizing itself. diff --git a/Source/WebKit2/UIProcess/qt/QtWebContext.cpp b/Source/WebKit2/UIProcess/qt/QtWebContext.cpp index 29a547ba9..df27961b5 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebContext.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebContext.cpp @@ -69,7 +69,7 @@ PassRefPtr<QtWebContext> QtWebContext::defaultContext() if (s_defaultContext) return PassRefPtr<QtWebContext>(s_defaultContext); - RefPtr<WebContext> context = WebContext::create(String()); + RefPtr<WebContext> context = WebContext::sharedProcessContext(); RefPtr<QtWebContext> defaultContext = QtWebContext::create(context.get()); s_defaultContext = defaultContext.get(); defaultContext->initialize(); diff --git a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp index 8b09b20f3..19ba336ae 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp @@ -53,11 +53,12 @@ QtWebIconDatabaseClient::QtWebIconDatabaseClient(QtWebContext *qtWebContext) iconDatabaseClient.version = kWKIconDatabaseClientCurrentVersion; iconDatabaseClient.clientInfo = this; iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL; - WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase), &iconDatabaseClient); + WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase.get()), &iconDatabaseClient); } QtWebIconDatabaseClient::~QtWebIconDatabaseClient() { + WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase.get()), 0); } void QtWebIconDatabaseClient::didChangeIconForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo) diff --git a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h index e8d056248..b2c00a8ee 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h +++ b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h @@ -58,7 +58,7 @@ private: unsigned iconURLHashForPageURL(const String&); static void didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURL, const void* clientInfo); uint64_t m_contextId; - WebKit::WebIconDatabase* m_iconDatabase; + RefPtr<WebKit::WebIconDatabase> m_iconDatabase; Mutex m_imageLock; }; diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp index e5175201a..09f896021 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp @@ -26,6 +26,7 @@ #include "NativeWebWheelEvent.h" #include "QtViewportInteractionEngine.h" #include "qquickwebpage_p.h" +#include "qquickwebview_p.h" #include <QDrag> #include <QGraphicsSceneMouseEvent> #include <QGuiApplication> @@ -84,20 +85,23 @@ static inline WebCore::DragOperation dropActionToDragOperation(Qt::DropActions a return (DragOperation)result; } -QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, QQuickWebPage* qmlWebPage) +QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, QQuickWebPage* qmlWebPage, QQuickWebView* qmlWebView) : m_webPageProxy(toImpl(pageRef)) , m_panGestureRecognizer(this) , m_pinchGestureRecognizer(this) , m_tapGestureRecognizer(this) , m_webPage(qmlWebPage) + , m_webView(qmlWebView) , m_previousClickButton(Qt::NoButton) , m_clickCount(0) , m_postponeTextInputStateChanged(false) { + connect(qApp->inputPanel(), SIGNAL(visibleChanged()), this, SLOT(inputPanelVisibleChanged())); } QtWebPageEventHandler::~QtWebPageEventHandler() { + disconnect(qApp->inputPanel(), SIGNAL(visibleChanged()), this, SLOT(inputPanelVisibleChanged())); } bool QtWebPageEventHandler::handleEvent(QEvent* ev) @@ -282,6 +286,12 @@ bool QtWebPageEventHandler::handleDropEvent(QDropEvent* ev) return accepted; } +void QtWebPageEventHandler::handlePotentialSingleTapEvent(const QTouchEvent::TouchPoint& point) +{ + QTransform fromItemTransform = m_webPage->transformFromItem(); + m_webPageProxy->handlePotentialActivation(fromItemTransform.map(point.pos()).toPoint()); +} + void QtWebPageEventHandler::handleSingleTapEvent(const QTouchEvent::TouchPoint& point) { m_postponeTextInputStateChanged = true; @@ -429,6 +439,20 @@ static void setInputPanelVisible(bool visible) qApp->inputPanel()->setVisible(visible); } +void QtWebPageEventHandler::inputPanelVisibleChanged() +{ + if (!m_interactionEngine) + return; + + // We only respond to the input panel becoming visible. + if (!m_webView->hasFocus() || !qApp->inputPanel()->visible()) + return; + + const EditorState& editor = m_webPageProxy->editorState(); + if (editor.isContentEditable) + m_interactionEngine->focusEditableArea(QRectF(editor.cursorRect), QRectF(editor.editorRect)); +} + void QtWebPageEventHandler::updateTextInputState() { if (m_postponeTextInputStateChanged) @@ -436,6 +460,11 @@ void QtWebPageEventHandler::updateTextInputState() const EditorState& editor = m_webPageProxy->editorState(); + m_webView->setInputMethodHints(Qt::InputMethodHints(editor.inputMethodHints)); + + if (!m_webView->hasFocus()) + return; + // Ignore input method requests not due to a tap gesture. if (!editor.isContentEditable) setInputPanelVisible(false); @@ -448,7 +477,7 @@ void QtWebPageEventHandler::doneWithGestureEvent(const WebGestureEvent& event, b m_postponeTextInputStateChanged = false; - if (!wasEventHandled) + if (!wasEventHandled || !m_webView->hasFocus()) return; const EditorState& editor = m_webPageProxy->editorState(); @@ -517,14 +546,6 @@ void QtWebPageEventHandler::didFindZoomableArea(const IntPoint& target, const In m_interactionEngine->zoomToAreaGestureEnded(QPointF(target), QRectF(area)); } -void QtWebPageEventHandler::focusEditableArea(const IntRect& caret, const IntRect& area) -{ - if (!m_interactionEngine) - return; - - m_interactionEngine->focusEditableArea(QRectF(caret), QRectF(area)); -} - void QtWebPageEventHandler::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage) { QImage dragQImage; diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h index f5b7fb317..ebe95dd8d 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h +++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h @@ -40,18 +40,18 @@ class QtWebPageEventHandler : public QObject { Q_OBJECT public: - QtWebPageEventHandler(WKPageRef, QQuickWebPage*); + QtWebPageEventHandler(WKPageRef, QQuickWebPage*, QQuickWebView*); ~QtWebPageEventHandler(); bool handleEvent(QEvent*); void setViewportInteractionEngine(QtViewportInteractionEngine*); + void handlePotentialSingleTapEvent(const QTouchEvent::TouchPoint&); void handleSingleTapEvent(const QTouchEvent::TouchPoint&); void handleDoubleTapEvent(const QTouchEvent::TouchPoint&); void didFindZoomableArea(const WebCore::IntPoint& target, const WebCore::IntRect& area); - void focusEditableArea(const WebCore::IntRect& caret, const WebCore::IntRect& area); void updateTextInputState(); void doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled); void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled); @@ -68,6 +68,10 @@ protected: QtPinchGestureRecognizer m_pinchGestureRecognizer; QtTapGestureRecognizer m_tapGestureRecognizer; QQuickWebPage* m_webPage; + QQuickWebView* m_webView; + +private slots: + void inputPanelVisibleChanged(); private: bool handleKeyPressEvent(QKeyEvent*); diff --git a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp index ac9fde418..bf86edce6 100644 --- a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp @@ -87,17 +87,17 @@ void WebPageProxy::registerApplicationScheme(const String& scheme) void WebPageProxy::resolveApplicationSchemeRequest(QtNetworkRequestData request) { - RefPtr<QtNetworkRequestData> requestData = adoptRef(new QtNetworkRequestData(request)); + RefPtr<QtRefCountedNetworkRequestData> requestData = adoptRef(new QtRefCountedNetworkRequestData(request)); m_applicationSchemeRequests.add(requestData); static_cast<QtPageClient*>(m_pageClient)->handleApplicationSchemeRequest(requestData); } void WebPageProxy::sendApplicationSchemeReply(const QQuickNetworkReply* reply) { - RefPtr<QtNetworkRequestData> requestData = reply->networkRequestData(); + RefPtr<QtRefCountedNetworkRequestData> requestData = reply->networkRequestData(); if (m_applicationSchemeRequests.contains(requestData)) { - RefPtr<QtNetworkReplyData> replyData = reply->networkReplyData(); - process()->send(Messages::WebPage::ApplicationSchemeReply(*replyData), pageID()); + RefPtr<QtRefCountedNetworkReplyData> replyData = reply->networkReplyData(); + process()->send(Messages::WebPage::ApplicationSchemeReply(replyData->data()), pageID()); m_applicationSchemeRequests.remove(requestData); } } |