qt5-5.7.0.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. --- qtwebengine/src/core/renderer/web_channel_ipc_transport.cpp
  2. +++ qtwebengine/src/core/renderer/web_channel_ipc_transport.cpp
  3. @@ -153,6 +153,8 @@ content::RenderView *WebChannelTransport::GetRenderView(v8::Isolate *isolate)
  4. WebChannelIPCTransport::WebChannelIPCTransport(content::RenderView *renderView)
  5. : content::RenderViewObserver(renderView)
  6. + , m_installed(false)
  7. + , m_installedWorldId(0)
  8. {
  9. }
  10. @@ -162,6 +164,8 @@ void WebChannelIPCTransport::installWebChannel(uint worldId)
  11. if (!webView)
  12. return;
  13. WebChannelTransport::Install(webView->mainFrame(), worldId);
  14. + m_installed = true;
  15. + m_installedWorldId = worldId;
  16. }
  17. void WebChannelIPCTransport::uninstallWebChannel(uint worldId)
  18. @@ -170,6 +174,7 @@ void WebChannelIPCTransport::uninstallWebChannel(uint worldId)
  19. if (!webView)
  20. return;
  21. WebChannelTransport::Uninstall(webView->mainFrame(), worldId);
  22. + m_installed = false;
  23. }
  24. void WebChannelIPCTransport::dispatchWebChannelMessage(const std::vector<char> &binaryJSON, uint worldId)
  25. @@ -217,6 +222,13 @@ void WebChannelIPCTransport::dispatchWebChannelMessage(const std::vector<char> &
  26. frame->callFunctionEvenIfScriptDisabled(callback, webChannelObjectValue->ToObject(), argc, argv);
  27. }
  28. +void WebChannelIPCTransport::DidCreateDocumentElement(blink::WebLocalFrame* frame)
  29. +{
  30. + blink::WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
  31. + if (m_installed && frame == main_frame)
  32. + WebChannelTransport::Install(frame, m_installedWorldId);
  33. +}
  34. +
  35. bool WebChannelIPCTransport::OnMessageReceived(const IPC::Message &message)
  36. {
  37. bool handled = true;
  38. --- qtwebengine/src/core/renderer/web_channel_ipc_transport.h
  39. +++ qtwebengine/src/core/renderer/web_channel_ipc_transport.h
  40. @@ -58,7 +58,11 @@ class WebChannelIPCTransport : public content::RenderViewObserver {
  41. void dispatchWebChannelMessage(const std::vector<char> &binaryJSON, uint worldId);
  42. void installWebChannel(uint worldId);
  43. void uninstallWebChannel(uint worldId);
  44. + virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) override;
  45. virtual bool OnMessageReceived(const IPC::Message &message) Q_DECL_OVERRIDE;
  46. +
  47. + bool m_installed;
  48. + uint m_installedWorldId;
  49. };
  50. } // namespace
  51. --- qtwebengine/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
  52. +++ qtwebengine/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
  53. @@ -37,6 +37,7 @@ private Q_SLOTS:
  54. void scriptModifications();
  55. void webChannel_data();
  56. void webChannel();
  57. + void noTransportWithoutWebChannel();
  58. };
  59. void tst_QWebEngineScript::domEditing()
  60. @@ -180,13 +181,17 @@ class TestObject : public QObject
  61. void tst_QWebEngineScript::webChannel_data()
  62. {
  63. QTest::addColumn<int>("worldId");
  64. - QTest::newRow("MainWorld") << static_cast<int>(QWebEngineScript::MainWorld);
  65. - QTest::newRow("ApplicationWorld") << static_cast<int>(QWebEngineScript::ApplicationWorld);
  66. + QTest::addColumn<bool>("reloadFirst");
  67. + QTest::newRow("MainWorld") << static_cast<int>(QWebEngineScript::MainWorld) << false;
  68. + QTest::newRow("ApplicationWorld") << static_cast<int>(QWebEngineScript::ApplicationWorld) << false;
  69. + QTest::newRow("MainWorldWithReload") << static_cast<int>(QWebEngineScript::MainWorld) << true;
  70. + QTest::newRow("ApplicationWorldWithReload") << static_cast<int>(QWebEngineScript::ApplicationWorld) << true;
  71. }
  72. void tst_QWebEngineScript::webChannel()
  73. {
  74. QFETCH(int, worldId);
  75. + QFETCH(bool, reloadFirst);
  76. QWebEnginePage page;
  77. TestObject testObject;
  78. QScopedPointer<QWebChannel> channel(new QWebChannel(this));
  79. @@ -205,6 +210,11 @@ void tst_QWebEngineScript::webChannel()
  80. page.scripts().insert(script);
  81. page.setHtml(QStringLiteral("<html><body></body></html>"));
  82. waitForSignal(&page, SIGNAL(loadFinished(bool)));
  83. + if (reloadFirst) {
  84. + // Check that the transport is also reinstalled on navigation
  85. + page.triggerAction(QWebEnginePage::Reload);
  86. + waitForSignal(&page, SIGNAL(loadFinished(bool)));
  87. + }
  88. page.runJavaScript(QLatin1String(
  89. "new QWebChannel(qt.webChannelTransport,"
  90. " function(channel) {"
  91. @@ -218,6 +228,17 @@ void tst_QWebEngineScript::webChannel()
  92. QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid));
  93. }
  94. +void tst_QWebEngineScript::noTransportWithoutWebChannel()
  95. +{
  96. + QWebEnginePage page;
  97. + page.setHtml(QStringLiteral("<html><body></body></html>"));
  98. +
  99. + QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid));
  100. + page.triggerAction(QWebEnginePage::Reload);
  101. + waitForSignal(&page, SIGNAL(loadFinished(bool)));
  102. + QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid));
  103. +}
  104. +
  105. QTEST_MAIN(tst_QWebEngineScript)
  106. #include "tst_qwebenginescript.moc"
  107. --- qtbase/src/plugins/platforms/cocoa/qnswindowdelegate.mm.orig 2016-06-10 08:48:56.000000000 +0200
  108. +++ qtbase/src/plugins/platforms/cocoa/qnswindowdelegate.mm 2016-06-20 13:57:36.000000000 +0200
  109. @@ -115,4 +115,7 @@
  110. return YES;
  111. }
  112. +- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions {
  113. + return NSApplicationPresentationFullScreen | NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock;
  114. +}
  115. @end
  116. --- qtwebengine/src/core/web_engine_context.cpp.ori 2016-06-20 13:58:31.000000000 +0200
  117. +++ qtwebengine/src/core/web_engine_context.cpp 2016-06-20 13:59:52.000000000 +0200
  118. @@ -292,6 +292,10 @@
  119. parsedCommandLine->AppendSwitchASCII(switches::kProfilerTiming, switches::kProfilerTimingDisabledValue);
  120. }
  121. + parsedCommandLine->AppendSwitch(switches::kEnableViewport);
  122. + parsedCommandLine->AppendSwitch(switches::kDisableGpu);
  123. + parsedCommandLine->AppendSwitch(switches::kDisableWebSecurity);
  124. +
  125. GLContextHelper::initialize();
  126. if (usingANGLE() || usingSoftwareDynamicGL() || usingQtQuick2DRenderer()) {
  127. --- qtbase/src/gui/kernel/qsurfaceformat.cpp
  128. +++ qtbase/src/gui/kernel/qsurfaceformat.cpp
  129. @@ -108,6 +108,7 @@ public:
  130. int major;
  131. int minor;
  132. int swapInterval;
  133. + QSurfaceFormat::OrientationFlags orientationFlags;
  134. };
  135. /*!
  136. @@ -734,6 +735,16 @@ int QSurfaceFormat::swapInterval() const
  137. return d->swapInterval;
  138. }
  139. +QSurfaceFormat::OrientationFlags QSurfaceFormat::orientationFlags() const
  140. +{
  141. + return d->orientationFlags;
  142. +}
  143. +
  144. +void QSurfaceFormat::setOrientationFlags(QSurfaceFormat::OrientationFlags orientationFlags)
  145. +{
  146. + d->orientationFlags = orientationFlags;
  147. +}
  148. +
  149. Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)
  150. /*!
  151. --- qtbase/src/gui/kernel/qsurfaceformat.h
  152. +++ qtbase/src/gui/kernel/qsurfaceformat.h
  153. @@ -55,7 +55,8 @@ public:
  154. StereoBuffers = 0x0001,
  155. DebugContext = 0x0002,
  156. DeprecatedFunctions = 0x0004,
  157. - ResetNotification = 0x0008
  158. + ResetNotification = 0x0008,
  159. + UseOptimalOrientation = 0x0010
  160. };
  161. Q_DECLARE_FLAGS(FormatOptions, FormatOption)
  162. @@ -79,6 +80,11 @@ public:
  163. CompatibilityProfile
  164. };
  165. + enum OrientationFlag {
  166. + MirrorVertically = 0x0001,
  167. + };
  168. + Q_DECLARE_FLAGS(OrientationFlags, OrientationFlag)
  169. +
  170. QSurfaceFormat();
  171. /*implicit*/ QSurfaceFormat(FormatOptions options);
  172. QSurfaceFormat(const QSurfaceFormat &other);
  173. @@ -139,6 +145,9 @@ public:
  174. int swapInterval() const;
  175. void setSwapInterval(int interval);
  176. + QSurfaceFormat::OrientationFlags orientationFlags() const;
  177. + void setOrientationFlags(QSurfaceFormat::OrientationFlags orientationFlags);
  178. +
  179. static void setDefaultFormat(const QSurfaceFormat &format);
  180. static QSurfaceFormat defaultFormat();
  181. --- qtbase/src/plugins/platforms/windows/qwindowseglcontext.cpp
  182. +++ qtbase/src/plugins/platforms/windows/qwindowseglcontext.cpp
  183. @@ -282,11 +282,25 @@ QWindowsOpenGLContext *QWindowsEGLStaticContext::createContext(QOpenGLContext *c
  184. return new QWindowsEGLContext(this, context->format(), context->shareHandle());
  185. }
  186. -void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err)
  187. +void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, const QSurfaceFormat format, int *err)
  188. {
  189. *err = 0;
  190. +
  191. + std::vector<EGLint> attrib_list;
  192. +#ifdef EGL_ANGLE_surface_orientation
  193. + if (format.testOption(QSurfaceFormat::UseOptimalOrientation)) {
  194. + EGLint surfaceOrientation = 0;
  195. + libEGL.eglGetConfigAttrib(m_display, nativeConfig, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &surfaceOrientation);
  196. + if (surfaceOrientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE) {
  197. + attrib_list.push_back(EGL_SURFACE_ORIENTATION_ANGLE);
  198. + attrib_list.push_back(EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE);
  199. + }
  200. + }
  201. +#endif
  202. + attrib_list.push_back(EGL_NONE);
  203. EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, nativeConfig,
  204. - static_cast<EGLNativeWindowType>(nativeWindow), 0);
  205. + static_cast<EGLNativeWindowType>(nativeWindow),
  206. + &attrib_list[0]);
  207. if (surface == EGL_NO_SURFACE) {
  208. *err = libEGL.eglGetError();
  209. qWarning("%s: Could not create the EGL window surface: 0x%x", __FUNCTION__, *err);
  210. @@ -335,6 +349,14 @@ QSurfaceFormat QWindowsEGLStaticContext::formatFromConfig(EGLDisplay display, EG
  211. format.setStereo(false);
  212. format.setSwapInterval(referenceFormat.swapInterval());
  213. +#ifdef EGL_ANGLE_surface_orientation
  214. + if (referenceFormat.testOption(QSurfaceFormat::UseOptimalOrientation)) {
  215. + EGLint surfaceOrientation = 0;
  216. + libEGL.eglGetConfigAttrib(display, config, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &surfaceOrientation);
  217. + format.setOrientationFlags((surfaceOrientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE) ? QSurfaceFormat::MirrorVertically : QSurfaceFormat::OrientationFlags());
  218. + }
  219. +#endif
  220. +
  221. // Clear the EGL error state because some of the above may
  222. // have errored out because the attribute is not applicable
  223. // to the surface type. Such errors don't matter.
  224. @@ -430,7 +452,7 @@ QWindowsEGLContext::QWindowsEGLContext(QWindowsEGLStaticContext *staticContext,
  225. }
  226. }
  227. m_format.setProfile(QSurfaceFormat::NoProfile);
  228. - m_format.setOptions(QSurfaceFormat::FormatOptions());
  229. + m_format.setOptions(m_format.options() & QSurfaceFormat::UseOptimalOrientation);
  230. QWindowsEGLStaticContext::libEGL.eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);
  231. }
  232. QWindowsEGLStaticContext::libEGL.eglDestroySurface(m_eglDisplay, pbuffer);
  233. --- qtbase/src/plugins/platforms/windows/qwindowseglcontext.h
  234. +++ qtbase/src/plugins/platforms/windows/qwindowseglcontext.h
  235. @@ -121,7 +121,7 @@ public:
  236. void *moduleHandle() const Q_DECL_OVERRIDE { return libGLESv2.moduleHandle(); }
  237. QOpenGLContext::OpenGLModuleType moduleType() const Q_DECL_OVERRIDE { return QOpenGLContext::LibGLES; }
  238. - void *createWindowSurface(void *nativeWindow, void *nativeConfig, int *err) Q_DECL_OVERRIDE;
  239. + void *createWindowSurface(void *nativeWindow, void *nativeConfig, const QSurfaceFormat format, int *err) Q_DECL_OVERRIDE;
  240. void destroyWindowSurface(void *nativeSurface) Q_DECL_OVERRIDE;
  241. QSurfaceFormat formatFromConfig(EGLDisplay display, EGLConfig config, const QSurfaceFormat &referenceFormat);
  242. --- qtbase/src/plugins/platforms/windows/qwindowsopenglcontext.h
  243. +++ qtbase/src/plugins/platforms/windows/qwindowsopenglcontext.h
  244. @@ -62,7 +62,7 @@ public:
  245. // If the windowing system interface needs explicitly created window surfaces (like EGL),
  246. // reimplement these.
  247. - virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/, int * /*err*/) { return 0; }
  248. + virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/, const QSurfaceFormat /*format*/, int * /*err*/) { return 0; }
  249. virtual void destroyWindowSurface(void * /*nativeSurface*/) { }
  250. private:
  251. --- qtbase/src/plugins/platforms/windows/qwindowswindow.cpp
  252. +++ qtbase/src/plugins/platforms/windows/qwindowswindow.cpp
  253. @@ -2458,7 +2458,7 @@ void *QWindowsWindow::surface(void *nativeConfig, int *err)
  254. #else
  255. if (!m_surface) {
  256. if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
  257. - m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig, err);
  258. + m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig, m_format, err);
  259. }
  260. return m_surface;
  261. --- qtdeclarative/src/quick/items/qquickwindow.cpp
  262. +++ qtdeclarative/src/quick/items/qquickwindow.cpp
  263. @@ -458,7 +458,13 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
  264. renderer->setDeviceRect(rect);
  265. renderer->setViewportRect(rect);
  266. }
  267. - renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
  268. + QRectF projRect(QPoint(0, 0), size);
  269. + bool mirrorVertically = QOpenGLContext::currentContext()->format().orientationFlags() & QSurfaceFormat::MirrorVertically;
  270. + QRectF mirrored(projRect.left(),
  271. + mirrorVertically ? projRect.bottom() : projRect.top(),
  272. + projRect.width(),
  273. + mirrorVertically ? -projRect.height() : projRect.height());
  274. + renderer->setProjectionMatrixToRect(mirrored);
  275. renderer->setDevicePixelRatio(devicePixelRatio);
  276. context->renderNextFrame(renderer, fboId);
  277. --- qtdeclarative/src/quick/scenegraph/qsgcontext.cpp
  278. +++ qtdeclarative/src/quick/scenegraph/qsgcontext.cpp
  279. @@ -476,6 +476,8 @@ QSurfaceFormat QSGContext::defaultSurfaceFormat() const
  280. static bool enableDebug = qEnvironmentVariableIsSet("QSG_OPENGL_DEBUG");
  281. format.setDepthBufferSize(useDepth ? 24 : 0);
  282. format.setStencilBufferSize(useStencil ? 8 : 0);
  283. + // XXX: Uncomment to enable application-side Y-coordinates-flipping by default
  284. + // format.setOption(QSurfaceFormat::UseOptimalOrientation);
  285. if (enableDebug)
  286. format.setOption(QSurfaceFormat::DebugContext);
  287. if (QQuickWindow::hasDefaultAlphaBuffer())