Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: content/common/input/web_input_event_traits.cc

Issue 250923004: Synthesize ctrl-wheel events on touchpad pinch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ensure scales never coalesce to 0 or Infinity Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/input/web_input_event_traits.cc
diff --git a/content/common/input/web_input_event_traits.cc b/content/common/input/web_input_event_traits.cc
index 4dcd4ba153c60fb807a34e14dd16262abcc2cf99..fa9f433a1d7fd538a6e1cd23ce6e0424e98f6cd9 100644
--- a/content/common/input/web_input_event_traits.cc
+++ b/content/common/input/web_input_event_traits.cc
@@ -5,6 +5,7 @@
#include "content/common/input/web_input_event_traits.h"
#include <bitset>
+#include <limits>
#include "base/logging.h"
@@ -14,6 +15,7 @@ using blink::WebKeyboardEvent;
using blink::WebMouseEvent;
using blink::WebMouseWheelEvent;
using blink::WebTouchEvent;
+using std::numeric_limits;
namespace content {
namespace {
@@ -173,6 +175,12 @@ void Coalesce(const WebGestureEvent& event_to_coalesce,
event_to_coalesce.data.scrollUpdate.deltaY;
} else if (event->type == WebInputEvent::GesturePinchUpdate) {
event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale;
+ // Ensure the scale remains bounded above 0 and below Infinity so that
+ // we can reliably perform operations like log on the values.
+ if (event->data.pinchUpdate.scale < numeric_limits<float>::min())
+ event->data.pinchUpdate.scale = numeric_limits<float>::min();
+ else if (event->data.pinchUpdate.scale > numeric_limits<float>::max())
+ event->data.pinchUpdate.scale = numeric_limits<float>::max();
}
}
« no previous file with comments | « content/common/input/synthetic_web_input_event_builders.cc ('k') | content/common/input/web_input_event_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698