Project

General

Profile

Bug #799 ยป qt-fix-zoom.patch

Soren Stoutner, 05/22/2023 06:50 AM

View differences:

src/core/web_contents_delegate_qt.cpp
const base::Process &process = renderProcessHost->GetProcess();
if (process.IsValid()) {
m_viewClient->renderProcessPidChanged(process.Pid());
m_viewClient->zoomUpdateIsNeeded();
}
}
}
......
if (newHost && newHost->GetWidget() && newHost->GetWidget()->GetView()) {
auto rwhv = static_cast<RenderWidgetHostViewQt *>(newHost->GetWidget()->GetView());
m_viewClient->widgetChanged(rwhv->delegate());
m_viewClient->zoomUpdateIsNeeded();
}
}
-- a/src/webenginewidgets/api/qwebenginepage.cpp
++ b/src/webenginewidgets/api/qwebenginepage.cpp
......
#endif
if (defaultAudioMuted != adapter->isAudioMuted())
adapter->setAudioMuted(defaultAudioMuted);
if (!qFuzzyCompare(adapter->currentZoomFactor(), defaultZoomFactor))
adapter->setZoomFactor(defaultZoomFactor);
if (view)
adapter->setVisible(view->isVisible());
......
});
}
void QWebEnginePagePrivate::zoomUpdateIsNeeded()
{
Q_Q(QWebEnginePage);
q->setZoomFactor(defaultZoomFactor);
}
void QWebEnginePagePrivate::recentlyAudibleChanged(bool recentlyAudible)
{
Q_Q(QWebEnginePage);
-- a/src/webengine/api/qquickwebengineview.cpp
++ b/src/webengine/api/qquickwebengineview.cpp
......
updateEditActions();
}
void QQuickWebEngineViewPrivate::zoomUpdateIsNeeded()
{
Q_Q(QQuickWebEngineView);
q->setZoomFactor(m_zoomFactor);
}
void QQuickWebEngineViewPrivate::recentlyAudibleChanged(bool recentlyAudible)
{
Q_Q(QQuickWebEngineView);
-- a/src/webenginewidgets/api/qwebenginepage_p.h
++ b/src/webenginewidgets/api/qwebenginepage_p.h
......
void loadProgressChanged(int progress) override;
void didUpdateTargetURL(const QUrl&) override;
void selectionChanged() override;
void zoomUpdateIsNeeded() override;
void recentlyAudibleChanged(bool recentlyAudible) override;
void renderProcessPidChanged(qint64 pid) override;
QRectF viewportRect() const override;
-- a/src/webengine/api/qquickwebengineview_p_p.h
++ b/src/webengine/api/qquickwebengineview_p_p.h
......
void loadProgressChanged(int progress) override;
void didUpdateTargetURL(const QUrl&) override;
void selectionChanged() override;
void zoomUpdateIsNeeded() override;
void recentlyAudibleChanged(bool recentlyAudible) override;
void renderProcessPidChanged(qint64 pid) override;
QRectF viewportRect() const override;
-- a/src/core/web_contents_adapter_client.h
++ b/src/core/web_contents_adapter_client.h
......
virtual void loadProgressChanged(int progress) = 0;
virtual void didUpdateTargetURL(const QUrl&) = 0;
virtual void selectionChanged() = 0;
virtual void zoomUpdateIsNeeded() = 0;
virtual void recentlyAudibleChanged(bool recentlyAudible) = 0;
virtual void renderProcessPidChanged(qint64 pid) = 0;
virtual QRectF viewportRect() const = 0;
-- a/src/core/web_contents_adapter.cpp
++ b/src/core/web_contents_adapter.cpp
......
content::HostZoomMap *zoomMap = content::HostZoomMap::GetForWebContents(m_webContents.get());
if (zoomMap) {
int render_process_id = m_webContents->GetMainFrame()->GetProcess()->GetID();
int render_view_id = m_webContents->GetRenderViewHost()->GetRoutingID();
zoomMap->SetTemporaryZoomLevel(render_process_id, render_view_id, zoomLevel);
// Set the default zoom level. Chromium uses a host map to remember zoom levels for individual hosts.
// Qt WebEngine does not make use of this host map, but all the code that utilizes it still remains
// underneath. The desired behavior in Qt WebEngine is that, once a zoom level has been set on a page,
// it will remain until it is set again. To accomplish this, The default zoom level is set below.
// This triggers logic which sets the zoom for the current page. When the URL of the page changes,
// Chromium checks the zoom map (which is empty), and then resets the zoom level to the default set
// below, causing the zoom to remain constant. See <https://bugreports.qt.io/browse/QTBUG-101030>.
zoomMap->SetDefaultZoomLevel(zoomLevel);
}
}
    (1-1/1)