diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-12-18 10:25:43 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-12-18 10:46:46 +0100 |
commit | 90178924ee7dda26e5f9b07c21eb6b3c7b802c98 (patch) | |
tree | 47a4e72b173e5e2ad10aacbb726931f03e358e27 /src/core/web_contents_adapter.cpp | |
parent | 168867aac8789f00adad08e574b16569084cb9cd (diff) | |
parent | 6f9ecd0a4675b0e1a7ef6851cbda7e43c05e9536 (diff) |
Merge remote-tracking branch 'origin/5.10' into dev
Change-Id: I9ddd2bdd830a862cd81dc1af5616d43e652a1c0e
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r-- | src/core/web_contents_adapter.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 515981b1b..59a917ae2 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -94,6 +94,7 @@ #include <QPageLayout> #include <QStringList> #include <QStyleHints> +#include <QTimer> #include <QVariant> #include <QtCore/qelapsedtimer.h> #include <QtCore/qmimedata.h> @@ -601,10 +602,28 @@ void WebContentsAdapter::load(const QWebEngineHttpRequest &request) params.extra_headers += (*it).toStdString() + ": " + request.header(*it).toStdString(); } - d->webContents->GetController().LoadURLWithParams(params); - // Follow chrome::Navigate and invalidate the URL immediately. - d->webContentsDelegate->NavigationStateChanged(d->webContents.get(), content::INVALIDATE_TYPE_URL); - focusIfNecessary(); + bool resizeNeeded = false; + if (request.url().hasFragment()) { + if (content::RenderWidgetHostView *rwhv = webContents()->GetRenderWidgetHostView()) { + const gfx::Size &viewportSize = rwhv->GetVisibleViewportSize(); + resizeNeeded = (viewportSize.width() == 0 || viewportSize.height() == 0); + } + } + + auto navigate = [this, params]() { + Q_D(WebContentsAdapter); + webContents()->GetController().LoadURLWithParams(params); + // Follow chrome::Navigate and invalidate the URL immediately. + d->webContentsDelegate->NavigationStateChanged(webContents(), content::INVALIDATE_TYPE_URL); + focusIfNecessary(); + }; + + if (resizeNeeded) { + // Schedule navigation on the event loop. + QTimer::singleShot(0, navigate); + } else { + navigate(); + } } void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) |