diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/chromium_overrides.cpp | 30 | ||||
-rw-r--r-- | src/core/chromium_overrides.h | 54 | ||||
-rw-r--r-- | src/core/compositor/delegated_frame_node.cpp | 2 | ||||
-rw-r--r-- | src/core/core_chromium.pri | 1 | ||||
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 127 | ||||
-rw-r--r-- | src/core/render_widget_host_view_qt.h | 15 | ||||
-rw-r--r-- | src/core/render_widget_host_view_qt_delegate.h | 7 | ||||
-rw-r--r-- | src/core/type_conversion.h | 5 | ||||
-rw-r--r-- | src/webengine/render_widget_host_view_qt_delegate_quick.cpp | 32 | ||||
-rw-r--r-- | src/webengine/render_widget_host_view_qt_delegate_quick.h | 4 | ||||
-rw-r--r-- | src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp | 9 | ||||
-rw-r--r-- | src/webengine/render_widget_host_view_qt_delegate_quickwindow.h | 3 | ||||
-rw-r--r-- | src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp | 24 | ||||
-rw-r--r-- | src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h | 4 |
14 files changed, 89 insertions, 228 deletions
diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp index c25d6dda9..09058301b 100644 --- a/src/core/chromium_overrides.cpp +++ b/src/core/chromium_overrides.cpp @@ -37,8 +37,6 @@ ** ****************************************************************************/ -#include "chromium_overrides.h" - #include "ozone/gl_context_qt.h" #include "qtwebenginecoreglobal_p.h" #include "web_contents_view_qt.h" @@ -72,27 +70,6 @@ #include "net/ssl/openssl_client_key_store.h" #endif -namespace QtWebEngineCore { -void GetScreenInfoFromNativeWindow(QWindow* window, content::ScreenInfo* results) -{ - QScreen* screen = window->screen(); - if (!screen) - return; - content::ScreenInfo r; - r.device_scale_factor = screen->devicePixelRatio(); - r.depth_per_component = 8; - r.depth = screen->depth(); - r.is_monochrome = (r.depth == 1); - - QRect screenGeometry = screen->geometry(); - r.rect = gfx::Rect(screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height()); - QRect available = screen->availableGeometry(); - r.available_rect = gfx::Rect(available.x(), available.y(), available.width(), available.height()); - *results = r; -} - -} // namespace QtWebEngineCore - void *GetQtXDisplay() { return GLContextHelper::getXDisplay(); @@ -113,13 +90,6 @@ WebContentsView* CreateWebContentsView(WebContentsImpl *web_contents, return rv; } -// static -void WebContentsView::GetDefaultScreenInfo(content::ScreenInfo* results) -{ - QWindow dummy; - QtWebEngineCore::GetScreenInfoFromNativeWindow(&dummy, results); -} - #if defined(Q_OS_MACOS) std::string getQtPrefix() { diff --git a/src/core/chromium_overrides.h b/src/core/chromium_overrides.h deleted file mode 100644 index b27bf309c..000000000 --- a/src/core/chromium_overrides.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CHROMIUM_OVERRIDES_H -#define CHROMIUM_OVERRIDES_H - -#include "content/public/common/screen_info.h" -#include <QtGlobal> - -QT_BEGIN_NAMESPACE -class QWindow; -QT_END_NAMESPACE - -namespace QtWebEngineCore { -void GetScreenInfoFromNativeWindow(QWindow* window, content::ScreenInfo* results); -} - -#endif diff --git a/src/core/compositor/delegated_frame_node.cpp b/src/core/compositor/delegated_frame_node.cpp index e2b6714a1..4fb05051b 100644 --- a/src/core/compositor/delegated_frame_node.cpp +++ b/src/core/compositor/delegated_frame_node.cpp @@ -619,7 +619,7 @@ void DelegatedFrameNode::commit(const viz::CompositorFrame &pendingFrame, QScopedPointer<DelegatedNodeTreeHandler> nodeHandler; - const QSizeF viewportSizeInPt = apiDelegate->screenRect().size(); + const QSizeF viewportSizeInPt = apiDelegate->viewGeometry().size(); const QSizeF viewportSizeF = viewportSizeInPt * devicePixelRatio; const QSize viewportSize(std::ceil(viewportSizeF.width()), std::ceil(viewportSizeF.height())); diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 27b6e4190..f4cb8c9da 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -149,7 +149,6 @@ HEADERS = \ browser_message_filter_qt.h \ certificate_error_controller_p.h \ certificate_error_controller.h \ - chromium_overrides.h \ client_cert_select_controller.h \ clipboard_qt.h \ command_line_pref_store_qt.h \ diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 0217bed59..9791c8c46 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -40,7 +40,6 @@ #include "render_widget_host_view_qt.h" #include "browser_accessibility_manager_qt.h" -#include "chromium_overrides.h" #include "compositor/compositor.h" #include "qtwebenginecoreglobal_p.h" #include "render_widget_host_view_qt_delegate.h" @@ -67,7 +66,6 @@ #include "ui/events/gesture_detection/gesture_configuration.h" #include "ui/events/gesture_detection/gesture_provider_config_helper.h" #include "ui/events/gesture_detection/motion_event.h" -#include "ui/gfx/geometry/size_conversions.h" #include "ui/gfx/image/image_skia.h" #include "ui/touch_selection/touch_selection_controller.h" @@ -248,6 +246,22 @@ private: int index; }; +static content::ScreenInfo screenInfoFromQScreen(QScreen *screen) +{ + content::ScreenInfo r; + if (screen) { + r.device_scale_factor = screen->devicePixelRatio(); + r.depth_per_component = 8; + r.depth = screen->depth(); + r.is_monochrome = (r.depth == 1); + r.rect = toGfx(screen->geometry()); + r.available_rect = toGfx(screen->availableGeometry()); + } else { + r.device_scale_factor = qGuiApp->devicePixelRatio(); + } + return r; +} + RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget) : content::RenderWidgetHostViewBase::RenderWidgetHostViewBase(widget) , m_gestureProvider(QtGestureProviderConfig(), this) @@ -264,7 +278,6 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget , m_cursorPosition(0) , m_emptyPreviousSelection(true) , m_wheelAckPending(false) - , m_pendingResize(false) , m_mouseWheelPhaseHandler(this) // This frame-sink id is based on what RenderWidgetHostViewChildFrame does: , m_frameSinkId(base::checked_cast<uint32_t>(widget->GetProcess()->GetID()), @@ -303,6 +316,7 @@ RenderWidgetHostViewQt::~RenderWidgetHostViewQt() void RenderWidgetHostViewQt::setDelegate(RenderWidgetHostViewQtDelegate* delegate) { m_delegate.reset(delegate); + visualPropertiesChanged(); } void RenderWidgetHostViewQt::setAdapterClient(WebContentsAdapterClient *adapterClient) @@ -329,30 +343,16 @@ void RenderWidgetHostViewQt::InitAsFullscreen(content::RenderWidgetHostView*) { } -void RenderWidgetHostViewQt::SetSize(const gfx::Size& size) +void RenderWidgetHostViewQt::SetSize(const gfx::Size &sizeInDips) { - int width = size.width(); - int height = size.height(); - - m_delegate->resize(width,height); + m_delegate->resize(sizeInDips.width(), sizeInDips.height()); } -void RenderWidgetHostViewQt::SetBounds(const gfx::Rect& screenRect) +void RenderWidgetHostViewQt::SetBounds(const gfx::Rect &windowRectInDips) { - // This is called when webkit has sent us a Move message. - if (IsPopup()) - m_delegate->move(toQt(screenRect.origin())); - SetSize(screenRect.size()); -} - -gfx::Size RenderWidgetHostViewQt::GetCompositorViewportPixelSize() const -{ - if (!m_delegate || !m_delegate->window() || !m_delegate->window()->screen()) - return gfx::Size(); - - const QScreen* screen = m_delegate->window()->screen(); - gfx::SizeF size = toGfx(m_delegate->screenRect().size()); - return gfx::ToCeiledSize(gfx::ScaleSize(size, screen->devicePixelRatio())); + DCHECK(IsPopup()); + m_delegate->move(toQt(windowRectInDips.origin())); + m_delegate->resize(windowRectInDips.width(), windowRectInDips.height()); } gfx::NativeView RenderWidgetHostViewQt::GetNativeView() const @@ -431,10 +431,7 @@ bool RenderWidgetHostViewQt::IsShowing() // Retrieve the bounds of the View, in screen coordinates. gfx::Rect RenderWidgetHostViewQt::GetViewBounds() const { - QRectF p = m_delegate->contentsRect(); - gfx::Point p1(floor(p.x()), floor(p.y())); - gfx::Point p2(ceil(p.right()), ceil(p.bottom())); - return gfx::BoundingRect(p1, p2); + return m_viewRectInDips; } void RenderWidgetHostViewQt::UpdateBackgroundColor() @@ -588,15 +585,13 @@ void RenderWidgetHostViewQt::DisplayCursor(const content::WebCursor &webCursor) } #if defined(USE_AURA) if (auraType != ui::CursorType::kNull) { - QWindow *window = m_delegate->window(); - qreal windowDpr = window ? window->devicePixelRatio() : 1.0f; int resourceId; gfx::Point hotspot; // GetCursorDataFor only knows hotspots for 1x and 2x cursor images, in physical pixels. - qreal hotspotDpr = windowDpr <= 1.0f ? 1.0f : 2.0f; + qreal hotspotDpr = m_screenInfo.device_scale_factor <= 1.0f ? 1.0f : 2.0f; if (ui::GetCursorDataFor(ui::CursorSize::kNormal, auraType, hotspotDpr, &resourceId, &hotspot)) { if (const gfx::ImageSkia *imageSkia = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resourceId)) { - QImage imageQt = toQImage(imageSkia->GetRepresentation(windowDpr)); + QImage imageQt = toQImage(imageSkia->GetRepresentation(m_screenInfo.device_scale_factor)); // Convert hotspot coordinates into device-independent pixels. qreal hotX = hotspot.x() / hotspotDpr; @@ -693,28 +688,16 @@ void RenderWidgetHostViewQt::SubmitCompositorFrame(const viz::LocalSurfaceId &lo m_adapterClient->updateScrollPosition(toQt(m_lastScrollOffset)); if (contentsSizeChanged) m_adapterClient->updateContentsSize(toQt(m_lastContentsSize)); - - if (m_pendingResize && host()) { - if (host()->SynchronizeVisualProperties()) - m_pendingResize = false; - } } void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo *results) const { - QWindow *window = m_delegate->window(); - if (!window) - return; - GetScreenInfoFromNativeWindow(window, results); + *results = m_screenInfo; } gfx::Rect RenderWidgetHostViewQt::GetBoundsInRootWindow() { - if (!m_delegate->window()) - return gfx::Rect(); - - QRect r = m_delegate->window()->frameGeometry(); - return gfx::Rect(r.x(), r.y(), r.width(), r.height()); + return m_windowRectInDips; } void RenderWidgetHostViewQt::ClearCompositorFrame() @@ -922,15 +905,7 @@ viz::ScopedSurfaceIdAllocator RenderWidgetHostViewQt::DidUpdateVisualProperties( void RenderWidgetHostViewQt::OnDidUpdateVisualPropertiesComplete(const cc::RenderFrameMetadata &metadata) { - if (metadata.local_surface_id) - m_localSurfaceIdAllocator.UpdateFromChild(*metadata.local_surface_id); - - m_localSurfaceIdAllocator.GenerateId(); - host()->SendScreenRects(); - if (m_pendingResize) { - if (host()->SynchronizeVisualProperties()) - m_pendingResize = false; - } + synchronizeVisualProperties(metadata.local_surface_id); } QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode) @@ -938,13 +913,6 @@ QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode) return m_compositor->updatePaintNode(oldNode, m_delegate.get()); } -void RenderWidgetHostViewQt::notifyResize() -{ - m_pendingResize = true; - if (host()->SynchronizeVisualProperties()) - m_pendingResize = false; -} - void RenderWidgetHostViewQt::notifyShown() { host()->WasShown(false); @@ -955,17 +923,26 @@ void RenderWidgetHostViewQt::notifyHidden() host()->WasHidden(); } -void RenderWidgetHostViewQt::windowBoundsChanged() +void RenderWidgetHostViewQt::visualPropertiesChanged() { - host()->SendScreenRects(); - if (m_delegate && m_delegate->window()) - host()->NotifyScreenInfoChanged(); -} + if (!m_delegate) + return; -void RenderWidgetHostViewQt::windowChanged() -{ - if (m_delegate && m_delegate->window()) - host()->NotifyScreenInfoChanged(); + gfx::Rect oldViewRect = m_viewRectInDips; + m_viewRectInDips = toGfx(m_delegate->viewGeometry().toAlignedRect()); + + gfx::Rect oldWindowRect = m_windowRectInDips; + QWindow *window = m_delegate->window(); + m_windowRectInDips = window ? toGfx(window->frameGeometry()) : gfx::Rect(); + + content::ScreenInfo oldScreenInfo = m_screenInfo; + m_screenInfo = screenInfoFromQScreen(window ? window->screen() : nullptr); + + if (m_viewRectInDips != oldViewRect || m_windowRectInDips != oldWindowRect) + host()->SendScreenRects(); + + if (m_viewRectInDips.size() != oldViewRect.size() || m_screenInfo != oldScreenInfo) + synchronizeVisualProperties(base::nullopt); } bool RenderWidgetHostViewQt::forwardEvent(QEvent *event) @@ -1749,4 +1726,14 @@ void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation() } } +void RenderWidgetHostViewQt::synchronizeVisualProperties(const base::Optional<viz::LocalSurfaceId> &childSurfaceId) +{ + if (childSurfaceId) + m_localSurfaceIdAllocator.UpdateFromChild(*childSurfaceId); + else + m_localSurfaceIdAllocator.GenerateId(); + + host()->SynchronizeVisualProperties(); +} + } // namespace QtWebEngineCore diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index f7bd82f03..70b4f509e 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -124,7 +124,6 @@ public: void InitAsFullscreen(content::RenderWidgetHostView*) override; void SetSize(const gfx::Size& size) override; void SetBounds(const gfx::Rect&) override; - gfx::Size GetCompositorViewportPixelSize() const override; gfx::NativeView GetNativeView() const override; gfx::NativeViewAccessible GetNativeViewAccessible() override; void Focus() override; @@ -176,11 +175,9 @@ public: // Overridden from RenderWidgetHostViewQtDelegateClient. QSGNode *updatePaintNode(QSGNode *) override; - void notifyResize() override; void notifyShown() override; void notifyHidden() override; - void windowBoundsChanged() override; - void windowChanged() override; + void visualPropertiesChanged() override; bool forwardEvent(QEvent *) override; QVariant inputMethodQuery(Qt::InputMethodQuery query) override; void closePopup() override; @@ -234,13 +231,20 @@ private: void processMotionEvent(const ui::MotionEvent &motionEvent); void clearPreviousTouchMotionState(); QList<QTouchEvent::TouchPoint> mapTouchPointIds(const QList<QTouchEvent::TouchPoint> &inputPoints); - void updateNeedsBeginFramesInternal(); bool IsPopup() const; void selectionChanged(); content::RenderFrameHost *getFocusedFrameHost(); + void synchronizeVisualProperties(const base::Optional<viz::LocalSurfaceId> &childSurfaceId); + + // Geometry of the view in screen DIPs. + gfx::Rect m_viewRectInDips; + // Geometry of the window, including frame, in screen DIPs. + gfx::Rect m_windowRectInDips; + content::ScreenInfo m_screenInfo; + ui::FilteredGestureProvider m_gestureProvider; base::TimeDelta m_eventsToNowDelta; bool m_sendMotionActionDown; @@ -274,7 +278,6 @@ private: bool m_imeHasHiddenTextCapability; bool m_wheelAckPending; - bool m_pendingResize; QList<blink::WebMouseWheelEvent> m_pendingWheelEvents; content::MouseWheelPhaseHandler m_mouseWheelPhaseHandler; viz::FrameSinkId m_frameSinkId; diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h index 5ce595502..e2c98360d 100644 --- a/src/core/render_widget_host_view_qt_delegate.h +++ b/src/core/render_widget_host_view_qt_delegate.h @@ -78,11 +78,9 @@ class QWEBENGINECORE_PRIVATE_EXPORT RenderWidgetHostViewQtDelegateClient { public: virtual ~RenderWidgetHostViewQtDelegateClient() { } virtual QSGNode *updatePaintNode(QSGNode *) = 0; - virtual void notifyResize() = 0; virtual void notifyShown() = 0; virtual void notifyHidden() = 0; - virtual void windowBoundsChanged() = 0; - virtual void windowChanged() = 0; + virtual void visualPropertiesChanged() = 0; virtual bool forwardEvent(QEvent *) = 0; virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) = 0; virtual void closePopup() = 0; @@ -92,8 +90,7 @@ class QWEBENGINECORE_PRIVATE_EXPORT RenderWidgetHostViewQtDelegate { public: virtual ~RenderWidgetHostViewQtDelegate() { } virtual void initAsPopup(const QRect&) = 0; - virtual QRectF screenRect() const = 0; - virtual QRectF contentsRect() const = 0; + virtual QRectF viewGeometry() const = 0; virtual void setKeyboardFocus() = 0; virtual bool hasKeyboardFocus() = 0; virtual void lockMouse() = 0; diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h index 96b4ecadc..7b1f1b4d6 100644 --- a/src/core/type_conversion.h +++ b/src/core/type_conversion.h @@ -172,6 +172,11 @@ inline gfx::SizeF toGfx(const QSizeF& size) return gfx::SizeF(size.width(), size.height()); } +inline gfx::Rect toGfx(const QRect &rect) +{ + return gfx::Rect(rect.x(), rect.y(), rect.width(), rect.height()); +} + inline QSizeF toQt(const gfx::SizeF &size) { return QSizeF(size.width(), size.height()); diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp index 2f65db97a..ba7e99c47 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp @@ -99,19 +99,9 @@ void RenderWidgetHostViewQtDelegateQuick::initAsPopup(const QRect &r) setVisible(true); } -QRectF RenderWidgetHostViewQtDelegateQuick::screenRect() const +QRectF RenderWidgetHostViewQtDelegateQuick::viewGeometry() const { - QPointF pos = mapToScene(QPointF(0,0)); - return QRectF(pos.x(), pos.y(), width(), height()); -} - -QRectF RenderWidgetHostViewQtDelegateQuick::contentsRect() const -{ - QPointF scenePoint = mapToScene(QPointF(0, 0)); - QPointF screenPos; - if (window()) - screenPos = window()->mapToGlobal(scenePoint.toPoint()); - return QRectF(screenPos.x(), screenPos.y(), width(), height()); + return QRectF(mapToGlobal(QPointF(0, 0)), size()); } void RenderWidgetHostViewQtDelegateQuick::setKeyboardFocus() @@ -322,16 +312,7 @@ void RenderWidgetHostViewQtDelegateQuick::inputMethodEvent(QInputMethodEvent *ev void RenderWidgetHostViewQtDelegateQuick::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { QQuickItem::geometryChanged(newGeometry, oldGeometry); - - if (window()) { - const QPointF globalPos = QQuickItem::mapToGlobal(position()); - if (globalPos != m_lastGlobalPos) { - m_lastGlobalPos = globalPos; - m_client->windowBoundsChanged(); - } - } - - m_client->notifyResize(); + m_client->visualPropertiesChanged(); } void RenderWidgetHostViewQtDelegateQuick::itemChange(ItemChange change, const ItemChangeData &value) @@ -347,8 +328,7 @@ void RenderWidgetHostViewQtDelegateQuick::itemChange(ItemChange change, const It if (!m_isPopup) m_windowConnections.append(connect(value.window, SIGNAL(closing(QQuickCloseEvent *)), SLOT(onHide()))); } - - m_client->windowChanged(); + m_client->visualPropertiesChanged(); } else if (change == QQuickItem::ItemVisibleHasChanged) { if (!m_isPopup && !value.boolValue) onHide(); @@ -362,9 +342,7 @@ QSGNode *RenderWidgetHostViewQtDelegateQuick::updatePaintNode(QSGNode *oldNode, void RenderWidgetHostViewQtDelegateQuick::onWindowPosChanged() { - if (window()) - m_lastGlobalPos = QQuickItem::mapToGlobal(position()); - m_client->windowBoundsChanged(); + m_client->visualPropertiesChanged(); } void RenderWidgetHostViewQtDelegateQuick::onHide() diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h index d4d64804a..4edf37cff 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.h +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h @@ -59,8 +59,7 @@ public: ~RenderWidgetHostViewQtDelegateQuick(); void initAsPopup(const QRect&) override; - QRectF screenRect() const override; - QRectF contentsRect() const override; + QRectF viewGeometry() const override; void setKeyboardFocus() override; bool hasKeyboardFocus() override; void lockMouse() override; @@ -113,7 +112,6 @@ private: RenderWidgetHostViewQtDelegateClient *m_client; QList<QMetaObject::Connection> m_windowConnections; bool m_isPopup; - QPointF m_lastGlobalPos; QQuickWebEngineView *m_view = nullptr; }; diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp index d3c88148e..3c6c743e0 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp @@ -62,14 +62,9 @@ void RenderWidgetHostViewQtDelegateQuickWindow::initAsPopup(const QRect &screenR show(); } -QRectF RenderWidgetHostViewQtDelegateQuickWindow::screenRect() const +QRectF RenderWidgetHostViewQtDelegateQuickWindow::viewGeometry() const { - return QRectF(x(), y(), width(), height()); -} - -QRectF RenderWidgetHostViewQtDelegateQuickWindow::contentsRect() const -{ - return geometry(); + return m_realDelegate->viewGeometry(); } void RenderWidgetHostViewQtDelegateQuickWindow::show() diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h index 36e4ddd8a..039f6102a 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h +++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h @@ -56,8 +56,7 @@ public: ~RenderWidgetHostViewQtDelegateQuickWindow(); void initAsPopup(const QRect&) override; - QRectF screenRect() const override; - QRectF contentsRect() const override; + QRectF viewGeometry() const override; void setKeyboardFocus() override {} bool hasKeyboardFocus() override { return false; } void lockMouse() override {} diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 5b464a461..efdfb17d0 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -233,15 +233,9 @@ void RenderWidgetHostViewQtDelegateWidget::closeEvent(QCloseEvent *event) m_client->closePopup(); } -QRectF RenderWidgetHostViewQtDelegateWidget::screenRect() const +QRectF RenderWidgetHostViewQtDelegateWidget::viewGeometry() const { - return QRectF(x(), y(), width(), height()); -} - -QRectF RenderWidgetHostViewQtDelegateWidget::contentsRect() const -{ - QPointF pos = mapToGlobal(QPoint(0, 0)); - return QRectF(pos.x(), pos.y(), width(), height()); + return QRectF(mapToGlobal(pos()), size()); } void RenderWidgetHostViewQtDelegateWidget::setKeyboardFocus() @@ -378,14 +372,7 @@ QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQ void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent) { QQuickWidget::resizeEvent(resizeEvent); - - const QPoint globalPos = mapToGlobal(pos()); - if (globalPos != m_lastGlobalPos) { - m_lastGlobalPos = globalPos; - m_client->windowBoundsChanged(); - } - - m_client->notifyResize(); + m_client->visualPropertiesChanged(); } void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event) @@ -401,7 +388,7 @@ void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event) m_windowConnections.append(connect(w, SIGNAL(xChanged(int)), SLOT(onWindowPosChanged()))); m_windowConnections.append(connect(w, SIGNAL(yChanged(int)), SLOT(onWindowPosChanged()))); } - m_client->windowChanged(); + m_client->visualPropertiesChanged(); m_client->notifyShown(); } @@ -497,8 +484,7 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event) void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged() { - m_lastGlobalPos = mapToGlobal(pos()); - m_client->windowBoundsChanged(); + m_client->visualPropertiesChanged(); } } // namespace QtWebEngineCore diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h index c1cd90093..a736aa5cf 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h @@ -66,8 +66,7 @@ public: ~RenderWidgetHostViewQtDelegateWidget(); void initAsPopup(const QRect&) override; - QRectF screenRect() const override; - QRectF contentsRect() const override; + QRectF viewGeometry() const override; void setKeyboardFocus() override; bool hasKeyboardFocus() override; void lockMouse() override; @@ -111,7 +110,6 @@ private: QScopedPointer<QQuickItem> m_rootItem; bool m_isPopup; QColor m_clearColor; - QPoint m_lastGlobalPos; QList<QMetaObject::Connection> m_windowConnections; QWebEnginePage *m_page = nullptr; QMetaObject::Connection m_parentDestroyedConnection; |