diff options
author | dimich <dimich@chromium.org> | 2016-03-03 14:40:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-03 22:42:22 +0000 |
commit | 6b7bd07d9d9494437e901881d3938297b261bb98 (patch) | |
tree | 39d3b58aed450bcede602bd9c1b149925e76af68 | |
parent | 67b71ea2e11563a4c0363e1dce4e266cebcd063a (diff) | |
download | chromium_src-6b7bd07d9d9494437e901881d3938297b261bb98.zip chromium_src-6b7bd07d9d9494437e901881d3938297b261bb98.tar.gz chromium_src-6b7bd07d9d9494437e901881d3938297b261bb98.tar.bz2 |
Revert of IPC::ParamTraits for ui::Event (towards ui::Events over mojo IPC) (patchset #18 id:340001 of https://codereview.chromium.org/1695783002/ )
Reason for revert:
Breaks compile: https://build.chromium.org/p/chromium.win/builders/Win%20x64%20GN%20%28dbg%29/builds/19183
Original issue's description:
> Implements and tests IPC::ParamTraits for ui::Event (towards ui::Events over mojo IPC). Support for (scoped) pointers for abstract ui::Event objects implemented using ui::ScopedEvent, and trusting ui::EventType information to instantiate the correct concrete type.
>
> BUG=584687
>
> Committed: https://crrev.com/482ddfefe2602f440146eebf4b56e8e040fb81fa
> Cr-Commit-Position: refs/heads/master@{#378821}
>
> Committed: https://crrev.com/74b231ad33ec44bc2662fef2831a3cd90e1f3834
> Cr-Commit-Position: refs/heads/master@{#379094}
TBR=rockot@chromium.org,sadrul@chromium.org,kenrb@chromium.org,tsepez@chromium.org,jam@chromium.org,sky@chromium.org,fsamuel@chromium.org,markdittmer@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=584687
Review URL: https://codereview.chromium.org/1765693002
Cr-Commit-Position: refs/heads/master@{#379123}
-rw-r--r-- | ash/mus/BUILD.gn | 2 | ||||
-rw-r--r-- | components/mus/BUILD.gn | 8 | ||||
-rw-r--r-- | components/mus/DEPS | 2 | ||||
-rw-r--r-- | components/mus/common/BUILD.gn | 35 | ||||
-rw-r--r-- | components/mus/common/args.cc | 3 | ||||
-rw-r--r-- | components/mus/common/event_param_traits.cc | 277 | ||||
-rw-r--r-- | components/mus/common/event_param_traits.h | 95 | ||||
-rw-r--r-- | components/mus/common/event_param_traits_macros.h | 101 | ||||
-rw-r--r-- | components/mus/common/event_param_traits_unittest.cc | 468 | ||||
-rw-r--r-- | components/mus/common/mus_common_export.h | 29 | ||||
-rw-r--r-- | components/mus/public/cpp/BUILD.gn | 2 | ||||
-rw-r--r-- | components/mus/public/cpp/tests/BUILD.gn | 2 | ||||
-rw-r--r-- | components/mus/ws/BUILD.gn | 8 | ||||
-rw-r--r-- | mash/wm/BUILD.gn | 2 | ||||
-rw-r--r-- | ui/events/event.cc | 3 | ||||
-rw-r--r-- | ui/events/event.h | 70 | ||||
-rw-r--r-- | ui/events/events.gyp | 3 | ||||
-rw-r--r-- | ui/events/gesture_event_details.h | 18 | ||||
-rw-r--r-- | ui/events/ipc/BUILD.gn | 1 | ||||
-rw-r--r-- | ui/events/keycodes/dom/dom_key.h | 3 | ||||
-rw-r--r-- | ui/gfx/ipc/gfx_param_traits.cc | 16 | ||||
-rw-r--r-- | ui/gfx/ipc/gfx_param_traits.h | 3 | ||||
-rw-r--r-- | ui/metro_viewer/metro_viewer_messages.h | 19 |
23 files changed, 38 insertions, 1132 deletions
diff --git a/ash/mus/BUILD.gn b/ash/mus/BUILD.gn index c6e9c9c..2a4664f 100644 --- a/ash/mus/BUILD.gn +++ b/ash/mus/BUILD.gn @@ -26,7 +26,7 @@ source_set("lib") { "//ash", "//cc", "//cc/surfaces", - "//components/mus/common:mus_common", + "//components/mus/common", "//components/mus/public/cpp", "//components/mus/public/interfaces", "//components/user_manager", diff --git a/components/mus/BUILD.gn b/components/mus/BUILD.gn index 5891ffa9..b29f28e 100644 --- a/components/mus/BUILD.gn +++ b/components/mus/BUILD.gn @@ -75,9 +75,6 @@ source_set("lib") { "mus_app.h", ] - public_deps = [ - "//components/mus/common:mus_common", - ] deps = [ ":resources_100", ":resources_200", @@ -85,6 +82,7 @@ source_set("lib") { "//base", "//cc", "//cc/surfaces", + "//components/mus/common", "//components/mus/gles2", "//components/mus/public/interfaces", "//components/mus/surfaces", @@ -105,7 +103,9 @@ source_set("lib") { if (use_x11) { public_configs = [ "//build/config/linux:x11" ] - public_deps += [ "//ui/events/platform/x11" ] + public_deps = [ + "//ui/events/platform/x11", + ] } if (use_ozone) { diff --git a/components/mus/DEPS b/components/mus/DEPS index 9ccd854..05f5c20 100644 --- a/components/mus/DEPS +++ b/components/mus/DEPS @@ -2,7 +2,7 @@ include_rules = [ "+cc", "+components/resource_provider", "+components/gpu", - "+ipc", + "+mojo/shell", "+mojo/common", "+mojo/converters", "+mojo/public", diff --git a/components/mus/common/BUILD.gn b/components/mus/common/BUILD.gn index 6f765c1..d0cc5d7 100644 --- a/components/mus/common/BUILD.gn +++ b/components/mus/common/BUILD.gn @@ -2,49 +2,16 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//testing/test.gni") - -component("mus_common") { +source_set("common") { sources = [ "args.cc", "args.h", - "event_param_traits.cc", - "event_param_traits.h", - "event_param_traits_macros.h", - "mus_common_export.h", "transient_window_utils.h", "types.h", "util.h", "window_tracker.h", ] - - defines = [ "MUS_IPC_IMPLEMENTATION" ] - deps = [ "//components/mus/public/interfaces", - "//ipc:ipc", - "//mojo/public/c/system:for_component", - "//ui/events:events", - "//ui/gfx/ipc", - ] -} - -test("mus_common_unittests") { - sources = [ - "event_param_traits_unittest.cc", - ] - public_deps = [ - ":mus_common", - ] - deps = [ - "//base", - "//base/test:run_all_unittests", - "//base/test:test_config", - "//ipc:ipc", - "//mojo/edk/test:test_support", - "//testing/gtest", - "//ui/events:events", - "//ui/gfx:test_support", - "//ui/gfx/ipc", ] } diff --git a/components/mus/common/args.cc b/components/mus/common/args.cc index 634828a..c60d591 100644 --- a/components/mus/common/args.cc +++ b/components/mus/common/args.cc @@ -3,12 +3,11 @@ // found in the LICENSE file. #include "components/mus/common/args.h" -#include "components/mus/common/mus_common_export.h" namespace mus { // Initializes X11 in threaded mode, and sets the |override_redirect| flag when // creating X11 windows. -const char MUS_COMMON_EXPORT kUseX11TestConfig[] = "use-x11-test-config"; +const char kUseX11TestConfig[] = "use-x11-test-config"; } // namespace mus diff --git a/components/mus/common/event_param_traits.cc b/components/mus/common/event_param_traits.cc deleted file mode 100644 index 2fd40db..0000000 --- a/components/mus/common/event_param_traits.cc +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (c) 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/mus/common/event_param_traits.h" - -#include <string.h> - -#include "ipc/ipc_message_utils.h" -#include "ipc/ipc_param_traits.h" -#include "ui/events/event.h" -#include "ui/gfx/ipc/gfx_param_traits.h" - -// Generate param traits size methods. -#include "ipc/param_traits_size_macros.h" -namespace IPC { -#include "components/mus/common/event_param_traits_macros.h" -} - -// Generate param traits write methods. -#include "ipc/param_traits_write_macros.h" -namespace IPC { -#include "components/mus/common/event_param_traits_macros.h" -} - -// Generate param traits read methods. -#include "ipc/param_traits_read_macros.h" -namespace IPC { -#include "components/mus/common/event_param_traits_macros.h" -} - -// Generate param traits log methods. -#include "ipc/param_traits_log_macros.h" -namespace IPC { -#include "components/mus/common/event_param_traits_macros.h" -} - -namespace IPC { - -// Implements (Write|Read|Log)Event for event type-qualified functions. Every -// such function invokes an implementation according to the event type and -// flags, or else invokes a default implementation. Event constructors require -// |type|, |time_stamp|, and |flags| (hence the common arguments passed to each -// implementation). -#define EVENT_IMPL(ReturnType, methodName, implName, defaultCase, ...) \ - ReturnType ParamTraits<ui::ScopedEvent>::methodName( \ - ui::EventType type, base::TimeDelta time_stamp, int flags, \ - ##__VA_ARGS__) { \ - switch (type) { \ - case ui::EventType::ET_MOUSE_PRESSED: \ - case ui::EventType::ET_MOUSE_DRAGGED: \ - case ui::EventType::ET_MOUSE_RELEASED: \ - case ui::EventType::ET_MOUSE_MOVED: \ - case ui::EventType::ET_MOUSE_ENTERED: \ - case ui::EventType::ET_MOUSE_EXITED: \ - case ui::EventType::ET_MOUSE_CAPTURE_CHANGED: \ - implName(ui::MouseEvent) \ - case ui::EventType::ET_KEY_PRESSED: \ - case ui::EventType::ET_KEY_RELEASED: \ - implName(ui::KeyEvent) \ - case ui::EventType::ET_MOUSEWHEEL: \ - implName(ui::MouseWheelEvent) \ - case ui::EventType::ET_TOUCH_RELEASED: \ - case ui::EventType::ET_TOUCH_PRESSED: \ - case ui::EventType::ET_TOUCH_MOVED: \ - case ui::EventType::ET_TOUCH_CANCELLED: \ - case ui::EventType::ET_DROP_TARGET_EVENT: \ - implName(ui::TouchEvent) \ - case ui::EventType::ET_GESTURE_SCROLL_BEGIN: \ - case ui::EventType::ET_GESTURE_SCROLL_END: \ - case ui::EventType::ET_GESTURE_SCROLL_UPDATE: \ - case ui::EventType::ET_GESTURE_SHOW_PRESS: \ - case ui::EventType::ET_GESTURE_WIN8_EDGE_SWIPE: \ - case ui::EventType::ET_GESTURE_TAP: \ - case ui::EventType::ET_GESTURE_TAP_DOWN: \ - case ui::EventType::ET_GESTURE_TAP_CANCEL: \ - case ui::EventType::ET_GESTURE_BEGIN: \ - case ui::EventType::ET_GESTURE_END: \ - case ui::EventType::ET_GESTURE_TWO_FINGER_TAP: \ - case ui::EventType::ET_GESTURE_PINCH_BEGIN: \ - case ui::EventType::ET_GESTURE_PINCH_END: \ - case ui::EventType::ET_GESTURE_PINCH_UPDATE: \ - case ui::EventType::ET_GESTURE_LONG_PRESS: \ - case ui::EventType::ET_GESTURE_LONG_TAP: \ - case ui::EventType::ET_GESTURE_SWIPE: \ - case ui::EventType::ET_GESTURE_TAP_UNCONFIRMED: \ - case ui::EventType::ET_GESTURE_DOUBLE_TAP: \ - implName(ui::GestureEvent) \ - case ui::EventType::ET_SCROLL: \ - implName(ui::ScrollEvent) \ - case ui::EventType::ET_SCROLL_FLING_START: \ - case ui::EventType::ET_SCROLL_FLING_CANCEL: \ - if (flags & ui::MouseEventFlags::EF_FROM_TOUCH) { \ - implName(ui::GestureEvent) \ - } else { \ - implName(ui::MouseEvent) \ - } \ - case ui::EventType::ET_CANCEL_MODE: \ - implName(ui::CancelModeEvent) \ - default: \ - defaultCase; \ - } \ - } - -// Concrete event type (T) implementation procedures: size, write, read, log. -#define SIZE_EVENT(T) ParamTraits<T>::GetSize(s, *static_cast<T*>(p.get())); -#define WRITE_EVENT(T) \ - ParamTraits<T>::Write(m, *static_cast<T*>(p.get())); \ - break; -#define READ_EVENT(T) \ - { \ - scoped_ptr<T> event(new T(type, time_stamp, flags)); \ - if (!ParamTraits<T>::Read(m, iter, event.get())) { \ - p->reset(); \ - return false; \ - } else { \ - *p = std::move(event); \ - return true; \ - } \ - } -#define LOG_EVENT(T) return ParamTraits<T>::Log(*static_cast<T*>(p.get()), l); - -// void SizeEvent(ui::EventType type, int flags, base::PickleSizer* s, -// const ui::ScopedEvent& p) { ... } -EVENT_IMPL(void, - SizeEvent, - SIZE_EVENT, - /* default switch/case: no-op */, - base::PickleSizer* s, - const ui::ScopedEvent& p) - -// void WriteEvent(ui::EventType type, int flags, base::Pickle* m, -// const ui::ScopedEvent& p) { ... } -EVENT_IMPL(void, - WriteEvent, - WRITE_EVENT, - /* default switch/case: no-op */, - base::Pickle* m, - const ui::ScopedEvent& p) - -// bool ReadEvent(ui::EventType type, int flags, base::Pickle* m, -// base::PickleIterator* iter, ui::ScopedEvent* p) { ... } -EVENT_IMPL(bool, - ReadEvent, - READ_EVENT, - return false;, - const base::Pickle* m, - base::PickleIterator* iter, - ui::ScopedEvent* p) - -// void LogEvent(ui::EventType type, int flags, const ui::ScopedEvent& p, -// std::string* l) { ... } -EVENT_IMPL(void, - LogEvent, - LOG_EVENT, - /* default switch/case: no-op */, - const ui::ScopedEvent& p, - std::string* l) - -#undef SIZE_EVENT -#undef WRITE_EVENT -#undef READ_EVENT -#undef LOG_EVENT -#undef EVENT_IMPL - -void ParamTraits<ui::ScopedEvent>::GetSize(base::PickleSizer* s, - const param_type& p) { - DCHECK(p); - GetParamSize(s, p->type_); - GetParamSize(s, p->name_); - GetParamSize(s, p->time_stamp_); - GetParamSize(s, p->flags_); - GetParamSize(s, p->phase_); - GetParamSize(s, p->result_); - GetParamSize(s, p->cancelable_); - SizeEvent(p->type_, p->time_stamp_, p->flags_, s, p); -} - -void ParamTraits<ui::ScopedEvent>::Write(base::Pickle* m, const param_type& p) { - DCHECK(p); - WriteParam(m, p->type_); - WriteParam(m, p->name_); - WriteParam(m, p->time_stamp_); - WriteParam(m, p->flags_); - WriteParam(m, p->phase_); - WriteParam(m, p->result_); - WriteParam(m, p->cancelable_); - WriteEvent(p->type_, p->time_stamp_, p->flags_, m, p); -} - -bool ParamTraits<ui::ScopedEvent>::Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* p) { - // Expect: valid ui::ScopedEvent that does not (yet) point to anything. - DCHECK(p && !*p); - - ui::EventType type; - std::string name; - base::TimeDelta time_stamp; - int flags; - ui::EventPhase phase; - ui::EventResult result; - bool cancelable; - - // Read initial params, then invoke ReadEvent which will reset() |p| to an - // instance of the correct concrete event type. - if (!ReadParam(m, iter, &type) || !ReadParam(m, iter, &name) || - !ReadParam(m, iter, &time_stamp) || !ReadParam(m, iter, &flags) || - !ReadParam(m, iter, &phase) || !ReadParam(m, iter, &result) || - !ReadParam(m, iter, &cancelable) || - !ReadEvent(type, time_stamp, flags, m, iter, p)) - return false; - - // Fill in abstract event information. - (*p)->type_ = type; - (*p)->name_ = name; - (*p)->time_stamp_ = time_stamp; - (*p)->flags_ = flags; - (*p)->phase_ = phase; - (*p)->result_ = result; - (*p)->cancelable_ = cancelable; - - return true; -} - -void ParamTraits<ui::ScopedEvent>::Log(const param_type& p, std::string* l) { - l->append("<UI Event: "); - LogEvent(p->type_, p->time_stamp_, p->flags_, p, l); - l->append(">"); -} - -void ParamTraits<ui::CancelModeEvent>::GetSize(base::PickleSizer* s, - const param_type& p) {} - -void ParamTraits<ui::CancelModeEvent>::Write(base::Pickle* m, - const param_type& p) {} - -bool ParamTraits<ui::CancelModeEvent>::Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* p) { - return true; -} - -void ParamTraits<ui::CancelModeEvent>::Log(const param_type& p, - std::string* l) { - l->append("<ui::CancelModeEvent>"); -} - -void ParamTraits<ui::GestureEventDetails::Details>::GetSize( - base::PickleSizer* s, - const param_type& p) { - s->AddBytes(sizeof(param_type)); -} - -void ParamTraits<ui::GestureEventDetails::Details>::Write(base::Pickle* m, - const param_type& p) { - m->WriteBytes(&p, sizeof(param_type)); -} - -bool ParamTraits<ui::GestureEventDetails::Details>::Read( - const base::Pickle* m, - base::PickleIterator* iter, - param_type* p) { - const char* data; - if (!iter->ReadBytes(&data, sizeof(param_type))) - return false; - - memcpy(p, data, sizeof(param_type)); - return true; -} - -void ParamTraits<ui::GestureEventDetails::Details>::Log(const param_type& p, - std::string* l) { - l->append("<ui::GestureEventDetails::Details>"); -} - -} // namespace IPC diff --git a/components/mus/common/event_param_traits.h b/components/mus/common/event_param_traits.h deleted file mode 100644 index c7702d9..0000000 --- a/components/mus/common/event_param_traits.h +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_MUS_COMMON_EVENT_PARAM_TRAITS_H_ -#define COMPONENTS_MUS_COMMON_EVENT_PARAM_TRAITS_H_ - -#include <string> - -#include "components/mus/common/event_param_traits_macros.h" -#include "components/mus/common/mus_common_export.h" -#include "ui/events/event.h" -#include "ui/events/gesture_event_details.h" - -namespace base { -class Pickle; -class PickleIterator; -} - -namespace ui { -class Event; -} - -namespace IPC { - -// Non-serialized data: -// -// Some event data only makes sense and/or is needed in the context where the -// raw event came from. As such, some data are explicitly NOT -// serialized. These data are as follows: -// base::NativeEvent native_event_; -// LatencyInfo* latency_; -// int source_device_id_; - -template <> -struct MUS_COMMON_EXPORT ParamTraits<ui::ScopedEvent> { - typedef ui::ScopedEvent param_type; - static void GetSize(base::PickleSizer* s, const param_type& p); - static void Write(base::Pickle* m, const param_type& p); - static bool Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* p); - static void Log(const param_type& p, std::string* l); - - static void SizeEvent(ui::EventType type, - base::TimeDelta time_stamp, - int flags, - base::PickleSizer* s, - const ui::ScopedEvent& p); - static void WriteEvent(ui::EventType type, - base::TimeDelta time_stamp, - int flags, - base::Pickle* m, - const ui::ScopedEvent& p); - static bool ReadEvent(ui::EventType type, - base::TimeDelta time_stamp, - int flags, - const base::Pickle* m, - base::PickleIterator* iter, - ui::ScopedEvent* p); - static void LogEvent(ui::EventType type, - base::TimeDelta time_stamp, - int flags, - const ui::ScopedEvent& p, - std::string* l); -}; - -// Manually implements no-op implementation for ui::CancelModeEvent because IPC -// BEGIN/END macros with no MEMBER or PARENT in between cause compiler -// errors. -template <> -struct ParamTraits<ui::CancelModeEvent> { - typedef ui::CancelModeEvent param_type; - static void GetSize(base::PickleSizer* s, const param_type& p); - static void Write(base::Pickle* m, const param_type& p); - static bool Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -template <> -struct ParamTraits<ui::GestureEventDetails::Details> { - typedef ui::GestureEventDetails::Details param_type; - static void GetSize(base::PickleSizer* s, const param_type& p); - static void Write(base::Pickle* m, const param_type& p); - static bool Read(const base::Pickle* m, - base::PickleIterator* iter, - param_type* p); - static void Log(const param_type& p, std::string* l); -}; - -} // namespace IPC - -#endif // COMPONENTS_MUS_COMMON_EVENT_PARAM_TRAITS_H_ diff --git a/components/mus/common/event_param_traits_macros.h b/components/mus/common/event_param_traits_macros.h deleted file mode 100644 index 10b4f36..0000000 --- a/components/mus/common/event_param_traits_macros.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - - -#include "components/mus/common/mus_common_export.h" -#include "ipc/ipc_message_utils.h" -#include "ipc/param_traits_macros.h" -#include "ui/events/event.h" -#include "ui/events/event_constants.h" - -#undef IPC_MESSAGE_EXPORT -#define IPC_MESSAGE_EXPORT MUS_COMMON_EXPORT - -IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::EventType, - ui::EventType::ET_UNKNOWN, - ui::EventType::ET_LAST) - -IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::EventResult, - ui::EventResult::ER_UNHANDLED, - ui::EventResult::ER_DISABLE_SYNC_HANDLING) - -IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::EventPhase, - ui::EventPhase::EP_PREDISPATCH, - ui::EventPhase::EP_POSTDISPATCH) - -IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::EventPointerType, - ui::EventPhase::EP_PREDISPATCH, - ui::EventPhase::EP_POSTDISPATCH) - -IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::KeyboardCode, - ui::KeyboardCode::VKEY_UNKNOWN, /* 0x00 */ - ui::KeyboardCode::VKEY_OEM_CLEAR /* 0xFE */) - -IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::DomCode, 0, 0x0c028c) - -IPC_STRUCT_TRAITS_BEGIN(ui::PointerDetails) - IPC_STRUCT_TRAITS_MEMBER(pointer_type) - IPC_STRUCT_TRAITS_MEMBER(radius_x) - IPC_STRUCT_TRAITS_MEMBER(radius_y) - IPC_STRUCT_TRAITS_MEMBER(force) - IPC_STRUCT_TRAITS_MEMBER(tilt_x) - IPC_STRUCT_TRAITS_MEMBER(tilt_y) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::LocatedEvent) - IPC_STRUCT_TRAITS_MEMBER(location_) - IPC_STRUCT_TRAITS_MEMBER(root_location_) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::MouseEvent) - IPC_STRUCT_TRAITS_PARENT(ui::LocatedEvent) - IPC_STRUCT_TRAITS_MEMBER(changed_button_flags_) - IPC_STRUCT_TRAITS_MEMBER(pointer_details_) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::MouseWheelEvent) - IPC_STRUCT_TRAITS_PARENT(ui::MouseEvent) - IPC_STRUCT_TRAITS_MEMBER(offset_) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::TouchEvent) - IPC_STRUCT_TRAITS_PARENT(ui::LocatedEvent) - IPC_STRUCT_TRAITS_MEMBER(touch_id_) - IPC_STRUCT_TRAITS_MEMBER(unique_event_id_) - IPC_STRUCT_TRAITS_MEMBER(rotation_angle_) - IPC_STRUCT_TRAITS_MEMBER(may_cause_scrolling_) - IPC_STRUCT_TRAITS_MEMBER(pointer_details_) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::DomKey) - IPC_STRUCT_TRAITS_MEMBER(value_) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::KeyEvent) - IPC_STRUCT_TRAITS_MEMBER(is_char_) - IPC_STRUCT_TRAITS_MEMBER(key_code_) - IPC_STRUCT_TRAITS_MEMBER(code_) - IPC_STRUCT_TRAITS_MEMBER(key_) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::ScrollEvent) - IPC_STRUCT_TRAITS_PARENT(ui::MouseEvent) - IPC_STRUCT_TRAITS_MEMBER(x_offset_) - IPC_STRUCT_TRAITS_MEMBER(y_offset_) - IPC_STRUCT_TRAITS_MEMBER(x_offset_ordinal_) - IPC_STRUCT_TRAITS_MEMBER(y_offset_ordinal_) - IPC_STRUCT_TRAITS_MEMBER(finger_count_) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::GestureEventDetails) - IPC_STRUCT_TRAITS_MEMBER(type_) - IPC_STRUCT_TRAITS_MEMBER(data_) - IPC_STRUCT_TRAITS_MEMBER(touch_points_) - IPC_STRUCT_TRAITS_MEMBER(bounding_box_) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(ui::GestureEvent) - IPC_STRUCT_TRAITS_PARENT(ui::LocatedEvent) - IPC_STRUCT_TRAITS_MEMBER(details_) -IPC_STRUCT_TRAITS_END() diff --git a/components/mus/common/event_param_traits_unittest.cc b/components/mus/common/event_param_traits_unittest.cc deleted file mode 100644 index 966f9ab..0000000 --- a/components/mus/common/event_param_traits_unittest.cc +++ /dev/null @@ -1,468 +0,0 @@ -// Copyright (c) 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/mus/common/event_param_traits.h" - -#include <limits> - -#include "ipc/ipc_message.h" -#include "ipc/ipc_param_traits.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/events/event.h" -#include "ui/events/event_constants.h" -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/rect_f.h" -#include "ui/gfx/geometry/vector2d.h" - -namespace ui { -namespace { - -#define CAST_EVENT(T, e) (*static_cast<const T*>(e.get())) -#define FEQ(a, b) (a == b || (std::isnan(a) && std::isnan(b))) -#define ASSERT_FEQ(a, b) ASSERT_TRUE(FEQ(a, b)) -#define MIN(T) std::numeric_limits<T>::min() -#define MAX(T) std::numeric_limits<T>::max() -#define IMIN MIN(int) -#define IMAX MAX(int) -#define FMIN MIN(float) -#define FMAX MAX(float) -#define FNAN std::numeric_limits<float>::quiet_NaN() - -class EventParamTraitsTest : public testing::Test { - protected: - // Implements event downcasting as performed by param traits. This enables - // testing the interface that client code actually uses: (de)serialization of - // scoped Event pointers that contain a concrete type. - static void CompareEvents(const ScopedEvent& a, const ScopedEvent& b) { - ASSERT_EQ(!!a, !!b); - ASSERT_EQ(a->type(), b->type()); - switch (a->type()) { - case EventType::ET_MOUSE_PRESSED: - case EventType::ET_MOUSE_DRAGGED: - case EventType::ET_MOUSE_RELEASED: - case EventType::ET_MOUSE_MOVED: - case EventType::ET_MOUSE_ENTERED: - case EventType::ET_MOUSE_EXITED: - case EventType::ET_MOUSE_CAPTURE_CHANGED: - Compare(CAST_EVENT(MouseEvent, a), CAST_EVENT(MouseEvent, b)); - break; - case EventType::ET_KEY_PRESSED: - case EventType::ET_KEY_RELEASED: - Compare(CAST_EVENT(KeyEvent, a), CAST_EVENT(KeyEvent, b)); - break; - case EventType::ET_MOUSEWHEEL: - Compare(CAST_EVENT(MouseWheelEvent, a), CAST_EVENT(MouseWheelEvent, b)); - break; - case EventType::ET_TOUCH_RELEASED: - case EventType::ET_TOUCH_PRESSED: - case EventType::ET_TOUCH_MOVED: - case EventType::ET_TOUCH_CANCELLED: - case EventType::ET_DROP_TARGET_EVENT: - Compare(CAST_EVENT(TouchEvent, a), CAST_EVENT(TouchEvent, b)); - break; - case EventType::ET_GESTURE_SCROLL_BEGIN: - case EventType::ET_GESTURE_SCROLL_END: - case EventType::ET_GESTURE_SCROLL_UPDATE: - case EventType::ET_GESTURE_SHOW_PRESS: - case EventType::ET_GESTURE_WIN8_EDGE_SWIPE: - case EventType::ET_GESTURE_TAP: - case EventType::ET_GESTURE_TAP_DOWN: - case EventType::ET_GESTURE_TAP_CANCEL: - case EventType::ET_GESTURE_BEGIN: - case EventType::ET_GESTURE_END: - case EventType::ET_GESTURE_TWO_FINGER_TAP: - case EventType::ET_GESTURE_PINCH_BEGIN: - case EventType::ET_GESTURE_PINCH_END: - case EventType::ET_GESTURE_PINCH_UPDATE: - case EventType::ET_GESTURE_LONG_PRESS: - case EventType::ET_GESTURE_LONG_TAP: - case EventType::ET_GESTURE_SWIPE: - case EventType::ET_GESTURE_TAP_UNCONFIRMED: - case EventType::ET_GESTURE_DOUBLE_TAP: - Compare(CAST_EVENT(GestureEvent, a), CAST_EVENT(GestureEvent, b)); - break; - case EventType::ET_SCROLL: - Compare(CAST_EVENT(ScrollEvent, a), CAST_EVENT(ScrollEvent, b)); - break; - case EventType::ET_SCROLL_FLING_START: - case EventType::ET_SCROLL_FLING_CANCEL: - ASSERT_EQ(!!a->flags() & MouseEventFlags::EF_FROM_TOUCH, - !!b->flags() & MouseEventFlags::EF_FROM_TOUCH); - if (a->flags() & MouseEventFlags::EF_FROM_TOUCH) { - Compare(CAST_EVENT(GestureEvent, a), CAST_EVENT(GestureEvent, b)); - } else { - Compare(CAST_EVENT(MouseEvent, a), CAST_EVENT(MouseEvent, b)); - } - break; - case EventType::ET_CANCEL_MODE: - Compare(CAST_EVENT(CancelModeEvent, a), CAST_EVENT(CancelModeEvent, b)); - break; - default: - NOTREACHED(); - } - } - -#undef CAST_EVENT - -#define CAST_EVENT(T, e) static_cast<const T&>(e) -#define COMPARE_BASE(T, a, b) Compare(CAST_EVENT(T, a), CAST_EVENT(T, b)) - - static void Compare(const Event& a, const Event& b) { - ASSERT_EQ(a.type(), b.type()); - ASSERT_EQ(a.name(), b.name()); - ASSERT_EQ(a.time_stamp(), b.time_stamp()); - ASSERT_EQ(a.flags(), b.flags()); - ASSERT_EQ(a.phase(), b.phase()); - ASSERT_EQ(a.result(), b.result()); - ASSERT_EQ(a.cancelable(), b.cancelable()); - ASSERT_EQ(a.IsShiftDown(), b.IsShiftDown()); - ASSERT_EQ(a.IsControlDown(), b.IsControlDown()); - ASSERT_EQ(a.IsAltDown(), b.IsAltDown()); - ASSERT_EQ(a.IsCommandDown(), b.IsCommandDown()); - ASSERT_EQ(a.IsAltGrDown(), b.IsAltGrDown()); - ASSERT_EQ(a.IsCapsLockOn(), b.IsCapsLockOn()); - ASSERT_EQ(a.IsKeyEvent(), b.IsKeyEvent()); - ASSERT_EQ(a.IsMouseEvent(), b.IsMouseEvent()); - ASSERT_EQ(a.IsTouchEvent(), b.IsTouchEvent()); - ASSERT_EQ(a.IsGestureEvent(), b.IsGestureEvent()); - ASSERT_EQ(a.IsEndingEvent(), b.IsEndingEvent()); - ASSERT_EQ(a.IsScrollEvent(), b.IsScrollEvent()); - ASSERT_EQ(a.IsScrollGestureEvent(), b.IsScrollGestureEvent()); - ASSERT_EQ(a.IsFlingScrollEvent(), b.IsFlingScrollEvent()); - ASSERT_EQ(a.IsMouseWheelEvent(), b.IsMouseWheelEvent()); - ASSERT_EQ(a.IsLocatedEvent(), b.IsLocatedEvent()); - ASSERT_EQ(a.handled(), b.handled()); - } - - static void Compare(const CancelModeEvent& a, const CancelModeEvent& b) { - COMPARE_BASE(Event, a, b); - } - - static void Compare(const LocatedEvent& a, const LocatedEvent& b) { - COMPARE_BASE(Event, a, b); - - ASSERT_EQ(a.x(), b.x()); - ASSERT_EQ(a.y(), b.y()); - ASSERT_EQ(a.location(), b.location()); - ASSERT_EQ(a.location_f(), b.location_f()); - ASSERT_EQ(a.root_location(), b.root_location()); - ASSERT_EQ(a.root_location_f(), b.root_location_f()); - } - - static void Compare(const MouseEvent& a, const MouseEvent& b) { - COMPARE_BASE(LocatedEvent, a, b); - - ASSERT_EQ(a.IsOnlyLeftMouseButton(), b.IsOnlyLeftMouseButton()); - ASSERT_EQ(a.IsLeftMouseButton(), b.IsLeftMouseButton()); - ASSERT_EQ(a.IsOnlyMiddleMouseButton(), b.IsOnlyMiddleMouseButton()); - ASSERT_EQ(a.IsMiddleMouseButton(), b.IsMiddleMouseButton()); - ASSERT_EQ(a.IsOnlyRightMouseButton(), b.IsOnlyRightMouseButton()); - ASSERT_EQ(a.IsRightMouseButton(), b.IsRightMouseButton()); - ASSERT_EQ(a.IsAnyButton(), b.IsAnyButton()); - ASSERT_EQ(a.button_flags(), b.button_flags()); - ASSERT_EQ(a.GetClickCount(), b.GetClickCount()); - ASSERT_EQ(a.changed_button_flags(), b.changed_button_flags()); - - Compare(a.pointer_details(), b.pointer_details()); - } - - static void Compare(const MouseWheelEvent& a, const MouseWheelEvent& b) { - COMPARE_BASE(MouseEvent, a, b); - - ASSERT_EQ(a.x_offset(), b.x_offset()); - ASSERT_EQ(a.y_offset(), b.y_offset()); - ASSERT_EQ(a.offset(), b.offset()); - } - - static void Compare(const TouchEvent& a, const TouchEvent& b) { - COMPARE_BASE(LocatedEvent, a, b); - - ASSERT_EQ(a.touch_id(), b.touch_id()); - ASSERT_EQ(a.unique_event_id(), b.unique_event_id()); - ASSERT_FEQ(a.rotation_angle(), b.rotation_angle()); - ASSERT_EQ(a.may_cause_scrolling(), b.may_cause_scrolling()); - ASSERT_EQ(a.synchronous_handling_disabled(), - b.synchronous_handling_disabled()); - - Compare(a.pointer_details(), b.pointer_details()); - } - - static void Compare(const KeyEvent& a, const KeyEvent& b) { - COMPARE_BASE(Event, a, b); - - ASSERT_EQ(a.GetCharacter(), b.GetCharacter()); - ASSERT_EQ(a.GetUnmodifiedText(), b.GetUnmodifiedText()); - ASSERT_EQ(a.GetText(), b.GetText()); - ASSERT_EQ(a.is_char(), b.is_char()); - ASSERT_EQ(a.is_repeat(), b.is_repeat()); - ASSERT_EQ(a.key_code(), b.key_code()); - ASSERT_EQ(a.GetLocatedWindowsKeyboardCode(), - b.GetLocatedWindowsKeyboardCode()); - ASSERT_EQ(a.GetConflatedWindowsKeyCode(), b.GetConflatedWindowsKeyCode()); - ASSERT_EQ(a.IsUnicodeKeyCode(), b.IsUnicodeKeyCode()); - ASSERT_EQ(a.code(), b.code()); - ASSERT_EQ(a.GetCodeString(), b.GetCodeString()); - ASSERT_EQ(a.GetDomKey(), b.GetDomKey()); - } - - static void Compare(const ScrollEvent& a, const ScrollEvent& b) { - COMPARE_BASE(MouseEvent, a, b); - - ASSERT_FEQ(a.x_offset(), b.x_offset()); - ASSERT_FEQ(a.y_offset(), b.y_offset()); - ASSERT_FEQ(a.x_offset_ordinal(), b.x_offset_ordinal()); - ASSERT_FEQ(a.y_offset_ordinal(), b.y_offset_ordinal()); - ASSERT_EQ(a.finger_count(), b.finger_count()); - } - - static void Compare(const GestureEvent& a, const GestureEvent& b) { - COMPARE_BASE(LocatedEvent, a, b); - - ASSERT_EQ(a.details(), b.details()); - } - - static void Compare(const PointerDetails& a, const PointerDetails& b) { - ASSERT_EQ(a.pointer_type, b.pointer_type); - ASSERT_FEQ(a.radius_x, b.radius_x); - ASSERT_FEQ(a.radius_y, b.radius_y); - ASSERT_FEQ(a.force, b.force); - ASSERT_FEQ(a.tilt_x, b.tilt_x); - ASSERT_FEQ(a.tilt_y, b.tilt_y); - } - - static void Verify(const ScopedEvent& event_in) { - IPC::Message msg; - IPC::ParamTraits<ScopedEvent>::Write(&msg, event_in); - - ScopedEvent event_out; - base::PickleIterator iter(msg); - EXPECT_TRUE(IPC::ParamTraits<ScopedEvent>::Read(&msg, &iter, &event_out)); - - CompareEvents(event_in, event_out); - - // Perform a sanity check that logging doesn't explode. - std::string event_in_string; - IPC::ParamTraits<ScopedEvent>::Log(event_in, &event_in_string); - std::string event_out_string; - IPC::ParamTraits<ScopedEvent>::Log(event_out, &event_out_string); - ASSERT_FALSE(event_in_string.empty()); - EXPECT_EQ(event_in_string, event_out_string); - } - - static GestureEventDetails CreateCornerCaseGestureEventDetails( - EventType type) { - GestureEventDetails details; - - // Only some types support |delta_x| and |delta_y| parameters. - if (type == EventType::ET_GESTURE_SCROLL_BEGIN || - type == EventType::ET_GESTURE_SCROLL_UPDATE || - type == EventType::ET_SCROLL_FLING_START || - type == EventType::ET_GESTURE_TWO_FINGER_TAP || - type == EventType::ET_GESTURE_SWIPE) { - details = GestureEventDetails(type, FMIN, FMAX); - } else { - details = GestureEventDetails(type); - } - - details.set_bounding_box(gfx::RectF(FMIN, FMAX, FNAN, FNAN)); - - // Note: Positive values and |type| check dodges DCHECKs that are not being - // tested here. - details.set_touch_points(IMAX); - if (type == EventType::ET_GESTURE_TAP || - type == EventType::ET_GESTURE_TAP_UNCONFIRMED || - type == EventType::ET_GESTURE_DOUBLE_TAP) { - details.set_tap_count(IMAX); - } - if (type == EventType::ET_GESTURE_PINCH_UPDATE) { - details.set_scale(FMAX); - } - - return details; - } -}; - -TEST_F(EventParamTraitsTest, GoodCancelModeEvent) { - ScopedEvent event(new CancelModeEvent()); - Verify(event); -} - -TEST_F(EventParamTraitsTest, GoodSimpleMouseEvent) { - EventType event_types[7] = { - EventType::ET_MOUSE_PRESSED, EventType::ET_MOUSE_DRAGGED, - EventType::ET_MOUSE_RELEASED, EventType::ET_MOUSE_MOVED, - EventType::ET_MOUSE_ENTERED, EventType::ET_MOUSE_EXITED, - EventType::ET_MOUSE_CAPTURE_CHANGED, - }; - for (int i = 0; i < 7; i++) { - ScopedEvent event(new MouseEvent(event_types[i], gfx::Point(), gfx::Point(), - base::TimeDelta(), 0, 0)); - Verify(event); - } -} - -TEST_F(EventParamTraitsTest, GoodCornerCaseMouseEvent) { - EventType event_types[7] = { - EventType::ET_MOUSE_PRESSED, EventType::ET_MOUSE_DRAGGED, - EventType::ET_MOUSE_RELEASED, EventType::ET_MOUSE_MOVED, - EventType::ET_MOUSE_ENTERED, EventType::ET_MOUSE_EXITED, - EventType::ET_MOUSE_CAPTURE_CHANGED, - }; - for (int i = 0; i < 7; i++) { - ScopedEvent event(new MouseEvent(event_types[i], gfx::Point(IMIN, IMIN), - gfx::Point(IMAX, IMAX), - base::TimeDelta::Max(), IMIN, IMAX)); - Verify(event); - } -} - -TEST_F(EventParamTraitsTest, GoodSimpleMouseWheelEvent) { - ScopedEvent event(new MouseWheelEvent(gfx::Vector2d(), gfx::Point(), - gfx::Point(), base::TimeDelta(), 0, 0)); - Verify(event); -} - -TEST_F(EventParamTraitsTest, GoodCornerCaseMouseWheelEvent) { - ScopedEvent event(new MouseWheelEvent( - gfx::Vector2d(IMIN, IMAX), gfx::Point(IMIN, IMIN), gfx::Point(IMAX, IMAX), - base::TimeDelta::Max(), IMIN, IMAX)); - Verify(event); -} - -TEST_F(EventParamTraitsTest, GoodSimpleTouchEvent) { - EventType event_types[5] = { - EventType::ET_TOUCH_RELEASED, EventType::ET_TOUCH_PRESSED, - EventType::ET_TOUCH_MOVED, EventType::ET_TOUCH_CANCELLED, - EventType::ET_DROP_TARGET_EVENT, - }; - for (int i = 0; i < 5; i++) { - ScopedEvent event(new TouchEvent(event_types[i], gfx::Point(), 0, 0, - base::TimeDelta(), 0.0, 0.0, 0.0, 0.0)); - Verify(event); - } -} - -TEST_F(EventParamTraitsTest, GoodCornerCaseTouchEvent) { - EventType event_types[5] = { - EventType::ET_TOUCH_RELEASED, EventType::ET_TOUCH_PRESSED, - EventType::ET_TOUCH_MOVED, EventType::ET_TOUCH_CANCELLED, - EventType::ET_DROP_TARGET_EVENT, - }; - for (int i = 0; i < 5; i++) { - ScopedEvent event(new TouchEvent(event_types[i], gfx::Point(IMIN, IMAX), - IMIN, IMAX, base::TimeDelta::Max(), FMIN, - FMAX, FNAN, FNAN)); - Verify(event); - } -} - -TEST_F(EventParamTraitsTest, GoodSimpleKeyEvent) { - EventType event_types[2] = { - EventType::ET_KEY_PRESSED, EventType::ET_KEY_RELEASED, - }; - for (int i = 0; i < 2; i++) { - ScopedEvent event(new KeyEvent(event_types[i], KeyboardCode::VKEY_UNKNOWN, - static_cast<DomCode>(0), 0, DomKey(0), - base::TimeDelta())); - Verify(event); - } -} - -TEST_F(EventParamTraitsTest, GoodCornerCaseKeyEvent) { - EventType event_types[2] = { - EventType::ET_KEY_PRESSED, EventType::ET_KEY_RELEASED, - }; - for (int i = 0; i < 2; i++) { - ScopedEvent event(new KeyEvent(event_types[i], KeyboardCode::VKEY_OEM_CLEAR, - static_cast<DomCode>(0x0c028c), IMIN, - MIN(DomKey), base::TimeDelta::Max())); - Verify(event); - } -} - -TEST_F(EventParamTraitsTest, GoodSimpleScrollEvent) { - ScopedEvent event(new ScrollEvent(EventType::ET_SCROLL, gfx::Point(), - base::TimeDelta(), 0, 0.0, 0.0, 0.0, 0.0, - 0)); - Verify(event); -} - -TEST_F(EventParamTraitsTest, GoodCornerCaseScrollEvent) { - ScopedEvent event(new ScrollEvent(EventType::ET_SCROLL, gfx::Point(), - base::TimeDelta(), IMIN, FMIN, FMAX, FNAN, - FMIN, IMAX)); - Verify(event); -} - -TEST_F(EventParamTraitsTest, GoodSimpleGestureEvent) { - EventType event_types[19] = { - EventType::ET_GESTURE_SCROLL_BEGIN, - EventType::ET_GESTURE_SCROLL_END, - EventType::ET_GESTURE_SCROLL_UPDATE, - EventType::ET_GESTURE_SHOW_PRESS, - EventType::ET_GESTURE_WIN8_EDGE_SWIPE, - EventType::ET_GESTURE_TAP, - EventType::ET_GESTURE_TAP_DOWN, - EventType::ET_GESTURE_TAP_CANCEL, - EventType::ET_GESTURE_BEGIN, - EventType::ET_GESTURE_END, - EventType::ET_GESTURE_TWO_FINGER_TAP, - EventType::ET_GESTURE_PINCH_BEGIN, - EventType::ET_GESTURE_PINCH_END, - EventType::ET_GESTURE_PINCH_UPDATE, - EventType::ET_GESTURE_LONG_PRESS, - EventType::ET_GESTURE_LONG_TAP, - EventType::ET_GESTURE_SWIPE, - EventType::ET_GESTURE_TAP_UNCONFIRMED, - EventType::ET_GESTURE_DOUBLE_TAP, - }; - for (int i = 0; i < 19; i++) { - ScopedEvent event(new GestureEvent(0.0, 0.0, 0, base::TimeDelta(), - GestureEventDetails(event_types[i]))); - Verify(event); - } -} - -TEST_F(EventParamTraitsTest, GoodCornerCaseGestureEvent) { - EventType event_types[17] = { - EventType::ET_GESTURE_SCROLL_UPDATE, - EventType::ET_GESTURE_SHOW_PRESS, - EventType::ET_GESTURE_WIN8_EDGE_SWIPE, - EventType::ET_GESTURE_TAP, - EventType::ET_GESTURE_TAP_DOWN, - EventType::ET_GESTURE_TAP_CANCEL, - EventType::ET_GESTURE_BEGIN, - EventType::ET_GESTURE_END, - EventType::ET_GESTURE_TWO_FINGER_TAP, - EventType::ET_GESTURE_PINCH_BEGIN, - EventType::ET_GESTURE_PINCH_END, - EventType::ET_GESTURE_PINCH_UPDATE, - EventType::ET_GESTURE_LONG_PRESS, - EventType::ET_GESTURE_LONG_TAP, - EventType::ET_GESTURE_SWIPE, - EventType::ET_GESTURE_TAP_UNCONFIRMED, - EventType::ET_GESTURE_DOUBLE_TAP, - }; - for (int i = 0; i < 17; i++) { - ScopedEvent event( - new GestureEvent(0.0, 0.0, 0, base::TimeDelta(), - CreateCornerCaseGestureEventDetails(event_types[i]))); - Verify(event); - } -} - -#undef FEQ -#undef ASSERT_FEQ -#undef CAST_EVENT -#undef COMPARE_BASE -#undef MIN -#undef MAX -#undef IMIN -#undef IMAX -#undef FMIN -#undef FMAX -#undef FNAN - -} // namespace -} // namespace ui diff --git a/components/mus/common/mus_common_export.h b/components/mus/common/mus_common_export.h deleted file mode 100644 index 3a2e930..0000000 --- a/components/mus/common/mus_common_export.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_MUS_COMMON_MUS_COMMON_EXPORT_H_ -#define COMPONENTS_MUS_COMMON_MUS_COMMON_EXPORT_H_ - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(MUS_IPC_IMPLEMENTATION) -#define MUS_COMMON_EXPORT __declspec(dllexport) -#else -#define MUS_COMMON_EXPORT __declspec(dllimport) -#endif // defined(MUS_IPC_IMPLEMENTATION) - -#else // defined(WIN32) -#if defined(MUS_IPC_IMPLEMENTATION) -#define MUS_COMMON_EXPORT __attribute__((visibility("default"))) -#else -#define MUS_COMMON_EXPORT -#endif -#endif - -#else // defined(COMPONENT_BUILD) -#define MUS_COMMON_EXPORT -#endif - -#endif // COMPONENTS_MUS_COMMON_MUS_COMMON_EXPORT_H_ diff --git a/components/mus/public/cpp/BUILD.gn b/components/mus/public/cpp/BUILD.gn index d750a9d..b2bb6df 100644 --- a/components/mus/public/cpp/BUILD.gn +++ b/components/mus/public/cpp/BUILD.gn @@ -49,7 +49,7 @@ source_set("cpp") { "//cc", "//cc/surfaces", "//cc/surfaces:surface_id", - "//components/mus/common:mus_common", + "//components/mus/common", "//mojo/converters/geometry", "//mojo/converters/surfaces", "//mojo/gles2", diff --git a/components/mus/public/cpp/tests/BUILD.gn b/components/mus/public/cpp/tests/BUILD.gn index f89b23f..dde0ebf 100644 --- a/components/mus/public/cpp/tests/BUILD.gn +++ b/components/mus/public/cpp/tests/BUILD.gn @@ -49,7 +49,7 @@ test("mojo_view_manager_lib_unittests") { ":unittest_support", "//base", "//base/test:test_support", - "//components/mus/common:mus_common", + "//components/mus/common", "//components/mus/public/cpp", "//mojo/common:common_base", "//mojo/converters/geometry", diff --git a/components/mus/ws/BUILD.gn b/components/mus/ws/BUILD.gn index 728d33f..ec8e702 100644 --- a/components/mus/ws/BUILD.gn +++ b/components/mus/ws/BUILD.gn @@ -71,7 +71,7 @@ source_set("lib") { "//cc", "//cc/surfaces", "//cc/surfaces:surface_id", - "//components/mus/common:mus_common", + "//components/mus/common", "//components/mus/gles2", "//components/mus/public/interfaces", "//components/mus/surfaces", @@ -109,7 +109,7 @@ source_set("test_support") { deps = [ "//base", - "//components/mus/common:mus_common", + "//components/mus/common", "//components/mus/public/cpp", "//components/mus/public/interfaces", "//mojo/common", @@ -151,7 +151,7 @@ test("window_manager_unittests") { "//base", "//base/test:test_config", "//cc:cc", - "//components/mus/common:mus_common", + "//components/mus/common", "//components/mus/public/cpp", "//components/mus/public/interfaces", "//components/mus/surfaces", @@ -191,7 +191,7 @@ mojo_native_application("apptests") { ":test_support", "//base", "//base/test:test_config", - "//components/mus/common:mus_common", + "//components/mus/common", "//components/mus/public/cpp", "//components/mus/public/cpp/tests:test_support", "//components/mus/public/interfaces", diff --git a/mash/wm/BUILD.gn b/mash/wm/BUILD.gn index 935186c..bc62208 100644 --- a/mash/wm/BUILD.gn +++ b/mash/wm/BUILD.gn @@ -70,7 +70,7 @@ source_set("lib") { deps = [ "//base", - "//components/mus/common:mus_common", + "//components/mus/common", "//components/mus/public/cpp", "//components/mus/public/interfaces", "//mash/shell/public/interfaces", diff --git a/ui/events/event.cc b/ui/events/event.cc index ca6704b6..21add83 100644 --- a/ui/events/event.cc +++ b/ui/events/event.cc @@ -844,9 +844,6 @@ bool KeyEvent::IsRepeated(const KeyEvent& event) { return false; } -KeyEvent::KeyEvent(EventType type, base::TimeDelta time_stamp, int flags) - : Event(type, time_stamp, flags) {} - KeyEvent::KeyEvent(const base::NativeEvent& native_event) : Event(native_event, EventTypeFromNative(native_event), diff --git a/ui/events/event.h b/ui/events/event.h index ca383d7..35999bf 100644 --- a/ui/events/event.h +++ b/ui/events/event.h @@ -6,6 +6,7 @@ #define UI_EVENTS_EVENT_H_ #include <stdint.h> + #include "base/compiler_specific.h" #include "base/event_types.h" #include "base/gtest_prod_util.h" @@ -26,10 +27,6 @@ namespace gfx { class Transform; } -namespace IPC { -template <class P> struct ParamTraits; -} - namespace ui { class EventTarget; class KeyEvent; @@ -39,10 +36,6 @@ class PointerEvent; class ScrollEvent; class TouchEvent; enum class DomCode; -class Event; -class MouseWheelEvent; - -using ScopedEvent = scoped_ptr<Event>; class EVENTS_EXPORT Event { public: @@ -289,9 +282,6 @@ class EVENTS_EXPORT Event { private: friend class EventTestApi; - // For (de)serialization. - friend struct IPC::ParamTraits<ui::ScopedEvent>; - EventType type_; std::string name_; base::TimeDelta time_stamp_; @@ -313,13 +303,6 @@ class EVENTS_EXPORT CancelModeEvent : public Event { public: CancelModeEvent(); ~CancelModeEvent() override; - - private: - // For (de)serialization. - CancelModeEvent(EventType type, base::TimeDelta time_stamp, int flags) - : Event(type, time_stamp, flags) {} - friend struct IPC::ParamTraits<ui::ScopedEvent>; - friend struct IPC::ParamTraits<ui::CancelModeEvent>; }; class EVENTS_EXPORT LocatedEvent : public Event { @@ -363,13 +346,6 @@ class EVENTS_EXPORT LocatedEvent : public Event { protected: friend class LocatedEventTestApi; - - // For (de)serialization. - LocatedEvent(EventType type, base::TimeDelta time_stamp, int flags) - : Event(type, time_stamp, flags) {} - friend struct IPC::ParamTraits<ui::ScopedEvent>; - friend struct IPC::ParamTraits<ui::LocatedEvent>; - explicit LocatedEvent(const base::NativeEvent& native_event); // Create a new LocatedEvent which is identical to the provided model. @@ -430,9 +406,6 @@ struct EVENTS_EXPORT PointerDetails { tilt_y == other.tilt_y; } - // For serialization. - friend struct IPC::ParamTraits<ui::PointerDetails>; - // The type of pointer device. EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN; @@ -552,13 +525,6 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent { pointer_details_ = details; } - protected: - // For (de)serialization. - MouseEvent(EventType type, base::TimeDelta time_stamp, int flags) - : LocatedEvent(type, time_stamp, flags) {} - friend struct IPC::ParamTraits<ui::ScopedEvent>; - friend struct IPC::ParamTraits<ui::MouseEvent>; - private: FRIEND_TEST_ALL_PREFIXES(EventTest, DoubleClickRequiresRelease); FRIEND_TEST_ALL_PREFIXES(EventTest, SingleClickRightLeft); @@ -619,12 +585,6 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent { const gfx::Vector2d& offset() const { return offset_; } private: - // For (de)serialization. - MouseWheelEvent(EventType type, base::TimeDelta time_stamp, int flags) - : MouseEvent(type, time_stamp, flags) {} - friend struct IPC::ParamTraits<ui::ScopedEvent>; - friend struct IPC::ParamTraits<ui::MouseWheelEvent>; - gfx::Vector2d offset_; }; @@ -697,22 +657,15 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent { } private: - // For (de)serialization. - TouchEvent(EventType type, base::TimeDelta time_stamp, int flags) - : LocatedEvent(type, time_stamp, flags), - should_remove_native_touch_id_mapping_(false) {} - friend struct IPC::ParamTraits<ui::ScopedEvent>; - friend struct IPC::ParamTraits<ui::TouchEvent>; - // Adjusts rotation_angle_ to within the acceptable range. void FixRotationAngle(); // The identity (typically finger) of the touch starting at 0 and incrementing // for each separable additional touch that the hardware can detect. - int touch_id_; + const int touch_id_; // A unique identifier for the touch event. - uint32_t unique_event_id_; + const uint32_t unique_event_id_; // Clockwise angle (in degrees) of the major axis from the X axis. Must be // less than 180 and non-negative. @@ -922,11 +875,6 @@ class EVENTS_EXPORT KeyEvent : public Event { void set_is_char(bool is_char) { is_char_ = is_char; } private: - // For (de)serialization. - KeyEvent(EventType type, base::TimeDelta time_stamp, int flags); - friend struct IPC::ParamTraits<ui::ScopedEvent>; - friend struct IPC::ParamTraits<ui::KeyEvent>; - // Determine key_ on a keystroke event from code_ and flags(). void ApplyLayout() const; @@ -1005,12 +953,6 @@ class EVENTS_EXPORT ScrollEvent : public MouseEvent { int finger_count() const { return finger_count_; } private: - // For (de)serialization. - ScrollEvent(EventType type, base::TimeDelta time_stamp, int flags) - : MouseEvent(type, time_stamp, flags) {} - friend struct IPC::ParamTraits<ui::ScopedEvent>; - friend struct IPC::ParamTraits<ui::ScrollEvent>; - // Potential accelerated offsets. float x_offset_; float y_offset_; @@ -1043,12 +985,6 @@ class EVENTS_EXPORT GestureEvent : public LocatedEvent { const GestureEventDetails& details() const { return details_; } private: - // For (de)serialization. - GestureEvent(EventType type, base::TimeDelta time_stamp, int flags) - : LocatedEvent(type, time_stamp, flags) {} - friend struct IPC::ParamTraits<ui::ScopedEvent>; - friend struct IPC::ParamTraits<ui::GestureEvent>; - GestureEventDetails details_; }; diff --git a/ui/events/events.gyp b/ui/events/events.gyp index b905a48..4a9d471 100644 --- a/ui/events/events.gyp +++ b/ui/events/events.gyp @@ -312,7 +312,6 @@ 'sources': [ 'ipc/latency_info_param_traits.cc', 'ipc/latency_info_param_traits.h', - 'ipc/latency_info_param_traits_macros.h', ], }, { @@ -389,4 +388,4 @@ ], }], ], -} +}
\ No newline at end of file diff --git a/ui/events/gesture_event_details.h b/ui/events/gesture_event_details.h index 6a79a4a..ff88041 100644 --- a/ui/events/gesture_event_details.h +++ b/ui/events/gesture_event_details.h @@ -5,18 +5,12 @@ #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ -#include <string.h> - #include "base/logging.h" #include "ui/events/event_constants.h" #include "ui/events/events_base_export.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_conversions.h" -namespace IPC { -template <class P> struct ParamTraits; -} - namespace ui { struct EVENTS_BASE_EXPORT GestureEventDetails { @@ -143,14 +137,6 @@ struct EVENTS_BASE_EXPORT GestureEventDetails { return data_.scroll_update.previous_update_in_sequence_prevented; } - // Supports comparison over internal structures for testing. - bool operator==(const GestureEventDetails& other) const { - return type_ == other.type_ && - !memcmp(&data_, &other.data_, sizeof(Details)) && - touch_points_ == other.touch_points_ && - bounding_box_ == other.bounding_box_; - } - private: EventType type_; union Details { @@ -196,10 +182,6 @@ struct EVENTS_BASE_EXPORT GestureEventDetails { int tap_count; // TAP repeat count. } data_; - // For mojo native implementation of (de)serialization. - friend struct IPC::ParamTraits<ui::GestureEventDetails>; - friend struct IPC::ParamTraits<ui::GestureEventDetails::Details>; - int touch_points_; // Number of active touch points in the gesture. // Bounding box is an axis-aligned rectangle that contains all the diff --git a/ui/events/ipc/BUILD.gn b/ui/events/ipc/BUILD.gn index 975b875..f7eaf88 100644 --- a/ui/events/ipc/BUILD.gn +++ b/ui/events/ipc/BUILD.gn @@ -9,7 +9,6 @@ component("events_ipc") { sources = [ "latency_info_param_traits.cc", "latency_info_param_traits.h", - "latency_info_param_traits_macros.h", ] defines = [ "EVENTS_IPC_IMPLEMENTATION" ] diff --git a/ui/events/keycodes/dom/dom_key.h b/ui/events/keycodes/dom/dom_key.h index 810f821..cb4b5ee 100644 --- a/ui/events/keycodes/dom/dom_key.h +++ b/ui/events/keycodes/dom/dom_key.h @@ -8,7 +8,6 @@ #include <stdint.h> #include "base/logging.h" -#include "ipc/ipc_param_traits.h" namespace ui { @@ -148,8 +147,6 @@ class DomKey { }; private: - friend struct IPC::ParamTraits<ui::DomKey>; - Base value_; }; diff --git a/ui/gfx/ipc/gfx_param_traits.cc b/ui/gfx/ipc/gfx_param_traits.cc index e800fef..1e5d612 100644 --- a/ui/gfx/ipc/gfx_param_traits.cc +++ b/ui/gfx/ipc/gfx_param_traits.cc @@ -81,12 +81,6 @@ void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) { l->append(base::StringPrintf("(%d, %d)", p.x(), p.y())); } -void ParamTraits<gfx::PointF>::GetSize(base::PickleSizer* s, - const gfx::PointF& p) { - GetParamSize(s, p.x()); - GetParamSize(s, p.y()); -} - void ParamTraits<gfx::PointF>::Write(base::Pickle* m, const gfx::PointF& p) { WriteParam(m, p.x()); WriteParam(m, p.y()); @@ -176,11 +170,6 @@ void ParamTraits<gfx::SizeF>::Log(const gfx::SizeF& p, std::string* l) { l->append(base::StringPrintf("(%f, %f)", p.width(), p.height())); } -void ParamTraits<gfx::Vector2d>::GetSize(base::PickleSizer* s, - const gfx::Vector2d& p) { - s->AddBytes(sizeof(int) * 2); -} - void ParamTraits<gfx::Vector2d>::Write(base::Pickle* m, const gfx::Vector2d& p) { int values[2] = { p.x(), p.y() }; @@ -248,11 +237,6 @@ void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { p.width(), p.height())); } -void ParamTraits<gfx::RectF>::GetSize(base::PickleSizer* s, - const gfx::RectF& p) { - s->AddBytes(sizeof(float) * 4); -} - void ParamTraits<gfx::RectF>::Write(base::Pickle* m, const gfx::RectF& p) { float values[4] = { p.x(), p.y(), p.width(), p.height() }; m->WriteBytes(&values, sizeof(float) * 4); diff --git a/ui/gfx/ipc/gfx_param_traits.h b/ui/gfx/ipc/gfx_param_traits.h index e22d0a6..55c1b85 100644 --- a/ui/gfx/ipc/gfx_param_traits.h +++ b/ui/gfx/ipc/gfx_param_traits.h @@ -48,7 +48,6 @@ struct GFX_IPC_EXPORT ParamTraits<gfx::Point> { template <> struct GFX_IPC_EXPORT ParamTraits<gfx::PointF> { typedef gfx::PointF param_type; - static void GetSize(base::PickleSizer* s, const param_type& p); static void Write(base::Pickle* m, const param_type& p); static bool Read(const base::Pickle* m, base::PickleIterator* iter, @@ -89,7 +88,6 @@ struct GFX_IPC_EXPORT ParamTraits<gfx::SizeF> { template <> struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2d> { typedef gfx::Vector2d param_type; - static void GetSize(base::PickleSizer* s, const param_type& p); static void Write(base::Pickle* m, const param_type& p); static bool Read(const base::Pickle* m, base::PickleIterator* iter, @@ -120,7 +118,6 @@ struct GFX_IPC_EXPORT ParamTraits<gfx::Rect> { template <> struct GFX_IPC_EXPORT ParamTraits<gfx::RectF> { typedef gfx::RectF param_type; - static void GetSize(base::PickleSizer* s, const param_type& p); static void Write(base::Pickle* m, const param_type& p); static bool Read(const base::Pickle* m, base::PickleIterator* iter, diff --git a/ui/metro_viewer/metro_viewer_messages.h b/ui/metro_viewer/metro_viewer_messages.h index 72428f5..8dfab4d 100644 --- a/ui/metro_viewer/metro_viewer_messages.h +++ b/ui/metro_viewer/metro_viewer_messages.h @@ -15,6 +15,22 @@ #define IPC_MESSAGE_START MetroViewerMsgStart +IPC_ENUM_TRAITS(ui::EventType) +IPC_ENUM_TRAITS(ui::EventFlags) + +// Contains the parameters sent for a mousebutton message. +IPC_STRUCT_BEGIN(MetroViewerHostMsg_MouseButtonParams) + + IPC_STRUCT_MEMBER(int32_t, x) + IPC_STRUCT_MEMBER(int32_t, y) + IPC_STRUCT_MEMBER(int32_t, extra) + IPC_STRUCT_MEMBER(ui::EventType, event_type) + IPC_STRUCT_MEMBER(uint32_t, flags) + IPC_STRUCT_MEMBER(ui::EventFlags, changed_button) + IPC_STRUCT_MEMBER(bool, is_horizontal_wheel) + +IPC_STRUCT_END() + // Messages sent from the viewer to the browser: // Inform the browser of the surface to target for compositing. @@ -26,6 +42,9 @@ IPC_MESSAGE_CONTROL3(MetroViewerHostMsg_MouseMoved, int32_t, /* x-coordinate */ int32_t, /* y-coordinate */ int32_t /* flags */) +// Informs the brower that a mouse button was pressed. +IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_MouseButton, + MetroViewerHostMsg_MouseButtonParams) // Informs the browser that a key was pressed. IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_KeyDown, uint32_t, /* virtual key */ |