[WPE] Floating point exception in WebEventFactory::createWebWheelEvent
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2018 15:38:29 +0000 (15:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2018 15:38:29 +0000 (15:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184037

Patch by Carlos Eduardo Ramalho <cadubentzen@gmail.com> on 2018-03-29
Reviewed by Žan Doberšek.

* Shared/wpe/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebWheelEvent): Use std::copysign() to avoid division by 0.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230074 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Shared/wpe/WebEventFactory.cpp

index 4d83dca..93e5a02 100644 (file)
@@ -1,3 +1,13 @@
+2018-03-29  Carlos Eduardo Ramalho  <cadubentzen@gmail.com>
+
+        [WPE] Floating point exception in WebEventFactory::createWebWheelEvent
+        https://bugs.webkit.org/show_bug.cgi?id=184037
+
+        Reviewed by Žan Doberšek.
+
+        * Shared/wpe/WebEventFactory.cpp:
+        (WebKit::WebEventFactory::createWebWheelEvent): Use std::copysign() to avoid division by 0.
+
 2018-03-28  Zalan Bujtas  <zalan@apple.com>
 
         Make it possible to override the screen size
index 6bedf6a..1935899 100644 (file)
@@ -27,7 +27,7 @@
 #include "WebEventFactory.h"
 
 #include <WebCore/Scrollbar.h>
-#include <cstdlib>
+#include <cmath>
 #include <wpe/input.h>
 #include <wtf/glib/GUniquePtr.h>
 
@@ -145,12 +145,12 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(struct wpe_input_axis_event*
     WebCore::FloatSize delta;
     switch (event->axis) {
     case Vertical:
-        wheelTicks = WebCore::FloatSize(0, event->value / std::abs(event->value));
+        wheelTicks = WebCore::FloatSize(0, std::copysign(1, event->value));
         delta = wheelTicks;
         delta.scale(WebCore::Scrollbar::pixelsPerLineStep());
         break;
     case Horizontal:
-        wheelTicks = WebCore::FloatSize(event->value / std::abs(event->value), 0);
+        wheelTicks = WebCore::FloatSize(std::copysign(1, event->value), 0);
         delta = wheelTicks;
         delta.scale(WebCore::Scrollbar::pixelsPerLineStep());
         break;