summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2019-01-08 08:19:22 +0200
committerKari Oikarinen <kari.oikarinen@qt.io>2019-01-08 08:19:22 +0200
commit846320f5877aafb9c7b319da6c972786805d9c30 (patch)
treeb4bda9f9b27ee311fc7f75de3843a828da23c340 /src/core
parent35b97b92968505793b162ccfdada65e25690f711 (diff)
parent5c85e0748b6c321d9988d126903fed85f311f5e7 (diff)
Merge 5.12 into 5.12.1
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/qwebengineurlrequestinfo.cpp3
-rw-r--r--src/core/api/qwebengineurlscheme.cpp6
-rw-r--r--src/core/api/qwebengineurlschemehandler.cpp43
-rw-r--r--src/core/browser_main_parts_qt.cpp4
-rw-r--r--src/core/download_manager_delegate_qt.cpp16
-rw-r--r--src/core/net/network_delegate_qt.cpp14
-rw-r--r--src/core/profile_adapter.cpp4
-rw-r--r--src/core/profile_io_data_qt.cpp11
-rw-r--r--src/core/profile_io_data_qt.h5
-rw-r--r--src/core/web_engine_context.cpp6
-rw-r--r--src/core/web_engine_context.h6
-rw-r--r--src/core/web_event_factory.cpp114
12 files changed, 174 insertions, 58 deletions
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp
index 2bb870071..ea9081fc1 100644
--- a/src/core/api/qwebengineurlrequestinfo.cpp
+++ b/src/core/api/qwebengineurlrequestinfo.cpp
@@ -120,6 +120,9 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, Q
\a info contains the information about the URL request and will track internally
whether its members have been altered.
+
+ \warning All method calls to the profile on the main thread will block until
+ execution of this function is finished.
*/
diff --git a/src/core/api/qwebengineurlscheme.cpp b/src/core/api/qwebengineurlscheme.cpp
index f36f3335b..d63599163 100644
--- a/src/core/api/qwebengineurlscheme.cpp
+++ b/src/core/api/qwebengineurlscheme.cpp
@@ -84,8 +84,10 @@ public:
URLs.
Custom URL schemes must be configured early at application startup, before
- creating any Qt WebEngine classes. The configuration applies globally to all
- profiles.
+ creating any Qt WebEngine classes. In general this means the schemes need to be configured before
+ a QGuiApplication or QApplication instance is created.
+
+ Every registered scheme configuration applies globally to all profiles.
\code
int main(int argc, char **argv)
diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp
index 94b85c42b..6f06b2c6e 100644
--- a/src/core/api/qwebengineurlschemehandler.cpp
+++ b/src/core/api/qwebengineurlschemehandler.cpp
@@ -48,12 +48,51 @@ QT_BEGIN_NAMESPACE
\brief The QWebEngineUrlSchemeHandler is a base class for handling custom URL schemes.
\since 5.6
- To implement a custom URL scheme for QtWebEngine, you must write a class derived from this class,
- and reimplement requestStarted(). Then install it via QWebEngineProfile::installUrlSchemeHandler()
+ To implement a custom URL scheme for QtWebEngine, you first have to create an instance of
+ QWebEngineUrlScheme and register it using QWebEngineUrlScheme::registerScheme().
+
+ \note Make sure that you create and register the scheme object \e before the QGuiApplication
+ or QApplication object is instantiated.
+
+ Then you must create a class derived from QWebEngineUrlSchemeHandler,
+ and reimplement the requestStarted() method.
+
+ Finally, install the scheme handler object via QWebEngineProfile::installUrlSchemeHandler()
or QQuickWebEngineProfile::installUrlSchemeHandler().
+ \code
+
+ class MySchemeHandler : public QWebEngineUrlSchemeHandler
+ {
+ public:
+ MySchemeHandler(QObject *parent = nullptr);
+ void requestStarted(QWebEngineUrlRequestJob *request)
+ {
+ // ....
+ }
+ };
+
+ int main(int argc, char **argv)
+ {
+ QWebEngineUrlScheme scheme("myscheme");
+ scheme.setSyntax(QWebEngineUrlScheme::Syntax::HostAndPort);
+ scheme.setDefaultPort(2345);
+ scheme.setFlags(QWebEngineUrlScheme::SecureScheme);
+ QWebEngineUrlScheme::registerScheme(scheme);
+
+ // ...
+ QApplication app(argc, argv);
+ // ...
+
+ // installUrlSchemeHandler does not take ownership of the handler.
+ MySchemeHandler *handler = new MySchemeHandler(parent);
+ QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("myscheme", handler);
+ }
+ \endcode
+
\inmodule QtWebEngineCore
+ \sa {QWebEngineUrlScheme}, {WebEngine Widgets WebUI Example}
*/
/*!
diff --git a/src/core/browser_main_parts_qt.cpp b/src/core/browser_main_parts_qt.cpp
index dbd123586..8f39386d4 100644
--- a/src/core/browser_main_parts_qt.cpp
+++ b/src/core/browser_main_parts_qt.cpp
@@ -204,9 +204,9 @@ void BrowserMainPartsQt::PreMainMessageLoopStart()
void BrowserMainPartsQt::PostMainMessageLoopRun()
{
- // The BrowserContext's destructor uses the MessageLoop so it should be deleted
+ // The ProfileQt's destructor uses the MessageLoop so it should be deleted
// right before the RenderProcessHostImpl's destructor destroys it.
- WebEngineContext::current()->destroyBrowserContext();
+ WebEngineContext::current()->destroyProfileAdapter();
}
int BrowserMainPartsQt::PreCreateThreads()
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 9fe233577..abf4a2a95 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -39,6 +39,8 @@
#include "download_manager_delegate_qt.h"
+#include "base/files/file_util.h"
+#include "base/time/time_to_iso8601.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/save_page_type.h"
@@ -156,15 +158,13 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
QFileInfo suggestedFile(defaultDownloadDirectory.absoluteFilePath(suggestedFilename));
QString suggestedFilePath = suggestedFile.absoluteFilePath();
- QString tmpFileBase = QString("%1%2%3").arg(suggestedFile.absolutePath()).arg(QDir::separator()).arg(suggestedFile.baseName());
+ base::FilePath tmpFilePath(toFilePathString(suggestedFilePath));
- for (int i = 1; QFileInfo::exists(suggestedFilePath); ++i) {
- suggestedFilePath = QString("%1(%2).%3").arg(tmpFileBase).arg(i).arg(suggestedFile.completeSuffix());
- if (i >= 99) {
- suggestedFilePath = suggestedFile.absoluteFilePath();
- break;
- }
- }
+ int uniquifier = base::GetUniquePathNumber(tmpFilePath, base::FilePath::StringType());
+ if (uniquifier > 0)
+ suggestedFilePath = toQt(tmpFilePath.InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", uniquifier)).AsUTF8Unsafe());
+ else if (uniquifier == -1)
+ suggestedFilePath = toQt(tmpFilePath.InsertBeforeExtensionASCII(base::StringPrintf(" - %s", base::TimeToISO8601(item->GetStartTime()).c_str())).AsUTF8Unsafe());
item->AddObserver(this);
QList<ProfileAdapterClient*> clients = m_profileAdapter->clients();
diff --git a/src/core/net/network_delegate_qt.cpp b/src/core/net/network_delegate_qt.cpp
index 551302291..37309931e 100644
--- a/src/core/net/network_delegate_qt.cpp
+++ b/src/core/net/network_delegate_qt.cpp
@@ -225,15 +225,22 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
const QUrl qUrl = toQt(request->url());
- QWebEngineUrlRequestInterceptor* interceptor = m_profileIOData->requestInterceptor();
+ QUrl firstPartyUrl = QUrl();
+ if (resourceType == content::ResourceType::RESOURCE_TYPE_SUB_FRAME)
+ firstPartyUrl = toQt(request->first_party_url());
+ else
+ firstPartyUrl = toQt(request->site_for_cookies());
+
+ QWebEngineUrlRequestInterceptor* interceptor = m_profileIOData->acquireInterceptor();
if (interceptor) {
QWebEngineUrlRequestInfoPrivate *infoPrivate = new QWebEngineUrlRequestInfoPrivate(toQt(resourceType),
toQt(navigationType),
qUrl,
- toQt(request->site_for_cookies()),
+ firstPartyUrl,
QByteArray::fromStdString(request->method()));
QWebEngineUrlRequestInfo requestInfo(infoPrivate);
interceptor->interceptRequest(requestInfo);
+ m_profileIOData->releaseInterceptor();
if (requestInfo.changed()) {
int result = infoPrivate->shouldBlockRequest ? net::ERR_BLOCKED_BY_CLIENT : net::OK;
@@ -249,7 +256,8 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, net::Complet
if (result != net::OK)
return result;
}
- }
+ } else
+ m_profileIOData->releaseInterceptor();
if (!resourceInfo)
return net::OK;
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index 86b16fd2c..800fcb401 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -82,7 +82,7 @@ ProfileAdapter::ProfileAdapter(const QString &storageName):
, m_visitedLinksPolicy(TrackVisitedLinksOnDisk)
, m_httpCacheMaxSize(0)
{
- WebEngineContext::current()->addBrowserContext(this);
+ WebEngineContext::current()->addProfileAdapter(this);
// creation of profile requires webengine context
m_profile.reset(new ProfileQt(this));
content::BrowserContext::Initialize(m_profile.data(), toFilePath(dataPath()));
@@ -92,7 +92,7 @@ ProfileAdapter::ProfileAdapter(const QString &storageName):
ProfileAdapter::~ProfileAdapter()
{
- WebEngineContext::current()->removeBrowserContext(this);
+ WebEngineContext::current()->removeProfileAdapter(this);
if (m_downloadManagerDelegate) {
m_profile->GetDownloadManager(m_profile.data())->Shutdown();
m_downloadManagerDelegate.reset();
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index 0a0d242a3..7783f1ae7 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -690,14 +690,17 @@ void ProfileIODataQt::updateRequestInterceptor()
// We in this case do not need to regenerate any Chromium classes.
}
-QWebEngineUrlRequestInterceptor *ProfileIODataQt::requestInterceptor()
+QWebEngineUrlRequestInterceptor *ProfileIODataQt::acquireInterceptor()
{
- // used in NetworkDelegateQt::OnBeforeURLRequest
- Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- QMutexLocker lock(&m_mutex);
+ m_mutex.lock();
return m_requestInterceptor;
}
+void ProfileIODataQt::releaseInterceptor()
+{
+ m_mutex.unlock();
+}
+
bool ProfileIODataQt::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const
{
return m_cookieDelegate->canSetCookie(firstPartyUrl,cookieLine, url);
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
index 6961e2ad2..5b416861c 100644
--- a/src/core/profile_io_data_qt.h
+++ b/src/core/profile_io_data_qt.h
@@ -89,10 +89,13 @@ public:
void generateUserAgent();
void generateJobFactory();
void regenerateJobFactory();
- QWebEngineUrlRequestInterceptor *requestInterceptor();
bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) const;
bool canGetCookies(const QUrl &firstPartyUrl, const QUrl &url) const;
+ // Used in NetworkDelegateQt::OnBeforeURLRequest.
+ QWebEngineUrlRequestInterceptor *acquireInterceptor();
+ void releaseInterceptor();
+
void setRequestContextData(content::ProtocolHandlerMap *protocolHandlers,
content::URLRequestInterceptorScopedVector request_interceptors);
void setFullConfiguration(); // runs on ui thread
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 1361ebbed..aee5be42f 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -183,13 +183,13 @@ bool usingSoftwareDynamicGL()
scoped_refptr<QtWebEngineCore::WebEngineContext> WebEngineContext::m_handle;
bool WebEngineContext::m_destroyed = false;
-void WebEngineContext::destroyBrowserContext()
+void WebEngineContext::destroyProfileAdapter()
{
if (m_defaultProfileAdapter)
qWarning("PostMainMessageLoopRun is done, but global profile still exists !");
}
-void WebEngineContext::addBrowserContext(ProfileAdapter *profileAdapter)
+void WebEngineContext::addProfileAdapter(ProfileAdapter *profileAdapter)
{
Q_ASSERT(!m_profileAdapters.contains(profileAdapter));
const QString path = profileAdapter->dataPath();
@@ -205,7 +205,7 @@ void WebEngineContext::addBrowserContext(ProfileAdapter *profileAdapter)
m_profileAdapters.append(profileAdapter);
}
-void WebEngineContext::removeBrowserContext(ProfileAdapter *profileAdapter)
+void WebEngineContext::removeProfileAdapter(ProfileAdapter *profileAdapter)
{
m_profileAdapters.removeAll(profileAdapter);
}
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index ce71984d4..604c85a61 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -82,9 +82,9 @@ public:
#if QT_CONFIG(webengine_printing_and_pdf)
printing::PrintJobManager* getPrintJobManager();
#endif
- void destroyBrowserContext();
- void addBrowserContext(ProfileAdapter *profileAdapter);
- void removeBrowserContext(ProfileAdapter *profileAdapter);
+ void destroyProfileAdapter();
+ void addProfileAdapter(ProfileAdapter *profileAdapter);
+ void removeProfileAdapter(ProfileAdapter *profileAdapter);
void destroy();
private:
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index a45f7048b..fc6287dd9 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -101,7 +101,7 @@ static KeyboardDriver keyboardDriverImpl()
if (platformName == QLatin1Literal("xcb") || platformName == QLatin1Literal("wayland"))
return KeyboardDriver::Xkb;
-#if QT_CONFIG(libinput) && QT_CONFIG(xkbcommon_evdev)
+#if QT_CONFIG(libinput) && QT_CONFIG(xkbcommon)
// Based on QEglFSIntegration::createInputHandlers and QLibInputKeyboard::processKey.
if (platformName == QLatin1Literal("eglfs") && !qEnvironmentVariableIntValue("QT_QPA_EGLFS_NO_LIBINPUT"))
return KeyboardDriver::Xkb;
@@ -927,6 +927,74 @@ static ui::DomKey domKeyForQtKey(int qtKey)
case Qt::Key_Zenkaku_Hankaku:
return ui::DomKey::ZENKAKU_HANKAKU;
+ // Dead keys (ui/events/keycodes/keyboard_code_conversion_xkb.cc)
+ case Qt::Key_Dead_Grave:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0300);
+ case Qt::Key_Dead_Acute:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0301);
+ case Qt::Key_Dead_Circumflex:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0302);
+ case Qt::Key_Dead_Tilde:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0303);
+ case Qt::Key_Dead_Macron:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0304);
+ case Qt::Key_Dead_Breve:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0306);
+ case Qt::Key_Dead_Abovedot:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0307);
+ case Qt::Key_Dead_Diaeresis:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0308);
+ case Qt::Key_Dead_Abovering:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x030A);
+ case Qt::Key_Dead_Doubleacute:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x030B);
+ case Qt::Key_Dead_Caron:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x030C);
+ case Qt::Key_Dead_Cedilla:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0327);
+ case Qt::Key_Dead_Ogonek:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0328);
+ case Qt::Key_Dead_Iota:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0345);
+ case Qt::Key_Dead_Voiced_Sound:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x3099);
+ case Qt::Key_Dead_Semivoiced_Sound:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x309A);
+ case Qt::Key_Dead_Belowdot:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0323);
+ case Qt::Key_Dead_Hook:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0309);
+ case Qt::Key_Dead_Horn:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x031B);
+ case Qt::Key_Dead_Stroke:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0338);
+ case Qt::Key_Dead_Abovecomma:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0313);
+ case Qt::Key_Dead_Abovereversedcomma:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0314);
+ case Qt::Key_Dead_Doublegrave:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x030F);
+ case Qt::Key_Dead_Belowring:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0325);
+ case Qt::Key_Dead_Belowmacron:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0331);
+ case Qt::Key_Dead_Belowcircumflex:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x032D);
+ case Qt::Key_Dead_Belowtilde:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0330);
+ case Qt::Key_Dead_Belowbreve:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x032E);
+ case Qt::Key_Dead_Belowdiaeresis:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0324);
+ case Qt::Key_Dead_Invertedbreve:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0311);
+ case Qt::Key_Dead_Belowcomma:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x0326);
+ case Qt::Key_Dead_Currency:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x00A4);
+ case Qt::Key_Dead_Greek:
+ return ui::DomKey::DeadKeyFromCombiningCharacter(0x037E);
+
// General-Purpose Function Keys
case Qt::Key_F1:
return ui::DomKey::F1;
@@ -1138,19 +1206,6 @@ static ui::DomKey domKeyForQtKey(int qtKey)
}
}
-static inline base::TimeTicks currentTimeForEvent(const QEvent *event)
-{
- Q_ASSERT(event);
-
- if (event->type() != QEvent::Leave) {
- const QInputEvent *inputEvent = static_cast<const QInputEvent *>(event);
- if (inputEvent->timestamp())
- return base::TimeTicks::FromInternalValue(inputEvent->timestamp() * 1000);
- }
-
- return base::TimeTicks::Now();
-}
-
template<class T>
static WebMouseEvent::Button mouseButtonForEvent(T *event)
{
@@ -1307,7 +1362,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev, double dpiScale)
mouseButtonForEvent<QMouseEvent>(ev),
0,
modifiersForEvent(ev),
- currentTimeForEvent(ev));
+ base::TimeTicks::Now());
webKitEvent.pointer_type = WebPointerProperties::PointerType::kMouse;
@@ -1317,7 +1372,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev, double dpiScale)
WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev, double dpiScale)
{
WebMouseEvent webKitEvent;
- webKitEvent.SetTimeStamp(currentTimeForEvent(ev));
+ webKitEvent.SetTimeStamp(base::TimeTicks::Now());
webKitEvent.SetModifiers(modifiersForEvent(ev));
webKitEvent.SetType(webEventTypeForEvent(ev));
@@ -1338,7 +1393,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QTabletEvent *ev, double dpiScale
mouseButtonForEvent<QTabletEvent>(ev),
0,
modifiersForEvent(ev),
- currentTimeForEvent(ev));
+ base::TimeTicks::Now());
webKitEvent.force = ev->pressure();
webKitEvent.tilt_x = ev->xTilt();
@@ -1355,7 +1410,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QEvent *ev)
Q_ASSERT(ev->type() == QEvent::Leave || ev->type() == QEvent::HoverLeave);
WebMouseEvent webKitEvent;
- webKitEvent.SetTimeStamp(currentTimeForEvent(ev));
+ webKitEvent.SetTimeStamp(base::TimeTicks::Now());
webKitEvent.SetType(WebInputEvent::kMouseLeave);
return webKitEvent;
}
@@ -1364,7 +1419,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QEvent *ev)
WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev, double dpiScale)
{
WebGestureEvent webKitEvent;
- webKitEvent.SetTimeStamp(currentTimeForEvent(ev));
+ webKitEvent.SetTimeStamp(base::TimeTicks::Now());
webKitEvent.SetModifiers(modifiersForEvent(ev));
webKitEvent.SetPositionInWidget(WebFloatPoint(ev->localPos().x() / dpiScale,
@@ -1434,7 +1489,7 @@ blink::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev, doub
WebMouseWheelEvent webEvent;
webEvent.SetType(webEventTypeForEvent(ev));
webEvent.SetModifiers(modifiersForEvent(ev));
- webEvent.SetTimeStamp(currentTimeForEvent(ev));
+ webEvent.SetTimeStamp(base::TimeTicks::Now());
webEvent.SetPositionInWidget(ev->x() / dpiScale, ev->y() / dpiScale);
webEvent.SetPositionInScreen(ev->globalX(), ev->globalY());
@@ -1464,7 +1519,7 @@ bool WebEventFactory::coalesceWebWheelEvent(blink::WebMouseWheelEvent &webEvent,
return false;
#endif
- webEvent.SetTimeStamp(currentTimeForEvent(ev));
+ webEvent.SetTimeStamp(base::TimeTicks::Now());
webEvent.SetPositionInWidget(ev->x() / dpiScale, ev->y() / dpiScale);
webEvent.SetPositionInScreen(ev->globalX(), ev->globalY());
@@ -1478,7 +1533,7 @@ bool WebEventFactory::coalesceWebWheelEvent(blink::WebMouseWheelEvent &webEvent,
content::NativeWebKeyboardEvent WebEventFactory::toWebKeyboardEvent(QKeyEvent *ev)
{
content::NativeWebKeyboardEvent webKitEvent(reinterpret_cast<gfx::NativeEvent>(ev));
- webKitEvent.SetTimeStamp(currentTimeForEvent(ev));
+ webKitEvent.SetTimeStamp(base::TimeTicks::Now());
webKitEvent.SetModifiers(modifiersForEvent(ev));
webKitEvent.SetType(webEventTypeForEvent(ev));
@@ -1502,17 +1557,20 @@ content::NativeWebKeyboardEvent WebEventFactory::toWebKeyboardEvent(QKeyEvent *e
// The dom_code field should contain the USB keycode of the *physical* key
// that was pressed. Physical meaning independent of layout and modifiers.
- //
// Since this information is not available from QKeyEvent in portable form,
- // we try to compute it from the native key code. If there's no native key
- // code available either, then we assume a US layout and convert it from
- // windows_key_code. The result will be incorrect on non-US layouts.
+ // we try to compute it from the native key code.
if (webKitEvent.native_key_code)
webKitEvent.dom_code = static_cast<int>(
ui::KeycodeConverter::NativeKeycodeToDomCode(webKitEvent.native_key_code));
- else
+
+ // The dom_code and windows_key_code can be converted to each other. The
+ // result will be incorrect on non-US layouts.
+ if (!webKitEvent.dom_code && webKitEvent.windows_key_code)
webKitEvent.dom_code = static_cast<int>(
- ui::UsLayoutKeyboardCodeToDomCode(static_cast<ui::KeyboardCode>(webKitEvent.windows_key_code)));
+ ui::UsLayoutKeyboardCodeToDomCode(static_cast<ui::KeyboardCode>(webKitEvent.windows_key_code)));
+ else if (webKitEvent.dom_code && !webKitEvent.windows_key_code)
+ webKitEvent.windows_key_code =
+ ui::DomCodeToUsLayoutKeyboardCode(static_cast<ui::DomCode>(webKitEvent.dom_code));
const ushort* text = qtText.utf16();
size_t textSize = std::min(sizeof(webKitEvent.text), size_t(qtText.length() * 2));