summaryrefslogtreecommitdiffstats
path: root/src/core
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/core
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/core')
-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
8 files changed, 101 insertions, 2 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;