summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/render_widget_host_view_qt.cpp10
-rw-r--r--src/core/render_widget_host_view_qt.h2
-rw-r--r--src/core/web_contents_adapter.cpp26
-rw-r--r--src/core/web_contents_adapter.h4
-rw-r--r--src/core/web_contents_delegate_qt.cpp2
-rw-r--r--src/core/web_engine_context.cpp3
6 files changed, 42 insertions, 5 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 0af26314a..c4d6200b7 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -286,6 +286,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
, m_adapterClient(0)
, m_imeInProgress(false)
, m_receivedEmptyImeEvent(false)
+ , m_isMouseLocked(false)
, m_imState(0)
, m_anchorPositionWithinSelection(-1)
, m_cursorPositionWithinSelection(-1)
@@ -448,6 +449,11 @@ bool RenderWidgetHostViewQt::HasFocus()
return m_delegate->hasKeyboardFocus();
}
+bool RenderWidgetHostViewQt::IsMouseLocked()
+{
+ return m_isMouseLocked;
+}
+
bool RenderWidgetHostViewQt::IsSurfaceAvailableForCopy()
{
if (m_enableViz)
@@ -520,6 +526,7 @@ bool RenderWidgetHostViewQt::LockMouse(bool)
{
m_previousMousePosition = QCursor::pos();
m_delegate->lockMouse();
+ m_isMouseLocked = true;
qApp->setOverrideCursor(Qt::BlankCursor);
return true;
}
@@ -528,6 +535,7 @@ void RenderWidgetHostViewQt::UnlockMouse()
{
m_delegate->unlockMouse();
qApp->restoreOverrideCursor();
+ m_isMouseLocked = false;
host()->LostMouseLock();
}
@@ -1784,6 +1792,8 @@ void RenderWidgetHostViewQt::handleFocusEvent(QFocusEvent *ev)
else if (ev->reason() == Qt::BacktabFocusReason)
viewHost->SetInitialFocus(true);
ev->accept();
+
+ m_adapterClient->webContentsAdapter()->handlePendingMouseLockPermission();
} else if (ev->lostFocus()) {
host()->SetActive(false);
host()->LostFocus();
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index a07d21468..453b90888 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -132,6 +132,7 @@ public:
gfx::NativeViewAccessible GetNativeViewAccessible() override;
void Focus() override;
bool HasFocus() override;
+ bool IsMouseLocked() override;
bool IsSurfaceAvailableForCopy() override;
void CopyFromSurface(const gfx::Rect &src_rect,
const gfx::Size &output_size,
@@ -289,6 +290,7 @@ private:
bool m_imeInProgress;
bool m_receivedEmptyImeEvent;
QPoint m_previousMousePosition;
+ bool m_isMouseLocked;
gfx::Vector2dF m_lastScrollOffset;
gfx::SizeF m_lastContentsSize;
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index c8bb10fd6..0f2f21f83 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1372,20 +1372,40 @@ void WebContentsAdapter::runFeatureRequestCallback(const QUrl &securityOrigin, P
m_profileAdapter->permissionRequestReply(securityOrigin, feature, allowed);
}
-void WebContentsAdapter::grantMouseLockPermission(bool granted)
+void WebContentsAdapter::grantMouseLockPermission(const QUrl &securityOrigin, bool granted)
{
CHECK_INITIALIZED();
+ if (securityOrigin != toQt(m_webContents->GetLastCommittedURL().GetOrigin()))
+ return;
if (granted) {
- if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView()))
+ if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) {
rwhv->Focus();
- else
+ if (!rwhv->HasFocus()) {
+ // We tried to activate our RWHVQtDelegate, but we failed. This probably means that
+ // the permission was granted from a modal dialog and the windowing system is not ready
+ // to set focus on the originating view. Since pointer lock strongly requires it, we just
+ // wait until the next FocusIn event.
+ m_pendingMouseLockPermissions.insert(securityOrigin, granted);
+ return;
+ }
+ } else
granted = false;
}
m_webContents->GotResponseToLockMouseRequest(granted);
}
+void WebContentsAdapter::handlePendingMouseLockPermission()
+{
+ CHECK_INITIALIZED();
+ auto it = m_pendingMouseLockPermissions.find(toQt(m_webContents->GetLastCommittedURL().GetOrigin()));
+ if (it != m_pendingMouseLockPermissions.end()) {
+ m_webContents->GotResponseToLockMouseRequest(it.value());
+ m_pendingMouseLockPermissions.erase(it);
+ }
+}
+
void WebContentsAdapter::setBackgroundColor(const QColor &color)
{
CHECK_INITIALIZED();
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index cc041ed55..66808ce5e 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -194,7 +194,8 @@ public:
void devToolsFrontendDestroyed(DevToolsFrontendQt *frontend);
void grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags);
- void grantMouseLockPermission(bool granted);
+ void grantMouseLockPermission(const QUrl &securityOrigin, bool granted);
+ void handlePendingMouseLockPermission();
void runFeatureRequestCallback(const QUrl &securityOrigin, ProfileAdapter::PermissionType feature, bool allowed);
void setBackgroundColor(const QColor &color);
@@ -268,6 +269,7 @@ private:
#endif
WebContentsAdapterClient *m_adapterClient;
quint64 m_nextRequestId;
+ QMap<QUrl, bool> m_pendingMouseLockPermissions;
std::unique_ptr<content::DropData> m_currentDropData;
uint m_currentDropAction;
bool m_updateDragActionCalled;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 216e4faf1..bf0254e82 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -655,7 +655,7 @@ void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_content
if (last_unlocked_by_target)
web_contents->GotResponseToLockMouseRequest(true);
else
- m_viewClient->runMouseLockPermissionRequest(toQt(web_contents->GetVisibleURL()));
+ m_viewClient->runMouseLockPermissionRequest(toQt(web_contents->GetLastCommittedURL().GetOrigin()));
}
void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *webContents, content::WebPreferences *webPreferences)
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 6a08b265e..efd5239d8 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -641,6 +641,9 @@ WebEngineContext::WebEngineContext()
appendToFeatureList(disableFeatures, network::features::kDnsOverHttpsUpgrade.name);
+ // When enabled, event.movement is calculated in blink instead of in browser.
+ appendToFeatureList(disableFeatures, features::kConsolidatedMovementXY.name);
+
// Explicitly tell Chromium about default-on features we do not support
appendToFeatureList(disableFeatures, features::kBackgroundFetch.name);
appendToFeatureList(disableFeatures, features::kSmsReceiver.name);