summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-06-11 12:57:07 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-06-11 12:57:42 +0200
commit147d70f330648acd105d6eb62493366fcf1e3abd (patch)
treeb47c0939bc7dfa155b787448da5102a10a156cfe /src
parent7f89badd0e1b71dabb5a88d1330b08ce9d8b6eb7 (diff)
parentaf1c0087e51b6e2ad905259bb7a1d50101735d2d (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts: .qmake.conf src/3rdparty src/core/configure.json src/core/profile_io_data_qt.cpp tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp Change-Id: Ie8ae4aa03881a0733ff497fff46e3f7040735650
Diffstat (limited to 'src')
-rw-r--r--src/core/configure.json10
-rw-r--r--src/core/core_module.pro2
-rw-r--r--src/core/devtools_frontend_qt.cpp3
-rw-r--r--src/core/web_contents_adapter.cpp6
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/core/web_contents_adapter_client.h1
-rw-r--r--src/core/web_contents_delegate_qt.cpp59
-rw-r--r--src/core/web_contents_delegate_qt.h21
-rw-r--r--src/webengine/api/qquickwebengineaction.cpp3
-rw-r--r--src/webengine/api/qquickwebengineview.cpp22
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h1
-rw-r--r--src/webengine/doc/src/webengineview_lgpl.qdoc7
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp22
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc8
-rw-r--r--src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc9
16 files changed, 166 insertions, 10 deletions
diff --git a/src/core/configure.json b/src/core/configure.json
index bb8ad7997..db900f046 100644
--- a/src/core/configure.json
+++ b/src/core/configure.json
@@ -335,6 +335,11 @@
"webengine-extensions-gcc-version" : {
"label": "GCC 6 or newer",
"type": "hasGcc6OrNewer"
+ },
+ "webengine-noexecstack" : {
+ "label": "linker supports -z noexecstack",
+ "type": "linkerSupportsFlag",
+ "flag": "-z,noexecstack"
}
},
@@ -678,6 +683,11 @@
"purpose": "Provides WebEngine Qml support.",
"section": "WebEngine",
"output": [ "privateFeature" ]
+ },
+ "webengine-noexecstack": {
+ "label": "linker supports -z noexecstack",
+ "condition": "config.unix && tests.webengine-noexecstack",
+ "output": [ "privateFeature" ]
}
},
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index f5234f88b..02aa6ac38 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -39,6 +39,8 @@ LIBS_PRIVATE += $$NINJA_LIB_DIRS $$NINJA_LIBS
# GN's LFLAGS doesn't always work across all the Linux configurations we support.
# The Windows and macOS ones from GN does provide a few useful flags however
+unix:qtConfig(webengine-noexecstack): \
+ QMAKE_LFLAGS += -Wl,-z,noexecstack
linux {
QMAKE_LFLAGS += -Wl,--gc-sections -Wl,-O1 -Wl,-z,now
# Embedded address sanitizer symbols are undefined and are picked up by the dynamic link loader
diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp
index 9eedee42a..28af84bd3 100644
--- a/src/core/devtools_frontend_qt.cpp
+++ b/src/core/devtools_frontend_qt.cpp
@@ -79,7 +79,6 @@
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
-#include <QDebug>
using namespace QtWebEngineCore;
namespace {
@@ -192,7 +191,7 @@ DevToolsFrontendQt *DevToolsFrontendQt::Show(QSharedPointer<WebContentsAdapter>
content::WebContents *contents = frontendAdapter->webContents();
if (contents == inspectedContents) {
- qWarning() << "You can not inspect youself";
+ LOG(WARNING) << "You can not inspect yourself";
return nullptr;
}
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index c4f4591e3..0ec5af0fe 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1630,6 +1630,12 @@ bool WebContentsAdapter::isFindTextInProgress() const
return m_lastFindRequestId != m_webContentsDelegate->lastReceivedFindReply();
}
+bool WebContentsAdapter::hasFocusedFrame() const
+{
+ CHECK_INITIALIZED(false);
+ return m_webContents->GetFocusedFrame() != nullptr;
+}
+
WebContentsAdapterClient::RenderProcessTerminationStatus
WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) {
auto status = WebContentsAdapterClient::RenderProcessTerminationStatus(-1);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 79aa68456..da4bc9190 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -217,6 +217,7 @@ public:
bool canViewSource();
void focusIfNecessary();
bool isFindTextInProgress() const;
+ bool hasFocusedFrame() const;
// meant to be used within WebEngineCore only
void initialize(content::SiteInstance *site);
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index b388b28d0..540dd5f1f 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -469,6 +469,7 @@ public:
virtual void updateScrollPosition(const QPointF &position) = 0;
virtual void updateContentsSize(const QSizeF &size) = 0;
virtual void updateNavigationActions() = 0;
+ virtual void updateEditActions() = 0;
virtual void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) = 0;
virtual bool supportsDragging() const = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 021044a71..c8fac0d54 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -64,6 +64,7 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "components/web_cache/browser/web_cache_manager.h"
+#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
@@ -104,6 +105,7 @@ WebContentsDelegateQt::WebContentsDelegateQt(content::WebContents *webContents,
, m_lastReceivedFindReply(0)
, m_faviconManager(new FaviconManager(webContents, adapterClient))
, m_lastLoadProgress(-1)
+ , m_frameFocusedObserver(adapterClient)
{
webContents->SetDelegate(this);
Observe(webContents);
@@ -262,11 +264,30 @@ bool WebContentsDelegateQt::HandleKeyboardEvent(content::WebContents *, const co
return true;
}
+void WebContentsDelegateQt::RenderFrameCreated(content::RenderFrameHost *render_frame_host)
+{
+ content::FrameTreeNode *node = static_cast<content::RenderFrameHostImpl *>(render_frame_host)->frame_tree_node();
+ m_frameFocusedObserver.addNode(node);
+}
+
void WebContentsDelegateQt::RenderFrameDeleted(content::RenderFrameHost *render_frame_host)
{
m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID());
}
+void WebContentsDelegateQt::RenderFrameHostChanged(content::RenderFrameHost *old_host, content::RenderFrameHost *new_host)
+{
+ if (old_host) {
+ content::FrameTreeNode *old_node = static_cast<content::RenderFrameHostImpl *>(old_host)->frame_tree_node();
+ m_frameFocusedObserver.removeNode(old_node);
+ }
+
+ if (new_host) {
+ content::FrameTreeNode *new_node = static_cast<content::RenderFrameHostImpl *>(new_host)->frame_tree_node();
+ m_frameFocusedObserver.addNode(new_node);
+ }
+}
+
void WebContentsDelegateQt::RenderViewHostChanged(content::RenderViewHost *, content::RenderViewHost *newHost)
{
if (newHost && newHost->GetWidget() && newHost->GetWidget()->GetView()) {
@@ -724,4 +745,42 @@ WebContentsAdapter *WebContentsDelegateQt::webContentsAdapter() const
return m_viewClient->webContentsAdapter();
}
+
+FrameFocusedObserver::FrameFocusedObserver(WebContentsAdapterClient *adapterClient)
+ : m_viewClient(adapterClient)
+{}
+
+void FrameFocusedObserver::addNode(content::FrameTreeNode *node)
+{
+ if (m_observedNodes.contains(node))
+ return;
+
+ node->AddObserver(this);
+ m_observedNodes.append(node);
+}
+
+void FrameFocusedObserver::removeNode(content::FrameTreeNode *node)
+{
+ node->RemoveObserver(this);
+ m_observedNodes.removeOne(node);
+}
+
+void FrameFocusedObserver::OnFrameTreeNodeFocused(content::FrameTreeNode *node)
+{
+ Q_UNUSED(node);
+ m_viewClient->updateEditActions();
+}
+
+void FrameFocusedObserver::OnFrameTreeNodeDestroyed(content::FrameTreeNode *node)
+{
+ m_observedNodes.removeOne(node);
+ m_viewClient->updateEditActions();
+}
+
+FrameFocusedObserver::~FrameFocusedObserver()
+{
+ for (content::FrameTreeNode *node : m_observedNodes)
+ node->RemoveObserver(this);
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 1629222c2..f6ba71256 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -40,6 +40,7 @@
#ifndef WEB_CONTENTS_DELEGATE_QT_H
#define WEB_CONTENTS_DELEGATE_QT_H
+#include "content/browser/frame_host/frame_tree_node.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -70,6 +71,23 @@ class WebContentsAdapter;
class WebContentsAdapterClient;
class WebEngineSettings;
+class FrameFocusedObserver : public content::FrameTreeNode::Observer
+{
+public:
+ FrameFocusedObserver(WebContentsAdapterClient *adapterClient);
+ ~FrameFocusedObserver();
+ void addNode(content::FrameTreeNode *node);
+ void removeNode(content::FrameTreeNode *node);
+
+protected:
+ void OnFrameTreeNodeFocused(content::FrameTreeNode *node) override;
+ void OnFrameTreeNodeDestroyed(content::FrameTreeNode *node) override;
+
+private:
+ WebContentsAdapterClient *m_viewClient;
+ QVector<content::FrameTreeNode *> m_observedNodes;
+};
+
class SavePageInfo
{
public:
@@ -132,7 +150,9 @@ public:
bool TakeFocus(content::WebContents *source, bool reverse) override;
// WebContentsObserver overrides
+ void RenderFrameCreated(content::RenderFrameHost *render_frame_host) override;
void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) override;
+ void RenderFrameHostChanged(content::RenderFrameHost *old_host, content::RenderFrameHost *new_host) override;
void RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host) override;
void DidStartNavigation(content::NavigationHandle *navigation_handle) override;
void DidFinishNavigation(content::NavigationHandle *navigation_handle) override;
@@ -175,6 +195,7 @@ private:
QSharedPointer<FilePickerController> m_filePickerController;
QUrl m_initialTargetUrl;
int m_lastLoadProgress;
+ FrameFocusedObserver m_frameFocusedObserver;
QUrl m_url;
QString m_title;
diff --git a/src/webengine/api/qquickwebengineaction.cpp b/src/webengine/api/qquickwebengineaction.cpp
index 69a05f29b..77ac8d340 100644
--- a/src/webengine/api/qquickwebengineaction.cpp
+++ b/src/webengine/api/qquickwebengineaction.cpp
@@ -146,8 +146,7 @@ QString QQuickWebEngineAction::iconName() const
/*!
\qmlproperty bool WebEngineAction::enabled
- This property holds whether the action is enabled. Context-dependent
- actions are always enabled.
+ This property holds whether the action is enabled.
*/
bool QQuickWebEngineAction::isEnabled() const
{
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 976e6ed04..bb8428951 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -942,6 +942,16 @@ void QQuickWebEngineViewPrivate::updateAction(QQuickWebEngineView::WebAction act
case QQuickWebEngineView::ViewSource:
enabled = adapter->canViewSource();
break;
+ case QQuickWebEngineView::Cut:
+ case QQuickWebEngineView::Copy:
+ case QQuickWebEngineView::Paste:
+ case QQuickWebEngineView::Undo:
+ case QQuickWebEngineView::Redo:
+ case QQuickWebEngineView::SelectAll:
+ case QQuickWebEngineView::PasteAndMatchStyle:
+ case QQuickWebEngineView::Unselect:
+ enabled = adapter->hasFocusedFrame();
+ break;
default:
break;
}
@@ -959,6 +969,18 @@ void QQuickWebEngineViewPrivate::updateNavigationActions()
updateAction(QQuickWebEngineView::ViewSource);
}
+void QQuickWebEngineViewPrivate::updateEditActions()
+{
+ updateAction(QQuickWebEngineView::Cut);
+ updateAction(QQuickWebEngineView::Copy);
+ updateAction(QQuickWebEngineView::Paste);
+ updateAction(QQuickWebEngineView::Undo);
+ updateAction(QQuickWebEngineView::Redo);
+ updateAction(QQuickWebEngineView::SelectAll);
+ updateAction(QQuickWebEngineView::PasteAndMatchStyle);
+ updateAction(QQuickWebEngineView::Unselect);
+}
+
QUrl QQuickWebEngineView::url() const
{
Q_D(const QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index aa0a765f8..10fe5c2fd 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -151,6 +151,7 @@ public:
void updateScrollPosition(const QPointF &position) override;
void updateContentsSize(const QSizeF &size) override;
void updateNavigationActions() override;
+ void updateEditActions() override;
void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) override;
bool supportsDragging() const override;
diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc
index 38c84f848..d256997cc 100644
--- a/src/webengine/doc/src/webengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/webengineview_lgpl.qdoc
@@ -376,7 +376,8 @@
which references HTML pages via URL.
External objects, such as stylesheets or images referenced in the HTML
- document, should be located relative to \a baseUrl. For example, if \a html
+ document, should be located relative to \a baseUrl. For external objects to
+ be loaded, \c baseUrl cannot be empty. For example, if \a html
is retrieved from \c http://www.example.com/documents/overview.html, which
is the base URL, then an image referenced with the relative URL, \c diagram.png,
should be at \c{http://www.example.com/documents/diagram.png}.
@@ -756,6 +757,10 @@
Redo the last editing action.
\value WebEngineView.SelectAll
Select all content.
+ This action is only enabled when the page's content is focused.
+ The focus can be forced by the JavaScript \c{window.focus()} call, or the
+ \l{WebEngineSettings::focusOnNavigationEnabled} {focusOnNavigationEnabled} setting
+ should be enabled to get automatic focus.
\value WebEngineView.PasteAndMatchStyle
Paste content from the clipboard with current style.
\value WebEngineView.OpenLinkInThisWindow
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 86736d42b..a350433b8 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -590,6 +590,16 @@ void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
case QWebEnginePage::ViewSource:
enabled = adapter->canViewSource();
break;
+ case QWebEnginePage::Cut:
+ case QWebEnginePage::Copy:
+ case QWebEnginePage::Paste:
+ case QWebEnginePage::Undo:
+ case QWebEnginePage::Redo:
+ case QWebEnginePage::SelectAll:
+ case QWebEnginePage::PasteAndMatchStyle:
+ case QWebEnginePage::Unselect:
+ enabled = adapter->hasFocusedFrame();
+ break;
default:
break;
}
@@ -608,6 +618,18 @@ void QWebEnginePagePrivate::updateNavigationActions()
updateAction(QWebEnginePage::ViewSource);
}
+void QWebEnginePagePrivate::updateEditActions()
+{
+ updateAction(QWebEnginePage::Cut);
+ updateAction(QWebEnginePage::Copy);
+ updateAction(QWebEnginePage::Paste);
+ updateAction(QWebEnginePage::Undo);
+ updateAction(QWebEnginePage::Redo);
+ updateAction(QWebEnginePage::SelectAll);
+ updateAction(QWebEnginePage::PasteAndMatchStyle);
+ updateAction(QWebEnginePage::Unselect);
+}
+
#ifndef QT_NO_ACTION
void QWebEnginePagePrivate::_q_webActionTriggered(bool checked)
{
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 5feefeb0e..dc0ead534 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -146,6 +146,7 @@ public:
void updateScrollPosition(const QPointF &position) override;
void updateContentsSize(const QSizeF &size) override;
void updateNavigationActions() override;
+ void updateEditActions() override;
void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) override;
bool supportsDragging() const override;
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index e63423be8..b68caed59 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -112,8 +112,7 @@
Actions only have an effect when they are applicable.
The availability of actions can be be determined by checking
- \l{QAction::}{isEnabled()} on the action returned by action(). Context-dependent
- actions are always enabled.
+ \l{QAction::}{isEnabled()} on the action returned by action().
\value NoWebAction No action is triggered.
\value Back Navigate back in the history of navigated links.
@@ -126,7 +125,10 @@
\value Paste Paste content from the clipboard.
\value Undo Undo the last editing action.
\value Redo Redo the last editing action.
- \value SelectAll Select all content.
+ \value SelectAll Select all content. This action is only enabled when the page's content is focused.
+ The focus can be forced by the JavaScript \c{window.focus()} call, or the
+ \l{QWebEngineSettings::FocusOnNavigationEnabled} {FocusOnNavigationEnabled} setting
+ should be enabled to get automatic focus.
\value PasteAndMatchStyle Paste content from the clipboard with current style.
\value OpenLinkInThisWindow Open the current link in the current window. (Added in Qt 5.6)
diff --git a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
index fce1e8d8f..1b7812dff 100644
--- a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015 The Qt Company Ltd.
+ Copyright (C) 2019 The Qt Company Ltd.
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Holger Hans Peter Freyther
Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
@@ -125,7 +125,11 @@
Sets the content of the web view to the specified \a html content.
External objects, such as stylesheets or images referenced in the HTML
- document, are located relative to \a baseUrl.
+ document, are located relative to \a baseUrl. For external objects to
+ be loaded, \c baseUrl cannot be empty. For example, if \a html
+ is retrieved from \c http://www.example.com/documents/overview.html, which
+ is the base URL, then an image referenced with the relative URL, \c diagram.png,
+ should be at \c{http://www.example.com/documents/diagram.png}.
The HTML document is loaded immediately, whereas external objects are loaded asynchronously.
@@ -156,6 +160,7 @@
is empty, it is assumed that the content is \c{text/plain,charset=US-ASCII}.
External objects referenced in the content are located relative to \a baseUrl.
+ For external objects to be loaded, \c baseUrl cannot be empty.
The data is loaded immediately; external objects are loaded asynchronously.