diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2018-02-26 12:48:03 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-04-06 06:36:24 +0000 |
commit | 3bc5b9d4f9d481707c02e83e0cd20f60dec425f2 (patch) | |
tree | f29ba0036095fcf178133281be582d5fe650814b /src/core/web_contents_adapter.h | |
parent | fbfc9ee7f06c6f36b79145bc7e8ba05c5d3fa621 (diff) |
Avoid creating temporary blank WebContents
- Avoid creating a blank WebContents for new QWebEnginePages only to replace it
with a different blank WebContents moments later. This problem is already
solved in QQuickWebEngineView by lazy initialization, therefore the patch
moves this lazy initialization into WebContentsAdapter itself so that it can
be applied to both QQuickWebEngineView and QWebEnginePage.
- Try to delay WebContents creation until the first navigation so that we have
enough information available to pick the right initial SiteInstance when
calling WebContents::Create. This is done by triggering WebContents creation
from the first call to a WebContentsAdapter::load* method.
- Use the SiteInstance from WebContentsDelegate::OpenURLFromTab. This method
gets a SiteInstance pointer which we should give to WebContents::Create.
Task-number: QTBUG-65561
Task-number: QTBUG-67163
Change-Id: Id7b351998adefb810cf27c61a1447b61d7f4c606
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/web_contents_adapter.h')
-rw-r--r-- | src/core/web_contents_adapter.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 54b07b4ff..f42dea394 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -52,6 +52,8 @@ namespace content { class WebContents; struct WebPreferences; +struct OpenURLParams; +class SiteInstance; } QT_BEGIN_NAMESPACE @@ -78,7 +80,18 @@ public: // Takes ownership of the WebContents. WebContentsAdapter(content::WebContents *webContents = 0); ~WebContentsAdapter(); - void initialize(WebContentsAdapterClient *adapterClient); + + void setClient(WebContentsAdapterClient *adapterClient); + + bool isInitialized() const; + + // These and only these methods will initialize the WebContentsAdapter. All + // other methods below will do nothing until one of these has been called. + void loadDefault(); + void load(const QUrl &url); + void load(const QWebEngineHttpRequest &request); + void setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl); + void reattachRWHV(); bool canGoBack() const; @@ -86,9 +99,6 @@ public: void stop(); void reload(); void reloadAndBypassCache(); - void load(const QUrl &url); - void load(const QWebEngineHttpRequest &request); - void setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl); void save(const QString &filePath = QString(), int savePageFormat = -1); QUrl activeUrl() const; QUrl requestedUrl() const; @@ -183,15 +193,15 @@ public: bool colorMode = true, bool useCustomMargins = true); - // meant to be used within WebEngineCore only - content::WebContents *webContents() const; void replaceMisspelling(const QString &word); - void viewSource(); bool canViewSource(); void focusIfNecessary(); bool isFindTextInProgress() const; + // meant to be used within WebEngineCore only + void initialize(content::SiteInstance *site); + content::WebContents *webContents() const; private: Q_DISABLE_COPY(WebContentsAdapter) |