summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-09 16:00:17 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-12 09:05:16 +0000
commit8ce1b9e5d67f1789a45d8d73960a892f77f34b06 (patch)
tree7117d1078477d51161e1ecb00d82c84b9ccdb5f0 /src/core
parent70558b6850ff6ca5289f5a0fbbd6729a72291cf3 (diff)
Add scrollPosition API
Adds an API to read the main-frame scrollPosition. In QtWebKit this property used to be in QWebFrame. Task-number: QTBUG-48323 Change-Id: Ic8312afac0dcdcfd8c7fd4589be774d327bb6268 Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/render_widget_host_view_qt.cpp4
-rw-r--r--src/core/type_conversion.h5
-rw-r--r--src/core/web_contents_adapter.cpp8
-rw-r--r--src/core/web_contents_adapter.h2
-rw-r--r--src/core/web_contents_adapter_client.h1
5 files changed, 20 insertions, 0 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 26ea4f4ae..bf0e80be9 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -628,6 +628,7 @@ bool RenderWidgetHostViewQt::HasAcceleratedSurface(const gfx::Size&)
void RenderWidgetHostViewQt::OnSwapCompositorFrame(uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame)
{
+ bool scrollOffsetChanged = (m_lastScrollOffset != frame->metadata.root_scroll_offset);
m_lastScrollOffset = frame->metadata.root_scroll_offset;
Q_ASSERT(!m_needsDelegatedFrameAck);
m_needsDelegatedFrameAck = true;
@@ -648,6 +649,9 @@ void RenderWidgetHostViewQt::OnSwapCompositorFrame(uint32 output_surface_id, sco
m_adapterClient->loadVisuallyCommitted();
m_didFirstVisuallyNonEmptyLayout = false;
}
+
+ if (scrollOffsetChanged)
+ m_adapterClient->updateScrollPosition(toQt(m_lastScrollOffset));
}
void RenderWidgetHostViewQt::GetScreenInfo(blink::WebScreenInfo* results)
diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h
index 9e5461888..0cefeb07a 100644
--- a/src/core/type_conversion.h
+++ b/src/core/type_conversion.h
@@ -94,6 +94,11 @@ inline QPoint toQt(const gfx::Point &point)
return QPoint(point.x(), point.y());
}
+inline QPointF toQt(const gfx::Vector2dF &point)
+{
+ return QPointF(point.x(), point.y());
+}
+
inline gfx::Point toGfx(const QPoint& point)
{
return gfx::Point(point.x(), point.y());
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 2b2512fc3..8f69fb92c 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -829,6 +829,14 @@ void WebContentsAdapter::wasHidden()
d->webContents->WasHidden();
}
+QPointF WebContentsAdapter::lastScrollOffset() const
+{
+ Q_D(const WebContentsAdapter);
+ if (content::RenderWidgetHostView *rwhv = d->webContents->GetRenderWidgetHostView())
+ return toQt(rwhv->GetLastScrollOffset());
+ return QPointF();
+}
+
void WebContentsAdapter::grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags)
{
Q_D(WebContentsAdapter);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index ecb084e56..39cc48834 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -143,6 +143,8 @@ public:
QWebChannel *webChannel() const;
void setWebChannel(QWebChannel *);
+ QPointF lastScrollOffset() const;
+
// meant to be used within WebEngineCore only
content::WebContents *webContents() const;
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 3ae84f9c8..94c6835ed 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -236,6 +236,7 @@ public:
virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) = 0;
virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) = 0;
+ virtual void updateScrollPosition(const QPointF &position) = 0;
virtual BrowserContextAdapter* browserContextAdapter() = 0;