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

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

Issue 1560553002: Framelet Prototype 2016 Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased + Applied Brett's Windows + Fixed security issue Created 4 years, 11 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/public/common/input/web_input_event_traits.cc
diff --git a/content/common/input/web_input_event_traits.cc b/content/public/common/input/web_input_event_traits.cc
similarity index 84%
rename from content/common/input/web_input_event_traits.cc
rename to content/public/common/input/web_input_event_traits.cc
index 1008c549ef6909e60ff73a637efea217c6f11c4a..54cd76714b8b094fce4b2664d575f4a172434f5d 100644
--- a/content/common/input/web_input_event_traits.cc
+++ b/content/public/common/input/web_input_event_traits.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/input/web_input_event_traits.h"
+#include "content/public/common/input/web_input_event_traits.h"
#include <bitset>
#include <limits>
@@ -30,9 +30,7 @@ void ApppendEventDetails(const WebKeyboardEvent& event, std::string* result) {
StringAppendF(result,
"{\n WinCode: %d\n NativeCode: %d\n IsSystem: %d\n"
" Text: %s\n UnmodifiedText: %s\n KeyIdentifier: %s\n}",
- event.windowsKeyCode,
- event.nativeKeyCode,
- event.isSystemKey,
+ event.windowsKeyCode, event.nativeKeyCode, event.isSystemKey,
reinterpret_cast<const char*>(event.text),
reinterpret_cast<const char*>(event.unmodifiedText),
reinterpret_cast<const char*>(event.keyIdentifier));
@@ -42,71 +40,43 @@ void ApppendEventDetails(const WebMouseEvent& event, std::string* result) {
StringAppendF(result,
"{\n Button: %d\n Pos: (%d, %d)\n WindowPos: (%d, %d)\n"
" GlobalPos: (%d, %d)\n Movement: (%d, %d)\n Clicks: %d\n}",
- event.button,
- event.x,
- event.y,
- event.windowX,
- event.windowY,
- event.globalX,
- event.globalY,
- event.movementX,
- event.movementY,
+ event.button, event.x, event.y, event.windowX, event.windowY,
+ event.globalX, event.globalY, event.movementX, event.movementY,
event.clickCount);
}
void ApppendEventDetails(const WebMouseWheelEvent& event, std::string* result) {
- StringAppendF(result,
- "{\n Delta: (%f, %f)\n WheelTicks: (%f, %f)\n Accel: (%f, %f)\n"
- " ScrollByPage: %d\n HasPreciseScrollingDeltas: %d\n"
- " Phase: (%d, %d)\n CanRubberband: (%d, %d)\n CanScroll: %d\n}",
- event.deltaX,
- event.deltaY,
- event.wheelTicksX,
- event.wheelTicksY,
- event.accelerationRatioX,
- event.accelerationRatioY,
- event.scrollByPage,
- event.hasPreciseScrollingDeltas,
- event.phase,
- event.momentumPhase,
- event.canRubberbandLeft,
- event.canRubberbandRight,
- event.canScroll);
+ StringAppendF(
+ result,
+ "{\n Delta: (%f, %f)\n WheelTicks: (%f, %f)\n Accel: (%f, %f)\n"
+ " ScrollByPage: %d\n HasPreciseScrollingDeltas: %d\n"
+ " Phase: (%d, %d)\n CanRubberband: (%d, %d)\n CanScroll: %d\n}",
+ event.deltaX, event.deltaY, event.wheelTicksX, event.wheelTicksY,
+ event.accelerationRatioX, event.accelerationRatioY, event.scrollByPage,
+ event.hasPreciseScrollingDeltas, event.phase, event.momentumPhase,
+ event.canRubberbandLeft, event.canRubberbandRight, event.canScroll);
}
void ApppendEventDetails(const WebGestureEvent& event, std::string* result) {
- StringAppendF(result,
- "{\n Pos: (%d, %d)\n GlobalPos: (%d, %d)\n SourceDevice: %d\n"
- " RawData: (%f, %f, %f, %f, %d)\n}",
- event.x,
- event.y,
- event.globalX,
- event.globalY,
- event.sourceDevice,
- event.data.scrollUpdate.deltaX,
- event.data.scrollUpdate.deltaY,
- event.data.scrollUpdate.velocityX,
- event.data.scrollUpdate.velocityY,
- event.data.scrollUpdate.previousUpdateInSequencePrevented);
+ StringAppendF(
+ result,
+ "{\n Pos: (%d, %d)\n GlobalPos: (%d, %d)\n SourceDevice: %d\n"
+ " RawData: (%f, %f, %f, %f, %d)\n}",
+ event.x, event.y, event.globalX, event.globalY, event.sourceDevice,
+ event.data.scrollUpdate.deltaX, event.data.scrollUpdate.deltaY,
+ event.data.scrollUpdate.velocityX, event.data.scrollUpdate.velocityY,
+ event.data.scrollUpdate.previousUpdateInSequencePrevented);
}
void ApppendTouchPointDetails(const WebTouchPoint& point, std::string* result) {
StringAppendF(result,
- " (ID: %d, State: %d, ScreenPos: (%f, %f), Pos: (%f, %f),"
- " Radius: (%f, %f), Rot: %f, Force: %f,"
- " Tilt: (%d, %d)),\n",
- point.id,
- point.state,
- point.screenPosition.x,
- point.screenPosition.y,
- point.position.x,
- point.position.y,
- point.radiusX,
- point.radiusY,
- point.rotationAngle,
- point.force,
- point.tiltX,
- point.tiltY);
+ " (ID: %d, State: %d, ScreenPos: (%f, %f), Pos: (%f, %f),"
+ " Radius: (%f, %f), Rot: %f, Force: %f,"
+ " Tilt: (%d, %d)),\n",
+ point.id, point.state, point.screenPosition.x,
+ point.screenPosition.y, point.position.x, point.position.y,
+ point.radiusX, point.radiusY, point.rotationAngle, point.force,
+ point.tiltX, point.tiltY);
}
void ApppendEventDetails(const WebTouchEvent& event, std::string* result) {
@@ -171,13 +141,11 @@ void Coalesce(const WebMouseWheelEvent& event_to_coalesce,
WebMouseWheelEvent* event) {
DCHECK(CanCoalesce(event_to_coalesce, *event));
float unaccelerated_x =
- GetUnacceleratedDelta(event->deltaX,
- event->accelerationRatioX) +
+ GetUnacceleratedDelta(event->deltaX, event->accelerationRatioX) +
GetUnacceleratedDelta(event_to_coalesce.deltaX,
event_to_coalesce.accelerationRatioX);
float unaccelerated_y =
- GetUnacceleratedDelta(event->deltaY,
- event->accelerationRatioY) +
+ GetUnacceleratedDelta(event->deltaY, event->accelerationRatioY) +
GetUnacceleratedDelta(event_to_coalesce.deltaY,
event_to_coalesce.accelerationRatioY);
event->deltaX += event_to_coalesce.deltaX;
@@ -256,8 +224,7 @@ bool CanCoalesce(const WebGestureEvent& event_to_coalesce,
// GesturePinchUpdate scales can be combined only if they share a focal point,
// e.g., with double-tap drag zoom.
if (event.type == WebInputEvent::GesturePinchUpdate &&
- event.x == event_to_coalesce.x &&
- event.y == event_to_coalesce.y)
+ event.x == event_to_coalesce.x && event.y == event_to_coalesce.y)
return true;
return false;
@@ -290,8 +257,7 @@ struct WebInputEventToString {
bool Execute(const WebInputEvent& event, std::string* result) const {
SStringPrintf(result, "%s (Time: %lf, Modifiers: %d)\n",
WebInputEventTraits::GetName(event.type),
- event.timeStampSeconds,
- event.modifiers);
+ event.timeStampSeconds, event.modifiers);
const EventType& typed_event = static_cast<const EventType&>(event);
ApppendEventDetails(typed_event, result);
return true;
@@ -378,8 +344,10 @@ bool Apply(Operator op,
} // namespace
const char* WebInputEventTraits::GetName(WebInputEvent::Type type) {
-#define CASE_TYPE(t) case WebInputEvent::t: return #t
- switch(type) {
+#define CASE_TYPE(t) \
+ case WebInputEvent::t: \
+ return #t
+ switch (type) {
CASE_TYPE(Undefined);
CASE_TYPE(MouseDown);
CASE_TYPE(MouseUp);
@@ -416,8 +384,8 @@ const char* WebInputEventTraits::GetName(WebInputEvent::Type type) {
default:
// Must include default to let blink::WebInputEvent add new event types
// before they're added here.
- DLOG(WARNING) <<
- "Unhandled WebInputEvent type in WebInputEventTraits::GetName.\n";
+ DLOG(WARNING)
+ << "Unhandled WebInputEvent type in WebInputEventTraits::GetName.\n";
break;
}
#undef CASE_TYPE
@@ -454,9 +422,7 @@ bool WebInputEventTraits::CanCoalesce(const WebInputEvent& event_to_coalesce,
// Early out before casting.
if (event_to_coalesce.type != event.type)
return false;
- return Apply(WebInputEventCanCoalesce(),
- event.type,
- event_to_coalesce,
+ return Apply(WebInputEventCanCoalesce(), event.type, event_to_coalesce,
&event);
}
« no previous file with comments | « content/public/common/input/web_input_event_traits.h ('k') | content/public/common/input/web_touch_event_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698