From 6fc84ae2ceccf0ab20db2fe98d919761d07e3b53 Mon Sep 17 00:00:00 2001 From: ruevs Date: Sun, 6 Nov 2022 03:42:23 +0200 Subject: [PATCH] Web: Remove the device pixel ratio workaround for Android tablets. Afetr the `GetDevicePixelRatio` function was fixed to return `double` `useWorkaround_devicePixelRatio` is not needed any more so remove it. See the discussion in #1310 pull request for details. --- src/platform/guihtml.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/platform/guihtml.cpp b/src/platform/guihtml.cpp index d80c4ff..223e4a4 100644 --- a/src/platform/guihtml.cpp +++ b/src/platform/guihtml.cpp @@ -579,9 +579,6 @@ public: std::function editingDoneFunc; std::shared_ptr menuBar; - bool useWorkaround_devicePixelRatio = false; - - WindowImplHtml(val htmlContainer, std::string emCanvasSel) : emCanvasSel(emCanvasSel), htmlContainer(htmlContainer), @@ -618,12 +615,6 @@ public: this->scrollbarHelper.set("onScrollCallback", Wrap(&onScrollCallback)); } - //FIXME(emscripten): In Chrome for Android on tablet device, devicePixelRatio should not be multiplied. - std::string userAgent = val::global("navigator")["userAgent"].as(); - bool is_smartphone = userAgent.find("Mobile") != std::string::npos; - bool is_android_device = userAgent.find("Android") != std::string::npos; - this->useWorkaround_devicePixelRatio = is_android_device && !is_smartphone; - sscheck(emscripten_set_resize_callback( EMSCRIPTEN_EVENT_TARGET_WINDOW, this, /*useCapture=*/false, WindowImplHtml::ResizeCallback)); @@ -933,14 +924,9 @@ public: sscheck(emscripten_get_element_css_size(htmlContainerSel.c_str(), &width, &height)); // sscheck(emscripten_get_element_css_size(emCanvasSel.c_str(), &width, &height)); - if (this->useWorkaround_devicePixelRatio) { - // Workaround is to skip applying devicePixelRatio. - // So NOP here. - } else { - double devicePixelRatio = emscripten_get_device_pixel_ratio(); - width *= devicePixelRatio; - height *= devicePixelRatio; - } + double devicePixelRatio = GetDevicePixelRatio(); + width *= devicePixelRatio; + height *= devicePixelRatio; int currentWidth = 0, currentHeight = 0; sscheck(emscripten_get_canvas_element_size(emCanvasSel.c_str(), ¤tWidth, ¤tHeight)); @@ -967,7 +953,7 @@ public: } double GetPixelDensity() override { - return 96.0 * emscripten_get_device_pixel_ratio(); + return 96.0 * GetDevicePixelRatio(); } double GetDevicePixelRatio() override {